[Dart-dev] DART/branches Revision: 11301

dart at ucar.edu dart at ucar.edu
Mon Mar 13 10:07:24 MDT 2017


nancy at ucar.edu
2017-03-13 10:07:24 -0600 (Mon, 13 Mar 2017)
269
these two files are not yet used by any other parts of the system, 
but hopefully by making them separate modules it will help to start
to untangle the interdependencies between our existing modules.  
add these now and migrate the code piecewise to start using them.




Added: DART/branches/rma_trunk/assimilation_code/modules/utilities/location_utilities_mod.f90
===================================================================
--- DART/branches/rma_trunk/assimilation_code/modules/utilities/location_utilities_mod.f90	                        (rev 0)
+++ DART/branches/rma_trunk/assimilation_code/modules/utilities/location_utilities_mod.f90	2017-03-13 16:07:24 UTC (rev 11301)
@@ -0,0 +1,263 @@
+! DART software - Copyright UCAR. This open source software is provided
+! by UCAR, "as is", without charge, subject to all terms of use at
+! http://www.image.ucar.edu/DAReS/DART/DART_download
+!
+! $Id$
+
+!> common routines used no matter which location module compiled with
+
+!>@todo FIXME  define ALL the VERTISXXX her, add a call to has_vert_choice
+!>to the xxx/location_mod, and if no, return without needing routines
+!>in each of the specific location routines.  if yes, call query and 
+!>match it with the type to return true/false.  remove vert_is_xxx from 
+!>all the other location routines!!!  :)
+!>will have to replicate the VERTISxxx in the location modules because
+!>fortran doesn't allow circular 'use's between modules.  ugh.
+
+!> the key for the netcdf routines is this sits above the location routines.  
+!> but that makes a circular dep for VERTIS... if they are here it forces
+!> a consistent set of values and removes all the vert_is_xxx routines from
+!> modules that don't have any vert choices.  but you have to replicate the
+!> parameters since you can't have this code use the publics and have the
+!> specific location_mods use VERTISxxx from here.  and depending on which
+!> specific module you use, only some or possibly none of the VERTs are defined.
+!> best we can do, i guess.  fortran sucks sometimes.
+
+!> can we do something about get_close here? simplify the code for
+!> modules which don't have variable vertical options?
+
+module location_utilitiess_mod
+
+use      types_mod, only : r8, MISSING_R8, MISSING_I, PI, RAD2DEG, DEG2RAD, OBSTYPELENGTH
+use  utilities_mod, only : error_handler, E_ERR, nc_check, E_MSG
+
+!>@todo FIXME: there should be accessor functions for 5 LocationXXX variables below.
+use location_mod, only: location_type, get_location, &
+          LocationDims, LocationName, LocationLName, &
+          LocationStorageOrder, LocationUnits, has_vert_choice, &
+          vert_is_height, vert_is_pressure, vert_is_undef, vert_is_level, &
+          vert_is_surface, vert_is_scale_height, query_location
+
+
+use typeSizes
+use netcdf
+
+implicit none
+private
+
+public :: nc_write_location_atts, nc_get_location_varids, nc_write_location, &
+          nc_write_location_vert, has_vert_choice
+
+! version controlled file description for error handling, do not edit
+character(len=256), parameter :: source   = &
+   "$URL$"
+character(len=32 ), parameter :: revision = "$Revision$"
+character(len=128), parameter :: revdate  = "$Date$"
+
+! should import these but they don't exist in low order locations mods
+!>@todo define them all here and replicate in the ones which use them.
+
+integer, parameter :: VERTISUNDEF       = -2  ! has no specific vertical location (undefined)
+integer, parameter :: VERTISSURFACE     = -1  ! surface value (value is surface elevation in m)
+integer, parameter :: VERTISLEVEL       =  1  ! by level
+integer, parameter :: VERTISPRESSURE    =  2  ! by pressure (in pascals)
+integer, parameter :: VERTISHEIGHT      =  3  ! by height (in meters)
+integer, parameter :: VERTISSCALEHEIGHT =  4  ! by scale height (unitless)
+
+interface nc_write_location
+   module procedure nc_write_single_location
+   module procedure nc_write_multiple_locations
+end interface
+
+contains
+
+!----------------------------------------------------------------------------
+!> Create and add attributes to a 'location' dimension and variable.
+
+subroutine nc_write_location_atts( ncFileID, fname, unlimDimID ) 
+ 
+integer,           intent(in) :: ncFileID    ! handle to the netcdf file
+character(len=*),  intent(in) :: fname       ! file name (for printing purposes)
+integer, optional, intent(in) :: unlimDimID  ! handle to the dimension that grows
+
+integer :: LocDimID
+integer :: VarID
+
+! define the rank/dimension of the location information
+call nc_check(nf90_def_dim(ncid=ncFileID, name='location', len=LocationDims, &
+       dimid = LocDimID), 'nc_write_location_atts', 'def_dim:location '//trim(fname))
+
+! Define the location variable and attributes
+
+if (present(unlimDimID)) then
+   call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+             dimids=(/ LocDimID, unlimDimID /), varid=VarID), &
+            'nc_write_location_atts', 'location:def_var')
+else


More information about the Dart-dev mailing list