Rc

Compiling Fortran

It is always a good habit to use two compilers to test the error. And particularly gfortran does it better.

Few Good Points that really saves:
  • IMPLICIT NONE
  • Defining parameters like pi, h etc.

Avoid :
  • EXP Like Expressions. For frequent use of particular values involving complex arithmetic operations, pre-calculate and store it in a table once and reuse the values. 
Few Good compiler Options:
  • gfortran -fbounds-check prog.f90
    It checks for the possible out-of bound arrays, and reports.
  • gfortran -Wall prog.f90
    It checks and reports all possible errors and warnings. To have a better portable and efficient code rectify all points to make 0 warnings.
  • After complete debugging in gfortran, compile by ifort and run to take the advantage of the latter's fastness.