ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Perhaps this should be a poll. Is there a preference for either declaring an integer like:
integer(kind=2) :: Integer1
or
integer(int16) :: Integer2
with the latter using ISO_FORTRAN_ENV
Portability? Style? Or have I had the cheek to ask about Earendil in Elrond's house, and the whole thing is over my head?
Bonus question: what's the majority take on using capital letters in declarations such as
INTEGER(KIND=2) :: Integer1 or INTEGER(INT16) :: Integer2
Obviously, the use of a meaningful symbolic constant or symbol, such as int16, is preferable to a meaninglesskind=2.
If the language ignores "UPPER" versus "lower" case, then the appropriate thing to do is to continue the practice that appears to have been followed in the source-code file that you are now working with. Strive to make your "new code" indistinguishable from the code that is already there.
Last edited by sundialsvcs; 05-18-2022 at 09:30 PM.
Thanks for the replies! Perhaps I could have been clearer with the intent of my question:
@wpeckham I feel a bit as though someone asked me for my ID at the liquor store. So, er, thanks, I guess. No, not homework, I have what has been called a terminal degree and am well past the formal education part of my life.
@sundialsvcs The code is all mine, and new. I started writing code in the late 70's and only recently came back to it, as a hobby. Fortran has changed quite a lot, as has programming style and recommendations in general. When and if I share it with the outside world, I'd prefer to be following whatever are considered current best practices in the Fortran coding community, just as I'd rather dress in public in a 2022 style rather than a 1972 style. The "kind=" seems to be older, but has apparently changed in meaning and possibly is compiler dependent. It also reminds me somewhat of the dreadful "CASE/SWITCH" for some reason.
But perhaps it has some advantage that I'm unaware of compared to using "int8" and requiring the use of a "use ISO_FORTRAN_ENV, intrinsic, only: INT8" statement in every program that uses it. On the other hand it is nice to be exact and it is a nice complement to the "use, intrinsic :: iso_c_binding" declarations for interoperability with c and c++ code.
The "intrinsic" qualifier doesn't always seem necessary to the gnu compiler either, which is weird.
As you might imagine, I find it esthetically a little challenging to have everything in lowercase, and personally find at least the declarations in all caps more normal. Of course I also still have a tendency to name all my integers with names beginning in "i,j,k" also! I've started making variable names with mixed case that are human readable, like MaxValue though.
So, any (modern) Fortran programmers out there: what do you all do?
I would prefer to see int16, because it "means something to me," rather than type=2, which would send me looking for the reference manual. As for other things like character case, the only thing I really want to see in source code is consistency.
As for other things like character case, the only thing I really want to see in source code is consistency.
I agree. Some things are mandated by the language, or more often the compiler, but after that the important thing is to set a coding standard that helps you to read, understand, and maintain your code: then stick with it unless doing so becomes painful.
PS. I am over 70, recently retired from both military and corporate work, and would head back for another degree were it not so freaking expensive. You are NEVER beyond learning as long as your brain still fires up!
You are NEVER beyond learning as long as your brain still fires up!
Agree about the learning, not sure I need another piece of paper on the wall in exchange for a lot of smaller pieces of paper. If I were retired, and money no object, I might like auditing classes, and would probably get suckered into a degree program, all assuming they would take me despite too many priors and superannuation.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.