ESMF_Test.F90 Source File


This file depends on

sourcefile~~esmf_test.f90~~EfferentGraph sourcefile~esmf_test.f90 ESMF_Test.F90 sourcefile~esmf_base.f90 ESMF_Base.F90 sourcefile~esmf_test.f90->sourcefile~esmf_base.f90 sourcefile~esmf_init.f90 ESMF_Init.F90 sourcefile~esmf_test.f90->sourcefile~esmf_init.f90 sourcefile~esmf_ioutil.f90 ESMF_IOUtil.F90 sourcefile~esmf_test.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_logerr.f90 ESMF_LogErr.F90 sourcefile~esmf_test.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_utiltypes.f90 ESMF_UtilTypes.F90 sourcefile~esmf_test.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_vm.f90 ESMF_VM.F90 sourcefile~esmf_test.f90->sourcefile~esmf_vm.f90 sourcefile~esmf_base.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_base.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_base.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_base.f90->sourcefile~esmf_vm.f90 sourcefile~esmf_initmacros.f90 ESMF_InitMacros.F90 sourcefile~esmf_base.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_init.f90->sourcefile~esmf_base.f90 sourcefile~esmf_init.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_init.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_init.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_init.f90->sourcefile~esmf_vm.f90 sourcefile~esmf_calendar.f90 ESMF_Calendar.F90 sourcefile~esmf_init.f90->sourcefile~esmf_calendar.f90 sourcefile~esmf_config.f90 ESMF_Config.F90 sourcefile~esmf_init.f90->sourcefile~esmf_config.f90 sourcefile~esmf_delayout.f90 ESMF_DELayout.F90 sourcefile~esmf_init.f90->sourcefile~esmf_delayout.f90 sourcefile~esmf_hconfig.f90 ESMF_HConfig.F90 sourcefile~esmf_init.f90->sourcefile~esmf_hconfig.f90 sourcefile~esmf_trace.f90 ESMF_Trace.F90 sourcefile~esmf_init.f90->sourcefile~esmf_trace.f90 sourcefile~esmf_util.f90 ESMF_Util.F90 sourcefile~esmf_init.f90->sourcefile~esmf_util.f90 sourcefile~esmf_ioutil.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_logerr.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_logerr.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_utilstring.f90 ESMF_UtilString.F90 sourcefile~esmf_logerr.f90->sourcefile~esmf_utilstring.f90 sourcefile~esmf_vm.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_vm.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_vm.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_f90interface.f90 ESMF_F90Interface.F90 sourcefile~esmf_vm.f90->sourcefile~esmf_f90interface.f90 sourcefile~esmf_vm.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_calendar.f90->sourcefile~esmf_base.f90 sourcefile~esmf_calendar.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_calendar.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_calendar.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_calendar.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_config.f90->sourcefile~esmf_base.f90 sourcefile~esmf_config.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_config.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_config.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_config.f90->sourcefile~esmf_delayout.f90 sourcefile~esmf_config.f90->sourcefile~esmf_hconfig.f90 sourcefile~esmf_config.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_config.f90->sourcefile~esmf_util.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_base.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_vm.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_f90interface.f90 sourcefile~esmf_delayout.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_f90interface.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_f90interface.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_hconfig.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_hconfig.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_hconfig.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_hconfig.f90->sourcefile~esmf_vm.f90 sourcefile~esmf_hconfig.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_initmacros.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_initmacros.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_trace.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_trace.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_util.f90->sourcefile~esmf_ioutil.f90 sourcefile~esmf_util.f90->sourcefile~esmf_logerr.f90 sourcefile~esmf_util.f90->sourcefile~esmf_utiltypes.f90 sourcefile~esmf_util.f90->sourcefile~esmf_initmacros.f90 sourcefile~esmf_util.f90->sourcefile~esmf_utilstring.f90

Files dependent on this one

ESMF_Test.F90wclock_utils.F90
w
wcomp_utils.F90
w
wcomp_utils.F90
w
wESMF_AlarmEx.F90
w
wESMF_AlarmUTest.F90
w
wESMF_AppMainEx.F90
w
wESMF_ArrayArbHaloEx.F90
w
wESMF_ArrayArbIdxSMMUTest.F90
w
wESMF_ArrayBundleCreateUTest.F90
w
wESMF_ArrayBundleEx.F90
w
wESMF_ArrayBundleHaloEx.F90
w
wESMF_ArrayBundleIOUTest.F90
w
wESMF_ArrayBundleRedistSTest.F90
w
wESMF_ArrayBundleRedistUTest.F90
w
wESMF_ArrayBundleSparseMatMulSTest.F90
w
wESMF_ArrayCommNBEx.F90
w
wESMF_ArrayCreateGetUTest.F90
w
wESMF_ArrayDataUTest.F90
w
wESMF_ArrayEx.F90
w
wESMF_ArrayFarrayEx.F90
w
wESMF_ArrayFarrayHaloEx.F90
w
wESMF_ArrayGatherUTest.F90
w
wESMF_ArrayHaloEx.F90
w
wESMF_ArrayHaloUTest.F90
w
wESMF_ArrayIOTypesUTest.F90
w
wESMF_ArrayIOUTest.F90
w
wESMF_ArrayLarrayEx.F90
w
wESMF_ArrayRedist3DSTest.F90
w
wESMF_ArrayRedistEx.F90
w
wESMF_ArrayRedistOpenACCSTest.F90
w
wESMF_ArrayRedistOpenMPSTest.F90
w
wESMF_ArrayRedistPerfUTest.F90
w
wESMF_ArrayRedistSharedObjSTest.F90
w
wESMF_ArrayRedistSTest.F90
w
wESMF_ArrayRedistSTestA.F90
w
wESMF_ArrayRedistSTestB.F90
w
wESMF_ArrayRedistUTest.F90
w
wESMF_ArrayScatterGatherArbEx.F90
w
wESMF_ArrayScatterGatherEx.F90
w
wESMF_ArrayScatterGatherSTest.F90
w
wESMF_ArrayScatterUTest.F90
w
wESMF_ArraySharedDeSSISTest.F90
w
wESMF_ArraySMMFromFileUTest.F90
w
wESMF_ArraySMMUTest.F90
w
wESMF_ArraySparseMatMulEx.F90
w
wESMF_ArraySparseMatMulSTest.F90
w
wESMF_ArraySpecEx.F90
w
wESMF_ArraySpecUTest.F90
w
wESMF_AttachMethodsEx.F90
w
wESMF_AttributeProfileUTest.F90
w
wESMF_AttributeSTest.F90
w
wESMF_AttributeUpdateComponentUTest.F90
w
wESMF_AttributeUpdateContainerStressUTest.F90
w
wESMF_AttributeUpdateMultiReconcileUTest.F90
w
wESMF_AttributeUpdateReconcileUTest.F90
w
wESMF_AttributeUpdateRemoveOnlyUTest.F90
w
wESMF_AttributeUpdateUTest.F90
w
wESMF_AttributeUtilUTest.F90
w
wESMF_BaseUTest.F90
w
wESMF_CalendarEx.F90
w
wESMF_CalendarUTest.F90
w
wESMF_CalRangeUTest.F90
w
wESMF_ClockEx.F90
w
wESMF_ClockUTest.F90
w
wESMF_CompCreateSTest.F90
w
wESMF_CompFortranAndCSTest.F90
w
wESMF_ComplianceCheckerSTest.F90
w
wESMF_ComponentUTest.F90
w
wESMF_CompSetServUTest.F90
w
wESMF_CompTunnelEx.F90
w
wESMF_CompTunnelUTest.F90
w
wESMF_ConcurrentCompSTest.F90
w
wESMF_ConcurrentEnsembleSTest.F90
w
wESMF_ConfigOverviewEx.F90
w
wESMF_ConfigUTest.F90
w
wESMF_ContainerUTest.F90
w
wESMF_CplCompCreateUTest.F90
w
wESMF_CplEx.F90
w
wESMF_DELayoutEx.F90
w
wESMF_DELayoutUTest.F90
w
wESMF_DELayoutWorkQueueUTest.F90
w
wESMF_DirectCouplingSTest.F90
w
wESMF_DistGridCreateGetUTest.F90
w
wESMF_DistGridEx.F90
w
wESMF_ExceptionsUTest.F90
w
wESMF_F90ArrayPtrUTest.F90
w
wESMF_F95PtrUTest.F90
w
wESMF_FaultToleranceCompASTest.F90
w
wESMF_FaultToleranceSTest.F90
w
wESMF_FeatureUTest.F90
w
wESMF_FieldArbGridEx.F90
w
wESMF_FieldArbGridUTest.F90
w
wESMF_FieldBundleCreateEx.F90
w
wESMF_FieldBundleCrGetUTest.F90
w
wESMF_FieldBundleHaloEx.F90
w
wESMF_FieldBundleIOUTest.F90
w
wESMF_FieldBundleLSRedistArb2ArbSTest.F90
w
wESMF_FieldBundleLSRedistArb2ArbUngrdDimSTest.F90
w
wESMF_FieldBundleRedistArb2ArbSTest.F90
w
wESMF_FieldBundleRedistBlk2ArbSTest.F90
w
wESMF_FieldBundleRedistBlk2BlkSTest.F90
w
wESMF_FieldBundleRedistEx.F90
w
wESMF_FieldBundleRedistPackedSTest.F90
w
wESMF_FieldBundleRedistUTest.F90
w
wESMF_FieldBundleRegridPackedSTest.F90
w
wESMF_FieldBundleRegridUTest.F90
w
wESMF_FieldBundleSMMEx.F90
w
wESMF_FieldBundleSMMPackedSTest.F90
w
wESMF_FieldBundleSMMSTest.F90
w
wESMF_FieldBundleSMMUTest.F90
w
wESMF_FieldBundleUTest.F90
w
wESMF_FieldCommEx.F90
w
wESMF_FieldConCompSTest.F90
w
wESMF_FieldCreateEx.F90
w
wESMF_FieldCreateGetUTest.F90
w
wESMF_FieldEx.F90
w
wESMF_FieldGatherUTest.F90
w
wESMF_FieldHaloEx.F90
w
wESMF_FieldHaloUTest.F90
w
wESMF_FieldIOUTest.F90
w
wESMF_FieldLSRedistArb2ArbSTest.F90
w
wESMF_FieldLSRedistArb2ArbUngrdDimSTest.F90
w
wESMF_FieldLSSMMSTest.F90
w
wESMF_FieldLSSMMUTest.F90
w
wESMF_FieldMeshRegridEx.F90
w
wESMF_FieldMeshSMMSTest.F90
w
wESMF_FieldMeshSMMUTest.F90
w
wESMF_FieldRedistArb2ArbSTest.F90
w
wESMF_FieldRedistArbUTest.F90
w
wESMF_FieldRedistBlk2ArbSTest.F90
w
wESMF_FieldRedistBlk2BlkSTest.F90
w
wESMF_FieldRedistEx.F90
w
wESMF_FieldRedistSTest.F90
w
wESMF_FieldRedistUTest.F90
w
wESMF_FieldRegridConsrvSTest.F90
w
wESMF_FieldRegridCsrv2ndUTest.F90
w
wESMF_FieldRegridCsrvUTest.F90
w
wESMF_FieldRegridCSUTest.F90
w
wESMF_FieldRegridDisjointSTest.F90
w
wESMF_FieldRegridEx.F90
w
wESMF_FieldRegridLSSTest.F90
w
wESMF_FieldRegridMaskEx.F90
w
wESMF_FieldRegridMeshSTest.F90
w
wESMF_FieldRegridMeshToMeshSTest.F90
w
wESMF_FieldRegridMultiSTest.F90
w
wESMF_FieldRegridOrderSTest.F90
w
wESMF_FieldRegridOverlapSTest.F90
w
wESMF_FieldRegridPatchDisjointSTest.F90
w
wESMF_FieldRegridSTest.F90
w
wESMF_FieldRegridUTest.F90
w
wESMF_FieldRegridXGSMMUTest.F90
w
wESMF_FieldRegridXGUTest.F90
w
wESMF_FieldRepDimEx.F90
w
wESMF_FieldSharedDeSSISTest.F90
w
wESMF_FieldSMMEx.F90
w
wESMF_FieldSMMFromFileUTest.F90
w
wESMF_FieldSMMUTest.F90
w
wESMF_FieldSparseMatMulSTest.F90
w
wESMF_FieldSphereRegridEx.F90
w
wESMF_FieldStressUTest.F90
w
wESMF_FieldUTest.F90
w
wESMF_FileRegridUTest.F90
w
wESMF_FortranWordsizeUTest.F90
w
wESMF_FrameworkUTest.F90
w
wESMF_GCompEx.F90
w
wESMF_GeomUTest.F90
w
wESMF_GridArbitraryUTest.F90
w
wESMF_GridCompCreateUTest.F90
w
wESMF_GridCoordUTest.F90
w
wESMF_GridCreateRegFromDGEx.F90
w
wESMF_GridCreateUTest.F90
w
wESMF_GridItemUTest.F90
w
wESMF_GridToMeshUTest.F90
w
wESMF_GridUsageEx.F90
w
wESMF_HConfigEx.F90
w
wESMF_HConfigUTest.F90
w
wESMF_InfoArrayUTest.F90
w
wESMF_InfoCacheUTest.F90
w
wESMF_InfoDescribeUTest.F90
w
wESMF_InfoGetFromHostEx.F90
w
wESMF_InfoGetInterfaceArrayUTest.F90
w
wESMF_InfoProfileUTest.F90
w
wESMF_InfoSyncUTest.F90
w
wESMF_InfoTutorialEx.F90
w
wESMF_InfoUTest.F90
w
wESMF_InitMacrosUTest.F90
w
wESMF_InternalStateEx.F90
w
wESMF_InternalStateModEx.F90
w
wESMF_InternalStateUTest.F90
w
wESMF_IO_FileTypeCheckUTest.F90
w
wESMF_IO_MultitileUTest.F90
w
wESMF_IO_YAMLUTest.F90
w
wESMF_IOCompUTest.F90
w
wESMF_IOGridCompUTest.F90
w
wESMF_IOUTest.F90
w
wESMF_LAPACKUTest.F90
w
wESMF_LocalArrayDataUTest.F90
w
wESMF_LocalArrayUTest.F90
w
wESMF_LocStreamEx.F90
w
wESMF_LocStreamUTest.F90
w
wESMF_LogErrEx.F90
w
wESMF_LogErrHaltUTest.F90
w
wESMF_LogErrPerfUTest.F90
w
wESMF_LogErrUTest.F90
w
wESMF_MapperSimpleTwoConcurrentCompsSTest.F90
w
wESMF_MapperTwoConcurrentCompsSTest.F90
w
wESMF_MeshEx.F90
w
wESMF_MeshFileIOUTest.F90
w
wESMF_MeshOpUTest.F90
w
wESMF_MeshUTest.F90
w
wESMF_NamedAliasUTest.F90
w
wESMF_NUOPC_UTest.F90
w
wESMF_NUOPCAtmModelEx.F90
w
wESMF_NUOPCBasicModelEx.F90
w
wESMF_PointListUTest.F90
w
wESMF_ProfileUTest.F90
w
wESMF_RecursiveComponentSTest.F90
w
wESMF_RegridWeightGenUTest.F90
w
wESMF_RHandleBitForBitEx.F90
w
wESMF_RHandleDynamicMaskingEx.F90
w
wESMF_RHandleFromFileEx.F90
w
wESMF_RHandleFromRHandleEx.F90
w
wESMF_RHandleReusabilityEx.F90
w
wESMF_RHandleVMEpochEx.F90
w
wESMF_RouteHandleAdvancedUTest.F90
w
wESMF_RouteHandleUTest.F90
w
wESMF_SciCompCreateUTest.F90
w
wESMF_SCompEx.F90
w
wESMF_SequentialEnsembleSTest.F90
w
wESMF_StateCreateUTest.F90
w
wESMF_StateEx.F90
w
wESMF_StateReconcileEx.F90
w
wESMF_StateReconcileProxyUTest.F90
w
wESMF_StateReconcileUTest.F90
w
wESMF_StateUTest.F90
w
wESMF_StdCompMethodsUTest.F90
w
wESMF_StringUTest.F90
w
wESMF_TestHarnessUTest.F90
w
wESMF_TestUTest.F90
w
wESMF_TimeEx.F90
w
wESMF_TimeIntervalEx.F90
w
wESMF_TimeIntervalUTest.F90
w
wESMF_TimeUTest.F90
w
wESMF_TraceClkMonoSyncUTest.F90
w
wESMF_TraceClkMonoUTest.F90
w
wESMF_TraceEx.F90
w
wESMF_TraceIOUTest.F90
w
wESMF_TraceMPIUTest.F90
w
wESMF_TraceSTest.F90
w
wESMF_TraceUserEx.F90
w
wESMF_TraceUTest.F90
w
wESMF_TransferGridSTest.F90
w
wESMF_TransferMeshSTest.F90
w
wESMF_TypeKindGetUTest.F90
w
wESMF_UtilUTest.F90
w
wESMF_VMAccUTest.F90
w
wESMF_VMAllFullReduceEx.F90
w
wESMF_VMAllGatherUTest.F90
w
wESMF_VMAllGatherVUTest.F90
w
wESMF_VMAllToAllUTest.F90
w
wESMF_VMAllToAllVUTest.F90
w
wESMF_VMBarrierUTest.F90
w
wESMF_VMBroadcastUTest.F90
w
wESMF_VMComponentEx.F90
w
wESMF_VMComponentUTest.F90
w
wESMF_VMControlMPIThreadSupportEx.F90
w
wESMF_VMDefaultBasicsEx.F90
w
wESMF_VMEpochLargeMsgUTest.F90
w
wESMF_VMGatherUTest.F90
w
wESMF_VMGetMPICommunicatorEx.F90
w
wESMF_VMHigherRankDataEx.F90
w
wESMF_VMNonBlockingEx.F90
w
wESMF_VMOpenMPUTest.F90
w
wESMF_VMScatterUTest.F90
w
wESMF_VMScatterVMGatherEx.F90
w
wESMF_VMSendNbVMRecvNbUTest.F90
w
wESMF_VMSendRecvNbUTest.F90
w
wESMF_VMSendRecvUTest.F90
w
wESMF_VMSendVMRecvEx.F90
w
wESMF_VMSendVMRecvUTest.F90
w
wESMF_VMUserMpiCommEx.F90
w
wESMF_VMUserMpiCommMultiEx.F90
w
wESMF_VMUserMpiEx.F90
w
wESMF_VMUserMpiInitUTest.F90
w
wESMF_VMUTest.F90
w
wESMF_WebServicesEx.F90
w
wESMF_WebServicesSTest.F90
w
wESMF_WebServUTest.F90
w
wESMF_WordsizeUTest.F90
w
wESMF_XGridConcurrentSTest.F90
w
wESMF_XGridEx.F90
w
wESMF_XGridMaskingUTest.F90
w
wESMF_XGridSerialSTest.F90
w
wESMF_XGridSparseMatEx.F90
w
wESMF_XGridUTest.F90
w
wuser_coupler.F90
w
wuser_coupler.F90
w
wuser_coupler.F90
w
wuser_coupler.F90
w
wuser_model2.F90
w
wuser_model2.F90
w
wuser_model2.F90
w
wuser_model2.F90
w
wuser_modelA.F90
w
wuser_modelA.F90
w
wuser_modelB.F90
w
wuser_modelB.F90
w

Source Code

! $Id$
!
! Earth System Modeling Framework
! Copyright (c) 2002-2025, University Corporation for Atmospheric Research,
! Massachusetts Institute of Technology, Geophysical Fluid Dynamics
! Laboratory, University of Michigan, National Centers for Environmental
! Prediction, Los Alamos National Laboratory, Argonne National Laboratory,
! NASA Goddard Space Flight Center.
! Licensed under the University of Illinois-NCSA License.
!
!==============================================================================
!
!     ESMF Test Module
      module ESMF_TestMod
!
!==============================================================================
!
! This file contains the Test class definition and all Test class
! methods.
!
!------------------------------------------------------------------------------

!===============================================================================
!BOP
!
! !MODULE: ESMF_TestMod
!
! !DESCRIPTION:
!   contains methods to support testing
!
!------------------------------------------------------------------------------
! !USES:
      use ESMF_UtilTypesMod
      use ESMF_BaseMod
      use ESMF_LogErrMod
      use ESMF_VMMod
      use ESMF_InitMod
      use ESMF_IOUtilMod
      implicit none

! !PUBLIC MEMBER FUNCTIONS:
      public ESMF_Test
      public ESMF_STest
      public ESMF_TestGlobal
      public ESMF_TestEnd
      public ESMF_TestFileCompare
      public ESMF_TestNumPETs
      public ESMF_TestMinPETs
      public ESMF_TestMaxPETs
      public ESMF_TestResultsGather
      public ESMF_TestStart
!EOP

!------------------------------------------------------------------------------
! The following line turns the CVS identifier string into a printable variable.
      character(*), parameter, private :: version = &
      '$Id$'

!==============================================================================
      
!     ! Test start time
      real(ESMF_KIND_R8), save :: start_time
      integer, save :: PETnum

      contains

!==============================================================================


!-------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_Test - Print PASS/FAIL messages for tests
!
! !INTERFACE:
      subroutine ESMF_Test(condition, name, failMsg, result, file, line, unit)

! !ARGUMENTS:
      logical, intent(in) :: condition      ! pass/fail condition
      character(*), intent(in) :: name      ! test name
      character(*), intent(in) :: failMsg   ! fail message
      integer, intent(inout) :: result      ! accumulated result
      character(*), intent(in) :: file      ! test file name
      integer, intent(in) :: line           ! test file line number
      integer, intent(in), optional :: unit ! additional output unit number

! !DESCRIPTION:
!     Prints a {\tt PASS} message to stdout if {\tt condition} is true,
!     and a {\tt FAIL} message if {\tt condition} is false.  If {\tt unit}
!     is specified, will in addition write the same message to that 
!     Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      character(2*ESMF_MAXSTR) :: msg
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      if(condition) then
        write(msg, *) "PASS ", trim(name), ", ", trim(file), ", line ", trim (linestr)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
      else
        write(msg, *) "FAIL ", trim(name), ", ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        result = result + 1  ! count total failures; 0 = all pass
      end if

      end subroutine ESMF_Test



!-------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_STest - Print PASS/FAIL and number of processor messages for tests
!
! !INTERFACE:
      subroutine ESMF_STest(condition, name, failMsg, result, file, line, unit, &
        petCount)

! !ARGUMENTS:
      logical, intent(in) :: condition      ! pass/fail condition
      character(*), intent(in) :: name      ! test name
      character(*), intent(in) :: failMsg   ! fail message
      integer, intent(inout) :: result      ! accumulated result
      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(in), optional :: petCount ! number of PETs if need override
      

! !DESCRIPTION:
!     Gets the PET count and prints out a number of processors message.
!     Prints a {\tt PASS} message to stdout if {\tt condition} is true,
!     and a {\tt FAIL} message if {\tt condition} is false.  If {\tt unit}
!     is specified, will in addition write the same message to that
!     Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      type(ESMF_VM):: vm
      integer:: petCountOpt, localrc
      character(ESMF_MAXSTR) :: msg
     
      if (present(petCount)) then
        petCountOpt = petCount
      else
        call ESMF_VMGetGlobal(vm, rc=localrc)
        call ESMF_VMGet(vm, petCount=petCountOpt, rc=localrc)
      endif
      write(msg, *) "NUMBER_OF_PROCESSORS", petCountOpt
      call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)

      call ESMF_Test(condition, name, failMsg, result,  file, line, unit)

      end subroutine ESMF_STest


!-------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestGlobal - Print PASS/FAIL messages for global test results
!
! !INTERFACE:
      subroutine ESMF_TestGlobal(condition, name, failMsg, result, file, line, &
        unit)

! !ARGUMENTS:
      logical, intent(in) :: condition      ! pass/fail condition
      character(*), intent(in) :: name      ! test name
      character(*), intent(in) :: failMsg   ! fail message
      integer, intent(inout) :: result      ! accumulated result
      character(*), intent(in) :: file      ! test file name
      integer, intent(in) :: line           ! test file line number
      integer, intent(in), optional :: unit ! additional output unit number

! !DESCRIPTION:
!     Prints a {\tt PASS} message to stdout if {\tt condition} is true on all
!     PETs, and a {\tt FAIL} message otherwise.  If {\tt unit}
!     is specified, will in addition write the same message to that 
!     Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

!      character(2*ESMF_MAXSTR) :: msg
      type(ESMF_VM):: vm
      integer:: petCount, localPet, localResult, localrc

      !DUMMY TEST TO QUIET DOWN COMPILER WARNINGS
      !TODO: Remove the following dummy test when implementing this method
      if (name==name) continue

      !DUMMY TEST TO QUIET DOWN COMPILER WARNINGS
      !TODO: Remove the following dummy test when implementing this method
      if (failMsg==failMsg) continue

      if(condition) then
        localResult = ESMF_SUCCESS
      else
        localResult = ESMF_FAILURE
        result = result + 1  ! count total failures; 0 = all pass
      end if
      
      ! for now "name" and "failMsg" are ignored because this impl. is 
      ! based on ESMF_TestResultsGather() which does not take those arguments

      call ESMF_VMGetGlobal(vm, rc=localrc)
      call ESMF_VMGet(vm, petCount=petCount, localPet=localPet, rc=localrc)
      call ESMF_TestResultsGather(vm, localPet, petCount, localResult, &
        file, line, unit, rc=localrc)

      end subroutine ESMF_TestGlobal


!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestEnd - Print information at the end of testing
!
! !INTERFACE:
      subroutine ESMF_TestEnd(file, line, unit)

! !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

! !DESCRIPTION:
!     Prints a standard message; intended to be called at the end of any
!     test code.  If {\tt unit}
!     is specified, will in addition write the same message to that 
!     Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      integer :: rc, localrc
      character(ESMF_MAXSTR) :: msg
      real(ESMF_KIND_R8) :: end_time, elapsed_time
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      write(msg, *) "Ending 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)

      call ESMF_Finalize(rc=rc)
      if (rc .ne. ESMF_SUCCESS) then
          write(msg, *) "Failure in Finalizing ESMF"
          print *, trim(msg)
          call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
          if (present(unit)) write(unit, *) trim(msg)
      endif

      ! Calculate & print out test elasped time
      call cpu_time(end_time)
      elapsed_time = (end_time-start_time) * 1000.0  ! msec
      write(msg, *) "PET", PETnum, " Test Elapsed Time ", elapsed_time, " msec."
      print *, trim(msg)

      end subroutine ESMF_TestEnd


#undef ESMF_METHOD
#define ESMF_METHOD 'ESMF_TestFileCompare'
!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestFileCompare - Compare two text files for equivalence
!
! !INTERFACE:
      function ESMF_TestFileCompare(file1, file2, exclusionList)

! !RETURN VALUE:
      logical :: ESMF_TestFileCompare

! !ARGUMENTS:
      character(*), intent(in) :: file1     ! test file name
      character(*), intent(in) :: file2     ! test file name
      character(*), intent(in), optional :: exclusionList(:)

! !DESCRIPTION:
!     Compares two files to see if they are identical.
!
!     Restrictions:
!     1.) Only text files are supported
!     2.) On systems which do not support recursive I/O, this function
!     should not be called from the I/O list of an I/O statement.
!     3.) On Windows, blank lines are ignored to avoid issues with cr/lfs.
!
!     The arguments are:
!     \begin{description}
!     \item [file1]
!       First of two files to be compared.
!     \item [file2]
!        Second of two files to be compared.
!     \item [{[exclusionList]}]
!       Character strings which, if any are present in text records being
!       compared, will cause a comparison error to be bypassed.  This is
!       useful for records which might legitimately differ between the two
!       files - such as a date or version string.
!     \end{description}
!EOP
!-------------------------------------------------------------------------------

      logical :: exclusions
      integer :: i
      integer :: ioerr1, ioerr2
      integer :: localrc
      character(1024) :: string1, string2
      character(ESMF_MAXSTR) :: errmsg
      integer :: unit1, unit2

      ESMF_TestFileCompare = .false.
      exclusions = present (exclusionList)

      call ESMF_UtilIOUnitGet (unit=unit1, rc=localrc)
      if (localrc /= ESMF_SUCCESS) then
        call ESMF_LogWrite (msg='Can not obtain IO unit number',  &
            logmsgFlag=ESMF_LOGMSG_ERROR)
        write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
            ': Can not obtain IO unit number'
        return
      end if        

      open (unit1, file=file1,  &
        form='formatted', status='old', action='read',  &
        iostat=ioerr1)
      if (ioerr1 /= 0) then
        errmsg = 'Can not open file: ' // file1
        call ESMF_LogWrite (msg=errmsg, logmsgFlag=ESMF_LOGMSG_ERROR)
        write (ESMF_UtilIOStderr,*) ESMF_METHOD, ': ' // trim (errmsg)
        return
      end if        

      call ESMF_UtilIOUnitGet (unit=unit2, rc=localrc)
      if (localrc /= ESMF_SUCCESS) then
        call ESMF_LogWrite (msg='Can not obtain IO unit number',  &
            logmsgFlag=ESMF_LOGMSG_ERROR)
        write (ESMF_UtilIOStderr,*) ESMF_METHOD,  &
            ': Can not obtain IO unit number'
        close (unit1)
        return
      end if

      open (unit2, file=file2,  &
        form='formatted', status='old', action='read',  &
        iostat=ioerr2)
      if (ioerr2 /= 0) then
        errmsg = 'Can not open file: ' // file2
        call ESMF_LogWrite (msg=errmsg, logmsgFlag=ESMF_LOGMSG_ERROR)
        write (ESMF_UtilIOStderr,*) ESMF_METHOD, ': ' // trim (errmsg)
        close (unit1)
        return
      end if        

read_loop:  &
      do
        do
          read (unit1, '(a)', iostat=ioerr1) string1
          if (ioerr1 /= 0) exit
          ! Ignore blank lines due to cr/lf vs newline issues
          do, i=1, len (string1)
            string1(i:i) = merge (string1(i:i), ' ', string1(i:i) /= achar (13))
          end do
          if (string1 /= ' ') exit
        end do

        do
          read (unit2, '(a)', iostat=ioerr2) string2
          if (ioerr2 /= 0) exit
          ! Ignore blank lines due to cr/lf vs newline issues
          do, i=1, len (string2)
            string2(i:i) = merge (string2(i:i), ' ', string2(i:i) /= achar (13))
          end do
          if (string2 /= ' ') exit
        end do

        if (ioerr1 /= ioerr2) then
!          print *, ESMF_METHOD, ': read iostats differ:', ioerr1, ioerr2
          exit
        end if

        select case (ioerr1)
        case (:-1)
          ESMF_TestFileCompare = .true.
          exit

        case (0)
          if (string1 /= string2) then
            if (exclusions) then
exclusion_loop:  &
              do, i=1, size (exclusionList)
                if (index (string1, trim (exclusionList(i))) /= 0 .and.  &
                    index (string2, trim (exclusionList(i))) /= 0) then
                  exit exclusion_loop
                end if
              end do exclusion_loop
              if (i > size (exclusionList)) exit read_loop
            else
#if 0
              print *, ESMF_METHOD, ': comparison error:'
              print *, '  string1 = >', trim (string1), '<'
              print *, '  string2 = >', trim (string2), '<'
#endif
              exit read_loop
            end if
          end if

        case (1:)
          write (errmsg, '(a,i4)') 'unknown iostat = ', ioerr1
          call ESMF_LogWrite (msg=errmsg, logmsgFlag=ESMF_LOGMSG_ERROR)
          print *, ESMF_METHOD, ': ', trim (errmsg)
          exit
        end select

      end do read_loop

      close (unit2)
      close (unit1)


      end function ESMF_TestFileCompare

!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestMinPETs - Verify there are a sufficient number of PETs
!
! !INTERFACE:
      function ESMF_TestMinPETs(petCount, file, line, unit)

! !RETURN VALUE:
      logical :: ESMF_TestMinPETs

! !ARGUMENTS:
      integer, intent(in) :: petCount       ! minimum number of acceptable PETs
      character(*), intent(in) :: file      ! test file name
      integer, intent(in) :: line           ! test file line number
      integer, intent(in), optional :: unit ! additional output unit number

! !DESCRIPTION:
!     Verifies we are running on at least the minimum number of PETs.
!     If {\tt unit} is specified, will in addition write the same message 
!     to that Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      character(ESMF_MAXSTR) :: msg, failMsg
      type(ESMF_VM) :: globalVM
      integer :: numPETs, localrc
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      ! assume failure until sure of success
      ESMF_TestMinPETs = .false.

      ! Get the global VM and pet count.
      call ESMF_VMGetGlobal(globalVM, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to get global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      end if

      call ESMF_VMGet(globalVM, petCount=numPETs, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to get number of PETS from global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ! Return neither a PASS or FAIL message, but SKIP.  The nightly
      ! build scripts are smarter about not looking for output from a
      ! file which only contains multiproc tags if it is being run uni,
      ! but this is more for the user to see.
      if (petCount .gt. numPETs) then
        write(failMsg, *) "These tests must run on at least", petCount, " processors."
        write(msg, *) "SKIP ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ESMF_TestMinPETs = .true.
      return

      end function ESMF_TestMinPETs

!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestMaxPETs - Verify there are not too many PETs
!
! !INTERFACE:
      function ESMF_TestMaxPETs(petCount, file, line, unit)

! !RETURN VALUE:
      logical :: ESMF_TestMaxPETs

! !ARGUMENTS:
      integer, intent(in) :: petCount       ! maximum number of acceptable PETs
      character(*), intent(in) :: file      ! test file name
      integer, intent(in) :: line           ! test file line number
      integer, intent(in), optional :: unit ! additional output unit number

! !DESCRIPTION:
!     Verifies we are not running on too many PETs.
!     If {\tt unit} is specified, will in addition write the same message 
!     to that Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      character(ESMF_MAXSTR) :: msg, failMsg
      type(ESMF_VM) :: globalVM
      integer :: numPETs, localrc
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      ! assume failure until sure of success
      ESMF_TestMaxPETs = .false.

      ! Get the global VM and pet count.
      call ESMF_VMGetGlobal(globalVM, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to get global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      end if

      call ESMF_VMGet(globalVM, petCount=numPETs, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to query global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ! Return neither a PASS or FAIL message, but SKIPPED.  The nightly
      ! build scripts are smarter about not looking for output from a
      ! file which only contains multiproc tags if it is being run uni,
      ! but this is more for the user to see.
      if (petCount .lt. numPETs) then
        write(failMsg, *) "These tests must run not more than", petCount, " processors."
        write(msg, *) "SKIP ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ESMF_TestMaxPETs = .true.
      return

      end function ESMF_TestMaxPETs

!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestNumPETs - Verify there are the correct number of PETs
!
! !INTERFACE:
      function ESMF_TestNumPETs(petCount, file, line, unit)

! !RETURN VALUE:
      logical :: ESMF_TestNumPETs

! !ARGUMENTS:
      integer, intent(in) :: petCount       ! exact number of acceptable PETs
      character(*), intent(in) :: file      ! test file name
      integer, intent(in) :: line           ! test file line number
      integer, intent(in), optional :: unit ! additional output unit number

! !DESCRIPTION:
!     Verifies we are running on exactly the required number of PETs.
!     If {\tt unit} is specified, will in addition write the same message 
!     to that Fortran unit number.
!
!EOP
!-------------------------------------------------------------------------------

      character(ESMF_MAXSTR) :: msg, failMsg
      type(ESMF_VM) :: globalVM
      integer :: numPETs, localrc
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      ! assume failure until sure of success
      ESMF_TestNumPETs = .false.

      ! Get the global VM and pet count.
      call ESMF_VMGetGlobal(globalVM, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to get global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      end if

      call ESMF_VMGet(globalVM, petCount=numPETs, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
        failMsg = "Unable to query global VM" 
        write(msg, *) "FAIL ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ! Return neither a PASS or FAIL message, but SKIPPED.  The nightly
      ! build scripts are smarter about not looking for output from a
      ! file which only contains multiproc tags if it is being run uni,
      ! but this is more for the user to see.
      if (petCount .ne. numPETs) then
        write(failMsg, *) "These tests must run on exactly", petCount, " processors."
        write(msg, *) "SKIP ", trim(file), ", line ", &
                      trim (linestr), ": ", trim(failMsg)
        print *, trim(msg)
        call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO)
        if (present(unit)) write(unit, *) trim(msg)
        return
      endif

      ESMF_TestNumPETs = .true.
      return

      end function ESMF_TestNumPETs


!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestResultsGather - Gathers test results from all Pets and prints out a PASS/FAIL message
!
! !INTERFACE:
      subroutine ESMF_TestResultsGather(vm, localPet, petCount, testResults, &
        file, line, unit,  rc)

! !ARGUMENTS:
      type(ESMF_VM), intent(in) :: vm     ! the vm of this pet
      integer, intent(in) :: localPet     ! number of this pet
      integer, intent(in) :: petCount     ! number of pets
      integer, intent(in) :: testResults  ! test results for this pet
      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:
!     The gatherPet gathers the test results, PASS/FAIl, from all other
!     Pets and prints out a PASS/FAIL Message . This subroutine should
!     be called at the end of system tests and use test cases.
!
!EOP
!-------------------------------------------------------------------------------
      character(ESMF_MAXSTR) :: msg
!      character(ESMF_MAXSTR) :: failMsg
      integer, allocatable:: array1(:), array2(:)
      integer:: finalrc, gatherRoot, i, localrc
      character(16) :: linestr

      write (linestr,*) line
      linestr = adjustl (linestr)

      allocate(array1(petCount))
      allocate(array2(1))
      ! Store test results
      array2(1) = testResults
      gatherRoot = 0

      ! Don't Gather until all pets are done
      call ESMF_VMBarrier(vm, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
          write(msg, *) " FAIL  ESMF_VMBarrier failed.  Error code ", localrc
          print *, trim(msg)
          if (present(unit)) write(unit, *) trim(msg)
          if (present(rc)) rc = localrc
          return
      endif

      

      ! Gather test results
      call ESMF_VMGather(vm, sendData=array2, recvData=array1, count=1, &
      rootPet=gatherRoot, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
          write(msg, *) " FAIL  ESMF_VMGather failed.  Error code ", localrc
          print *, trim(msg)
          if (present(unit)) write(unit, *) trim(msg)
          if (present(rc)) rc = localrc
          return
      endif


      ! assume success
      finalrc=ESMF_SUCCESS

      ! The gather pet checks the results and prints out PASS/FAIL message.
      if (localPet==gatherRoot) then
        do i=1, petCount
                if (array1(i).EQ.ESMF_FAILURE) finalrc = ESMF_FAILURE
        enddo
        if (finalrc.EQ.ESMF_SUCCESS) then
            print *, " PASS: ", trim(file), ' ', trim (linestr)
            call c_ESMC_PrintPassFlush(); ! print and flush out of C++
        else
            print *, " FAIL: ", trim(file), ' ', trim (linestr)
        endif
      endif
      deallocate(array1)
      deallocate(array2)

      ! Don't end test until all pets are done
      call ESMF_VMBarrier(vm, rc=localrc)
      if (localrc .ne. ESMF_SUCCESS) then
          write(msg, *) " FAIL  ESMF_VMBarrier failed.  Error code ", localrc
          print *, trim(msg)
          if (present(unit)) write(unit, *) trim(msg)
          if (present(rc)) rc = localrc
          return
      endif
      
      if (present(rc)) rc=ESMF_SUCCESS
                                                 
      end subroutine ESMF_TestResultsGather

!------------------------------------------------------------------------------
!BOP
!
! !IROUTINE:  ESMF_TestStart - Print information at the start of testing
!
! !INTERFACE:
      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, substring=".", back=.true.) ! search from back of string,
                                                        ! safe for ./file start
      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

!------------------------------------------------------------------------------

      end module ESMF_TestMod