ESMF_InterArrayCreateTrg Function

private recursive function ESMF_InterArrayCreateTrg(farray1D, farray2D, farray3D, farray1DI8, farray2DI8, farray3DI8, farray1DR8, farray2DR8, farray3DR8, rc) result(InterArrayCreateTrg)

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional, target :: farray1D(:)
integer, intent(in), optional, target :: farray2D(:,:)
integer, intent(in), optional, target :: farray3D(:,:,:)
integer(kind=ESMF_KIND_I8), intent(in), optional, target :: farray1DI8(:)
integer(kind=ESMF_KIND_I8), intent(in), optional, target :: farray2DI8(:,:)
integer(kind=ESMF_KIND_I8), intent(in), optional, target :: farray3DI8(:,:,:)
real(kind=ESMF_KIND_R8), intent(in), optional, target :: farray1DR8(:)
real(kind=ESMF_KIND_R8), intent(in), optional, target :: farray2DR8(:,:)
real(kind=ESMF_KIND_R8), intent(in), optional, target :: farray3DR8(:,:,:)
integer, intent(out), optional :: rc

Return Value type(ESMF_InterArray)


Source Code

  recursive function ESMF_InterArrayCreateTrg(farray1D, farray2D, farray3D, &
    farray1DI8, farray2DI8, farray3DI8, farray1DR8, farray2DR8, farray3DR8, &
    rc) result (InterArrayCreateTrg)
!
! !ARGUMENTS:
    integer, target,               intent(in),  optional :: farray1D(:)
    integer, target,               intent(in),  optional :: farray2D(:,:)
    integer, target,               intent(in),  optional :: farray3D(:,:,:)
    integer(ESMF_KIND_I8), target, intent(in),  optional :: farray1DI8(:)
    integer(ESMF_KIND_I8), target, intent(in),  optional :: farray2DI8(:,:)
    integer(ESMF_KIND_I8), target, intent(in),  optional :: farray3DI8(:,:,:)
    real(ESMF_KIND_R8), target,    intent(in),  optional :: farray1DR8(:)
    real(ESMF_KIND_R8), target,    intent(in),  optional :: farray2DR8(:,:)
    real(ESMF_KIND_R8), target,    intent(in),  optional :: farray3DR8(:,:,:)
    integer,                       intent(out), optional :: rc
!
! !RETURN VALUE:
    type(ESMF_InterArray) :: InterArrayCreateTrg
!
! !DESCRIPTION:
!   Create an {\tt ESMF\_InterArray} from Fortran array.
!
!   The arguments are:
!   \begin{description}
!   \item[{[farray1D]}]
!     1D Fortran array of default integer kind.
!   \item[{[farray2D]}]
!     2D Fortran array of default integer kind.
!   \item[{[farray3D]}]
!     3D Fortran array of default integer kind.
!   \item[{[farray1DI8]}]
!     1D Fortran array of ESMF_TYPEKIND_I8.
!   \item[{[farray2DI8]}]
!     2D Fortran array of ESMF_TYPEKIND_I8.
!   \item[{[farray3DI8]}]
!     3D Fortran array of ESMF_TYPEKIND_I8.
!   \item[{[farray1DR8]}]
!     1D Fortran array of ESMF_TYPEKIND_R8.
!   \item[{[farray2DR8]}]
!     2D Fortran array of ESMF_TYPEKIND_R8.
!   \item[{[farray3DR8]}]
!     3D Fortran array of ESMF_TYPEKIND_R8.
!   \item[{[rc]}]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer                 :: localrc      ! local return code
    type(ESMF_InterArray)   :: array        ! opaque pointer to new C++ object
    integer, pointer        :: farray1DPtr(:)
    integer, pointer        :: farray2DPtr(:,:)
    integer, pointer        :: farray3DPtr(:,:,:)
    integer(ESMF_KIND_I8), pointer        :: farray1DI8Ptr(:)
    integer(ESMF_KIND_I8), pointer        :: farray2DI8Ptr(:,:)
    integer(ESMF_KIND_I8), pointer        :: farray3DI8Ptr(:,:,:)
    real(ESMF_KIND_R8), pointer           :: farray1DR8Ptr(:)
    real(ESMF_KIND_R8), pointer           :: farray2DR8Ptr(:,:)
    real(ESMF_KIND_R8), pointer           :: farray3DR8Ptr(:,:,:)

    ! initialize return code; assume routine not implemented
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! mark this InterArray as invalid
    call c_ESMC_InterArraySetInvalid(array, localrc)
    InterArrayCreateTrg = array
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! initialize
    nullify(farray1DPtr)
    nullify(farray2DPtr)
    nullify(farray3DPtr)
    nullify(farray1DI8Ptr)
    nullify(farray2DI8Ptr)
    nullify(farray3DI8Ptr)
    nullify(farray1DR8Ptr)
    nullify(farray2DR8Ptr)
    nullify(farray3DR8Ptr)

    if (present(farray1D)) farray1DPtr => farray1D
    if (present(farray2D)) farray2DPtr => farray2D
    if (present(farray3D)) farray3DPtr => farray3D
    if (present(farray1DI8)) farray1DI8Ptr => farray1DI8
    if (present(farray2DI8)) farray2DI8Ptr => farray2DI8
    if (present(farray3DI8)) farray3DI8Ptr => farray3DI8
    if (present(farray1DR8)) farray1DR8Ptr => farray1DR8
    if (present(farray2DR8)) farray2DR8Ptr => farray2DR8
    if (present(farray3DR8)) farray3DR8Ptr => farray3DR8

    ! create InterArray object
    array = ESMF_InterArrayCreate(farray1DPtr, farray2DPtr, farray3DPtr, &
      farray1DI8Ptr, farray2DI8Ptr, farray3DI8Ptr,  &
      farray1DR8Ptr, farray2DR8Ptr, farray3DR8Ptr,  &
      transferOwnership=.false., rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

    ! set return value
    InterArrayCreateTrg = array

    ! return successfully
    if (present(rc)) rc = ESMF_SUCCESS

  end function ESMF_InterArrayCreateTrg