-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What constitutes idiomatic Fortran? #12
Comments
Well, the obvious one would be operations on entire arrays. Another would
|
@rouson Great discussion! 👏 @cmacmackin I have experienced some problems overloading derived type name with Intel Fortran, see this. Do you have similar issues? |
@szaghi I haven't used ifort extensively enough to be able to say. On 21/01/16 09:09, Stefano Zaghi wrote:
Chris MacMackin |
Yes - there have been issues with overloading structure constructors in ifort. Many have been fixed, but I believe I’ve still seen at least one case with version 16. The usual symptom is that some higher level procedure will generate an error indicating that the compiler thinks the constructor is the type or vice versa. Often reordering the USE statements can get around this symptom. But in many instances I’ve had to go back and rename the constructor. Usually something like “newFoo” to make the intent clear.
Thomas Clune, Ph. D. [email protected] |
@tclune Thanks for your support! |
Unfortunately, the first thing that occurs to me as idiomatic Fortran are the consistent bad practices that are used throughout the community. E.g., using short variable names, long procedures, etc. Sad but true.
Thomas Clune, Ph. D. [email protected] |
I suggest that from here on we refer to idiomatic Fortran code as being simply fortranic! 😄 |
👏 |
😄 |
Never mind. I spelled “ISO_FORTRAN_ENV” as “ISO_C_BINDING” and got unlucky that the first error was for INT16. Getting some caffeine …
Thomas Clune, Ph. D. [email protected] |
In my experience "ideomatic lang" was something I first heard about python, and the usage of the word is mainly found there. For that language the concept is a result of active and centralized work with style guides and I etiquette, and I think this is a way of handling the freedom the language allows. For instance, many things in python are enforced by convention rather than by the specification/reference implementation; private methods are made private by name wrangling and filtering of the interpreter rather than by actual enforcement of privacy. Fortran was created before there where language style guides, and does not have any natural centre that can impose a style upon the followers in the same way that python has the benevolent dictator for life. |
@Tobychev, thanks for these great insights. I'll take this opportunity to put in a plug for Modern Fortran: Style and Usage by Coleman and Specter. |
I recently used the term "Fortran idioms" or possibly "idiomatic Fortran" on comp.lang.fortran and someone commented that they weren't sure such a thing exists, which makes me think that it should exist if it doesn't. I see the term "idiom" in discussions of common practices in other languages. I interpret it as being the common way one does things when she really knows the language's full range of capabilities and chooses the most powerful or succinct or transparent and expressive way to accomplish the goal. By comparison, there's a whole book on writing idiomatic Python.
I think of idiomatic Fortran as using things such as array constructors to do in one line what would require a loop in some other languages:
real, allocatable :: positive_integers(:)
positive_integers = [(i,i=1,100)]
Is there such a thing as idiomatic Fortran?
Would it be another reasonable name for "Best Practices"?
Are there other examples of practices you would consider to be natural idioms that an experienced Fortran programmer might use, but that a newcomer to the language -- especially one whose primary experience is in one of the other common scientific programming languages -- would likely do in a less elegant way?
Damian
The text was updated successfully, but these errors were encountered: