ExtDataTypeDef.F90 Source File


This file depends on

sourcefile~~extdatatypedef.f90~~EfferentGraph sourcefile~extdatatypedef.f90 ExtDataTypeDef.F90 sourcefile~extdataabstractfilehandler.f90 ExtDataAbstractFileHandler.F90 sourcefile~extdatatypedef.f90->sourcefile~extdataabstractfilehandler.f90 sourcefile~extdatabracket.f90 ExtDataBracket.F90 sourcefile~extdatatypedef.f90->sourcefile~extdatabracket.f90 sourcefile~extdataupdatepointer.f90 ExtDataUpdatePointer.F90 sourcefile~extdatatypedef.f90->sourcefile~extdataupdatepointer.f90 sourcefile~filemetadatautilities.f90 FileMetadataUtilities.F90 sourcefile~extdatatypedef.f90->sourcefile~filemetadatautilities.f90 sourcefile~griddedioitem.f90 GriddedIOitem.F90 sourcefile~extdatatypedef.f90->sourcefile~griddedioitem.f90 sourcefile~stateutils.f90 StateUtils.F90 sourcefile~extdatatypedef.f90->sourcefile~stateutils.f90 sourcefile~verticalcoordinate.f90 VerticalCoordinate.F90 sourcefile~extdatatypedef.f90->sourcefile~verticalcoordinate.f90 sourcefile~extdataabstractfilehandler.f90->sourcefile~extdatabracket.f90 sourcefile~extdataabstractfilehandler.f90->sourcefile~filemetadatautilities.f90 sourcefile~datacollection.f90 DataCollection.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~datacollection.f90 sourcefile~datacollectionmanager.f90 DataCollectionManager.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~datacollectionmanager.f90 sourcefile~extdataconstants.f90 ExtDataConstants.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~extdataconstants.f90 sourcefile~extdatafilestream.f90 ExtDataFileStream.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~extdatafilestream.f90 sourcefile~mapl_comms.f90 MAPL_Comms.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~mapl_comms.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~mapl_keywordenforcer.f90 MAPL_KeywordEnforcer.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~stringtemplate.f90 StringTemplate.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~stringtemplate.f90 sourcefile~timestringconversion.f90 TimeStringConversion.F90 sourcefile~extdataabstractfilehandler.f90->sourcefile~timestringconversion.f90 sourcefile~base_base.f90 Base_Base.F90 sourcefile~extdatabracket.f90->sourcefile~base_base.f90 sourcefile~extdatabracket.f90->sourcefile~extdataconstants.f90 sourcefile~extdatanode.f90 ExtDataNode.F90 sourcefile~extdatabracket.f90->sourcefile~extdatanode.f90 sourcefile~fieldutils.f90 FieldUtils.F90 sourcefile~extdatabracket.f90->sourcefile~fieldutils.f90 sourcefile~extdatabracket.f90->sourcefile~mapl_comms.f90 sourcefile~extdatabracket.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~extdatabracket.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~extdataupdatepointer.f90->sourcefile~mapl_comms.f90 sourcefile~extdataupdatepointer.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~extdataupdatepointer.f90->sourcefile~mapl_keywordenforcer.f90 sourcefile~extdataupdatepointer.f90->sourcefile~timestringconversion.f90 sourcefile~mapl_abstractgridfactory.f90 MAPL_AbstractGridFactory.F90 sourcefile~filemetadatautilities.f90->sourcefile~mapl_abstractgridfactory.f90 sourcefile~filemetadatautilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~mapl_gridmanager.f90 MAPL_GridManager.F90 sourcefile~filemetadatautilities.f90->sourcefile~mapl_gridmanager.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~filemetadatautilities.f90->sourcefile~pfio.f90 sourcefile~statearithmeticparser.f90 StateArithmeticParser.F90 sourcefile~stateutils.f90->sourcefile~statearithmeticparser.f90 sourcefile~statefilter.f90 StateFilter.F90 sourcefile~stateutils.f90->sourcefile~statefilter.f90 sourcefile~statemasking.f90 StateMasking.F90 sourcefile~stateutils.f90->sourcefile~statemasking.f90 sourcefile~verticalcoordinate.f90->sourcefile~filemetadatautilities.f90 sourcefile~verticalcoordinate.f90->sourcefile~mapl_comms.f90 sourcefile~verticalcoordinate.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~verticalcoordinate.f90->sourcefile~pfio.f90 sourcefile~udunits2f.f90 udunits2f.F90 sourcefile~verticalcoordinate.f90->sourcefile~udunits2f.f90

Files dependent on this one

sourcefile~~extdatatypedef.f90~~AfferentGraph sourcefile~extdatatypedef.f90 ExtDataTypeDef.F90 sourcefile~extdataderivedexportvector.f90 ExtDataDerivedExportVector.F90 sourcefile~extdataderivedexportvector.f90->sourcefile~extdatatypedef.f90 sourcefile~extdatagridcompng.f90 ExtDataGridCompNG.F90 sourcefile~extdatagridcompng.f90->sourcefile~extdatatypedef.f90 sourcefile~extdatagridcompng.f90->sourcefile~extdataderivedexportvector.f90 sourcefile~extdataoldtypescreator.f90 ExtDataOldTypesCreator.F90 sourcefile~extdatagridcompng.f90->sourcefile~extdataoldtypescreator.f90 sourcefile~extdataprimaryexportvector.f90 ExtDataPrimaryExportVector.F90 sourcefile~extdatagridcompng.f90->sourcefile~extdataprimaryexportvector.f90 sourcefile~extdataoldtypescreator.f90->sourcefile~extdatatypedef.f90 sourcefile~extdataprimaryexportvector.f90->sourcefile~extdatatypedef.f90 sourcefile~extdatadrivergridcomp.f90 ExtDataDriverGridComp.F90 sourcefile~extdatadrivergridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~mapl_capgridcomp.f90 MAPL_CapGridComp.F90 sourcefile~mapl_capgridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~comp_testing_driver.f90 Comp_Testing_Driver.F90 sourcefile~comp_testing_driver.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~extdatadriver.f90 ExtDataDriver.F90 sourcefile~extdatadriver.f90->sourcefile~extdatadrivergridcomp.f90 sourcefile~extdatadrivermod.f90 ExtDataDriverMod.F90 sourcefile~extdatadriver.f90->sourcefile~extdatadrivermod.f90 sourcefile~extdatadrivermod.f90->sourcefile~extdatadrivergridcomp.f90 sourcefile~mapl_cap.f90 MAPL_Cap.F90 sourcefile~mapl_cap.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~mapl_gridcomps.f90 MAPL_GridComps.F90 sourcefile~mapl_gridcomps.f90->sourcefile~mapl_cap.f90 sourcefile~mapl_nuopcwrappermod.f90 MAPL_NUOPCWrapperMod.F90 sourcefile~mapl_nuopcwrappermod.f90->sourcefile~mapl_cap.f90

Source Code

#include "MAPL_Exceptions.h"
module MAPL_ExtDataTypeDef
   use ESMF
   use MAPL_GriddedIOItemMod
   use MAPL_ExtDataBracket
   use MAPL_ExtDataPointerUpdate
   use MAPL_ExtDataAbstractFileHandler
   use MAPL_FileMetadataUtilsMod
   use MAPL_StateUtils
   use VerticalCoordinateMod
   implicit none

   public PrimaryExport
   public DerivedExport
   public BracketingFields
   public copy_primary

  integer, parameter         :: MAPL_ExtDataNullFrac      = -9999

  type BracketingFields
     ! fields to store endpoints for interpolation of a vector pair
     type(ExtDataBracket) :: comp1
     type(ExtDataBracket) :: comp2
     logical :: initialized = .false.
  end type BracketingFields

  type PrimaryExport
     character(len=ESMF_MAXSTR)   :: name
     character(len=:), allocatable :: units
     integer                      :: Trans
     character(len=ESMF_MAXSTR)   :: var
     character(len=ESMF_MAXPATHLEN)   :: file_template

     logical                      :: isConst
     real                         :: Const !remove
     integer                      :: vartype ! MAPL_FieldItem or MAPL_BundleItem

     class(ExtDataAbstractFileHandler), allocatable :: filestream

     ! if primary export represents a pair of vector fields
     logical                      :: isVector
     type(BracketingFields)       :: modelGridFields

     ! names of the two vector components in the gridded component where import is declared
     character(len=ESMF_MAXSTR)   :: vcomp1, vcomp2
     ! the corresponding names of the two vector components on file
     character(len=ESMF_MAXSTR)   :: fcomp1, fcomp2
     type(GriddedIOitem)          :: fileVars

     integer                      :: pfioCollection_id
     integer                      :: iclient_collection_id

     logical                      :: ExtDataAlloc
     integer                      :: FracVal = MAPL_ExtDataNullFrac
     ! do we have to do vertical interpolation
     logical                      :: do_VertInterp = .false.
     logical                      :: do_Fill = .false.
     type(FileMetadataUtils)      :: file_metadata
     type(ExtDataPointerUpdate)   :: update_freq
     type(VerticalCoordinate)     :: vcoord
     logical                      :: delivered_item = .true. 

     ! new stuff
     logical                      :: cycling
     logical                      :: persist_closest
     type(ESMF_Time), allocatable :: source_time(:)

     ! for multiple collections
     type(ESMF_Time), allocatable :: start_end_time(:)
     logical :: initialized = .false.
     logical :: fail_on_missing_file = .true.

     type(ESMF_FieldBundle) :: t_interp_bundle

     character(len=4) :: importVDir = "down"
     logical :: enable_vertical_regrid = .false.
     logical :: allow_vertical_regrid = .false.
     character(len=:), allocatable :: aux_ps, aux_q
     real, allocatable :: molecular_weight

  end type PrimaryExport
  
  type DerivedExport
     character(len=ESMF_MAXSTR)     :: name
     character(len=ESMF_MAXPATHLEN) :: expression
     logical                        :: masking
     type(StateMask), allocatable :: mask_definition 
     type(ExtDataPointerUpdate)     :: update_freq
     contains
        procedure :: evaluate_derived_field
  end type DerivedExport

  contains

      subroutine copy_primary(p1, p2, aux_type )
         type(PrimaryExport), intent(in) :: p1
         type(PrimaryExport), intent(out) :: p2
         character(len=*), intent(in) :: aux_type

         character(len=:), allocatable :: new_name, aux_name
         logical :: has_aux_item
         if (aux_type == 'Q') then
            has_aux_item = allocated(p1%aux_q)
            aux_name=p1%aux_q
         end if
         if (aux_type == 'PS') then
            has_aux_item = allocated(p1%aux_ps)
            aux_name=p1%aux_ps
         end if
         p2 = p1
         if (has_aux_item) then
            p2%var=aux_name
            new_name = aux_name//"_"//trim(p1%name)
            p2%name=new_name
            p2%fileVars%xname = aux_name
            p2%fcomp1 = aux_name
            p2%vcomp1=new_name
         else
            p2%file_template = "/dev/null"
            p2%isConst = .true.
         end if
         p2%delivered_item = .false.

      end subroutine
         
      subroutine evaluate_derived_field(this,state,rc)
         class(DerivedExport), intent(inout) :: this
         type(ESMF_State), intent(inout) :: state
         integer, optional, intent(out) :: rc

         integer :: status
         type(ESMF_Field) :: field

         call ESMF_StateGet(state,trim(this%name),field,_RC)
         if (this%masking) then
            call this%mask_definition%evaluate_mask(state,field,_RC)
         else
            call MAPL_StateEval(state,trim(this%expression),field,_RC)
         end if
         _RETURN(_SUCCESS)
      end subroutine

end module  MAPL_ExtDataTypeDef