[Dart-dev] DART/branches Revision: 12050

dart at ucar.edu dart at ucar.edu
Mon Nov 6 09:39:59 MST 2017


nancy at ucar.edu
2017-11-06 09:39:55 -0700 (Mon, 06 Nov 2017)
289
move stagger location into a separate routine (we can
revisit this if you want - but i believe we may need
this in another location in the code). 

add support for skipping the grid write code in the
nc_write_model_atts() routine.  add debug dump code
that only prints N values per line.




Modified: DART/branches/recam/models/cam-fv/new_model_mod.f90
===================================================================
--- DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-04 21:22:34 UTC (rev 12049)
+++ DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-06 16:39:55 UTC (rev 12050)
@@ -271,35 +271,49 @@
 
 myqty = get_kind_index(domain_id, myvarid)
 
-select case (grid_stagger%qty_stagger(myqty))
+location = get_location_from_index(iloc, jloc, vloc, myvarid)
+
+! return state quantity for this index if requested
+if (present(var_type)) var_type = myqty
+
+end subroutine get_state_meta_data
+
+!-----------------------------------------------------------------------
+
+function get_location_from_index(i, j, k, q)
+integer, intent(in) :: i
+integer, intent(in) :: j
+integer, intent(in) :: k
+integer, intent(in) :: q
+type(location_type) :: get_location_from_index
+
+
+select case (grid_stagger%qty_stagger(q))
   case (STAGGER_U)
-   location = set_location(grid_data%lon%vals(iloc), &
-                           grid_data%slat%vals(jloc), &
-                           real(vloc,r8), VERTISLEVEL)
+   get_location_from_index = set_location(grid_data%lon%vals(i), &
+                                          grid_data%slat%vals(j), &
+                                          real(k,r8), VERTISLEVEL)
 
   case (STAGGER_V)
-   location = set_location(grid_data%slon%vals(iloc), &
-                           grid_data%lat%vals(jloc), &
-                           real(vloc,r8), VERTISLEVEL)
+   get_location_from_index = set_location(grid_data%slon%vals(i), &
+                                          grid_data%lat%vals(j), &
+                                          real(k,r8), VERTISLEVEL)
    
   !>@todo not sure what to do yet. ? +-1/2 ?
   case (STAGGER_W)
-   location = set_location(grid_data%lon%vals(iloc), &
-                           grid_data%lat%vals(jloc), &
-                           real(vloc,r8), VERTISLEVEL)
+   get_location_from_index = set_location(grid_data%lon%vals(i), &
+                                          grid_data%lat%vals(j), &
+                                          real(k,r8)-0.5_r8, VERTISLEVEL)
+  ! no stagger - cell centers
   case default
-   location = set_location(grid_data%lon%vals(iloc), &
-                           grid_data%lat%vals(jloc), &
-                           real(vloc,r8), VERTISLEVEL)
+   get_location_from_index = set_location(grid_data%lon%vals(i), &
+                                          grid_data%lat%vals(j), &
+                                          real(k,r8), VERTISLEVEL)
 
 end select
 
-! return state quantity for this index if requested
-if (present(var_type)) var_type = myqty
+end function get_location_from_index
 
-end subroutine get_state_meta_data
-
-
 !-----------------------------------------------------------------------
 !>
 !> Model interpolate will interpolate any DART state variable
@@ -439,6 +453,16 @@
 
 call nc_add_global_attribute(ncid, "model", "CAM")
 
+! this option is for users who want the smallest output
+! or diagnostic files - only the state vector data will
+! be written.   otherwise, if you want to plot this data
+! the rest of this routine writes out enough grid info
+! to make the output file look like the input.
+if (minimal_output) then
+   call nc_enddef(ncid)
+   return
+endif
+
 !----------------------------------------------------------------------------
 ! Output the grid variables.
 !----------------------------------------------------------------------------
@@ -879,6 +903,7 @@
 character(len=*),   intent(in)    :: varname
 type(cam_1d_array), intent(inout) :: grid_array
 
+integer :: i, per_line
 !>@todo need to check that this exists
 call nc_get_variable_size(ncid, varname, grid_array%nsize)
 allocate(grid_array%vals(grid_array%nsize))
@@ -885,8 +910,14 @@
 
 call nc_get_variable(ncid, varname, grid_array%vals)
 


More information about the Dart-dev mailing list