0

Background

I'm working on compiling MCIP which mean Meteorology Chemistry Interface Processor in centos 5.9 system.

I use gcc -version 4.9 to implement the process.

Setting

Here is some configuration setting in ~/.bashrc:

export DIR=/disk2/hyf/lib ## All lib ar installed under this path
# NetCDF setting
export PATH="$DIR/netcdf/bin:$PATH"
export NETCDF="$DIR/netcdf"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$NETCDF/lib     
# IOAPI 
export BIN=Linux2_x86_64gfort
export BASEDIR=/disk2/hyf/backup/software/ioapi
export PATH=$DIR/ioapi-3.1/bin:$PATH
export LD_LIBRARY_PATH=$DIR/ioapi-3.1/lib:$LD_LIBRARY_PATH
# Set M3LIB for the model
export M3LIB=/disk2/hyf/cmaq/CMAQv5.1/lib

I also do soft link for the CMAQ model as these:
ln -s $NETCDF $(M3LIB)/x86_64/gcc/netcdf ln -s $IOAPI $(M3LIB)/x86_64/gcc/ioapi

Makefile

Here is some subroutine in the Makefile:

 # Requirements: set M3LIB before running this script

.SUFFIXES:
.SUFFIXES: .o .f90 .F90

MODEL = mcip.exe

#...gfortran
FC      = gfortran
NETCDF = $(M3LIB)/netcdf
IOAPI_ROOT = $(M3LIB)/ioapi
FFLAGS  = -O3 -gdwarf-2 -gstrict-dwarf -I$(NETCDF)/include -   I$(IOAPI_ROOT)/include \
      -ffpe-trap='invalid','zero','overflow','underflow'
##FFLAGS        = -g -O0  \
      -ffpe-trap='invalid','zero','overflow','underflow'  \
      -I$(NETCDF)/include -I$(IOAPI_ROOT)/include
LIBS    = -L$(IOAPI_ROOT)/lib -lioapi  \
      -L$(NETCDF)/lib -lnetcdf -lgomp

DEFS   =

MODULES =\
 const_mod.o \
 const_pbl_mod.o \
 coord_mod.o \
 date_time_mod.o \
 date_pack_mod.o \
 files_mod.o \
 groutcom_mod.o \
 luvars_mod.o \
 mcipparm_mod.o \
 mcoutcom_mod.o \
 mdoutcom_mod.o \
 metinfo_mod.o \
 metvars_mod.o \
 vgrd_mod.o \
 wrf_netcdf_mod.o \
 xvars_mod.o \
 sat2mcip_mod.o

OBJS =\
 mcip.o \
 alloc_ctm.o \
 alloc_met.o \
 alloc_x.o \
 bcldprc_ak.o \
 blddesc.o \
 chkwpshdr.o \
 chkwrfhdr.o \
 close_files.o \
 collapx.o \
 comheader.o \
 cori.o \
 dealloc_ctm.o \
 dealloc_met.o \
 dealloc_x.o \
 detangle_soil_px.o \
 e_aerk.o \
 dynflds.o \
 getgist.o \
 getluse.o \
 getmet.o \
 getpblht.o \
 getsdt.o \
 getversion.o \
 graceful_stop.o \
 gridout.o \
 init_io.o \
 init_met.o \
 init_x.o \
 julian.o \
 layht.o \
 ll2xy_lam.o \


 .......

ERROR

The output after I make shows like:

make[1]: Entering directory `/disk2/hyf/cmaq/CMAQv5.1/scripts/mcip/src'
gfortran -g -O0 -gdwarf-2 -gstrict-dwarf \ 
         -I/disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/netcdf/include \      
         -I/disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/ioapi/include  -c const_mod.f90
......

chkwpshdr.o: In function `chkwpshdr_':
/disk2/hyf/cmaq/CMAQv5.1/scripts/mcip/src/chkwpshdr.f90:109: \    
 undefined reference to `__netcdf_MOD_nf90_get_att_one_fourbyteint'

 (a lot of these code showing the same mistake 'undefined reference')  

 /disk2/hyf/cmaq/CMAQv5.1/lib/x86_64/gcc/ioapi/lib/libioapi.a(open3.o): In    
 function `open3_':
 open3.F:(.text+0x1531): undefined reference to `ncclos_'
 .........

I think the compiler may have some conflicts with the .F and .f90 files in some case. But I don't know why. The gcc andhas already successfully installed with $PATH defined.

10
  • 1
    Why is this tagged C++ instead of Fortran? Commented Oct 18, 2016 at 9:21
  • Sorry, the website system just recommended 'c++' in the first place. Commented Oct 18, 2016 at 9:24
  • 1
    This is the netcdf which is linked incorrectly. Which version of NetCDF do you have? Where is it installed? Commented Oct 18, 2016 at 9:33
  • I use netcdf-version 4.13(The last version that the netcdf-c and fortran toghther). I installed it in another place and ln -s $netcdf_PATH $(M3LIB)/x86_64/gcc/netcdf Commented Oct 18, 2016 at 10:11
  • The netcdf should be installed correctly. Because other models have complied well. Commented Oct 18, 2016 at 10:12

1 Answer 1

1

I've faced the same problem, and I've got to solve it by adding -lnetcdff and -lnetcdf (in this order) to the LIBS option in the MCIP makefile. Make sure the NETCDF variable is pointing to the correct path where netcdf is installed in your system.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I'll check it later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.