! 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
!> A collection of interfaces to the MPI (Message Passing Interface)
!> multi-processor communication library routines.
!>
!> This file and its companion file, null_mpi_utilities_mod.f90,
!> are the only modules in the DART system that should be calling
!> the MPI library routines directly.  This isolates the MPI calls
!> and allows programs to swap in the null version to compile the
!> same source files into a serial program.
!>
!> If you add any routines or change any arguments in this file
!> you must make the same changes in the null version.  These two
!> modules have the same module name and must have identical
!> public routines and calling formats.
!>
!> All MPI routines are called from here.  There is a companion
!> file which has the same module name and entry points but all
!> routines are stubs.  This allows a single-task version of the
!> code to be compiled without the MPI libraries.


! 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
! parse a list of blank separated words or name=val pairs from a string.
!
! get_args_from_string() is used to parse a single string into
! multiple blank-separated words.  returns the count of words
! and a character array of each word.
!
! get_name_val_pairs_from_string() is used to parse a line of input
! into two character arrays: the name strings and the value strings.
!
! these routines can be used to parse text lines into tokens,
! or split up a line of input in lieu of command line args from
! a terminal/stdin. in earlier years, fortran routines for parsing
! command line args were a non-standard extension.  alternatives
! that are completely portable are:
!
! have the program read a line from stdin (read(*,*) or read(0,*))
!
! run the program thus:
!   % echo "a b c" | program
! or
!   % cat file
!    a b c
!   % program < file
! or
!   % program <<EOF
!   a b c
!   EOF
!
! to use from a file, open the file and:
!
!   read(unitnum, "(A256)") line
!   call get_args_from_string(line, wordcount, words)
!
! the limit on the number of words and the length of each string
! is determined by the 'words' character array that is passed in.
! it should have already been allocated by the caller.
!
! handles " " or ' ' quoted strings, and \ escapes the next character.
! for the name=val form, a final & sets a return flag to indicate
! there is a following line that is part of the same context.
!


! 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
!> See the mpi_utilities_mod.f90 documentation for more information on
!> this file.  If you change either file you must make the corresponding
!> changes in the other if it affects a public interface.  They must stay
!> in sync.
!>
!> Substitute this code for mpi_utilities_mod.f90 if you do not want to
!> have to link in an MPI library, and you only want to run single task.
!> Many of the single task DART utility programs use this file instead of
!> the parallel version.  Note that this file has the same module name
!> and the same external entry points as the real mpi_utilities_mod.f90
!> file, so it will link correctly as a replacement file.
!>
!> Programs using this module instead of the actual MPI routines do not
!> need to be compiled with the MPI wrapper commands (e.g. mpif90).
!> In most cases it will be better to compile with the fortran compiler
!> directly.  (On some platforms this is required.)


! 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
!
! Sets whether or not you can have missing values in your state
! vector.  This module is to avoid circular dependencies and can be
! accessed directly by the model_mod.


! 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
!-------------------------------------------------------------------------------


! 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
! This module originally written by I. Grooms and described (briefly)
! in "A Quantile-Conserving Ensemble Filter Based on Kernel-Density Estimation"
! by Grooms & Riedel (Remote Sensing, 2024; DOI:10.3390/rs16132377).


! 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
!> Operations and storage required for various adaptive inflation algorithms


! 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
!
!
!
!!!!!!!!!!!!!!!!!!!!!!  PLEASE READ BEFORE USING  !!!!!!!!!!!!!!!!!!!!!!
!
! This version of assim_tools_mod supports ongoing developments toward a
! localized particle filter (Poterjoy 2016; Poterjoy and Anderson 2016;
! Poterjoy et al. 2019; Poterjoy 2021). It should NOT be used with 'filter
! kind' other than 9 or with any sort of adaptive prior/posterior inflation.
! A breakdown of namelist options specific to the local PF are described
! below. They include options to use a hybrid PF-EAKF update, which performs
! a partial assimilation of observations with the PF followed by a second
! update using the EAKF (Poterjoy 2021). Please contact the developer
! (Jon Poterjoy, poterjoy@umd.edu) before using.
!
!>  A variety of operations required by assimilation.


! 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
! Thanks to Chris Riedel who developed the methods in this module.
! This module only supports standard beta distributions for which the
! lower bound is 0 and the upper bound is 1.


! 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
!> Correct covariances for fixed ensemble sizes.
!> Ref: Anderson, J., 2012:
!> Localization and Sampling Error Correction in Ensemble Kalman Filter Data Assimilation.
!> Mon. Wea. Rev., 140, 2359-2371, doi: 10.1175/MWR-D-11-00013.1.
!> query the needed table sizes, and read in the values for any
!> given ensemble size.  the two arrays of values returned are
!> the true_correl_mean and alpha.


! 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
!------------------------------------------------------------------------------
!> quality_control_mod.f90
!>
!> This module contains routines related to quality control.
!>
!------------------------------------------------------------------------------


! 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
! A variety of PDFs, CDFs, quantile functions and other tools for working with distributions
! to implement quantile conserving filters in observation space and regression in quantile space.


! 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
! This module only supports standard gamma distributions for which the
! lower bound is 0.


! 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
!>  A variety of operations required by assimilation.


! 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
!> This module is used to wrap around the basic portions of existing dynamical models to
!> add capabilities needed by the standard assimilation methods.
!>
!>@todo FIXME explore redundant routines , especially 'diagnostic' ones
!>@todo the documentation for this module is out-of-date.


! 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
!> This program removes duplicate observations.
!> This file contains 1 module and 1 program.  the module code has
!> to come first, so page down for the main program.
!> The module is a custom sort routine needed to compare 2 observations,
!> and then the program uses the sort to match duplicate observations
!> in an obs_seq file.
!> Module:
!> Routine to sort observations at the same time into a consistent order.
!> Obs sequence files are guarenteed to be traversed in time order;
!> running them through the standard obs_sequence_tool will physically
!> order them in the file in the same way a linked-list traversal would.
!>
!> But for multiple obs at the same time there is no way to indicate or
!> control how to order them relative to each other.  This tool sorts
!> same-time obs based on location, then kind, then variance.  If there
!> are duplicate obs in the same file this helps get them together and
!> pass through only one copy of the observation.


! 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
!> Utility to try to sort observations at the same time into a
!> consistent order.  Obs sequence files are guarenteed to be
!> traversed in time order, so running them through the standard
!> obs_sequence_tool will physically order them in the file in
!> the same way a linked-list traversal would.  But for multiple
!> obs at the same time, there is no way to indicate how to order
!> them relative to each other.  This tool tries to sort same-time
!> obs based on location, then kind, then variance.  If there are
!> duplicate obs in the same file, this might be a way to get them
!> together, and possibly add code to remove them.


! 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
!
!----------------------------------------------------------------------
! This module provides support for observations from COSMOS.
! Each COSMOS installation has soil properties that have been measured
! and are needed by the COSMIC algorithm that converts moisture to
! counts of neutron intensity. These properties constitute additional
! metadata for each observation. The routines in this module read and
! write that metadata and provide the 'get_expected_neutron_intensity()'
! routine that is the 'observation operator'
!
!  OBS            1
!           -1           2          -1
! obdef
! loc3d
!      4.188790204786391        0.6986026390077337         137.7093918137252      3
! kind
!            1
! cosmic
!    <an array of 4 parameters>
!    <an array of 4 parameters>
!    <neutron_intensity_key>
!      0          0
!    4.0000000000000000
!----------------------------------------------------------------------
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! COSMOS_NEUTRON_INTENSITY,    QTY_NEUTRON_INTENSITY
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_COSMOS_mod, only : read_cosmos_metadata, &
!                                 write_cosmos_metadata, &
!                           interactive_cosmos_metadata, &
!                          get_expected_neutron_intensity
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!      case(COSMOS_NEUTRON_INTENSITY)
!         call get_expected_neutron_intensity(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(COSMOS_NEUTRON_INTENSITY)
!      call read_cosmos_metadata(obs_def%key, key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(COSMOS_NEUTRON_INTENSITY)
!      call write_cosmos_metadata(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(COSMOS_NEUTRON_INTENSITY)
!      call interactive_cosmos_metadata(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!RADIOSONDE_RELATIVE_HUMIDITY,    QTY_RELATIVE_HUMIDITY
!DROPSONDE_RELATIVE_HUMIDITY,     QTY_RELATIVE_HUMIDITY
!AIRCRAFT_RELATIVE_HUMIDITY,      QTY_RELATIVE_HUMIDITY
!ACARS_RELATIVE_HUMIDITY,         QTY_RELATIVE_HUMIDITY
!MARINE_SFC_RELATIVE_HUMIDITY,    QTY_RELATIVE_HUMIDITY
!LAND_SFC_RELATIVE_HUMIDITY,      QTY_RELATIVE_HUMIDITY
!METAR_RELATIVE_HUMIDITY_2_METER, QTY_RELATIVE_HUMIDITY
!AIRS_RELATIVE_HUMIDITY,          QTY_RELATIVE_HUMIDITY
!MESONET_RELATIVE_HUMIDITY,       QTY_RELATIVE_HUMIDITY
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_rel_humidity_mod, only : get_expected_relative_humidity
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(RADIOSONDE_RELATIVE_HUMIDITY, DROPSONDE_RELATIVE_HUMIDITY, &
!              AIRCRAFT_RELATIVE_HUMIDITY,   ACARS_RELATIVE_HUMIDITY,     &
!              MARINE_SFC_RELATIVE_HUMIDITY, LAND_SFC_RELATIVE_HUMIDITY,  &
!              METAR_RELATIVE_HUMIDITY_2_METER, AIRS_RELATIVE_HUMIDITY, MESONET_RELATIVE_HUMIDITY)
!            call get_expected_relative_humidity(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(RADIOSONDE_RELATIVE_HUMIDITY, DROPSONDE_RELATIVE_HUMIDITY, &
!              AIRCRAFT_RELATIVE_HUMIDITY,   ACARS_RELATIVE_HUMIDITY,     &
!              MARINE_SFC_RELATIVE_HUMIDITY, LAND_SFC_RELATIVE_HUMIDITY,  &
!              METAR_RELATIVE_HUMIDITY_2_METER, AIRS_RELATIVE_HUMIDITY, MESONET_RELATIVE_HUMIDITY)
!            continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(RADIOSONDE_RELATIVE_HUMIDITY, DROPSONDE_RELATIVE_HUMIDITY, &
!              AIRCRAFT_RELATIVE_HUMIDITY,   ACARS_RELATIVE_HUMIDITY,     &
!              MARINE_SFC_RELATIVE_HUMIDITY, LAND_SFC_RELATIVE_HUMIDITY,  &
!              METAR_RELATIVE_HUMIDITY_2_METER, AIRS_RELATIVE_HUMIDITY, MESONET_RELATIVE_HUMIDITY)
!            continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(RADIOSONDE_RELATIVE_HUMIDITY, DROPSONDE_RELATIVE_HUMIDITY, &
!              AIRCRAFT_RELATIVE_HUMIDITY,   ACARS_RELATIVE_HUMIDITY,     &
!              MARINE_SFC_RELATIVE_HUMIDITY, LAND_SFC_RELATIVE_HUMIDITY,  &
!              METAR_RELATIVE_HUMIDITY_2_METER, AIRS_RELATIVE_HUMIDITY, MESONET_RELATIVE_HUMIDITY)
!            continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!-----------------------------------------------------------------------------
!   DART Code:  Johnny Hendricks , hendric at ucar.edu
!   Original DART/Radar work: Nancy Collins
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! DENSITY_ION_E,               QTY_DENSITY_ION_E
! MOLEC_OXYGEN_MIXING_RATIO,   QTY_MOLEC_OXYGEN_MIXING_RATIO
! ATOMIC_OXYGEN_MIXING_RATIO,  QTY_ATOMIC_OXYGEN_MIXING_RATIO
! DENSITY_ION_OP,              QTY_DENSITY_ION_OP
! ION_O_MIXING_RATIO,          QTY_ION_O_MIXING_RATIO
! ATOMIC_H_MIXING_RATIO,       QTY_ATOMIC_H_MIXING_RATIO
! END DART PREPROCESS TYPE DEFINITIONS
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!    use obs_def_ion_density_mod, only : get_expected_oxygen_ion_val
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(DENSITY_ION_OP)
!     call get_expected_oxygen_ion_val(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(DENSITY_ION_E, &
!        MOLEC_OXYGEN_MIXING_RATIO, &
!        ATOMIC_OXYGEN_MIXING_RATIO, &
!        DENSITY_ION_OP, &
!        ION_O_MIXING_RATIO, &
!        ATOMIC_H_MIXING_RATIO)
!      continue
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(DENSITY_ION_E, &
!        MOLEC_OXYGEN_MIXING_RATIO, &
!        ATOMIC_OXYGEN_MIXING_RATIO, &
!        DENSITY_ION_OP, &
!        ION_O_MIXING_RATIO, &
!        ATOMIC_H_MIXING_RATIO)
!      continue
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(DENSITY_ION_E, &
!        MOLEC_OXYGEN_MIXING_RATIO, &
!        ATOMIC_OXYGEN_MIXING_RATIO, &
!        DENSITY_ION_OP, &
!        ION_O_MIXING_RATIO, &
!        ATOMIC_H_MIXING_RATIO)
!      continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
! The obs_def_land_mod.f90 is intended to provide the forward operators
! necessary to convert land surface states to the expected values of the
! observations. Since the meaning of land model variables varies across
! land models, the forward operators here may try multiple approaches.
! The following observation kinds are currently created by the converters
! in the NASA_Earthdata directory. As NASA provides them
!	soil_moisture_x:long_name = "Volumetric Soil Moisture from X-band" ;
!	soil_moisture_x:units = "percent" ;
! CLM soil moisture in the restart files is another beast:
!       H2OSOI_LIQ:long_name = "liquid water" ;
!       H2OSOI_LIQ:units = "kg/m2" ;
! CLM soil moisture in the history files is another beast:
!       H2OSOI:long_name = "liquid water" ;
!       H2OSOI:units = "mm3/mm3" ;
!SMOS_A_SOIL_MOISTURE,         volumetric soil moisture  percent
!SMOS_D_SOIL_MOISTURE,         volumetric soil moisture  percent
!SMAP_A_SOIL_MOISTURE,         volumetric soil moisture  percent
!SMAP_D_SOIL_MOISTURE,         volumetric soil moisture  percent
!SSMI_A_SOIL_MOISTURE,         volumetric soil moisture  percent
!SSMI_D_SOIL_MOISTURE,         volumetric soil moisture  percent
!AMSRE_A_SOIL_MOISTURE_X,      volumetric soil moisture  percent (cvrts to a fraction)
!AMSRE_D_SOIL_MOISTURE_X,      volumetric soil moisture  percent (cvrts to a fraction)
!AMSRE_A_SOIL_MOISTURE_C,      volumetric soil moisture  percent (cvrts to a fraction)
!AMSRE_D_SOIL_MOISTURE_C,      volumetric soil moisture  percent (cvrts to a fraction)
!TRMM_SOIL_MOISTURE,           volumetric soil moisture  percent
!WINDSAT_SOIL_MOISTURE_X,      volumetric soil moisture  percent
!WINDSAT_SOIL_MOISTURE_C,      volumetric soil moisture  percent
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!SOIL_TEMPERATURE,               QTY_SOIL_TEMPERATURE,           COMMON_CODE
!LPRM_SOIL_MOISTURE,             QTY_SOIL_MOISTURE,              COMMON_CODE
!SMOS_A_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!SMOS_D_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!SMAP_A_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!SMAP_D_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!SSMI_A_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!SSMI_D_SOIL_MOISTURE,           QTY_SOIL_MOISTURE,              COMMON_CODE
!AMSRE_A_SOIL_MOISTURE_X,        QTY_SOIL_MOISTURE,              COMMON_CODE
!AMSRE_D_SOIL_MOISTURE_X,        QTY_SOIL_MOISTURE,              COMMON_CODE
!AMSRE_A_SOIL_MOISTURE_C,        QTY_SOIL_MOISTURE,              COMMON_CODE
!AMSRE_D_SOIL_MOISTURE_C,        QTY_SOIL_MOISTURE,              COMMON_CODE
!TRMM_SOIL_MOISTURE,             QTY_SOIL_MOISTURE,              COMMON_CODE
!WINDSAT_SOIL_MOISTURE_X,        QTY_SOIL_MOISTURE,              COMMON_CODE
!WINDSAT_SOIL_MOISTURE_C,        QTY_SOIL_MOISTURE,              COMMON_CODE
!WATER_TABLE_DEPTH,              QTY_WATER_TABLE_DEPTH,          COMMON_CODE
!SOIL_TEMPERATURE,               QTY_SOIL_TEMPERATURE,           COMMON_CODE
!SOIL_MOISTURE,                  QTY_SOIL_MOISTURE,              COMMON_CODE
!LAYER_LIQUID_WATER,             QTY_SOIL_LIQUID_WATER,          COMMON_CODE
!LAYER_ICE,                      QTY_SOIL_ICE,                   COMMON_CODE
!SNOW_THICKNESS,                 QTY_SNOW_THICKNESS,             COMMON_CODE
!SNOW_WATER,                     QTY_SNOW_WATER,                 COMMON_CODE
!MODIS_SNOWCOVER_FRAC,           QTY_SNOWCOVER_FRAC,             COMMON_CODE
!MODIS_LEAF_AREA_INDEX,          QTY_LEAF_AREA_INDEX,            COMMON_CODE
!GIMMS_LEAF_AREA_INDEX,          QTY_LEAF_AREA_INDEX,            COMMON_CODE
!SP_LEAF_AREA_INDEX,             QTY_LEAF_AREA_INDEX,            COMMON_CODE
!SOIL_MINERAL_NITROGEN,          QTY_SOIL_MINERAL_NITROGEN,      COMMON_CODE
!MODIS_FPAR,                     QTY_FRACTION_ABSORBED_PAR
!BIOMASS,                        QTY_BIOMASS
!LEAF_CARBON,                    QTY_LEAF_CARBON,                COMMON_CODE
!LIVE_STEM_CARBON,               QTY_LIVE_STEM_CARBON,           COMMON_CODE
!DEAD_STEM_CARBON,               QTY_DEAD_STEM_CARBON,           COMMON_CODE
!LEAF_AREA_INDEX,                QTY_LEAF_AREA_INDEX,            COMMON_CODE
!LEAF_NITROGEN,                  QTY_LEAF_NITROGEN,              COMMON_CODE
!TOWER_AIR_TEMPERATURE,          QTY_TEMPERATURE,                COMMON_CODE
!TREE_RING_NPP_FLUX,             QTY_NET_PRIMARY_PROD_FLUX,      COMMON_CODE
!TOWER_SOIL_TEMPERATURE,         QTY_TEMPERATURE,                COMMON_CODE
!TOWER_U_WIND_COMPONENT,         QTY_U_WIND_COMPONENT,           COMMON_CODE
!TOWER_V_WIND_COMPONENT,         QTY_V_WIND_COMPONENT,           COMMON_CODE
!TOWER_GLOBAL_RADIATION,         QTY_RADIATION,                  COMMON_CODE
!TOWER_NET_CARBON_FLUX,          QTY_NET_CARBON_FLUX,            COMMON_CODE
!SURFACE_ALBEDO,                 QTY_SURFACE_ALBEDO
!OCO2_SIF,                       QTY_SOLAR_INDUCED_FLUORESCENCE, COMMON_CODE
!ECOSTRESS_ET,                   QTY_LATENT_HEAT_FLUX,           COMMON_CODE
!HARMONIZED_SIF,                 QTY_SOLAR_INDUCED_FLUORESCENCE
! END DART PREPROCESS TYPE DEFINITIONS
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_land_mod, only : calculate_albedo, &
!                               calculate_biomass, &
!                               calculate_fpar, &
!                               calculate_sif, &
!                               read_sif_wavelength, &
!                               write_sif_wavelength, &
!                               interactive_sif_wavelength
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(SURFACE_ALBEDO)
!     call calculate_albedo(state_handle, ens_size, location, expected_obs, istatus)
!  case(BIOMASS)
!     call calculate_biomass(state_handle, ens_size, location, expected_obs, istatus)
!  case(MODIS_FPAR)
!     call calculate_fpar(state_handle, ens_size, location, expected_obs, istatus)
!  case(HARMONIZED_SIF)
!     call calculate_sif(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!    case(SURFACE_ALBEDO, &
!         BIOMASS, &
!         MODIS_FPAR)
!       continue
!    case(HARMONIZED_SIF)
!       call read_SIF_wavelength(obs_def%key, key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!    case(SURFACE_ALBEDO, &
!         BIOMASS, &
!         MODIS_FPAR)
!       continue
!    case(HARMONIZED_SIF)
!       call write_SIF_wavelength(key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!    case(SURFACE_ALBEDO, &
!         BIOMASS, &
!         MODIS_FPAR)
!       continue
!    case(HARMONIZED_SIF)
!       call interactive_SIF_wavelength(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
!>@todo FIXME: check to see if obs are of volume or thickness - for now we
! will assume volume.
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!SYN_SEAICE_CONCENTR,             QTY_SEAICE_CONCENTR,           COMMON_CODE
!SAT_U_SEAICE_COMPONENT,          QTY_U_SEAICE_COMPONENT,        COMMON_CODE
!SAT_V_SEAICE_COMPONENT,          QTY_V_SEAICE_COMPONENT,        COMMON_CODE
!SAT_SEAICE_CONCENTR,             QTY_SEAICE_CONCENTR,           COMMON_CODE
!SAT_SEAICE_VOLUME,               QTY_SEAICE_VOLUME,             COMMON_CODE
!SAT_SEAICE_SNOWVOLUME,           QTY_SEAICE_SNOWVOLUME,         COMMON_CODE
!SAT_SEAICE_SURFACETEMP,          QTY_SEAICE_SURFACETEMP,        COMMON_CODE
!SAT_SEAICE_FY,                   QTY_SEAICE_FY,                 COMMON_CODE
!SAT_SEAICE_AGREG_FY,             QTY_SEAICE_AGREG_FY
!SAT_SEAICE_AGREG_SURFACETEMP,    QTY_SEAICE_AGREG_SURFACETEMP
!SAT_SEAICE_RADAR_FREEBOARD,      QTY_SEAICE_AGREG_FREEBOARD
!SAT_SEAICE_LASER_FREEBOARD,      QTY_SEAICE_AGREG_FREEBOARD
!SAT_SEAICE_AGREG_CONCENTR,       QTY_SEAICE_AGREG_CONCENTR
!SAT_SEAICE_AGREG_VOLUME,         QTY_SEAICE_AGREG_VOLUME
!SAT_SEAICE_AGREG_SNOWVOLUME,     QTY_SEAICE_AGREG_SNOWVOLUME
!SAT_SEAICE_AGREG_THICKNESS,      QTY_SEAICE_AGREG_THICKNESS
!SAT_SEAICE_AGREG_SNOWDEPTH,      QTY_SEAICE_AGREG_SNOWDEPTH
! END DART PREPROCESS TYPE DEFINITIONS
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_cice_mod, only : get_expected_agreg_freeboard, &
!                               get_expected_agreg_over_grid, &
!                               get_expected_agreg_over_ice,  &
!                               get_expected_agreg_thickness
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!   case(SAT_SEAICE_RADAR_FREEBOARD)
!      call get_expected_agreg_freeboard(state_handle, ens_size, location, &
!               obs_kind_ind, expected_obs, istatus)
!   case(SAT_SEAICE_LASER_FREEBOARD)
!      call get_expected_agreg_freeboard(state_handle, ens_size, location, &
!               obs_kind_ind, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_THICKNESS)
!      call get_expected_agreg_thickness(state_handle, ens_size, location, &
!               QTY_SEAICE_VOLUME, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_SNOWDEPTH)
!      call get_expected_agreg_thickness(state_handle, ens_size, location, &
!               QTY_SEAICE_SNOWVOLUME, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_CONCENTR)
!      call get_expected_agreg_over_grid(state_handle, ens_size, location, &
!               QTY_SEAICE_CONCENTR, expected_obs,istatus)
!   case(SAT_SEAICE_AGREG_VOLUME)
!      call get_expected_agreg_over_grid(state_handle, ens_size, location, &
!               QTY_SEAICE_VOLUME, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_SNOWVOLUME)
!      call get_expected_agreg_over_grid(state_handle, ens_size, location, &
!               QTY_SEAICE_SNOWVOLUME, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_SURFACETEMP)
!      call get_expected_agreg_over_ice(state_handle, ens_size, location, &
!               QTY_SEAICE_SURFACETEMP, expected_obs, istatus)
!   case(SAT_SEAICE_AGREG_FY)
!      call get_expected_agreg_over_ice(state_handle, ens_size, location, &
!               QTY_SEAICE_FY, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!    case(SAT_SEAICE_LASER_FREEBOARD,   &
!         SAT_SEAICE_RADAR_FREEBOARD,   &
!         SAT_SEAICE_AGREG_THICKNESS,   &
!         SAT_SEAICE_AGREG_SNOWDEPTH,   &
!         SAT_SEAICE_AGREG_CONCENTR,    &
!         SAT_SEAICE_AGREG_VOLUME,      &
!         SAT_SEAICE_AGREG_SNOWVOLUME,  &
!         SAT_SEAICE_AGREG_SURFACETEMP, &
!         SAT_SEAICE_AGREG_FY)
!       continue
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!    case(SAT_SEAICE_LASER_FREEBOARD,   &
!         SAT_SEAICE_RADAR_FREEBOARD,   &
!         SAT_SEAICE_AGREG_THICKNESS,   &
!         SAT_SEAICE_AGREG_SNOWDEPTH,   &
!         SAT_SEAICE_AGREG_CONCENTR,    &
!         SAT_SEAICE_AGREG_VOLUME,      &
!         SAT_SEAICE_AGREG_SNOWVOLUME,  &
!         SAT_SEAICE_AGREG_SURFACETEMP, &
!         SAT_SEAICE_AGREG_FY)
!       continue
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!    case(SAT_SEAICE_LASER_FREEBOARD,   &
!         SAT_SEAICE_RADAR_FREEBOARD,   &
!         SAT_SEAICE_AGREG_THICKNESS,   &
!         SAT_SEAICE_AGREG_SNOWDEPTH,   &
!         SAT_SEAICE_AGREG_CONCENTR,    &
!         SAT_SEAICE_AGREG_VOLUME,      &
!         SAT_SEAICE_AGREG_SNOWVOLUME,  &
!         SAT_SEAICE_AGREG_SURFACETEMP, &
!         SAT_SEAICE_AGREG_FY)
!       continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! MOPITT_CO_RETRIEVAL, QTY_CO
! IASI_CO_RETRIEVAL, QTY_CO
! GEO_CO_ASI, QTY_CO
! GEO_CO_NAM, QTY_CO
! GEO_CO_EUR, QTY_CO
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_mopitt_mod, only : write_mopitt_co, read_mopitt_co, &
!                                  interactive_mopitt_co, get_expected_mopitt_co, &
!                                  set_obs_def_mopitt_co, get_expected_iasi_co
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(MOPITT_CO_RETRIEVAL)
!            call get_expected_mopitt_co(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!         case(IASI_CO_RETRIEVAL)
!            call get_expected_iasi_co(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!         case(GEO_CO_ASI)
!            call get_expected_mopitt_co(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!         case(GEO_CO_NAM)
!            call get_expected_mopitt_co(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!         case(GEO_CO_EUR)
!            call get_expected_mopitt_co(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!      case(MOPITT_CO_RETRIEVAL, IASI_CO_RETRIEVAL, GEO_CO_ASI, GEO_CO_NAM, GEO_CO_EUR)
!         call read_mopitt_co(obs_def%key, ifile, fileformat)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!      case(MOPITT_CO_RETRIEVAL, IASI_CO_RETRIEVAL, GEO_CO_ASI, GEO_CO_NAM, GEO_CO_EUR)
!         call write_mopitt_co(obs_def%key, ifile, fileformat)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!      case(MOPITT_CO_RETRIEVAL, IASI_CO_RETRIEVAL, GEO_CO_ASI, GEO_CO_NAM, GEO_CO_EUR)
!         call interactive_mopitt_co(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS SET_OBS_DEF_MOPITT_CO
!      case(MOPITT_CO_RETRIEVAL, IASI_CO_RETRIEVAL, GEO_CO_ASI, GEO_CO_NAM, GEO_CO_EUR)
!         call set_obs_def_mopitt_co(obs_def%key)
! END DART PREPROCESS SET_OBS_DEF_MOPITT_CO
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! Note:  This version has a namelist item for the max number of
! gps observations that can be read in, but it is currently commented out.
! Search below for the 'NAMELIST' string to find where to comment the
! code back in.  There are 2 places.  This maximum must be the total of
! all gps obs in all input files, which if you are reading multiple obs_seq
! files (e.g. for the obs_diag program) might be a larger number than 100K.
!>@todo we should have a local vs nonlocal forward operator for GPS RO,
!>so we don't have to add the metadata for the local operator.  big space
!>and time savings.  also, we should add GPSRO_BENDING_ANGLE if someone
!>can contribute a forward operator for it.
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! TEMPERATURE,             QTY_TEMPERATURE,        COMMON_CODE
! SPECIFIC_HUMIDITY,       QTY_SPECIFIC_HUMIDITY,  COMMON_CODE
! PRESSURE,                QTY_PRESSURE,           COMMON_CODE
! GPSRO_REFRACTIVITY,      QTY_GPSRO
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_gps_mod, only : get_expected_gpsro_ref, interactive_gpsro_ref, &
!                              read_gpsro_ref, write_gpsro_ref
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(GPSRO_REFRACTIVITY)
!            call get_expected_gpsro_ref(state_handle, ens_size,  location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(GPSRO_REFRACTIVITY)
!            call read_gpsro_ref(obs_def%key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(GPSRO_REFRACTIVITY)
!            call write_gpsro_ref(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(GPSRO_REFRACTIVITY)
!            call interactive_gpsro_ref(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! Fortran has a limit of 32 characters for variable names. Hence,
! each column can be at most 32 characters wide.
! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! SAT_TEMPERATURE,                 QTY_TEMPERATURE,                COMMON_CODE
! SAT_TEMPERATURE_ELECTRON,        QTY_TEMPERATURE_ELECTRON,       COMMON_CODE
! SAT_TEMPERATURE_ION,             QTY_TEMPERATURE_ION,            COMMON_CODE
! SAT_DENSITY_NEUTRAL_O3P,         QTY_DENSITY_NEUTRAL_O3P,        COMMON_CODE
! SAT_DENSITY_NEUTRAL_O2,          QTY_DENSITY_NEUTRAL_O2,         COMMON_CODE
! SAT_DENSITY_NEUTRAL_N2,          QTY_DENSITY_NEUTRAL_N2,         COMMON_CODE
! SAT_DENSITY_NEUTRAL_N4S,         QTY_DENSITY_NEUTRAL_N4S,        COMMON_CODE
! SAT_DENSITY_NEUTRAL_NO,          QTY_DENSITY_NEUTRAL_NO,         COMMON_CODE
! SAT_DENSITY_NEUTRAL_N2D,         QTY_DENSITY_NEUTRAL_N2D,        COMMON_CODE
! SAT_DENSITY_NEUTRAL_N2P,         QTY_DENSITY_NEUTRAL_N2P,        COMMON_CODE
! SAT_DENSITY_NEUTRAL_H,           QTY_DENSITY_NEUTRAL_H,          COMMON_CODE
! SAT_DENSITY_NEUTRAL_HE,          QTY_DENSITY_NEUTRAL_HE,         COMMON_CODE
! SAT_DENSITY_NEUTRAL_CO2,         QTY_DENSITY_NEUTRAL_CO2,        COMMON_CODE
! SAT_DENSITY_NEUTRAL_O1D,         QTY_DENSITY_NEUTRAL_O1D,        COMMON_CODE
! SAT_DENSITY_ION_O4SP,            QTY_DENSITY_ION_O4SP,           COMMON_CODE
! SAT_DENSITY_ION_O2P,             QTY_DENSITY_ION_O2P,            COMMON_CODE
! SAT_DENSITY_ION_N2P,             QTY_DENSITY_ION_N2P,            COMMON_CODE
! SAT_DENSITY_ION_NP,              QTY_DENSITY_ION_NP,             COMMON_CODE
! SAT_DENSITY_ION_NOP,             QTY_DENSITY_ION_NOP,            COMMON_CODE
! SAT_DENSITY_ION_O2DP,            QTY_DENSITY_ION_O2DP,           COMMON_CODE
! SAT_DENSITY_ION_O2PP,            QTY_DENSITY_ION_O2PP,           COMMON_CODE
! SAT_DENSITY_ION_HP,              QTY_DENSITY_ION_HP,             COMMON_CODE
! SAT_DENSITY_ION_HEP,             QTY_DENSITY_ION_HEP,            COMMON_CODE
! SAT_DENSITY_ION_E,               QTY_DENSITY_ION_E,              COMMON_CODE
! SAT_VELOCITY_U,                  QTY_VELOCITY_U,                 COMMON_CODE
! SAT_VELOCITY_V,                  QTY_VELOCITY_V,                 COMMON_CODE
! SAT_VELOCITY_W,                  QTY_VELOCITY_W,                 COMMON_CODE
! SAT_VELOCITY_U_ION,              QTY_VELOCITY_U_ION,             COMMON_CODE
! SAT_VELOCITY_V_ION,              QTY_VELOCITY_V_ION,             COMMON_CODE
! SAT_VELOCITY_W_ION,              QTY_VELOCITY_W_ION,             COMMON_CODE
! SAT_VELOCITY_VERTICAL_O3P,       QTY_VELOCITY_VERTICAL_O3P,      COMMON_CODE
! SAT_VELOCITY_VERTICAL_O2,        QTY_VELOCITY_VERTICAL_O2,       COMMON_CODE
! SAT_VELOCITY_VERTICAL_N2,        QTY_VELOCITY_VERTICAL_N2,       COMMON_CODE
! SAT_VELOCITY_VERTICAL_N4S,       QTY_VELOCITY_VERTICAL_N4S,      COMMON_CODE
! SAT_VELOCITY_VERTICAL_NO,        QTY_VELOCITY_VERTICAL_NO,       COMMON_CODE
! SAT_F107,                        QTY_1D_PARAMETER,               COMMON_CODE
! SAT_RHO,                         QTY_DENSITY
! GPS_PROFILE,                     QTY_ELECTRON_DENSITY,           COMMON_CODE
! COSMIC_ELECTRON_DENSITY,         QTY_ELECTRON_DENSITY
! GND_GPS_VTEC,		           QTY_GND_GPS_VTEC
! CHAMP_DENSITY,                   QTY_DENSITY
! MIDAS_TEC,                       QTY_VERTICAL_TEC,               COMMON_CODE
! SSUSI_O_N2_RATIO,                QTY_O_N2_COLUMN_DENSITY_RATIO
! GPS_VTEC_EXTRAP,                 QTY_VERTICAL_TEC,               COMMON_CODE
! SABER_TEMPERATURE,               QTY_TEMPERATURE,                COMMON_CODE
! AURAMLS_TEMPERATURE,             QTY_TEMPERATURE,                COMMON_CODE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_upper_atm_mod, only : get_expected_upper_atm_density
!  use obs_def_upper_atm_mod, only : get_expected_gnd_gps_vtec
!  use obs_def_upper_atm_mod, only : get_expected_O_N2_ratio
!  use obs_def_upper_atm_mod, only : get_expected_electron_density
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! case(SAT_RHO)
!      call get_expected_upper_atm_density(state_handle, ens_size, location, expected_obs, istatus)
! case(CHAMP_DENSITY)
!      call get_expected_upper_atm_density(state_handle, ens_size, location, expected_obs, istatus)
! case(GND_GPS_VTEC)
!      call get_expected_gnd_gps_vtec(state_handle, ens_size, location, expected_obs, istatus)
! case(SSUSI_O_N2_RATIO)
!      call get_expected_O_N2_ratio(state_handle, ens_size, location, expected_obs, istatus)
! case(COSMIC_ELECTRON_DENSITY)
!      call get_expected_electron_density(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
! case(SAT_RHO)
!      continue
! case(CHAMP_DENSITY)
!      continue
! case(GND_GPS_VTEC)
!      continue
! case(SSUSI_O_N2_RATIO)
!      continue
! case(COSMIC_ELECTRON_DENSITY)
!      continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
! case(SAT_RHO)
!      continue
! case(CHAMP_DENSITY)
!      continue
! case(GND_GPS_VTEC)
!      continue
! case(SSUSI_O_N2_RATIO)
!      continue
! case(COSMIC_ELECTRON_DENSITY)
!      continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
! case(SAT_RHO)
!      continue
! case(CHAMP_DENSITY)
!      continue
! case(GND_GPS_VTEC)
!      continue
! case(SSUSI_O_N2_RATIO)
!      continue
! case(COSMIC_ELECTRON_DENSITY)
!      continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!   MPD_ABSOLUTE_HUMIDITY,    QTY_ABSOLUTE_HUMIDITY
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_abs_humidity_mod, only : get_expected_absolute_humidity
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(MPD_ABSOLUTE_HUMIDITY)
!            call get_expected_absolute_humidity(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(MPD_ABSOLUTE_HUMIDITY)
!            continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(MPD_ABSOLUTE_HUMIDITY)
!            continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(MPD_ABSOLUTE_HUMIDITY)
!            continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! SALINITY,                      QTY_SALINITY,              COMMON_CODE
! TEMPERATURE,                   QTY_TEMPERATURE,           COMMON_CODE
! U_CURRENT_COMPONENT,           QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! V_CURRENT_COMPONENT,           QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! SEA_SURFACE_HEIGHT,            QTY_SEA_SURFACE_HEIGHT,    COMMON_CODE
! SEA_SURFACE_PRESSURE,          QTY_SEA_SURFACE_PRESSURE,  COMMON_CODE
! ARGO_U_CURRENT_COMPONENT,      QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! ARGO_V_CURRENT_COMPONENT,      QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! ARGO_SALINITY,                 QTY_SALINITY,              COMMON_CODE
! ARGO_TEMPERATURE,              QTY_TEMPERATURE,           COMMON_CODE
! ADCP_U_CURRENT_COMPONENT,      QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! ADCP_V_CURRENT_COMPONENT,      QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! ADCP_SALINITY,                 QTY_SALINITY,              COMMON_CODE
! ADCP_TEMPERATURE,              QTY_TEMPERATURE,           COMMON_CODE
! FLOAT_SALINITY,                QTY_SALINITY,              COMMON_CODE
! FLOAT_TEMPERATURE,             QTY_TEMPERATURE,           COMMON_CODE
! DRIFTER_U_CURRENT_COMPONENT,   QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! DRIFTER_V_CURRENT_COMPONENT,   QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! DRIFTER_SALINITY,              QTY_SALINITY,              COMMON_CODE
! DRIFTER_TEMPERATURE,           QTY_TEMPERATURE,           COMMON_CODE
! GLIDER_U_CURRENT_COMPONENT,    QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! GLIDER_V_CURRENT_COMPONENT,    QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! GLIDER_SALINITY,               QTY_SALINITY,              COMMON_CODE
! GLIDER_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
! MOORING_U_CURRENT_COMPONENT,   QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! MOORING_V_CURRENT_COMPONENT,   QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! MOORING_SALINITY,              QTY_SALINITY,              COMMON_CODE
! MOORING_TEMPERATURE,           QTY_TEMPERATURE,           COMMON_CODE
! MOORING_PRESSURE,              QTY_PRESSURE,              COMMON_CODE
! BOTTLE_SALINITY,               QTY_SALINITY,              COMMON_CODE
! BOTTLE_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
! CTD_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! CTD_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! TCTD_SALINITY,                 QTY_SALINITY,              COMMON_CODE
! TCTD_TEMPERATURE,              QTY_TEMPERATURE,           COMMON_CODE
! STD_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! STD_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! XCTD_SALINITY,                 QTY_SALINITY,              COMMON_CODE
! XCTD_TEMPERATURE,              QTY_TEMPERATURE,           COMMON_CODE
! MBT_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! MBT_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! XBT_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! XBT_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! DBT_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! DBT_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! APB_SALINITY,                  QTY_SALINITY,              COMMON_CODE
! APB_TEMPERATURE,               QTY_TEMPERATURE,           COMMON_CODE
! DOPPLER_U_CURRENT_COMPONENT,   QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! DOPPLER_V_CURRENT_COMPONENT,   QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! DOPPLER_W_CURRENT_COMPONENT,   QTY_W_CURRENT_COMPONENT,   COMMON_CODE
! SATELLITE_MICROWAVE_SST,       QTY_TEMPERATURE,           COMMON_CODE
! SATELLITE_INFRARED_SST,        QTY_TEMPERATURE,           COMMON_CODE
! SATELLITE_BLENDED_SST,         QTY_TEMPERATURE,           COMMON_CODE
! SATELLITE_SSH,                 QTY_SEA_SURFACE_HEIGHT,    COMMON_CODE
! SATELLITE_SSS,                 QTY_SALINITY,              COMMON_CODE
! J1_SEA_SURFACE_ANOMALY,        QTY_SEA_SURFACE_ANOMALY,   COMMON_CODE
! EN_SEA_SURFACE_ANOMALY,        QTY_SEA_SURFACE_ANOMALY,   COMMON_CODE
! GFO_SEA_SURFACE_ANOMALY,       QTY_SEA_SURFACE_ANOMALY,   COMMON_CODE
! DRY_LAND,                      QTY_DRY_LAND,              COMMON_CODE
! OI_SEA_SURFACE_TEMPERATURE,    QTY_TEMPERATURE,           COMMON_CODE
! HFRADAR_U_CURRENT_COMPONENT,   QTY_U_CURRENT_COMPONENT,   COMMON_CODE
! HFRADAR_V_CURRENT_COMPONENT,   QTY_V_CURRENT_COMPONENT,   COMMON_CODE
! HFRADAR_RADIAL_VELOCITY,       QTY_VELOCITY
! FERRYBOX_SALINITY,             QTY_SALINITY,              COMMON_CODE
! FERRYBOX_TEMPERATURE,          QTY_TEMPERATURE,           COMMON_CODE
! OCEAN_COLOR,                   QTY_SURFACE_CHLOROPHYLL,   COMMON_CODE
! BATS_OXYGEN,                   QTY_DISSOLVED_OXYGEN,             COMMON_CODE
! BATS_ALKALINITY,               QTY_ALKALINITY,                   COMMON_CODE
! BATS_ORGANIC_CARBON,           QTY_DISSOLVED_ORGANIC_CARBON,     COMMON_CODE
! BATS_INORGANIC_CARBON,         QTY_DISSOLVED_INORGANIC_CARBON,   COMMON_CODE
! BATS_NITROGEN,                 QTY_DISSOLVED_ORGANIC_NITROGEN,   COMMON_CODE
! BATS_NITRATE,                  QTY_NITRATE_CONCENTRATION,        COMMON_CODE
! BATS_SILICATE,                 QTY_DISSOLVED_INORGANIC_SIO3,     COMMON_CODE
! BATS_PHOSPHATE,                QTY_PHOSPHATE_CONCENTRATION,      COMMON_CODE
! END DART PREPROCESS TYPE DEFINITIONS
! From Ibrahim - 19 May 2009
! "Concerning the radar observations: we can use a format very similar to what we
! have been using for all the other types of observations:
!
!LAT LON DEPTH ANGLE OBS_value Z_LOC ERR_obs QC_flag TYPE_obs STARTDATE1 STARTDATE2
!
! where here we only add "ANGLE": the angle of the radial observation.
!
! Now what we need is to compute the radial velocity R_model from the state vector
! (which already contains the horizontal velocities U and V) using
!
! 'OBS_value' = U*cos(angle) + V*sin(angle)
!
! The angles are in degrees (0 from the east) and the observations in m/s.
! so to compute 'OBS_value' we need to read the observation file to get the ANGLE,
! and that's basically the only difference with the assimilation of the other
! types of observations. We also need to introduce the new obs type
! (HFRADAR_RADIAL_VELOCITY)."
! changed all occurences of xxx_radial_vel to xxx_hf_radial_vel (for high
! frequency) since otherwise the external names here collide with those
! external names in the radar module (for weather radars, e.g. nexrad).  nsc.
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_ocean_mod, only : write_hf_radial_vel, read_hf_radial_vel,           &
!                            interactive_hf_radial_vel, get_expected_hf_radial_vel
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(HFRADAR_RADIAL_VELOCITY)
!     call get_expected_hf_radial_vel(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(HFRADAR_RADIAL_VELOCITY)
!      call read_hf_radial_vel(obs_def%key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(HFRADAR_RADIAL_VELOCITY)
!      call write_hf_radial_vel(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(HFRADAR_RADIAL_VELOCITY)
!      call interactive_hf_radial_vel(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!BUOY_U_WIND_COMPONENT,        QTY_U_WIND_COMPONENT,      COMMON_CODE
!BUOY_V_WIND_COMPONENT,        QTY_V_WIND_COMPONENT,      COMMON_CODE
!BUOY_SURFACE_PRESSURE,        QTY_SURFACE_PRESSURE,      COMMON_CODE
!BUOY_TEMPERATURE,             QTY_TEMPERATURE,           COMMON_CODE
!SHIP_U_WIND_COMPONENT,        QTY_U_WIND_COMPONENT,      COMMON_CODE
!SHIP_V_WIND_COMPONENT,        QTY_V_WIND_COMPONENT,      COMMON_CODE
!SHIP_SURFACE_PRESSURE,        QTY_SURFACE_PRESSURE,      COMMON_CODE
!SHIP_TEMPERATURE,             QTY_TEMPERATURE,           COMMON_CODE
!SYNOP_U_WIND_COMPONENT,       QTY_U_WIND_COMPONENT,      COMMON_CODE
!SYNOP_V_WIND_COMPONENT,       QTY_V_WIND_COMPONENT,      COMMON_CODE
!SYNOP_SURFACE_PRESSURE,       QTY_SURFACE_PRESSURE,      COMMON_CODE
!SYNOP_SPECIFIC_HUMIDITY,      QTY_SPECIFIC_HUMIDITY,     COMMON_CODE
!SYNOP_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
!AIREP_U_WIND_COMPONENT,       QTY_U_WIND_COMPONENT,      COMMON_CODE
!AIREP_V_WIND_COMPONENT,       QTY_V_WIND_COMPONENT,      COMMON_CODE
!AIREP_PRESSURE,               QTY_PRESSURE,              COMMON_CODE
!AIREP_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
!AMDAR_U_WIND_COMPONENT,       QTY_U_WIND_COMPONENT,      COMMON_CODE
!AMDAR_V_WIND_COMPONENT,       QTY_V_WIND_COMPONENT,      COMMON_CODE
!AMDAR_PRESSURE,               QTY_PRESSURE,              COMMON_CODE
!AMDAR_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
!PILOT_U_WIND_COMPONENT,       QTY_U_WIND_COMPONENT,      COMMON_CODE
!PILOT_V_WIND_COMPONENT,       QTY_V_WIND_COMPONENT,      COMMON_CODE
!PILOT_PRESSURE,               QTY_PRESSURE,              COMMON_CODE
!PILOT_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
!BOGUS_U_WIND_COMPONENT,       QTY_U_WIND_COMPONENT,      COMMON_CODE
!BOGUS_V_WIND_COMPONENT,       QTY_V_WIND_COMPONENT,      COMMON_CODE
!BOGUS_PRESSURE,               QTY_PRESSURE,              COMMON_CODE
!BOGUS_TEMPERATURE,            QTY_TEMPERATURE,           COMMON_CODE
!PROFILER_U_WIND_COMPONENT,    QTY_U_WIND_COMPONENT,      COMMON_CODE
!PROFILER_V_WIND_COMPONENT,    QTY_V_WIND_COMPONENT,      COMMON_CODE
!PROFILER_PRESSURE,            QTY_PRESSURE,              COMMON_CODE
!SATEM_THICKNESS,              QTY_TEMPERATURE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_gts_mod, only : get_expected_thickness
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(SATEM_THICKNESS)
!            call get_expected_thickness(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
! case(SATEM_THICKNESS)
!      continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
! case(SATEM_THICKNESS)
!      continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
! case(SATEM_THICKNESS)
!      continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!TOWER_AIR_TEMPERATURE,          QTY_TEMPERATURE,              COMMON_CODE
!TOWER_GLOBAL_RADIATION,         QTY_RADIATION,                COMMON_CODE
!TOWER_NET_CARBON_FLUX,          QTY_NET_CARBON_FLUX,          COMMON_CODE
!TOWER_SOIL_TEMPERATURE,         QTY_TEMPERATURE,              COMMON_CODE
!TOWER_U_WIND_COMPONENT,         QTY_U_WIND_COMPONENT,         COMMON_CODE
!TOWER_V_WIND_COMPONENT,         QTY_V_WIND_COMPONENT,         COMMON_CODE
!SOIL_RESPIRATION_FLUX,          QTY_SOIL_RESPIRATION_FLUX
!TOWER_ER_FLUX,                  QTY_ER_FLUX
!TOWER_GPP_FLUX,                 QTY_GROSS_PRIMARY_PROD_FLUX
!TOWER_LATENT_HEAT_FLUX,         QTY_LATENT_HEAT_FLUX
!TOWER_NETC_ECO_EXCHANGE,        QTY_NET_CARBON_PRODUCTION
!TOWER_SENSIBLE_HEAT_FLUX,       QTY_SENSIBLE_HEAT_FLUX
! END DART PREPROCESS TYPE DEFINITIONS
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_tower_mod, only : get_scalar_from_history
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(TOWER_LATENT_HEAT_FLUX)
!     call get_scalar_from_history('EFLX_LH_TOT_R', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
!  case(TOWER_SENSIBLE_HEAT_FLUX)
!     call get_scalar_from_history('FSH', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
!  case(TOWER_NETC_ECO_EXCHANGE)
!     call get_scalar_from_history('NEP', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
!  case(TOWER_GPP_FLUX)
!     call get_scalar_from_history('GPP', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
!  case(TOWER_ER_FLUX)
!     call get_scalar_from_history('ER', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
!  case(SOIL_RESPIRATION_FLUX)
!     call get_scalar_from_history('SR', state_handle, ens_size, &
!                    copy_indices, location, obs_time, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!    case(TOWER_LATENT_HEAT_FLUX, &
!         TOWER_SENSIBLE_HEAT_FLUX, &
!         TOWER_NETC_ECO_EXCHANGE, &
!         TOWER_GPP_FLUX, &
!         TOWER_ER_FLUX, &
!         SOIL_RESPIRATION_FLUX)
!       continue
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!    case(TOWER_LATENT_HEAT_FLUX, &
!         TOWER_SENSIBLE_HEAT_FLUX, &
!         TOWER_NETC_ECO_EXCHANGE, &
!         TOWER_GPP_FLUX, &
!         TOWER_ER_FLUX, &
!         SOIL_RESPIRATION_FLUX)
!       continue
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!    case(TOWER_LATENT_HEAT_FLUX, &
!         TOWER_SENSIBLE_HEAT_FLUX, &
!         TOWER_NETC_ECO_EXCHANGE, &
!         TOWER_GPP_FLUX, &
!         TOWER_ER_FLUX, &
!         SOIL_RESPIRATION_FLUX)
!       continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! This is for the GRACE total water storage observation operator.
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! WATER_UNCONFINED_AQUIFER,   QTY_LIQUID_WATER,        COMMON_CODE
! GRACE_TOTAL_WATER_STORAGE,  QTY_TOTAL_WATER_STORAGE
! END DART PREPROCESS TYPE DEFINITIONS
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! use obs_def_GRACE_mod, only: get_expected_TWS
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! case(GRACE_TOTAL_WATER_STORAGE)
! call get_expected_TWS(state_handle, ens_size, location, &
!                       obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!    case(GRACE_TOTAL_WATER_STORAGE)
!       continue
! END DART PREPROCESS READ_OBS_DEF
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!    case(GRACE_TOTAL_WATER_STORAGE)
!       continue
! END DART PREPROCESS WRITE_OBS_DEF
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!    case(GRACE_TOTAL_WATER_STORAGE)
!       continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
!>@todo  make a namelist-defined grid (lower left corner, nx, ny, dx, dy)
!> allocate, call interp for t, u, v, p and fill it.  store the location
!> of the obs being interpolated.  compute the values.  wait for subsequent
!> calls for this same location.
!>
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! VORTEX_LAT, QTY_VORTEX_LAT
! VORTEX_LON, QTY_VORTEX_LON
! VORTEX_PMIN, QTY_VORTEX_PMIN
! VORTEX_WMAX, QTY_VORTEX_WMAX
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_vortex_mod, only : get_expected_vortex_info
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(VORTEX_LAT)
!            call get_expected_vortex_info(state_handle, ens_size, location, 'lat', expected_obs, istatus)
!         case(VORTEX_LON)
!            call get_expected_vortex_info(state_handle, ens_size, location, 'lon', expected_obs, istatus)
!         case(VORTEX_PMIN)
!            call get_expected_vortex_info(state_handle, ens_size, location, 'pmi', expected_obs, istatus)
!         case(VORTEX_WMAX)
!            call get_expected_vortex_info(state_handle, ens_size, location, 'wma', expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!      case(VORTEX_LAT)
!         continue
!      case(VORTEX_LON)
!         continue
!      case(VORTEX_PMIN)
!         continue
!      case(VORTEX_WMAX)
!         continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!      case(VORTEX_LAT)
!         continue
!      case(VORTEX_LON)
!         continue
!      case(VORTEX_PMIN)
!         continue
!      case(VORTEX_WMAX)
!         continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!      case(VORTEX_LAT)
!         continue
!      case(VORTEX_LON)
!         continue
!      case(VORTEX_PMIN)
!         continue
!      case(VORTEX_WMAX)
!         continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
!----------------------------------------------------------------------
!> Utilities that can be used by any of the obs_def_xxx_mods.
!> In a separate module to obs_def_mod to avoid a circular dependency.


! 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
!
!-----------------------------------------------------------------------------
! DART radar observation module, including the observation operators for the
! two primary radar-observation types -- Doppler velocity and reflectivity --
! plus other utility subroutines and functions.  A number of simplifications
! are employed for the observation operators.  Most notably, the model state
! is mapped to a "point" observation, whereas a real radar observation is a
! volumetric sample.  The implications of this approximation have not been
! investigated fully, so in the future it might be worth developing and testing
! more sophisticated observation operators that produce volumetric power-
! weighted samples.
!
! This module is able to compute reflectivity and precipitation fall speed
! (needed for computing Doppler radial velocity) from the prognostic model
! fields only for simple single-moment microphysics schemes such as the Kessler
! and Lin schemes.  If a more complicated microphysics scheme is used, then
! reflectivity and fall speed must be accessible instead as diagnostic fields
! in the model state.
!
! Author and Contact information:
!   Radar Science:  David Dowell, ddowell at ucar.edu
!   DART Code:  Nancy Collins, nancy at ucar.edu
!   Original DART/Radar work:  Alain Caya
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! DOPPLER_RADIAL_VELOCITY, QTY_VELOCITY
! RADAR_REFLECTIVITY, QTY_RADAR_REFLECTIVITY
! RADAR_CLEARAIR_REFLECTIVITY, QTY_RADAR_REFLECTIVITY
! PRECIPITATION_FALL_SPEED, QTY_POWER_WEIGHTED_FALL_SPEED
! END DART PREPROCESS TYPE DEFINITIONS
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_radar_mod, only : write_radial_vel, read_radial_vel,           &
!                            interactive_radial_vel, get_expected_radial_vel, &
!                            read_radar_ref, get_expected_radar_ref,          &
!                            get_expected_fall_velocity
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(DOPPLER_RADIAL_VELOCITY)
!     call get_expected_radial_vel(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!  case(RADAR_REFLECTIVITY)
!     call get_expected_radar_ref(state_handle, ens_size, location, expected_obs, istatus)
!  case(RADAR_CLEARAIR_REFLECTIVITY)
!     call get_expected_radar_ref(state_handle, ens_size, location, expected_obs, istatus)
!  case(PRECIPITATION_FALL_SPEED)
!     call get_expected_fall_velocity(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(DOPPLER_RADIAL_VELOCITY)
!      call read_radial_vel(obs_def%key, ifile, fform)
!   case(RADAR_REFLECTIVITY)
!      call read_radar_ref(obs_val, obs_def%key)
!  case(RADAR_CLEARAIR_REFLECTIVITY)
!      call read_radar_ref(obs_val, obs_def%key)
!   case(PRECIPITATION_FALL_SPEED)
!      continue
! END DART PREPROCESS READ_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(DOPPLER_RADIAL_VELOCITY)
!      call write_radial_vel(obs_def%key, ifile, fform)
!   case(RADAR_REFLECTIVITY)
!      continue
!   case(RADAR_CLEARAIR_REFLECTIVITY)
!      continue
!   case(PRECIPITATION_FALL_SPEED)
!      continue
! END DART PREPROCESS WRITE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(DOPPLER_RADIAL_VELOCITY)
!      call interactive_radial_vel(obs_def%key)
!   case(RADAR_REFLECTIVITY)
!      continue
!   case(PRECIPITATION_FALL_SPEED)
!      continue
!   case(RADAR_CLEARAIR_REFLECTIVITY)
!      continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! Forward operator to compute total precipitable water in a column,
! in centimeters, over the ocean.   Can be used as an example of a
! forward operator that loops over either fixed pressure levels or
! over model levels.
! This code is only correct for TPW over the ocean where the surface
! is at 0m elevation.  For TWP over land you must be able to compute
! the surface elevation for any given lat/lon location.  This code
! assumes the model can return the surface pressure for any given
! lat/lon location, and the specific humidity for a given location
! where the vertical is either pressure or model levels.
! keep in mind that fortran allows only 31 characters in parameter
! definitions (which is what this string is going to be used for).
! if the platform name gets longer than 5 chars, consider going
! to something like xxx_TOTAL_PRECIP_WATER to give you room to
! put in more descriptive platform names.
! BEGIN DART PREPROCESS TYPE DEFINITIONS
!  AQUA_TOTAL_PRECIPITABLE_WATER, QTY_TOTAL_PRECIPITABLE_WATER
! TERRA_TOTAL_PRECIPITABLE_WATER, QTY_TOTAL_PRECIPITABLE_WATER
!  AMSR_TOTAL_PRECIPITABLE_WATER, QTY_TOTAL_PRECIPITABLE_WATER
! MODIS_TOTAL_PRECIPITABLE_WATER, QTY_TOTAL_PRECIPITABLE_WATER
!   GPS_TOTAL_PRECIPITABLE_WATER, QTY_TOTAL_PRECIPITABLE_WATER
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_tpw_mod, only : get_expected_tpw
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(AQUA_TOTAL_PRECIPITABLE_WATER,TERRA_TOTAL_PRECIPITABLE_WATER,GPS_TOTAL_PRECIPITABLE_WATER)
!            call get_expected_tpw(state_handle, ens_size, location, expected_obs, istatus)
!         case(AMSR_TOTAL_PRECIPITABLE_WATER,MODIS_TOTAL_PRECIPITABLE_WATER)
!            call get_expected_tpw(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(AQUA_TOTAL_PRECIPITABLE_WATER,TERRA_TOTAL_PRECIPITABLE_WATER,GPS_TOTAL_PRECIPITABLE_WATER)
!           continue
!         case(AMSR_TOTAL_PRECIPITABLE_WATER,MODIS_TOTAL_PRECIPITABLE_WATER)
!           continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(AQUA_TOTAL_PRECIPITABLE_WATER,TERRA_TOTAL_PRECIPITABLE_WATER,GPS_TOTAL_PRECIPITABLE_WATER)
!           continue
!         case(AMSR_TOTAL_PRECIPITABLE_WATER,MODIS_TOTAL_PRECIPITABLE_WATER)
!           continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(AQUA_TOTAL_PRECIPITABLE_WATER,TERRA_TOTAL_PRECIPITABLE_WATER,GPS_TOTAL_PRECIPITABLE_WATER)
!           continue
!         case(AMSR_TOTAL_PRECIPITABLE_WATER,MODIS_TOTAL_PRECIPITABLE_WATER)
!           continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! RADIOSONDE_SURFACE_ALTIMETER, QTY_SURFACE_PRESSURE
! DROPSONDE_SURFACE_ALTIMETER,  QTY_SURFACE_PRESSURE
! MARINE_SFC_ALTIMETER,         QTY_SURFACE_PRESSURE
! LAND_SFC_ALTIMETER,           QTY_SURFACE_PRESSURE
! METAR_ALTIMETER,              QTY_SURFACE_PRESSURE
! MESONET_SURFACE_ALTIMETER,    QTY_SURFACE_PRESSURE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_altimeter_mod, only : get_expected_altimeter, compute_altimeter
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(RADIOSONDE_SURFACE_ALTIMETER, DROPSONDE_SURFACE_ALTIMETER, MARINE_SFC_ALTIMETER, &
!              LAND_SFC_ALTIMETER, METAR_ALTIMETER, MESONET_SURFACE_ALTIMETER)
!            call get_expected_altimeter(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(RADIOSONDE_SURFACE_ALTIMETER, DROPSONDE_SURFACE_ALTIMETER, MARINE_SFC_ALTIMETER, &
!              LAND_SFC_ALTIMETER, METAR_ALTIMETER, MESONET_SURFACE_ALTIMETER)
!            continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(RADIOSONDE_SURFACE_ALTIMETER, DROPSONDE_SURFACE_ALTIMETER, MARINE_SFC_ALTIMETER, &
!              LAND_SFC_ALTIMETER, METAR_ALTIMETER, MESONET_SURFACE_ALTIMETER)
!            continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(RADIOSONDE_SURFACE_ALTIMETER, DROPSONDE_SURFACE_ALTIMETER, MARINE_SFC_ALTIMETER, &
!              LAND_SFC_ALTIMETER, METAR_ALTIMETER, MESONET_SURFACE_ALTIMETER)
!            continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! An example of a simple forward operator that involves more than
! just interpolating directly from a state vector in a model.
!
! This section defines a specific type in the left column and
! can be any string you want to use for an observation.  The
! right column must be a generic kind that already exists in
! the obs_kind/DEFAULT_obs_kind_mod.F90 file.
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! RADIOSONDE_WIND_SPEED,         QTY_VELOCITY
! END DART PREPROCESS TYPE DEFINITIONS
! This section will be added to the main obs_def_mod.f90 that
! is going to be generated, to allow it to call the code we
! are defining here.
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_wind_speed_mod, only : get_expected_windspeed
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! This section will be dropped into a large case statement in the
! main obs_def_mod.f90 code to control what happens with each
! observation type that is processed.
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!   case(RADIOSONDE_WIND_SPEED)
!        call get_expected_windspeed(state_handle, ens_size, location, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! The next few sections do nothing because there is no additional
! data to read, write, or prompt for.  But there still needs to be a
! case statement in the large select, so they must be here.
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(RADIOSONDE_WIND_SPEED)
!     continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(RADIOSONDE_WIND_SPEED)
!     continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(RADIOSONDE_WIND_SPEED)
!     continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! This is the code that implements the forward operator.
! Define a module, and make public anything that will be called
! from the main obs_def_mod.f90 file.  Here it is just the
! get_expected routine.  There isn't any initialization needed
! but the stub is there; it could read a namelist if there are
! any run-time options to be set.
! BEGIN DART PREPROCESS MODULE CODE


! 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
! Forward operator to compute total cloud water in a column,
! in kg/m2.   Can be used as an example of a
! forward operator that loops over either fixed pressure levels or
! over model levels.
!>@todo FIXME remove all the TAB characters - technically not supported, can issue warnings
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! GOES_CWP_PATH,      QTY_CWP_PATH
! GOES_LWP_PATH,      QTY_CWP_PATH
! GOES_IWP_PATH,      QTY_CWP_PATH
! GOES_CWP_ZERO,      QTY_CWP_PATH_ZERO
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!  use obs_def_cwp_mod, only : get_expected_cwp, write_cwp, read_cwp, set_cbp_ctp,interactive_cwp
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(GOES_CWP_PATH)
!            call get_expected_cwp(state_handle, ens_size, location, "GOES_CWP_PATH", obs_def%key, expected_obs, istatus)
!         case(GOES_LWP_PATH)
!            call get_expected_cwp(state_handle, ens_size, location, "GOES_LWP_PATH", obs_def%key, expected_obs, istatus)
!         case(GOES_IWP_PATH)
!            call get_expected_cwp(state_handle, ens_size, location, "GOES_IWP_PATH", obs_def%key, expected_obs, istatus)
!         case(GOES_CWP_ZERO)
!            call get_expected_cwp(state_handle, ens_size, location, "GOES_CWP_ZERO", obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(GOES_CWP_PATH)
!            call write_cwp(obs_def%key, ifile, fform)
!         case(GOES_LWP_PATH)
!            call write_cwp(obs_def%key, ifile, fform)
!         case(GOES_IWP_PATH)
!            call write_cwp(obs_def%key, ifile, fform)
!         case(GOES_CWP_ZERO)
!            call write_cwp(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(GOES_CWP_PATH)
!            call read_cwp(obs_def%key, ifile, fform)
!         case(GOES_LWP_PATH)
!            call read_cwp(obs_def%key, ifile, fform)
!         case(GOES_IWP_PATH)
!            call read_cwp(obs_def%key, ifile, fform)
!         case(GOES_CWP_ZERO)
!            call read_cwp(obs_def%key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(GOES_CWP_PATH)
!            call interactive_cwp(obs_def%key)
!         case(GOES_LWP_PATH)
!            call interactive_cwp(obs_def%key)
!         case(GOES_IWP_PATH)
!            call interactive_cwp(obs_def%key)
!         case(GOES_CWP_ZERO)
!            call interactive_cwp(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! RAW_STATE_VARIABLE,    QTY_STATE_VARIABLE,     COMMON_CODE
! RAW_TRACER_CONCENTRATION,       QTY_TRACER_CONCENTRATION,     COMMON_CODE
! RAW_TRACER_SOURCE,     QTY_TRACER_SOURCE, COMMON_CODE
! RAW_STATE_1D_INTEGRAL, QTY_1D_INTEGRAL
! RAW_STATE_VAR_POWER,   QTY_STATE_VAR_POWER
! LARGE_SCALE_STATE,     QTY_LARGE_SCALE_STATE,  COMMON_CODE
! SMALL_SCALE_STATE,     QTY_SMALL_SCALE_STATE,  COMMON_CODE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_1d_state_mod, only : write_1d_integral, read_1d_integral, &
!                                     interactive_1d_integral, get_expected_1d_integral, &
!                                     write_power, read_power, interactive_power, get_expected_power
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(RAW_STATE_1D_INTEGRAL)
!            call get_expected_1d_integral(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
!         case(RAW_STATE_VAR_POWER)
!            call get_expected_power(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!      case(RAW_STATE_1D_INTEGRAL)
!         call read_1d_integral(obs_def%key, ifile, fform)
!      case(RAW_STATE_VAR_POWER)
!         call read_power(obs_def%key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!      case(RAW_STATE_1D_INTEGRAL)
!         call write_1d_integral(obs_def%key, ifile, fform)
!      case(RAW_STATE_VAR_POWER)
!         call write_power(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!      case(RAW_STATE_1D_INTEGRAL)
!         call interactive_1d_integral(obs_def%key)
!      case(RAW_STATE_VAR_POWER)
!         call interactive_power(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! DEWPOINT,                QTY_DEWPOINT
! DEWPOINT_2_METER,        QTY_DEWPOINT
! BUOY_DEWPOINT,           QTY_DEWPOINT
! SHIP_DEWPOINT,           QTY_DEWPOINT
! SYNOP_DEWPOINT,          QTY_DEWPOINT
! AIREP_DEWPOINT,          QTY_DEWPOINT
! AMDAR_DEWPOINT,          QTY_DEWPOINT
! PILOT_DEWPOINT,          QTY_DEWPOINT
! BOGUS_DEWPOINT,          QTY_DEWPOINT
! AIRS_DEWPOINT,           QTY_DEWPOINT
! METAR_DEWPOINT_2_METER,  QTY_DEWPOINT
! RADIOSONDE_DEWPOINT,     QTY_DEWPOINT
! DROPSONDE_DEWPOINT,      QTY_DEWPOINT
! AIRCRAFT_DEWPOINT,       QTY_DEWPOINT
! ACARS_DEWPOINT,          QTY_DEWPOINT
! MARINE_SFC_DEWPOINT,     QTY_DEWPOINT
! LAND_SFC_DEWPOINT,       QTY_DEWPOINT
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_dew_point_mod, only : get_expected_dew_point
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(DEWPOINT)
!            call get_expected_dew_point(state_handle,  ens_size, location, 1, expected_obs, istatus)
!         case(AIREP_DEWPOINT, AMDAR_DEWPOINT, PILOT_DEWPOINT, BOGUS_DEWPOINT, AIRS_DEWPOINT)
!            call get_expected_dew_point(state_handle, ens_size,  location, 1, expected_obs, istatus)
!         case(RADIOSONDE_DEWPOINT, AIRCRAFT_DEWPOINT, ACARS_DEWPOINT, DROPSONDE_DEWPOINT)
!            call get_expected_dew_point(state_handle,  ens_size, location, 1, expected_obs, istatus)
!
!         case(DEWPOINT_2_METER)
!            call get_expected_dew_point(state_handle,  ens_size, location, 2, expected_obs, istatus)
!         case(BUOY_DEWPOINT, SHIP_DEWPOINT, SYNOP_DEWPOINT)
!            call get_expected_dew_point(state_handle,  ens_size, location, 2, expected_obs, istatus)
!         case(MARINE_SFC_DEWPOINT, LAND_SFC_DEWPOINT)
!            call get_expected_dew_point(state_handle,  ens_size, location, 2, expected_obs, istatus)
!         case(METAR_DEWPOINT_2_METER)
!            call get_expected_dew_point(state_handle,  ens_size, location, 2, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!         case(DEWPOINT, DEWPOINT_2_METER)
!            continue
!         case(METAR_DEWPOINT_2_METER)
!            continue
!         case(AIREP_DEWPOINT, AMDAR_DEWPOINT, PILOT_DEWPOINT, BOGUS_DEWPOINT)
!            continue
!         case(BUOY_DEWPOINT, SHIP_DEWPOINT, SYNOP_DEWPOINT, AIRS_DEWPOINT)
!            continue
!         case(RADIOSONDE_DEWPOINT, AIRCRAFT_DEWPOINT, ACARS_DEWPOINT, DROPSONDE_DEWPOINT)
!            continue
!         case(MARINE_SFC_DEWPOINT, LAND_SFC_DEWPOINT)
!            continue
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!         case(DEWPOINT, DEWPOINT_2_METER)
!            continue
!         case(METAR_DEWPOINT_2_METER)
!            continue
!         case(AIREP_DEWPOINT, AMDAR_DEWPOINT, PILOT_DEWPOINT, BOGUS_DEWPOINT)
!            continue
!         case(BUOY_DEWPOINT, SHIP_DEWPOINT, SYNOP_DEWPOINT, AIRS_DEWPOINT)
!            continue
!         case(RADIOSONDE_DEWPOINT, AIRCRAFT_DEWPOINT, ACARS_DEWPOINT, DROPSONDE_DEWPOINT)
!            continue
!         case(MARINE_SFC_DEWPOINT, LAND_SFC_DEWPOINT)
!            continue
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!         case(DEWPOINT, DEWPOINT_2_METER)
!            continue
!         case(METAR_DEWPOINT_2_METER)
!            continue
!         case(AIREP_DEWPOINT, AMDAR_DEWPOINT, PILOT_DEWPOINT, BOGUS_DEWPOINT)
!            continue
!         case(BUOY_DEWPOINT, SHIP_DEWPOINT, SYNOP_DEWPOINT, AIRS_DEWPOINT)
!            continue
!         case(RADIOSONDE_DEWPOINT, AIRCRAFT_DEWPOINT, ACARS_DEWPOINT, DROPSONDE_DEWPOINT)
!            continue
!         case(MARINE_SFC_DEWPOINT, LAND_SFC_DEWPOINT)
!            continue
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
!----------------------------------------------------------------------
! This module provides support for observations of streamflow.
!
!  OBS            1
!           -1           2          -1
! obdef
! loc3d
!      4.188790204786391        0.6986026390077337         137.7093918137252      3
! kind
!            1
! gageID_linkID
!    <a chararacter string ID for the gage>    <numeric link ID>
!      0          0
!    4.0000000000000000
!----------------------------------------------------------------------
! keep in mind that fortran allows only 31 characters in parameter
! definitions (which is what this string is going to be used for).
! if the platform name gets longer than 5 chars, consider going
! to something like xxx_TOTAL_PRECIP_WATER to give you room to
! put in more descriptive platform names.
! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy-
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! STREAM_FLOW,                    QTY_STREAM_FLOW
! DEEP_GROUNDWATER_LEVEL,         QTY_DEEP_GROUNDWATER_LEVEL,    COMMON_CODE
! SKIN_TEMPERATURE,               QTY_SKIN_TEMPERATURE,          COMMON_CODE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_streamflow_mod, only : read_streamflow_metadata, &
!                                     write_streamflow_metadata, &
!                               interactive_streamflow_metadata
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! The get_expected_obs_from_def for STREAM_FLOW is kinda dumb at the moment, but
! it expected that there will be a more complicated one soon.
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!  case(STREAM_FLOW)
!     call interpolate(state_handle, ens_size, location, QTY_STREAM_FLOW, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!   case(STREAM_FLOW)
!      call read_streamflow_metadata(obs_def%key, key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!   case(STREAM_FLOW)
!      call write_streamflow_metadata(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!   case(STREAM_FLOW)
!      call interactive_streamflow_metadata(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


! 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
!
! BEGIN DART PREPROCESS TYPE DEFINITIONS
! TEMPERATURE,          QTY_TEMPERATURE,         COMMON_CODE
! SURFACE_PRESSURE,     QTY_SURFACE_PRESSURE,    COMMON_CODE
! SKIN_TEMPERATURE,     QTY_SKIN_TEMPERATURE,    COMMON_CODE
! TES_NADIR_OBS,        QTY_NADIR_RADIANCE
! END DART PREPROCESS TYPE DEFINITIONS
! BEGIN DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
!   use obs_def_TES_nadir_mod, only : write_TES_nadir_obs, read_TES_nadir_obs, &
!                                    interactive_TES_nadir_obs, get_expected_TES_nadir_obs
! END DART PREPROCESS USE OF SPECIAL OBS_DEF MODULE
! BEGIN DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
!         case(TES_NADIR_OBS)
!            call get_expected_TES_nadir_obs(state_handle, ens_size, location, obs_def%key, expected_obs, istatus)
! END DART PREPROCESS GET_EXPECTED_OBS_FROM_DEF
! BEGIN DART PREPROCESS READ_OBS_DEF
!      case(TES_NADIR_OBS)
!         call read_TES_nadir_obs(obs_def%key, ifile, fform)
! END DART PREPROCESS READ_OBS_DEF
! BEGIN DART PREPROCESS WRITE_OBS_DEF
!      case(TES_NADIR_OBS)
!         call write_TES_nadir_obs(obs_def%key, ifile, fform)
! END DART PREPROCESS WRITE_OBS_DEF
! BEGIN DART PREPROCESS INTERACTIVE_OBS_DEF
!      case(TES_NADIR_OBS)
!         call interactive_TES_nadir_obs(obs_def%key)
! END DART PREPROCESS INTERACTIVE_OBS_DEF
! BEGIN DART PREPROCESS MODULE CODE


!$$$  subprogram documentation block
!                .      .    .                                       .
! subprogram:    read_raddiag                       read rad diag file
!   prgmmr: tahara           org: np20                date: 2003-01-01
!
! abstract:  This module contains code to process radiance
!            diagnostic files.  The module defines structures
!            to contain information from the radiance
!            diagnostic files and then provides two routines
!            to access contents of the file.
!
! program history log:
!   2005-07-22 treadon - add this doc block
!   2010-10-05 treadon - refactor code to GSI standard
!   2010-10-08 zhu     - use data_tmp to handle various npred values
!   2011-02-22 kleist  - changes related to memory allocate/deallocate
!   2011-04-08 li      - add tref, dtw, dtc to diag_data_fix_list, add tb_tz to diag_data_chan_list
!                      - correspondingly, change ireal_radiag (26 -> 30) and ipchan_radiag (7 -> 8)
!   2011-07-24 safford - make structure size for reading data_fix data version dependent
!   2013-11-21 todling - revisit how versions are set (add set/get_radiag)
!   2014-01-27 todling - add ob sensitivity index
!
! contains
!   read_radiag_header - read radiance diagnostic file header
!   read_radiag_data   - read radiance diagnostic file data
!
! attributes:
!   language: f90
!   machine:  ibm RS/6000 SP
!
!$$$


! 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$
! utility routines intended to make it easier to create the most
! common types of observations:  threed_sphere locations, which
! is what 99% of earth observations use.
! added an alternative for obs locations specified in X,Y,Z cartesian
! coordinates.  used for subsurface water models, and some idealized
! atmosphere models.


! 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$
!> utility routines that work on observation sequences
!>


! This code is not protected by the DART copyright agreement.
! DART $Id$


! This code is not protected by the DART copyright agreement.
! adapted from original JPL code, example AIRS readers
!
! updated for version 6 and 7 of the AIRS data formats
! added fields needed to support radiances
! removed unused items to streamline the code.
!
! april 2019, nsc


! 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


!====================================================================!
!                                                                    !
! Copyright 2002-2022,2023                                           !
! Mikael Granvik, Jenni Virtanen, Karri Muinonen, Teemu Laakso,      !
! Dagmara Oszkiewicz                                                 !
!                                                                    !
! This file is part of OpenOrb.                                      !
!                                                                    !
! OpenOrb is free software: you can redistribute it and/or modify it !
! under the terms of the GNU General Public License as published by  !
! the Free Software Foundation, either version 3 of the License, or  !
! (at your option) any later version.                                !
!                                                                    !
! OpenOrb is distributed in the hope that it will be useful, but     !
! WITHOUT ANY WARRANTY; without even the implied warranty of         !
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  !
! General Public License for more details.                           !
!                                                                    !
! You should have received a copy of the GNU General Public License  !
! along with OpenOrb. If not, see <http://www.gnu.org/licenses/>.    !
!                                                                    !
!====================================================================!
!
!! *Module*description*:
!!
!! Parameters for modules.
!!
!! @author  MG
!! @version 2023-04-05
!!


!====================================================================!
!                                                                    !
! Copyright 2002-2024,2025                                           !
! Mikael Granvik, Jenni Virtanen, Karri Muinonen, Teemu Laakso,      !
! Dagmara Oszkiewicz, Lauri Siltala                                  !
!                                                                    !
! This file is part of OpenOrb.                                      !
!                                                                    !
! OpenOrb is free software: you can redistribute it and/or modify it !
! under the terms of the GNU General Public License as published by  !
! the Free Software Foundation, either version 3 of the License, or  !
! (at your option) any later version.                                !
!                                                                    !
! OpenOrb is distributed in the hope that it will be useful, but     !
! WITHOUT ANY WARRANTY; without even the implied warranty of         !
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  !
! General Public License for more details.                           !
!                                                                    !
! You should have received a copy of the GNU General Public License  !
! along with OpenOrb. If not, see <http://www.gnu.org/licenses/>.    !
!                                                                    !
!====================================================================!
!
!! *Module*description*:
!!
!! Defines parameters relating to planets and minor planets in the
!! solar system, and contains the routines for using planetary
!! ephemerides provided by JPL and IMCCE.
!!
!! This software is partly based on jplsub.f (by JPL) and a
!! Fortran 90 compilation of the same software by Hannu Karttunen
!! (Tuorla Observatory, Turku, Finland).
!!
!! *Example*:
!!
!!

!!program myprog
!!
!! use planetary_data
!! implicit none
!! real(8), dimension(6) :: crtcrd
!! real(8) :: t
!! logical :: error
!!
!! crtcrd = JPL_ephemeris(t, 3, 11, error)
!! if (error) stop 'Error 2'
!!
!!end program myprog
!!

!!
!! @author  MG, TL
!! @version 2025-05-20
!!