fillArray1d Subroutine

subroutine fillArray1d(arrayToFill, arrayToFillPtr, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Array), intent(in) :: arrayToFill
real(kind=ESMF_KIND_R8), intent(out), pointer :: arrayToFillPtr(:)
integer, intent(out) :: rc

Source Code

  subroutine fillArray1d(arrayToFill, arrayToFillPtr, rc)
    ! Fills a 1-d ESMF_Array with data (localPet times index), and returns a pointer to
    ! the Array's data
    !
    ! Assumes 1 DE per PET; works best if arrayToFill is created with ESMF_INDEX_GLOBAL

    type(ESMF_Array), intent(in) :: arrayToFill
    real(ESMF_KIND_R8), pointer, intent(out) :: arrayToFillPtr(:)
    integer, intent(out) :: rc

    integer :: i

    call ESMF_ArrayGet(arrayToFill, farrayPtr=arrayToFillPtr, rc=rc)
    if (rc /= ESMF_SUCCESS) return

    do i = lbound(arrayToFillPtr, 1), ubound(arrayToFillPtr, 1)
       arrayToFillPtr(i) = localPet*100._ESMF_KIND_R8 + i
    end do

  end subroutine fillArray1d