0

I am trying to install netcdf module for fortran. I am following steps from this link http://albeniz.eng.uci.edu/software/WRFCMAQ/NetCDF_installation_for_C_and_Fortran_libraries-HPC.pdf

I am getting error:

configure: netCDF 4.4.1.1
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
configure: checking user options
checking whether a win32 DLL is desired... no
checking whether a NCIO_MINBLOCKSIZE was specified... 256
checking if fsync support is enabled... no
checking if jna bug workaround is enabledd... no
checking whether extra valgrind tests should be run... no
checking whether we should build netCDF-4... no
checking do we require hdf5 dynamic-loading support... yes
checking whether reading of HDF4 SD files is to be enabled... no
checking whether to fetch some sample HDF4 files from Unidata ftp site to test HDF4 reading (requires wget)... no
checking whether we should attempt to install netcdf-fortran (EXPERIMENTAL)... no
checking whether extra example tests should be run... no
checking whether parallel IO tests should be run... no
checking whether a default chunk size in bytes was specified... 4194304
checking whether a maximum per-variable cache size for HDF5 was specified... 67108864
checking whether a number of chunks for the default per-variable cache was specified... 10
checking whether a default file cache size for HDF5 was specified... 4194304
checking whether a default file cache maximum number of elements for HDF5 was specified... 1009
checking whether a default cache preemption for HDF5 was specified... 0.75
checking whether netCDF-4 logging is enabled... no
checking whether DAP client is to be built... no
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/mirzaba/test/FSM2/srcNETCDF/netcdf-4.4.1.1':
configure: error: C compiler cannot create executables
See `config.log' for more details

This is my config.log

## ---------------- ##

ac_cv_build=x86_64-unknown-linux-gnu ac_cv_env_CC_set=set ac_cv_env_CC_value=gcc ac_cv_env_CFLAGS_set=set ac_cv_env_CFLAGS_value=-O ac_cv_env_CPPFLAGS_set=set ac_cv_env_CPPFLAGS_value='-DNDEBUG -DgFortran' ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_LDFLAGS_set= ac_cv_env_LDFLAGS_value= ac_cv_env_LIBS_set= ac_cv_env_LIBS_value= ac_cv_env_LT_SYS_LIBRARY_PATH_set= ac_cv_env_LT_SYS_LIBRARY_PATH_value= ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set= ac_cv_env_host_alias_value= ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_host=x86_64-unknown-linux-gnu ac_cv_path_install='/usr/bin/install -c' ac_cv_path_mkdir=/bin/mkdir ac_cv_prog_AWK=gawk ac_cv_prog_ac_ct_CC=gcc ac_cv_prog_make_make_set=yes ac_cv_target=x86_64-unknown-linux-gnu am_cv_make_support_nested_variables=yes

-----------------

Output variables.

-----------------

                                                                                         167,1         37%

steeldriver
  • 136,215
  • 21
  • 243
  • 336
  • 1
    Is there any particular reason you are not using the pre-built libnetcdf-dev / libnetcdff-dev from the Ubuntu repository? – steeldriver Feb 13 '23 at 21:33
  • Not really, I think I just don't know how to do that. I can explain what I am trying to do. I am trying to compile a model on google cloud virtual machine. I am cloning it from git (https://github.com/RichardEssery/FSM2), installing gfortran and then I am trying to install netcdf module. I don't know how to go about it. – Bareera Mirza Feb 13 '23 at 22:11
  • Well you haven't mentioned what Ubuntu version you are using, but on 22.04 I am able to build FSM2 from the git source with netcdf simply by installing the libnetcdff-dev package (from the universe repository) and editing the compil_nc.sh file to correct the include and library paths – steeldriver Feb 13 '23 at 23:23
  • I am using Ubuntu 18.04.6 LTS Can you tell me how did you edit compile_nc.sh file? – Bareera Mirza Feb 14 '23 at 03:07
  • This is what my compil_nc.sh file look like after I edit it

    $FC -O3 -c -I/usr/lib/gcc/x86_64-linux-gnu FSM2_temp.f90 $FC -O3 -c -I/usr/include FSM2_temp.f90 -o FSM2 #$FC -O3 -c -I/usr/lib64/gfortran/modules FSM2_temp.f90 #$FC -o -c -I/usr/include/netcdf.mod FSM2_temp.f90 $FC -o FSM2 FSM2_temp.o -L/usr/include -lnetcdff #$FC -o FSM2 FSM2_temp.o -L/usr/lib64 -lnetcdff mv FSM2 ../FSM2

    rm out rm .mod rm .o rm FSM2_temp.f90 cd ..

    – Bareera Mirza Feb 14 '23 at 03:25
  • I've added details below – steeldriver Feb 14 '23 at 12:22

1 Answers1

0

If you really want to install netcdf from source, you will need to troubleshoot the error:

configure: error: C compiler cannot create executables

Some possible reasons for the error are

  • compiler or linker improperly installed

  • an incompatible linker elsewhere on your PATH

  • the filesystem on which the target directory resides mounted with the noexec option


However the Ubuntu "universe" repository already contains pre-built packages for both the C/C++ (libnetcdf-dev) and Fortran (libnetcdff-dev) netcdf ABIs. So if your real goal is just to build FSM2 with netcdf support from the github repo, all you need to do is:

  • enable the universe repository if you have not already done so - see for example How do I enable the "Universe" repository?

  • install the libnetcdff-dev package (which will install the C/C++ dev and runtime packages as dependencies)

     sudo apt update && sudo apt install libnetcdff-dev
    
  • modify the FSM2 package's compil_nc.sh script to set the module include and library paths to those used by the Ubuntu package:

     $ diff compil_nc.sh.orig compil_nc.sh
     43,44c43,44
     < $FC -O3 -c -I/usr/lib64/gfortran/modules FSM2_temp.f90
     < $FC -o FSM2 FSM2_temp.o -L/usr/lib64 -lnetcdff
     ---
     > $FC -O3 -c -I/usr/include FSM2_temp.f90
     > $FC -o FSM2 FSM2_temp.o -L/usr/lib/x86_64 -lnetcdff
    
steeldriver
  • 136,215
  • 21
  • 243
  • 336