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 mailing list
>> netcdfgroup@xxxxxxxxxxxxxxxx
>> For list information or to unsubscribe, visit:
>> http://www.unidata.ucar.edu/mailing_lists/
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
--
with best regards
Sudheer
**********************************************************************************
Sudheer Joseph
Scientist
Indian National Centre for Ocean Information Services (INCOIS)
Ocean Valley, Post Box No# 21,
IDA Jeedimetla P.O.
Hyderabad, Ranga Reddy District - 500 055
Andhra Pradesh, India.
TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail:sjo@xxxxxxxxxxxxxx; sudheer.joseph@xxxxxxxxx; sjo@xxxxxxxxxxxxx.
Web- http://oppamthadathil.tripod.com
--------------* ---------------
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
Martin Luther King, Jr.
"What we have done for ourselves alone dies with us.
What we have done for others and the world remains and is immortal."
- Albert Pines