FieldCreate.F90 Source File


This file depends on

sourcefile~~fieldcreate.f90~~EfferentGraph sourcefile~fieldcreate.f90 FieldCreate.F90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~fieldcreate.f90->sourcefile~errorhandling.f90 sourcefile~fieldinfo.f90 FieldInfo.F90 sourcefile~fieldcreate.f90->sourcefile~fieldinfo.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~fieldcreate.f90->sourcefile~keywordenforcer.f90 sourcefile~lu_bound.f90 LU_Bound.F90 sourcefile~fieldcreate.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90 UngriddedDims.F90 sourcefile~fieldcreate.f90->sourcefile~ungriddeddims.f90 sourcefile~verticalstaggerloc.f90 VerticalStaggerLoc.F90 sourcefile~fieldcreate.f90->sourcefile~verticalstaggerloc.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90 sourcefile~fieldinfo.f90->sourcefile~errorhandling.f90 sourcefile~fieldinfo.f90->sourcefile~keywordenforcer.f90 sourcefile~fieldinfo.f90->sourcefile~ungriddeddims.f90 sourcefile~fieldinfo.f90->sourcefile~verticalstaggerloc.f90 sourcefile~infoutilities.f90 InfoUtilities.F90 sourcefile~fieldinfo.f90->sourcefile~infoutilities.f90 sourcefile~mapl_esmf_infokeys.f90 MAPL_ESMF_InfoKeys.F90 sourcefile~fieldinfo.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~ungriddeddims.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddims.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddims.f90->sourcefile~infoutilities.f90 sourcefile~ungriddeddims.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~ungriddeddim.f90 UngriddedDim.F90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddim.f90 sourcefile~ungriddeddimvector.f90 UngriddedDimVector.F90 sourcefile~ungriddeddims.f90->sourcefile~ungriddeddimvector.f90 sourcefile~infoutilities.f90->sourcefile~errorhandling.f90 sourcefile~infoutilities.f90->sourcefile~keywordenforcer.f90 sourcefile~infoutilities.f90->sourcefile~mapl_esmf_infokeys.f90 sourcefile~mapl_esmf_infokeys.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddim.f90->sourcefile~errorhandling.f90 sourcefile~ungriddeddim.f90->sourcefile~lu_bound.f90 sourcefile~ungriddeddim.f90->sourcefile~infoutilities.f90 sourcefile~ungriddeddimvector.f90->sourcefile~ungriddeddim.f90

Files dependent on this one

sourcefile~~fieldcreate.f90~~AfferentGraph sourcefile~fieldcreate.f90 FieldCreate.F90 sourcefile~api.f90 API.F90 sourcefile~api.f90->sourcefile~fieldcreate.f90 sourcefile~fieldbundledelta.f90 FieldBundleDelta.F90 sourcefile~fieldbundledelta.f90->sourcefile~fieldcreate.f90 sourcefile~fieldbundleget.f90 FieldBundleGet.F90 sourcefile~fieldbundledelta.f90->sourcefile~fieldbundleget.f90 sourcefile~fixedlevelsverticalgrid.f90 FixedLevelsVerticalGrid.F90 sourcefile~fixedlevelsverticalgrid.f90->sourcefile~fieldcreate.f90 sourcefile~meanaction.f90 MeanAction.F90 sourcefile~meanaction.f90->sourcefile~fieldcreate.f90 sourcefile~test_fieldbundledelta.pf Test_FieldBundleDelta.pf sourcefile~test_fieldbundledelta.pf->sourcefile~fieldcreate.f90 sourcefile~test_fieldbundledelta.pf->sourcefile~fieldbundledelta.f90 sourcefile~test_fieldbundledelta.pf->sourcefile~fieldbundleget.f90 sourcefile~test_fieldcreate.pf Test_FieldCreate.pf sourcefile~test_fieldcreate.pf->sourcefile~fieldcreate.f90 sourcefile~test_fielddelta.pf Test_FieldDelta.pf sourcefile~test_fielddelta.pf->sourcefile~fieldcreate.f90 sourcefile~test_fieldreset.pf Test_FieldReset.pf sourcefile~test_fieldreset.pf->sourcefile~fieldcreate.f90 sourcefile~accumulatoractioninterface.f90 AccumulatorActionInterface.F90 sourcefile~accumulatoractioninterface.f90->sourcefile~meanaction.f90 sourcefile~fieldbundleget.f90->sourcefile~api.f90 sourcefile~fieldspec.f90 FieldSpec.F90 sourcefile~fieldspec.f90->sourcefile~api.f90 sourcefile~modelverticalgrid.f90 ModelVerticalGrid.F90 sourcefile~modelverticalgrid.f90->sourcefile~fixedlevelsverticalgrid.f90 sourcefile~modelverticalgrid.f90->sourcefile~fieldspec.f90 sourcefile~parse_geometry_spec.f90 parse_geometry_spec.F90 sourcefile~parse_geometry_spec.f90->sourcefile~fixedlevelsverticalgrid.f90 sourcefile~parse_geometry_spec.f90->sourcefile~modelverticalgrid.f90 sourcefile~test_fixedlevelsverticalgrid.pf Test_FixedLevelsVerticalGrid.pf sourcefile~test_fixedlevelsverticalgrid.pf->sourcefile~fixedlevelsverticalgrid.f90 sourcefile~test_meanaction.pf Test_MeanAction.pf sourcefile~test_meanaction.pf->sourcefile~meanaction.f90 sourcefile~bracketspec.f90 BracketSpec.F90 sourcefile~bracketspec.f90->sourcefile~fieldspec.f90 sourcefile~frequencyaspect.f90 FrequencyAspect.F90 sourcefile~frequencyaspect.f90->sourcefile~accumulatoractioninterface.f90 sourcefile~make_itemspec.f90 make_itemSpec.F90 sourcefile~make_itemspec.f90->sourcefile~fieldspec.f90 sourcefile~sharedio.f90 SharedIO.F90 sourcefile~sharedio.f90->sourcefile~fieldbundleget.f90 sourcefile~test_addfieldspec.pf Test_AddFieldSpec.pf sourcefile~test_addfieldspec.pf->sourcefile~fieldspec.f90 sourcefile~test_bracketspec.pf Test_BracketSpec.pf sourcefile~test_bracketspec.pf->sourcefile~fieldspec.f90 sourcefile~test_fieldspec.pf Test_FieldSpec.pf sourcefile~test_fieldspec.pf->sourcefile~fieldspec.f90 sourcefile~test_modelverticalgrid.pf Test_ModelVerticalGrid.pf sourcefile~test_modelverticalgrid.pf->sourcefile~modelverticalgrid.f90 sourcefile~test_timeinterpolateaction.pf Test_TimeInterpolateAction.pf sourcefile~test_timeinterpolateaction.pf->sourcefile~fieldbundleget.f90 sourcefile~timeinterpolateaction.f90 TimeInterpolateAction.F90 sourcefile~timeinterpolateaction.f90->sourcefile~fieldbundleget.f90

Source Code

#include "MAPL_Generic.h"

module mapl3g_FieldCreate
   use mapl3g_VerticalStaggerLoc
   use mapl3g_FieldInfo
   use mapl3g_UngriddedDims
   use mapl_KeywordEnforcer
   use mapl_ErrorHandling
   use mapl3g_LU_Bound
   use esmf, MAPL_FieldEmptyCreate => ESMF_FieldEmptyCreate
   implicit none(type,external)
   private


   public :: MAPL_FieldCreate
   public :: MAPL_FieldEmptyComplete


   interface MAPL_FieldCreate
      procedure :: field_create
   end interface MAPL_FieldCreate

   interface MAPL_FieldEmptyComplete
      procedure :: field_empty_complete
   end interface MAPL_FieldEmptyComplete

contains

   function field_create( &
        geom, typekind, &
        unusable, & ! keyword enforcement
        ! Optional ESMF args
        gridToFieldMap, ungridded_dims, & 
        ! Optional MAPL args
        num_levels, vert_staggerloc, & 
        units, standard_name, long_name, &
        rc) result(field)

      type(ESMF_Field) :: field
      type(ESMF_Geom), intent(in) :: geom
      type(ESMF_TypeKind_Flag), intent(in) :: typekind
      class(KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(in) :: gridToFieldMap(:)
      type(UngriddedDims), optional, intent(in) :: ungridded_dims
      integer, optional, intent(in) :: num_levels
      type(VerticalStaggerLoc), optional, intent(in) :: vert_staggerloc
      character(len=*), optional, intent(in) :: units
      character(len=*), optional, intent(in) :: standard_name
      character(len=*), optional, intent(in) :: long_name
      integer, optional, intent(out) :: rc

      integer :: status

      field = MAPL_FieldEmptyCreate(_RC)
      _ASSERT(present(num_levels) .eqv. present(vert_staggerloc), "num_levels and vert_staggerloc must be both present or both absent")

      call ESMF_FieldEmptySet(field, geom=geom, _RC)
      call MAPL_FieldEmptyComplete(field, &
           typekind=typekind, gridToFieldMap=gridToFieldMap, ungridded_dims=ungridded_dims, &
           num_levels=num_levels, vert_staggerloc=vert_staggerloc, &
           units=units, standard_name=standard_name, long_name=long_name, &
           _RC)

      _RETURN(_SUCCESS)
   end function field_create

   subroutine field_empty_complete( field, &
        typekind, unusable, & 
        gridToFieldMap, ungridded_dims, &
        num_levels, vert_staggerloc, &
        units, standard_name, &
        long_name, &
        rc)

      type(ESMF_Field), intent(inout) :: field
      type(ESMF_TypeKind_Flag), intent(in) :: typekind
      class(KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(in) :: gridToFieldMap(:)
      type(UngriddedDims), optional, intent(in) :: ungridded_dims
      integer, optional, intent(in) :: num_levels
      type(VerticalStaggerLoc), optional, intent(in) :: vert_staggerloc
      character(len=*), optional, intent(in) :: units
      character(len=*), optional, intent(in) :: standard_name
      character(len=*), optional, intent(in) :: long_name
      integer, optional, intent(out) :: rc

      integer :: status
      type(LU_Bound), allocatable :: bounds(:)
      type(ESMF_Info) :: field_info

      bounds = make_bounds(num_levels=num_levels, ungridded_dims=ungridded_dims)
      call ESMF_FieldEmptyComplete(field, typekind=typekind, &
           gridToFieldMap=gridToFieldMap, &
           ungriddedLBound=bounds%lower, ungriddedUBound=bounds%upper, _RC)

      call ESMF_InfoGetFromHost(field, field_info, _RC)
      call MAPL_FieldInfoSetInternal(field_info, &
           ungridded_dims=ungridded_dims, &
           num_levels=num_levels, vert_staggerloc=vert_staggerloc, &
           units=units, standard_name=standard_name, long_name=long_name, _RC)

      _RETURN(_SUCCESS)
      _UNUSED_DUMMY(unusable)
   end subroutine field_empty_complete
   

   function make_bounds(num_levels, ungridded_dims) result(bounds)
      type(LU_Bound), allocatable :: bounds(:)
      integer, optional, intent(in) :: num_levels
      type(UngriddedDims), optional, intent(in) :: ungridded_dims

      bounds = [LU_Bound :: ]

      if (present(num_levels)) then
         bounds = [bounds, LU_Bound(1, num_levels)]
      end if

      if (present(ungridded_dims)) then
         bounds = [bounds, ungridded_dims%get_bounds()]
      end if

   end function make_bounds


end module mapl3g_FieldCreate