test_scalar Subroutine

public subroutine test_scalar()

Arguments

None

Calls

proc~~test_scalar~~CallsGraph proc~test_scalar test_scalar asserttrue asserttrue proc~test_scalar->asserttrue interface~nearlyequal nearlyEqual proc~test_scalar->interface~nearlyequal

Source Code

   subroutine test_scalar()
      type (LocalMemReference) :: a
      integer (kind=INT32) :: i
      integer (kind=INT64) :: j
      real (kind=REAL32) :: r
      real (kind=REAL64) :: d

      integer ( kind=INT32), pointer :: iPtr
      integer ( kind=INT64), pointer :: jPtr
      real ( kind=REAL32), pointer :: rPtr
      real ( kind=REAL64), pointer :: dPtr
      i = 100
      a = LocalMemReference(i)
      call c_f_pointer(a%base_address, iptr)
      @assertTrue(iptr == i)
      call a%deallocate()
      @assertTrue(.not. associated(a%i_ptr))
      
      j = 10000
      a = LocalMemReference(j)
      call c_f_pointer(a%base_address, jptr)
      @assertTrue(jptr == j)
      call a%deallocate()
      @assertTrue(.not. associated(a%i_ptr))

      r = 100.0
      a = LocalMemReference(r)
      call c_f_pointer(a%base_address, rptr)
      @assertTrue(nearlyEqual(rptr, r))
      call a%deallocate()
      @assertTrue(.not. associated(a%i_ptr))

      d = 100.0d0
      a = LocalMemReference(d)
      call c_f_pointer(a%base_address, dptr)
      @assertTrue(nearlyEqual(dptr, d))
      call a%deallocate()
      @assertTrue(.not. associated(a%i_ptr))

   end subroutine test_scalar