[Dart-dev] [4495] DART/trunk/models/wrf/model_mod.f90: Change the routine which returns the location of the state vector points.

nancy at ucar.edu nancy at ucar.edu
Thu Sep 16 14:58:35 MDT 2010


Revision: 4495
Author:   nancy
Date:     2010-09-16 14:58:35 -0600 (Thu, 16 Sep 2010)
Log Message:
-----------
Change the routine which returns the location of the state vector points.
The original version only had the mass grid to work from, and so computed
where the staggered points for the U and V grids should be.  However with
a deformed grid these were not exactly in the right places.  The code was
recently changed to read in the U and V staggered grids for writing to the
output diagnostic files, so those grids are now available for use by this
routine.  For the U and V staggers, look up the point locations directly
in the arrays instead of doing a computation.

note that this code is now more accurate, and the expected differences are
slight, but it will NOT be bitwise reproducible with previous versions.  
in simple tests over the CONUS domain i saw differences in the output 
state space diagnostics of order 10e-4 in the U and V field values.

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

-------------- next part --------------
Modified: DART/trunk/models/wrf/model_mod.f90
===================================================================
--- DART/trunk/models/wrf/model_mod.f90	2010-09-16 20:05:54 UTC (rev 4494)
+++ DART/trunk/models/wrf/model_mod.f90	2010-09-16 20:58:35 UTC (rev 4495)
@@ -3356,67 +3356,22 @@
 integer,  intent(in)  :: i,j,var_type, id
 real(r8), intent(out) :: long, lat
 
-! find lat and long, must
-! correct for possible u or v staggering in x, y
+! given i, j indices into the horizontal grid return the lat/long.
+! if u or v staggering use the staggered grids, otherwise use the mass 
+! grid.  this code has changed -- earlier versions only had the mass 
+! grid available and used it to compute cell midpoints and called them 
+! the staggered points.  now that all three grids are being read, look 
+! up the point locations directly from the appropriate array.
 
 if (var_type == wrf%dom(id)%type_u) then
-
-   if (i == 1) then
-      long = wrf%dom(id)%longitude(1,j) - &
-           0.5_r8*(wrf%dom(id)%longitude(2,j)-wrf%dom(id)%longitude(1,j))
-      if ( abs(wrf%dom(id)%longitude(2,j) - wrf%dom(id)%longitude(1,j)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat = wrf%dom(id)%latitude(1,j) - &
-           0.5_r8*(wrf%dom(id)%latitude(2,j)-wrf%dom(id)%latitude(1,j))
-   else if (i == wrf%dom(id)%wes) then
-      long = wrf%dom(id)%longitude(i-1,j) + &
-           0.5_r8*(wrf%dom(id)%longitude(i-1,j)-wrf%dom(id)%longitude(i-2,j))
-      if ( abs(wrf%dom(id)%longitude(i-1,j) - wrf%dom(id)%longitude(i-2,j)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat = wrf%dom(id)%latitude(i-1,j) + &
-           0.5_r8*(wrf%dom(id)%latitude(i-1,j)-wrf%dom(id)%latitude(i-2,j))
-   else
-      long = 0.5_r8*(wrf%dom(id)%longitude(i,j)+wrf%dom(id)%longitude(i-1,j))
-      if ( abs(wrf%dom(id)%longitude(i,j) - wrf%dom(id)%longitude(i-1,j)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat = 0.5_r8*(wrf%dom(id)%latitude(i,j) +wrf%dom(id)%latitude(i-1,j))
-   endif
-
+   long = wrf%dom(id)%longitude_u(i,j)
+   lat  = wrf%dom(id)%latitude_u(i,j)
 elseif (var_type == wrf%dom(id)%type_v) then
-
-   if (j == 1) then
-      long = wrf%dom(id)%longitude(i,1) - &
-           0.5_r8*(wrf%dom(id)%longitude(i,2)-wrf%dom(id)%longitude(i,1))
-      if ( abs(wrf%dom(id)%longitude(i,2) - wrf%dom(id)%longitude(i,1)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat = wrf%dom(id)%latitude(i,1) - &
-           0.5_r8*(wrf%dom(id)%latitude(i,2)-wrf%dom(id)%latitude(i,1))
-   else if (j == wrf%dom(id)%sns) then
-      long = wrf%dom(id)%longitude(i,j-1) + &
-           0.5_r8*(wrf%dom(id)%longitude(i,j-1)-wrf%dom(id)%longitude(i,j-2))
-      if ( abs(wrf%dom(id)%longitude(i,j-1) - wrf%dom(id)%longitude(i,j-2)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat = wrf%dom(id)%latitude(i,j-1) + &
-           0.5_r8*(wrf%dom(id)%latitude(i,j-1)-wrf%dom(id)%latitude(i,j-2))
-   else
-      long = 0.5_r8*(wrf%dom(id)%longitude(i,j)+wrf%dom(id)%longitude(i,j-1))
-      if ( abs(wrf%dom(id)%longitude(i,j) - wrf%dom(id)%longitude(i,j-1)) > 180.0_r8 ) then
-         long = long - 180.0_r8
-      endif
-      lat  = 0.5_r8*(wrf%dom(id)%latitude(i,j) +wrf%dom(id)%latitude(i,j-1))
-
-   endif
-
+   long = wrf%dom(id)%longitude_v(i,j)
+   lat  = wrf%dom(id)%latitude_v(i,j)
 else
-
    long = wrf%dom(id)%longitude(i,j)
    lat  = wrf%dom(id)%latitude(i,j)
-
 endif
 
 do while (long <   0.0_r8)


More information about the Dart-dev mailing list