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

20050222: NCVPT: Edge+start exceeds dimension bound



Luiz,

In the netCDF Common Data Language, variables are printed with the
outermost dimension first and the innermost dimension last.  For
example, in

>         float salinity(Time, zt_k, yt_j, xt_i) ; 

"Time" is the outermost dimension and "xt_i" is the innermost dimension.

In the Fortran language, however, the order is reversed: the first
dimension is the innermost and the last dimension is the outermost.  For
example, in

>        DOUBLE PRECISION RHVALS(Time, zt_k, yt_j, xt_i)

"Time" is the innermost dimension and "xt_i" is the outermost.

If you reverse the order of dimensions in your program, then it should 
work.

Depending on your computer, you might also have to change the type of
the RHVALS array because it is currently DOUBLE PRECISION (which is
often 8 bytes in size) but the type of the "salinity" netCDF variable 
is "float", which is 4 bytes in size.

Regards,
Steve Emmerson

NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publicly available
through the web.  If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.

------- Original Message

>To: address@hidden
>From: lassad <address@hidden>
>Subject: Fwd: Problem on ncvarput function
>Organization: UFRJ
>Keywords: 200502211400.j1LE0Ov2004702 netCDF Fortran


>Date: Mon, 21 Feb 2005 05:03:28 -0800
>To: address@hidden
>From: lassad <address@hidden>
>Subject: Problem on ncvarput function
>
>Hi all,
>
>I'm trying to use the NCVPT fortran interface to change the value of a 
>variable on a netcdf file. I'm trying to that using the following fortran 
>program (below):
>
>******************************************************************************
*********************************************
>  program teste
>
>        INTEGER Time, zt_k, yt_j, xt_i
>        PARAMETER (NDIMS=4)
>        PARAMETER (Time=11, zt_k=40, yt_j=200, xt_i=360)
>
>        INCLUDE '/home/knoppix/MOM/lib/include/netcdf.inc'
>        INTEGER  NCID, RCODE
>
>        INTEGER  RHID               ! variable ID
>        INTEGER START(NDIMS), COUNT(NDIMS)
>        DOUBLE PRECISION RHVALS(Time, zt_k, yt_j, xt_i)
>        DATA START / 1, 1, 1, 1/
>        DATA COUNT /Time, zt_k, yt_j, xt_i/
>        NCID = NCOPN ('time_mean2.nc', NCWRITE, RCODE)
>        print *, 'NCID =', NCID
>        CALL NCREDF (NCID, RCODE)  ! enter definition mode
>        RHID = NCVID (NCID, 'salinity', RCODE)  ! get ID
>        CALL NCENDF (NCID, RCODE)  ! leave definition mode
>
>        DO 10 ITIME = 1, Time
>           DO 10 IDEPTH = 1, zt_k
>             DO 10 ILAT = 1, yt_j
>                 DO 10 ILON = 1, xt_i
>
>           RHVALS(ITIME, IDEPTH, ILAT, ILON) = 0.0  -------> I just wnat 
> to zero all the values.
>     10 CONTINUE
>
>        CALL NCVPT(NCID, RHID, START, COUNT, RHVALS, RCODE)
>        stop
>        end
>******************************************************************************
*****************************************
>
>The name of the variable that I want to change its values is salinity an 
>it is on file time_mean2.nc that has its header showed below:
>
>**********************************
>
>netcdf time_mean2 {
>dimensions:
>         Surface = 1 ;
>         Time = UNLIMITED ; // (11 currently)
>         yt_j = 200 ;
>         xt_i = 360 ;
>         zt_k = 40 ;
>         yu_j = 200 ;
>         xu_i = 360 ;
>         zw_k = 40 ;
>         xt_i_edges = 363 ;
>         xu_i_edges = 363 ;
>         yt_j_edges = 203 ;
>         yu_j_edges = 203 ;
>         zt_k_edges = 41 ;
>         zw_k_edges = 41 ;
>variables:
>         float Surface(Surface) ;
>                 Surface:long_name = "Depth of surface" ;
>                 Surface:units = "m" ;
>                 Surface:cartesian_axis = "Z" ;
>                 Surface:positive = "down" ;
>         double Time(Time) ;
>                 Time:long_name = "Time since initial condition" ;
>                 Time:units = "days since 1979-01-01 00:00:00.0" ;
>                 Time:cartesian_axis = "T" ;
>         float convU(Time, Surface, yt_j, xt_i) ;
>                 convU:long_name = "convergence of H*ubar" ;
>                 convU:units = "cm/s" ;
>                 convU:valid_range = -300000.f, 300000.f ;
>                 convU:missing_value = -1.e+34f ;
>                 convU:_FillValue = -1.e+34f ;
>         float eta(Time, yt_j, xt_i) ;
>                 eta:long_name = "Surface height" ;
>                 eta:units = "cm" ;
>                 eta:valid_range = -3000000.f, 3000000.f ;
>                 eta:missing_value = -1.e+34f ;
>                 eta:_FillValue = -1.e+34f ;
>         float hblt(Time, yt_j, xt_i) ;
>                 hblt:long_name = "Boundary layer depth" ;
>                 hblt:units = "cm" ;
>                 hblt:valid_range = -3000000.f, 3000000.f ;
>                 hblt:missing_value = -1.e+34f ;
>                 hblt:_FillValue = -1.e+34f ;
>         float hflx(Time, Surface, yt_j, xt_i) ;
>                 hflx:long_name = "Surface heat flux" ;
>                 hflx:units = "cal/cm**2/s" ;
>                 hflx:valid_range = -1.f, 1.f ;
>                 hflx:missing_value = -1.e+34f ;
>                 hflx:_FillValue = -1.e+34f ;
>         float hmxl(Time, yt_j, xt_i) ;
>                 hmxl:long_name = "Mixed layer depth" ;
>                 hmxl:units = "cm" ;
>                 hmxl:valid_range = -3000000.f, 3000000.f ;
>                 hmxl:missing_value = -1.e+34f ;
>                 hmxl:_FillValue = -1.e+34f ;
>         float period(Time) ;
>                 period:long_name = "time averaging period" ;
>                 period:units = "day" ;
>                 period:valid_range = 0.f, 9.999999e+19f ;
>                 period:missing_value = -1.e+34f ;
>                 period:_FillValue = -1.e+34f ;
>         float psiu(Time, Surface, yt_j, xt_i) ;
>                 psiu:long_name = "Streamfunction for H*ubar" ;
>                 psiu:units = "Sv" ;
>                 psiu:valid_range = -3000000.f, 3000000.f ;
>                 psiu:missing_value = -1.e+34f ;
>                 psiu:_FillValue = -1.e+34f ;
>         float psiv(Time, Surface, yt_j, xt_i) ;
>                 psiv:long_name = "Streamfunction for H*vbar" ;
>                 psiv:units = "Sv" ;
>                 psiv:valid_range = -3000000.f, 3000000.f ;
>                 psiv:missing_value = -1.e+34f ;
>                 psiv:_FillValue = -1.e+34f ;
>         float salinity(Time, zt_k, yt_j, xt_i) ; 
> -------------------------------------------> variable that I want to 
> change ******* salinity
>                 salinity:long_name = "salinity" ;
>                 salinity:units = "psu" ;
>                 salinity:valid_range = -100.f, 100.f ;
>                 salinity:missing_value = -1.e+34f ;
>                 salinity:_FillValue = -1.e+34f ;
>         float sff(Time, Surface, yt_j, xt_i) ;
>                 sff:long_name = "Fresh water flux" ;
>                 sff:units = "cm/s" ;
>                 sff:valid_range = -3000000.f, 3000000.f ;
>                 sff:missing_value = -1.e+34f ;
>                 sff:_FillValue = -1.e+34f ;
>         float sflx(Time, Surface, yt_j, xt_i) ;
>                 sflx:long_name = "Surface salt flux" ;
>                 sflx:units = "g/cm**2/s" ;
>                 sflx:valid_range = -1.f, 1.f ;
>                 sflx:missing_value = -1.e+34f ;
>                 sflx:_FillValue = -1.e+34f ;
>         float taux(Time, Surface, yu_j, xu_i) ;
>                 taux:long_name = "Zonal windstress" ;
>                 taux:units = "dyn/cm**2" ;
>                 taux:valid_range = -20.f, 20.f ;
>                 taux:missing_value = -1.e+34f ;
>                 taux:_FillValue = -1.e+34f ;
>         float tauy(Time, Surface, yu_j, xu_i) ;
>                 tauy:long_name = "Meridional windstress" ;
>                 tauy:units = "dyn/cm**2" ;
>                 tauy:valid_range = -20.f, 20.f ;
>                 tauy:missing_value = -1.e+34f ;
>                 tauy:_FillValue = -1.e+34f ;
>         float temp(Time, zt_k, yt_j, xt_i) ;
>                 temp:long_name = "potential temperature" ;
>                 temp:units = "deg C" ;
>                 temp:valid_range = -5.f, 50.f ;
>                 temp:missing_value = -1.e+34f ;
>                 temp:_FillValue = -1.e+34f ;
>         float u(Time, zt_k, yu_j, xu_i) ;
>                 u:long_name = "Zonal velocity" ;
>                 u:units = "cm/s" ;
>                 u:valid_range = -3000.f, 3000.f ;
>                 u:missing_value = -1.e+34f ;
>                 u:_FillValue = -1.e+34f ;
>         float v(Time, zt_k, yu_j, xu_i) ;
>                 v:long_name = "Meridional velocity" ;
>                 v:units = "cm/s" ;
>                 v:valid_range = -3000.f, 3000.f ;
>                 v:missing_value = -1.e+34f ;
>                 v:_FillValue = -1.e+34f ;
>         float w(Time, zw_k, yt_j, xt_i) ;
>                 w:long_name = "W at T cell bottom" ;
>                 w:units = "cm/s" ;
>                 w:valid_range = -100.f, 100.f ;
>                 w:missing_value = -1.e+34f ;
>                 w:_FillValue = -1.e+34f ;
>         float xt_i(xt_i) ;
>                 xt_i:long_name = "Longitude of T points" ;
>                 xt_i:units = "degrees_E" ;
>                 xt_i:cartesian_axis = "X" ;
>         float xt_i_edges(xt_i_edges) ;
>                 xt_i_edges:long_name = "Longitude of T edges" ;
>                 xt_i_edges:units = "degrees_E" ;
>                 xt_i_edges:cartesian_axis = "X" ;
>         float xu_i(xu_i) ;
>                 xu_i:long_name = "Longitude of U points" ;
>                 xu_i:units = "degrees_E" ;
>                 xu_i:cartesian_axis = "X" ;
>         float xu_i_edges(xu_i_edges) ;
>                 xu_i_edges:long_name = "Longitude of U edges" ;
>                 xu_i_edges:units = "degrees_E" ;
>                 xu_i_edges:cartesian_axis = "X" ;
>         float yt_j(yt_j) ;
>                 yt_j:long_name = "Latitude of T points" ;
>                 yt_j:units = "degrees_N" ;
>                 yt_j:cartesian_axis = "Y" ;
>         float yt_j_edges(yt_j_edges) ;
>                 yt_j_edges:long_name = "Latitude of T edges" ;
>                 yt_j_edges:units = "degrees_N" ;
>                 yt_j_edges:cartesian_axis = "Y" ;
>         float yu_j(yu_j) ;
>                 yu_j:long_name = "Latitude of U points" ;
>                 yu_j:units = "degrees_N" ;
>                 yu_j:cartesian_axis = "Y" ;
>         float yu_j_edges(yu_j_edges) ;
>                 yu_j_edges:long_name = "Latitude of U edges" ;
>                 yu_j_edges:units = "degrees_N" ;
>                 yu_j_edges:cartesian_axis = "Y" ;
>         float zt_k(zt_k) ;
>                 zt_k:long_name = "Depth of T grid point" ;
>                 zt_k:units = "m" ;
>                 zt_k:cartesian_axis = "Z" ;
>                 zt_k:positive = "down" ;
>         float zt_k_edges(zt_k_edges) ;
>                 zt_k_edges:long_name = "Depth of T edges" ;
>                 zt_k_edges:units = "cm" ;
>                 zt_k_edges:cartesian_axis = "Z" ;
>                 zt_k_edges:positive = "down" ;
>         float zw_k(zw_k) ;
>                 zw_k:long_name = "Depth of T cell bottom" ;
>                 zw_k:units = "m" ;
>                 zw_k:cartesian_axis = "Z" ;
>                 zw_k:positive = "down" ;
>         float zw_k_edges(zw_k_edges) ;
>                 zw_k_edges:long_name = "Depth of W edges" ;
>                 zw_k_edges:units = "cm" ;
>                 zw_k_edges:cartesian_axis = "Z" ;
>                 zw_k_edges:positive = "down" ;
>
>// global attributes:
>                 :filename = "time_mean.001980.01.01.dta.nc" ;
>                 :MPP_IO_VERSION = "$Id: mpp_io.F90,v 5.1 1999/10/26 
> 15:48:52 vb Exp $" ;
>                 :title = "GFDL OCEAN 1980" ;
>                 :history = "Thu Jul 20 13:50:34 2000: ncks -d Time,1,11 
> /ldata/las/gfdl_ocean_assimilation/time_mean.001980.nc tmp.nc" ;
>*************************************************************************
>
>When I run the program I've got the following error message:
>
>NCVPT: : Edge+start exceeds dimension bound
>
>
>Does anyone knows how could I solve this problem?
>
>Really thanks for the help.
>
>
>Luiz Paulo

------- End of Original Message