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