subroutine ESMF_TestStart(file, line, unit, rc)
! !ARGUMENTS:
character(*), intent(in) :: file ! test file name
integer, intent(in) :: line ! test file line number
integer, intent(in), optional :: unit ! additional output unit number
integer, intent(out), optional :: rc ! return code
! !DESCRIPTION:
! Initializes the ESMF framework, and prints a standard start message
! which is parsed by the nightly build scripts. Must be called once
! at the start of test code.
! If {\tt unit} is specified, will in addition write the same message
! to that Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------
character(ESMF_MAXSTR) :: msg, logFileName
type(ESMF_VM) :: globalVM
integer :: numPETs, localrc, underScore, Period
character(16) :: linestr
write (linestr,*) line
linestr = adjustl (linestr)
! create a file name for the log file
! find locations of the underscore and period
underScore = index (file, "_")
Period = index (file, ".")
logFileName = file(underScore+1:Period) // "Log"
! initialize the framework. if this fails, print a message directly
! because there is no guarentee that the log code will be working.
call ESMF_Initialize(vm=globalVM, defaultlogfilename=logFileName, &
logkindflag=ESMF_LOGKIND_MULTI, rc=localrc)
!logkindflag=ESMF_LOGKIND_SINGLE, rc=localrc)
if (localrc .ne. ESMF_SUCCESS) then
write(msg, *) "FAIL Unable to initialize the ESMF Framework. Error code ", localrc
print *, trim(msg)
if (present(unit)) write(unit, *) trim(msg)
if (present(rc)) rc = localrc
return
endif
call ESMF_LogSet (flush=.true.)
! get test start time
call cpu_time(start_time)
call ESMF_VMGet(globalVM, petCount=numPETs, localPet=PETnum, rc=localrc)
if (localrc .ne. ESMF_SUCCESS) then
write(msg, *) "FAIL Unable to get number of PETs. Error code ", localrc
print *, trim(msg)
if (present(unit)) write(unit, *) trim(msg)
if (present(rc)) rc = localrc
return
endif
write(msg, *) "Beginning Test, file ", trim(file), ", line ", trim (linestr)
print *, trim(msg)
call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
if (present(unit)) write(unit, *) trim(msg)
write(msg, *) "NUMBER_OF_PROCESSORS", numPETs
print *, trim(msg)
call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
if (present(unit)) write(unit, *) trim(msg)
if (present(rc)) rc=ESMF_SUCCESS
end subroutine ESMF_TestStart