Skip to content

Commit f82212e

Browse files
authored
Merge pull request #1208 from CliMA/js/docs
update docs
2 parents bcefb53 + 152f6a0 commit f82212e

40 files changed

+352
-110
lines changed

docs/make.jl

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mkpath(GENERATED_DIR)
3939
end
4040
tutorials_jl = flatten_to_array_of_strings(get_second(tutorials))
4141
println("Building literate tutorials...")
42-
tutorials_dir = joinpath(@__DIR__, "tutorials")
42+
tutorials_dir = joinpath(@__DIR__, "src", "tutorials")
4343
tutorials_jl = map(x -> joinpath(tutorials_dir, x), tutorials_jl)
4444
pmap(t -> generate_tutorial(tutorials_dir, t), tutorials_jl)
4545

@@ -51,18 +51,28 @@ include("list_standalone_models.jl")
5151
include("list_diagnostics.jl")
5252
pages = Any[
5353
"Home" => "index.md",
54-
"Getting Started" => "getting_started.md",
55-
"Repository structure" => "folderstructure.md",
54+
"Running your first simulation" => "getting_started.md",
55+
"ClimaLand structure" => [
56+
"Model structure" => "model_structure.md",
57+
"Repository structure" => "repo_structure.md",
58+
],
5659
"Tutorials" => tutorials,
5760
"Standalone models" => standalone_models,
58-
"Diagnostics" => diagnostics,
61+
"Analyzing model output" => [
62+
"Diagnostics" => diagnostics,
63+
"Leaderboard" => "leaderboard/leaderboard.md",
64+
],
65+
"Running on GPU or with MPI" => "architectures.md",
5966
"Calibration" => "calibration.md",
60-
"Leaderboard" => "leaderboard/leaderboard.md",
61-
"Restarts" => "restarts.md",
62-
"Time type" => "timemanager.md",
63-
"Misc. utilities" => "shared_utilities.md",
67+
"Restarting a simulation" => "restarts.md",
68+
"Software utilities" => [
69+
"ITime type" => "itime.md",
70+
"Shared utilities" => "shared_utilities.md",
71+
],
72+
"Physical units" => "physical_units.md",
73+
"Julia background" => "julia.md",
6474
"APIs" => apis,
65-
"Contribution guide" => "Contributing.md",
75+
"Contributor guide" => "contributing.md",
6676
]
6777

6878
mathengine = MathJax(

docs/src/Contributing.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/src/architectures.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Running on GPU or with MPI
2+
3+
ClimaLand.jl is designed to run on either CPU or GPU, and to be compatible with MPI.
4+
This section will explain how to select the architecture you want to run your simulation on.
5+
6+
The CliMA ecosystem uses [ClimaComms.jl](https://github.com/CliMA/ClimaComms.jl)
7+
to control which architecture to run on, and related internals are handled within that package.
8+
This isolation makes specifying the architecture to use relatively simple.
9+
10+
ClimaComms.jl introduces two concepts that we utilize to define the architecture
11+
to run a simulation on: the `device` and the `context`.
12+
13+
The `device` specifies whether we want to run on CPU or GPU.
14+
The `context` contains information about the device, and also defines whether we
15+
want to run on an individual processor or distributedly with MPI.
16+
Since the device is contained within the context's data structure, when we construct
17+
these objects in ClimaLand we simply refer to them as the context.
18+
19+
Below, we have descriptions for how to specify the context when trying to run a
20+
simulation in different setups. There are two ways to do this: internally within a
21+
script/REPL, or in the terminal via environment variables.
22+
23+
For more detailed information, please see the ClimaComms.jl [documentation](https://clima.github.io/ClimaComms.jl/dev/).
24+
25+
## Choosing the architecture within a script/REPL
26+
27+
To select the architecture to use within a script or the REPL, we will
28+
explicitly set the device and context to use. The context is then
29+
automatically used for the rest of the session.
30+
31+
### Running on CPU (without MPI)
32+
33+
```
34+
context = ClimaComms.SingletonCommsContext(ClimaComms.CPUSingleThreaded())
35+
```
36+
37+
### Running on GPU (without MPI)
38+
39+
```
40+
context = ClimaComms.SingletonCommsContext(ClimaComms.CUDADevice())
41+
```
42+
43+
### Running with MPI
44+
45+
On CPU:
46+
```
47+
context = ClimaComms.MPICommsContext(ClimaComms.CPUSingleThreaded())
48+
```
49+
50+
On GPU:
51+
```
52+
context = ClimaComms.MPICommsContext(ClimaComms.CUDADevice())
53+
```
54+
55+
### Default context and device
56+
57+
We can also set the context using the following default constructor. This is useful for runs where
58+
we want to run on CPU and don't have MPI available, perhaps for example in simple local runs.
59+
```
60+
context = ClimaComms.context()
61+
```
62+
63+
This constructor will by default run on CPU without MPI, unless the relevant environment variables are set.
64+
See the section below for more details about controlling the architecture with environment variables.
65+
66+
## Choosing the architecture via environment variables
67+
68+
ClimaComms checks two environment variables to determine which device and context to use: `CLIMACOMMS_DEVICE` and
69+
`CLIMACOMMS_CONTEXT`. Setting these environment variables provides an alternative to defining the device and context
70+
explicitly, as was done above.
71+
72+
### Running on CPU (without MPI)
73+
74+
```
75+
ENV["CLIMACOMMS_DEVICE"] = "CPU"
76+
ENV["CLIMACOMMS_CONTEXT"] = "SINGLETON"
77+
```
78+
79+
### Running on GPU (without MPI)
80+
81+
```
82+
ENV["CLIMACOMMS_DEVICE"] = "CUDA"
83+
ENV["CLIMACOMMS_CONTEXT"] = "SINGLETON"
84+
```
85+
86+
### Running with MPI
87+
88+
On CPU:
89+
```
90+
ENV["CLIMACOMMS_DEVICE"] = "CPU"
91+
ENV["CLIMACOMMS_CONTEXT"] = "MPI"
92+
```
93+
94+
On GPU:
95+
```
96+
ENV["CLIMACOMMS_DEVICE"] = "CUDA"
97+
ENV["CLIMACOMMS_CONTEXT"] = "MPI"
98+
```

docs/src/contributing.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Contributing
2+
3+
Thank you for contributing to `ClimaLand`! We encourage Pull Requests (PRs).
4+
Please do not hesitate to ask questions, or to open issues if something seems amiss
5+
or you'd like a new feature.
6+
7+
## Some useful tips
8+
- When developing code it's best to work on a branch off of the most recent main.
9+
This can be done by running the following commands, where "initials" corresponds to the first and last initial of the person starting the branch.
10+
```
11+
git checkout main
12+
git pull
13+
git checkout -b initials/branch_name
14+
```
15+
16+
- Make sure you add tests for your code in `test/`, appropriate documentation in `docs/`,
17+
and descriptive inline comments throughout the code.
18+
All exported functions and structs must have docstrings.
19+
- When your PR is ready for review, clean up your commit history by squashing to 1 commit per PR
20+
and make sure your code is current with `ClimaLand.jl` main by rebasing.
21+
22+
## Continuous integration
23+
24+
After rebasing your branch, you can ask for review. Fill out the template and
25+
provide a clear summary of what your PR does. When a PR is created or
26+
updated, a set of automated tests are run on the PR in our continuous
27+
integration (CI) system.
28+
29+
ClimaLand.jl's continuous integration contains multiple automated tests,
30+
which are described below. All of these must pass for a PR to be eligible
31+
to merge into the main branch.
32+
33+
### Unit testing
34+
35+
Unit tests are defined in the `test/` folder, and are all listed in the file
36+
`test/runtests.jl`, which allows them to easily be called together.
37+
In our CI, these tests are run via Github Actions on a variety of operating
38+
systems and Julia versions. We also use downgrade tests to check the lower limits
39+
of our Julia package compat bounds, and downstream tests to verify compatibility
40+
with ClimaCoupler.jl.
41+
42+
### Buildkite pipeline
43+
44+
The buildkite pipeline contains a variety of ClimaLand simulations,
45+
which span the complexity of our models and domains.
46+
Some of these simulations have explicit checks, for example comparing
47+
to empirical solutions or output from external codebases, while others
48+
test that the simulation can run without error.
49+
50+
This pipeline also runs our unit test suite on GPU and with MPI,
51+
to ensure all of our source code is compatible with those setups.
52+
53+
### Formatting check
54+
55+
The `JuliaFormatter` test checks if the PR is correctly formatted according
56+
to `.dev/climaformat.jl`. To ensure that this is the case, we recommend running
57+
`julia --project=.dev .dev/climaformat.jl` on each PR before requresting review.
58+
This command will apply the formatter and any changes it detects are necessary.
59+
60+
### Documentation
61+
62+
The `Documentation` test rebuilds the documentation for the PR and checks if the docs
63+
are consistent and generate valid output.

docs/src/diagnostics/users_diagnostics.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ When running a ClimaLand simulations, you have multiple options on how to write
44
You may want all variables, or just a selected few.
55
You may want instantaneous values, at the highest temporal and spatial resolution, or you may want to get averages at hourly or monthly time scale, and integrate in space
66
(for example soil moisture from 0 to 1 meter depth).
7-
You may want to get more specific reductions, such as 10 days maximums, or compute a new variables that is a function of others.
8-
You may want to get your outputs in memory in a Julia Dict, or write them in a NetCDF file.
7+
You may want to get more specific reductions, such as 10 days maximums, or compute a new variables as a function of others.
8+
You may want to get your outputs in memory in a Julia dictionary, or write them in a NetCDF file.
99

1010
This is where ClimaLand Diagnostics comes in for users.
1111

1212
In this documentation page, we first explain how to use default diagnostics and what are the defaults, and then explain how to define your own diagnostics for more advanced users.
1313

1414
## Default Diagnostics
1515

16+
Diagnostics refer to output saved during the simulation, which may be prognostic or diagnostic variables.
17+
Note that this is different from checkpointing the simulation, which has specific requirements.
18+
For information about checkpointing and restarting simulations, please see the page titled
19+
[Restarting Simulations](@ref).
20+
1621
Once you have defined your model and are ready to run a simulation, and after adding ClimaDiagnostics (using ClimaDiagnostics),
1722
you can add default diagnostics to it by doing the following steps:
1823

@@ -161,4 +166,3 @@ viz.plot!(fig, var) # creates an axis inside fig, and plot your var in it.
161166

162167
CairoMakie.save(fig) # saves the figure in current working directory
163168
```
164-

docs/src/getting_started.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Getting Started
22

3-
## For Users
3+
## Installation of Julia and ClimaLand
44

5-
### Installation
5+
ClimaLand is provided as a Julia package, so it requires having Julia installed. Information about Julia packages is available on the [Julia website](https://julialang.org/packages/).
66

77
First, download and install Julia by following the instructions at [https://julialang.org/downloads/](https://julialang.org/downloads/).
8-
Then, you can install the ClimaLand package by doing:
8+
Then, you can launch a [Julia REPL](https://docs.julialang.org/en/v1/stdlib/REPL/) and install the
9+
ClimaLand.jl package by running:
910

1011
```julia
11-
julia> ] # Enter Package REPL mode
12-
Pkg> add ClimaLand # Install ClimaLand
13-
Pkg> # Go back to Julia REPL mode
14-
Julia> using ClimaLand
12+
julia> using Pkg
13+
julia> Pkg.add(ClimaLand)
14+
julia> using ClimaLand
1515
```
1616

1717
A typical land simulation employs several different parameterizations to model the various land-surface processes. Let's start our journet into ClimaLand by looking at one of those.
@@ -59,4 +59,3 @@ Where modules are shown in red, functions are shown in blue, and types are shown
5959

6060
To see the documentation about a particular module, function or type, you can use ? to go in help mode
6161
in the REPL, or `@doc` as in [Parameterization above](#Parameterization).
62-

docs/src/index.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,30 @@ Markdown.parse(String(take!(io)))
1414

1515
ClimaLand is the Land model of the Climate Modeling Alliance (CliMA) Earth System Model, which
1616
also contains other components ([atmosphere](https://github.com/CliMA/ClimaAtmos.jl), [ocean](https://github.com/CliMA/ClimaOcean.jl), [sea-ice](https://github.com/CliMA/ClimaSeaIce.jl)).
17+
Details about the CliMA project can be found on the [project website](https://clima.caltech.edu/).
1718

18-
ClimaLand can be run coupled (or "online") with these other components via [ClimaCoupler](https://github.com/CliMA/ClimaCoupler.jl),
19-
or it can be run as a standalone, via prescribed meteorological data ("offline").
19+
ClimaLand can be run coupled ("online") with these other components via [ClimaCoupler](https://github.com/CliMA/ClimaCoupler.jl),
20+
or it can be run as a standalone model, via prescribed meteorological data ("offline").
2021

21-
ClimaLand library, described in this documentation, is written in the Julia
22+
The ClimaLand library, described in this documentation, is written in the Julia
2223
programming language. It aims to be fast and have a clear syntax. ClimaLand
2324
can run on CPU or GPU, it has a modular design, and is flexible in many ways. This documentation will expand on each of these elements.
2425

25-
## Important Links
26-
27-
- [CliMA Homepage](https://clima.caltech.edu/)
28-
- [CliMA GitHub Organisation](https://github.com/CliMA)
29-
- [ClimaCoupler](https://github.com/CliMA/ClimaCoupler.jl)
30-
- [ClimaAnalysis](https://github.com/CliMA/ClimaAnalysis.jl)
31-
- [Julia Homepage](https://julialang.org)
32-
3326
## Documentation for Users and Developers
3427

3528
ClimaLand has documentation for both users and developers. The documentation for users is aimed at scientists who wants
3629
to run simulations using ClimaLand, whereas the documentation for developers is aimed at contributors of the ClimaLand
3730
code library. As such, users can skip reading the docs for developers, and vice-versa.
3831

39-
## Physical units
32+
## This documentation includes information about:
33+
- How to run your first ClimaLand simulation
34+
- A series of tutorials explaining ClimaLand models and physics
35+
- The structure of ClimaLand models and code
36+
- How to analyze model output, calibrate models using CliMA's pipeline, and restart simulations
37+
- and more!
4038

41-
Note that CliMA, in all its repositories, uses Standard Units, reminded below
42-
43-
| Quantity | Unit Name | SI Symbol | SI Unit Equivalent |
44-
|:----------------------|:----------|:----------|:--------------------|
45-
| Length | Meter | m | 1 m |
46-
| Mass | Kilogram | kg | 1 kg |
47-
| Time | Second | s | 1 s |
48-
| Temperature | Kelvin | K | 1 K |
49-
| Amount of Substance | Mole | mol | 1 mol |
50-
| Energy | Joule | J | 1 J = 1 N·m |
51-
| Power | Watt | W | 1 W = 1 J/s |
52-
| Pressure | Pascal | Pa | 1 Pa = 1 N/m² |
53-
| Frequency | Hertz | Hz | 1 Hz = 1 s⁻¹ |
39+
## Important Links
5440

41+
- [CliMA GitHub Organisation](https://github.com/CliMA)
42+
- [Julia Homepage](https://julialang.org)
43+
- [Julia Manual](https://docs.julialang.org/en/v1/manual/getting-started/)
File renamed without changes.

0 commit comments

Comments
 (0)