"multiple definition" problem in compiling with key_agrif

Hi,

I am trying to compile a nested configuration of ORCA2_LIM with key_agrif in NEMO v3.6. However, it ended up with multiple definition messages which failed the compilation:

  ->Make: start
  fcm_internal load:C convsrc /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o conv
  ar: creating /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/tmp/lib__fcm__conv.a
  cc -o conv /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o -L/home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/lib -l__fcm__conv 
  /usr/bin/ld: /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/lib/lib__fcm__conv.a(dependfile.o):(.bss+0x0): multiple definition of `curvar'; /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o:(.bss+0x0): first defined here
  /usr/bin/ld: /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/lib/lib__fcm__conv.a(dependfile.o):(.bss+0x8): multiple definition of `List_ModuleUsedInModuleUsed_Var'; /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o:(.bss+0x8): first defined here
  /usr/bin/ld: /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/lib/lib__fcm__conv.a(dependfile.o):(.bss+0x10): multiple definition of `List_ModuleUsed_Var'; /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o:(.bss+0x10): first defined here

  ...

  /usr/bin/ld: /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/lib/lib__fcm__conv.a(writeinfile.o):(.bss+0x4e80): multiple definition of `infree'; /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/obj/main.o:(.bss+0x4e80): first defined here
  collect2: error: ld returned 1 exit status
  fcm_internal load failed (256)
  make: *** [/home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/Makefile:406: conv] Error 1
  make -f /home/klqs/model/NEMO_v3.6/NEMOGCM/CONFIG/ORCA2_LIM/AGRIFLIB/Makefile -j 1 all failed (2) at /home/klqs/model/NEMO_v3.6/NEMOGCM/EXTERNAL/fcm/bin/../lib/Fcm/Build.pm line 597.
  Build failed on Thu Jan 12 15:25:20 2023.
  ->Make: 1 second
  ->TOTAL: 1 second

Have anyone met this problem before? Or any suggestions about how to fix this?

Cheers,
Lequan


  • arch.fcm

    %NCDF_HOME           /home/klqs/softwares/netcdf
    %HDF5_HOME           /home/klqs/softwares/hdf5/hdf5
    %XIOS_HOME           /home/klqs/softwares/xios1
    %OASIS_HOME          
    
    %CURL_INC_PATH       /usr/include/x86_64-linux-gnu/curl
    %CURL_LIB_PATH       /usr/lib/x86_64-linux-gnu
    
    %NCDF_INC            -I%NCDF_HOME/include  -I%HDF5_HOME/include  -I%CURL_INC_PATH -I/usr/include/libxml
    %NCDF_LIB            -L%NCDF_HOME/lib -lnetcdff -lnetcdf -L%HDF5_HOME/lib -lhdf5_hl -lhdf5  -lz -L%CURL_LIB_PATH -lcurl -lxml2 
    %XIOS_INC            -I%XIOS_HOME/inc 
    %XIOS_LIB            -L%XIOS_HOME/lib -lxios
    %OASIS_INC           
    %OASIS_LIB           
    
    %CPP	             cpp
    %FC                  mpiifort -c -cpp
    # for Curie Fat Node
    #%FCFLAGS             -i4 -r8 -O3 -fp-model precise -xSSE4.2 
    # for Curie Thin Node
    #%FCFLAGS             -i4 -r8 -O3 -fp-model precise -xAVX
    # for Curie all Node
    %FCFLAGS             -i4 -r8 -O3 -fp-model precise
    %FFLAGS              %FCFLAGS
    %LD                  mpiifort
    %LDFLAGS             -lstdc++
    %FPPFLAGS            -P -traditional
    %AR                  ar
    %ARFLAGS             rs
    %MK                  make
    %USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
    %USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
    
    %CC                  cc
    %CFLAGS              -O0
    
  • Compilers

    mpiifort

    mpiifort -v
    mpiifort for the Intel(R) MPI Library 2021.8 for Linux*
    Copyright Intel Corporation.
    ifort version 2021.8.0
    

    mpiicc

    mpiicc -v
    mpiicc for the Intel(R) MPI Library 2021.8 for Linux*
    Copyright Intel Corporation.
    icc: remark #10441: The Intel(R) C++ Compiler Classic (ICC) is deprecated and will be removed from product release in the second half of 2023. The Intel(R) oneAPI DPC++/C++ Compiler (ICX) is the recommended compiler moving forward. Please transition to use this compiler. Use '-diag-disable=10441' to disable this message.
    icc version 2021.8.0 (gcc version 11.3.0 compatibility)
    
  • cpp_ORCA2_LIM.fcm

    bld::tool::fppkeys key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_agrif
    
  • A compilation log is attached here:

Update: I forgot to edit C compiler used in the compilation. Everything works after I set %CC to mpiicc