how to compile the released plotting toolbox using gfortran?

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

how to compile the released plotting toolbox using gfortran?

#1 Unread post by leonjld »

I am using gfortran (in ubuntu syste) for the roms3.0. However, there is no makefile for the plotting toolbox associated with gfortran compiler under linux. Is there a solution to this? Say using the Linux-g95.mk and do some easy modifications? Thanks!

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#2 Unread post by kate »

Yes, copy Linux-g95.mk to Linux-gfortran.mk. I don't know the origin of all these changes, but I have:

Code: Select all

114% diff -u Linux-g95.mk  Linux-gfortran.mk
--- Linux-g95.mk        2007-07-09 15:15:22.000000000 -0800
+++ Linux-gfortran.mk   2007-07-09 15:15:22.000000000 -0800
@@ -23,8 +23,8 @@
 #
 # First the defaults
 #
-               FC := g95
-           FFLAGS := -fno-second-underscore
+               FC := gfortran
+           FFLAGS := -frepack-arrays
               CPP := /usr/bin/cpp
          CPPFLAGS := -P -traditional
                LD := $(FC)
plus some NetCDF library location and compiler option changes.

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#3 Unread post by leonjld »

sorry, I mean the makefile of the roms plotting package, not roms itself.

I got the following error:

ar: creating libUTIL.a
ranlib libUTIL.a
ncargf90 -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt \
libUTIL.a -L/usr/local/lib -lnetcdf
make: ncargf90: Command not found
make: *** [/home/leonjld/bin/cnt] Error 127



Do I need to install NCAR library?

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#4 Unread post by kate »

Oh, that. ncargf77 is a script that comes with NCARG. ncargf90 is a copy of it with the changes needed for linking with whatever fortran you are using. You can edit it to put gfortran instead of g77, for intance. You may or may not need to track down some libraries as well.

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#5 Unread post by leonjld »

kate wrote:Oh, that. ncargf77 is a script that comes with NCARG. ncargf90 is a copy of it with the changes needed for linking with whatever fortran you are using. You can edit it to put gfortran instead of g77, for intance. You may or may not need to track down some libraries as well.
Thanks for the reply,Kate. I followed your suggestion and changed 'ncargf90' to 'gfortran', and now I get the following errors:

ar: creating libUTIL.a
ranlib libUTIL.a
gfortran -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt \
libUTIL.a -L/usr/local/lib -lnetcdf
cnt.o: In function `pltfield_':
cnt.f90:(.text+0x12e): undefined reference to `frame_'
cnt.f90:(.text+0x887): undefined reference to `set_'
cnt.f90:(.text+0xc5c): undefined reference to `set_'
cpmpxy2d.o: In function `cpmpxy_':
cpmpxy2d.f90:(.text+0x63): undefined reference to `maptrn_'
cpmpxy2d.f90:(.text+0x110): undefined reference to `maptrn_'
cpmpxy2d.f90:(.text+0x13c): undefined reference to `maptrn_'
cpmpxy2d.f90:(.text+0x16b): undefined reference to `maptrn_'
cpmpxy2d.f90:(.text+0x19a): undefined reference to `maptrn_'
stumsl.o: In function `stumsl_':
stumsl.f90:(.text+0x40): undefined reference to `curve_'
stumxy.o: In function `stuixy_':
stumxy.f90:(.text+0x1c6): undefined reference to `maptri_'
stumxy.f90:(.text+0x240): undefined reference to `maptri_'
.
.
.
.
.
.
landmask.f90:(.text+0x4d4): undefined reference to `mapita_'
libUTIL.a(box.o): In function `box_':
box.f90:(.text+0x45): undefined reference to `getset_'
box.f90:(.text+0x84): undefined reference to `gsfais_'
box.f90:(.text+0x90): undefined reference to `gsplci_'
box.f90:(.text+0xaa): undefined reference to `gpl_'
collect2: ld returned 1 exit status
make: *** [/home/leonjld/bin/cnt] Error 1
rm datestr.f90 inside.f90 vindices.f90 get_date.f90 zgrid.f90 svel.f90 jebar.f90 entropy.f90 geodesic_dist.f90 depth_iso.f90 day_code.f90 hordiv.f90 get_nc1dat.f90 cgrid.f90 checkstrm.f90 lenstr.f90 gksinit.f90 velocity.f90 relvor.f90 box.f90 drawcl.f90 stumsl.f90 lintrp.f90 dens.f90

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#6 Unread post by kate »

All those undefined references are to the NCAR Graphics package. This package comes with libraries and a script for linking to those libraries. You need a version of that script that will invoke gfortran with all the goodies it needs. Do you have the NCARG package? Does it have an ncargf77 script? Now copy that script to the name ncargf90 and edit it until it works. What is your next error?

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#7 Unread post by leonjld »

kate wrote:All those undefined references are to the NCAR Graphics package. This package comes with libraries and a script for linking to those libraries. You need a version of that script that will invoke gfortran with all the goodies it needs. Do you have the NCARG package? Does it have an ncargf77 script? Now copy that script to the name ncargf90 and edit it until it works. What is your next error?
Thanks Kate. My next error seems to be the netcdf library:

ncargf77 -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bi
n/cnt \
libUTIL.a -L/usr/local/lib -lnetcdf
g77 -fPIC -fno-second-underscore -O -O3 -ffast-math cnt.o cpmpxy2d.o mapeod.o st
umsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt libUTIL.a -L/usr/local/lib -ln
etcdf -L/usr/local/lib -L/usr/lib -lncarg -lncarg_gks -lncarg_c -lX11 -lXext
leonjld@Blacksmith:~/romsplot/src$ make
ncargf77 -O3 -ffast-math \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt \
libUTIL.a -L/usr/local/lib -lnetcdf
g77 -fPIC -fno-second-underscore -O -O3 -ffast-math cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt libUTIL.a -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/lib -lncarg -lncarg_gks -lncarg_c -lX11 -lXext
/usr/bin/ld: Warning: size of symbol `mapcm4_' changed from 128 in libUTIL.a(hbackground.o) to 224 in /usr/local/lib/libncarg.a(mapbd.o)
/usr/bin/ld: Warning: size of symbol `mapcm2_' changed from 60 in libUTIL.a(cnt_frame.o) to 124 in /usr/local/lib/libncarg.a(mapbd.o)
/usr/bin/ld: Warning: size of symbol `mapcm1_' changed from 28 in libUTIL.a(hbackground.o) to 48 in /usr/local/lib/libncarg.a(mapbd.o)
libUTIL.a(crash.o): In function `crash_':
crash.f:(.text+0x26): undefined reference to `nf_close__'
crash.f:(.text+0xb9): undefined reference to `nf_strerror__'
crash.f:(.text+0xed): undefined reference to `nf_close__'
libUTIL.a(get_nc2dat.o): In function `get_nc2dat__':
get_nc2dat.f:(.text+0x147): undefined reference to `nf_inq_varid__'
get_nc2dat.f:(.text+0x1a7): undefined reference to `nf_inq_var__'
get_nc2dat.f:(.text+0x234): undefined reference to `nf_inq_dim__'
get_nc2dat.f:(.text+0x399): undefined reference to `nf_inq_attname__'
get_nc2dat.f:(.text+0x423): undefined reference to `nf_get_att_real__'
get_nc2dat.f:(.text+0x51d): undefined reference to `nf_inq_varid__'
get_nc2dat.f:(.text+0x545): undefined reference to `nf_get_var_real__'
......






However, I am sure that my netcdf is properly installed. And there are those fies in the directory as specified by the mk file: /usr/local/include (including netcdf.h and netcdf.inc) and /usr/local/lib (including libnetcdf.a).

So what might be wrong.

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#8 Unread post by kate »

leonjld wrote:-fno-second-underscore
Try editing ncargf90 to remove this.

Actually, this could be trouble if NCARG was compiled with -fno-second-underscore. You will likely have to recompile Netcdf with this option too.

As for your mapcmx warnings, they are common blocks which changed from real to double at some point. Check the Makefile bits to see which NCARGxx you have defined and if that gives you the correct common blocks.

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#9 Unread post by leonjld »

kate wrote:
leonjld wrote:-fno-second-underscore
Try editing ncargf90 to remove this.

Actually, this could be trouble if NCARG was compiled with -fno-second-underscore. You will likely have to recompile Netcdf with this option too.

As for your mapcmx warnings, they are common blocks which changed from real to double at some point. Check the Makefile bits to see which NCARGxx you have defined and if that gives you the correct common blocks.
Thanks but I still have problems. I tried removing the '-fno-second-underscore' by executing:

g77 -fPIC -O3 -ffast-math cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt libUTIL.a -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/lib -lncarg -lncarg_gks -lncarg_c -lX11 -lXext

But the errors produced are exactly the same as before. The references still have two underscores like 'nf_close__'.

If I have to re-compile netcdf, where in the netcdf's makefile do I need to add the '-fno-second-underscore' thing?

For the warnings, I checked my ncarg version by 'ncargversion' and it said 4.4.2, and the option I am using is the default NCARG442.

Thanks again!

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#10 Unread post by kate »

leonjld wrote:Thanks but I still have problems. I tried removing the '-fno-second-underscore' by executing:

g77 -fPIC -O3 -ffast-math cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt libUTIL.a -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/lib -lncarg -lncarg_gks -lncarg_c -lX11 -lXext

But the errors produced are exactly the same as before. The references still have two underscores like 'nf_close__'.

If I have to re-compile netcdf, where in the netcdf's makefile do I need to add the '-fno-second-underscore' thing?

For the warnings, I checked my ncarg version by 'ncargversion' and it said 4.4.2, and the option I am using is the default NCARG442.

Thanks again!
If your NCARG used -fno-second-underscore, you will have to add it to the FFLAGS in the plotting code too. Perhaps start there after doing a "make clean". You can use the "nm" command to find out which way each piece was compiled:

nm /usr/local/lib/libnetcdf.a | grep nf_close

My version of the plotting code doesn't know about NCARG442, just these (in the makefile):

Code: Select all

#NCAR_VERSION ?= NCARG410
#NCAR_VERSION ?= NCARG422 
#NCAR_VERSION ?= NCARG430
#NCAR_VERSION ?= NCARG431 
 NCAR_VERSION ?= NCARG441
The trouble is likely coming from Utility/hbackground.F and Utility/cnt_frame.F.

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#11 Unread post by leonjld »

kate wrote: If your NCARG used -fno-second-underscore, you will have to add it to the FFLAGS in the plotting code too. Perhaps start there after doing a "make clean". You can use the "nm" command to find out which way each piece was compiled:

nm /usr/local/lib/libnetcdf.a | grep nf_close

My version of the plotting code doesn't know about NCARG442, just these (in the makefile):

Code: Select all

#NCAR_VERSION ?= NCARG410
#NCAR_VERSION ?= NCARG422 
#NCAR_VERSION ?= NCARG430
#NCAR_VERSION ?= NCARG431 
 NCAR_VERSION ?= NCARG441
The trouble is likely coming from Utility/hbackground.F and Utility/cnt_frame.F.

Thanks Kate, it does work by re-compiling the plotting code using -fno-second-underscore. However, new errors emerged :(


ncargf77 -O3 -ffast-math -fno-second-underscore \
cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt \
libUTIL.a -L/usr/local/lib -lnetcdf
g77 -fPIC -fno-second-underscore -O -O3 -ffast-math -fno-second-underscore cnt.o cpmpxy2d.o mapeod.o stumsl.o stumxy.o vvumxy.o -o /home/leonjld/bin/cnt libUTIL.a -L/usr/local/lib -lnetcdf -L/usr/local/lib -L/usr/lib -lncarg -lncarg_gks -lncarg_c -lX11 -lXext
/usr/bin/ld: Warning: size of symbol `mapcm4_' changed from 128 in libUTIL.a(hbackground.o) to 224 in /usr/local/lib/libncarg.a(mapbd.o)
/usr/bin/ld: Warning: size of symbol `mapcm2_' changed from 60 in libUTIL.a(cnt_frame.o) to 124 in /usr/local/lib/libncarg.a(mapbd.o)
/usr/bin/ld: Warning: size of symbol `mapcm1_' changed from 28 in libUTIL.a(hbackground.o) to 48 in /usr/local/lib/libncarg.a(mapbd.o)
libUTIL.a(hbackground.o): In function `mapgrd_':
hbackground.f:(.text+0x1f4e): undefined reference to `mapchi_'
hbackground.f:(.text+0x26ba): undefined reference to `mapchi_'
collect2: ld returned 1 exit status
make: *** [/home/leonjld/bin/cnt] Error 1


Although I did see "mapchi_" in by "nm libUTIL.a |grep mapchi", and it shows:

U mapchi_

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

#12 Unread post by kate »

From Utility/hbackground.F:

Code: Select all

#if defined NCARG430 || defined NCARG431 || defined NCARG441
      CALL mdpchi (2,0,idsh)
#else
      CALL mapchi (2,0,idsh)
#endif
We should probably change this to:

Code: Select all

#if defined NCARG410 || defined NCARG422
      CALL mapchi (2,0,idsh)
#else
      CALL mdpchi (2,0,idsh)
#endif

leonjld
Posts: 51
Joined: Fri Feb 27, 2004 6:30 pm
Location: NOAA/NESDIS/STAR

#13 Unread post by leonjld »

kate wrote:From Utility/hbackground.F:

Code: Select all

#if defined NCARG430 || defined NCARG431 || defined NCARG441
      CALL mdpchi (2,0,idsh)
#else
      CALL mapchi (2,0,idsh)
#endif
We should probably change this to:

Code: Select all

#if defined NCARG410 || defined NCARG422
      CALL mapchi (2,0,idsh)
#else
      CALL mdpchi (2,0,idsh)
#endif
Thanks a lot, Kate. With your help I finally made it. I changed all "NCARG441" in "hbackground.F" into "NCARG442" and then the compilation was successful. However, the package itself seems not easy to master.

Post Reply