MEGANv3.1 processing compilation

Dear all,

I am trying to compile the MEGANv3.1 preprocessor (Fortran program).
Here is the Makefile I modified.

.SUFFIXES: .o .f90
F90    = gfortran
NETCDF_DIR = /disk/r071/cliucv/smoke/subsys/netcdf
LIBS   = -L$(NETCDF_DIR)/lib -lnetcdf
INCLUDE_MODULES = -I$(NETCDF_DIR)/include
FFLAGS = -O3 -Bstatic

Then when I type make, here is the error.

gfortran -o prepmegan4cmaq_lai.x -O3 -Bstatic misc_definitions_module.o constants_module.o bio_types.o area_mapper.o prepmegan4cmaq_lai.o -L/disk/r071/cliucv/smoke/subsys/netcdf/lib -lnetcdf
area_mapper.o: In function `__area_mapper_MOD_area_interp2':
area_mapper.f90:(.text+0x3652): undefined reference to `nf_inq_varid_'
area_mapper.f90:(.text+0x3716): undefined reference to `nf_get_var_real_'
area_mapper.o: In function `__area_mapper_MOD_discrete_frac':
area_mapper.f90:(.text+0x747b): undefined reference to `nf_inq_varid_'
area_mapper.f90:(.text+0x7553): undefined reference to `nf_get_var_int_'
area_mapper.o: In function `__area_mapper_MOD_area_interp':
area_mapper.f90:(.text+0xb2d2): undefined reference to `nf_inq_varid_'
area_mapper.f90:(.text+0xb396): undefined reference to `nf_get_var_int_'
area_mapper.o: In function `__area_mapper_MOD_handle_ncerr.part.1.constprop.5':
area_mapper.f90:(.text.unlikely+0x42): undefined reference to `nf_strerror_'
prepmegan4cmaq_lai.o: In function `wrf_file.1887':
prepmegan4cmaq_lai.f90:(.text+0x112): undefined reference to `nf_open_'
prepmegan4cmaq_lai.f90:(.text+0x1af): undefined reference to `nf_inq_dimid_'
prepmegan4cmaq_lai.f90:(.text+0x22f): undefined reference to `nf_inq_dimlen_'
prepmegan4cmaq_lai.f90:(.text+0x2af): undefined reference to `nf_inq_dimid_'
prepmegan4cmaq_lai.f90:(.text+0x32f): undefined reference to `nf_inq_dimlen_'
prepmegan4cmaq_lai.f90:(.text+0x3b7): undefined reference to `nf_get_att_int_'
prepmegan4cmaq_lai.f90:(.text+0x4a2): undefined reference to `nf_get_att_real_'
prepmegan4cmaq_lai.f90:(.text+0x594): undefined reference to `nf_get_att_real_'
prepmegan4cmaq_lai.f90:(.text+0x688): undefined reference to `nf_get_att_real_'
prepmegan4cmaq_lai.f90:(.text+0x77a): undefined reference to `nf_get_att_real_'
prepmegan4cmaq_lai.f90:(.text+0x86c): undefined reference to `nf_get_att_real_'
prepmegan4cmaq_lai.o:prepmegan4cmaq_lai.f90:(.text+0x953): more undefined references to `nf_get_att_real_' follow
prepmegan4cmaq_lai.o: In function `wrf_file.1887':
prepmegan4cmaq_lai.f90:(.text+0xc74): undefined reference to `nf_close_'
prepmegan4cmaq_lai.o: In function `MAIN__':
prepmegan4cmaq_lai.f90:(.text+0x192d): undefined reference to `nf_open_'
prepmegan4cmaq_lai.f90:(.text+0x1a1f): undefined reference to `nf_inq_dimid_'
prepmegan4cmaq_lai.f90:(.text+0x1adc): undefined reference to `nf_inq_dimlen_'
prepmegan4cmaq_lai.f90:(.text+0x1b98): undefined reference to `nf_inq_dimid_'
prepmegan4cmaq_lai.f90:(.text+0x1c55): undefined reference to `nf_inq_dimlen_'
prepmegan4cmaq_lai.f90:(.text+0x1e3c): undefined reference to `nf_inq_varid_'
prepmegan4cmaq_lai.f90:(.text+0x1ef6): undefined reference to `nf_get_var_real_'
prepmegan4cmaq_lai.f90:(.text+0x2055): undefined reference to `nf_inq_varid_'
prepmegan4cmaq_lai.f90:(.text+0x210f): undefined reference to `nf_get_var_real_'
prepmegan4cmaq_lai.f90:(.text+0x31ab): undefined reference to `nf_close_'
prepmegan4cmaq_lai.f90:(.text+0x5c33): undefined reference to `nf_inq_varid_'
prepmegan4cmaq_lai.f90:(.text+0x5d7a): undefined reference to `nf_get_vara_real_'
prepmegan4cmaq_lai.o: In function `handle_ncerr.1880.part.0.constprop.1':
prepmegan4cmaq_lai.f90:(.text.unlikely+0x42): undefined reference to `nf_strerror_'
collect2: error: ld returned 1 exit status
make: *** [prepmegan4cmaq_lai.x] Error 1

Looking forward to your reply.

Chang

See https://cjcoats.github.io/ioapi/AVAIL.html#ncf4:
For netCDF-4, you need to build both the netCDF-C libnetcdf.a and the netCDF-Fortran libnetcdff.a (and put both of them where the compiler can find them – /disk/r071/cliucv/smoke/subsys/netcdf/lib in this case), and your compile/link command needs both of these, listing the Fortran-library first:

gfortran -o prepmegan4cmaq_lai.x -O3 -Bstatic misc_definitions_module.o constants_module.o bio_types.o area_mapper.o prepmegan4cmaq_lai.o -L/disk/r071/cliucv/smoke/subsys/netcdf/lib -lnetcdff.a -lnetcdf.a
1 Like