help with ROMS compiling

Discussion on computers, ROMS installation and compiling

Moderators: arango, robertson

Post Reply
Message
Author
youngstor
Posts: 29
Joined: Mon Mar 01, 2010 2:11 pm
Location: Georgia

help with ROMS compiling

#1 Unread post by youngstor »

I was trying to compile ROMS on my Linux computer. At first I used ifort compiler and had an error msg saying " This module file was not generated by any release of this compiler". According to the thread at "viewtopic.php?f=31&t=2638", I figure it might be because NetCDF package was compiled with a different compiler.

Therefore I switched to gfortran compiler, and I had a different error msg when compiling:

Code: Select all

ROMS/Bin/cpp_clean Build/master.f90
cd Build; /usr/bin/mpif90 -c -frepack-arrays -O3 -ffast-math master.f90
/usr/bin/mpif90 -frepack-arrays -O3 -ffast-math  Build/esmf_roms.o Build/master.o Build/ocean_control.o Build/ocean_coupler.o Build/propagator.o Build/roms_export.o Build/roms_import.o -o oceanM  Build/libNLM.a Build/libANA.a Build/libUTIL.a Build/libMODS.a -L/etc/NetCDF/fortran/lib -lnetcdf
/usr/bin/ld: cannot find -lnetcdf
collect2: ld returned 1 exit status
make: *** [oceanM] Error 1
My understanding is that I am missing libnetcdf.a library file. Here is what I have in my computer:
/etc/NetCDF/fortran/lib/libnetcdff.a
/etc/NetCDF/fortran/lib/libnetcdff.so
/etc/NetCDF/c/lib/libnetcdf.a

and NetCDF directory is defined as:
NETCDF_INCDIR=/etc/NetCDF/fortran/include
NETCDF_LIBDIR=/etc/NetCDF/fortran/lib
export NETCDF_INCDIR
export NETCDF_LIBDIR

I also tried to define NETCDF_LIBDIR=/etc/NetCDF/c/lib, but still got errors.

Please help !!

Thanks so much!!

Mike Y.

linzhenhua
Posts: 64
Joined: Mon Oct 17, 2005 2:02 am
Location: Institute of Oceanology,Chinese Academy of Sciences

Re: help with ROMS compiling

#2 Unread post by linzhenhua »

The reason for this is the compiler is trying to find the file libnetcdf.a, but the netcdf fortran library in your system is libnetcdff.a.

You could add "-lnetcdff" in your corresponding Compiler/*.mk file.
Last edited by linzhenhua on Sat Feb 08, 2014 2:48 am, edited 1 time in total.

youngstor
Posts: 29
Joined: Mon Mar 01, 2010 2:11 pm
Location: Georgia

Re: help with ROMS compiling

#3 Unread post by youngstor »

linzhenhua wrote:The reason for this is the compiler is trying to find the file libnetcdf.a, but the netcdf fortran library in your system is libnetcdff.a.

You could either link the libnetcdff.a to a libnetcdf.a or add "-lnetcdff" in your corresponding Compiler/*.mk file.
Thanks a lot for reply.
So I changed "-lnetcdf" to "-lnetcdff" in the complier/Linux-gfortran.mk file, and compiled again. Here is what I got ...:

Code: Select all

cd Build; /usr/bin/mpif90 -c -frepack-arrays -O3 -ffast-math master.f90
/usr/bin/mpif90 -frepack-arrays -O3 -ffast-math  Build/esmf_roms.o Build/master.o Build/ocean_control.o Build/ocean_coupler.o Build/propagator.o Build/roms_export.o Build/roms_import.o -o oceanM  Build/libNLM.a Build/libANA.a Build/libUTIL.a Build/libMODS.a -L/etc/NetCDF/fortran/lib -lnetcdff
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncattdel'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_attname'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_set_default_format'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_dimname'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_dim'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncsync'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_nvars'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncattname'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_open'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncvarrename'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_set_base_pe'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_format'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncopts'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc__create'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_varndims'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_advise'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_attlen'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_def_var'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncvarinq'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncsetfill'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncopen'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc__open_mp'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_dimlen'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_delete_mp'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc__enddef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncclose'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncinquire'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nctypelen'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_copy_var'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncattcopy'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncredef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_base_pe'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_rename_var'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_redef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_att'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncattinq'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncendef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_vardimid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_rename_att'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vara_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc__open'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_ndims'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncabort'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncdimrename'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_libvers'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_sync'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_natts'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncdiminq'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncerr'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncdimid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_close'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_dimid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nccreate'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_varm_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_unlimdim'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_del_att'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_abort'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_def_dim'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncvarid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_varm_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_vartype'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_strerror'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_varname'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_set_fill'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_enddef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_short'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncattrename'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_att_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_varid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_schar'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_attid'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vara'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_att_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `ncdimdef'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var1_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_create'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_rename_dim'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var1_float'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_copy_att'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_vars_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_varnatts'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_vars_double'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_put_var_text'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_delete'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_atttype'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_inq_var'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc_get_var_int'
/etc/NetCDF/fortran/lib/libnetcdff.so: undefined reference to `nc__create_mp'
collect2: ld returned 1 exit status
make: *** [oceanM] Error 1


Apparently it was linked to "libnetcdff.so" instead of "libnetcdff.a". Is that where the problem is?

By the way, why do I have a "libnetcdff.a" instead of "libnetcdf.a" in my "/fortran/lib" directory? Is that normal?

Thanks again.

Mike Y.

linzhenhua
Posts: 64
Joined: Mon Oct 17, 2005 2:02 am
Location: Institute of Oceanology,Chinese Academy of Sciences

Re: help with ROMS compiling

#4 Unread post by linzhenhua »

Firstly please igore the linking methods posted previously. The reson you have a "libnetcdff.a" instead of "libnetcdf.a" is because the version you use is netcdf4.

One simple method I suggest is to download netcdf 3.6.3, compile and use that version.

If you still want to use the available netcdf library. Try the following step:
1) define and export NETCDF_INCDIR as you previously do.
2) edit the file complier/Linux-gfortran.mk, change the following line:

LIBS += -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf

to:

LIBS += -L/etc/NetCDF/c/lib -L/etc/NetCDF/fortran/lib -lnetcdff -lnetcdf

save the file, then make clean and rebuild the model.

youngstor
Posts: 29
Joined: Mon Mar 01, 2010 2:11 pm
Location: Georgia

Re: help with ROMS compiling

#5 Unread post by youngstor »

linzhenhua wrote:Firstly please igore the linking methods posted previously. The reson you have a "libnetcdff.a" instead of "libnetcdf.a" is because the version you use is netcdf4.

One simple method I suggest is to download netcdf 3.6.3, compile and use that version.

If you still want to use the available netcdf library. Try the following step:
1) define and export NETCDF_INCDIR as you previously do.
2) edit the file complier/Linux-gfortran.mk, change the following line:

LIBS += -L$(NETCDF_LIBDIR) -lnetcdff -lnetcdf

to:

LIBS += -L/etc/NetCDF/c/lib -L/etc/NetCDF/fortran/lib -lnetcdff -lnetcdf

save the file, then make clean and rebuild the model.
Awesome! It fixed the problem! The code was built successfully and I am running my first test case now.
Thank you soooo much!!

Mike Y.

Post Reply