ESMF_Config_Test Program

Variables

Type Attributes Name Initial
character(len=*), parameter :: version = '$Id$'

Source Code

    program ESMF_Config_Test


!USES
      use ESMF_TestMod     ! test methods
      use ESMF
      use config_subrs

      implicit none

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

      counter_total = 0
      counter_success = 0
 
!-------------------------------------------------------------------------------
! The unit tests are divided into Sanity and Exhaustive. The Sanity tests are
! always run. When the environment variable, EXHAUSTIVE, is set to ON then
! the EXHAUSTIVE and sanity tests both run. If the EXHAUSTIVE variable is set
! to OFF, then only the sanity unit tests.
! Special strings (Non-exhaustive and exhaustive) have been
! added to allow a script to count the number and types of unit tests.
!-------------------------------------------------------------------------------


      call ESMF_TestStart(ESMF_SRCLINE, rc=rc)
      if (rc /= ESMF_SUCCESS) call ESMF_Finalize(endflag=ESMF_END_ABORT)


      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for uncreated object"
      write(failMsg, *) "Did not return .false."
      isCreated = ESMF_ConfigIsCreated(cf)
      call ESMF_Test((isCreated .eqv. .false.), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for uncreated object"
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      isCreated = ESMF_ConfigIsCreated(cf, rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Create test Config for IsCreated"
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      cf = ESMF_ConfigCreate(rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for created object"
      write(failMsg, *) "Did not return .true."
      isCreated = ESMF_ConfigIsCreated(cf)
      call ESMF_Test((isCreated .eqv. .true.), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for created object"
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      isCreated = ESMF_ConfigIsCreated(cf, rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Destroy test Config for IsCreated"
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      call ESMF_ConfigDestroy(cf, rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for destroyed object"
      write(failMsg, *) "Did not return .false."
      isCreated = ESMF_ConfigIsCreated(cf)
      call ESMF_Test((isCreated .eqv. .false.), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      write(name, *) "Testing Config IsCreated for destroyed object"
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      isCreated = ESMF_ConfigIsCreated(cf, rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)
      !------------------------------------------------------------------------

      !------------------------------------------------------------------------
      !NEX_UTest
      ! Test Config Create
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      write(name, *) "Config Create Test"
      cf = ESMF_ConfigCreate(rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

      !------------------------------------------------------------------------
      !NEX_UTest
      ! Test Config Print
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      write(name, *) "Config Print Test"
      call ESMF_ConfigPrint(cf, rc=rc)
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

      !------------------------------------------------------------------------
      !NEX_UTest
      ! Test Config Destroy
      write(failMsg, *) "Did not return ESMF_SUCCESS"
      write(name, *) "Config Destroy Test"
      call ESMF_ConfigDestroy( cf, rc=rc) 
      call ESMF_Test((rc.eq.ESMF_SUCCESS), name, failMsg, result, ESMF_SRCLINE)

#ifdef ESMF_TESTEXHAUSTIVE

      !------------------------------------------------------------------------
      !EX_UTest
      ! Test Config Destroy of a destroyed Config
      write(failMsg, *) "Did not return ESMF_RC_OBJ_DELETED"
      write(name, *) "Destroy a destroyed Config Test"
      call ESMF_ConfigDestroy( cf, rc=rc) 
      call ESMF_Test((rc.eq.ESMF_RC_OBJ_DELETED), name, failMsg, result, ESMF_SRCLINE)

     !------------------------------------------------------------------------
     !EX_UTest
     ! Destroyed Config Get Attribute Int Test
     write(failMsg, *) "Did not return ESMF_RC_OBJ_DELETED"
     write(name, *) "Destroyed Config Get Attribute Int Test"
     call ESMF_ConfigGetAttribute( cf, nDE, label ='Number_of_DEs:', &
           default=7, rc = rc )
     call ESMF_Test((rc.eq.ESMF_RC_OBJ_DELETED), name, failMsg, result, ESMF_SRCLINE)

     !------------------------------------------------------------------------
     !EX_UTest
     ! Destroyed Config Get Attribute Char Test
     write(failMsg, *) "Did not return ESMF_RC_OBJ_DELETED"
     write(name, *) "Destroyed Config Get Attribute Char Test"
     call ESMF_ConfigGetChar( cf, answer, label='Do_you_want_quality_control:', &
                                    rc = rc )
     call ESMF_Test((rc.eq.ESMF_RC_OBJ_DELETED), name, failMsg, result, ESMF_SRCLINE)

     !------------------------------------------------------------------------
     !EX_UTest
     ! Destroyed Config Find Label Test
      write(failMsg, *) "Did not return ESMF_RC_OBJ_DELETED"
      write(name, *) "Non-create Config Find Label Test"
      call ESMF_ConfigFindLabel( cf, 'v-wind_flag:', rc=rc)
      call ESMF_Test((rc.eq.ESMF_RC_OBJ_DELETED), name, failMsg, result, ESMF_SRCLINE)




! Initialization:
!----------------
      call Initialization()
      if (rc /= ESMF_RC_DUP_NAME) then
        call ESMF_ConfigDestroy( cf, rc=rc) 
        call ESMF_TestEnd(ESMF_SRCLINE)
        STOP            ! Catastropic Error
      endif

! Retrieval of single parameters
!--------------------------------
      call SinglePar()


! Retrieval of a group of parameters on a single line
! ----------------------------------------------------

      call  MultPar_SingleLine_U()
      call  MultPar_SingleLine_V()
      call  MultPar_SingleLine_Vf()


! Retrieval of a group of parameters on multiple lines
!   ----------------------------------------------------
      call MultPar_MultLines()


! Retrieval of Tables of unknown length
! ---------------------------------------

      call Table()

!
! Setting of single parameters
! ------------------------------
      call SingleParSet()

! Sections
! ------------------------------
      call Sections()


! Finalization
! ------------
 
      call Finalization()

! REPORTING
! ------------
      
      !EX_UTest
      write(failMsg, *) "Config Unit test failed"
      write(name, *) "Config Unit Test"
      call ESMF_Test((counter_success.eq.counter_total), name, failMsg, result, ESMF_SRCLINE)
      if  (counter_total > 0) then
         if( counter_success == counter_total ) then 
            print *,'ESMF_Config: All tests were successful'
         else
            success_rate = 100.0 * counter_success / counter_total 
            print *,'ESMF_Config: Success rate: ', nint(success_rate),'%' 
         endif
      endif

#endif

      call ESMF_TestEnd(ESMF_SRCLINE)


  end program ESMF_Config_Test