MAPL_ServiceServices.F90 Source File


This file depends on

sourcefile~~mapl_serviceservices.f90~~EfferentGraph sourcefile~mapl_serviceservices.f90 MAPL_ServiceServices.F90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~mapl_serviceservices.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~mapl_providedserviceitemvector.f90 MAPL_ProvidedServiceItemVector.F90 sourcefile~mapl_serviceservices.f90->sourcefile~mapl_providedserviceitemvector.f90 sourcefile~mapl_requestedserviceitemvector.f90 MAPL_RequestedServiceItemVector.F90 sourcefile~mapl_serviceservices.f90->sourcefile~mapl_requestedserviceitemvector.f90 sourcefile~mapl_serviceconnectionitemvector.f90 MAPL_ServiceConnectionItemVector.F90 sourcefile~mapl_serviceservices.f90->sourcefile~mapl_serviceconnectionitemvector.f90 sourcefile~mapl_serviceservicestypes.f90 MAPL_ServiceServicesTypes.F90 sourcefile~mapl_serviceservices.f90->sourcefile~mapl_serviceservicestypes.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~mapl_providedserviceitemvector.f90->sourcefile~mapl_serviceservicestypes.f90 sourcefile~mapl_requestedserviceitemvector.f90->sourcefile~mapl_serviceservicestypes.f90 sourcefile~mapl_serviceconnectionitemvector.f90->sourcefile~mapl_serviceservicestypes.f90 sourcefile~mapl_serviceservicestypes.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90

Files dependent on this one

sourcefile~~mapl_serviceservices.f90~~AfferentGraph sourcefile~mapl_serviceservices.f90 MAPL_ServiceServices.F90 sourcefile~maplgeneric.f90 MaplGeneric.F90 sourcefile~maplgeneric.f90->sourcefile~mapl_serviceservices.f90 sourcefile~mapl_generic.f90 MAPL_Generic.F90 sourcefile~mapl_generic.f90->sourcefile~maplgeneric.f90 sourcefile~comp_testing_driver.f90 Comp_Testing_Driver.F90 sourcefile~comp_testing_driver.f90->sourcefile~mapl_generic.f90 sourcefile~mapl.f90 MAPL.F90 sourcefile~comp_testing_driver.f90->sourcefile~mapl.f90 sourcefile~mapl_capgridcomp.f90 MAPL_CapGridComp.F90 sourcefile~comp_testing_driver.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~extdatagridcompmod.f90 ExtDataGridCompMod.F90 sourcefile~extdatagridcompmod.f90->sourcefile~mapl_generic.f90 sourcefile~extdatagridcompng.f90 ExtDataGridCompNG.F90 sourcefile~extdatagridcompng.f90->sourcefile~mapl_generic.f90 sourcefile~mapl.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~extdatagridcompmod.f90 sourcefile~mapl_capgridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~mapl_historygridcomp.f90 MAPL_HistoryGridComp.F90 sourcefile~mapl_capgridcomp.f90->sourcefile~mapl_historygridcomp.f90 sourcefile~mapl_geosatmaskmod.f90 MAPL_GeosatMaskMod.F90 sourcefile~mapl_geosatmaskmod.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_historycollection.f90 MAPL_HistoryCollection.F90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_geosatmaskmod.f90 sourcefile~mapl_stationsamplermod.f90 MAPL_StationSamplerMod.F90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_stationsamplermod.f90 sourcefile~mapl_trajectorymod.f90 MAPL_TrajectoryMod.F90 sourcefile~mapl_historycollection.f90->sourcefile~mapl_trajectorymod.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_geosatmaskmod.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_historycollection.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_stationsamplermod.f90 sourcefile~mapl_historygridcomp.f90->sourcefile~mapl_trajectorymod.f90 sourcefile~mapl_orbgridcompmod.f90 MAPL_OrbGridCompMod.F90 sourcefile~mapl_orbgridcompmod.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_stationsamplermod.f90->sourcefile~mapl_generic.f90 sourcefile~mapl_trajectorymod.f90->sourcefile~mapl_generic.f90 sourcefile~capdriver.f90 CapDriver.F90 sourcefile~capdriver.f90->sourcefile~mapl.f90 sourcefile~extdatadriver.f90 ExtDataDriver.F90 sourcefile~extdatadriver.f90->sourcefile~mapl.f90 sourcefile~extdatadrivergridcomp.f90 ExtDataDriverGridComp.F90 sourcefile~extdatadrivergridcomp.f90->sourcefile~extdatagridcompmod.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~extdatagridcompng.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~mapl.f90 sourcefile~extdatadrivergridcomp.f90->sourcefile~mapl_historygridcomp.f90 sourcefile~extdatadrivermod.f90 ExtDataDriverMod.F90 sourcefile~extdatadrivermod.f90->sourcefile~mapl.f90 sourcefile~extdataroot_gridcomp.f90 ExtDataRoot_GridComp.F90 sourcefile~extdataroot_gridcomp.f90->sourcefile~mapl.f90 sourcefile~mapl_cap.f90 MAPL_Cap.F90 sourcefile~mapl_cap.f90->sourcefile~mapl_capgridcomp.f90 sourcefile~mapl_demo_fargparse.f90 MAPL_demo_fargparse.F90 sourcefile~mapl_demo_fargparse.f90->sourcefile~mapl.f90 sourcefile~mapl_geosatmaskmod_smod.f90 MAPL_GeosatMaskMod_smod.F90 sourcefile~mapl_geosatmaskmod_smod.f90->sourcefile~mapl_geosatmaskmod.f90 sourcefile~mapl_trajectorymod_smod.f90 MAPL_TrajectoryMod_smod.F90 sourcefile~mapl_trajectorymod_smod.f90->sourcefile~mapl_trajectorymod.f90 sourcefile~pfio_mapl_demo.f90 pfio_MAPL_demo.F90 sourcefile~pfio_mapl_demo.f90->sourcefile~mapl.f90 sourcefile~regrid_util.f90 Regrid_Util.F90 sourcefile~regrid_util.f90->sourcefile~mapl.f90 sourcefile~time_ave_util.f90 time_ave_util.F90 sourcefile~time_ave_util.f90->sourcefile~mapl.f90 sourcefile~ut_extdata.f90 ut_ExtData.F90 sourcefile~ut_extdata.f90->sourcefile~extdatagridcompmod.f90 sourcefile~varspecdescription.f90 VarspecDescription.F90 sourcefile~varspecdescription.f90->sourcefile~mapl.f90

Source Code

#include "MAPL_ErrLog.h"
module mapl_ServiceServices
  use ESMF
  use MAPL_ExceptionHandling
  use mapl_ServiceConnectionItemVector
  use mapl_ProvidedServiceItemVector
  use mapl_RequestedServiceItemVector
  use mapl_ServiceServicesTypes

  implicit none
  private

  public ProvidedServiceGet
  public ProvidedServiceSet
  public RequestedServiceGet
  public FillRequestBundle

contains

  subroutine ProvidedServiceGet(provider_list, advertised_service, bundle, rc)
    type(ProvidedServiceItemVector), intent(IN) :: provider_list
    character(len=*), intent(IN) :: advertised_service
    type(ESMF_FieldBundle), intent(OUT) :: bundle
    integer, optional, intent(out) :: rc
    
    logical :: found
    type (ProvidedServiceItemVectorIterator) :: iter
    type (ProvidedServiceType), pointer :: item
    
    _ASSERT(provider_list%size()>0,'provider_list should not be empty')
    
    found = .false.
    iter = provider_list%begin()
    ! loop over provided services
    do while (iter /= provider_list%end())
       item => iter%get()
       if(item%service_name == advertised_service) then
          found = .true.
          bundle = item%bundle
          exit
       end if
    end do
    _ASSERT(found, 'No match found for service')
    call iter%next()
    _RETURN(_SUCCESS)
  end subroutine ProvidedServiceGet
   
  subroutine ProvidedServiceSet(provider_list, state, rc)
    type(ProvidedServiceItemVector), intent(IN) :: provider_list
    type(ESMF_State), intent(IN) :: state
    integer, optional, intent(out) :: rc
    
    integer :: status
    type (ProvidedServiceItemVectorIterator) :: iter
    type (ProvidedServiceType), pointer :: item
    
    _ASSERT(provider_list%size()>0,'provider_list should not be empty')
    
    iter = provider_list%begin()
    ! loop over provided services
    do while (iter /= provider_list%end())
       item => iter%get()
       call ESMF_StateGet(state, item%bundle_name, &
            item%bundle, rc=status)
       _VERIFY(status)
       call iter%next()
    end do

    _RETURN(_SUCCESS)
  end subroutine ProvidedServiceSet
   
  subroutine RequestedServiceGet(request_list, service, bundle, rc)
    type(RequestedServiceItemVector), intent(IN) :: request_list
    character(len=*), intent(IN) :: service
    type(ESMF_FieldBundle), intent(OUT) :: bundle
    integer, optional, intent(out) :: rc
    
    logical :: found
    type (RequestedServiceItemVectorIterator) :: iter
    type (RequestedServiceType), pointer :: item
    
    _ASSERT(request_list%size()>0,'request_list should not be empty')
    
    found = .false.
    iter = request_list%begin()
    ! loop over requested services
    do while (iter /= request_list%end())
       item => iter%get()
       if(item%service_name == service) then
          found = .true.
          bundle = item%bundle
          exit
       end if
    END DO
    _ASSERT(found, 'No match found for service')
    _RETURN(_SUCCESS)
  end subroutine RequestedServiceGet
   
  subroutine FillRequestBundle(request_list, state, rc)
    type(RequestedServiceItemVector), intent(INOUT) :: request_list
    type(ESMF_State), intent(IN) :: state
    integer, optional, intent(out) :: rc
    
    integer :: status
    integer :: i, nl
    type(ESMF_Field), allocatable :: fields(:)
    type (RequestedServiceItemVectorIterator) :: iter
    type (RequestedServiceType), pointer :: item
    
    _ASSERT(request_list%size()>0,'request_list should not be empty')

    iter = request_list%begin()
    ! loop over requested services
    do while (iter /= request_list%end())
       item => iter%get()
       if (allocated(item%var_list)) then
          nl = size(item%var_list)
          allocate(fields(nl), stat=status)
          _VERIFY(status)
          do i=1, nl
             call ESMF_StateGet(state, item%var_list(i), &
                  fields(i), rc=status)
             _VERIFY(status)
          end do
          call ESMF_FieldBundleAdd(item%bundle, fields, rc=status)
          _VERIFY(status)
          deallocate(fields)
       end if
       call iter%next()
    end do
    
    _RETURN(_SUCCESS)
  end subroutine FillRequestBundle
   
end module mapl_ServiceServices