[Dart-dev] DART/branches Revision: 12048

dart at ucar.edu dart at ucar.edu
Sat Nov 4 14:27:56 MDT 2017


hendric at ucar.edu
2017-11-04 14:27:54 -0600 (Sat, 04 Nov 2017)
59
adding netcdf routines to write grid information for CAM.




Modified: DART/branches/recam/models/cam-fv/new_model_mod.f90
===================================================================
--- DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-03 23:51:26 UTC (rev 12047)
+++ DART/branches/recam/models/cam-fv/new_model_mod.f90	2017-11-04 20:27:54 UTC (rev 12048)
@@ -25,12 +25,15 @@
 use  ensemble_manager_mod
 use distributed_state_mod
 use   state_structure_mod
-use  netcdf_utilities_mod,  only : nc_check, nc_get_variable, nc_get_variable_size
+use  netcdf_utilities_mod,  only : nc_check, nc_get_variable, nc_get_variable_size, &
+                                   nc_add_attribute_to_variable, nc_define_real_variable, &
+                                   nc_add_global_creation_time, nc_add_global_attribute, &
+                                   nc_define_dimension, nc_put_variable, nc_sync, nc_enddef, &
+                                   nc_redef
 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
-
 use netcdf
 
 implicit none
@@ -401,234 +404,151 @@
 !> This includes coordinate variables and some metadata, but NOT the
 !> actual DART state.
 !>
-!> @param ncid the netCDF handle of the DART diagnostic file opened by
-!>                 assim_model_mod:init_diag_output
-!> @param model_writes_state have the state structure write out all of the
-!>                 state variables
+!> @param ncid    the netCDF handle of the DART diagnostic file opened by
+!>                assim_model_mod:init_diag_output
 
-subroutine nc_write_model_atts(ncid, domain_id)
+subroutine nc_write_model_atts(ncid, dom_id)
 
 integer, intent(in) :: ncid      ! netCDF file identifier
-integer, intent(in) :: domain_id
+integer, intent(in) :: dom_id
 
-integer :: nDimensions, nVariables, nAttributes, unlimitedDimID
-
 ! for the dimensions and coordinate variables
-integer :: nxirhoDimID, nxiuDimID, nxivDimID
-integer :: netarhoDimID, netauDimID, netavDimID
-integer :: nsrhoDimID, nswDimID
-integer :: VarID
+integer :: NlonDimID, NlatDimID, NzDimID
+integer :: ulonVarID, ulatVarID, tlonVarID, tlatVarID, ZGVarID, ZCVarID
+integer :: KMTVarID, KMUVarID
 
-! local variables
+!----------------------------------------------------------------------
+! local variables 
+!----------------------------------------------------------------------
 
-character(len=256) :: filename
+character(len=*), parameter :: routine = 'nc_write_model_atts'
+integer     :: i
 
 if ( .not. module_initialized ) call static_init_model
 
-! we only have a netcdf handle here so we do not know the filename
-! or the fortran unit number.  but construct a string with at least
-! the netcdf handle, so in case of error we can trace back to see
-! which netcdf file is involved.
+!-------------------------------------------------------------------------------
+! Write Global Attributes 
+!-------------------------------------------------------------------------------
+call nc_redef(ncid)
 
-write(filename,*) 'ncid', ncid
+call nc_add_global_creation_time(ncid)
 
-!#! ! Write Global Attributes
+call nc_add_global_attribute(ncid, "model_source", source )
+call nc_add_global_attribute(ncid, "model_revision", revision )
+call nc_add_global_attribute(ncid, "model_revdate", revdate )
+
+call nc_add_global_attribute(ncid, "model", "CAM")
+
+!----------------------------------------------------------------------------
+! Output the grid variables.
+!----------------------------------------------------------------------------
+! Define the new dimensions IDs
+!----------------------------------------------------------------------------
+
+call nc_define_dimension(ncid, 'lon',  grid_data%lon%nsize,  routine)
+call nc_define_dimension(ncid, 'lat',  grid_data%lat%nsize,  routine)
+call nc_define_dimension(ncid, 'slon', grid_data%slon%nsize, routine)
+call nc_define_dimension(ncid, 'slat', grid_data%slat%nsize, routine)
+call nc_define_dimension(ncid, 'lev',  grid_data%lev%nsize,  routine)
+call nc_define_dimension(ncid, 'ilev', grid_data%ilev%nsize, routine)
+call nc_define_dimension(ncid, 'gw',   grid_data%gw%nsize,   routine)
+call nc_define_dimension(ncid, 'hyam', grid_data%hyam%nsize, routine)
+call nc_define_dimension(ncid, 'hybm', grid_data%hybm%nsize, routine)
+call nc_define_dimension(ncid, 'hyai', grid_data%hyai%nsize, routine)
+call nc_define_dimension(ncid, 'hybi', grid_data%hybi%nsize, routine)
+
+!----------------------------------------------------------------------------
+! Create the Coordinate Variables and the Attributes


More information about the Dart-dev mailing list