[Thread Prev][Thread Next][Index]
Re: data shifting
Dear Dr. Manke,
Thank you very much for your reply.
The attached file datashift.txt contains all the information
about show data and show grid var.
Also the netcdf file is the POM model output and I attach the subroutine
pom2k.n used for writing in netcdf.
I understood that the shift has caused because of the origin initialisation
error and I am trying to work on that.
Also during the model run, the model was integrated 20 years from the
initial time using climatological forcing and then the interannually
varying forcings. In the model calendar year has 360 days so during the
period of 20 years run the time axis has shifted more than three months
resulting to show a wrong time in the plot.
Any help to overcome these will be greatly appreciated.
With thanks and best regards
Gnanaseelan
Ansley Manke wrote:
> Hi Gnanaseelan,
> We will need more information to understand what may be
> happening. Have your read your data into Ferret? If so, what
> do you see when you issue the commands
>
> yes? show data
> yes? show grid var ! where var is your variable name
>
> And also the SHOW AXIS command for the X and Y axes.
> What command do you use to write the data to NetCDF?
>
> Ansley Manke
>
> "Dr.C. Gnanaseelan" wrote:
>
> > Dear ferret users,
> >
> > I have netcdf files of data (one degree resolution) for the region 35E
> > to 115E and 20S:25N.
> > But while writing the data from model in the netcdf format, it was
> > stored in 1E to 80E and 1N to 46N.
> > The data plots well in the region and the land is clearly seen as the
> > value is zero over land. However axes are from 0 to 80 and 0 to 46.
> > I tried to redefine the axes, but then as the data is not available
> > beyond 80E the plot was not showing anything in the region.
> > Can any one help me to overcome this?
> >
> > With thanks and best regards
> > Gnanaseelan
>
> --
> Ansley Manke Pacific Marine Environmental Laboratory Seattle WA
C***********************************************************************
C
C NetCDF subroutines for pom2k.f
C
C For version number and date, see start of subroutine write_netcdf
C
C***********************************************************************
C
subroutine def_var_netcdf(ncid,name,nvdims,vdims,varid,
$ n_long_name,long_name,n_units,units,
$ n_coords,coords,lcoords,
$ nf_float,nf_noerr)
C **********************************************************************
C * *
C * FUNCTION : Defines a netCDF variable and its attributes. *
C * *
C * ncid ........ the netCDF I.D. *
C * name ........ the variable name *
C * nvdims ...... the number of dimensions of name *
C * vdims ....... a vector of length at least nvdims, *
C * containing the dimension I.D.s *
C * varid ....... the variable I.D. returned *
C * n_long_name . the number of characters in long_name *
C * long_name ... the long name for the variable *
C * n_units ..... the number of characters in units *
C * units ....... the units of the variable *
C * n_coords .... the number of characters in coords *
C * (if applicable) *
C * coords ...... the names of variables for the *
C * "coordinates" attribute *
C * (if applicable) *
C * lcoords ..... .true. if a "coordinates" attribute *
C * required, otherwise .false. *
c * nf_float .... an integer defining the netCDF *
C * variable type *
C * nf_noerr .... an integer defining the netCDF "no *
C * error" status *
C * *
C * (nf_float and nf_noerr are declared and defined in *
C * the file netcdf.inc "included" in the subroutine *
C * write_netcdf.) *
C * *
C **********************************************************************
C
integer vdims(4)
C
integer ncid,nf_noerr,nvdims,varid,n_long_name,n_units,n_coords
C
logical lcoords
C
character*(*) name,long_name,units,coords
C
integer status
C
status=nf_def_var(ncid,name,nf_float,nvdims,vdims,varid)
C
call handle_netcdf_error('nf_def_var ',
$ status,nf_noerr)
C
C write(6,1) name,varid
C 1 format('Variable ID returned by nf_def_var for variable ',
C $ a7,' = ',i5)
C
status=nf_put_att_text(ncid,varid,'long_name',
$ n_long_name,long_name)
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
status=nf_put_att_text(ncid,varid,'units',
$ n_units,units)
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
C Add coordinates attribute, if necessary:
C
if(lcoords) then
C
status=nf_put_att_text(ncid,varid,'coordinates',
$ n_coords,coords)
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
endif
C
return
C
end
C
subroutine handle_netcdf_error(routine,status,nf_noerr)
C **********************************************************************
C * *
C * FUNCTION : Checks for netCDF error. *
C * *
C **********************************************************************
C
implicit none
C
integer status,nf_noerr
C
character*20 routine
C
character*80 nf_strerror
C
if (status.ne.nf_noerr) then
C
write(6,1) routine,nf_strerror(status)
1 format('NetCDF routine ',a20,' terminated with error:'/2x,a80)
stop
C
else
C
return
C
endif
C
end
C
subroutine write_netcdf(netcdf_file,option)
C **********************************************************************
C * *
C * FUNCTION : Initialises, writes to and closed netCDF file. *
C * *
C * netcdf_file ....... name of output file *
C * option ............ 1 to initialise file *
C * 2 to write a set of data *
C * 3 to close file *
C * *
C * In order to include another variable: *
C * *
C * 1. Within the loop "if(option.eq.1) then": *
C * *
C * Insert appropriate "call def_var_netcdf(.....)", *
C * followed by "status=nf_put_att_<type>(.....)" *
C * statements for any additional attributes. Each *
C * of these latter statements should be followed by *
C * a "call handle_netcdf_error(.....)" statement. *
C * *
C * 2. Within the loop "if(option.eq.2) then": *
C * *
C * Insert appropriate *
C * "status=nf_put_var_<type>(.....)" statement, *
C * followed by a "call handle_netcdf_error(.....)" *
C * statement. *
C * *
C **********************************************************************
C
implicit none
C
include 'pom2k.c'
C
C Filename of netCDF "include" file:
C
include '/usr/local/netcdf/include/netcdf.inc'
C include '/usr/sayre/include/netcdf.inc'
C
integer option
C
character*120 netcdf_file
C
integer count(4),start(4),vdims(4)
C
integer dum_varid,dvm_varid
integer dx_varid,dy_varid
integer east_c_varid,east_e_varid,east_u_varid,east_v_varid
integer elb_varid
integer fsm_varid
integer h_varid
integer iout
integer ncid
integer north_c_varid,north_e_varid,north_u_varid,north_v_varid
integer rho_varid,rmean_varid,rot_varid
integer status,s_varid
integer time_dimid,time_varid,t_varid
integer uab_varid,u_varid
integer vab_varid,v_varid
integer w_varid
integer x_dimid
integer y_dimid
integer z_dimid,z_varid,zz_varid
C
save dum_varid,dvm_varid
save dx_varid,dy_varid
save east_c_varid,east_e_varid,east_u_varid,east_v_varid
save elb_varid
save fsm_varid
save h_varid
save iout
save ncid
save north_c_varid,north_e_varid,north_u_varid,north_v_varid
save rho_varid,rmean_varid,rot_varid
save s_varid
save time_dimid,time_varid,t_varid
save uab_varid,u_varid
save vab_varid,v_varid
save w_varid
save x_dimid
save y_dimid
save z_dimid,z_varid,zz_varid
C
C***********************************************************************
C
C source_n should agree with source defined in pom2k.f.
C
character*40 source_n
parameter(source_n='pom2k 2002-09-06')
C
if(source.ne.source_n) then
C
write(6,4)
4 format(/'Incompatible versions of program and include files ',
$ '..... program terminated'/)
stop
C
endif
C
C***********************************************************************
C
if(option.eq.1) then
C
C Initialise netCDF ouput:
C
C Initialise time index:
C
iout=0
C
C Create netcdf file:
C
status=nf_create(netcdf_file,nf_clobber,ncid)
call handle_netcdf_error('nf_create ',
$ status,nf_noerr)
C write(6,1) ncid
C 1 format('ncid returned by nf_create = ',i5)
C
C Define global attributes:
C
status=nf_put_att_text(ncid,nf_global,'source',
$ 40,source)
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
status=nf_put_att_text(ncid,nf_global,'title',
$ 40,title)
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
C Define dimensions:
C
status=nf_def_dim(ncid,'time',nf_unlimited,time_dimid)
call handle_netcdf_error('nf_def_dim ',
$ status,nf_noerr)
C write(6,2) 'time',time_dimid
C 2 format('Dimension ID returned by nf_def_dim for variable ',
C $ a4,' = ',i5)
C
status=nf_def_dim(ncid,'z1',kb,z_dimid)
call handle_netcdf_error('nf_def_dim ',
$ status,nf_noerr)
C write(6,2) 'z1',z_dimid
C
status=nf_def_dim(ncid,'y',jm,y_dimid)
call handle_netcdf_error('nf_def_dim ',
$ status,nf_noerr)
C write(6,2) 'y',y_dimid
C
status=nf_def_dim(ncid,'x',im,x_dimid)
call handle_netcdf_error('nf_def_dim ',
$ status,nf_noerr)
C write(6,2) 'x',x_dimid
C
C Define variables and their attributes:
C
vdims(1)=time_dimid
C
call def_var_netcdf(ncid,'time',1,vdims,time_varid,
$ 4,'time',37,'days since '//time_start,
$ 1,' ',.false.,
$ nf_float,nf_noerr)
C
vdims(1)=z_dimid
C
call def_var_netcdf(ncid,'z1',1,vdims,z_varid,
$ 18,'sigma of cell face',11,'sigma_level',
$ 1,' ',.false.,
$ nf_float,nf_noerr)
status=nf_put_att_text(ncid,z_varid,'standard_name',
$ 22,'ocean_sigma_coordinate')
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
status=nf_put_att_text(ncid,z_varid,'formula_terms',
$ 26,'sigma: z eta: elb depth: h')
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
call def_var_netcdf(ncid,'zz',1,vdims,zz_varid,
$ 20,'sigma of cell centre',11,'sigma_level',
$ 1,' ',.false.,
$ nf_float,nf_noerr)
status=nf_put_att_text(ncid,zz_varid,'standard_name',
$ 22,'ocean_sigma_coordinate')
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
status=nf_put_att_text(ncid,zz_varid,'formula_terms',
$ 27,'sigma: zz eta: elb depth: h')
call handle_netcdf_error('nf_put_att_text ',
$ status,nf_noerr)
C
vdims(1)=x_dimid
vdims(2)=y_dimid
C
call def_var_netcdf(ncid,'dx',2,vdims,dx_varid,
$ 19,'grid increment in x',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'dy',2,vdims,dy_varid,
$ 19,'grid increment in y',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'east_u',2,vdims,east_u_varid,
$ 19,'easting of u-points',5,'metre',
$ 14,'east_u north_u',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'east_v',2,vdims,east_v_varid,
$ 19,'easting of v-points',5,'metre',
$ 14,'east_v north_v',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'east_e',2,vdims,east_e_varid,
$ 27,'easting of elevation points',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'east_c',2,vdims,east_c_varid,
$ 23,'easting of cell corners',5,'metre',
$ 14,'east_c north_c',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'north_u',2,vdims,north_u_varid,
$ 20,'northing of u-points',5,'metre',
$ 14,'east_u north_u',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'north_v',2,vdims,north_v_varid,
$ 20,'northing of v-points',5,'metre',
$ 14,'east_v north_v',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'north_e',2,vdims,north_e_varid,
$ 28,'northing of elevation points',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'north_c',2,vdims,north_c_varid,
$ 24,'northing of cell corners',5,'metre',
$ 14,'east_c north_c',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'rot',2,vdims,rot_varid,
$ 34,'Rotation angle of x-axis wrt. east',6,'degree',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'h',2,vdims,h_varid,
$ 23,'undisturbed water depth',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'fsm',2,vdims,fsm_varid,
$ 17,'free surface mask',13,'dimensionless',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'dum',2,vdims,dum_varid,
$ 15,'u-velocity mask',13,'dimensionless',
$ 14,'east_u north_u',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'dvm',2,vdims,dvm_varid,
$ 15,'v-velocity mask',13,'dimensionless',
$ 14,'east_v north_v',.true.,
$ nf_float,nf_noerr)
C
vdims(1)=x_dimid
vdims(2)=y_dimid
vdims(3)=z_dimid
C
call def_var_netcdf(ncid,'rmean',3,vdims,rmean_varid,
$ 25,'horizontally-averaged rho',13,'dimensionless',
$ 17,'east_e north_e zz',.true.,
$ nf_float,nf_noerr)
C
vdims(1)=x_dimid
vdims(2)=y_dimid
vdims(3)=time_dimid
C
call def_var_netcdf(ncid,'uab',3,vdims,uab_varid,
$ 16,'depth-averaged u',9,'metre/sec',
$ 14,'east_u north_u',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'vab',3,vdims,vab_varid,
$ 16,'depth-averaged v',9,'metre/sec',
$ 14,'east_v north_v',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'elb',3,vdims,elb_varid,
$ 17,'surface elevation',5,'metre',
$ 14,'east_e north_e',.true.,
$ nf_float,nf_noerr)
C
vdims(1)=x_dimid
vdims(2)=y_dimid
vdims(3)=z_dimid
vdims(4)=time_dimid
C
call def_var_netcdf(ncid,'u',4,vdims,u_varid,
$ 10,'x-velocity',9,'metre/sec',
$ 17,'east_u north_u zz',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'v',4,vdims,v_varid,
$ 10,'y-velocity',9,'metre/sec',
$ 17,'east_v north_v zz',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'w',4,vdims,w_varid,
$ 10,'z-velocity',9,'metre/sec',
$ 16,'east_e north_e z',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'temp',4,vdims,t_varid,
$ 21,'potential temperature',1,'K',
$ 17,'east_e north_e zz',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'s',4,vdims,s_varid,
$ 23,'salinity x rho / rhoref',3,'PSS',
$ 17,'east_e north_e zz',.true.,
$ nf_float,nf_noerr)
C
call def_var_netcdf(ncid,'rho',4,vdims,rho_varid,
$ 21,'(density-1000)/rhoref',13,'dimensionless',
$ 17,'east_e north_e zz',.true.,
$ nf_float,nf_noerr)
C
C End definitions:
C
status=nf_enddef(ncid)
call handle_netcdf_error('nf_enddef ',
$ status,nf_noerr)
C
C Write initial data:
C
status=nf_put_var_real(ncid,z_varid,z)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,zz_varid,zz)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,dx_varid,dx)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,dy_varid,dy)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,east_u_varid,east_u)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,east_v_varid,east_v)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,east_e_varid,east_e)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,east_c_varid,east_c)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,north_u_varid,north_u)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,north_v_varid,north_v)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,north_e_varid,north_e)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,north_c_varid,north_c)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,rot_varid,rot)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,h_varid,h)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,fsm_varid,fsm)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,dum_varid,dum)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,dvm_varid,dvm)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
status=nf_put_var_real(ncid,rmean_varid,rmean)
call handle_netcdf_error('nf_put_var_real ',
$ status,nf_noerr)
C
C-----------------------------------------------------------------------
C
else if(option.eq.2) then
C
C Write a set of data:
C
iout=iout+1
start(1)=iout
count(1)=1
C
status=nf_put_vara_real(ncid,time_varid,start,count,time)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
start(1)=1
start(2)=1
start(3)=iout
count(1)=im
count(2)=jm
count(3)=1
C
status=nf_put_vara_real(ncid,uab_varid,start,count,uab)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,vab_varid,start,count,vab)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,elb_varid,start,count,elb)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
start(1)=1
start(2)=1
start(3)=1
start(4)=iout
count(1)=im
count(2)=jm
count(3)=kb
count(4)=1
C
status=nf_put_vara_real(ncid,u_varid,start,count,u)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,v_varid,start,count,v)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,w_varid,start,count,w)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,t_varid,start,count,t)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,s_varid,start,count,s)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
status=nf_put_vara_real(ncid,rho_varid,start,count,rho)
call handle_netcdf_error('nf_put_vara_real ',
$ status,nf_noerr)
C
C-----------------------------------------------------------------------
C
else if(option.eq.3) then
C
C Close file:
C
status=nf_close(ncid)
call handle_netcdf_error('nf_close ',
$ status,nf_noerr)
C
C-----------------------------------------------------------------------
C
else
C
write(6,3)
3 format(/'Invalid option for subroutine write_netcdf ..... ',
$ 'program terminated'/)
stop
C
endif
C
C-----------------------------------------------------------------------
C
return
C
end
C
C End of source code
C
C-----------------------------------------------------------------------
C
yes? use pom2k.nc
*** NOTE: Units on axis "z1" are not recognized: sigma_level
*** NOTE: They will not be convertible:
show grid temp
GRID GIM5
name axis # pts start end
X X 81 r 1 81
Y Y 46 r 1 46
Z1 Z (sigma_level 21 i -1 0
TIME TIME 13 r 02-OCT-1981 00:00 27-SEP-1982 00:00
yes? show data
currently SET data sets:
1> ./pom2k.nc (default)
name title I J K L
ZZ sigma of cell centre ... ... 1:21 ...
DX grid increment in x 1:81 1:46 ... ...
DY grid increment in y 1:81 1:46 ... ...
EAST_U easting of u-points 1:81 1:46 ... ...
EAST_V easting of v-points 1:81 1:46 ... ...
EAST_E easting of elevation points 1:81 1:46 ... ...
EAST_C easting of cell corners 1:81 1:46 ... ...
NORTH_U northing of u-points 1:81 1:46 ... ...
NORTH_V northing of v-points 1:81 1:46 ... ...
NORTH_E northing of elevation points 1:81 1:46 ... ...
NORTH_C northing of cell corners 1:81 1:46 ... ...
ROT Rotation angle of x-axis wrt. e 1:81 1:46 ... ...
H undisturbed water depth 1:81 1:46 ... ...
FSM free surface mask 1:81 1:46 ... ...
DUM u-velocity mask 1:81 1:46 ... ...
DVM v-velocity mask 1:81 1:46 ... ...
RMEAN horizontally-averaged rho 1:81 1:46 1:21 ...
UAB depth-averaged u 1:81 1:46 ... 1:13
VAB depth-averaged v 1:81 1:46 ... 1:13
ELB surface elevation 1:81 1:46 ... 1:13
U x-velocity 1:81 1:46 1:21 1:13
V y-velocity 1:81 1:46 1:21 1:13
W z-velocity 1:81 1:46 1:21 1:13
TEMP potential temperature 1:81 1:46 1:21 1:13
S salinity x rho / rhoref 1:81 1:46 1:21 1:13
RHO (density-1000)/rhoref 1:81 1:46 1:21 1:13
yes? show axis x
name axis # pts start end
X 81 r 1 81
Axis span (to cell edges) = 81
yes? show axis y
name axis # pts start end
Y 46 r 1 46
Axis span (to cell edges) = 46
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement