Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

fortran90 - Include both .f and .F90 file in Fortran main file header

I am using some F77 fixed format code with my F90 program. I am trying to include both kinds of code in my main program. Here's how I have arranged my code:

Header files:

File Name:include.inc
include 'module_variables.F90'
include 'message.F90'
include 'module_common_functions.f90'
include 'module_input_gdf.F90'
...

Relavant LAPACK files

File Name: lapack.inc
include 'xerbla.f'
include 'strsm.f'
include 'slaswp.f'
include 'sgetrs.f'
include 'sgetrf.f'
...

Now my main program looks like:

include 'lapack.inc'
include 'include.inc'

program MDL_HydroD

   use module_variables
   use module_write_files
   use module_read_files
   ...

When I try to compile my main code with ifort "MDL HydroD.F90", the F77 formatted files give error message:

xerbla.f(1): error #5078: Unrecognized token '' skipped
*> rief  XERBLA
---^ 

This is because the compiler is reading the commented section (starts with *). Is there any way I can compile with both type of fortran code in my header.

Note: I am using Intel Composer XE 2013 with command prompt.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

There are compiler specific directives (not part of the standard language), for that compiler, that allow you to change the source form in use.

Place the relevant directive before the include file, and then place the other directive after the include file to switch the source form back. Perhaps:

!DEC$ NOFREEFORM
      INCLUDE 'lapack.inc'
!DEC$ FREEFORM

See http://software.intel.com/en-us/node/466230 for more information.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...