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

Test #1: Fortran + C + NetCDF | errors occur but display correct content on screen

HaHaHa

New member
Hi there,

I just installed libraries and tried to test it, following instruction step by step.
There were some errors after running each comment, but the screen displayed correctly, so can anyone help me to check if I install the libraries correctly please? If it's not correct, could you please point it out?


gfortran -c 01_fortran+c+netcdf_f.f
01_fortran+c+netcdf_f.f:5:0:
5 | INCLUDE 'netcdf.inc'
|
Fatal Error: Cannot open included file 'netcdf.inc'
compilation terminated.

gcc -c 01_fortran+c+netcdf_c.c
#return nothing

gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf
ld: file not found: 01_fortran+c+netcdf_f.o
collect2: error: ld returned 1 exit status


./a.out
C function called by Fortran
Values are xx = 2.00 and ii = 1
SUCCESS test 4 fortran calling c


Mac Intel OS13
gcc (Homebrew GCC 12.2.0) 12.2.0
NetCDF 4.9
 
Hi there,

I just installed libraries and tried to test it, following instruction step by step.
There were some errors after running each comment, but the screen displayed correctly, so can anyone help me to check if I install the libraries correctly please? If it's not correct, could you please point it out?


gfortran -c 01_fortran+c+netcdf_f.f
01_fortran+c+netcdf_f.f:5:0:
5 | INCLUDE 'netcdf.inc'
|
Fatal Error: Cannot open included file 'netcdf.inc'
compilation terminated.

gcc -c 01_fortran+c+netcdf_c.c
#return nothing

gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf
ld: file not found: 01_fortran+c+netcdf_f.o
collect2: error: ld returned 1 exit status


./a.out
C function called by Fortran
Values are xx = 2.00 and ii = 1
SUCCESS test 4 fortran calling c


Mac Intel OS13
gcc (Homebrew GCC 12.2.0) 12.2.0
NetCDF 4.9
can you post your $PATH & LD_LIBRARY_PATH?

Usually these errors occur when NETCDF folder isn't in them.
 
can you post your $PATH & LD_LIBRARY_PATH?

Usually these errors occur when NETCDF folder isn't in them.
Hi there, thanks for your reply. A bit long, but I tried to give more details :). Thank you for your time and help.

It has a netcdf folder under LIBRARIES, /Users/username/forProgram/Build_WRF/LIBRARIES/netcdf, but no any NetCDF
I linked regarding this (netcdf-c & netcdf-fortran)

I set the following variables again (I typed all as followings on one go, do I need to change the order OR under a specific directory to set those variables?)
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export JASPERINC=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
export LDFLAGS=-L/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export CPPFLAGS=-I/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
export PATH=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/bin:$PATH
export NETCDF=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/NetCDF
export PATH=/Users/username/forProgracdm/Build_WRF/LIBRARIES/mpich/bin:$PATH
export NCDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf
export LD_LIBRARY_PATH=${NCDIR}/lib:${LD_LIBRARY_PATH}
export NFDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf


after setting all above, then
cd netcdf-c-4.9.0
make distclean

./configure --prefix=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf --disable-dap --disable-netcdf-4 --disable-shared

after above, run cp ${NETCDF}/include/netcdf.inc .
still cp: /Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/include/netcdf.inc: No such file or directory
(checked, there is't a netcdf.inc file under include folder, /Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/include,
but there is one in /usr/local/include/netcdf.inc )


echo $PATH
/Users/username/forProgracdm/Build_WRF/LIBRARIES/mpich/bin:/Users/liudeng/forProgram/Build_WRF/LIBRARIES/netcdf/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin

echo &LD_LIBRARY_PATH
[1] 79672
[1] + done echo
zsh: command not found: LD_LIBRARY_PATH


I run which ncdump shows me "/opt/local/bin/ncdump" (but there isn't netcdf folder under this path)
and then run ncdump shows me"netcdf library version 4.9.0 of Jan 6 2023 18:08:56 $"

There isn't netcdf folder under /usr/local, but /usr/local/Homebrew.

And how can I ensure the libraries are installed with same compilers? (I used homebrew gcc for WRF & WPS installation.)
  • It is important to note that these libraries must all be installed with the same compilers as will be used to install WRF and WPS.

Many many many thanks.
 
Last edited:
Give this a try:
Your full path to the NETCDF folder needs to be in the $PATH variable
Code:
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export JASPERINC=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
export LDFLAGS=-L/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export CPPFLAGS=-I/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
[QUOTE]
export PATH=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/NetCDF/bin:$PATH
[/QUOTE]
export NETCDF=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/NetCDF
export PATH=/Users/username/forProgracdm/Build_WRF/LIBRARIES/mpich/bin:$PATH
export NCDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf
export LD_LIBRARY_PATH=${NCDIR}/lib:${LD_LIBRARY_PATH}
export NFDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf
 
Give this a try:
Your full path to the NETCDF folder needs to be in the $PATH variable
Code:
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export JASPERINC=/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
export LDFLAGS=-L/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/lib
export CPPFLAGS=-I/Users/username/forProgram/Build_WRF/LIBRARIES/grib2/include
[QUOTE]
export PATH=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/NetCDF/bin:$PATH
[/QUOTE]
export NETCDF=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf/NetCDF
export PATH=/Users/username/forProgracdm/Build_WRF/LIBRARIES/mpich/bin:$PATH
export NCDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf
export LD_LIBRARY_PATH=${NCDIR}/lib:${LD_LIBRARY_PATH}
export NFDIR=/Users/username/forProgram/Build_WRF/LIBRARIES/netcdf
Thanks for your reply.
I made new Build_WRF directory and tried export PATH=/Users/username/Build_WRF/LIBRARIES/netcdf/NetCDF/bin:$PATH
But still the same error, "...Build_WRF/LIBRARIES/netcdf/NetCDF/include/netcdf.inc: No such file or directory", and I checked netcdf folder, still only share, lib, include, and bin four folders, no NetCDF folder.

These are my steps:

#set env variables
export CC=gcc
export CXX=g++
export FC=gfortran
export FCFLAGS=-m64
export F77=gfortran
export FFLAGS=-m64
export JASPERLIB=/Users/username/Build_WRF/LIBRARIES/grib2/lib
export JASPERINC=/Users/username/Build_WRF/LIBRARIES/grib2/include
export LDFLAGS=-L/Users/username/Build_WRF/LIBRARIES/grib2/lib
export CPPFLAGS=-I/Users/username/Build_WRF/LIBRARIES/grib2/include
export PATH=/Users/username/Build_WRF/LIBRARIES/netcdf/NetCDF/bin:$PATH
export NETCDF=/Users/username/Build_WRF/LIBRARIES/netcdf/NetCDF
export PATH=/Users/username/Build_WRF/LIBRARIES/mpich/bin:$PATH
export NCDIR=/Users/username/Build_WRF/LIBRARIES/netcdf
export LD_LIBRARY_PATH=${NCDIR}/lib:${LD_LIBRARY_PATH}
export NFDIR=/Users/username/Build_WRF/LIBRARIES/netcdf

#build netcdf
tar xzvf netcdf-c-4.9.0.tar.gz
cd netcdf-c-4.9.0
./configure --prefix=/Users/username/Build_WRF/LIBRARIES/netcdf --disable-dap --disable-netcdf-4 --disable-shared
make
make install
cd ..


#build zlib
tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure --prefix=/Users/username/Build_WRF/LIBRARIES/grib2
make
make install
cd ..

#build libpng
tar xzvf libpng-1.2.50.tar.gz
cd libpng-1.2.50
./configure --prefix=/Users/username/Build_WRF/LIBRARIES/grib2
make
make install
cd ..

#build jasper
tar xzvf jasper-1.900.1.tar.gz
cd jasper-1.900.1
./configure --prefix=/Users/username/Build_WRF/LIBRARIES/grib2
make
make install
cd ..


"cd" into the TESTS directory then
tar -xf Fortran_C_NETCDF_MPI_tests.tar
cp ${NETCDF}/include/netcdf.inc .

output:
cp: /Users/username/Build_WRF/LIBRARIES/netcdf/NetCDF/include/netcdf.inc: No such file or directory


Almost every “make install”, there is output like this:
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.


Is this related to why there isn’t NetCDF under netcdf?
 
Just so I understand better, you are using macos and homebrew gcc?
Hi, thanks for your reply. Not too sure macos(sorry I'm new to terminal), but I use homebrew gcc.

gcc --version
gcc (Homebrew GCC 12.2.0) 12.2.0

I tested regarding System Environment Tests
All outputs are the same as this link.
 
Top