Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 100 additions & 18 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,126 @@ on: [push, pull_request]

jobs:
Build:
runs-on: [ubuntu-latest]
name: ${{ matrix.compiler }}-${{ matrix.version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ macos-14, macos-15, macos-15-intel, macos-26, ubuntu-24.04 ]
compiler: [ gfortran ]
version: [ 14 ]
extra_flags: [ -g ]
oc_version: [ 2.10.3 ]

include:
- os: ubuntu-24.04
compiler: gfortran
version: 13
extra_flags: -g -ffree-line-length-0
oc_version: 2.10.3

env:
FC: gfortran
GCC_V: 14
COMPILER_VERSION: ${{ matrix.version }}
OC_VERSION: ${{ matrix.oc_version }}
FC: ${{ matrix.compiler }}
FFLAGS: ${{ matrix.extra_flags }}
FPM_FLAGS: --profile release --verbose

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install fpm
uses: fortran-lang/setup-fpm@v7
uses: fortran-lang/setup-fpm@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fpm-version: latest

- name: Get Time
id: time
uses: nanzm/get-time-action@v1.1
uses: nanzm/get-time-action@master
with:
format: 'YYYY-MM'

- name: Setup cache for opencoarrays
- name: Install macOS Dependencies
if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gfortran' && matrix.version == 14 }}
run: |
set -x
brew update
# fpm binary distribution for macOS requires gfortran shared libraries from gcc@12
brew install -v gcc@12
brew install -v opencoarrays gcc@14 open-mpi
#brew --prefix
#ls -alR $(brew --prefix)/bin
echo "FC=gfortran-${COMPILER_VERSION}" >> "$GITHUB_ENV"

- name: Install Ubuntu Native Dependencies
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && matrix.compiler == 'gfortran' }}
run: |
set -x
sudo apt update
sudo apt install -y build-essential pkg-config make
sudo apt install -y gfortran-${COMPILER_VERSION} g++-${COMPILER_VERSION}

- name: OpenCoarrays/MPICH Cache
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' }}
id: cache-opencoarrays
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: "OpenCoarrays-2.10.2/"
key: ${{ steps.time.outputs.time }}
path: OpenCoarrays-${{ matrix.oc_version }}
key: OpenCoarrays-${{ matrix.oc_version }}-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }}-${{ steps.time.outputs.time }}

- name: Install GFortran, OpenCoarrays
- name: OpenCoarrays/MPICH Build
if: ${{ steps.cache-opencoarrays.outputs.cache-hit != 'true' && contains(matrix.os, 'ubuntu') && matrix.container == '' }}
run: |
sudo apt update
sudo apt install -y build-essential gfortran-${GCC_V} g++-${GCC_V} pkg-config make
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_V} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${GCC_V} \
--slave /usr/bin/g++ g++ /usr/bin/g++-${GCC_V}
if [ ! -d OpenCoarrays-2.10.2 ] ; then wget -P . https://github.com/sourceryinstitute/OpenCoarrays/releases/download/2.10.2/OpenCoarrays-2.10.2.tar.gz && tar -xf OpenCoarrays-2.10.2.tar.gz && cd OpenCoarrays-2.10.2 && TERM=xterm ./install.sh -y; fi
set -x
rm -Rf OpenCoarrays-${OC_VERSION}
#OC_URL=https://github.com/sourceryinstitute/OpenCoarrays/releases/download/${OC_VERSION}/OpenCoarrays-${OC_VERSION}.tar.gz
OC_URL=https://github.com/sourceryinstitute/OpenCoarrays/archive/refs/tags/${OC_VERSION}.tar.gz
wget -P . ${OC_URL}
tar -xf ${OC_VERSION}.tar.gz
cd OpenCoarrays-${OC_VERSION}
TERM=xterm ./install.sh --yes-to-all \
--with-fortran gfortran-${COMPILER_VERSION} \
--with-cxx g++-${COMPILER_VERSION} \
--with-c gcc-${COMPILER_VERSION}

- name: Setup Ubuntu Compilers
if: ${{ contains(matrix.os, 'ubuntu') && matrix.container == '' && matrix.compiler == 'gfortran' }}
run: |
set -x
PREFIX="$PWD/OpenCoarrays-${OC_VERSION}/prerequisites/installations"
OC_PATH="$PREFIX/opencoarrays/${OC_VERSION}"
MPI_PATH=$(ls -d $PREFIX/mpich/*)
#ls -alR ${PREFIX}
cat ${OC_PATH}/setup.sh
echo "PATH=${OC_PATH}/bin:${MPI_PATH}/bin:$PATH" >> "$GITHUB_ENV"
echo "FC=gfortran-${COMPILER_VERSION}" >> "$GITHUB_ENV"
echo "FPM_FFLAGS=${FFLAGS}" >> "$GITHUB_ENV"
echo "FPM_CFLAGS=${CFLAGS}" >> "$GITHUB_ENV"
echo "FPM_CXXFLAGS=${CXXFLAGS}" >> "$GITHUB_ENV"
echo "FPM_LDFLAGS=${LDFLAGS}" >> "$GITHUB_ENV"

- name: Version info
run: |
echo == TOOL VERSIONS ==
echo Platform version info:
uname -a
if test -r /etc/os-release ; then grep -e NAME -e VERSION /etc/os-release ; fi
if test -x /usr/bin/sw_vers ; then /usr/bin/sw_vers ; fi
echo
echo PATH="$PATH"
for tool in ${FC} caf mpicc mpif90 fpm ; do
( echo ; set -x ; w=$(which $tool) ; \
if test -n "$w" ; then \
ls -al $w ; ls -alhL $w ; $tool --version || echo ERROR=$? ; \
fi )
done

- name: Build, run, and test
run: |
source OpenCoarrays-2.10.2/prerequisites/installations/opencoarrays/2.10.2/setup.sh
fpm test --compiler caf --runner "cafrun -n 2"
#source OpenCoarrays-${OC_VERSION}/prerequisites/installations/opencoarrays/${OC_VERSION}/setup.sh
fpm test --compiler caf --runner "cafrun -n 2" ${FPM_FLAGS}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Despite advances in microscopy, imaging techniques only capture a very small spa

Prerequisites
-------------
1. A Fortran 2018 compiler (`gfortran` + [OpenCoarrays])
1. A Fortran 2018 compiler with multi-image/coarray support (e.g. `gfortran` + [OpenCoarrays])
2. The Fortran Package Manager

Downloading, Building, and Testing
Expand Down Expand Up @@ -44,8 +44,11 @@ export FOR_COARRAY_NUM_IMAGES=4
fpm test --compiler ifx --profile release --flag "-heap-arrays -coarray"
```

Note this requires a working install of Intel MPI.

#### Single-image (serial) execution
Same as multi-image execution except `FOR_COARRAY_NUM_IMAGES=1`.
Also requires a working install of Intel MPI.

#### Automatic GPU-based acceleration: _Experimental_
The following command is listed here for reference while we investigate what appear to be platform-specific compiler issues causing a crashe when automatic GPU-based acceleration is enabled with the required coarray features:
Expand Down
20 changes: 17 additions & 3 deletions test/subdomain_test_m.F90
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ function concave_laplacian() result(test_diagnosis)

block
real, parameter :: tolerance = 1.0E-06
integer :: nx, ny, nz
logical internally_zero, concave_at_faces, doubly_concave_at_edges, triply_concave_in_corners, constant_away_from_edges

associate(me=>this_image(), n_subdomains=>num_images(), nx=>size(lap_f_vals,1), ny=>size(lap_f_vals,2),nz=>size(lap_f_vals,3))
nx = size(lap_f_vals,1)
ny = size(lap_f_vals,2)
nz = size(lap_f_vals,3)
associate(me=>this_image(), n_subdomains=>num_images())
associate(first_zero_in_x => merge(3, 1, me==1), last_zero_in_x => merge(nx-2, nx, me==n_subdomains))
internally_zero = all(abs(lap_f_vals(first_zero_in_x:last_zero_in_x, 3:ny-2, 3:nz-2)) < tolerance)
end associate
Expand Down Expand Up @@ -197,20 +201,30 @@ function correct_steady_state() result(test_diagnosis)
end associate

associate(residual => T%values() - T_steady)
#ifdef __INTEL_COMPILER
! workaround a typecheck defect observed in ifx 2025.2.1
test_diagnosis = .all. [(residual .isAtLeast. 0.) .and. (residual .isAtMost. tolerance)]
#else
test_diagnosis = .all. ((residual .isAtLeast. 0.) .and. (residual .isAtMost. tolerance))
#endif
end associate
end function

function functional_matches_procedural() result(test_diagnosis)
type(test_diagnosis_t) test_diagnosis
real, parameter :: tolerance = 1.E-06
real, parameter :: tolerance = 1.E-05
integer, parameter :: steps = 1000, n=21
real, parameter :: alpha = 1.
real, parameter :: side=1., boundary_val=1., internal_val=2.

associate( T_f => T_functional(), T_p => T_procedural())
associate(L_infinity_norm => maxval(abs(T_f - T_p)))
#ifdef __INTEL_COMPILER
! workaround a typecheck defect observed in ifx 2025.2.1
test_diagnosis = .all. [T_f .approximates. T_p .within. tolerance]
#else
test_diagnosis = .all. (T_f .approximates. T_p .within. tolerance)
#endif
end associate
end associate

Expand Down Expand Up @@ -249,4 +263,4 @@ function T_procedural()
end function

end function
end module subdomain_test_m
end module subdomain_test_m
Loading