Error to compile IOAPI with flags netcdf-4 NETCDF

Hi everyone,
I’m practicing to compile IOAI with flags netcdf-4 NETCDF. I have changed a little bit in the Makefile and Makeinclude.Linux2_x86_64ifort.
To be more precise, in Makeinclude.Linux2_x86_64ifort, I add -DIOAPI_NCF4=1 in ARCHFLAGS:

-DF90=1 -DFLDMN=1

My Makefile is that:

LIBINST = /work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/ioapi/lib
BININST = /work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/ioapi/bin
CPLMODE = nocpl
PVMINCL = /dev/null
NCFLIBS = -L/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/netcdf/lib -lnetcdff -lnetcdf
NCFLIBS = "/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/netcdf/bin/nf-config --flibs /work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/netcdf/bin/nc-config --libs"
IODIR = (BASEDIR)/ioapi FIXDIR = (IODIR)/fixed_src

Unfortunately, I got the error:

/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/src/ioapi/Linux2_x86_64ifort/libioapi.a(init3.o): In function init3_': init3.F90:(.text+0xa5): undefined reference to nf_inq_libvers_’
/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/src/ioapi/Linux2_x86_64ifort/libioapi.a(open3.o): In function open3_': open3.F90:(.text+0xcdf): undefined reference to nf_close_’
/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/src/ioapi/Linux2_x86_64ifort/libioapi.a(opnfil3.o): In function opnfil3_': opnfil3.F90:(.text+0xfd): undefined reference to nf_open_’
opnfil3.F90:(.text+0x136): undefined reference to nf_get_att_int_' opnfil3.F90:(.text+0x164): undefined reference to nf_get_att_int_’
opnfil3.F90:(.text+0x1b7): undefined reference to nf_get_att_int_' opnfil3.F90:(.text+0x1e5): undefined reference to nf_get_att_int_’
opnfil3.F90:(.text+0x213): undefined reference to `nf_get_att_int_’

All of the log file and Makefile are attached in the below.
Please help me to solve this problem!
Any suggestions will be appreciated.
make.log.txt (197.4 KB)
Makefile.txt (10.4 KB)
Makeinclude.Linux2_x86_64ifort.txt (1.5 KB)

Where you have double-quotes around the *config commands (that means “take this literally”), you need instead to be using back-quotes (which means “take the result of executing this command”).

Hi Cjcoats,
Thank you for your reply. But I really don’t know your comment.
Can you explain more clearly?

Easy, low-tech way: run the commands

nf-config --flibs
nc-config --libs

Take the outputs and paste them into the NCFLIBS definition. The thing with the back-quotes is the “high-tech” way of doing just that…

Hi cjcoats,
Thank you for your explanation,
I’ve change my NCFLIBS flag to be like that:

NCFLIBS= -L/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/netcdf/lib -lnetcdff -L/work/users/weather/user/manh/cmaq/Build_CMAQ/Intel_Compiler/LIBRARIES/netcdf/lib -lnetcdf

However, the error related the NETCDF library still occurred. The makelog file is included in the below.
make_log.txt (71.4 KB)

Please help me to address it!
Thank you very much

You have not followed the recommendations to configure and build netCDF with the flags

--disable-netcdf4 --disable-dap

See about what the I/O API build system does to attempt to “paper over” the incompatibilities this causes:

If you build netCDF-4 without the --disable-netcdf4, you will also need to add -DIOAPI_NCF4=1 either to the ARCHFLAGS in your Makeinclude.${BIN} or to the DEFINEFLAGS in your Makefile, since defining netCDF-4 causes netCDF to change parts of the netCDF-3 interface.

Hi @cjcoats,

a quick comment on this issue, I recently experienced a similar issue, where I installed NetCDF with the --disable-netcdf4 --disable-dap flags but I still needed to add the -DIOAPI_NCF4=1 to my Makeinclude file, because the following:
nm libnetcdff.a | grep nf_get_var_int64_
did returned a value.

Not sure if this happened because of the NetCDF version I used or what (NetCDF 4.7.4) but apparently you need to add the -DIOAPI_NCF4=1 even if you added the recommended flags.


Isn’t compatibility from version to version delighful? ;-(

Yet more “work-around” documentation to be done…

Hi @ever.barreto
Thank you for your recommendation.
I can not build successfully IOAPI with the --disable-netcdf4 --disable-dap flags of NETCDF version 4.7.4 without the -DIOAPI_NCF4=1 to my Makeinclude file.

Hi @cjcoats
Thank you very much.
I have added the -DIOAPI_NCF4=1 flag into the Makeinclude file and my problem is solved.