Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

gfortran - Combining F77 and F95 fortran code

I'm working on some scientific code that is mostly F77 but also some F95. In places, I need to include F77 code into my F95 code. Is there a way to get this code to play nicely within my code by using a particular compiler flag or something? I'm using gfortran and occasionally ifort. It is possible for me to modify the legacy code but I would need to do it in a sensible way to maintain backwards compatibility with other F77 code while also being forwards compatible with F95 code.

I get errors like:

cstruc:16.12:
    Included at mod_op.f90:6:

      REAL*8
            1
Error: Invalid character in name at (1)
cstruc:17.6:
    Included at mod_op.f90:6:

     &       RH, RH1,      ! ln rho
      1
Error: Invalid character in name at (1)
cstruc:18.6:
    Included at mod_op.f90:6:

     &       RHP, RHP1,    ! d ln rho / d ln p
      1
Error: Invalid character in name at (1)
cstruc:19.6:
    Included at mod_op.f90:6:

     &       RHT, RHT1,    ! d ln rho / d ln T
      1
Error: Invalid character in name at (1)

cstruc looks like this:

  REAL*8
 &       RH, RH1,      ! ln rho
 &       RHP, RHP1,    ! d ln rho / d ln p
 &       RHT, RHT1,    ! d ln rho / d ln T
 &       PSI,          ! ln Lambda (for degenerate gas)
 &       RHPSI,        ! d ln rho / d PSI
 &       RHPSIP,       ! d2 ln rho / d PSI d ln P
 &       RHPSIT,       ! d2 ln rho / d PSI d ln T
 &       PL,           ! P at J1
 &       TONI          ! T at J1

Any help is much appreciated. Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I suggest to try the "intersection" form from http://fortranwiki.org/fortran/show/Continuation+lines

It is legal as both free and fixed source form.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...