union_platform Function

public function union_platform(a, b, rc)

Arguments

Type IntentOptional Attributes Name
type(obs_platform), intent(in) :: a
type(obs_platform), intent(in) :: b
integer, intent(out), optional :: rc

Return Value type(obs_platform)


Calls

proc~~union_platform~~CallsGraph proc~union_platform union_platform proc~copy_platform_nckeys copy_platform_nckeys proc~union_platform->proc~copy_platform_nckeys proc~mapl_return MAPL_Return proc~union_platform->proc~mapl_return proc~mapl_verify MAPL_Verify proc~union_platform->proc~mapl_verify proc~copy_platform_nckeys->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

Source Code

  function union_platform(a, b, rc)
    type(obs_platform) :: union_platform
    type(obs_platform), intent(in)  :: a
    type(obs_platform), intent(in)  :: b
    integer, optional, intent(out) :: rc

    character (len=ESMF_MAXSTR), allocatable :: field_name_loc(:,:)
    integer :: nfield, nentry_name
    integer, allocatable :: tag(:)
    integer :: i, j, k
    integer :: status

    union_platform = copy_platform_nckeys(a, _RC)
    nfield = a%ngeoval + b%ngeoval
    allocate (tag(b%ngeoval))

    tag(:)=1    ! true
    k=nfield
    do j=1, b%ngeoval
       do i=1, a%ngeoval
          if ( trim(b%field_name(1,j)) == trim(a%field_name(1,i)) ) then
             tag(j)=0
          endif
       enddo
       if (tag(j)==0) k=k-1
    enddo
    union_platform%ngeoval=k
    nfield=k
    nentry_name=union_platform%nentry_name
    if ( allocated (union_platform%field_name) ) deallocate(union_platform%field_name)
    allocate(union_platform%field_name(nentry_name, nfield))
    do i=1, a%ngeoval
       union_platform%field_name(:,i) = a%field_name(:,i)
    enddo
    if (nfield>a%ngeoval) then
       k = a%ngeoval
       do j=1, b%ngeoval
          if (tag(j)==1) then
             k = k + 1
             union_platform%field_name(:,k) = b%field_name(:,j)
          end if
       enddo
    end if
    _RETURN(_SUCCESS)

  end function union_platform