LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-18-2022, 03:37 PM   #1
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
Style question, fortran


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
 
Old 05-18-2022, 04:41 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,757

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
Homework?
 
Old 05-18-2022, 09:28 PM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,683
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Obviously, the use of a meaningful symbolic constant or symbol, such as int16, is preferable to a meaningless kind=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.
 
1 members found this post helpful.
Old 05-19-2022, 08:40 AM   #4
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851

Original Poster
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
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?
 
Old 05-19-2022, 08:58 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,683
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
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.
 
Old 05-19-2022, 10:41 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 5,757

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
Quote:
Originally Posted by sundialsvcs View Post
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!

Last edited by wpeckham; 05-19-2022 at 10:43 AM.
 
Old 05-19-2022, 12:37 PM   #7
mostlyharmless
Senior Member
 
Registered: Jan 2008
Distribution: Arch/Manjaro, might try Slackware again
Posts: 1,851

Original Poster
Blog Entries: 14

Rep: Reputation: 284Reputation: 284Reputation: 284
Quote:
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
g77 in gcc 4.1.0 not found only gfortran fortran 95 compiler! I need fortran 77. TheBrick Linux - Software 3 07-04-2007 06:39 AM
Gnu Fortran versus Intel Fortran tomatoefish Linux - Software 3 02-20-2006 01:31 PM
does linux fortran compiler in fedora 4 support VAX FORTRAN? terrence Programming 17 08-31-2005 08:59 AM
VIM-style wrapping to OpenOffice style schmmd Linux - Software 1 12-21-2004 06:50 PM
how to change mandrake style menu to kde style menu msalimane Mandriva 1 12-07-2004 01:16 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration