Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Migrating a large fortran program from ifort to gfortran

Status
Not open for further replies.

awa5114

Structural
Feb 1, 2016
135
I have a large program containing 40 source files that I am trying to migrate to `gfortran` compiler. 39 of these source files contain module definitions (only) and 1 of these files contains a main program. The main program references 12 of the module definition source files via `use modulename` syntax. These 12 files in turn reference the other 27 module definitions. All the files are necessary for the functioning of the program.

I have compiled all of the 39 module-definition source files using the following syntax. I also made sure ensuring that I compile lowest level modules first (i.e those that reference no other modules) then higher level modules next (i.e those that reference many other modules).

`gfortran -ffree-form -ffree-line-length-200 -DMACRO1 -DMACRO2 -c ModuleFileName.FOR -o ModuleFileName.o`

Once all 39 modules were compiled I ensured that corresponding .o and .mod files were generated (which they were). I then attempted to compile the main program using the following command:

`gfortran -ffree-form -ffree-line-length-200 -DMACRO1 -DMACRO2 -o MainProgramName.FOR ModuleFileName1.o ModuleFileName2.o ModuleFileName3.o ..... ModuleFileName11.o ModuleFileName12.o`

Note above that I am only using the 12 module definitions that the main program uses, since the .o and .mod files for all the modules are available. I have also attempted a very large (similar command) containing all 39 modules including the ones not reference by `MainProgram`. The issue I faced was the same, multiple instances of the same error:

`undefined reference to '__[module_name]_MOD_[function_name]'`

I am sure that this is due to how I have gone about compiling the program, specifically the `gfortran` commands. Why am I getting this error when all the .o and .mod files are already created? Is this from the way I have compiled the modules individually or from the way I am compiling the main program?
 
Replies continue below

Recommended for you

You need the -fintrinsic-modules-path to specify the directory where the mod files are created/picked up from
 
Doesn't it just work off of the current directory? I don't think the program needs a full path for every .mod file. They are all contained within the same directory as the main program...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor