diff --git a/.circleci/config.yml b/.circleci/config.yml index 9153bf2..7c4ad6c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,9 @@ version: 2.1 executors: - gcc-build-env: + gfortran-large: docker: - - image: gmao/ubuntu20-geos-env-mkl:v6.2.4-openmpi_4.0.5-gcc_10.3.0 + - image: gmao/ubuntu20-geos-env-mkl:v6.2.7-openmpi_4.0.6-gcc_11.2.0 auth: username: $DOCKERHUB_USER password: $DOCKERHUB_AUTH_TOKEN @@ -14,62 +14,102 @@ executors: resource_class: large #MEDIUM# resource_class: medium + ifort-large: + docker: + - image: gmao/ubuntu20-geos-env:v6.2.7-intelmpi_2021.2.0-intel_2021.2.0 + auth: + username: $DOCKERHUB_USER + password: $DOCKERHUB_AUTH_TOKEN + resource_class: large + #MEDIUM# resource_class: medium + workflows: version: 2.1 build-and-test: jobs: - - build: - context: + - build-GEOSfvdycore: + name: build-GEOSfvdycore-on-<< matrix.compiler >> + matrix: + parameters: + compiler: [gfortran, ifort] + context: - docker-hub-creds - - make-experiment: + - make-fv3-experiment: + name: make-fv3-experiment-on-<< matrix.compiler >> + matrix: + parameters: + compiler: [gfortran, ifort] requires: - - build + - build-GEOSfvdycore-on-<< matrix.compiler >> context: - docker-hub-creds - - run-standalone: + - run-fv3-standalone: + name: run-fv3-standalone-on-<< matrix.compiler >> + matrix: + parameters: + compiler: [gfortran, ifort] requires: - - make-experiment + - make-fv3-experiment-on-<< matrix.compiler >> context: - docker-hub-creds jobs: - build: - executor: gcc-build-env + build-GEOSfvdycore: + parameters: + compiler: + type: string + executor: << parameters.compiler >>-large working_directory: /root/project steps: - checkout: path: GEOSfvdycore - run: name: "Versions etc" - command: mpirun --version && gfortran --version && echo $BASEDIR && pwd && ls + command: mpirun --version && << parameters.compiler>> --version && echo $BASEDIR && pwd && ls - run: name: "Mepo clone external repos" command: | cd ${CIRCLE_WORKING_DIRECTORY}/GEOSfvdycore mepo clone mepo status + - run: + name: "Mepo checkout-if-exists" + command: | + cd ${CIRCLE_WORKING_DIRECTORY}/GEOSfvdycore + echo "${CIRCLE_BRANCH}" + if [ "${CIRCLE_BRANCH}" != "develop" ] && [ "${CIRCLE_BRANCH}" != "main" ] + then + mepo checkout-if-exists ${CIRCLE_BRANCH} + fi + mepo status - run: name: "CMake" command: | + mkdir -p /logfiles cd ${CIRCLE_WORKING_DIRECTORY}/GEOSfvdycore - mkdir build - cd build - cmake .. -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CIRCLE_WORKING_DIRECTORY}/workspace/install -DUSE_F2PY=OFF + mkdir -p ${CIRCLE_WORKING_DIRECTORY}/workspace/build-GEOSfvdycore + cd ${CIRCLE_WORKING_DIRECTORY}/workspace/build-GEOSfvdycore + cmake ${CIRCLE_WORKING_DIRECTORY}/GEOSfvdycore -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=<< parameters.compiler >> -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CIRCLE_WORKING_DIRECTORY}/workspace/install-GEOSfvdycore -DUSE_F2PY=OFF |& tee /logfiles/cmake.log - run: name: "Build and install" command: | - cd ${CIRCLE_WORKING_DIRECTORY}/GEOSfvdycore/build - make -j"$(nproc)" install - #MEDIUM# make -j4 install - + cd ${CIRCLE_WORKING_DIRECTORY}/workspace/build-GEOSfvdycore + make -j"$(nproc)" install |& tee /logfiles/make.log + #MEDIUM# make -j4 install |& tee /logfiles/make.log + - store_artifacts: + path: /logfiles # We need to persist the install for the next step + # but only if we are running gcm tests - persist_to_workspace: root: workspace paths: - - install + - install-GEOSfvdycore - make-experiment: - executor: gcc-build-env + make-fv3-experiment: + parameters: + compiler: + type: string + executor: << parameters.compiler >>-large working_directory: /root/project steps: - attach_workspace: @@ -77,7 +117,7 @@ jobs: - run: name: "Run fv3_setup" command: | - cd ${CIRCLE_WORKING_DIRECTORY}/workspace/install/bin + cd ${CIRCLE_WORKING_DIRECTORY}/workspace/install-GEOSfvdycore/bin INPUT_FOR_SETUP=$(cat \<>-large working_directory: /root/project steps: - attach_workspace: @@ -137,8 +181,9 @@ jobs: exit 1 fi - run: - name: "Cat log file" + name: "Copy log files" command: | cd ${CIRCLE_WORKING_DIRECTORY}/workspace/test-fv3-c12 - - cat *.log + cp *.log /logfiles + - store_artifacts: + path: /logfiles diff --git a/.github/workflows/enforce-labels.yml b/.github/workflows/enforce-labels.yml index eba5468..550bab8 100644 --- a/.github/workflows/enforce-labels.yml +++ b/.github/workflows/enforce-labels.yml @@ -8,7 +8,7 @@ jobs: require-label: runs-on: ubuntu-latest steps: - - uses: yogevbd/enforce-label-action@2.2.1 + - uses: yogevbd/enforce-label-action@2.2.2 with: REQUIRED_LABELS_ANY: "0 diff,0 diff trivial,Non 0-diff,0 diff structural" REQUIRED_LABELS_ANY_DESCRIPTION: "Select at least one label ['0 diff', '0 diff trivial', 'Non 0-diff', '0 diff structural']" diff --git a/.github/workflows/release-tarball.yml b/.github/workflows/release-tarball.yml new file mode 100644 index 0000000..467370d --- /dev/null +++ b/.github/workflows/release-tarball.yml @@ -0,0 +1,38 @@ +name: Create Complete Release Tarball + +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }} + + - name: Checkout mepo + uses: actions/checkout@v2 + with: + repository: GEOS-ESM/mepo + path: mepo + + - name: Run mepo + run : | + cd ${GITHUB_WORKSPACE}/${{ github.event.repository.name }}-${{ github.event.release.tag_name }} + ${GITHUB_WORKSPACE}/mepo/mepo clone + + - name: Create tarball + run: | + tar --exclude-vcs --exclude=.mepo -cf ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.COMPLETE.tar ${{ github.event.repository.name }}-${{ github.event.release.tag_name }} + xz -T6 ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.COMPLETE.tar + + - name: Upload tarball + run: | + gh release upload ${{ github.event.release.tag_name }} ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.COMPLETE.tar.xz -R ${{ github.repository_owner }}/${{ github.event.repository.name }} + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + diff --git a/.gitignore b/.gitignore index 78f284c..8fd879f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /.mepo/ parallel_build.o* log.* +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index e03008c..df4fc21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW) project ( GEOSfvdycore - VERSION 1.2.7 + VERSION 1.3 LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") @@ -18,16 +18,24 @@ if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + "Debug" "Release" "Aggressive") endif () set (DOING_GEOS5 YES) # Should find a better place for this - used in Chem component set (ACG_FLAGS -v) + +# This flag at R4 means that FV3 is compiled at R4 and *linked* to +# FMS built at R4. set (FV_PRECISION "R4" CACHE STRING "Precision of FV3 core (R4, R4R8, R8)") -list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/@cmake") +# mepo can now clone subrepos in three styles +foreach (dir cmake @cmake cmake@) + if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/${dir}) + list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/${dir}") + endif () +endforeach () include (esma) ecbuild_declare_project() @@ -38,8 +46,9 @@ add_definitions(-Dsys${CMAKE_SYSTEM_NAME} -DESMA64) add_definitions(${MPI_Fortran_COMPILE_FLAGS}) include_directories(${MPI_Fortran_INCLUDE_PATH}) +esma_mepo_style(env env_dir) +esma_add_subdirectory (${env_dir}) # Recursively build source tree -add_subdirectory (@env) add_subdirectory (src) # https://www.scivision.dev/cmake-auto-gitignore-build-dir/ @@ -54,4 +63,5 @@ install( DESTINATION ${CMAKE_INSTALL_PREFIX} ) - +# Adds abiilty to tar source +include (esma_cpack) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..b616a27 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,126 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "base-configure", + "hidden": true, + "displayName": "Base Configure Settings", + "description": "Sets build and install directories", + "binaryDir": "${sourceDir}/build-${presetName}", + "cacheVariables": { + "BASEDIR": "$env{BASEDIR}", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/install-${presetName}", + "CMAKE_BUILD_TYPE": "${presetName}" + } + }, + { + "name": "base-gnu", + "hidden": true, + "inherits": "base-configure", + "displayName": "Base GNU Make Config", + "description": "Sets GNU Make generator", + "generator": "Unix Makefiles" + }, + { + "name": "base-ninja", + "hidden": true, + "inherits": "base-configure", + "displayName": "Base Ninja Config", + "description": "Sets Ninja generator", + "generator": "Ninja" + }, + { + "name": "Release", + "inherits": "base-gnu", + "displayName": "Release Configure", + "description": "Release build using GNU Make generator" + }, + { + "name": "Debug", + "inherits": "base-gnu", + "displayName": "Debug Configure", + "description": "Debug build using GNU Make generator" + }, + { + "name": "Aggressive", + "inherits": "base-gnu", + "displayName": "Aggressive Configure", + "description": "Aggressive build using GNU Make generator" + }, + { + "name": "Release-Ninja", + "inherits": "base-ninja", + "displayName": "Release Ninja Configure", + "description": "Release build using Ninja generator" + }, + { + "name": "Debug-Ninja", + "inherits": "base-ninja", + "displayName": "Debug Ninja Configure", + "description": "Debug build using Ninja generator" + }, + { + "name": "Aggressive-Ninja", + "inherits": "base-ninja", + "displayName": "Aggressive Ninja Configure", + "description": "Aggressive build using Ninja generator" + } + ], + "buildPresets": [ + { + "name": "base-build", + "hidden": true, + "displayName": "Base Build Config", + "description": "Sets default build options", + "jobs": 6, + "targets": ["install"] + }, + { + "name": "Release", + "configurePreset": "Release", + "inherits": "base-build", + "displayName": "Release Build", + "description": "Release build using GNU Make generator" + }, + { + "name": "Debug", + "configurePreset": "Debug", + "inherits": "base-build", + "displayName": "Debug Build", + "description": "Debug build using GNU Make generator" + }, + { + "name": "Aggressive", + "configurePreset": "Aggressive", + "inherits": "base-build", + "displayName": "Aggressive Build", + "description": "Aggressive build using GNU Make generator" + }, + { + "name": "Release-Ninja", + "configurePreset": "Release-Ninja", + "inherits": "base-build", + "displayName": "Release Ninja Build", + "description": "Release build using Ninja generator" + }, + { + "name": "Debug-Ninja", + "configurePreset": "Debug-Ninja", + "inherits": "base-build", + "displayName": "Debug Ninja Build", + "description": "Debug build using Ninja generator" + }, + { + "name": "Aggressive-Ninja", + "configurePreset": "Aggressive-Ninja", + "inherits": "base-build", + "displayName": "Aggressive Ninja Build", + "description": "Aggressive build using Ninja generator" + } + ] +} diff --git a/README.md b/README.md index 4eed344..5d85a41 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,124 @@ which obtains the latest `git`, `CMake`, and `mepo` modules. #### Obtain the Model +On GitHub, there are three ways to clone the model: SSH, HTTPS, or GitHub CLI. +The first two are "git protocols" which determine how `git` communicates with +GitHub: either through https or ssh. (The latter is a CLI that uses either ssh or +https protocol underneath.) + +For developers of GEOS, the SSH git protocol is recommended as it can avoid some issues if +[two-factor authentication +(2FA)](https://docs.github.com/en/github/authenticating-to-github/securing-your-account-with-two-factor-authentication-2fa) +is enabled on GitHub. + +##### SSH + +To clone the GEOSfvdycore using the SSH url (starts with `git@github.com`), you run: +``` +git clone git@github.com:GEOS-ESM/GEOSfvdycore.git +``` + +###### Permission denied (publickey) + +If this is your first time using GitHub with any SSH URL, you might get this +error: +``` +Permission denied (publickey). +fatal: Could not read from remote repository. + +Please make sure you have the correct access rights +and the repository exists. +``` + +If you do see this, you need to [upload an ssh +key](https://docs.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account) +to your GitHub account. This needs to be done on any machine that you want to +use the SSH URL through. + + +##### HTTPS + +To clone the model through HTTPS you run: + ``` git clone https://github.com/GEOS-ESM/GEOSfvdycore.git ``` +Note that if you use the HTTPS URL and have 2FA set up on GitHub, you will need +to use [personal access +tokens](https://docs.github.com/en/github/authenticating-to-github/accessing-github-using-two-factor-authentication#authenticating-on-the-command-line-using-https) +as a password. + +##### GitHub CLI + +You can also use the [GitHub CLI](https://cli.github.com/) with: +``` +gh repo clone GEOS-ESM/GEOSfvdycore +``` + +Note that when you first use `gh`, it will ask what your preferred git protocol +is (https or ssh) to use "underneath". The caveats above will apply to whichever +you choose. + +--- + +### Single Step Building of the Model + +If all you wish is to build the model, you can run `parallel_build.csh` from a head node. Doing so will checkout all the external repositories of the model and build it. When done, the resulting model build will be found in `build/` and the installation will be found in `install/` with setup scripts like `fv3_setup` in `install/bin`. + +#### Develop Version of GEOSfvdycore + +`parallel_build.csh` provides a special flag for checking out the +development branch of GMAO_Shared. If you run: + +``` +parallel_build.csh -develop +``` +then `mepo` will run: + +``` +mepo develop GMAO_Shared +``` + +#### Debug Version of GEOSfvdycore + +To obtain a debug version, you can run `parallel_build.csh -debug` which will build with debugging flags. This will build in `build-Debug/` and install into `install-Debug/`. + --- -#### Use mepo to checkout the model + +### Multiple Steps for Building the Model + +The steps detailed below are essentially those that `parallel_build.csh` performs for you. Either method should yield identical builds. + +#### Mepo + +The GEOSfvdycore is comprised of a set of sub-repositories. These are +managed by a tool called [mepo](https://github.com/GEOS-ESM/mepo). To +clone all the sub-repos, you can run `mepo clone` inside the fixture: + ``` cd GEOSfvdycore mepo clone ``` +The first command initializes the multi-repository and the second one +clones and assembles all the sub-repositories according to +`components.yaml` + +#### Checking out develop branch of GMAO_Shared + +To get development branch of GMAO_Shared (a la +the `-develop` flag for `parallel_build.csh`, one needs to run the +equivalent `mepo` command. As mepo itself knows (via `components.yaml`) what the development branch of each +subrepository is, the equivalent of `-develop` for `mepo` is to +checkout the development branch of GMAO_Shared: +``` +mepo develop GMAO_Shared +``` + +This must be done *after* `mepo clone` as it is running a git command in +each sub-repository. + #### Build the Model ##### Load Compiler, MPI Stack, and Baselibs diff --git a/components.yaml b/components.yaml index ae1d03d..7a30cca 100644 --- a/components.yaml +++ b/components.yaml @@ -5,13 +5,13 @@ GEOSfvdycore: env: local: ./@env remote: ../ESMA_env.git - tag: v3.3.1 + tag: v3.4.0 develop: main cmake: local: ./@cmake remote: ../ESMA_cmake.git - tag: v3.5.4 + tag: v3.6.2 develop: develop ecbuild: @@ -22,14 +22,14 @@ ecbuild: GMAO_Shared: local: ./src/Shared/@GMAO_Shared remote: ../GMAO_Shared.git - tag: v1.4.6 + tag: v1.4.10 sparse: ./config/GMAO_Shared.sparse develop: main MAPL: local: ./src/Shared/@MAPL remote: ../MAPL.git - tag: v2.8.4 + tag: v2.8.6 develop: develop FMS: @@ -41,7 +41,7 @@ FMS: FVdycoreCubed_GridComp: local: ./src/Components/@FVdycoreCubed_GridComp remote: ../FVdycoreCubed_GridComp.git - tag: v1.2.16 + tag: v1.2.17 develop: develop fvdycore: diff --git a/parallel_build.csh b/parallel_build.csh index d5cf594..0558ea5 100755 --- a/parallel_build.csh +++ b/parallel_build.csh @@ -30,7 +30,12 @@ while ($#argv) shift end -if (! -d ${ESMADIR}/@env) then +if (-d ${ESMADIR}/@env || -d ${ESMADIR}/env@ || -d ${ESMADIR}/env) then + if ( "$DEVELOP" == "TRUE" ) then + echo "Checking out development branch of GMAO_Shared" + mepo develop GMAO_Shared + endif +else if ($?PBS_JOBID || $?SLURM_JOBID) then echo " mepo clone must be run!" echo " This requires internet access but you are on a compute node" @@ -41,14 +46,9 @@ if (! -d ${ESMADIR}/@env) then mepo init mepo clone if ( "$DEVELOP" == "TRUE" ) then - echo "Checking out development branches of GEOSgcm_GridComp and GEOSgcm_App" - mepo develop GEOSgcm_GridComp GEOSgcm_App - endif + echo "Checking out development branch of GMAO_Shared" + mepo develop GMAO_Shared endif -else - if ( "$DEVELOP" == "TRUE" ) then - echo "Checking out development branches of GEOSgcm_GridComp and GEOSgcm_App" - mepo develop GEOSgcm_GridComp GEOSgcm_App endif endif @@ -57,5 +57,9 @@ set argv = "$origargv" if ( -d ${ESMADIR}/@env ) then ${ESMADIR}/@env/build.csh -esmadir $ESMADIR $argv +else if ( -d ${ESMADIR}/env@ ) then + ${ESMADIR}/env@/build.csh -esmadir $ESMADIR $argv +else if ( -d ${ESMADIR}/env ) then + ${ESMADIR}/env/build.csh -esmadir $ESMADIR $argv endif diff --git a/src/Components/CMakeLists.txt b/src/Components/CMakeLists.txt index fc5d86b..18bdb8c 100644 --- a/src/Components/CMakeLists.txt +++ b/src/Components/CMakeLists.txt @@ -1,2 +1,2 @@ -add_subdirectory (@FVdycoreCubed_GridComp) +esma_add_subdirectory (FVdycoreCubed_GridComp) diff --git a/src/Shared/CMakeLists.txt b/src/Shared/CMakeLists.txt index f0fabf2..4c58917 100644 --- a/src/Shared/CMakeLists.txt +++ b/src/Shared/CMakeLists.txt @@ -1,6 +1,6 @@ esma_add_subdirectories ( - @MAPL - @GMAO_Shared + MAPL + GMAO_Shared ) -add_subdirectory (@FMS fms_r4) +esma_add_subdirectory (FMS RENAME fms_r4)