Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

(RESOLVED) netcdf-fortran configure error

anelito

New member
Hi,

I try to install netcdf in UBUNTU 24.04.1 following:
Compiling WRF

I type:
export DIR=$(pwd)
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib
export CPPFLAGS=-I$DIR/grib2/include
echo "Rutas establecidas"

tar xzvf netcdf-c-4.7.2.tar.gz
cd netcdf-c-4.7.2
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf
cd ..
echo "netcdf-c-4.7.2 instalado"

export LIBS="-lnetcdf -lz"
tar xzvf netcdf-fortran-4.5.2.tar.gz
cd netcdf-fortran-4.5.2
/configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared

and I got an error:
checking netcdf.h usability... no
checking netcdf.h presence... no
checking for netcdf.h... no
configure: error: netcdf.h could not be found. Please set CPPFLAGS.

What should I do?
How should I set CPPFLAGS?
Or should I try newer netcdf version?

thanks in advance,
A
 
Last edited:
You need to set CPPFLAGS and LDFLAGS to .../netcdf/... too.

For example: export LDFLAGS=-L$DIR/grib2/lib:-L$DIR/netcdf/lib
you are also going to need these too

FFLAGS=-fallow-argument-mismatch
FCFLAGS=-fallow-argument-mismatch

so total you will need to do this

FFLAGS=-fallow-argument-mismatch -m64
FCFLAGS=-fallow-argument-mismatch -m64
LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH (or something similar)
 
Done, now I can install netcdf successfully.

then, trying to install mpich-3.0.4 I got this error:

checking whether gfortran allows mismatched arguments... no
configure: error: The Fortran compiler gfortran will not compile files that call
the same routine with arguments of different types.

What should I do?

Thanks in advance,
A
 
Done, now I can install netcdf successfully.

then, trying to install mpich-3.0.4 I got this error:

checking whether gfortran allows mismatched arguments... no
configure: error: The Fortran compiler gfortran will not compile files that call
the same routine with arguments of different types.

What should I do?

Thanks in advance,
A
Finally I solved this problem installing the last mpich version mpich-4.2.3.
 
you are also going to need these too

FFLAGS=-fallow-argument-mismatch
FCFLAGS=-fallow-argument-mismatch

so total you will need to do this

FFLAGS=-fallow-argument-mismatch -m64
FCFLAGS=-fallow-argument-mismatch -m64
LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH (or something similar)
when I set:
export LDFLAGS=-L$DIR/grib2/lib:-L$DIR/netcdf/lib
export CPPFLAGS=-I$DIR/netcdf/include:-L$DIR/netcdf/include

netcdf-c-4.7.2 is installed successfully but netcdf-fortran-4.5.2 fails. The config.og says:
********************************************************************************
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3939: $? = 1
configure:3928: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:3939: $? = 1
configure:3959: checking whether the C compiler works
configure:3981: gcc -I/home/a/WRF/LIBRARIES/netcdf/include:-L/home/a/WRF/LIBRARIES/netcdf/include -L/home/a/WRF/LIBRARIES/grib2/lib:-L/home/a/WRF/LIBRARIES/netcdf/lib conftest.c -lnetcdf >&5
/usr/bin/ld: cannot find -lnetcdf: No such file or directory
collect2: error: ld returned 1 exit status
********************************************************************************
what shoul I do to set:
export LDFLAGS=-L$DIR/grib2/lib:-L$DIR/netcdf/lib
export CPPFLAGS=-I$DIR/netcdf/include:-L$DIR/netcdf/include
?

my best regards,
A
 
Finally I installed all the libreries in Ubuntu 24.04 64bits.

Previously I installed/updated all these packages:
sudo apt-get install build-essential csh gfortran m4 curl perl libopenmpi-dev libhdf5-openmpi-dev libpng-dev netcdf-bin libnetcdff-dev

then using the next script I installed the libraries:


#!/bin/bash

export DIR=$(pwd)
export CC=gcc
export CXX=g++
export FC=gfortran
export F77=gfortran
export FFLAGS="-fallow-argument-mismatch -m64"
export FCFLAGS="-fallow-argument-mismatch -m64"
export JASPERLIB=$DIR/grib2/lib
export JASPERINC=$DIR/grib2/include
export LDFLAGS=-L$DIR/grib2/lib:-L$DIR/netcdf/lib
export CPPFLAGS=-I$DIR/grib2/include:-I$DIR/netcdf/include
export LD_LIBRARY_PATH=$DIR/grib2/lib:$LD_LIBRARY_PATH
echo "Rutas establecidas"

tar xzvf netcdf-c-4.9.2.tar.gz
cd netcdf-c-4.9.2
./configure --prefix=$DIR/netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf
cd ..
echo "netcdf-c-4.9.2 instalado"

export LIBS="-lnetcdf"
tar xzvf netcdf-fortran-4.6.1.tar.gz
cd netcdf-fortran-4.6.1
./configure --prefix=$DIR/netcdf --disable-shared
make
make install
export PATH=$DIR/netcdf/bin:$PATH
export NETCDF=$DIR/netcdf
cd ..
echo "netcdf-fortran-4.6.1 instalado"

tar xzvf mpich-4.2.3.tar.gz
cd mpich-4.2.3
export FFLAGS=-fallow-argument-mismatch
./configure --prefix=$DIR/mpich
#./configure --prefix=$DIR/mpich --with-device=ch3:nemesis --enable-fast=all,O3 --disable-float --enable-threads=multiple
make
make install
export PATH=$DIR/mpich/bin:$PATH
cd ..
echo "mpich-4.2.3 instalado"

#zlib1g en synaptic
tar xzvf zlib-1.3.1.tar.gz #or just .tar if no .gz present
cd zlib-1.3.1
./configure --prefix=$DIR/grib2
make
make install
cd ..
echo "zlib-1.3.1 instalado"

#anntes en synaptic
tar xzvf libpng-1.2.50.tar.gz #or just .tar if no .gz present
cd libpng-1.2.50
./configure --prefix=$DIR/grib2
make
make install
cd ..
echo "libpng-1.2.50 instalado"

tar xzvf jasper-1.900.1.tar.gz #or just .tar if no .gz present
cd jasper-1.900.1
./configure --prefix=$DIR/grib2
make
make install
cd ..
echo "jasper-1.900.1 instalado"

exec bash
exit

Thanks and regards!
 
Last edited:
Top