[Dart-dev] DART/branches Revision: 11195
dart at ucar.edu
dart at ucar.edu
Mon Mar 6 09:05:33 MST 2017
nancy at ucar.edu
2017-03-06 09:05:33 -0700 (Mon, 06 Mar 2017)
79
this is new and didn't get committed in the previous
commit (but should have)
Added: DART/branches/location_utils/location/common/location_utils.f90
===================================================================
--- DART/branches/location_utils/location/common/location_utils.f90 (rev 0)
+++ DART/branches/location_utils/location/common/location_utils.f90 2017-03-06 16:05:33 UTC (rev 11195)
@@ -0,0 +1,212 @@
+! 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_utils_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
+
+! 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.
+! VERTISUNDEF, VERTISSURFACE, VERTISLEVEL, VERTISPRESSURE, &
+! VERTISHEIGHT, VERTISSCALEHEIGHT
+
+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$"
+
+! FIXME!!
+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)
+
+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
+ call nc_check(nf90_def_var(ncFileID, 'location', xtype=nf90_double, &
+ dimids=(/ LocDimID /), varid=VarID), &
+ 'nc_write_location_atts', 'location:def_var')
More information about the Dart-dev
mailing list