C_AllocateProgram.f90 817 Bytes
Newer Older
1
program C_AllocatorProgram
2
3
  
  use iso_c_binding
4
5
6
7
  use C_AllocateModule
  
  implicit none
  
8
  integer ( c_int ):: &
9
    Status
10
11
  integer ( c_int ), dimension ( 3 ) :: &
    A_Shape
12
13
14
  real ( KDR ), dimension ( :, :, : ), allocatable :: &
    Array
  
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  Status = - huge ( 1 )
  
  A_Shape = [ 10, 20, 3 ]
  
  !--FIXME: the following caused gcc/10.1 to crash
  !print*, 'Requested shape', A_Shape
  
  call C_Allocate ( Array, A_Shape, Status )
  
  if ( Status == 0 ) then
    print*, 'is Array Allocated? ', allocated ( Array )
    !-- FIXME: shape causes GCC to crash
    !print*, 'Shape:', shape ( Array )
    print*, 'size:', size ( Array )
    !print*, 'lbounds', lbound ( Array )
    !print*, 'ubounds', ubound ( Array )
    
  else 
    print*, 'Allocation failed'
  end if
35
36
  
end program C_AllocatorProgram