Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed
PROGRAM modify_anomalyc ******************************************************************************c * Read the modified and unmodified PV from the R file and *c * perform some non-standard modifications: (a) Change of amplitude, *c * (b) Stretching and shrinking along an axis, (c) rotation, or *c * (d) change in position.c *c # modify_anomaly.sh R_20060116_18 shifty=-10,rot=10,stretchy=1.5,rot=-10,shifty=10c # modify_anomaly.sh R_20060116_18 fac=2c # modify_anomaly.sh R_20060116_18 cex=-30,cey=-30,rot=20c * *c * Michael Sprenger / Spring, Summer 2007 *c ******************************************************************************implicit nonec -----------------------------------------------------------------------------c Declaration of parameters and variablesc -----------------------------------------------------------------------------c Input/output file and command stringcharacter*80 pvsrcfilecharacter*80 commandstrc Grid parametersinteger nx,ny,nzreal xmin,ymin,zmin,xmax,ymax,zmaxreal dx,dy,dzreal mdvc 3d fields for calculation of qgPV and Ertel's PVreal,allocatable,dimension (:,:,:) :: pv1,pv2,anoc Numerical epsilonreal epsparameter (eps=0.01)c Parameters for the transformationsreal cex,cey ! Centre point for rotationreal angle ! Rotation anglec Auxiliary variablesreal zposinteger i,j,kinteger statcharacter*80 varnameinteger nreal parcharacter*80 comc -----------------------------------------------------------------------------c Preparationsc -----------------------------------------------------------------------------print*,'********************************************************'print*,'* MODIFY_ANOMALY *'print*,'********************************************************'c Read parameter fileopen(10,file='fort.10')read(10,*) pvsrcfileread(10,*) commandstrclose(10)print*print*,'Input file : ',trim(pvsrcfile)print*,'Command : ',trim(commandstr)print*c Get lat/lon gid parameters from input filecall read_dim (nx,ny,nz,dx,dy,dz,xmin,ymin,zmin,mdv,> pvsrcfile)print*,'Read_Dim: nx,ny,nz = ',nx,ny,nzprint*,' dx,dy,dz = ',dx,dy,dzprint*,' xmin,ymin,zmin = ',xmin,ymin,zminprint*,' mdv = ',mdvprint*c Count from 0, not from 1: consistent with <inv_cart.f>.nx=nx-1ny=ny-1nz=nz-1c Allocate memory for modified and non-modified PVallocate(pv1 (0:nx,0:ny,0:nz),STAT=stat)if (stat.ne.0) print*,'error allocating pv1'allocate(pv2 (0:nx,0:ny,0:nz),STAT=stat)if (stat.ne.0) print*,'error allocating pv2'allocate(ano (0:nx,0:ny,0:nz),STAT=stat)if (stat.ne.0) print*,'error allocating ano'c Read data from filevarname='PV'call read_inp (pv1,varname,pvsrcfile,> nx,ny,nz,dx,dy,dz,xmin,ymin,zmin,mdv)varname='PV_FILT'call read_inp (pv2,varname,pvsrcfile,> nx,ny,nz,dx,dy,dz,xmin,ymin,zmin,mdv)c Define the anomalydo i=0,nxdo j=0,nydo k=0,nzif ( (abs(pv1(i,j,k)-mdv).gt.eps).and.> (abs(pv2(i,j,k)-mdv).gt.eps) ) thenano(i,j,k)=pv1(i,j,k)-pv2(i,j,k)elseano(i,j,k)=0.endifenddoenddoenddoc -------------------------------------------------------------------------------c Modificationsc -------------------------------------------------------------------------------c Set the default values for parameterscex = 0.cey = 0.angle = 0.c Set the counter for the command stringn=1c Loop over all commands100 continuec Extract new command/parameter pair; exit if no new commandcall next_command(commandstr,n,com,par)if (com.eq.'nil') goto 200print*,trim(com),parc Multiply the anomaly by a constant factorif (com.eq.'fac') thencall mod_factor (ano,par,nx,ny,nz,mdv)endifc Set the centre point (needed for rotations)if (com.eq.'cex') thencex=parendifif (com.eq.'cey') thencey=parendifc Rotation around the centrre pointif (com.eq.'rot') thencall mod_rotation (ano,par,cex,cey,> nx,ny,nz,xmin,ymin,dx,dy,mdv)endifc Shift in x or in y directionif (com.eq.'shiftx') thencall mod_shift (ano,par,0.,> nx,ny,nz,xmin,ymin,dx,dy,mdv)endifif (com.eq.'shifty') thencall mod_shift (ano,0.,par,> nx,ny,nz,xmin,ymin,dx,dy,mdv)endifc Stretch/shrink in x or in y directionif (com.eq.'stretchx') thencall mod_stretch (ano,par,1.,> nx,ny,nz,xmin,ymin,dx,dy,mdv)endifif (com.eq.'stretchy') thencall mod_stretch (ano,1.,par,> nx,ny,nz,xmin,ymin,dx,dy,mdv)endifc Goto next command/parameter pairgoto 100c All commands handled200 continuec --------------------------------------------------------------------------------c Write modified fieldsc --------------------------------------------------------------------------------c Build the modified PV distribution from the anomalydo i=0,nxdo j=0,nydo k=0,nzif ( (abs(pv1(i,j,k)-mdv).gt.eps).and.> (abs(ano(i,j,k)-mdv).gt.eps) ) thenpv2(i,j,k)=pv1(i,j,k)-ano(i,j,k)elsepv2(i,j,k)=mdvendifenddoenddoenddoc Write result to netcdf filevarname='PV_FILT'call write_inp (pv2,varname,pvsrcfile,nx,ny,nz)c Write the modified anomaly also to the filevarname='PV_ANOM'call write_inp (ano,varname,pvsrcfile,nx,ny,nz)endc ********************************************************************************c * Command handling and transformations *c ********************************************************************************c --------------------------------------------------------------------------------c Extract next command from command stringc --------------------------------------------------------------------------------subroutine next_command (commandstr,n,com,par)c Given the command string <commandstr>, extract the next command/parameter pairc <com,par> starting at position <n> of the command string.implicit nonec Declaration of subroutine parameterscharacter*80 commandstrcharacter*80 comreal parinteger nc Auxiliary variablesinteger i,j,kc Check whether end of command line reachedif (n.ge.80) thencom='nil'par=0.goto 120endifc Set indices to next next command/parameter pairi=nj=n100 if ( (commandstr(j:j).ne.'=').and.(j.lt.80) ) thenj=j+1goto 100endifk=j+1110 if ( (commandstr(k:k).ne.',' ).and.> (commandstr(k:k).ne.';' ).and.> (commandstr(k:k).ne.' ' ).and.> (k .lt.80 ) ) thenk=k+1goto 110endifc Check whether this is a valid command/parameter pairif ( ((j-1).lt.i).or.((k-1).lt.(j+1)) ) thencom='nil'par=0.goto 120endifc Extract tzhe command and the parametercom=commandstr(i:j-1)read(commandstr(j+1:k-1),*) parc Set the counter to the next command/parameter pairn=k+1c Exit point120 continueendc --------------------------------------------------------------------------------c Multiply the anomaly by a factorc --------------------------------------------------------------------------------subroutine mod_factor (field,factor,nx,ny,nz,mdv)c Multiply the anomaly <field> by a constant factor <factor>. The grid and thec missing data value are given by <nx,ny,nz,mdv>.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field(0:nx,0:ny,0:nz)real mdvreal factorc Parametersreal epsparameter (eps=0.01)c Auxiliary variablesinteger i,j,kc Do the transformationdo i=0,nxdo j=0,nydo k=0,nzif ( (abs(field(i,j,k)-mdv).gt.eps) ) thenfield(i,j,k)=factor*field(i,j,k)endifenddoenddoenddoendc --------------------------------------------------------------------------------c Rotate the anomalyc --------------------------------------------------------------------------------subroutine mod_rotation (field,angle,cex,cey,> nx,ny,nz,xmin,ymin,dx,dy,mdv)c Rotate the anomaly <field> in the horizontal by the angle <angle>. The centrec for the rotation is given by <cex,cey>, expressed in rotated longitude, latitude.c The grid and the missing data value are given by <nx,ny,nz,xmin,ymin,dx,dy,mdv>.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field(0:nx,0:ny,0:nz)real xmin,ymin,dx,dyreal mdvreal anglereal cex,ceyc Parametersreal epsparameter (eps=0.01)real pi180parameter (pi180=3.14159/180.)c Auxiliary variablesinteger i,j,kreal lon,lat,rlon,rlatreal xmax,ymaxreal tmp1(0:nx,0:ny),tmp2(0:nx,0:ny)c Externalsreal int2dexternal int2dc Maximal grid extensionxmax=xmin+real(nx-1)*dxymax=ymin+real(ny-1)*dyc Do the Transformationdo k=0,nzc Copy level to 2d arraydo i=0,nxdo j=0,nytmp1(i,j)=field(i,j,k)enddoenddoc Rotate each grid pointdo i=0,nxdo j=0,nyc Lon/lat coordinates of grid pointlon=xmin+real(i)*dx-cexlat=ymin+real(j)*dy-ceyc Rotationrlon = cex + lon*cos(angle*pi180) + lat*sin(angle*pi180)rlat = cey - lon*sin(angle*pi180) + lat*cos(angle*pi180)c Do the interpolationif ( (rlon.gt.xmin).and.(rlon.lt.xmax).and.> (rlat.gt.ymin).and.(rlat.lt.ymax) )> thentmp2(i,j)=int2d(tmp1,rlon,rlat,> dx,dy,xmin,ymin,nx,ny,mdv)elsetmp2(i,j)=0.endifenddoenddoc Copy 2d array to leveldo i=0,nxdo j=0,nyfield(i,j,k)=tmp2(i,j)enddoenddoenddoendc --------------------------------------------------------------------------------c Shift the anomaly in x and y directionc --------------------------------------------------------------------------------subroutine mod_shift (field,shiftx,shifty,> nx,ny,nz,xmin,ymin,dx,dy,mdv)c Shift the anomaly <field> in the horizontal by the vector <shiftx,shifty>.c The grid and the missing data value are given by <nx,ny,nz,xmin,ymin,dx,dy,mdv>.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field(0:nx,0:ny,0:nz)real xmin,ymin,dx,dyreal mdvreal shiftx,shiftyc Parametersreal epsparameter (eps=0.01)c Auxiliary variablesinteger i,j,kreal lon,lat,rlon,rlatreal xmax,ymaxreal tmp1(0:nx,0:ny),tmp2(0:nx,0:ny)c Externalsreal int2dexternal int2dc Maximal grid extensionxmax=xmin+real(nx-1)*dxymax=ymin+real(ny-1)*dyc Do the Transformationdo k=0,nzc Copy level to 2d arraydo i=0,nxdo j=0,nytmp1(i,j)=field(i,j,k)enddoenddoc Rotate each grid pointdo i=0,nxdo j=0,nyc Lon/lat coordinates of grid pointlon=xmin+real(i)*dxlat=ymin+real(j)*dyc shifted coordinatesrlon = lon - shiftxrlat = lat - shiftyc Do the interpolationif ( (rlon.gt.xmin).and.(rlon.lt.xmax).and.> (rlat.gt.ymin).and.(rlat.lt.ymax) )> thentmp2(i,j)=int2d(tmp1,rlon,rlat,> dx,dy,xmin,ymin,nx,ny,mdv)elsetmp2(i,j)=0.endifenddoenddoc Copy 2d array to leveldo i=0,nxdo j=0,nyfield(i,j,k)=tmp2(i,j)enddoenddoenddoendc --------------------------------------------------------------------------------c Stretch/shrink the anomaly in x and y directionc --------------------------------------------------------------------------------subroutine mod_stretch (field,stretchx,stretchy,> nx,ny,nz,xmin,ymin,dx,dy,mdv)c Stretch the anomaly <field> in the horizontal by the fatcors <stretchx,stretchy>.c The grid and the missing data value are given by <nx,ny,nz,xmin,ymin,dx,dy,mdv>.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field(0:nx,0:ny,0:nz)real xmin,ymin,dx,dyreal mdvreal stretchx,stretchyc Parametersreal epsparameter (eps=0.01)c Auxiliary variablesinteger i,j,kreal lon,lat,rlon,rlatreal xmax,ymaxreal tmp1(0:nx,0:ny),tmp2(0:nx,0:ny)c Externalsreal int2dexternal int2dc Maximal grid extensionxmax=xmin+real(nx-1)*dxymax=ymin+real(ny-1)*dyc Do the Transformationdo k=0,nzc Copy level to 2d arraydo i=0,nxdo j=0,nytmp1(i,j)=field(i,j,k)enddoenddoc Rotate each grid pointdo i=0,nxdo j=0,nyc Lon/lat coordinates of grid pointlon=xmin+real(i)*dxlat=ymin+real(j)*dyc shifted coordinatesrlon = 1./stretchx * lonrlat = 1./stretchy * latc Do the interpolationif ( (rlon.gt.xmin).and.(rlon.lt.xmax).and.> (rlat.gt.ymin).and.(rlat.lt.ymax) )> thentmp2(i,j)=int2d(tmp1,rlon,rlat,> dx,dy,xmin,ymin,nx,ny,mdv)elsetmp2(i,j)=0.endifenddoenddoc Copy 2d array to leveldo i=0,nxdo j=0,nyfield(i,j,k)=tmp2(i,j)enddoenddoenddoendc ------------------------------------------------------------------------c Two-dimensional interpolationc ------------------------------------------------------------------------real function int2d(ar,lon,lat,> dx,dy,xmin,ymin,nx,ny,mdv)c Interpolate the field <ar(nx,ny)> to the position <lon,lat>. Thec grid is specified by <dx,dy,xmin,ymin,nx,ny>.implicit nonec Declaration of subroutine paramtersinteger nx,nyreal ar(0:nx,0:ny)real lon,latreal dx,dy,xmin,yminreal mdvc Parametersreal epsparameter (eps=0.01)c Auxiliary variablesreal ri,rjinteger i,j,ir,jureal frac0i,frac0j,frac1i,frac1jreal tmp,norc Get indexri=(lon-xmin)/dxrj=(lat-ymin)/dyi=int(ri)j=int(rj)if ((i.lt.0).or.(i.gt.nx).or.> (j.lt.0).or.(j.gt.ny)) thenprint*,'lat/lon interpolation not possible....'stopendifc Get inidices of left and upper neighboursir=i+1if (ir.gt.nx) ir=nxju=j+1if (ju.gt.ny) ju=nyc Get the weights for the bilinear interpolationfrac0i=ri-float(i)frac0j=rj-float(j)frac1i=1.-frac0ifrac1j=1.-frac0jc Bilinear interpolation with missing data checktmp=0.nor=0.if ( (abs(ar(i ,j )-mdv).gt.eps) ) thentmp = tmp + ar(i ,j ) * frac1i * frac1jnor = nor + frac1i * frac1jendifif ( (abs(ar(i ,ju)-mdv).gt.eps) ) thentmp = tmp + ar(i ,ju) * frac1i * frac0jnor = nor + frac1i * frac0jendifif ( (abs(ar(ir,j )-mdv).gt.eps) ) thentmp = tmp + ar(ir,j ) * frac0i * frac1jnor = nor + frac0i * frac1jendifif ( (abs(ar(ir,ju)-mdv).gt.eps) ) thentmp = tmp + ar(ir,ju) * frac0i * frac0jnor = nor + frac0i * frac0jendifc Return resultint2d=tmp/norendc ********************************************************************************c * NETCDF INPUT AND OUTPUT *c ********************************************************************************c --------------------------------------------------------------------------------c Write input field to netcdfc --------------------------------------------------------------------------------SUBROUTINE write_inp (field,fieldname,pvsrcfile,nx,ny,nz)c Read <fieldname> from netcdf file <pvsrcfile> into <field>. The grid is specifiedc by <nx,ny,nz,dx,dy,dz,xmin,ymin,zmin>. A check is performed whether the inputc files are consitent with this grid.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field (0:nx,0:ny,0:nz)character*80 fieldnamecharacter*80 pvsrcfilec Auxiliary variablesinteger cdfid,statinteger vardim(4)real misdatreal varmin(4),varmax(4),stag(4)integer ndimin,outid,i,j,kreal tmp(0:nx,0:ny,0:nz)integer ntimesreal time(200)integer nvarscharacter*80 vnam(100),varnameinteger isokc Get grid parameters from PVcall cdfopn(pvsrcfile,cdfid,stat)if (stat.ne.0) goto 998call getvars(cdfid,nvars,vnam,stat)if (stat.ne.0) goto 998isok=0varname='PV'call check_varok(isok,varname,vnam,nvars)if (isok.eq.0) goto 998call getdef(cdfid,varname,ndimin,misdat,vardim,> varmin,varmax,stag,stat)if (stat.ne.0) goto 998time(1)=0.call gettimes(cdfid,time,ntimes,stat)if (stat.ne.0) goto 998call clscdf(cdfid,stat)if (stat.ne.0) goto 998c Save variables (write definition, if necessary)call cdfwopn(pvsrcfile,cdfid,stat)if (stat.ne.0) goto 998isok=0varname=fieldnamecall check_varok(isok,varname,vnam,nvars)if (isok.eq.0) thencall putdef(cdfid,varname,ndimin,misdat,vardim,> varmin,varmax,stag,stat)if (stat.ne.0) goto 998endifcall putdat(cdfid,varname,time(1),0,field,stat)print*,'W ',trim(varname),' ',trim(pvsrcfile)if (stat.ne.0) goto 998c Close input netcdf filecall clscdf(cdfid,stat)if (stat.ne.0) goto 998returnc Exception handling998 print*,'Write_Inp: Problem with input netcdf file... Stop'stopendc --------------------------------------------------------------------------------c Read input fields for reference profilec --------------------------------------------------------------------------------SUBROUTINE read_inp (field,fieldname,pvsrcfile,> nx,ny,nz,dx,dy,dz,xmin,ymin,zmin,mdv)c Read <fieldname> from netcdf file <pvsrcfile> into <field>. The grid is specifiedc by <nx,ny,nz,dx,dy,dz,xmin,ymin,zmin>. A check is performed whether the inputc files are consitent with this grid. The missing data value is set to <mdv>.implicit nonec Declaration of subroutine parametersinteger nx,ny,nzreal field(0:nx,0:ny,0:nz)character*80 fieldnamecharacter*80 pvsrcfilereal dx,dy,dz,xmin,ymin,zminreal mdvc Numerical and physical parametersreal epsparameter (eps=0.01)c Auxiliary variablesinteger cdfid,stat,cdfid99integer vardim(4)real misdatreal varmin(4),varmax(4),stag(4)integer ndimin,outid,i,j,kreal tmp(nx,ny,nz)integer ntimesreal time(200)integer nvarscharacter*80 vnam(100),varnameinteger isokc Open the input netcdf filecall cdfopn(pvsrcfile,cdfid,stat)if (stat.ne.0) goto 998c Check whether needed variables are on filecall getvars(cdfid,nvars,vnam,stat)if (stat.ne.0) goto 998isok=0varname=trim(fieldname)call check_varok(isok,varname,vnam,nvars)if (isok.eq.0) goto 998c Get the grid parameters from thetacall getdef(cdfid,varname,ndimin,misdat,vardim,> varmin,varmax,stag,stat)if (stat.ne.0) goto 998time(1)=0.call gettimes(cdfid,time,ntimes,stat)if (stat.ne.0) goto 998c Check whether grid parameters are consistentif ( (vardim(1).ne.(nx+1)).or.> (vardim(2).ne.(ny+1)).or.> (vardim(3).ne.(nz+1)).or.> (abs(varmin(1)-xmin).gt.eps).or.> (abs(varmin(2)-ymin).gt.eps).or.> (abs(varmin(3)-zmin).gt.eps).or.> (abs((varmax(1)-varmin(1))/real(vardim(1)-1)-dx).gt.eps).or.> (abs((varmax(2)-varmin(2))/real(vardim(2)-1)-dy).gt.eps).or.> (abs((varmax(3)-varmin(3))/real(vardim(3)-1)-dz).gt.eps) )>thenprint*,'Input grid inconsitency...'print*,' Nx = ',vardim(1),nx+1print*,' Ny = ',vardim(2),ny+1print*,' Nz = ',vardim(3),nz+1print*,' Varminx = ',varmin(1),xminprint*,' Varminy = ',varmin(2),yminprint*,' Varminz = ',varmin(3),zminprint*,' Dx = ',(varmax(1)-varmin(1))/real(nx-1),dxprint*,' Dy = ',(varmax(2)-varmin(2))/real(ny-1),dyprint*,' Dz = ',(varmax(3)-varmin(3))/real(nz-1),dzgoto 998endifc Load variablescall getdef(cdfid,varname,ndimin,misdat,vardim,> varmin,varmax,stag,stat)if (stat.ne.0) goto 998call getdat(cdfid,varname,time(1),0,field,stat)print*, 'R ',trim(varname),' ',trim(pvsrcfile)if (stat.ne.0) goto 998c Close input netcdf filecall clscdf(cdfid,stat)if (stat.ne.0) goto 998c Set missing data value to <mdv>do i=1,nxdo j=1,nydo k=1,nzif (abs(field(i,j,k)-misdat).lt.eps) thenfield(i,j,k)=mdvendifenddoenddoenddoreturnc Exception handling998 print*,'Read_Inp: Problem with input netcdf file... Stop'stopendc --------------------------------------------------------------------------------c Check whether variable is found on netcdf filec --------------------------------------------------------------------------------subroutine check_varok (isok,varname,varlist,nvars)c Check whether the variable <varname> is in the list <varlist(nvars)>. If this isC the case, <isok> is incremented by 1. Otherwise <isok> keeps its value.implicit nonec Declaraion of subroutine parametersinteger isokinteger nvarscharacter*80 varnamecharacter*80 varlist(nvars)c Auxiliary variablesinteger ic Maindo i=1,nvarsif (trim(varname).eq.trim(varlist(i))) isok=isok+1enddoendc --------------------------------------------------------------------------------c Get grid parametersc --------------------------------------------------------------------------------subroutine read_dim (nx,ny,nz,dx,dy,dz,xmin,ymin,zmin,mdv,> pvsrcfile)c Get the grid parameters from the variable <THETA> on the input file <pvsrcfile>.c The grid parameters arec nx,ny,nz : Number of grid points in x, y and z directionc xmin,ymin,zmin : Minimum domain coordinates in x, y and z directionc xmax,ymax,zmax : Maximal domain coordinates in x, y and z directionc dx,dy,dz : Horizontal and vertical resolutionc Additionally, it is checked whether the vertical grid is equally spaced. If ok,c the grid paramters are transformed from lon/lat to distance (in meters)implicit nonec Declaration of subroutine parameterscharacter*80 pvsrcfileinteger nx,ny,nzreal dx,dy,dzreal xmin,ymin,zmin,xmax,ymax,zmaxreal mdvc Numerical epsilon and other physical/geoemtrical parametersreal epsparameter (eps=0.01)c Auxiliary variablesinteger cdfid,cstidinteger ierrcharacter*80 vnam(100),varnameinteger nvarsinteger isokinteger vardim(4)real misdatreal varmin(4),varmax(4),stag(4)real aklev(1000),bklev(1000),aklay(1000),bklay(1000)real dhcharacter*80 csninteger ndiminteger ic Get all grid parameterscall cdfopn(pvsrcfile,cdfid,ierr)if (ierr.ne.0) goto 998call getvars(cdfid,nvars,vnam,ierr)if (ierr.ne.0) goto 998isok=0varname='PV'call check_varok(isok,varname,vnam,nvars)if (isok.eq.0) goto 998call getcfn(cdfid,csn,ierr)if (ierr.ne.0) goto 998call cdfopn(csn,cstid,ierr)if (ierr.ne.0) goto 998call getdef(cdfid,varname,ndim,misdat,vardim,varmin,varmax,> stag,ierr)if (ierr.ne.0) goto 998nx=vardim(1)ny=vardim(2)nz=vardim(3)xmin=varmin(1)ymin=varmin(2)zmin=varmin(3)call getlevs(cstid,nz,aklev,bklev,aklay,bklay,ierr)if (ierr.ne.0) goto 998call getgrid(cstid,dx,dy,ierr)if (ierr.ne.0) goto 998xmax=varmax(1)ymax=varmax(2)zmax=varmax(3)dz=(zmax-zmin)/real(nz-1)call clscdf(cstid,ierr)if (ierr.ne.0) goto 998call clscdf(cdfid,ierr)if (ierr.ne.0) goto 998c Check whether the grid is equallay spaced in the verticaldo i=1,nz-1dh=aklev(i+1)-aklev(i)if (abs(dh-dz).gt.eps) thenprint*,'Aklev: Vertical grid must be equally spaced... Stop'print*,(aklev(i),i=1,nz)stopendifdh=aklay(i+1)-aklay(i)if (abs(dh-dz).gt.eps) thenprint*,'Aklay: Vertical grid must be equally spaced... Stop'print*,(aklay(i),i=1,nz)stopendifenddoc Set missing data valuemdv=misdatreturnc Exception handling998 print*,'Read_Dim: Problem with input netcdf file... Stop'stopend