-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from snek5000/doc/final-touches
Final touches to docs and release
- Loading branch information
Showing
20 changed files
with
240 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# How to make a compressed archive of simulation data | ||
|
||
Nek5000 simulations can generate a lot of data files. To reduce the strain in your HPC facility, it is often recommended: | ||
|
||
1. To limit the **number of files** | ||
1. Reduce the **disk usage** | ||
|
||
We can achieve both without erasing any data by using Snek5000 and efficient | ||
compression tools namely [`zstandard`](https://en.wikipedia.org/wiki/Zstd) and | ||
preferably | ||
[`bsdtar`](https://www.freebsd.org/cgi/man.cgi?query=bsdtar&sektion=1&format=html) | ||
(usually faster) if not [GNU `tar`](https://www.gnu.org/software/tar/). If | ||
unavailable some of these can be installed using conda / mamba: | ||
|
||
```bash | ||
conda install -c conda-forge zstandard tar | ||
``` | ||
|
||
Once a simulation is done, you can create the archive using | ||
|
||
```bash | ||
cd path/to/sim | ||
snek-make archive | ||
``` | ||
|
||
The module which does the archiving is described [here](snek5000.util.archive). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# How to control Fortran warnings during compilation | ||
|
||
By default Snek5000 suppresses the compilation warnings. This is because | ||
Nek5000 uses a lot of *legacy tricks* to achieve high performance which | ||
triggers warnings in modern C and Fortran compilers. | ||
|
||
To display the warnings one should adjust the `verbosity` keyword argument for | ||
[`Output.update_snakemake_config`](snek5000.output.base.Output.update_snakemake_config). For example | ||
in your solver's Snakemake file | ||
|
||
```{code-block} python | ||
--- | ||
emphasize-lines: 6 | ||
--- | ||
from snek5000 import ensure_env, get_snek_resource | ||
from snek5000_canonical import short_name, Output | ||
configfile: "config_simul.yml" | ||
Output.update_snakemake_config(config, short_name, verbosity=1) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
jupytext: | ||
formats: ipynb,md:myst | ||
text_representation: | ||
extension: .md | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.1 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# How to export a standalone source code archive which excludes Snek5000 | ||
|
||
Add the following Snakemake rule to your solver's Snakefile (for example see | ||
[snek5000-phill]): | ||
|
||
```python | ||
from phill import short_name, Output | ||
|
||
# generate compile.sh | ||
# =================== | ||
rule generate_compile_sh: | ||
output: | ||
"compile.sh", | ||
run: | ||
from phill.templates import env | ||
|
||
template = env.get_template("compile.sh.j2") | ||
Output.write_compile_sh(template, config, path=output) | ||
|
||
|
||
# create a archive with source files | ||
# ================================== | ||
rule source_archive: | ||
input: | ||
f"{short_name}.box", | ||
f"{short_name}.par", | ||
f"{short_name}.usr", | ||
"SIZE", | ||
"compile.sh", | ||
"makefile_usr.inc", | ||
*list(Output().makefile_usr_sources), | ||
output: | ||
f"{short_name}-source_archive.tar.gz", | ||
shell: | ||
""" | ||
tar cvf {output} {input} | ||
""" | ||
``` | ||
|
||
Now execute in an IPython console to generate source code from your templates | ||
and prescribed parameters. | ||
|
||
```{code-cell} python | ||
--- | ||
tags: [hide-output] | ||
--- | ||
from phill.solver import Simul | ||
params = Simul.create_default_params() | ||
# modify params if necessary | ||
sim = Simul(params) | ||
``` | ||
|
||
Finally make the source code archive: | ||
|
||
```{code-cell} python | ||
--- | ||
tags: [hide-output] | ||
--- | ||
sim.make.exec('source_archive') | ||
``` | ||
|
||
```{code-cell} python | ||
%mv {sim.path_run}/phill_source-archive.tar.gz . | ||
``` | ||
|
||
This archive may now be shared to your colleagues or kept as a standalone | ||
archive which only depends on Nek5000 for compilation. | ||
|
||
[snek5000-phill]: https://github.com/snek5000/snek5000-phill/blob/main/src/phill/Snakefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# How to read / write default parameter values from a `*.par` file | ||
|
||
Snek5000 is capable of parsing existing `*.par` files. This is shown in the [`snek5000-tgv` example](../examples/snek5000-tgv/src/snek5000_tgv/solver.py), | ||
|
||
```{code-block} python | ||
--- | ||
emphasize-lines: 15-17 | ||
--- | ||
from snek5000.solvers.base import SimulNek | ||
from snek5000.params import complete_params_from_par_file | ||
class SimulTGV(SimulNek): | ||
... | ||
@classmethod | ||
def create_default_params(cls): | ||
... | ||
# Read defaults for `params.nek` from `tgv.par.cfg` (original code) | ||
info_solver = cls.info_solver # cls.InfoSolver() | ||
output_cls = info_solver.import_classes()["Output"] | ||
root = output_cls.get_root() | ||
complete_params_from_par_file( | ||
params, root / f"{info_solver.short_name}.par.cfg" | ||
) | ||
``` | ||
|
||
This is useful while porting an existing Nek5000 code as a Snek5000 solver. | ||
[See the function's | ||
documentation](snek5000.params.complete_params_from_par_file) for more details. | ||
|
||
```{note} | ||
In Snek5000 we follow a convention of renaming the `*.par` file as `*.par.cfg` | ||
in the common source code file to distinguish from the generated `*.par` file | ||
for a specific simulation. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# How to rebuild Nek5000 libraries and tools | ||
|
||
For a fresh git clone of Nek5000 sources, Snek5000 takes care of the build | ||
automatically. However if your C and Fortran compiler with its related | ||
toolchain gets an update, or if you change it intentionally you may need to | ||
recompile Nek5000 libraries again. To do so: | ||
|
||
```sh | ||
cd $NEK_SOURCE_ROOT | ||
git clean -xdf | ||
``` | ||
|
||
Next time you execute a Snek5000 solver, the libraries would be rebuild. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# How to run a simulation in the foreground / background | ||
|
||
By default, executing a simulation as | ||
|
||
```{code-block} python | ||
--- | ||
emphasize-lines: 5 | ||
--- | ||
from snek5000_canonical.solver import Simul | ||
params = Simul.create_default_params() | ||
sim = Simul(params) | ||
sim.make.exec('run') | ||
``` | ||
|
||
would launch the Snakemake rule `run` (default, if not specified) which | ||
launches a simulation in the **background** and returns control to the user. | ||
This is useful in monitoring the simulation. For example see the [tutorial for | ||
snek5000-cbox](../tuto_cbox). | ||
|
||
However in HPC clusters you should launch your simulations in the | ||
**foreground**, thus preventing the job from exiting while the simulation is | ||
going on. You can also specify number of MPI processes using the `nproc` keyword argument. For example: | ||
|
||
```{code-block} python | ||
--- | ||
emphasize-lines: 5 | ||
--- | ||
nb_nodes = 2 | ||
nb_procs_per_node = 32 | ||
sim.make.exec( | ||
'run_fg', | ||
nproc=nb_nodes * nb_procs_per_node | ||
) | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters