Skip to content

Commit

Permalink
Update readme to more modern CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
mathomp4 committed Jan 6, 2025
1 parent 07739aa commit 33ef1d6
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,39 @@ source @env/g5_modules.sh
```

##### Create Build Directory
We currently do not allow in-source builds of GEOSgcm. So we must make a directory:
```
mkdir build
```
The advantages of this is that you can build both a Debug and Release version with the same clone if desired.

##### Run CMake
CMake generates the Makefiles needed to build the model.

CMake generates the Makefiles needed to build the model. This command:
```
cd build
cmake .. -DBASEDIR=$BASEDIR/Linux -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_INSTALL_PREFIX=../install
cmake -B build -S . -DCMAKE_INSTALL_PREFIX=install
```
This will install to a directory parallel to your `build` directory. If you prefer to install elsewhere change the path in:

As is, this command assumes you are in the root of the GEOSgcm checkout and will create a `build/` directory in the root of the checkout and install into `install/ parallel to the `build/` directory.

This command has three options:

1. `-B` specifies the build directory.
2. `-S` specifies the source directory (root of the checkout).
3. `-DCMAKE_INSTALL_PREFIX` specifies the installation directory.

If you prefer to install elsewhere change the path in:

```
-DCMAKE_INSTALL_PREFIX=<path>
-DCMAKE_INSTALL_PREFIX=/path/to/install
```
and CMake will install there.

If you prefer your build somewhere else, you can specify that with:
```
-B /path/to/build
```

Finally, if your source is in a different directory than the current one, you can specify that with:
```
-S /path/to/source
```

###### Create and install source tarfile

Note that running with `parallel_build.csh` will create and install a tarfile of the source code at build time. But if CMake is run by hand, this is not the default action (as many who build with CMake by hand are developers and not often running experiments). In order to enable this at install time, add:
Expand All @@ -283,15 +298,15 @@ to your CMake command.

##### Build and Install with Make
```
make -jN install
cmake --build build -j N
```
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 GCM

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

Expand Down

0 comments on commit 33ef1d6

Please sign in to comment.