Help with NEMO Compilation Error: Linking Issue fcm_internal

Hi everyone,

I’m trying to run one of the test cases in NEMO and encountering a compilation error during a linking step. I’m following this example configuration: apptainer-nemo.def.

The command I’m using to compile the test is:

./makenemo -m local -a DOME -n DOME_v2

Here’s my local configuration file:

%NCDF_HOME           /nemo/installs  
%HDF5_HOME           /nemo/installs  
%XIOS_HOME           /nemo/sources/XIOS/xios  
%OASIS_HOME            

%NCDF_INC            -I%NCDF_HOME/include   
%NCDF_LIB            -L%NCDF_HOME/lib -lnetcdf -lnetcdff -L%HDF5_HOME/lib -lhdf5_hl -lhdf5 -lcurl  
%XIOS_INC            -I%XIOS_HOME/inc  
%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++  
%OASIS_INC             
%OASIS_LIB            

%CPP                 cpp -Dkey_nosignedzero  
%FC                  mpif90 -c -cpp  
%FCFLAGS             -O3 -fdefault-real-8 -ffree-line-length-none -fno-second-underscore -Dgfortran -funroll-all-loops -fcray-pointer -fallow-argument-mismatch  
%FFLAGS              %FCFLAGS  
%LD                  mpif90  
%LDFLAGS             -Wl,-rpath,$INSTDIR/lib  
%FPPFLAGS            -P -C -traditional  
%AR                  ar  
%ARFLAGS             rs  
%MK                  make  
%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC  
%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB  

%CC                  gcc  
%CFLAGS              

When I run the makenemo command, I get this error:

2/AGRIFLIB/obj/main.o:(.bss+0x4ef8): first defined here  
/usr/bin/ld: /nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/lib/lib__fcm__conv.a(writeinfile.o):(.bss+0x4efc): multiple definition of `value_char_size3'; /nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/obj/main.o:(.bss+0x4efc): first defined here  
...  
collect2: error: ld returned 1 exit status  
fcm_internal load failed (256)  
make: *** [/nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/Makefile:406: conv] Error 1  
make -f /nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/Makefile -j 1 all failed (2) at /nemo/sources/NEMO/NEMOGCM/ext/FCM/bin/../lib/Fcm/Build.pm line 597.  

On further inspection, this seems to be the problematic command:

gcc -o conv /nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/obj/main.o -L/nemo/sources/NEMO/NEMOGCM/tests/DOME_v2/AGRIFLIB/lib -l__fcm__conv

The error is:

/usr/bin/ld: cannot find -l__fcm__conv: No such file or directory  
collect2: error: ld returned 1 exit status  

I’ve verified the FCM installation, and the bin and lib directories seem to be present:

root@88e9669300bd:/nemo/sources/NEMO/NEMOGCM# ls ext/FCM/bin/  
fcm  fcm_graphic_diff  fcm_graphic_merge  fcm_gui  fcm_internal  fcm_setup_konqueror  fcm_update_version_dir.pl  
root@88e9669300bd:/nemo/sources/NEMO/NEMOGCM# ls ext/FCM/lib/Fcm/  
Base.pm   BuildSrc.pm   CLI.pm      Cm.pm               CmUrl.pm         Dest.pm       ExtractConfigComparator.pm  Interactive     Keyword.pm      Timer.pm  
Build     BuildTask.pm  CfgFile.pm  CmBranch.pm         Config.pm        Exception.pm  ExtractFile.pm              Interactive.pm  ReposBranch.pm  Util  
Build.pm  CLI           CfgLine.pm  CmCommitMessage.pm  ConfigSystem.pm  Extract.pm    ExtractSrc.pm               Keyword         SrcDirLayer.pm  Util.pm  

I’m stuck on how to resolve this linkage issue. Does anyone have any tips or suggestions?

Thanks in advance! :blush:

Hi! I encountered the same error (“multiple definition of”), and it turned out AGRIF did not like the gcc verison i was using (11.4.0). So, I switched to intel compilers and it worked. In my *fcm I used the following:
%FC mpiifort -fc=ifx -c -cpp
%FC mpiifort -fc=ifx -c -cpp
%CC mpiicc -cc=icx
%CFLAGS -O0 -fcommon -Wno-implicit-function-declaration