MAPL_read_bundle Subroutine

public subroutine MAPL_read_bundle(bundle, file_tmpl, time, only_vars, regrid_method, noread, file_override, file_weights, 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
logical, intent(in), optional :: file_weights
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_data_collection ClientManager%add_data_collection proc~mapl_read_bundle->none~add_data_collection none~at~49 MAPLCollectionVector%at proc~mapl_read_bundle->none~at~49 none~done_collective_prefetch ClientManager%done_collective_prefetch proc~mapl_read_bundle->none~done_collective_prefetch none~find~12 MAPLDataCollection%find proc~mapl_read_bundle->none~find~12 none~get_time_info FileMetadataUtils%get_time_info proc~mapl_read_bundle->none~get_time_info none~process_data_from_file~2 MAPL_GriddedIO%process_data_from_file proc~mapl_read_bundle->none~process_data_from_file~2 none~push_back~19 GriddedIOitemVector%push_back proc~mapl_read_bundle->none~push_back~19 none~request_data_from_file~4 MAPL_GriddedIO%request_data_from_file proc~mapl_read_bundle->none~request_data_from_file~4 none~set_param~2 MAPL_GriddedIO%set_param proc~mapl_read_bundle->none~set_param~2 proc~fill_grads_template fill_grads_template proc~mapl_read_bundle->proc~fill_grads_template 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~2 main proc~main~2->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~2

Source Code

      subroutine MAPL_read_bundle(bundle,file_tmpl,time,only_vars,regrid_method,noread,file_override,file_weights,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
         logical, optional, intent(in) :: file_weights
         integer, optional, intent(out) :: rc

         integer :: status
         integer :: num_fields, metadata_id, collection_id, time_index, i, regrid_hints
         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_data_collection(trim(file_tmpl))

         metadata_id = MAPL_DataAddCollection(trim(file_tmpl))
         collection => DataCollections%at(metadata_id)
         _ASSERT(associated(collection), 'specified metadata_id not found')
         if (present(file_override)) file_name = file_override

         metadata => collection%find(trim(file_name), _RC)
         _ASSERT(associated(metadata), 'filename <'//trim(file_name)//'> not found')
         call metadata%get_time_info(timeVector=time_series,_RC)
         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)
         if (present(file_weights)) then
            if (file_weights) then
               regrid_hints = 0
               regrid_hints = IOR(regrid_hints,REGRID_HINT_FILE_WEIGHTS)
               call cfio%set_param(regrid_hints=regrid_hints)
            end if
         end if
         call cfio%request_data_from_file(trim(file_name),timeindex=time_index,rc=status)
         _VERIFY(status)
         call i_clients%done_collective_prefetch(_RC)
         call i_clients%wait(_RC)
         call cfio%process_data_from_file(rc=status)
         _VERIFY(status)

         _RETURN(_SUCCESS)

      end subroutine MAPL_read_bundle