ESMF_MeshIO Subroutine

public subroutine ESMF_MeshIO(vm, grid, staggerLoc, filename, array1, array2, array3, array4, array5, array6, spherical, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_VM), intent(inout) :: vm
type(ESMF_Grid), intent(inout) :: grid
type(ESMF_StaggerLoc), intent(in) :: staggerLoc
character(len=*), intent(in) :: filename
type(ESMF_Array), intent(inout), optional :: array1
type(ESMF_Array), intent(inout), optional :: array2
type(ESMF_Array), intent(inout), optional :: array3
type(ESMF_Array), intent(inout), optional :: array4
type(ESMF_Array), intent(inout), optional :: array5
type(ESMF_Array), intent(inout), optional :: array6
integer, intent(in), optional :: spherical
integer, intent(out), optional :: rc

Source Code

    subroutine ESMF_MeshIO(vm, grid, staggerLoc, filename, &
                         array1, array2, array3, array4, array5, array6, &
                         spherical, rc)
!
!
! !ARGUMENTS:
    type(ESMF_VM), intent(inout)                  :: vm
    type(ESMF_Grid), intent(inout)                :: grid
    type(ESMF_StaggerLoc), intent(in)             :: staggerLoc
    character(len = *), intent(in)                :: filename
    type(ESMF_Array), intent(inout), optional     :: array1
    type(ESMF_Array), intent(inout), optional     :: array2
    type(ESMF_Array), intent(inout), optional     :: array3
    type(ESMF_Array), intent(inout), optional     :: array4
    type(ESMF_Array), intent(inout), optional     :: array5
    type(ESMF_Array), intent(inout), optional     :: array6
    integer,                intent(in), optional  :: spherical
    integer,                intent(out), optional :: rc
!
! !DESCRIPTION:
!   Write the fields out for purview.  This function overcomes certain
!   difficulties in passing strings with an optional number of arguments.
!
!   \begin{description}
!   \item [vm]
!         Virutal machine
!   \item[staggerLoc]
!         stagger of field
!   \item[filename]
!         File (stub) to write results to
!   \item [{[array1-6]}]
!         Arrays to write as data
!   \item [{[spherical]}]
!         If == 1, then grid will be transformed to a 3d spherical manifold
!   \item [{[rc]}]
!         Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    integer                 :: localrc      ! local return code
    integer                 :: minidx
    integer                 :: lspherical

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

    lspherical = 0
    if (present(spherical)) lspherical = spherical

    minidx = 10

    if (.not. present(array6)) minidx = 6
    if (.not. present(array5)) minidx = 5
    if (.not. present(array4)) minidx = 4
    if (.not. present(array3)) minidx = 3
    if (.not. present(array2)) minidx = 2
    if (.not. present(array1)) minidx = 1

    select case (minidx)
      case (1)
        return
      case (2)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 1, filename, localrc, &
             array1, array1, array1, array1, array1, array1, lspherical)
      case (3)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 2, filename, localrc, &
             array1, array2, array1, array1, array1, array1, lspherical)
      case (4)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 3, filename, localrc, &
             array1, array2, array3, array1, array1, array1, lspherical)
      case (5)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 4, filename, localrc, &
             array1, array2, array3, array4, array1, array1, lspherical)
      case (6)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 5, filename, localrc, &
             array1, array2, array3, array4, array5, array1, lspherical)
      case (10)
        call c_ESMC_MeshIO(vm, grid, staggerLoc, 6, filename, localrc, &
             array1, array2, array3, array4, array5, array6, lspherical)
      case default
        localrc = ESMF_RC_NOT_IMPL
    end select
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
      ESMF_CONTEXT, rcToReturn=rc)) return

  end subroutine ESMF_MeshIO