ESMF_LocStreamPrint Subroutine

public subroutine ESMF_LocStreamPrint(locstream, keywordEnforcer, options, rc)

Arguments

Type IntentOptional Attributes Name
type(ESMF_LocStream), intent(in) :: locstream
type(ESMF_KeywordEnforcer), optional :: keywordEnforcer
character(len=*), intent(in), optional :: options
integer, intent(out), optional :: rc

Source Code

      subroutine ESMF_LocStreamPrint(locstream, keywordEnforcer, options, rc)
!
!
! !ARGUMENTS:
      type(ESMF_LocStream), intent(in)             :: locstream 
type(ESMF_KeywordEnforcer), optional:: keywordEnforcer ! must use keywords below
      character (len = *),  intent(in),   optional :: options
      integer,              intent(out),  optional :: rc
!
! !DESCRIPTION:
!     Prints information about the {\tt locstream} to {\tt stdout}.
!  This subroutine goes through the internal data members of a locstream
 !  data type and prints information of each data member.
!
!     The arguments are:
!     \begin{description}
!     \item [locstream]
!     \item [{[options]}]
!           Print options are not yet supported.
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOP
        type(ESMF_LocStreamType),pointer :: lstypep
        character(len=ESMF_MAXSTR)       :: name
        integer                          :: localrc
        character(len=6)                 :: defaultopts
        integer                          :: i
        type(ESMF_TypeKind_Flag)              :: keyKind
        real(ESMF_KIND_R8), pointer :: tmpR8(:)
        real(ESMF_KIND_R4), pointer :: tmpR4(:)
        integer(ESMF_KIND_I4), pointer :: tmpI4(:)
        integer                          :: cl,cu,j

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

        ! check variables
        ESMF_INIT_CHECK_DEEP(ESMF_LocStreamGetInit,locstream,rc)

        !DUMMY TEST TO QUIET DOWN COMPILER WARNINGS
        !TODO: Remove the following dummy test when dummy argument actually used
        if (present (options)) continue

        write(ESMF_UtilIOStdout,*) "LocStream Print Starts ====>"

        ! Get internal pointer to locstream
        lstypep => locstream%lstypep

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

        call ESMF_GetName(lstypep%base, name, localrc)
        if (ESMF_LogFoundError(localrc, &
                                  ESMF_ERR_PASSTHRU, &
                                  ESMF_CONTEXT, rcToReturn=rc)) return

        write(ESMF_UtilIOStdout,*)  "Name =     '",  trim(name), "'" 
        write(ESMF_UtilIOStdout,*)  "KeyCount =",lstypep%keyCount
        write(ESMF_UtilIOStdout,*) "Keys:"
        do i=1,lstypep%keyCount
           write(ESMF_UtilIOStdout,*) "   ",trim(lstypep%keyNames(i)),     &
                                      " - ",trim(lstypep%keyLongNames(i)), &
                                      "    ",trim(lstypep%keyUnits(i))


          call ESMF_LocStreamGetKey(locstream,lstypep%keyNames(i),typekind=keyKind,rc=localrc)
          if (ESMF_LogFoundError(localrc, &
                                 ESMF_ERR_PASSTHRU, &
                                 ESMF_CONTEXT, rcToReturn=rc)) return

          if (keyKind .eq. ESMF_TYPEKIND_I4) then
            call  ESMF_LocStreamGetKey(locstream, keyName=lstypep%keyNames(i), &
              computationalLBound=cl, computationalUBound=cu, farray=tmpI4, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                                   ESMF_ERR_PASSTHRU, &
                                   ESMF_CONTEXT, rcToReturn=rc)) return
            do j=cl,cu
              write(ESMF_UtilIOStdout,*) "    arr(",j,")= ",tmpI4(j)
            enddo
          else if (keyKind .eq. ESMF_TYPEKIND_R4) then
            call  ESMF_LocStreamGetKey(locstream, keyName=lstypep%keyNames(i), &
              computationalLBound=cl, computationalUBound=cu, farray=tmpR4, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                                   ESMF_ERR_PASSTHRU, &
                                   ESMF_CONTEXT, rcToReturn=rc)) return
            do j=cl,cu
              write(ESMF_UtilIOStdout,*) "    arr(",j,")= ",tmpR4(j)
            enddo
          else if (keyKind .eq. ESMF_TYPEKIND_R8) then
            call  ESMF_LocStreamGetKey(locstream, keyName=lstypep%keyNames(i), &
              computationalLBound=cl, computationalUBound=cu, farray=tmpR8, rc=localrc)
            if (ESMF_LogFoundError(localrc, &
                                   ESMF_ERR_PASSTHRU, &
                                   ESMF_CONTEXT, rcToReturn=rc)) return
            do j=cl,cu
              write(ESMF_UtilIOStdout,*) "    arr(",j,")= ",tmpR8(j)
            enddo
          else
            if (ESMF_LogFoundError(ESMF_RC_ARG_WRONG, &
              msg=" - unknown typekind for LocStream key", &
              ESMF_CONTEXT, rcToReturn=rc)) return
          endif
        enddo

        write(ESMF_UtilIOStdout,*) "LocStream Print Ends   ====>"

        if (present(rc)) rc = ESMF_SUCCESS

        end subroutine ESMF_LocStreamPrint