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

[netCDF #VZH-911645]: my 4-D netcdf data is not read by unidata fortran codes



Pankaj,

I wrote:

> > But this installation-method gave another type of error in executing a
> > fortran code. Compiling a fortran program to read netcdf was okay using
> > below command:
> > gfortran -o test -I/usr/include pgmread-netcdf2.f90 -lnetcdf -
> > lnetcdff
> > However, executing the code gives below error:
> > ./test: symbol lookup error: /usr/local/lib/libnetcdff.so.5:
> > undefined symbol: ncerr
> 
> Try changing the order of the libraries:
> 
> gfortran -o test -I/usr/include pgmread-netcdf2.f90 -lnetcdff -lnetcdf
> 
> because the netcdf Fortran library (libnetcdff.so) calls functions
> from the netCDF C library (libnetcdf.so).  It seems you may also need
> 
> -L/usr/local/lib
> 
> before specification of the libraries.  Without that, you may be getting
> a different version of the libraries installed previously somewhere else.

Also, I hadn't noticed that you are using -I/usr/include instead of 
-I/usr/local/include.  If you have installed the netCDF Fortran libraries
using --prefix=/usr/local, then you should be using

  gfortran -o test -I/usr/local/include pgmread-netcdf2.f90 \
    -L/usr/local/lib -lnetcdff -lnetcdf

and to run test, you would probably need to set the LD_LIBRARY_PATH
environment variable to include /usr/local/lib, as in

  LD_LIBRARY_PATH=/usr/local/lib test

Make sure you don't have a previous installation in /usr/lib and 
/usr/include, because in that case the older installation will
be used instead of the new installation under /usr/local.

You can avoid the necessity of setting LD_LIBRARY_PATH by
following the instructions in the message you got from running
"make install":

  ----------------------------------------------------------------------
  Libraries have been installed in:
     /usr/local/lib

  If you ever happen to want to link against installed libraries
  in a given directory, LIBDIR, you must either use libtool, and
  specify the full pathname of the library, or use the `-LLIBDIR'
  flag during linking and do at least one of the following:
     - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
       during execution
     - add LIBDIR to the `LD_RUN_PATH' environment variable
       during linking
     - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
     - have your system administrator add LIBDIR to `/etc/ld.so.conf'

  See any operating system documentation about shared libraries for
  more information, such as the ld(1) and ld.so(8) manual pages.
  ----------------------------------------------------------------------

--Russ


> If that doesn't work for you, you might find it easier to first
> build and install just the netCDF C library from a recent version,
> for example 4.3.1.1, and then install the netCDF Fortran library
> following these detailed instructions:
> 
> http://www.unidata.ucar.edu/netcdf/docs/netcdf-fortran-install.html
> 
> --Russ
> 
> > However, I uninstall netcdf from netcdf-4.1.2 directory and see that
> > compiling and executing codes for reading netcdf is successful and
> > incorporating your suggestions gives some kind of output.
> >
> > Thank you again if you can find something missing in my method of
> > running netcdf modules and libraries.
> > Regards
> > Pankaj
> >
> >
> > ----- Original Message -----
> > From: "Unidata netCDF Support" <address@hidden>
> > Sent Date: 06:34:07 Thu February 13, 2014
> >
> > > Hi Pankaj,
> > >
> > > Sorry, but we don't have the resources for detailed debugging of
> > > user applications.  If you built the netCDF C and Fortan libraries
> > > and "make check" ran successfully, then the library and ncdump are
> > > working as intended.
> > >
> > > If you suspect there is a bug in the library, we would need a small
> > > program that demonstrated the bug by writing data to a netCDF file,
> > > reading the data, and printing an indication of the bug.
> > >
> > > --Russ
> > >
> > > > Please look into the problem I am facing now in reading netcdf data
> > > > using fortran codes. As suggested by you in the below mail, I did
> > some
> > > > corrections in my program for variable declaration. Thus the program
> > is
> > > > executed successfully now and the netcdf data is read by the program
> > and
> > > > the output is also generated.
> > > >
> > > > However, the range of data is  between 1.03624427E-06 to 1.03720561E
> > -06
> > > > in increasing order for 360 (lon) x 180 (lat) x 15 (layers) x 12 (
> > time)
> > > > points. I think the data is not properly generated since ncdump of
> > the
> > > > netcdf data file shows many missing data as well and a different
> > data
> > > > set. I checked with other fortran code also with suggested
> > correction,
> > > > however the program could read netcdf data properly and the output
> > > > generated is same.
> > > >
> > > > ncdump of netcdf data generates below sample:
> > > >
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > _,
> > > > _,
> > > > (many missing data lines)
> > > > :
> > > > :
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > _,
> > > > _, _, _, _, _, _, _, _, _, _, 0.01161965, 0.01172744, 0.0118268,
> > > > 0.01196955, 0.01214784, 0.0123204, 0.01234178, 0.01217634, 0.
> > > > 01188548,
> > > > 0.01164075, 0.01148022, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 0.00113727,
> > > > 0.001201613, 0.001232482, 0.001210016, 0.001129237, 0.001008214,
> > > > 0.000850776, 0.0007075624, 0.0006338682, 0.0006352033, 0.0006716939,
> > > > 0.0007437626, 0.0008677125, 0.001072157, 0.001404119, 0.001935425,
> > > > 0.002639251, 0.003327798, 0.003907743, 0.004484775, 0.004986423,
> > > > 0.00537102, 0.005751694, 0.006038316, 0.006216454, 0.006355461,
> > > > 0.006524057, 0.006707882, 0.006811586, 0.006774242, 0.006615386,
> > > > 0.006460694, 0.006332785, 0.006236786, 0.006161074, 0.006096281,
> > > > 0.006028299, 0.005944978, 0.00588075, 0.005860889, 0.005849245,
> > > > 0.005848445, 0.005817015, 0.005784002, 0.005819898, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > _,
> > > > _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
> > > > :
> > > > :
> > > > afterwards continuous data set for the rest of larger part
> > > > :
> > > > :
> > > > 0.0003057834, 0.0002918573, 0.0002743326, 0.0002530323, 0.0002287087,
> > > > 0.0002033903, 0.0001799934, 0.0001603418, 0.0001450872, 0.0001339376,
> > > > 0.0001261685, 0.0001208666, 0.0001169688, 0.0001133534, 0.0001094718,
> > > > 0.0001055817, 0.0001018786, 9.898411e-05, 9.733205e-05, 9.677732e-05,
> > > > 9.674822e-05, 9.675948e-05, 9.687019e-05, 9.717577e-05, 9.762236e-05,
> > > > 9.797748e-05, 9.793872e-05, 9.735269e-05, 9.620324e-05, 9.464778e-05,
> > > > 9.29976e-05, 9.155437e-05, 9.073644e-05, 9.142152e-05, 9.31278e-05,
> > > > 9.496194e-05, 9.662777e-05, 9.829528e-05, 0.0001000483, 0.0001016511,
> > > > 0.0001030593, 0.0001046747, 0.0001068782, 0.0001098189, 0.0001138458,
> > > > :
> > > > :
> > > >
> > > > ----- Original Message -----
> > > > From: "Unidata netCDF Support" <address@hidden>
> > > > Sent Date: 04:34:50 Thu January 30, 2014
> > > >
> > > > > Hi Pankaj,
> > > > >
> > > > > > I am looking for urgent help in reading 4-D netcdf data. I have
> > > > > > tried to read my data using UNIDATA various fortran codes and
> > > > > > c-program but after successful compilation, "variable not found
> > stop
> > > > > > 2" message is delivered on executing although UNIDATA sample
> > netcdf
> > > > > > files are duly read using these fortran codes.
> > > > >
> > > > > For netcdfread_4D.f90, you are using the wrong variable names for
> > > > > what's actually in the netCDF file you're reading.  Try:
> > > > >
> > > > > !      character (len = *), parameter :: LAT_NAME = "latitude"
> > > > >        character (len = *), parameter :: LAT_NAME = "TLAT"
> > > > > !      character (len = *), parameter :: LON_NAME = "longitude"
> > > > >        character (len = *), parameter :: LON_NAME = "TLONG"
> > > > >
> > > > > For the second program, netcdfread_4D.f90, the same problem occurs,
> > > > > since there is no variable in the file named "data".  If you want
> > to
> > > > > read values of the variable named "BSI", try:
> > > > >
> > > > > !      character (len = *), parameter :: VAR_NAME='data'
> > > > >        character (len = *), parameter :: VAR_NAME='BSI'
> > > > >
> > > > > --Russ
> > > > >
> > > > > Russ Rew                                         UCAR Unidata
> > Program
> > > > > address@hidden
> > http://www.unidata.ucar.edu
> > > > >
> > > > >
> > > > >
> > > > > Ticket Details
> > > > > ===================
> > > > > Ticket ID: VZH-911645
> > > > > Department: Support netCDF
> > > > > Priority: Normal
> > > > > Status: Closed
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > Russ Rew                                         UCAR Unidata Program
> > > address@hidden                      http://www.unidata.ucar.edu
> > >
> > >
> > >
> > > Ticket Details
> > > ===================
> > > Ticket ID: VZH-911645
> > > Department: Support netCDF
> > > Priority: High
> > > Status: Closed
> > >
> > >
> >
> >
> >
> Russ Rew                                         UCAR Unidata Program
> address@hidden                      http://www.unidata.ucar.edu
> 
> 
Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: VZH-911645
Department: Support netCDF
Priority: High
Status: Closed