[Dart-dev] DART/branches Revision: 12154
dart at ucar.edu
dart at ucar.edu
Fri Dec 1 09:50:32 MST 2017
nancy at ucar.edu
2017-12-01 09:50:31 -0700 (Fri, 01 Dec 2017)
133
return VERTISSURFACE for 2d fields in get_state_meta_data()
and first stab at computing surface pressure for staggered
grid points.
Modified: DART/branches/recam/models/cam-fv/model_mod.f90
===================================================================
--- DART/branches/recam/models/cam-fv/model_mod.f90 2017-11-30 22:28:00 UTC (rev 12153)
+++ DART/branches/recam/models/cam-fv/model_mod.f90 2017-12-01 16:50:31 UTC (rev 12154)
@@ -301,7 +301,7 @@
! Local variables
integer :: iloc, vloc, jloc
-integer :: myvarid, myqty
+integer :: myvarid, myqty, nd
if ( .not. module_initialized ) call static_init_model
@@ -308,8 +308,9 @@
call get_model_variable_indices(index_in, iloc, jloc, vloc, var_id=myvarid)
myqty = get_kind_index(domain_id, myvarid)
+nd = get_num_dims(domain_id, myvarid)
-location = get_location_from_index(iloc, jloc, vloc, myqty)
+location = get_location_from_index(iloc, jloc, vloc, myqty, nd)
! return state quantity for this index if requested
if (present(var_type)) var_type = myqty
@@ -318,20 +319,31 @@
!-----------------------------------------------------------------------
-function get_location_from_index(i, j, k, q)
+function get_location_from_index(i, j, k, q, nd)
integer, intent(in) :: i
integer, intent(in) :: j
integer, intent(in) :: k
integer, intent(in) :: q
+integer, intent(in) :: nd
type(location_type) :: get_location_from_index
real(r8) :: slon_val
+real(r8) :: use_vert_val
+integer :: use_vert_type
+if (nd == 2) then
+ use_vert_type = VERTISSURFACE
+ use_vert_val = MISSING_R8 ! could also be surface elevation
+else
+ use_vert_type = VERTISLEVEL
+ use_vert_val = real(k,r8)
+endif
+
select case (grid_stagger%qty_stagger(q))
case (STAGGER_U)
get_location_from_index = set_location(grid_data%lon%vals(i), &
grid_data%slat%vals(j), &
- real(k,r8), VERTISLEVEL)
+ use_vert_val, use_vert_type)
case (STAGGER_V)
slon_val = grid_data%slon%vals(i)
@@ -339,18 +351,18 @@
if (slon_val > 360) slon_val = slon_val - 360.0_r8
get_location_from_index = set_location(slon_val, &
grid_data%lat%vals(j), &
- real(k,r8), VERTISLEVEL)
+ use_vert_val, use_vert_type)
!>@todo not sure what to do yet. ? +-1/2 ?
case (STAGGER_W)
get_location_from_index = set_location(grid_data%lon%vals(i), &
grid_data%lat%vals(j), &
- real(k,r8)-0.5_r8, VERTISLEVEL)
+ use_vert_val - 0.5_r8, use_vert_type)
! no stagger - cell centers
case default
get_location_from_index = set_location(grid_data%lon%vals(i), &
grid_data%lat%vals(j), &
- real(k,r8), VERTISLEVEL)
+ use_vert_val, use_vert_type)
end select
@@ -358,6 +370,59 @@
!-----------------------------------------------------------------------
!>
+!> this routine should be called to get a value from an unstaggered grid
+!> that corresponds to a staggered grid. e.g. you need the surface pressurre
+!> under a V wind point.
+
+subroutine get_staggered_values_from_qty(ens_handle, ens_size, qty, lon_index, lat_index, lev_index, stagger_qty, vals, my_status)
+type(ensemble_type), intent(in) :: ens_handle
+integer, intent(in) :: ens_size
+integer, intent(in) :: qty
+integer, intent(in) :: lon_index
+integer, intent(in) :: lat_index
+integer, intent(in) :: lev_index
+integer, intent(in) :: stagger_qty
+real(r8), intent(out) :: vals(ens_size)
+integer, intent(out) :: my_status
+
+integer :: next_lat, next_lon, stagger
+real(r8) :: vals_bot(ens_size), vals_top(ens_size)
More information about the Dart-dev
mailing list