Skip to content

Commit

Permalink
Merge pull request #30 from GEOS-ESM/feature/mathomp4/update-ctm-to-p…
Browse files Browse the repository at this point in the history
…resent

Updates for CTM to Bring in-line with GCM v10.19.0
  • Loading branch information
mmanyin authored May 21, 2021
2 parents bf701e4 + 1e673f1 commit e0810b6
Show file tree
Hide file tree
Showing 42 changed files with 1,776 additions and 663 deletions.
53 changes: 44 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,63 @@
version: 2
jobs:
build:
version: 2.1

executors:
gcc-build-env:
docker:
- image: gmao/geos-build-env-gcc-source:6.0.4
- image: gmao/ubuntu20-geos-env-mkl:v6.1.0-openmpi_4.0.5-gcc_10.2.0
auth:
username: $DOCKERHUB_USER
password: $DOCKERHUB_AUTH_TOKEN
environment:
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
OMPI_MCA_btl_vader_single_copy_mechanism: none
resource_class: large
#MEDIUM# resource_class: medium

workflows:
version: 2.1
build-test:
jobs:
- build-GEOSctm:
context:
- docker-hub-creds

jobs:
build-GEOSctm:
executor: gcc-build-env
working_directory: /root/project
steps:
- checkout
- checkout:
path: GEOSctm
- run:
name: "Versions etc"
command: mpirun --version && gfortran --version && echo $BASEDIR && pwd && ls
- run:
name: "Mepo clone external repos"
command: |
mepo init
cd ${CIRCLE_WORKING_DIRECTORY}/GEOSctm
mepo clone
mepo status
- run:
name: "Mepo checkout-if-exists"
command: |
cd ${CIRCLE_WORKING_DIRECTORY}/GEOSctm
echo "${CIRCLE_BRANCH}"
if [ "${CIRCLE_BRANCH}" != "develop" ] && [ "${CIRCLE_BRANCH}" != "master" ] && [ "${CIRCLE_BRANCH}" != "main" ]
then
mepo checkout-if-exists ${CIRCLE_BRANCH}
fi
mepo status
- run:
name: "CMake"
command: |
cd ${CIRCLE_WORKING_DIRECTORY}/GEOSctm
mkdir build
cd build
cmake .. -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_BUILD_TYPE=Debug
cmake .. -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_BUILD_TYPE=Debug -DUSE_F2PY=OFF
- run:
name: "Build"
command: |
cd build
make -j2 install
cd ${CIRCLE_WORKING_DIRECTORY}/GEOSctm/build
make -j"$(nproc)" install
#MEDIUM# make -j4 install
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# Order is important; the last matching pattern takes the most
# precedence.

# Everything in GEOSgcm should be owned by the GCM Gatekeepers
* @GEOS-ESM/ctm-gatekeepers

# The GCM gatekeepers and CMake should know/approve these
/.github/ @GEOS-ESM/cmake-team @GEOS-ESM/ctm-gatekeepers
/.circleci/ @GEOS-ESM/cmake-team @GEOS-ESM/ctm-gatekeepers
/.codebuild/ @GEOS-ESM/cmake-team @GEOS-ESM/ctm-gatekeepers

# The GEOS CMake Team is the CODEOWNER for the CMakeLists.txt files in this repository
CMakeLists.txt @GEOS-ESM/cmake-team

# The GEOS CMake Team should be notified about and approve config changes
/config/ @GEOS-ESM/cmake-team
61 changes: 61 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build Tests

on:
pull_request:
types: [opened, synchronize, reopened]
# Do not run if the only files changed cannot affect the build
paths-ignore:
- "**.md"
- "parallel_build.csh"
- ".github/CODEOWNERS"
- ".codebuild/**"
- ".circleci/**"

jobs:
build_ctm:
name: Build GEOSctm
if: "!contains(github.event.pull_request.labels.*.name, '0 diff trivial')"
runs-on: ubuntu-latest
container:
image: gmao/ubuntu20-geos-env-mkl:v6.1.0-openmpi_4.0.5-gcc_10.2.0
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
env:
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
OMPI_MCA_btl_vader_single_copy_mechanism: none
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout CTM
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Versions etc.
run: |
gfortran --version
mpirun --version
echo $BASEDIR
- name: Mepo clone external repos
run: |
mepo clone
mepo status
mepo status
- name: Update other branches
if:
"!contains('refs/heads/main,refs/heads/develop', github.ref)"
run: |
mepo checkout-if-exists ${GITHUB_HEAD_REF}
mepo status
- name: CMake
run: |
mkdir build
cd build
cmake .. -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_BUILD_TYPE=Debug -DMPIEXEC_PREFLAGS='--oversubscribe' -DUSE_F2PY=OFF
- name: Build
run: |
cd build
make -j4 install
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*~
/@cmake/
/@modules/
/cmake/
/cmake@/
/@env/
/BUILD/
/build*/
/install*/
parallel_build.o*
/env/
/env@/
/.mepo/
parallel_build.o*
log.*
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_policy (SET CMP0054 NEW)

project (
GEOSctm
VERSION 1.0
VERSION 2.0
LANGUAGES Fortran CXX C) # Note - CXX is required for ESMF

if ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
Expand All @@ -25,9 +25,7 @@ set (DOING_GEOS5 YES)

# Should find a better place for this - used in Chem component
set (ACG_FLAGS -v)
set (F2PYEXT .so)
set (F2PY_SUFFIX .so)
set (FV_PRECISION R8)
set (FV_PRECISION "R8" CACHE STRING "Precision of FV3 core (R4, R4R8, R8)")

list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/@cmake")
include (esma)
Expand All @@ -44,3 +42,16 @@ include_directories(${MPI_Fortran_INCLUDE_PATH})
add_subdirectory (@env)
add_subdirectory (src)

# https://www.scivision.dev/cmake-auto-gitignore-build-dir/
# --- auto-ignore build directory
if(NOT EXISTS ${PROJECT_BINARY_DIR}/.gitignore)
file(WRITE ${PROJECT_BINARY_DIR}/.gitignore "*")
endif()

# Piggyback that file into install
install(
FILES ${PROJECT_BINARY_DIR}/.gitignore
DESTINATION ${CMAKE_INSTALL_PREFIX}
)


54 changes: 0 additions & 54 deletions Externals.cfg

This file was deleted.

87 changes: 79 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

In your `.bashrc` or `.tcshrc` or other rc file add a line:

##### NCCS (SLES11)

##### NCCS
```
module use -a /discover/swdev/gmao_SIteam/modulefiles-SLES11
module use -a /discover/swdev/gmao_SIteam/modulefiles-SLES12
```

##### NAS
Expand All @@ -33,19 +32,74 @@ Now load the `GEOSenv` module:
```
module load GEOSenv
```
which obtains the latest `git`, `CMake`, and `manage_externals` modules.
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 GEOSctm using the SSH url (starts with `[email protected]`), you run:
```
git clone [email protected]:GEOS-ESM/GEOSctm.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/GEOSctm.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/GEOSctm
```

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 `gcm_setup` and `fvsetup` in `install/bin`.
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 `ctm_setup` in `install/bin`.

#### Debug Version of GEOS

Expand All @@ -57,12 +111,21 @@ To obtain a debug version, you can run `parallel_build.csh -debug` which will bu

The steps detailed below are essentially those that `parallel_build.csh` performs for you. Either method should yield identical builds.

##### Checkout externals
#### Mepo

The GEOS CTM 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 GEOSctm
checkout_externals
mepo clone
```

The first command initializes the multi-repository and the second one
clones and assembles all the sub-repositories according to
`components.yaml`

#### Build the Model

##### Load Compiler, MPI Stack, and Baselibs
Expand Down Expand Up @@ -96,6 +159,14 @@ and CMake will install there.

##### Build and Install with Make
```
make -j6 install
make -jN install
```
where `N` is the number of parallel processes. On discover head nodes, this should only be as high as 2 due to limits on the head nodes. On a compute node, you can set `N` has high as you like, though 8-12 is about the limit of parallelism in our model's make system.

### Run the CTM

Once the model has built successfully, you will have an `install/` directory in your checkout. To run `ctm_setup` go to the `install/bin/` directory and run it there:
```
cd install/bin
./ctm_setup
```
Loading

0 comments on commit e0810b6

Please sign in to comment.