Some random thoughts on coding in Fortran!

Since last 7+ years that I am working in fortran. Almost all my weekdays for the last 7 years are filled with tinkering/writing fortran codes.

Fortran is the life blood of the engineering industry especially for the aerospace industry. And being part of this industry one can’t miss getting entangled with fortran.

So here are some random thoughts on coding with fortran.

1. Fortran allows implicit declaration and this is the biggest cause of error that happens in a fortran program. Most of the old codes rely on fortran convection of implicit declaration and this causes a problem when a variable can get….

2. Fortran 77 is strict. If you don’t respect the columns, you will spend countless hours struggling pruning the errors that the compiler throws at you.

3. The beauty of fortran is that a code written 40 years ago will run exactly the same way in the modern compiler as it did 40 years ago, with little or no modification. Backward compatibility is ingrained in fortran. But this causes a problem as when coding one can use old/new coding syntax…

4. Fortran version above fortran 77 is very modern. You can allocate reallocate dynamic memory, use pointers for efficient memory usage and many other new features. So don’t get stuck to just fortran 77. Instead of using go to statements, one can efficienly use cycle exit command to control the flow of a fortran program.

5. Not declaring the dimensions of an array. One of the another common error that I have seen cropping up various times. Most compilers catch it but some let you to find out.

6. Not declaring a function as external.

7. Fortran90 is rich in intrinsic functions. Not knowing them is a big disadvantage. Life becomes easy if you know many of the functions. Like maxval, minval, sum etc

8. Not understanding data statements. Data statements are one time initialization. So if one is planning to initialize a variable everytime the routine is called it should not be in a data statement.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s