ESMF_StateItemPrint Subroutine

public subroutine ESMF_StateItemPrint(stateItem, header, prefixstr, longflag, debugflag, unit, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_StateItem), intent(in), target :: stateItem
character(len=*), intent(in) :: header
character(len=*), intent(in) :: prefixstr
logical, intent(in) :: longflag
logical, intent(in) :: debugflag
integer, intent(in), optional :: unit
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_StateItemPrint (stateItem, header, prefixstr,  &
      longflag, debugflag, unit, rc)
!
! !ARGUMENTS:
    type(ESMF_StateItem), intent(in), target    :: stateItem
    character(*),         intent(in)            :: header
    character(*),         intent(in)            :: prefixstr
    logical,              intent(in)            :: longflag
    logical,              intent(in)            :: debugflag
    integer,              intent(in),  optional :: unit
    integer,              intent(out), optional :: rc
!         
! !DESCRIPTION:
!   Print a StateItem.
!
!   The arguments are:
!   \begin{description}
!   \item[stateItem]
!     {\tt ESMF\_StateItem} queried.
!   \item[header]
!     Title line
!   \item[prefixstr]
!     Leading characters for output string (for indentation levels)
!   \item[longflag]
!     Print additional information such as proxyflag
!   \item[longflag]
!     Print additional information such as VMId
!   \item[unit]
!     Fortran unit number
!   \item[{[rc]}]
!     Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!   \end{description}
!
!EOPI
!------------------------------------------------------------------------------
    type(ESMF_VMId) :: vmid
    type(ESMF_Array),           pointer :: arrayp
    type(ESMF_ArrayBundle),     pointer :: abundlep
    type(ESMF_FieldType),       pointer :: fieldp
    type(ESMF_FieldBundleType), pointer :: fbundlep
    type(ESMF_RouteHandle),     pointer :: rhandlep
    type(ESMF_StateClass),      pointer :: statep

    integer                     :: localrc      ! local return code
    integer                     :: localunit
    character(2*ESMF_MAXSTR)    :: outbuf

    ! Initialize return code; assume failure until success is certain
    localrc = ESMF_RC_NOT_IMPL
    if (present(rc)) rc = ESMF_RC_NOT_IMPL

    localunit = ESMF_UtilIOStdout
    if (present (unit)) then
      localunit = unit
    end if

    write (localunit, *) prefixstr, header, 'name: ', trim (stateItem%namep)

    outbuf = prefixstr // "          type:"

    select case (stateItem%otype%ot)
    case (ESMF_STATEITEM_FIELDBUNDLE%ot)
        outbuf = trim (outbuf) // " FieldBundle"
    case (ESMF_STATEITEM_FIELD%ot)
        outbuf = trim (outbuf) // " Field"
    case (ESMF_STATEITEM_ARRAY%ot)
        outbuf = trim (outbuf) // " Array"
    case (ESMF_STATEITEM_ARRAYBUNDLE%ot)
        outbuf = trim (outbuf) // " ArrayBundle"
    case (ESMF_STATEITEM_ROUTEHANDLE%ot)
        outbuf = trim (outbuf) // " Route handle"
    case (ESMF_STATEITEM_STATE%ot)
        outbuf = trim (outbuf) // " State"
#if 0
    case (ESMF_STATEITEM_NAME%ot)
        outbuf = trim (outbuf) // " Placeholder name"
    case (ESMF_STATEITEM_INDIRECT%ot)
        outbuf = trim (outbuf) // " Indirect Field inside a FieldBundle"
#endif
    case (ESMF_STATEITEM_UNKNOWN%ot)
        outbuf = trim (outbuf) // " Unknown"
    case (ESMF_STATEITEM_NOTFOUND%ot)
        outbuf = trim (outbuf) // " Not found"
    case default
        outbuf = trim (outbuf) // " (bad type value)"
    end select

    if (longflag) then
      outbuf = trim (outbuf) //  &
            ", proxy flag: " // merge ("yes", "no ", stateItem%proxyFlag)

    end if

    write (localunit,*) trim(outbuf)

    if (debugflag) then

      select case (stateItem%otype%ot)
      case (ESMF_STATEITEM_FIELDBUNDLE%ot)
        fbundlep => stateItem%datap%fbp%this
        call ESMF_BaseGetVMId (fbundlep%base, vmid, rc=localrc)

      case (ESMF_STATEITEM_FIELD%ot)
        fieldp => stateItem%datap%fp%ftypep

        call ESMF_BaseGetVMId (fieldp%base, vmid, rc=localrc)
        call c_ESMC_BasePrint(fieldp, 1, "debug", ESMF_FALSE, "", ESMF_FALSE, localrc)

      case (ESMF_STATEITEM_ARRAY%ot)
        arrayp => stateItem%datap%ap
        call c_ESMC_GetVMId (arrayp, vmid, localrc)

      case (ESMF_STATEITEM_ARRAYBUNDLE%ot)
        abundlep => stateItem%datap%abp
        call c_ESMC_GetVMId (abundlep, vmid, localrc)

      case (ESMF_STATEITEM_ROUTEHANDLE%ot)
        rhandlep => stateItem%datap%rp
        call c_ESMC_GetVMId (rhandlep, vmid, localrc)

      case (ESMF_STATEITEM_STATE%ot)
        statep => stateItem%datap%spp
        call ESMF_BaseGetVMId (statep%base, vmid, rc=localrc)

      end select
      if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

      call ESMF_UtilIOUnitFlush (localunit, rc=localrc)
      if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

      call c_esmc_vmidprint (vmid, localrc)
      if (ESMF_LogFoundError(localrc, &
         ESMF_ERR_PASSTHRU, &
         ESMF_CONTEXT, rcToReturn=rc)) return

    end if

    ! Return successfully
    if (present(rc)) rc = ESMF_SUCCESS
 
  end subroutine ESMF_StateItemPrint