ESMF_FeatureAllocArg Subroutine

public subroutine ESMF_FeatureAllocArg(n, a, indicies, tfs, dts, rc)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n
real, intent(out), allocatable :: a(:)
integer, intent(out), allocatable :: indicies(:)
logical, intent(out), allocatable :: tfs(:)
type(ESMF_AllocDType), intent(out), allocatable :: dts(:)
integer, intent(out) :: rc

Source Code

  subroutine ESMF_FeatureAllocArg (n, a, indicies, tfs, dts, rc)
    integer,                   intent(in)  :: n
    ! F2003 and F95+TR15581 allocatable dummy arguments except for strings
    real,         allocatable, intent(out) :: a(:)
    integer,      allocatable, intent(out) :: indicies(:)
    logical,      allocatable, intent(out) :: tfs(:)
    type(ESMF_AllocDType), allocatable, intent(out) :: dts(:)
    integer,                   intent(out) :: rc

    integer :: i
    integer :: memstat

    allocate (a(n), indicies(n), tfs(n), dts(n), stat=memstat)
    if (ESMF_LogFoundAllocError (memstat,  &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    do, i=1, n
      a(i) = i
      indicies(i) = i
      tfs = mod (i, 1) == 1
      allocate (dts(i)%a(10), dts(i)%indicies(20), dts(i)%tfs(20), dts(i)%chars(32), stat=memstat)
      if (ESMF_LogFoundAllocError (memstat,  &
          ESMF_CONTEXT,  &
          rcToReturn=rc)) return
      dts(i)%a = 0.0
      dts(i)%indicies = 0
      dts(i)%tfs = .false.
      dts(i)%chars = ' '
    end do

    rc = ESMF_SUCCESS

  end subroutine ESMF_FeatureAllocArg