NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi netcdf group: We have installed netcdf 3.5 on a Linux system running RedHat 7.3. I am using pgf90 4.0-2 to compile a small f90 code, and am getting "undefined reference" errors: (sundog) foster : gmake pgf90 -c -I/opt/local/include rdmgcm.F pgf90 -c -I/opt/local/include mkcdf.F pgf90 -c -I/opt/local/include mkncfile.F pgf90 -o mkcdf mkcdf.o mkncfile.o rdmgcm.o -L/opt/local/lib -lnetcdf mkncfile.o: In function `mkncfile_': mkncfile.o(.text+0x110): undefined reference to `nf_create_' mkncfile.o: In function `handle_ncerr_': mkncfile.o(.text+0x77a): undefined reference to `nf_strerror_' gmake: *** [mkcdf] Error 2 (sundog) foster : I am using #include "netcdf.inc" in mkncfile.F, and it is apparently finding this file in /opt/local/include. The lib libnetcdf.a is in /opt/local/lib, and it has both nf_create and nf_strerror. I will attach the Makefile and mkncfile.F. Thanks for any suggestions, --Ben ----------------------------------------------------------------------- Ben Foster High Altitude Observatory (HAO) foster@xxxxxxxx phone: 303-497-1595 fax: 303-497-1589 Nat. Center for Atmos. Res. P.O. Box 3000 Boulder CO 80307 USA -----------------------------------------------------------------------
# UNAMES = $(shell uname -s) #----------------------------------------------------------------------- ifeq ($(UNAMES),Linux) SHELL=/bin/csh EXEC = mkcdf FC = pgf90 #FFLAGS = -I/local/d/foster/netcdf-3.5.0/include #LIBS = -L/local/d/foster/netcdf-3.5.0/lib -lnetcdf FFLAGS = -I/opt/local/include LIBS = -L/opt/local/lib -lnetcdf LDFLAGS endif #----------------------------------------------------------------------- ifeq ($(UNAMES),SunOS) SHELL=/bin/csh EXEC = mkcdf FC = f90 FFLAGS = -I/opt/local/include LIBS = -L/opt/local/lib -lnetcdf LDFLAGS endif #----------------------------------------------------------------------- # .SUFFIXES: .F include Objects #OBJS = mkcdf.F rdmgcm.F mkncfile.F $(EXEC): $(OBJS) $(FC) -o $@ $(OBJS) $(LDFLAGS) $(LIBS) include Depends .f.o: $(FC) -c $(FFLAGS) $< .F.o: $(FC) -c $(FFLAGS) $<
! subroutine mkncfile(fileout) implicit none #include "netcdf.inc" ! ! Args: character(len=*),intent(in) :: fileout ! ! Local: integer,save :: ncalls=0 integer :: istat,ncid character(len=120) :: char120 ! ncalls = ncalls+1 write(6,"('mkncfile: ncalls=',i4)") ncalls if (ncalls == 1) then istat = nf_create(fileout,NF_CLOBBER,ncid) if (istat /= NF_NOERR) then write(char120,"('Error return from nf_create for netcdf ', | 'file ',a)") trim(fileout) call handle_ncerr(istat,char120) ncid = 0 else write(6,"('Created netcdf file ',a,' ncid=',i8)") | trim(fileout),ncid endif endif end subroutine mkncfile !------------------------------------------------------------------- subroutine handle_ncerr(istat,msg) implicit none #include "netcdf.inc" ! ! Handle a netcdf lib error: ! integer,intent(in) :: istat character(len=*),intent(in) :: msg ! write(6,"(/72('-'))") write(6,"('>>> Error from netcdf library:')") write(6,"(a)") trim(msg) write(6,"('istat=',i5)") istat write(6,"(a)") nf_strerror(istat) write(6,"(72('-')/)") return end subroutine handle_ncerr
netcdfgroup
archives: