From 6c118aaf70f503c643996d057fdb8565570e1e8d Mon Sep 17 00:00:00 2001 From: Katherine Rasmussen Date: Tue, 16 Jan 2024 11:15:02 -0800 Subject: [PATCH] fix: Update setup scripts in top level directory and in cloud-microphysics subdir. --- cloud-microphysics/setup.sh | 16 ++++++-------- setup.sh | 42 ++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/cloud-microphysics/setup.sh b/cloud-microphysics/setup.sh index 762322804..283cb1ba1 100755 --- a/cloud-microphysics/setup.sh +++ b/cloud-microphysics/setup.sh @@ -54,7 +54,6 @@ if ! command -v brew > /dev/null ; then fi fi - brew tap fortran-lang/fortran # required for building fpm brew install fortran-lang/fortran/fpm netcdf netcdf-fortran pkg-config coreutils # coreutils supports `realpath` below @@ -120,19 +119,16 @@ if [ $CI = true ]; then echo "---------------" fi -if command -v fpm > /dev/null 2>&1; then - brew tap fortran-lang/fortran - brew install fortran-lang/fortran/fpm -fi - echo "$RUN_FPM_SH test" $RUN_FPM_SH test echo "" echo "____________________ cloud-microphysics has been set up! _______________________" echo "" -echo "To run one of the programs in the example subdirectory, enter a command of the" -echo "following form at a shell command prompt after replacing " -echo "with the base name of a file in the example/ subdirectory:" +echo "Usage:" +echo "" +echo "./build/run-fpm.sh run train-cloud-microphysics -- \ " +echo " --base --epochs \ " +echo " [--start ] [--end ] [--stride ]" echo "" -echo "./build/run-fpm.sh run train-cloud-microphysics" +echo "where angular brackets denote user-provided values and square brackets denote optional arguments" diff --git a/setup.sh b/setup.sh index d36ec5b0a..0f36b3df1 100755 --- a/setup.sh +++ b/setup.sh @@ -37,32 +37,40 @@ done set -u # error on use of undefined variable -if ! command -v brew > /dev/null ; then - if ! command -v curl > /dev/null ; then - echo "Please install curl and then rerun ./setup.sh" - exit 1 - fi - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - if [ $(uname) = "Linux" ]; then - if [ -z "$PATH" ]; then - PATH=/home/linuxbrew/.linuxbrew/bin/ - else - PATH=/home/linuxbrew/.linuxbrew/bin/:"$PATH" +if ! command -v gfortran > /dev/null ; then + echo "This script assumes usage of gfortran to compile and build" + echo "When using other Fortran compilers, please ensure you have fpm downloaded and in your path" + echo "Then use the following command to install inference-engine: fpm build --flag \"-fcoarray=single\"." + echo "Please replace the coarray flag with appropriate coarray flag for your compiler" + exit 1 +fi + +if ! command -v fpm > /dev/null ; then + if ! command -v brew > /dev/null ; then + if ! command -v curl > /dev/null ; then + echo "Please install curl and then rerun ./setup.sh" + exit 1 + fi + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [ $(uname) = "Linux" ]; then + if [ -z "$PATH" ]; then + PATH=/home/linuxbrew/.linuxbrew/bin/ + else + PATH=/home/linuxbrew/.linuxbrew/bin/:"$PATH" + fi fi fi + brew tap fortran-lang/fortran # required for building fpm + brew install fortran-lang/fortran/fpm fi - -brew tap fortran-lang/fortran # required for building fpm -brew install fortran-lang/fortran/fpm - -FPM_FLAG="-fcoarray=single -O3" FPM_FC=${FC:-"gfortran-13"} FPM_CC=${CC:-"gcc-13"} mkdir -p build -fpm build --flag ${FPM_FLAG} +fpm build --flag "-fcoarray=single -O3" +fpm test echo "" echo "____________________ Inference-Engine has been set up! _______________________"