MAPL_read_bundle Subroutine

public subroutine MAPL_read_bundle(bundle, file_tmpl, time, only_vars, regrid_method, noread, file_override, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_FieldBundle), intent(inout) :: bundle
character(len=*), intent(in) :: file_tmpl
type(ESMF_Time), intent(in) :: time
character(len=*), intent(in), optional :: only_vars
integer, intent(in), optional :: regrid_method
logical, intent(in), optional :: noread
character(len=*), intent(in), optional :: file_override
integer, intent(out), optional :: rc

Calls

proc~~mapl_read_bundle~~CallsGraph proc~mapl_read_bundle MAPL_read_bundle esmf_fieldbundleget esmf_fieldbundleget proc~mapl_read_bundle->esmf_fieldbundleget interface~mapl_assert MAPL_Assert proc~mapl_read_bundle->interface~mapl_assert none~add_ext_collection ClientManager%add_ext_collection proc~mapl_read_bundle->none~add_ext_collection none~at~324 MAPLCollectionVector%at proc~mapl_read_bundle->none~at~324 none~done_collective_prefetch ClientManager%done_collective_prefetch proc~mapl_read_bundle->none~done_collective_prefetch none~find~72 MAPLDataCollection%find proc~mapl_read_bundle->none~find~72 none~process_data_from_file MAPL_GriddedIO%process_data_from_file proc~mapl_read_bundle->none~process_data_from_file none~push_back~55 GriddedIOitemVector%push_back proc~mapl_read_bundle->none~push_back~55 none~request_data_from_file MAPL_GriddedIO%request_data_from_file proc~mapl_read_bundle->none~request_data_from_file none~set_param MAPL_GriddedIO%set_param proc~mapl_read_bundle->none~set_param proc~fill_grads_template fill_grads_template proc~mapl_read_bundle->proc~fill_grads_template proc~get_time_info FileMetadataUtils%get_time_info proc~mapl_read_bundle->proc~get_time_info proc~mapl_create_bundle_from_metdata_id MAPL_create_bundle_from_metdata_id proc~mapl_read_bundle->proc~mapl_create_bundle_from_metdata_id proc~mapl_dataaddcollection MAPL_DataAddCollection proc~mapl_read_bundle->proc~mapl_dataaddcollection proc~mapl_return MAPL_Return proc~mapl_read_bundle->proc~mapl_return proc~mapl_verify MAPL_Verify proc~mapl_read_bundle->proc~mapl_verify

Called by

proc~~mapl_read_bundle~~CalledByGraph proc~mapl_read_bundle MAPL_read_bundle proc~main main proc~main->proc~mapl_read_bundle program~time_ave time_ave program~time_ave->proc~mapl_read_bundle program~ut_regridding ut_ReGridding program~ut_regridding->proc~mapl_read_bundle program~regrid_util Regrid_Util program~regrid_util->proc~main

Source Code

      subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread,file_override,rc)
         type(ESMF_FieldBundle), intent(inout) :: bundle
         character(len=*), intent(in) :: file_tmpl
         type(ESMF_Time), intent(in) :: time
         character(len=*), optional, intent(in) :: only_vars
         integer, optional, intent(in) :: regrid_method
         logical, optional, intent(in) :: noread
         character(len=*), optional, intent(in) :: file_override
         integer, optional, intent(out) :: rc

         integer :: status
         integer :: num_fields, metadata_id, collection_id, time_index, i
         type(MAPL_GriddedIO) :: cfio
         character(len=ESMF_MAXPATHLEN) :: file_name
         type(MAPLDataCollection), pointer :: collection => null()
         type(fileMetaDataUtils), pointer :: metadata
         type(ESMF_Time), allocatable :: time_series(:)
         type(GriddedIOItemVector)            :: items
         character(len=ESMF_MAXSTR), allocatable :: field_names(:)
         type(GriddedIOitem) :: item

         call fill_grads_template(file_name,file_tmpl,time=time,rc=status)
         _VERIFY(status)

         collection_id=i_clients%add_ext_collection(trim(file_tmpl))

         metadata_id = MAPL_DataAddCollection(trim(file_tmpl))
         collection => DataCollections%at(metadata_id)
         if (present(file_override)) file_name = file_override
        
         metadata => collection%find(trim(file_name), _RC)
         call metadata%get_time_info(timeVector=time_series,rc=status)
         _VERIFY(status)
         time_index=-1
         do i=1,size(time_series)
            if (time==time_series(i)) then
               time_index=i
               exit
            end if
         end do
         _ASSERT(time_index/=-1,"Time not found on file "//trim(file_name))
         deallocate(time_series)

         call ESMF_FieldBundleGet(bundle,fieldCount=num_fields,rc=status)
         _VERIFY(status)
         if (num_fields ==0) then
            call MAPL_create_bundle_from_metdata_id(bundle,metadata_id,file_name,only_vars=only_vars,rc=status)
            _VERIFY(status)
         end if
         if (present(noread)) then
            if (noread) then
               _RETURN(_SUCCESS)
            end if
         end if

         call ESMF_FieldBundleGet(bundle,fieldCount=num_fields,rc=status)
         _VERIFY(status)
         allocate(field_names(num_fields))
         call ESMF_FieldBundleGet(bundle,fieldnamelist=field_names,rc=status)
         _VERIFY(status)
         do i=1,num_fields
            item%itemTYpe=ItemTYpeScalar
            item%xname=trim(field_names(i))
            call items%push_back(item)
         enddo


         cfio=MAPL_GriddedIO(output_bundle=bundle,metadata_collection_id=metadata_id,read_collection_id=collection_id,items=items)
         call cfio%set_param(regrid_method=regrid_method)
         call cfio%request_data_from_file(trim(file_name),timeindex=time_index,rc=status)
         _VERIFY(status)
         call i_clients%done_collective_prefetch()
         call i_clients%wait()
         call cfio%process_data_from_file(rc=status)
         _VERIFY(status)

         _RETURN(_SUCCESS)

      end subroutine MAPL_read_bundle