diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2907b5ba..ddfff653b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -92,6 +92,7 @@ jobs: compiler: flang version: latest container: snowstep/llvm:ubuntu-24.04-latest + FFLAGS: -DHAVE_COARRAY # https://hub.docker.com/r/phhargrove/llvm-flang/tags - os: ubuntu-24.04 @@ -200,6 +201,7 @@ jobs: version: latest network: udp container: snowstep/llvm:ubuntu-24.04-latest + FFLAGS: -DHAVE_COARRAY container: image: ${{ matrix.container }} diff --git a/app/native-multi-image.F90 b/app/native-multi-image.F90 index f42660de7..643f95138 100644 --- a/app/native-multi-image.F90 +++ b/app/native-multi-image.F90 @@ -20,6 +20,7 @@ program native_multi_image #ifndef HAVE_SYNC_IMAGES #define HAVE_SYNC_IMAGES HAVE_SYNC #endif + #ifndef HAVE_COLLECTIVES #define HAVE_COLLECTIVES 1 #endif @@ -35,8 +36,19 @@ program native_multi_image #ifndef HAVE_CO_BROADCAST #define HAVE_CO_BROADCAST HAVE_COLLECTIVES #endif + #ifndef HAVE_TEAM #define HAVE_TEAM 1 +#endif + +#ifndef HAVE_COARRAY +#define HAVE_COARRAY 0 +#endif +#ifndef HAVE_MAIN_COARRAY +#define HAVE_MAIN_COARRAY HAVE_COARRAY +#endif +#ifndef HAVE_ALLOC_COARRAY +#define HAVE_ALLOC_COARRAY HAVE_COARRAY #endif USE, INTRINSIC :: ISO_FORTRAN_ENV @@ -46,6 +58,11 @@ program native_multi_image integer :: team_id type(TEAM_TYPE) :: subteam, res # endif +# if HAVE_MAIN_COARRAY + integer :: sca_int_1[*] + integer :: sca_int_2[2,*] + integer :: sca_int_3[2,3,*] +# endif me = THIS_IMAGE() ni = NUM_IMAGES() @@ -126,6 +143,10 @@ program native_multi_image write(*,'(A,I3)') "After END TEAM statement, TEAM_NUMBER() is ", TEAM_NUMBER() # endif + call sync_all + call test_allocatable_coarray + call test_allocatable_coarray + call sync_all write(*,'(A,I1,A,I1,A)') "Goodbye from image ", me, " of ", ni, " images" @@ -153,6 +174,24 @@ subroutine status(str) call sync_all end subroutine + subroutine test_allocatable_coarray() +# if HAVE_ALLOC_COARRAY + logical, save :: once = .true. + integer, allocatable :: aca_int_1[:] + integer, allocatable :: aca_int_2[:,:] + integer, save, allocatable :: aca_int_3[:,:,:] + if (once) then + once = .false. + call status("Testing ALLOCATABLE coarrays...") + print *, ALLOCATED(aca_int_1), ALLOCATED(aca_int_2), ALLOCATED(aca_int_3) + ALLOCATE(aca_int_1[*]) + ALLOCATE(aca_int_2[2,*]) + ALLOCATE(aca_int_3[2,3,*]) + end if + print *, ALLOCATED(aca_int_1), ALLOCATED(aca_int_2), ALLOCATED(aca_int_3) +# endif + end subroutine + #else stop "Native multi-image test disabled" #endif