[Dart-dev] DART/branches Revision: 12044

dart at ucar.edu dart at ucar.edu
Fri Nov 3 16:37:51 MDT 2017


nancy at ucar.edu
2017-11-03 16:37:49 -0600 (Fri, 03 Nov 2017)
262
added the start of quad interpolation support.
the plan is to call it once to get the horizontal
corner indices, and then evaluate it at the lower
and upper levels and then interpolate linearly in
the vertical.

added the quad code from the quad_interp branch.




Modified: DART/branches/recam/models/cam-fv/new_model_mod.f90
===================================================================
--- DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-03 22:08:41 UTC (rev 12043)
+++ DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-03 22:37:49 UTC (rev 12044)
@@ -27,6 +27,7 @@
 use   state_structure_mod
 use  netcdf_utilities_mod,  only : nc_check, nc_get_variable, nc_get_variable_size
 use       location_io_mod
+use        quad_utils_mod
 use     default_model_mod,  only : adv_1step, init_time, init_conditions, &
                                    nc_write_model_vars, pert_model_copies
 
@@ -150,6 +151,11 @@
 ! Surface potential; used for calculation of geometric heights.
 real(r8), allocatable :: phis(:, :)
 
+! Horizontal interpolation code.  Need a handle for nonstaggered, U and V.
+type(quad_interp_handle) :: interp_nonstaggered, &
+                            interp_u_staggered, &
+                            interp_v_staggered
+
 contains
 
 
@@ -328,11 +334,10 @@
 interp_val = MISSING_R8
 istatus = 99
 
-lon_lat_vert = get_location(obs_loc)
+lon_lat_vert = get_location(location)
 
 varid = get_varid_from_kind(domain_id, obs_qty)
 
-
 if (varid < 0) then
    if(debug > 12) then
       write(string1,*)'did not find obs_qty ', obs_qty, ' in the state'
@@ -880,7 +885,7 @@
 !>
 
 
-subroutine read_grid_info(grid_file, grid )
+subroutine read_grid_info(grid_file, grid)
 character(len=*), intent(in)  :: grid_file
 type(cam_grid),   intent(out) :: grid
 
@@ -891,8 +896,11 @@
                'read_grid_info', 'open '//trim(grid_file))
 
 ! Get the grid info
-call get_cam_grid(ncid)
+call get_cam_grid(ncid, grid)
 
+! Set up the interpolation structure for later 
+call setup_interpolation(grid)
+
 call nc_check( nf90_close(ncid), 'read_grid_info', 'close '//trim(grid_file))
 
 end subroutine read_grid_info
@@ -903,23 +911,56 @@
 !> 
 !>   
 
-subroutine get_cam_grid(ncid)
-integer, intent(in) :: ncid
+subroutine setup_interpolation(grid)
+type(cam_grid), intent(in) :: grid
 
-call fill_cam_1d_array(ncid, 'lon',  grid_data%lon)
-call fill_cam_1d_array(ncid, 'lat',  grid_data%lat)
-call fill_cam_1d_array(ncid, 'lev',  grid_data%lev)
-call fill_cam_1d_array(ncid, 'ilev', grid_data%ilev) ! for staggered vertical grid
-call fill_cam_1d_array(ncid, 'slon', grid_data%slon)
-call fill_cam_1d_array(ncid, 'slat', grid_data%slat)
-call fill_cam_1d_array(ncid, 'gw',   grid_data%gw)   ! gauss weights
-call fill_cam_1d_array(ncid, 'hyai', grid_data%hyai)
-call fill_cam_1d_array(ncid, 'hybi', grid_data%hybi)
-call fill_cam_1d_array(ncid, 'hyam', grid_data%hyam)
-call fill_cam_1d_array(ncid, 'hybm', grid_data%hybm)
+!>@todo FIXME the cam fv grid is really evenly spaced in lat and lon,
+!>even though they provide full lon() and lat() arrays.  the deltas
+!>between each pair would be faster
 
+! mass points at cell centers
+call init_quad_interp(GRID_QUAD_IRREG_SPACED_REGULAR, grid%lon%nsize, grid%lat%nsize, QUAD_LOCATED_CELL_CENTERS, &
+                      global=.true., spans_lon_zero=.true., pole_wrap=.true., &
+                      interp_handle=interp_nonstaggered)
+call set_quad_coords(interp_nonstaggered, grid%lon%vals, grid%lat%vals)
+
+! U stagger
+call init_quad_interp(GRID_QUAD_IRREG_SPACED_REGULAR, grid%lon%nsize, grid%slat%nsize, QUAD_LOCATED_CELL_CENTERS, &
+                      global=.true., spans_lon_zero=.true., pole_wrap=.true., &
+                      interp_handle=interp_u_staggered)
+call set_quad_coords(interp_u_staggered, grid%lon%vals, grid%slat%vals)
+
+! V stagger
+call init_quad_interp(GRID_QUAD_IRREG_SPACED_REGULAR, grid%slon%nsize, grid%lat%nsize, QUAD_LOCATED_CELL_CENTERS, &
+                      global=.true., spans_lon_zero=.true., pole_wrap=.true., &
+                      interp_handle=interp_v_staggered)
+call set_quad_coords(interp_v_staggered, grid%slon%vals, grid%lat%vals)
+


More information about the Dart-dev mailing list