| 1 |
!{ dg-do run } |
| 2 |
|
| 3 |
! Contributed by Anton Shterenlikht <as at cmplx dot uk> |
| 4 |
! Check PR81265 is fixed. |
| 5 |
|
| 6 |
module m |
| 7 |
implicit none |
| 8 |
private |
| 9 |
public :: s |
| 10 |
|
| 11 |
abstract interface |
| 12 |
subroutine halo_exchange( array ) |
| 13 |
integer, allocatable, intent( inout ) :: array(:,:,:,:)[:,:,:] |
| 14 |
end subroutine halo_exchange |
| 15 |
end interface |
| 16 |
|
| 17 |
interface |
| 18 |
module subroutine s( coarray, hx ) |
| 19 |
integer, allocatable, intent( inout ) :: coarray(:,:,:,:)[:,:,:] |
| 20 |
procedure( halo_exchange ) :: hx |
| 21 |
end subroutine s |
| 22 |
end interface |
| 23 |
|
| 24 |
end module m |
| 25 |
submodule( m ) sm |
| 26 |
contains |
| 27 |
module procedure s |
| 28 |
|
| 29 |
if ( .not. allocated(coarray) ) then |
| 30 |
write (*,*) "ERROR: s: coarray is not allocated" |
| 31 |
error stop |
| 32 |
end if |
| 33 |
|
| 34 |
sync all |
| 35 |
|
| 36 |
call hx( coarray ) |
| 37 |
|
| 38 |
end procedure s |
| 39 |
|
| 40 |
end submodule sm |
| 41 |
module m2 |
| 42 |
implicit none |
| 43 |
private |
| 44 |
public :: s2 |
| 45 |
contains |
| 46 |
subroutine s2( coarray ) |
| 47 |
integer, allocatable, intent( inout ) :: coarray(:,:,:,:)[:,:,:] |
| 48 |
if ( .not. allocated( coarray ) ) then |
| 49 |
write (*,'(a)') "ERROR: s2: coarray is not allocated" |
| 50 |
error stop |
| 51 |
end if |
| 52 |
end subroutine s2 |
| 53 |
end module m2 |
| 54 |
program p |
| 55 |
use m |
| 56 |
use m2 |
| 57 |
implicit none |
| 58 |
integer, allocatable :: space(:,:,:,:)[:,:,:] |
| 59 |
integer :: errstat |
| 60 |
|
| 61 |
allocate( space(10,10,10,2) [2,2,*], source=0, stat=errstat ) |
| 62 |
if ( errstat .ne. 0 ) then |
| 63 |
write (*,*) "ERROR: p: allocate( space ) )" |
| 64 |
error stop |
| 65 |
end if |
| 66 |
|
| 67 |
if ( .not. allocated (space) ) then |
| 68 |
write (*,*) "ERROR: p: space is not allocated" |
| 69 |
error stop |
| 70 |
end if |
| 71 |
|
| 72 |
call s( space, s2 ) |
| 73 |
|
| 74 |
end program p |