Recently I have to combine my C++ code with the Fortran code from my colleague, and I soon find the complication with the gcc compilers.  The Fortran code was written in F77, with a few exceptions when f90 syntax is used.  It compiles well with g77, coming with pre-4.0 version of the gcc compilers.  gcc 4.0 ships with gfortran rather than g77.  gfortran is a Fortran 95 compiler, which is supposed to comile Fortran 77 codes as well, but not for the code I have.  Fortunately, I'm able to compile the code with gfortran by some simple changes:
In Fortran 90/95, a "&" at the end of a line, or in the front of a line, is treated as line continuation sign.  But in Fortran 77, it has to be a character at the sixth column.  In the code I get, most "&"'s comply to the Fortran 77 format, but some are not.  So I move all "&"'s to the sixth column, and now the code compile with gfortran.
I also need to compile the code with ifort on a different computer.  The only thing that is different from gfortran is one compile option.  The fortran code has long lines occasionally (allowed in Fortran 90/95 since its's free format).  With g77 or gfortran, the compiler option "-ffixed-line-length-none" does the trick.  But this option is not available in the Intel compiler.  Fortunately, the long lines in the code is not terribly long, and "-132" option for ifort works.  This option assumes the field width to be 132 columns rather than the standard 72 columns.
Subscribe to:
Post Comments (Atom)
 

 All contents on this page are licensed under a Creative
Commons Attribution-Noncommercial-Share Alike 3.0 United States
License.
All contents on this page are licensed under a Creative
Commons Attribution-Noncommercial-Share Alike 3.0 United States
License.
No comments:
Post a Comment