- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am porting some windows fortran code to linux.
the command I use to compile is:
ifort -assume protect_parens *.f* > dump.txt 2>&1
any of the .for or .f90 files that have statements like:
use GlobalConsts
use DataTypes
refering to the .mod files which I compiled using
ifort GlobalConsts.f90 and put the resulting .mod in the same directory as the source file USEing the mod
the dump file gives me (it cant see any of the vars in globalconstants???):
/tmp/ifortQQ57xF.o: In function `addboundaryconditions_':
AddBoundaryConditions.f90:(.text+0x14): undefined reference to `globalconsts_mp_explicit_boundary_conditions_'
/tmp/ifortzNt23D.o: In function `adddefaults_':
AddDefaults.for:(.text+0x13): undefined reference to `globalconsts_mp_mobil_unit_'
AddDefaults.for:(.text+0x1b): undefined reference to `globalconsts_mp_default_mob_'
AddDefaults.for:(.text+0x2b): undefined reference to `globalconsts_mp_charge_unit_'
AddDefaults.for:(.text+0x33): undefined reference to `globalconsts_mp_default_charge_'
AddDefaults.for:(.text+0x3c): undefined reference to `globalconsts_mp_diff_unit_'
AddDefaults.for:(.text+0x44): undefined reference to `globalconsts_mp_default_diff_'
AddDefaults.for:(.text+0x58): undefined reference to `globalconsts_mp_empty_'
AddDefaults.for:(.text+0xe8): undefined reference to `globalconsts_mp_empty_'
AddDefaults.for:(.text+0x129): undefined reference to `globalconsts_mp_empty_'
AddDefaults.for:(.text+0x1d1): undefined reference to `globalconsts_mp_empty_'
/tmp/ifortXWhXzC.o: In function `addfiles_':
AddFiles.for:(.text+0x1b): undefined reference to `globalconsts_mp_max_comps_'
AddFiles.for:(.text+0x136): undefined reference to `globalconsts_mp_tag_'
/tmp/iforteqxS5A.o: In function `additem_':
AddItem.for:(.text+0x10): undefined reference to `globalconsts_mp_max_comps_'
AddItem.for:(.text+0x47): undefined reference to `globalconsts_mp_empty_'
AddItem.for:(.text+0xdc): undefined reference to `globalconsts_mp_empty_'
any ideas?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In compiling the module source file, you need the "-c" option:
ifort -c mymodule.f90
Then you need the .mod AND the .o file created from the above. The .mod file you can think of as having all the procedure/data declarations - the actual code needed is in the .o file.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
using the -c option did indeed give me .mod and .o files
root@rob-laptop:/home/rob/CreviceCorrSimCode/mods# ifort -c *.f90
root@rob-laptop:/home/rob/CreviceCorrSimCode/mods# ls
d2u.sh datatypes.mod GlobalConsts.f90 GlobalConsts.o globalvars.mod
DataTypes.f90 DataTypes.o globalconsts.mod GlobalVars.f90 GlobalVars.o
so I copied those up one level to my source directory ands tried again and got the same messages . Could it be related to the upcase characters in the .o files name
globalvars.mod VS GlobalVars.o
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifort -module ./ -I /home/rob/CreviceCorrSimCode -assume protect_parens *.f*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you have a common confusion about the way modules work. As you saw, when you compile a module you get a .mod and a .o. The .mod is read by the compiler when you have a USE statement. The .o is used by the linker and has the same name as the source file. The .o must be named when you link, otherwise you will get undefined references as you did.
When compiling and linking on a single command, then there's a single .o and no problem. If you use -c to separately compile module files, then you have to find a way to present those objects to the linker. You can either name them individually on the ifort command doing the linking, or insert them into a library (.a) and name that when you link. It is not sufficient to specify the path to the .o files when linking - you have to give the linker the file name(s).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That was the last peice in the puzzle
ifort -assume protect_parens *.f* modules.o
did the trick (I consolodate the 3 modules into one f90->.o)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ifort file.f90 *.obj
This above will do great when you have a bunch of object files.
However, I am having the following error now:
which is related to not being able to use IMSL
fatal error LNK1104: cannot open file 'smaths.lib
any help???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/54BF544B471F3F61DFD338F1D58F9426/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page