fillin_primary Subroutine

public subroutine fillin_primary(this, item_name, base_name, primary_item, time, clock, unusable, rc)

Type Bound

ExtDataOldTypesCreator

Arguments

Type IntentOptional Attributes Name
class(ExtDataOldTypesCreator), intent(inout), target :: this
character(len=*), intent(in) :: item_name
character(len=*), intent(in) :: base_name
type(PrimaryExport), intent(inout) :: primary_item
type(ESMF_Time), intent(inout) :: time
type(ESMF_Clock), intent(inout) :: clock
class(KeywordEnforcer), intent(in), optional :: unusable
integer, intent(out), optional :: rc

Calls

proc~~fillin_primary~~CallsGraph proc~fillin_primary ExtDataOldTypesCreator%fillin_primary interface~mapl_assert MAPL_Assert proc~fillin_primary->interface~mapl_assert none~at~299 ExtDataRuleMap%at proc~fillin_primary->none~at~299 none~create_from_parameters ExtDataPointerUpdate%create_from_parameters proc~fillin_primary->none~create_from_parameters none~detect_metadata ExtDataFileStream%detect_metadata proc~fillin_primary->none~detect_metadata none~initialize~3 ExtDataAbstractFileHandler%initialize proc~fillin_primary->none~initialize~3 none~set_defaults ExtDataTimeSample%set_defaults proc~fillin_primary->none~set_defaults none~set_parameters ExtDataBracket%set_parameters proc~fillin_primary->none~set_parameters proc~mapl_return MAPL_Return proc~fillin_primary->proc~mapl_return proc~mapl_verify MAPL_Verify proc~fillin_primary->proc~mapl_verify proc~regrid_method_string_to_int regrid_method_string_to_int proc~fillin_primary->proc~regrid_method_string_to_int none~find~63 ExtDataRuleMap%find none~at~299->none~find~63 none~create_from_parameters->proc~mapl_return none~create_from_parameters->proc~mapl_verify ESMF_TimeGet ESMF_TimeGet none~create_from_parameters->ESMF_TimeGet ESMF_TimeSet ESMF_TimeSet none~create_from_parameters->ESMF_TimeSet proc~string_to_esmf_timeinterval string_to_esmf_timeinterval none~create_from_parameters->proc~string_to_esmf_timeinterval proc~string_to_integer_time string_to_integer_time none~create_from_parameters->proc~string_to_integer_time none~detect_metadata->interface~mapl_assert none~detect_metadata->proc~mapl_return none~detect_metadata->proc~mapl_verify none~at~210 MAPLCollectionVector%at none~detect_metadata->none~at~210 none~find~54 MAPLDataCollection%find none~detect_metadata->none~find~54 proc~get_time_info FileMetadataUtils%get_time_info none~detect_metadata->proc~get_time_info none~set_defaults->proc~mapl_return none~set_defaults->proc~mapl_verify none~set_parameters->proc~mapl_return at at proc~mapl_return->at insert insert proc~mapl_return->insert proc~mapl_throw_exception MAPL_throw_exception proc~mapl_return->proc~mapl_throw_exception proc~mapl_verify->proc~mapl_throw_exception ESMF_UtilStringUpperCase ESMF_UtilStringUpperCase proc~regrid_method_string_to_int->ESMF_UtilStringUpperCase

Source Code

   subroutine fillin_primary(this,item_name,base_name,primary_item,time,clock,unusable,rc)
      class(ExtDataOldTypesCreator), target, intent(inout) :: this
      character(len=*), intent(in) :: item_name
      character(len=*), intent(in) :: base_name
      type(PrimaryExport), intent(inout) :: primary_item
      type(ESMF_Time), intent(inout) :: time
      type(ESMF_Clock), intent(inout) :: clock
      class(KeywordEnforcer), optional, intent(in) :: unusable
      integer, optional, intent(out) :: rc

      type(ExtDataRule), pointer :: rule
      type(ExtDataFileStream),  pointer :: dataset
      type(ExtDataTimeSample), pointer :: time_sample
      type(ExtDataTimeSample), target :: default_time_sample
      type(ExtDataSimpleFileHandler) :: simple_handler
      type(ExtDataClimFileHandler) :: clim_handler
      integer :: status, semi_pos
      logical :: disable_interpolation, get_range, exact

      _UNUSED_DUMMY(unusable)
      rule => this%rule_map%at(trim(item_name))
      time_sample => this%sample_map%at(rule%sample_key)

      if(.not.associated(time_sample)) then
        call default_time_sample%set_defaults()
        time_sample=>default_time_sample
      end if
      primary_item%vartype = MAPL_FieldItem
      if (allocated(rule%vector_partner)) primary_item%vartype = MAPL_VectorField
      primary_item%name = trim(base_name)
      if (primary_item%vartype == MAPL_VectorField) then
         primary_item%vcomp1 = trim(base_name)
         primary_item%vcomp2 = trim(rule%vector_partner)
         primary_item%var = rule%file_var
         primary_item%fcomp1 = rule%file_var
         primary_item%fcomp2 = rule%vector_file_partner
         primary_item%fileVars%itemType = ItemTypeVector
         primary_item%fileVars%xname  = trim(rule%file_var)
         primary_item%fileVars%yname  = trim(rule%vector_file_partner)
      else
         primary_item%vcomp1 = trim(base_name)
         primary_item%var = rule%file_var
         primary_item%fcomp1 = rule%file_var
         primary_item%fileVars%itemType = ItemTypeScalar
         primary_item%fileVars%xname  = trim(rule%file_var)
      end if

      ! regrid method
      if (index(rule%regrid_method,"FRACTION;")>0) then
         semi_pos = index(rule%regrid_method,";")
         read(rule%regrid_method(semi_pos+1:),*) primary_item%fracVal
         primary_item%trans = REGRID_METHOD_FRACTION
      else
         primary_item%trans = regrid_method_string_to_int(rule%regrid_method)
      end if
      _ASSERT(primary_item%trans/=UNSPECIFIED_REGRID_METHOD,"improper regrid method chosen")

      if (trim(time_sample%extrap_outside) =="clim") then
         primary_item%cycling=.true.
      else if (trim(time_sample%extrap_outside) == "persist_closest") then
         primary_item%persist_closest=.true.
         primary_item%cycling=.false.
      else if (trim(time_sample%extrap_outside) == "none") then
         primary_item%cycling=.false.
         primary_item%persist_closest=.false.
      end if

      allocate(primary_item%source_time,source=time_sample%source_time)
      ! new refresh
      call primary_item%update_freq%create_from_parameters(time_sample%refresh_time, &
           time_sample%refresh_frequency, time_sample%refresh_offset, time, clock, _RC)

      disable_interpolation =  .not.time_sample%time_interpolation
      exact = time_sample%exact

      call primary_item%modelGridFields%comp1%set_parameters(linear_trans=rule%linear_trans,disable_interpolation=disable_interpolation,exact=exact)
      call primary_item%modelGridFields%comp2%set_parameters(linear_trans=rule%linear_trans,disable_interpolation=disable_interpolation,exact=exact)

      ! file_template
      primary_item%isConst = .false.
      if (index(rule%collection,"/dev/null")==0) then

         if ( ASSOCIATED(this%file_stream_map%at(trim(rule%collection))) ) then
           dataset => this%file_stream_map%at(trim(rule%collection))
         else
           _FAIL("ExtData problem with collection "//TRIM(rule%collection))
         end if

         primary_item%file_template = dataset%file_template
         get_range = trim(time_sample%extrap_outside) /= "none"
         call dataset%detect_metadata(primary_item%file_metadata,time,rule%multi_rule,get_range=get_range,_RC)
      else
         primary_item%file_template = rule%collection
      end if

      if (index(rule%collection,'/dev/null') /= 0) then
         primary_item%isConst = .true.
         primary_item%const=rule%linear_trans(1)
      else
         if (primary_item%cycling) then
            call clim_handler%initialize(dataset,_RC)
            allocate(primary_item%filestream,source=clim_handler)
         else
            call simple_handler%initialize(dataset,persist_closest=primary_item%persist_closest,_RC)
            allocate(primary_item%filestream,source=simple_handler)
         end if
      end if

      primary_item%fail_on_missing_file = rule%fail_on_missing_file

      _RETURN(_SUCCESS)

   end subroutine fillin_primary