VarspecDescription.F90 Source File


This file depends on

sourcefile~~varspecdescription.f90~~EfferentGraph sourcefile~varspecdescription.f90 VarspecDescription.F90 sourcefile~constants.f90 Constants.F90 sourcefile~varspecdescription.f90->sourcefile~constants.f90 sourcefile~mapl.f90 MAPL.F90 sourcefile~varspecdescription.f90->sourcefile~mapl.f90 sourcefile~internalconstants.f90 InternalConstants.F90 sourcefile~constants.f90->sourcefile~internalconstants.f90 sourcefile~mathconstants.f90 MathConstants.F90 sourcefile~constants.f90->sourcefile~mathconstants.f90 sourcefile~physicalconstants.f90 PhysicalConstants.F90 sourcefile~constants.f90->sourcefile~physicalconstants.f90 sourcefile~base.f90 Base.F90 sourcefile~mapl.f90->sourcefile~base.f90 sourcefile~esmf_cfiomod.f90 ESMF_CFIOMod.F90 sourcefile~mapl.f90->sourcefile~esmf_cfiomod.f90 sourcefile~fieldbundleread.f90 FieldBundleRead.F90 sourcefile~mapl.f90->sourcefile~fieldbundleread.f90 sourcefile~fieldbundlewrite.f90 FieldBundleWrite.F90 sourcefile~mapl.f90->sourcefile~fieldbundlewrite.f90 sourcefile~fieldutils.f90 FieldUtils.F90 sourcefile~mapl.f90->sourcefile~fieldutils.f90 sourcefile~mapl_generic.f90 MAPL_Generic.F90 sourcefile~mapl.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_gridcomps.f90 MAPL_GridComps.F90 sourcefile~mapl.f90->sourcefile~mapl_gridcomps.f90 sourcefile~mapl_profiler.f90~2 MAPL_Profiler.F90 sourcefile~mapl.f90->sourcefile~mapl_profiler.f90~2 sourcefile~openmp_support.f90 OpenMP_Support.F90 sourcefile~mapl.f90->sourcefile~openmp_support.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~mapl.f90->sourcefile~pfio.f90 sourcefile~pythonbridge.f90 PythonBridge.F90 sourcefile~mapl.f90->sourcefile~pythonbridge.f90 sourcefile~stateutils.f90 StateUtils.F90 sourcefile~mapl.f90->sourcefile~stateutils.f90 sourcefile~stubcomponent.f90 StubComponent.F90 sourcefile~mapl.f90->sourcefile~stubcomponent.f90 sourcefile~varspecmiscmod.f90 VarSpecMiscMod.F90 sourcefile~mapl.f90->sourcefile~varspecmiscmod.f90

Files dependent on this one

sourcefile~~varspecdescription.f90~~AfferentGraph sourcefile~varspecdescription.f90 VarspecDescription.F90 sourcefile~extdataroot_gridcomp.f90 ExtDataRoot_GridComp.F90 sourcefile~extdataroot_gridcomp.f90->sourcefile~varspecdescription.f90 sourcefile~capdriver.f90 CapDriver.F90 sourcefile~capdriver.f90->sourcefile~extdataroot_gridcomp.f90 sourcefile~extdatadriver.f90 ExtDataDriver.F90 sourcefile~extdatadriver.f90->sourcefile~extdataroot_gridcomp.f90 sourcefile~extdatadrivermod.f90 ExtDataDriverMod.F90 sourcefile~extdatadriver.f90->sourcefile~extdatadrivermod.f90 sourcefile~extdatadrivermod.f90->sourcefile~extdataroot_gridcomp.f90

Source Code

#include "MAPL_Generic.h"

module VarspecDescriptionMod
   use MAPL
   use ESMF
   use gFTL_StringVector
   use MAPL_Constants, only: MAPL_R4, MAPL_R8
   implicit none
   private

   public :: VarspecDescription

   type, extends(MAPL_VarSpecType) :: VarspecDescription
   contains
      procedure :: addNewSpec
   end type VarspecDescription

   interface VarspecDescription
      module procedure new_VarspecDescriptionFromConfig
   end interface VarspecDescription

contains

   ! have to pass in the number of words on the config line because
   ! of a config bug, config really sucks
   function new_VarspecDescriptionFromConfig(cf,nwords,rc) result(VarspecDescr)
      type(VarspecDescription) :: VarspecDescr
      type(ESMF_Config), intent(inout) :: cf
      integer, intent(in) :: nwords
      logical :: lcomp
      integer, optional, intent(out) :: rc

      integer :: status

      type(StringVector) :: svec
      integer :: i
      integer, pointer :: ungrid_ptr(:)
      character(ESMF_MAXSTR) :: tmpstring

      do i=1,nwords
         call ESMF_ConfigGetAttribute(cf,tmpstring,rc=status)
         _VERIFY(status)
         if (trim(tmpstring)==',') cycle
         call svec%push_back(trim(tmpstring))
      enddo

      lcomp = (svec%size()==6 .or. svec%size()==7)
      _ASSERT(lcomp, 'Wrong number of columns in state descriptor')
      VarspecDescr%short_name = svec%at(1)
      
      ! Parse and validate precision (column 2)
      tmpstring = svec%at(2)
      if (trim(tmpstring) == 'R4') then
         VarspecDescr%precision = MAPL_R4
      else if (trim(tmpstring) == 'R8') then
         VarspecDescr%precision = MAPL_R8
      else
        _FAIL('Invalid precision "'// trim(tmpstring) // '": Must be either R4 or R8')

      end if
      
      VarspecDescr%long_name = svec%at(3)
      VarspecDescr%units = svec%at(4)
      tmpstring = svec%at(5)
      if (trim(tmpstring) == 'xy') then
         VarspecDescr%dims = MAPL_DimsHorzOnly
      else if (trim(tmpstring) == 'xyz') then
         VarspecDescr%dims = MAPL_DimsHorzVert
      else if (trim(tmpstring) == 'tileonly') then
         VarspecDescr%dims = MAPL_DimsTileOnly
      end if
      tmpstring = svec%at(6)
      if (trim(tmpstring) == 'none') then
         VarspecDescr%location = MAPL_VLocationNone
      else if (trim(tmpstring) == 'c') then
         VarspecDescr%location = MAPL_VLocationCenter
      else if (trim(tmpstring) == 'e') then
         VarspecDescr%location = MAPL_VLocationEdge
      end if
      if (svec%size() == 7) then
         tmpstring = svec%at(7)
         allocate(ungrid_ptr(1))
         read(tmpstring,*)ungrid_ptr(1)
         if (ungrid_ptr(1) > 0) VarspecDescr%ungridded_dims => ungrid_ptr
      end if


   end function new_VarspecDescriptionFromConfig

   subroutine addNewSpec(this,gc,specType,rc)
      class(VarspecDescription), intent(in) :: this
      type(ESMF_GridComp), intent(inout) :: gc
      character(*), intent(in) :: specType
      integer, optional, intent(out) :: rc

      integer :: status

      if (specType == "IMPORT") then
         call MAPL_AddImportSpec(GC, &
              SHORT_NAME = this%short_name, &
              LONG_NAME = this%long_name, &
              UNITS = this%units, &
              DIMS = this%dims, &
              VLOCATION = this%location, &
              PRECISION = this%precision, &
              !STAGGERING = this%staggering, &
              !ROTATION = this%rotation, &
              UNGRIDDED_DIMS = this%ungridded_dims, &
              _RC)
      else if (specType == "EXPORT") then
         call MAPL_AddExportSpec(GC, &
              SHORT_NAME = this%short_name, &
              LONG_NAME = this%long_name, &
              UNITS = this%units, &
              DIMS = this%dims, &
              VLOCATION = this%location, &
              PRECISION = this%precision, &
              !STAGGERING = this%staggering, &
              !ROTATION = this%rotation, &
              UNGRIDDED_DIMS = this%ungridded_dims, &
              _RC)
      else
         _RETURN(_FAILURE)
      end if

   end subroutine AddNewSpec

end module VarspecDescriptionMod


module VarspecDescriptionVectorMod
   use VarspecDescriptionMod

#define _type type (VarspecDescription)
#define _vector VarspecDescriptionVector
#define _iterator VarspecDescriptionVectorIterator
#include "templates/vector.inc"

end module VarspecDescriptionVectorMod