ESMF_FieldPrint Subroutine

public subroutine ESMF_FieldPrint(field, keywordEnforcer, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_Field), intent(in) :: field
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_FieldPrint(field, keywordEnforcer, rc)
!
!
! !ARGUMENTS:
    type(ESMF_Field), intent(in)            :: field
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
    integer,          intent(out), optional :: rc
!
! !STATUS:
! \begin{itemize}
! \item\apiStatusCompatibleVersion{5.2.0r}
! \end{itemize}
!
! !DESCRIPTION:
!     Prints information about the {\tt field} to {\tt stdout}.
!     This subroutine goes through the internal data members of a field
!     data type and prints information of each data member.
!
!     The arguments are:
!     \begin{description}
!     \item [field]
!           An {\tt ESMF\_Field} object.
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOP

    character(len=ESMF_MAXSTR)      :: name, str
    type(ESMF_FieldType), pointer   :: fp
    integer                         :: i, localrc
    integer                         :: gridrank, arrayrank
    character(len=6)                :: defaultopts
    type(ESMF_Status)               :: fieldstatus

!       Initialize
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    ! check variables
    ESMF_INIT_CHECK_DEEP(ESMF_FieldGetInit,field,rc)

    ! print option is not implemented, but it has to pass to c_ESMC_BasePrint()
    defaultopts = "brief"

    fp => field%ftypep

    call ESMF_BaseGetStatus(fp%base, fieldstatus, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

    !nsc call ESMF_LogWrite("Field Print:", ESMF_LOGMSG_INFO)
    write(ESMF_UtilIOStdout,*) "Field Print Starts ====>"

    call ESMF_StatusString(fieldstatus, str, localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    write(ESMF_UtilIOStdout,*)  "Field base status = ", trim(str)

    if (fieldstatus .ne. ESMF_STATUS_READY) then
      write(ESMF_UtilIOStdout,*) "Empty or Uninitialized Field"
      write(ESMF_UtilIOStdout,*) "Field Print Ends   ====>"
      if (present(rc)) rc = ESMF_SUCCESS
      return
    endif

    if (.not. associated(field%ftypep)) then
      !jw  call ESMF_LogWrite("Empty or Uninitialized Field", ESMF_LOGMSG_INFO)
      write(ESMF_UtilIOStdout,*) "Empty or Uninitialized Field"
      write(ESMF_UtilIOStdout,*) "Field Print Ends   ====>"
      if (present(rc)) rc = ESMF_SUCCESS
      return
    endif

    call ESMF_GetName(fp%base, name, localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return
    !jw  write(msgbuf, *)  "  Name = '",  trim(name), "'"
    !jw  call ESMF_LogWrite(msgbuf, ESMF_LOGMSG_INFO)
    write(ESMF_UtilIOStdout,*)  "  Name = '",  trim(name), "'"

    call ESMF_BasePrint(fp%base, options=defaultopts, rc=localrc)
    if (ESMF_LogFoundError(localrc, &
        ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT, rcToReturn=rc)) return

    write(ESMF_UtilIOStdout,*)  "Field status = ", fp%status
    if (fp%status .eq. ESMF_FIELDSTATUS_GRIDSET .or. &
         fp%status .eq. ESMF_FIELDSTATUS_COMPLETE) then
!      call ESMF_GeomPrint(fp%geom, "", localrc)
!      if (ESMF_LogFoundError(localrc, &
!          ESMF_ERR_PASSTHRU, &
!          ESMF_CONTEXT, rcToReturn=rc)) return
      call ESMF_GeomGet(fp%geom, dimCount=gridrank, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
          ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      write(ESMF_UtilIOStdout,*) "gridrank = ", gridrank
    endif

    if (fp%status .eq. ESMF_FIELDSTATUS_COMPLETE) then
      call ESMF_ArrayPrint(fp%array, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
          ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      call ESMF_ArrayGet(fp%array, rank=arrayrank, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
          ESMF_ERR_PASSTHRU, &
          ESMF_CONTEXT, rcToReturn=rc)) return
      write(ESMF_UtilIOStdout,*) "arrayrank = ", arrayrank
    endif

    write(ESMF_UtilIOStdout,*) "gridToFieldMap ungriddedLBound ungriddedUBound totalLWidth", &
          " totalUWidth"
    do i = 1, ESMF_MAXDIM
      write(ESMF_UtilIOStdout,*) fp%gridToFieldMap(i), fp%ungriddedLBound(i), fp%ungriddedUBound(i), &
            "    ", fp%totalLWidth(i), fp%totalUWidth(i)
    enddo
    write(ESMF_UtilIOStdout,*) "Field Print Ends   ====>"

    if (present(rc)) rc = ESMF_SUCCESS

  end subroutine ESMF_FieldPrint