From 6935022f525e10d2f8a76a4b90fbdfaaf3ce63b4 Mon Sep 17 00:00:00 2001 From: Dan Bonachea Date: Wed, 8 Jul 2026 16:27:58 -0700 Subject: [PATCH 1/2] native-multi-image: Add test coverage for coarray initialization Initialization for module coarrays remains disabled for now, pending https://github.com/lfortran/lfortran/issues/12163 --- app/native-multi-image.F90 | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/app/native-multi-image.F90 b/app/native-multi-image.F90 index fa7a0c0a..6270ecab 100644 --- a/app/native-multi-image.F90 +++ b/app/native-multi-image.F90 @@ -70,6 +70,9 @@ #ifndef HAVE_MODULE_COARRAY #define HAVE_MODULE_COARRAY HAVE_COARRAY #endif +#ifndef HAVE_COARRAY_INIT +#define HAVE_COARRAY_INIT HAVE_COARRAY +#endif ! coarray query intrinsics #ifndef HAVE_COARRAY_QUERY @@ -108,6 +111,13 @@ end if ; \ END BLOCK +#define COARRAY_INT_INIT_VALUE 123456789 +#if HAVE_COARRAY_INIT +# define COARRAY_INT_INIT = COARRAY_INT_INIT_VALUE +#else +# define COARRAY_INT_INIT +#endif + module helpers USE, INTRINSIC :: ISO_FORTRAN_ENV USE, INTRINSIC :: ISO_C_BINDING, only: c_int8_t @@ -155,13 +165,18 @@ subroutine test_save_extern_coarray() use helpers implicit none logical, save :: once = .true. - integer, save :: esc_int_1[*] - integer, save :: esc_int_2[2,*] - integer, save :: esc_int_3[2:3,4:5,*] + integer, save :: esc_int_1[*] COARRAY_INT_INIT + integer, save :: esc_int_2[2,*] COARRAY_INT_INIT + integer, save :: esc_int_3[2:3,4:5,*] COARRAY_INT_INIT if (once) then once = .false. call status("Testing external SAVE coarrays...") +# if HAVE_COARRAY_INIT + CHECK_VALI(esc_int_1, COARRAY_INT_INIT_VALUE) + CHECK_VALI(esc_int_2, COARRAY_INT_INIT_VALUE) + CHECK_VALI(esc_int_3, COARRAY_INT_INIT_VALUE) +# endif esc_int_1 = 1 esc_int_2 = 2 esc_int_3 = 3 @@ -178,9 +193,9 @@ module coarrays implicit none # if HAVE_MODULE_COARRAY - integer :: msc_int_1[*] - integer :: msc_int_2[2,*] - integer :: msc_int_3[2:3,4:5,*] + integer :: msc_int_1[*] ! COARRAY_INT_INIT + integer :: msc_int_2[2,*] ! COARRAY_INT_INIT + integer :: msc_int_3[2:3,4:5,*] ! COARRAY_INT_INIT # endif public @@ -194,6 +209,11 @@ subroutine test_module_coarray() if (once) then once = .false. call status("Testing module SAVE coarrays...") +# if HAVE_COARRAY_INIT && 0 /* disabled pending LFortran issue #12163 */ + CHECK_VALI(msc_int_1, COARRAY_INT_INIT_VALUE) + CHECK_VALI(msc_int_2, COARRAY_INT_INIT_VALUE) + CHECK_VALI(msc_int_3, COARRAY_INT_INIT_VALUE) +# endif msc_int_1 = 1 msc_int_2 = 2 msc_int_3 = 3 @@ -227,9 +247,9 @@ program native_multi_image type(TEAM_TYPE) :: default_team # endif # if HAVE_MAIN_COARRAY - integer :: sca_int_1[*] - integer :: sca_int_2[2,*] - integer :: sca_int_3[2,3,*] + integer :: sca_int_1[*] COARRAY_INT_INIT + integer :: sca_int_2[2,*] COARRAY_INT_INIT + integer :: sca_int_3[2,3,*] COARRAY_INT_INIT # endif # if HAVE_EVENT_TYPE type(event_type), target :: default_event[*] @@ -338,6 +358,12 @@ program native_multi_image # endif # if HAVE_MAIN_COARRAY +# if HAVE_COARRAY_INIT + call status("Testing main program coarray initialization...") + CHECK_VALI(sca_int_1, COARRAY_INT_INIT_VALUE) + CHECK_VALI(sca_int_2, COARRAY_INT_INIT_VALUE) + CHECK_VALI(sca_int_3, COARRAY_INT_INIT_VALUE) +# endif # if HAVE_COBOUND call status("Testing LCOBOUND/UCOBOUND...") if (THIS_IMAGE() == 1) then From dd0c1549984605c70067bd3daa1c53761f4717b9 Mon Sep 17 00:00:00 2001 From: Dan Bonachea Date: Wed, 8 Jul 2026 16:30:19 -0700 Subject: [PATCH 2/2] CI: Disable HAVE_COARRAY_INIT for flang --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee0a9704..9edd9e01 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -329,7 +329,7 @@ jobs: fi if [ "${NATIVE_MULTI_IMAGE}" == true ] ; then if [[ $COMPILER_VERSION == latest ]] ; then - echo "FFLAGS=$FFLAGS -fcoarray -DHAVE_COARRAY -DHAVE_ALLOC_COARRAY=0 -DHAVE_SAVE_COARRAY=0 -DHAVE_MODULE_COARRAY=0 -DIGNORE_FAILURES=6" >> "$GITHUB_ENV" + echo "FFLAGS=$FFLAGS -fcoarray -DHAVE_COARRAY -DHAVE_ALLOC_COARRAY=0 -DHAVE_SAVE_COARRAY=0 -DHAVE_MODULE_COARRAY=0 -DHAVE_COARRAY_INIT=0 -DIGNORE_FAILURES=6" >> "$GITHUB_ENV" else echo "FFLAGS=$FFLAGS -fcoarray -DIGNORE_FAILURES=8" >> "$GITHUB_ENV" fi