Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Problems compiling paleotopo.f90

Hi, 

We are having trouble compiling paleotopo.f90. We have tried in both Mac OS and MintLinux.
Our Fortran compiler is GNU Fortran 4.7.2.
Our NetCDF version is 4.2.
The following message shows up:

/tmp/ccw4171p.o: na função `add_topo_':
paleotopo.f90:(.text+0x5b8d): undefined reference for `nf_open_'
paleotopo.f90:(.text+0x5bd6): undefined reference for`nf_inq_varid_'
paleotopo.f90:(.text+0x5c26): undefined reference for `nf_inq_var_'
paleotopo.f90:(.text+0x5c5b): undefined reference for `nf_inq_dim_'
paleotopo.f90:(.text+0x5c94): undefined reference for `nf_inq_dim_'
paleotopo.f90:(.text+0x61b3): undefined reference for`nf_get_var_real_'
paleotopo.f90:(.text+0x61cd): undefined reference for `nf_close_'
collect2: error: ld returned 1 exit status

We suspect that it might be related to our netCDF version but we are not sure about it. 
We appreciate any help. Thank you very much in advance

Maria Pivel
 

jedwards

CSEG and Liaisons
Staff member
Oi Maria,
The netcdf version that you are using requires a seperate fortran download and build.  Make sure that you have and are linking the libnetcdff.a file. - Jim
 
We solved the problem. You were right, Jim.We found other persons with the same problem and we solved it using the following command: gfortran -I /opt/local/include/ -L /opt/local/lib/ -lnetcdff -lnetcdf -o paleotopo paleotopo.f90Thank you very much! 
 
I think only -lnetcdff was necessary. When debugging NetCDF I usually do  the following test:filename: test_nc.f90program test_nc
      implicit none
      include 'netcdf.inc'
      print*,nf_inq_libvers()
end program test_ncThen compile it with:gfortran -I test_nc.f90 -o test_nc -lnetcdffThen I can just experiment with -fsecond-underscore -fno-underscoring -lnetcdf (without additional f)If you have NetCDF installed on system paths, "" would be either /usr/include or /usr/local/includeElse, additionally you should specify the Library search path, i.e. -I${HOME}/mynetcdfinst/include -L${HOME}/mynetcdfinst/libThis can help debug NetCDF installations and ensure you are using the version you want to.
 
Top