[MITgcm-support] Loading Netcdf libraries for MITGCM

Nairita Pal nairita.pal at coral.iitkgp.ac.in
Thu Apr 13 07:40:11 EDT 2023


Thanks so much Martin. This problem is now resolved! 

Working on the genmake_tnc.F file separately really worked.

Turns out that the final path is quite long with all the -lnetcdf etc

The following worked in case you are interested:

Final set of commands:

> LIBS='/home/apps/netcdf_fortran_with_parallel_support_4.5.2/lib -lnetcdff -I/home/apps/parallel_hdf5_1_10_7/include -I/home/apps/parallel_netcdf_1.11.2/include -L/home/apps/parallel_netcdf_1.11.2/lib -L/home/apps/parallel_hdf5_1_10_7/lib -L/scratch/hksahu.iitkgp/WRF/netcdf-c-4.7.2/install/lib -lnetcdf -lm -lhdf5 -lnetcdf -L/home/apps/netcdf_c_with_parallel_support_4.7.4/lib -I/home/apps/netcdf_c_with_parallel_support_4.7.4/include'

> export NETCDF_ROOT=$LIBS
>~/MIT_GCM/MITgcm/tools/genmake2 -rootdir ~/MIT_GCM/MITgcm -mods ~/MIT_GCM/MITgcm/verification/exp2/code -optfile /home/nairitacl/MIT_GCM/MITgcm/tools/build_options/linux_amd64_gfortran

Thanks so much again!

Best regards,
Nairita

----- Original Message -----
From: "Martin Losch" <Martin.Losch at awi.de>
To: "MITgcm Support" <mitgcm-support at mitgcm.org>
Sent: Wednesday, April 12, 2023 5:08:25 PM
Subject: Re: [MITgcm-support] Loading Netcdf libraries for MITGCM

Hi again,

in the genmake.log file, there is section “running: check_netcdf_lib()
There you find the example code that was used to test the netcdf installation:

      program fgennc
#include "netcdf.inc"
      integer iret, ncid, xid
      iret = nf_create('genmake_tnc.nc', NF_CLOBBER, ncid)
      IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
      iret = nf_def_dim(ncid, 'X', 11, xid)
      IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
      iret = nf_close(ncid)
      IF (iret .NE. NF_NOERR) write(*,*) NF_STRERROR(iret)
      end

Put this into a file called genmake_tnc.F, then try the ensuing commands, e.g.

cat genmake_tnc.F |  cpp -traditional -P -DWORDLENGTH=4 -DNML_TERMINATOR -DHAVE_SYSTEM -DHAVE_FDATE -DHAVE_CLOC -DHAVE_SETRLSTK -DHAVE_SIGREG -DHAVE_STAT -I/home/apps/netcdf_c_with_parallel_support_4.7.4/include
gfortran  -fconvert=big-endian -fimplicit-none -mcmodel=medium -O3 -funroll-loops -c genmake_tnc.f  \ 
  &&  gfortran  -fconvert=big-endian -fimplicit-none -mcmodel=medium -O3 -funroll-loops -o genmake_tnc.o -L/home/apps/netcdf_c_with_parallel_support_4.7.4/lib

and modify the flags until it works. I assume that there’s some -lnetcdf missing. This needs to be part of your LIBS variable. (or use NETCDF_ROOT).

Martin

> On 12. Apr 2023, at 12:39, Nairita Pal <nairita.pal at coral.iitkgp.ac.in> wrote:
> 
> Hi Martin,
> 
> Thanks so much again.
> 
> I tried the possible ways to export NETCDF, at command line and also by hard coding. But am puzzled because nothing seems to work. After looking at the genmake.log file it seems like the genmake2 command cannot find "nf_create" etc. Seems to be a fortran wrapper to netcdf or something like that. NetCDF is working however. I tested it on standard files. Attached is the genmake.log file if you have some time on your hands.
> 
> Best regards,
> Nairita 
> 
> ----- Original Message -----
> From: "Martin Losch" <Martin.Losch at awi.de>
> To: "MITgcm Support" <mitgcm-support at mitgcm.org>
> Sent: Wednesday, April 12, 2023 12:51:06 PM
> Subject: Re: [MITgcm-support] Loading Netcdf libraries for MITGCM
> 
> After the genmake2 step there’s a genmake.log file which shows you the comands and error messages in greater detail. Usually you can figure out from that where the problem is. You also need to make sure that your netcdf installation works.
> 
> Martin
> 
> PS. In your case it would have been easier to use the original build_options file and use "export NETCDF_ROOT=/home/apps/netcdf_c_with_parallel_support_4.7.4” at the command line before doing the genmake2 command
> 
>> On 12. Apr 2023, at 09:17, Nairita Pal <nairita.pal at coral.iitkgp.ac.in> wrote:
>> 
>> Hi Martin,
>> 
>> Thanks so much for the prompt reply. Really appreciate it.
>> 
>> I have hardwired the path in my linux_amd64_gfortran path, but still it doesn't work. I am wondering if some compiler mismatch could be the issue. Attached is my linux_amd64_gfortran file. Thanks so much in advance!
>> 
>> Best regards,
>> Nairita
>> 
>> ----- Original Message -----
>> From: "Martin Losch" <Martin.Losch at awi.de>
>> To: "MITgcm Support" <mitgcm-support at mitgcm.org>
>> Sent: Wednesday, April 12, 2023 12:32:33 PM
>> Subject: Re: [MITgcm-support] Loading Netcdf libraries for MITGCM
>> 
>> If the netcdf libaries are in an unusual place you need to tell the model where they are. Depending on which build options file you are using you can either hardwire this in the build options file and set the variables:
>> 
>>   INCLUDES='-I/yourPath/include'
>>   LIBS='-L/yourPath/lib’
>> 
>> or similar, or you may be able to set the environment variable NETCDF_ROOT, NETCDF_HOME, etc before you run gemake2. Have a look at your optfile (e.g. tools/build_options/linux_amd64_gfortran) so see how to do it.
>> 
>> Martin
>> 
>> 
>>> On 12. Apr 2023, at 08:23, Nairita Pal <nairita.pal at coral.iitkgp.ac.in> wrote:
>>> 
>>> Hi,
>>> 
>>> I want to compile the MITGCM code for a verification test case exp2. While compiling the code, although everything else runs fine, the netcdf library seems to be missing. I get the message:
>>> 
>>> "Can we create NetCDF-enabled binaries...  no"
>>> 
>>> I was wondering if you could help me regarding this issue.
>>> 
>>> Note that I have loaded NetCDF libraries. However, the location is not the usual /usr/include directory, and is loaded in a software directory in my home folder inside the cluster. Probably there are some inconsistencies regarding the paths?
>>> 
>>> Best regards,
>>> Nairita Pal
>>> 
>>> -- 
>>> Assistant Professor,
>>> Center for Oceans, Rivers, Atmosphere and Land Sciences (CORAL)
>>> IIT Kharagpur
>>> 
>>> Homepage: https://sites.google.com/view/nairita-pal/home
>>> _______________________________________________
>>> MITgcm-support mailing list
>>> MITgcm-support at mitgcm.org
>>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>> 
>> _______________________________________________
>> MITgcm-support mailing list
>> MITgcm-support at mitgcm.org
>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
>> -- 
>> Assistant Professor,
>> Center for Oceans, Rivers, Atmosphere and Land Sciences (CORAL)
>> IIT Kharagpur
>> 
>> Homepage: https://sites.google.com/view/nairita-pal/home
>> <linux_amd64_gfortran>_______________________________________________
>> MITgcm-support mailing list
>> MITgcm-support at mitgcm.org
>> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
> 
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
> -- 
> Assistant Professor,
> Center for Oceans, Rivers, Atmosphere and Land Sciences (CORAL)
> IIT Kharagpur
> 
> Homepage: https://sites.google.com/view/nairita-pal/home
> <genmake.log>_______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support

_______________________________________________
MITgcm-support mailing list
MITgcm-support at mitgcm.org
http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support
-- 
Assistant Professor,
Center for Oceans, Rivers, Atmosphere and Land Sciences (CORAL)
IIT Kharagpur

Homepage: https://sites.google.com/view/nairita-pal/home


More information about the MITgcm-support mailing list