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

[Support #XEX-904945]: [Fwd: reading netcdf]



Hi Ben,

The problem is that you are trying to read from a 1-dimensional netCDF 
variable, p, as if it were a 4-dimensional variable.

Using the ncdump program to look at your file shows

  $ ncdump -c afoifa.pgj9dec.nc
   netcdf afoifa.pgj9dec {
  dimensions:
          longitude = 96 ;
          latitude = 72 ;
          p = 17 ;
          t = UNLIMITED ; // (121 currently)
          longitude_1 = 96 ;
          latitude_1 = 73 ;
          msl = 1 ;
          ht_1 = 1 ;
          t_1 = 120 ;
  variables:
          float longitude(longitude) ;
                  longitude:units = "degrees_east" ;
                  longitude:point_spacing = "even" ;
                  longitude:modulo = " " ;
          float latitude(latitude) ;
                  latitude:units = "degrees_north" ;
                  latitude:point_spacing = "even" ;
          float p(p) ;
                  p:units = "mbar" ;
                  p:positive = "down" ;

  ...

so p is a 1-dimensional coordinate variable for the dimension p.

Then you get the variable id, pres_varid, from which to read data:

    call check( nf90_inq_varid(ncid, PRES_NAME, pres_varid) )

with "PRES_NAME" defined as "p".

Then you try to read one record of pressure data in a loop with the call

     call check( nf90_get_var(ncid, pres_varid, pres_in, start = start, &
                              count = count) )

but the start and count vectors you used are 4-dimensional and specify reading 
NLONS*NLATS*NLVLS*1 = 117504 values from the 1-dimensional p variable, that 
only has 17 values.  Hance the error message:

   Edge+start exceeds dimension bound

(Here "edge" is used in the documentation for the "count" vector, since it 
represents the number of values desired along each edge of the multidimensional 
slab of values you are reading.)

For pressure, you probably want the "p_1" variable instead of "p":

  character (len = *), parameter :: PRES_NAME="p_1"

because it has the right shape in the netCDF file:

   float p_1(t, msl, latitude_1, longitude_1) ;

but then you would also need to use the right dimensions for that variable:

  character (len = *), parameter :: LVL_NAME = "msl"
  character (len = *), parameter :: LAT_NAME = "latitude_1"
  character (len = *), parameter :: LON_NAME = "longitude_1"
  character (len = *), parameter :: REC_NAME = "t"

To read the temp variable, which has a slightly different shape:

        float temp(t, p, latitude_1, longitude_1) ;

you would have to use the "p" dimension instead of the "msl" dimension, so 
maybe you really need two different LVL_NAME macros, one corresponding to msl 
and the other to p.

--Russ

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



Ticket Details
===================
Ticket ID: XEX-904945
Department: Support
Priority: Normal
Status: Closed