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.
Sudheer,Sorry, I may have misunderstood your question. What I think you are asking should be entirely possible in Fortran 90 with an allocatable array and a single call to nf90_get_var. So it sounds like you have some kind of Fortran or Netcdf calling bug, as also noted by Dave Pierce.
If the problem persists, please describe the error message or symptom, and give short excerpts of the relevant code. Good luck.
--Dave On 6/10/2010 10:36 PM, Sudheer Joseph wrote:
Thank you Dave, The subroutine you mentioned is very useful. But my question was slightly different. suppose if you get the dimension size before reading the 3 dimensional variable. we cannot use that information to read the netcdf 3rd dimension at a stretch. I mean if I use the NTIM= nf_get_dim(time) ( just for illustration sake ) and use this for allocating the dimension for 3D variable it will not accept as it is not defined as a parameter. allocate(pres_in(NLONS, NLATS, NTIM)) count = (/ NLONS, NLATS,NTIM/) start = (/ 1, 1, 1/) One possibility came to my mind yesterday night was to read the data as xy slabs and use a do loop to read the time dimension. It appears there is no way to read the 3D variable at one call if we are not defining the dimension as parameter. with best regards, Sudheer On Fri, Jun 11, 2010 at 3:42 AM, Dave Allured<dave.allured@xxxxxxxx> wrote:Sudheer, If the names of the dimensions are always the same, then use nf90_inq_dimid followed by nf90_inquire_dimension to get the length of each dimension. See the example on this page: http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90/NF90_005fINQUIRE_005fDIMENSION.html If all the dimensions have coordinate variables, then the following subroutine will get several dimension lengths in one call: http://www.esrl.noaa.gov/psd/people/dave.allured/data/f90/lib/getnc_dims.f90 If the dimension names change between Netcdf files, then the problem is more complicated. We can address that if neither of the above works for you. --Dave A. NOAA/PSD/CIRES On 6/10/2010 7:55 AM, Sudheer Joseph wrote:Dear Users, I have been coding a program to read multiple netcdf files having different time dimensions. I want to know if there is a way to read netcdf varibale with out defining the dimension as parameter. with in fortran 90 program. normally we need to define like below ! timesteps of data. integer, parameter :: NDIMS = 3, NRECS =1 integer, parameter :: NTIM=1464, NLATS = 94, NLONS = 192 allocate(pres_in(NLONS, NLATS, NTIM))count = (/ NLONS, NLATS,NTIM/) start = (/ 1, 1, 1/) ! Read the surface pressure and temperature data from the file, one ! record at a time. call check( nf90_get_var(ncid, pres_varid, pres_in, start = start,count = count) ) In my case ntim may be different for different files. I wanted to use the reading part as a subroutine where ntim is provided as a variable and passed to subroutine but if I declare ntim as varible then netcdf gives an error. If any one have a solution please help. I am not looking for solutions like replacing the parameter statement using shell script and re compiling it etc. with best regards, Sudheer
netcdfgroup
archives: