Ocean Modeling Discussion

ROMS/TOMS

Search for:
It is currently Sat Jul 20, 2019 8:09 pm




Post new topic Reply to topic  [ 6 posts ] 

All times are UTC

Author Message
PostPosted: Thu Aug 24, 2006 10:24 pm 
Offline
User avatar

Joined: Tue Jul 01, 2003 4:12 am
Posts: 515
Location: NIWA
Has anyone managed to build ROMS in OpenMP mode with Gnu Fortran 95 (gfortran)? When I try on Linux with a recent version of gfortran I get undefined reference errors:

libUTIL.a(mp_routines.o): In function `my_threadnum__':
mp_routines.f90:(.text+0x1d): undefined reference to `omp_get_thread_num__'
libUTIL.a(mp_routines.o): In function `my_numthreads__':
mp_routines.f90:(.text+0x29): undefined reference to `omp_get_max_threads__'

I *think* the problem might me that I am using both the -fopenmp and -ff2c compiler flags (the former to support OpenMP and the latter to allow linking with NetCDF).


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 06, 2006 12:28 am 
Offline
User avatar

Joined: Tue Jul 01, 2003 4:12 am
Posts: 515
Location: NIWA
OK, I've sorted it out. The solution is to build netCDF in a way that doesn't require the Gfortran -ff2c flag.

I'll spare the gory details, but if anyone wants more info, please contact me.

By the way, Gfortran is the Gnu Fortran 95 compiler. It is included with GCC versions 4.1 or so and later (and so should be bundled with recent Linux distributions). It is also available separately, see http://gcc.gnu.org/wiki/GFortran. G95 is a separate Fortran 95 compiler , see http://www.g95.org/. They are are both free/open source.

G95 has been able to build ROMS for a year or two, Gfortran has only managed it more recently. G95 is a little friendlier and more adaptable and I generally prefer it, but Gfortran now supports OpenMP, hence my renewed interest.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 06, 2006 1:06 am 
Offline
Site Admin
User avatar

Joined: Wed Feb 26, 2003 4:41 pm
Posts: 1078
Location: IMCS, Rutgers University
Good job Mark :!: Did you used the same configuration file as with G95? If not, please send me the Gfortran configuration file so I can add it our increasing list of make include files.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 06, 2006 6:01 am 
Offline
User avatar

Joined: Tue Jul 01, 2003 4:12 am
Posts: 515
Location: NIWA
Hi Hernan

As you know, I just sent you an email about this stuff, but I'll mention the info here in case it's of wider interest.

Good old g77 adds two underscores to its global symbols. G95 is binary-compatible with g77 and also uses two underscores. Gfortran is not binary-compatible and uses a single underscore. However the gfortran -ff2c switch causes it to use two. See

http://gcc.gnu.org/onlinedocs/gcc-4.1.1 ... en-Options
http://www.g95.org/docs.html

Until today, I had a single version of the netCDF library, built with g95 or g77. To link gfortran-compiled ROMS with that I used the -ff2c switch.

Conversely, in the master copy of the ROMS source (and by "master" I mean "Hernan"), Makefile.g95 has had -fno-second-underscore in its FFLAGS. From this I conjecture that you are linking g95-compiled ROMS with a library built with gfortran.

The cleanest solution for the ROMS source is, I think, to avoid either of these flags. If you're using g95 you should link with a netCDF library built with g95, ditto with gfortran. If you want to be able to use both compilers, you'll need two versions of the netCDF library. But you might disagree...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 13, 2006 6:08 pm 
Offline

Joined: Thu Jun 12, 2003 6:55 pm
Posts: 33
Location: Dalhousie University
Hi,

we're trying to build ROMS with OpenMP on a Linux (centOS 4.4 X86_64) system for testing purposes, and are having problems with OpenMP in particular

Initial build attempts without OpenMP were successful using either gfortran or g95 fortran compiler. Most recent attempts now with openMP enabled are failing with errors (shown below) - regardless of building and linking to different NetCDF builds appropriate for the compiler.

the errors shown are,

(a) for g95 build:

Bin/cpp_clean propagator.f90
g95 -c -ftrace=full -O3 -ffast-math propagator.f90
g95 -c -ftrace=full -O3 -ffast-math ocean_control.f90
g95 -c -ftrace=full -O3 -ffast-math master.f90
g95 -ftrace=full -O3 -ffast-math master.o ocean_control.o propagator.o -o oceanO libNLM.a libUTIL.a libMODS.a -L/opt/netcdf/lib -lnetcdf
libUTIL.a(mp_routines.o)(.text+0x105): In function `my_numthreads__':
: undefined reference to `omp_get_max_threads__'
libUTIL.a(mp_routines.o)(.text+0x165): In function `my_threadnum__':
: undefined reference to `omp_get_thread_num__'
make: *** [oceanO] Error 1
rm mod_kinds.f90

(b) for gfortran build:

...
: undefined reference to `nf_inq_varndims_'
libUTIL.a(get_varcoords.o)(.text+0x226): In function `get_varcoords_':
: undefined reference to `nf_get_vara_double_'
libUTIL.a(get_varcoords.o)(.text+0x2e7): In function `get_varcoords_':
: undefined reference to `nf_inq_varid_'
libUTIL.a(get_varcoords.o)(.text+0x321): In function `get_varcoords_':
: undefined reference to `nf_inq_varndims_'
libUTIL.a(get_varcoords.o)(.text+0x394): In function `get_varcoords_':
: undefined reference to `nf_get_vara_double_'
libUTIL.a(get_varcoords.o)(.text+0x508): In function `get_varcoords_':
: undefined reference to `nf_inq_varname_'
libUTIL.a(nf_fwrite2d.o)(.text+0x17c): In function `nf_fwrite2d_':
: undefined reference to `nf_put_vara_double_'
libUTIL.a(nf_fwrite3d.o)(.text+0x2d7): In function `nf_fwrite3d_':
: undefined reference to `nf_put_vara_double_'
collect2: ld returned 1 exit status
make: *** [oceanO] Error 1
rm mod_kinds.f90
[root@localhost roms]#


Does anyone have any hints or comments on steps to be taken to successfully build OpenMP ROMS on this sort of platform?

Many thanks,

Katja Fennel (& Tim Chipman)


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 13, 2006 9:52 pm 
Offline
User avatar

Joined: Tue Jul 01, 2003 4:12 am
Posts: 515
Location: NIWA
G95 doesn't support OpenMP, so it's not surprising that didn't work.

You Gfortran problems look like they're related to name mangling, the subject of my previous post on this thread. I suggest you make sure you are *not* using the "-ff2c" switch with Gfortran (your error messages suggest you aren't) and that you link with a netCDF library that has been built with Gfortran, or with G95 or G77 using the -fno-second-underscore switch. You might find this helpful:

http://www.unidata.ucar.edu/support/hel ... 01040.html

It *is* possible to build and run ROMS in OpenMP mode with Gfortran on Linux. Once you get past the linking issues, you might have a problem with your kernel version: it has to be reasonably recent to support thread-local storage or some such thing; if not, an error is issued at run time.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group