[Dart-dev] [4477] DART/trunk/models/NCOMMAS/model_mod.f90: Krikey ... patched s

nancy at ucar.edu nancy at ucar.edu
Fri Aug 13 14:15:52 MDT 2010


Revision: 4477
Author:   thoar
Date:     2010-08-13 14:15:52 -0600 (Fri, 13 Aug 2010)
Log Message:
-----------
Krikey ... patched sv_to_restart_file() so that it checks the size of the
prognostic variable in memory - not the size of the netCDF variable - to
allocate space for the variable. The start/count mechanism in the nf90_put_var()
accounts for the fact you're stuffing a 3D variable into a 5D slot.

Ran ncommas_to_dart, perfect_model_obs, and dart_to_ncommas cleanly.

I also pruned out some unused variables as determined by the ifort compiler.

Modified Paths:
--------------
    DART/trunk/models/NCOMMAS/model_mod.f90

-------------- next part --------------
Modified: DART/trunk/models/NCOMMAS/model_mod.f90
===================================================================
--- DART/trunk/models/NCOMMAS/model_mod.f90	2010-08-12 23:40:48 UTC (rev 4476)
+++ DART/trunk/models/NCOMMAS/model_mod.f90	2010-08-13 20:15:52 UTC (rev 4477)
@@ -316,7 +316,7 @@
   
 ! Local variables
 
-  integer  :: nxp, nyp, nzp, var_index, iloc, jloc, kloc, nf, n
+  integer  :: nxp, nyp, nzp, iloc, jloc, kloc, nf, n
   integer  :: myindx, lat_index, lon_index, index2
   real(r8) :: height
   real(r8) :: x1,y1
@@ -432,7 +432,7 @@
 integer, dimension(NF90_MAX_VAR_DIMS) :: dimIDs
 character(len=NF90_MAX_NAME)          :: varname
 character(len=paramname_length)       :: kind_string
-integer :: ncid, VarID, numdims, dimlen, varsize, nc_rc
+integer :: ncid, VarID, numdims, dimlen, varsize
 integer :: iunit, io, ivar, i, index1, indexN
 integer :: ss, dd
 integer :: nDimensions, nVariables, nAttributes, unlimitedDimID, TimeDimID
@@ -639,8 +639,8 @@
 model_size = progvar(nfields)%indexN
 
 if ( debug > 0 ) then
-  write(logfileunit, *)'grid: nx[ce], ny[ce], nz[ce] = ', nxc, nxe, nyc, nye, nzc, nze
-  write(     *     , *)'grid: nx[ce], ny[ce], nz[ce] = ', nxc, nxe, nyc, nye, nzc, nze
+  write(logfileunit,'("grid: nx[ce], ny[ce], nz[ce] =",6(1x,i5))') nxc, nxe, nyc, nye, nzc, nze
+  write(     *     ,'("grid: nx[ce], ny[ce], nz[ce] =",6(1x,i5))') nxc, nxe, nyc, nye, nzc, nze
   write(logfileunit, *)'model_size = ', model_size
   write(     *     , *)'model_size = ', model_size
 endif
@@ -1241,7 +1241,6 @@
 
 integer, dimension(NF90_MAX_VAR_DIMS) :: dimIDs, mystart, mycount
 character(len=NF90_MAX_NAME)          :: varname 
-integer :: nDimensions, nVariables, nAttributes, unlimitedDimID
 integer :: i, ivar, VarID, ncNdims, dimlen
 integer :: TimeDimID, CopyDimID
 
@@ -1697,8 +1696,8 @@
    where(dimIDs == TimeDimID) mycount = 1   ! only the latest one
 
    if ( debug > 1 ) then
-      write(*,*)'restart_file_to_sv '//trim(varname)//' start is ',mystart(1:ncNdims)
-      write(*,*)'restart_file_to_sv '//trim(varname)//' count is ',mycount(1:ncNdims)
+      write(*,*)'restart_file_to_sv '//trim(varname)//' start = ',mystart(1:ncNdims)
+      write(*,*)'restart_file_to_sv '//trim(varname)//' count = ',mycount(1:ncNdims)
    endif
 
    indx = progvar(ivar)%index1
@@ -1852,7 +1851,6 @@
 if (do_output()) &
     call print_date(statedate,'date of restart file '//trim(filename))
 
-
 ! The DART prognostic variables are only defined for a single time.
 ! We already checked the assumption that variables are xy2d or xyz3d ...
 ! IF the netCDF variable has a TIME dimension, it must be the last dimension,
@@ -1910,7 +1908,7 @@
       write(*,*)'sv_to_restart_file '//trim(varname)//' count is ',mycount(1:ncNdims)
    endif
 
-   if (ncNdims == 1) then
+   if (progvar(ivar)%numdims == 1) then
       ni = mycount(1)
       allocate(data_1d_array(ni))
       call vector_to_prog_var(state_vector, progvar(ivar), data_1d_array)
@@ -1919,7 +1917,7 @@
             'sv_to_restart_file', 'put_var '//trim(varname))
       deallocate(data_1d_array)
 
-   elseif (ncNdims == 2) then
+   elseif (progvar(ivar)%numdims == 2) then
 
       ni = mycount(1)
       nj = mycount(2)
@@ -1931,7 +1929,7 @@
             'sv_to_restart_file', 'put_var '//trim(varname))
       deallocate(data_2d_array)
 
-   elseif (ncNdims == 3) then
+   elseif (progvar(ivar)%numdims == 3) then
 
       ni = mycount(1)
       nj = mycount(2)
@@ -1944,7 +1942,7 @@
             'sv_to_restart_file', 'put_var '//trim(varname))
       deallocate(data_3d_array)
 
-   elseif (ncNdims == 4) then
+   elseif (progvar(ivar)%numdims == 4) then
 
       ni = mycount(1)
       nj = mycount(2)
@@ -2040,7 +2038,7 @@
 
   real(r8)         :: loc_array(3), llon, llat
   real(r8)         :: lheight
-  integer          :: base_offset, offset
+  integer          :: base_offset
   integer          :: nf, i, n0, n1
   integer          :: iloc, jloc, kloc, nxp, nyp, nzp
   real(r8)         :: xi, yi, xf, yf, zf, q1, q2, vt, vb
@@ -2475,11 +2473,8 @@
 real(r8),                 intent(out) :: ref_lat, ref_lon
 real(r8),                 intent(out) :: xg_pos, yg_pos, hgt_offset
 
-integer, dimension(NF90_MAX_VAR_DIMS) :: dimIDs
-character(len=NF90_MAX_NAME)          :: varname
-integer                               :: VarID, numdims, dimlen
-integer                               :: ncid, dimid
-integer                               :: i,j
+integer  :: ncid, VarID
+integer  :: i,j
 real(r8) :: x,y,lat,lon
 
 ! Read the netcdf file data


More information about the Dart-dev mailing list