Re: undefined reference with include 'netcdf.inc'



On Jun 27, 1:16 pm, deadpickle <deadpic...@xxxxxxxxx> wrote:
I am trying to compile a fortran 90 code (snippet):

include 'netcdf.inc'
!Open file and check for error
print *, "Open ", filename, "for NetCDF reading"
status = NF_OPEN(filename,0,ncid)
if (status /= NF_NOERR) then
print *, ' --! ERROR: Problem opening ', ADJUSTR(filename)
stop
endif
print *,"---Done"

with netcdf.inc containing:
integer nf_open
! (character*(*) path,
! integer mode,
! integer ncid)
external nf_open

On compiling I get the error:
In function `crefcell_mp_crefextract_.':
test1.f90: undefined reference to `nf_open_'

Any ideas on what this error means and how to resolve it?


Richard mentioned one possibility, which is that the
command line for the linker does not include the netcdf
library. Another possibility is that you are using a
version of the library that uses the f2c underscore
conventions. If you do nm on the library and see the
symbol nf_open__ is defined, that is the problem. If
that is the problem, a variety of fixes are possible.
Too many, unfortunately, to start making blind suggestions.

Bob Corbett
.



Relevant Pages

  • [patch 14/67] USB: Allow compile in g_ether, fix typo
    ... Allows compiling g_ether in and fixes a typo with MUSB_HDRC ...
    (Linux-Kernel)
  • Re: Header files
    ... IMO it would benefit the OP to write directly in Fortran. ... use "float" variables and Fortran floating-point calculations should ... always be defined when compiling and using BoxLib. ...
    (comp.lang.fortran)
  • How to compile xv on YDL 4.1
    ... I've found that compiling xv3.10a on Yellow Dog Linux ... requires some fiddling with the config files and the source code. ...
    (comp.os.linux.powerpc)
  • Re: Header files
    ... IMO it would benefit the OP to write directly in Fortran. ... use "float" variables and Fortran floating-point calculations should ... always be defined when compiling and using BoxLib. ...
    (comp.lang.fortran)
  • Re: Problem with a conditional part of Makefile
    ... compiling. ... misunderstanding the error function in gmake? ... wwith a tab - otherwise it's interpreted as a command, ...
    (comp.unix.programmer)