From 1677ce9b71629a858401ec4910524d0fb48e2aad Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Mon, 17 Jun 2024 10:54:22 -0700 Subject: [PATCH 1/2] Add bug workarounds for gfortran-14 associate-stmt bug --- example/learn-addition.F90 | 5 +++-- example/learn-exponentiation.F90 | 5 +++-- example/learn-microphysics-procedures.F90 | 5 +++-- example/learn-multiplication.F90 | 5 +++-- example/learn-power-series.F90 | 5 +++-- example/learn-saturated-mixing-ratio.F90 | 5 +++-- example/train-and-write.F90 | 5 +++-- fpm.toml | 2 +- test/trainable_engine_test_m.F90 | 10 ++++++---- 9 files changed, 28 insertions(+), 19 deletions(-) diff --git a/example/learn-addition.F90 b/example/learn-addition.F90 index 39cb91d09..8d5a35510 100644 --- a/example/learn-addition.F90 +++ b/example/learn-addition.F90 @@ -84,7 +84,7 @@ program learn_addition block real, parameter :: tolerance = 1.E-06 integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -94,7 +94,8 @@ program learn_addition do p = 1, num_pairs print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block diff --git a/example/learn-exponentiation.F90 b/example/learn-exponentiation.F90 index e9a0b9f75..9cdd0efba 100644 --- a/example/learn-exponentiation.F90 +++ b/example/learn-exponentiation.F90 @@ -84,7 +84,7 @@ program learn_exponentiation block real, parameter :: tolerance = 1.E-06 integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -94,7 +94,8 @@ program learn_exponentiation do p = 1, num_pairs print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block diff --git a/example/learn-microphysics-procedures.F90 b/example/learn-microphysics-procedures.F90 index eb03282b0..fe4ac50e8 100644 --- a/example/learn-microphysics-procedures.F90 +++ b/example/learn-microphysics-procedures.F90 @@ -120,7 +120,7 @@ program learn_microphysics_procedures report_network_performance: & block integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -130,7 +130,8 @@ program learn_microphysics_procedures do p = 1, num_pairs print "(6(G13.5,2x))", inputs(p)%values(), network_outputs(p)%values(), desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block report_network_performance diff --git a/example/learn-multiplication.F90 b/example/learn-multiplication.F90 index 23eaa54d8..0c6a8349d 100644 --- a/example/learn-multiplication.F90 +++ b/example/learn-multiplication.F90 @@ -84,7 +84,7 @@ program learn_multiplication block real, parameter :: tolerance = 1.E-06 integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -94,7 +94,8 @@ program learn_multiplication do p = 1, num_pairs print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block diff --git a/example/learn-power-series.F90 b/example/learn-power-series.F90 index 262996171..e730fde1e 100644 --- a/example/learn-power-series.F90 +++ b/example/learn-power-series.F90 @@ -86,7 +86,7 @@ program learn_power_series block real, parameter :: tolerance = 1.E-06 integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -96,7 +96,8 @@ program learn_power_series do p = 1, num_pairs print "(6G13.5, a1, 6G13.5)",network_outputs(p)%values(), "|", desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block diff --git a/example/learn-saturated-mixing-ratio.F90 b/example/learn-saturated-mixing-ratio.F90 index 6b6166ad5..8546f697f 100644 --- a/example/learn-saturated-mixing-ratio.F90 +++ b/example/learn-saturated-mixing-ratio.F90 @@ -119,7 +119,7 @@ program train_saturated_mixture_ratio report_network_performance: & block integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -129,7 +129,8 @@ program train_saturated_mixture_ratio do p = 1, num_pairs print "(4(G13.5,2x))", inputs(p)%values(), network_outputs(p)%values(), desired_outputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block report_network_performance diff --git a/example/train-and-write.F90 b/example/train-and-write.F90 index 86928075a..c12087e5e 100644 --- a/example/train-and-write.F90 +++ b/example/train-and-write.F90 @@ -72,7 +72,7 @@ program train_and_write block real, parameter :: tolerance = 1.E-06 integer p -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else @@ -84,7 +84,8 @@ program train_and_write do p = 1, num_pairs print *,network_outputs(p)%values(),"|", inputs(p)%values(), "|", network_outputs(p)%values() - inputs(p)%values() end do -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block diff --git a/fpm.toml b/fpm.toml index b5402765d..eca2be014 100644 --- a/fpm.toml +++ b/fpm.toml @@ -6,4 +6,4 @@ maintainer = "rouson@lbl.gov" [dependencies] assert = {git = "https://github.com/sourceryinstitute/assert", tag = "1.7.0"} -julienne = {git = "https://github.com/sourceryinstitute/julienne", tag = "442819a6c11a055c94cc29e1f78d935c9736abb5"} +julienne = {git = "https://github.com/sourceryinstitute/julienne", tag = "2ca5c93e11b46395608fd00abbdf797d9be0b3d4"} diff --git a/test/trainable_engine_test_m.F90 b/test/trainable_engine_test_m.F90 index 5fbdc10e4..14af78302 100644 --- a/test/trainable_engine_test_m.F90 +++ b/test/trainable_engine_test_m.F90 @@ -466,14 +466,15 @@ function preserves_identity_mapping() result(test_passes) block real(rkind), parameter :: tolerance = 1.E-06 -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else associate(network_outputs => trainable_engine%infer(inputs)) #endif test_passes = maxval(abs([(network_outputs(i)%values() - inputs(i)%values(), i=1,num_pairs)])) < tolerance -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block @@ -527,14 +528,15 @@ function perturbed_identity_converges() result(test_passes) block real(rkind), parameter :: tolerance = 1.E-06 -#ifdef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ type(tensor_t), allocatable :: network_outputs(:) network_outputs = trainable_engine%infer(inputs) #else associate(network_outputs => trainable_engine%infer(inputs)) #endif test_passes = maxval(abs([(network_outputs(i)%values() - inputs(i)%values(), i=1,num_pairs)])) < tolerance -#ifndef _CRAYFTN +#if defined _CRAYFTN || __GFORTRAN__ +#else end associate #endif end block From 31f9f6b117d47df35880a1dfea22e4ced4b8a403 Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Mon, 17 Jun 2024 11:01:00 -0700 Subject: [PATCH 2/2] Update setup script to `gfortran-14` and update CI --- .github/workflows/CI.yml | 5 +++-- setup.sh | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6cb490efe..0c948d264 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -8,17 +8,18 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macOS-latest] + os: [macOS-12] fail-fast: true env: FC: gfortran - GCC_V: 13 + GCC_V: 14 steps: - name: Checkout code uses: actions/checkout@v2 - name: Install Dependencies MacOS + if: contains(matrix.os, 'mac') run: | brew install gcc@${GCC_V} sudo ln -s $(which gfortran-${GCC_V}) $(dirname $(which gfortran-${GCC_V}))/gfortran diff --git a/setup.sh b/setup.sh index f270d4396..5908ce704 100755 --- a/setup.sh +++ b/setup.sh @@ -74,8 +74,8 @@ if ! command -v fpm > /dev/null ; then fi fi -FPM_FC=${FC:-"gfortran-13"} -FPM_CC=${CC:-"gcc-13"} +FPM_FC=${FC:-"gfortran-14"} +FPM_CC=${CC:-"gcc-14"} fpm test --profile release --flag "-fopenmp"