Compilation error for MAC OS with xlf95_r

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Posts: 5
Joined: Thu May 25, 2006 2:36 am
Location: University of Colorado, boulder

Compilation error for MAC OS with xlf95_r

#1 Post by thaned » Wed Jun 14, 2006 7:08 am

I am using Mac G5 with "xlf95_r" to compile the ROMS version 2.2. I got an error at the very last step. I have feeling that it might be problem with flush_ but I am not quite sure. Then I tried to check "Utility/mp_routines.F" by change "AIX" to "XLF" but still not solving this problem. Can anyone know how to deal with this problem. Part of the error message I got is:

xlf95_r -c -qsuffix=f=f90 -qmaxmem=-1 -qextname -O3 -qstrict master.f90
** ocean === End of Compilation 1 ===
1501-510 Compilation successful for file master.f90.
xlf95_r -qsuffix=f=f90 -qmaxmem=-1 -qextname -O3 -qstrict master.o ocean_control.o -o oceanS libNLM.a libUTIL.a libMODS.a -L/usr/local/netcdf-3.6.1/lib -lnetcdf
ld: Undefined symbols:


#2 Post by abarth » Mon Jun 19, 2006 1:49 pm


For some reason, the compiler can't find the netcdf functions.
Can you run the following commands?
nm close_io.o | grep nf_close
nm /usr/local/netcdf-3.6.1/lib/libnetcdf.a | grep nf_close

Both commands should give the same function names (including underscores). If you have compiled netcdf will the gcc, you probably need either to compile it with xlf or with somethink like "gcc -fleading-underscore".


Posts: 5
Joined: Thu May 25, 2006 2:36 am
Location: University of Colorado, boulder

#3 Post by thaned » Mon Jun 19, 2006 5:11 pm

You are right. The results are different. One from model provide underscore at before and after the file names.

nm close_io.o | grep nf_close
U _nf_close_
nm /usr/local/netcdf-3.6.1/lib/libnetcdf.a | grep nf_close
00000818 T _nf_close
U _nf_close

How can I correct this problem? I did reinstall netCDF with same xlf compiler with option of "cc -fleading-underscore" but problem still persist.
I 'll try to see if there any .F file I can modify
Thanks for suggestion.

User avatar
Posts: 3700
Joined: Wed Jul 02, 2003 5:29 pm
Location: IMS/UAF, USA

#4 Post by kate » Mon Jun 19, 2006 5:26 pm

The problem is with -qextname. This is an xlf option to put a trailing underscore on the name (_nf_close_) instead of leaving it be (_nf_close). First, check to see if -qextname was used when building the netcdf library. If not, take it out of the compile options on the Mac. Now you will get a link error on missing flush_. To fix this, go into mp_routines and look for my_flush. It does something in the case of AIX - add DARWIN to the list (#if defined AIX || defined DARWIN). I helped someone with this just last week. :)

Post Reply