ESMF_ReconcileDebugPrint Subroutine

private subroutine ESMF_ReconcileDebugPrint(text, multitext, ask, rc)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in), optional :: text
character(len=*), intent(in), optional :: multitext
logical, intent(in), optional :: ask
integer, intent(out), optional :: rc

Source Code

  subroutine ESMF_ReconcileDebugPrint (text, multitext, ask, rc)
    use ESMF_IOUtilMod
    character(*), intent(in),  optional :: text
    character(*), intent(in),  optional :: multitext
    logical,      intent(in),  optional :: ask
    integer,      intent(out), optional :: rc

    type(ESMF_VM) :: vm
    integer :: localrc
    integer :: mypet, npets
    character(16) :: answer
    character(10) :: time
    logical :: localask

    call ESMF_VMGetCurrent(vm=vm, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    call ESMF_VMGet(vm, localPet=mypet, petCount=npets, rc=localrc)
    if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
        ESMF_CONTEXT,  &
        rcToReturn=rc)) return

    localask = .false.
    if (present (ask)) then
      localask = ask
    end if

    if (present (text)) then
#if 0
      call ESMF_UtilIOUnitFlush (ESMF_UtilIOStdout)
      call ESMF_VMBarrier (vm)
      if (mypet == 0) then
        call date_and_time (time=time)
        write (ESMF_UtilIOStdout,*)  &
          time(1:2), ':', time(3:4), ':', time(5:), ': ', text
        call ESMF_UtilIOUnitflush (ESMF_UtilIOStdout)
      end if
      call ESMF_VMBarrier (vm)
#else
      call ESMF_LogWrite(trim(text), ESMF_LOGMSG_DEBUG, rc=rc)
#endif
    end if

    if (present (multitext)) then
#if 0
      write (ESMF_UtilIOStdout,*) multitext
      call ESMF_UtilIOUnitFlush (ESMF_UtilIOStdout)
      call ESMF_VMBarrier (vm)
#else
      call ESMF_LogWrite(trim(multitext), ESMF_LOGMSG_DEBUG, rc=rc)
#endif
    end if

    if (localask) then
      if (mypet == 0) then
        write (ESMF_UtilIOStdout,'(a)') 'Proceed?'
        call ESMF_UtilIOUnitFlush (ESMF_UtilIOStdout)
        read (ESMF_UtilIOStdin,'(a)') answer
      end if
      call ESMF_VMBarrier (vm)
    end if

  end subroutine ESMF_ReconcileDebugPrint