1's blog

Peddling with commons brought me this experience:

Best to put them in an INCLUDE file which then has a similar purpouse as a header file in other languages.

Now, there is something really scary. Eventhough those blocks should have the purpouse of preserving the variable values between different units, it may happen that a block ends up with undefined values upon exit from e.g. a subroutine! This could take place if the block data is not shared between the unit which calls the subroutine and the called subroutine. To give an example, let there be common block /DAT/ in subrotine fB and fC. You, the novice fortran programmer, would probably think - "hmm, if i call fB it will do what I want it to do with /DAT/ and

1 What Is Fortran?

Fortran is the most widely used programming language in the world for numerical applications. It has achieved this position partly by being on the scene earlier than any of the other major languages and partly because it seems gradually to have evolved the features which its users, especially scientists and engineers, found most useful. In order to retain compatibility with old programs, Fortran has advanced mainly by adding new features rather than by removing old ones. The net result is, of course, that some parts of the language are, by present standards, rather archaic: some of these can be avoided easily, others can still be a nuisance.

In my (short) experience, what following is completely true:

From senator-bedfellow.mit.edu!bloom-beacon.mit.edu!apollo.hp.com!lf.hp.com!news.dtc.hp.com!col.hp.com!usenet.eel.ufl.edu!spool.mu.edu!howland.reston.ans.net!gatech2!swrinde!cs.utexas.edu!utnut!nott!cu23.crl.aecl.ca!usenet Tue Dec 12 12:52:20 1995
Newsgroups: comp.lang.fortran
Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!apollo.hp.com!lf.hp.com!news.dtc.hp.com!col.hp.com!usenet.eel.ufl.edu!spool.mu.edu!howland.reston.ans.net!gatech2!swrinde!cs.utexas.edu!utnut!nott!cu23.crl.aecl.ca!usenet
From: ..... (Glen Reesor)
Subject: Fortran Coding Style for the Modern Programmer
X-Nntp-Posting-Host: .....
Message-ID: <.....>
Sender: ..... (USENET News System)
Organization: AECL-Research
X-Newsreader: knews 0.9.3

First:

If you can, avoid using Fortran.

***Preprocessors and fortran compilers***

I was first using ifort (Intel fortran), and it is straightforward to use cpp style declarations like #if, #ifdef, #ifndef, etc.
What is necessary is to provide the compiler with the additional flag: '-fpp'. With GNU compilers (e.g gfortran) you can also use
GNU C/C++ preprocessor cpp. The command would be: 'gfortran .... -x f77-cpp-input .....'.

Syndicate content