Re: Ten Commandments for Fortran Programming?
- From: Gary Scott <garylscott@xxxxxxxxxxxxx>
- Date: Fri, 01 Sep 2006 22:50:16 GMT
Walter Spector wrote:
Stanislaus wrote:
Are there any code styles for Fortran? Official or not. And what do you
prefer?
Perhaps this should be an FAQ response for this newsgroup? What do others
think? (All constructive additions/deletions/commentary appreciated!)
Walt
---------------------------------------------------------------------------
Ten Commandments for Fortran Programming
comp.lang.fortran
(DRAFT v0.1)
1.) Thou shalt use IMPLICIT NONE in every program unit.
Good, but it would be better if it were the default.
2.) Thou shalt CONTAIN every subroutine and function.
Except when required to create Fortran 77 compatible libraries or libraries to be shared with other languages...
3.) Thou shalt use self-explanatory variable names.
Good, but don't go overboard. Not everybody is a blazing typist. What about naming conventions that require a prefix identifying variable type and/or other information?
4.) Thou shalt comment thy code accurately, but not excessively.
Good. Thou shalt use inline comments in order to compress source code where feasible, for example a list of variable declarations, rather than one whole line comment, one variable declaration, one whole line comment...
5.) Thou shalt honor and use the current Fortran Standard; for it
is good, and powerful, and most vendors are striving to follow it.
Can't, no compilers available.
6.) Thou shalt PARAMETERize "magic numbers". In one place.
Good, probably a module.
7.) Thou shalt use ALLOCATABLE sizing for major arrays.
Depends on who they are used...
8.) Thou shalt indent the interior of every block construct.
Good. Thou shalt indent the corresponding "end" statement at the same indention position as the "start" statement.
9. Thou shalt strive to avoid GOTO statements, POINTERs, and COMMON blocks,
unless there is no other way.
Key word "strive". Almost any application calling an OS API will require pointers. That is the vast majority of applications.
10.) Thou shalt test for, and handle, errors whenever practical; for core
dumps are bad for end-users morale.
They are bad for the application programmer's reputation also.
--
Gary Scott
mailto:garylscott@sbcglobal dot net
Fortran Library: http://www.fortranlib.com
Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html
Why are there two? God only knows.
If you want to do the impossible, don't hire an expert because he knows it can't be done.
-- Henry Ford
.
- Follow-Ups:
- Re: Ten Commandments for Fortran Programming?
- From: Brooks Moses
- Re: Ten Commandments for Fortran Programming?
- From: Dan Nagle
- Re: Ten Commandments for Fortran Programming?
- References:
- Ten Commandments for Fortran Programming?
- From: Walter Spector
- Ten Commandments for Fortran Programming?
- Prev by Date: Re: Crash of dlincg
- Next by Date: Re: Crash of dlincg
- Previous by thread: Re: Ten Commandments for Fortran Programming?
- Next by thread: Re: Ten Commandments for Fortran Programming?
- Index(es):
Relevant Pages
|