[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #WCR-337446]: problems with NETCDF4



Hi Sujay,

> I am trying to work with NETCDF4 and I built the library with the following 
> versions.
> NETCDF 4.1.3
> HDF5 1.8.8
> zlib 1.2.6
> 
> The make check install seems to work and completed successfully.
> 
> I then wrote this small test program:
> 
> program writeNETCDF
> 
> use netcdf
> 
> implicit none
> 
> character*50 :: fname
> integer      :: iret,ftn
> 
> fname = 'test.nc'
> iret = nf90_create(path=trim(fname),cmode=nf90_clobber, &
> ncid=ftn)
> print*, iret, ftn
> 
> end program writeNETCDF
> 
> I used the following commands to compile the code:
> ifort -c -g -u -traceback -fpe0 -nomixed_str_len_arg -names lowercase 
> -convert big_endian -assume by
> terecl -I/discover/nobackup/projects/lis/libs/netcdf-4.1.3/include/ 
> writeNETCDF.F90
> 
> ifort -o writeNETCDF writeNETCDF.o 
> -L/discover/nobackup/projects/lis/libs/netcdf-4.1.3/lib/ -lnetcdf
> I get the following linking error: 
> /gpfsm/dhome/svkumar/Tests/netcdf/writeNETCDF.F90:11: undefined reference to 
> `netcdf_mp_nf90_create_'
> 
> So then I added modified the compile script to include -lnetcdff
> 
> ifort -o writeNETCDF writeNETCDF.o 
> -L/discover/nobackup/projects/lis/libs/netcdf-4.1.3/lib/ -lnetcdf -lnetcdff
> 
> Now the compile process worked fine. When I run the code, I get the following 
> output
> 
> /Tests/netcdf % ./writeNETCDF
> 0       65536
> 
> So the ncid value seems wrong and the any following Netcdf calls with this 
> ncid fails.

That ncid value would be correct in netCDF-4, even for a classic format file,
because the top 16 bits of the ncid identify the open file and the bottom 16 
bits
identify the group within the open file, in case it is a netCDF-4 file with 
groups.
The ncid is just supposed to be an opaque file handle used temporarily for open 
files
and groups.

I tried your program, adding a definition of a dimension, and it seemed to work 
fine:

program writeNETCDF

use netcdf

implicit none

character*50 :: fname
integer      :: iret,ftn
integer      :: dimid

fname = 'test.nc'
iret = nf90_create(path=trim(fname),cmode=nf90_clobber, &
ncid=ftn)
print*, iret, ftn
iret = nf90_def_dim(ftn, "n", 10, dimid)
iret = nf90_close(ftn)

end program writeNETCDF

After compiling and running the program, ncdump showed the file was a classic
format netCDF file with the expected contents:

support$ gfortran -I/usr/local/include wcr.f90 -L/usr/local/lib -lnetcdff  
-lnetcdf -o wcr
support$ LD_LIBRARY_PATH=/usr/local/lib ./wcr
           0       65536
support$ ls -l test.nc
-rw-rw-r-- 1 russ ustaff 44 Feb 14 11:26 test.nc
support$ ncdump -k test.nc
classic
support$ ncdump test.nc
netcdf test {
dimensions:
        n = 10 ;
}

Please let us know if this doesn't work for you.

--Russ


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: WCR-337446
Department: Support netCDF
Priority: Normal
Status: Closed