Main menu


Problems compiling paleotopo.f90

4 posts / 0 new
Last post
Problems compiling paleotopo.f90


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


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

CESM Software Engineer


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.f90

Thank you very much! 


I think only -lnetcdff was necessary. When debugging NetCDF I usually do  the following test:

filename: test_nc.f90

program test_nc
      implicit none
      include ''
end program test_nc

Then compile it with:

gfortran -I<path_to_netcdf_inc> test_nc.f90 -o test_nc -lnetcdff

Then I can just experiment with -fsecond-underscore -fno-underscoring -lnetcdf (without additional f)

If you have NetCDF installed on system paths, "<path_to_netcdf_inc>" would be either /usr/include or /usr/local/include

Else, additionally you should specify the Library search path, i.e. -I${HOME}/mynetcdfinst/include -L${HOME}/mynetcdfinst/lib

This can help debug NetCDF installations and ensure you are using the version you want to.

Log in or register to post comments

Who's new

  • dsc254@...
  • zhanghp@...
  • 2guido@...
  • fengjie@...
  • huzhy2010@...