Test_CoordinateVariable.pf Source File


This file depends on

sourcefile~~test_coordinatevariable.pf~~EfferentGraph sourcefile~test_coordinatevariable.pf Test_CoordinateVariable.pf sourcefile~attribute.f90 Attribute.F90 sourcefile~test_coordinatevariable.pf->sourcefile~attribute.f90 sourcefile~coordinatevariable.f90 CoordinateVariable.F90 sourcefile~test_coordinatevariable.pf->sourcefile~coordinatevariable.f90 sourcefile~pfio_constants.f90 pFIO_Constants.F90 sourcefile~test_coordinatevariable.pf->sourcefile~pfio_constants.f90 sourcefile~variable.f90 Variable.F90 sourcefile~test_coordinatevariable.pf->sourcefile~variable.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~attribute.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~pfio_utilities.f90 pFIO_Utilities.F90 sourcefile~attribute.f90->sourcefile~pfio_utilities.f90 sourcefile~unlimitedentity.f90 UnlimitedEntity.F90 sourcefile~attribute.f90->sourcefile~unlimitedentity.f90 sourcefile~coordinatevariable.f90->sourcefile~pfio_constants.f90 sourcefile~coordinatevariable.f90->sourcefile~variable.f90 sourcefile~keywordenforcer.f90 KeywordEnforcer.F90 sourcefile~coordinatevariable.f90->sourcefile~keywordenforcer.f90 sourcefile~coordinatevariable.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~coordinatevariable.f90->sourcefile~pfio_utilities.f90 sourcefile~variable.f90->sourcefile~attribute.f90 sourcefile~variable.f90->sourcefile~pfio_constants.f90 sourcefile~variable.f90->sourcefile~keywordenforcer.f90 sourcefile~variable.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~variable.f90->sourcefile~pfio_utilities.f90 sourcefile~stringvectorutil.f90 StringVectorUtil.F90 sourcefile~variable.f90->sourcefile~stringvectorutil.f90 sourcefile~variable.f90->sourcefile~unlimitedentity.f90 sourcefile~errorhandling.f90 ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~pfio_utilities.f90->sourcefile~pfio_constants.f90 sourcefile~pfio_utilities.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~stringvectorutil.f90->sourcefile~attribute.f90 sourcefile~stringvectorutil.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~stringvectorutil.f90->sourcefile~pfio_utilities.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_constants.f90 sourcefile~unlimitedentity.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~unlimitedentity.f90->sourcefile~pfio_utilities.f90 sourcefile~errorhandling.f90->sourcefile~mapl_throw.f90

Source Code

! CFIO is mostly a container composed of FTL containers.  As such,
! most of the tests here are just to drive the formulation of the
! interface, not the algorithms.

module Test_CoordinateVariable
   use pfunit
   use pFIO_AttributeMod
   use pFIO_VariableMod
   use pFIO_CoordinateVariableMod
   use gFTL2_StringVector
   use pFIO_ConstantsMod
   use, intrinsic :: iso_fortran_env, only: INT32, INT64
   use, intrinsic :: iso_fortran_env, only: REAL32, REAL64
   implicit none

   ! Need an empty integer array for some tests
   integer :: empty(0)

contains

   @test
   subroutine test_get_coordinate_data()
      type (Variable) :: var
      type (CoordinateVariable) :: cvar
      class(*), pointer :: c32(:),c64(:)

      var  = Variable(type=pFIO_INT32)
      cvar = CoordinateVariable(var, [1.0_real32, 10.0_real32])
      c32 => cvar%get_coordinate_data()
      select type (c32)
      type is (real(real32))   
         @assertEqual(c32, [1.0_real32, 10.0_real32])
      end select

      var  = Variable(type=pFIO_INT32)
      cvar = CoordinateVariable(var, [1.0_real64, 10.0_real64])
      c64 => cvar%get_coordinate_data()    
      select type (c64)
      type is (real(real64))   
        @assertEqual(c64, [1.0_real64, 10.0_real64])
      end select

   end subroutine test_get_coordinate_data

   @test
   subroutine test_replace_coordinate_data()
      type (Variable) :: var
      type (CoordinateVariable) :: cvar
      class(*), pointer :: c32(:),c64(:)

      var  = Variable(type=pFIO_INT32)
      cvar = CoordinateVariable(var, [1.0_real32, 10.0_real32])
      call cvar%replace_coordinate_data([2.0_real32])

      c32 => cvar%get_coordinate_data()    
      select type (c32)
      type is (real(real32))   
        @assertEqual(c32, [2.0_real32])
      end select

      var  = Variable(type=pFIO_INT32)
      cvar = CoordinateVariable(var, [1.0_real64, 10.0_real64])
      call cvar%replace_coordinate_data([2.0_real64])
      c64 => cvar%get_coordinate_data()    
      select type (c64)
      type is (real(real64))   
        @assertEqual(c64, [2.0_real64])
      end select

   end subroutine test_replace_coordinate_data

   @test
   subroutine test_serialize()
      type (Variable) :: v1
      type (CoordinateVariable) :: cv1, cv2
      integer,allocatable :: buffer(:)

      v1 = Variable(type=pFIO_INT32, dimensions='x,y')
      call v1%add_attribute('attr2', 2.)
      call v1%add_attribute('attr1', 1.)
      call v1%add_attribute('attr3', 'cat')

      cv1 = CoordinateVariable(v1,[1.0_real64,2.0_real64])
      call cv1%serialize(buffer)
      call CoordinateVariable_deserialize(buffer,cv2)
      @assertTrue(cv1 == cv2)
      call cv2%replace_coordinate_data([1.000000001_real64,2.0_real64])
      @assertFalse(cv1 == cv2)

   end subroutine

end module Test_CoordinateVariable