diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..8e180eb Binary files /dev/null and b/.DS_Store differ diff --git a/book/.DS_Store b/book/.DS_Store new file mode 100644 index 0000000..1d686ab Binary files /dev/null and b/book/.DS_Store differ diff --git a/book/_toc.yml b/book/_toc.yml index 7c8a5e8..51b4683 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -2,9 +2,30 @@ format: jb-book root: intro.md parts: - - caption: Running DALES + - caption: Getting started with DALES! + chapters: + - file: running/settingup.ipynb + - file: running/compilation.ipynb + - caption: Running your first case in DALES + chapters: + - file: running/testcase.ipynb + - file: running/output.ipynb + - caption: Setting up your own case + chapters: + - file: running/basic_namoptions.ipynb + - caption: Advanced DALES options chapters: - file: running/tracers.ipynb + # - file: running/chemistry.ipynb + # - file: running/ibm.ipynb + # - file: running/openbcs.ipynb + # - file: running/gpu.ipynb + - caption: Options outside main branch (for now) + chapters: + - file: running/ibm.ipynb + - caption: Recent publications using DALES + chapters: + - file: running/papers.ipynb - caption: Contributing chapters: - file: developers/usermanual.md \ No newline at end of file diff --git a/book/intro.md b/book/intro.md index a4a18e8..1394aab 100644 --- a/book/intro.md +++ b/book/intro.md @@ -1,7 +1,15 @@ # DALES documentation -Welcome to the DALES documentation! +Welcome to the documentation of the Dutch Atmospheric Large-Eddy Simulation (in short: DALES)! ```{note} This documentation is a work-in-progress and for a future release of DALES. -``` \ No newline at end of file +``` + +The aim of this manual is to provide an up-to-date starting point for new users, explaining how to compile, setup and run the Dutch Atmospheric Large-Eddy Simulation. The manual will cover, among other things, general settings, and options (for example, statistics output), and instructions how to make more advanced cases (for example, simulations with tracers). The principles of the DALES model are described in [Heus et al., 2010](https://doi.org/10.5194/gmd-3-415-2010). + +```{note} +This manual is written for the main-branch (v. X.Y) in mind. Other branches may contain new features that are not necessarily described in this manual. +``` + +At a later stage, this manual may be extended with in-depth information on code structure, variable naming schemes, and implementation details, better enabling people to become _new contributors_ to DALES. diff --git a/book/running/basic_namoptions.ipynb b/book/running/basic_namoptions.ipynb new file mode 100644 index 0000000..f1b6d58 --- /dev/null +++ b/book/running/basic_namoptions.ipynb @@ -0,0 +1,33 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Basic Namoptions\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/chemistry.ipynb b/book/running/chemistry.ipynb new file mode 100644 index 0000000..c46ec44 --- /dev/null +++ b/book/running/chemistry.ipynb @@ -0,0 +1,239 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setting up your system\n", + "\n", + "DALES can handle an arbitrary number of tracers. Examples of tracers are aerosols, hydrometeors, chemical species, et cetera. We distinguish two types of tracers:\n", + "\n", + "- Internal tracers. These are tracers defined internally, by the model itself. For example, the the bulkmicrophysics schemes define various tracers that represent quantities like rain and cloud droplets. The user does not have to provide any input for these tracers.\n", + "- User-defined tracers. These tracers need to be provided by the user in a NetCDF file. \n", + "\n", + "## Preparing the NetCDF file" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, we have to define a new tracer NetCDF file. This file has to be called `tracers..nc`, where `` corresponds to what you have set as `iexpnr` in the `&RUN` section of your namelist." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "import netCDF4 as nc\n", + "\n", + "tracers_nc = nc.Dataset(\"tracers.001.nc\", \"w\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we'll create a dimension corresponding to the vertical levels. Tracers are defined at the full levels (cell centers), so the dimension we have to provide is `zt`. We don't have to provide the actual values of the levels, since those have already been read from `init.001.nc`. This example is based on the benchmark RICO case, which uses 126 vertical levels." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): \n", + " groups: \n" + ] + } + ], + "source": [ + "height_dim = tracers_nc.createDimension(\"zt\", size=126)\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Adding a tracer\n", + "Now we can define our tracer. For this example, we make a tracer that represents carbon dioxide (CO2): " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): float64 co2(zt)\n", + " groups: \n" + ] + } + ], + "source": [ + "co2 = tracers_nc.createVariable(\"co2\", \"f8\", (\"zt\",))\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we provide some (fake) initial profile:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "co2[:] = np.ones(126) * 1e-6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tracer attributes\n", + "We can provide a number of attributes for our new tracer. These attributes either provide extra information for output, or enable extra schemes for the tracer.\n", + "\n", + "| Attribute | Type | Description |\n", + "| ------------ | ------- | ----------- |\n", + "| `long_name` | String | Full name of the tracer |\n", + "| `unit` | String | Unit of the tracer |\n", + "| `molar_mass` | Float | Molar mass of the tracer |\n", + "| `lemis` | Integer | Tracer is emitted (1=True, 0=False)|\n", + "| `lreact` | Integer | Tracer is involved in chemistry |\n", + "| `ldep` | Integer | Tracer is deposited |\n", + "| `lags` | Integer | Tracer is involved in photosynthesis |\n", + "\n", + "Attributes can be set like this:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "NetCDF: Not a valid ID", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mco2\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlong_name\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcarbon dioxide\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2\u001b[0m co2\u001b[38;5;241m.\u001b[39munit \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkg/kg\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m co2\u001b[38;5;241m.\u001b[39mmolar_mass \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m44.009\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4907\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.__setattr__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4613\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.setncattr\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1775\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._set_att\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1700\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._get_format\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:2113\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._ensure_nc_success\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: NetCDF: Not a valid ID" + ] + } + ], + "source": [ + "co2.long_name = \"carbon dioxide\"\n", + "co2.unit = \"kg/kg\"\n", + "co2.molar_mass = \"44.009\"\n", + "co2.lemis = 1\n", + "co2.lags = 1\n", + "\n", + "print(co2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Don't forget to close the NetCDF file:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "tracers_nc.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can check the end result with `ncdump`:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "netcdf tracers.001 {\n", + "dimensions:\n", + "\tzt = 126 ;\n", + "variables:\n", + "\tdouble co2(zt) ;\n", + "data:\n", + "\n", + " co2 = _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _ ;\n", + "}\n" + ] + } + ], + "source": [ + "!ncdump tracers.001.nc" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/compilation.ipynb b/book/running/compilation.ipynb new file mode 100644 index 0000000..e33da3f --- /dev/null +++ b/book/running/compilation.ipynb @@ -0,0 +1,123 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compilation of DALES\n", + "\n", + "## Generic compilation\n", + "The next step after obtaining the code and installing required dependencies, is to build the code. As a starting point, we assume you are still in the main `dales` directory after checking out the main branch via git. It is advised the build the code in a different folder to better maintain overview. We therefore first move one directory up, make a new directory and move into that directory.\n", + "```{code} shell\n", + "cd ../\n", + "mkdir build\n", + "cd build\n", + "```\n", + "\n", + "We then invoke `cmake` on the directory where the code is placed. This will configure the build of the code.\n", + "```{code} shell\n", + "cmake ../dales \n", + "```\n", + "Finally, the code can be build with the following command:\n", + "```{code} shell\n", + "make \n", + "```\n", + "After successfull compilation, the executable `dales4.4` (@team: number to change) is located in the subdirectory `src/`. Compilation of the code may be sped up using the `-j ` specifier, with `nprocs` being the amount of parallel processes.\n", + "\n", + "## Compilation options\n", + "It is possible to specify optional features at the compilation stage of the model. These optional features can be activated by adding them as specifyers to the cmake command, for example, \n", + "```{code} shell\n", + "cmake ../dales -DCMAKE_BUILD_TYPE=Debug\n", + "```\n", + "will produce a debug build. The debug build is much slower than the release build but contains more error checks. A list of other compilation options is shown below\n", + "- Choose between single and double precision for the main prognostic fields and for the Poisson solver (from v4.4, default `64`)\n", + " ```{code} shell\n", + " -DFIELD_PRECISION=32\n", + " ```\n", + " ```{code} shell\n", + " -DPOIS_PRECISION=32\n", + " ```\n", + "- Optional alternative Poisson solvers (since v4.3, default `False`)\n", + " ```{code} shell\n", + " -DUSE_FFTW=True\n", + " ``` \n", + " ```{code} shell\n", + " -DUSE_HYPRE=True\n", + " ``` \n", + "```{caution}\n", + "To use HYPRE or FFTW, the library needs to both be enabled at compilation and selected at runtime by setting the &SOLVER section of the namoptions input file. `FIX LINK: See Alternative Poisson solvers`.\n", + "```\n", + "```{hint}\n", + "`-DPOIS_PRECISION=32` and `-DUSE_HYPRE=True` can be used together, but HYPRE is 64-bit only, so only use this, if it is really what you want.\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compilation on specific clusters\n", + "\n", + "### Delftblue (TUDelft HPC)\n", + "**Tested 20-11-2023**\n", + "```{code} shell\n", + "module load 2023r1-gcc11\n", + "module load openmpi/4.1.4\n", + "module load cmake/3.24.3\n", + "module load netcdf-fortran/4.6.0\n", + "module load fftw/3.3.10\n", + "\n", + "git clone https://github.com/dalesteam/dales\n", + "cd dales\n", + "mkdir build\n", + "cd build\n", + "\n", + "export SYST=gnu-fast\n", + "cmake .. -DUSE_FFTW=True\n", + "\n", + "make -j 8\n", + "```\n", + "\n", + "### Snellius (Dutch National system)\n", + "**Tested with module set 2022**\n", + "```{code} shell\n", + "module load 2022\n", + "module load foss/2022a\n", + "module load netCDF-Fortran/4.6.0-gompi-2022a\n", + "module load CMake/3.23.1-GCCcore-11.3.0\n", + "# module load Hypre/2.25.0-foss-2022a # optional\n", + "\n", + "mkdir build\n", + "cd build\n", + "export SYST=gnu-fast\n", + "cmake .. -DUSE_FFTW=True\n", + "# or, for single precision:\n", + "# cmake .. -DUSE_FFTW=True -DFIELD_PRECISION=32 -DPOIS_PRECISION=32\n", + "\n", + "make -j 8\n", + "```" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/gpu.ipynb b/book/running/gpu.ipynb new file mode 100644 index 0000000..c46ec44 --- /dev/null +++ b/book/running/gpu.ipynb @@ -0,0 +1,239 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setting up your system\n", + "\n", + "DALES can handle an arbitrary number of tracers. Examples of tracers are aerosols, hydrometeors, chemical species, et cetera. We distinguish two types of tracers:\n", + "\n", + "- Internal tracers. These are tracers defined internally, by the model itself. For example, the the bulkmicrophysics schemes define various tracers that represent quantities like rain and cloud droplets. The user does not have to provide any input for these tracers.\n", + "- User-defined tracers. These tracers need to be provided by the user in a NetCDF file. \n", + "\n", + "## Preparing the NetCDF file" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, we have to define a new tracer NetCDF file. This file has to be called `tracers..nc`, where `` corresponds to what you have set as `iexpnr` in the `&RUN` section of your namelist." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "import netCDF4 as nc\n", + "\n", + "tracers_nc = nc.Dataset(\"tracers.001.nc\", \"w\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we'll create a dimension corresponding to the vertical levels. Tracers are defined at the full levels (cell centers), so the dimension we have to provide is `zt`. We don't have to provide the actual values of the levels, since those have already been read from `init.001.nc`. This example is based on the benchmark RICO case, which uses 126 vertical levels." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): \n", + " groups: \n" + ] + } + ], + "source": [ + "height_dim = tracers_nc.createDimension(\"zt\", size=126)\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Adding a tracer\n", + "Now we can define our tracer. For this example, we make a tracer that represents carbon dioxide (CO2): " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): float64 co2(zt)\n", + " groups: \n" + ] + } + ], + "source": [ + "co2 = tracers_nc.createVariable(\"co2\", \"f8\", (\"zt\",))\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we provide some (fake) initial profile:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "co2[:] = np.ones(126) * 1e-6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tracer attributes\n", + "We can provide a number of attributes for our new tracer. These attributes either provide extra information for output, or enable extra schemes for the tracer.\n", + "\n", + "| Attribute | Type | Description |\n", + "| ------------ | ------- | ----------- |\n", + "| `long_name` | String | Full name of the tracer |\n", + "| `unit` | String | Unit of the tracer |\n", + "| `molar_mass` | Float | Molar mass of the tracer |\n", + "| `lemis` | Integer | Tracer is emitted (1=True, 0=False)|\n", + "| `lreact` | Integer | Tracer is involved in chemistry |\n", + "| `ldep` | Integer | Tracer is deposited |\n", + "| `lags` | Integer | Tracer is involved in photosynthesis |\n", + "\n", + "Attributes can be set like this:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "NetCDF: Not a valid ID", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mco2\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlong_name\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcarbon dioxide\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2\u001b[0m co2\u001b[38;5;241m.\u001b[39munit \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkg/kg\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m co2\u001b[38;5;241m.\u001b[39mmolar_mass \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m44.009\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4907\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.__setattr__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4613\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.setncattr\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1775\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._set_att\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1700\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._get_format\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:2113\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._ensure_nc_success\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: NetCDF: Not a valid ID" + ] + } + ], + "source": [ + "co2.long_name = \"carbon dioxide\"\n", + "co2.unit = \"kg/kg\"\n", + "co2.molar_mass = \"44.009\"\n", + "co2.lemis = 1\n", + "co2.lags = 1\n", + "\n", + "print(co2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Don't forget to close the NetCDF file:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "tracers_nc.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can check the end result with `ncdump`:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "netcdf tracers.001 {\n", + "dimensions:\n", + "\tzt = 126 ;\n", + "variables:\n", + "\tdouble co2(zt) ;\n", + "data:\n", + "\n", + " co2 = _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _ ;\n", + "}\n" + ] + } + ], + "source": [ + "!ncdump tracers.001.nc" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/ibm.ipynb b/book/running/ibm.ipynb new file mode 100644 index 0000000..abee15a --- /dev/null +++ b/book/running/ibm.ipynb @@ -0,0 +1,34 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Immersed Boundary Method (IBM)\n", + "\n", + "TO WRITE" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/openbcs.ipynb b/book/running/openbcs.ipynb new file mode 100644 index 0000000..c46ec44 --- /dev/null +++ b/book/running/openbcs.ipynb @@ -0,0 +1,239 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setting up your system\n", + "\n", + "DALES can handle an arbitrary number of tracers. Examples of tracers are aerosols, hydrometeors, chemical species, et cetera. We distinguish two types of tracers:\n", + "\n", + "- Internal tracers. These are tracers defined internally, by the model itself. For example, the the bulkmicrophysics schemes define various tracers that represent quantities like rain and cloud droplets. The user does not have to provide any input for these tracers.\n", + "- User-defined tracers. These tracers need to be provided by the user in a NetCDF file. \n", + "\n", + "## Preparing the NetCDF file" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, we have to define a new tracer NetCDF file. This file has to be called `tracers..nc`, where `` corresponds to what you have set as `iexpnr` in the `&RUN` section of your namelist." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "import netCDF4 as nc\n", + "\n", + "tracers_nc = nc.Dataset(\"tracers.001.nc\", \"w\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we'll create a dimension corresponding to the vertical levels. Tracers are defined at the full levels (cell centers), so the dimension we have to provide is `zt`. We don't have to provide the actual values of the levels, since those have already been read from `init.001.nc`. This example is based on the benchmark RICO case, which uses 126 vertical levels." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): \n", + " groups: \n" + ] + } + ], + "source": [ + "height_dim = tracers_nc.createDimension(\"zt\", size=126)\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Adding a tracer\n", + "Now we can define our tracer. For this example, we make a tracer that represents carbon dioxide (CO2): " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): float64 co2(zt)\n", + " groups: \n" + ] + } + ], + "source": [ + "co2 = tracers_nc.createVariable(\"co2\", \"f8\", (\"zt\",))\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we provide some (fake) initial profile:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "co2[:] = np.ones(126) * 1e-6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tracer attributes\n", + "We can provide a number of attributes for our new tracer. These attributes either provide extra information for output, or enable extra schemes for the tracer.\n", + "\n", + "| Attribute | Type | Description |\n", + "| ------------ | ------- | ----------- |\n", + "| `long_name` | String | Full name of the tracer |\n", + "| `unit` | String | Unit of the tracer |\n", + "| `molar_mass` | Float | Molar mass of the tracer |\n", + "| `lemis` | Integer | Tracer is emitted (1=True, 0=False)|\n", + "| `lreact` | Integer | Tracer is involved in chemistry |\n", + "| `ldep` | Integer | Tracer is deposited |\n", + "| `lags` | Integer | Tracer is involved in photosynthesis |\n", + "\n", + "Attributes can be set like this:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "NetCDF: Not a valid ID", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mco2\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlong_name\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcarbon dioxide\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2\u001b[0m co2\u001b[38;5;241m.\u001b[39munit \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkg/kg\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m co2\u001b[38;5;241m.\u001b[39mmolar_mass \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m44.009\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4907\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.__setattr__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4613\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.setncattr\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1775\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._set_att\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1700\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._get_format\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:2113\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._ensure_nc_success\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: NetCDF: Not a valid ID" + ] + } + ], + "source": [ + "co2.long_name = \"carbon dioxide\"\n", + "co2.unit = \"kg/kg\"\n", + "co2.molar_mass = \"44.009\"\n", + "co2.lemis = 1\n", + "co2.lags = 1\n", + "\n", + "print(co2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Don't forget to close the NetCDF file:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "tracers_nc.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can check the end result with `ncdump`:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "netcdf tracers.001 {\n", + "dimensions:\n", + "\tzt = 126 ;\n", + "variables:\n", + "\tdouble co2(zt) ;\n", + "data:\n", + "\n", + " co2 = _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _ ;\n", + "}\n" + ] + } + ], + "source": [ + "!ncdump tracers.001.nc" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/output.ipynb b/book/running/output.ipynb new file mode 100644 index 0000000..071241c --- /dev/null +++ b/book/running/output.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Output" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/papers.ipynb b/book/running/papers.ipynb new file mode 100644 index 0000000..ef0f3f0 --- /dev/null +++ b/book/running/papers.ipynb @@ -0,0 +1,43 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## List of publications using DALES\n", + "The following contains a _non-exhaustive_ list of publications in which DALES was used.\n", + "\n", + "### 2024\n", + "- Liqui Lung, F., Jakob, C., Siebesma, A. P. and Jansson, F. (2024). _Open boundary conditions for atmospheric large-eddy simulations and their implementation in DALES4.4_. Geoscientific Model Development, **17(9)**, 4053--4076, https://doi.org/10.5194/gmd-17-4053-2024\n", + "### 2023\n", + "- Jansson, F., Janssens, M., Grönqvist, J. H., Siebesma, A. P., Glassmeier, F., Attema, J., et al. (2023). _Cloud Botany: Shallow cumulus clouds in an ensemble of idealized large-domain large-eddy simulations of the trades_. Journal of Advances in Modeling Earth Systems, **15**, e2023MS003796. https://doi.org/10.1029/2023MS003796 \n", + "### 2022\n", + "\n", + "### 2021\n", + "\n", + "### 2020 and before" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/settingup.ipynb b/book/running/settingup.ipynb new file mode 100644 index 0000000..f811774 --- /dev/null +++ b/book/running/settingup.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setting up your system\n", + "\n", + "This section aids you in preparing and setting up your system to run DALES. We assume you are using a UNIX-based system and are familiar with basic terminal commands. First, we will cover the basic requirements to use DALES, which are minimally required. Second, a list of optional librariers/packages is given that will enable optimal use of DALES. Finally, we will tell how you to obtain the latest, tested version of the code (i.e., the \"main branch\")." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Requirements\n", + "DALES has a few general requirements for installation and usage:\n", + "- Fortran compiler (e.g., gfortran)\n", + "- MPI implementation (for multi-cpu runs)\n", + "- NetCDF4 libraries (for output/input)\n", + "- CMake libraries\n", + "- Make (to build the code)\n", + "\n", + "These requirements can be easily installed on most UNIX-based systems via a package manager. For example, on `ubuntu` via the standard package manager\n", + "```{code} shell\n", + "sudo apt install cmake\n", + "```\n", + "On MacOS, a standard way to install packages is via `homebrew`\n", + "```{code} shell\n", + "brew install cmake\n", + "```\n", + "\n", + "When using high-performance conputing (HPC) infrastructures, these requirements may already be pre-installed. Many HPC infrastructures employ sets of software modules in which case the requirements often have to be loaded in. A list of available modules on the system is then given by the following command:\n", + "```{code} shell\n", + "module avail\n", + "```\n", + "Available modules can subsequently be loaded via the `load` command, for example, loading `cmake` via:\n", + "```{code} shell\n", + "module load cmake\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Optional libraries/packages\n", + "The folling list of libraries/packages can (probably: will) make your use of DALES easier:\n", + "- FFTW3 library (better performance Fourier transforms)\n", + "- HYPRE library (for the iterative Poisson solver)\n", + "- Python + numpy + matplotlib (to generate input files and/or analyse output)\n", + "- Python-netcdf4 library (to read in netcdf4 output)\n", + "- CDO (easily merge and operate on multiple netcdf4 files)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Downloading the code\n", + "The next step after installed these libraries and packages is to get the DALES code. The example below uses the `Git` software for this purpose. After going to the destination path on your system, download the code by using the command below\n", + "```{code} shell\n", + " % git clone https://github.com/dalesteam/dales.git\n", + "```\n", + "\n", + "Here, a new directory called `dales` should have appeared. By default, the latest main branch is checked out inside this directory (denoted by the `*`). This can be confirmed by doing the following\n", + "```{code} shell\n", + "cd dales\n", + "git branch\n", + "```\n", + "which should give as output\n", + "```{code} shell\n", + " dales % * main\n", + "```\n", + "\n", + "Other available branches of the main repository can be viewed with the `-a` option\n", + "```{code} shell\n", + " dales % git branch -a\n", + "* main\n", + "remotes/origin/3.1\n", + "remotes/origin/3.2\n", + "remotes/origin/4.1\n", + "remotes/origin/4.1_TROFFEEhack\n", + "remotes/origin/4.1_aero_m7\n", + "...\n", + "```\n", + "\n", + "Checking out a specific branch (e.g., the `ruisdael` bracnh) is done via\n", + "```{code} shell\n", + "git checkout -b remotes/origin/ruisdael\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Planning on coding yourself in DALES?\n", + "If you plan to change parts of the code and want to keep track of your changes, it may be worthwhile to use your personal Github account and first fork the main repository. The steps to get the code on your system are then slightly different.\n", + "\n", + "```{code} shell\n", + "git remote add origin https://github.com//dales.git\n", + "git remote add upstream https://github.com/dalesteam/dales.git\n", + "\n", + "git config --global user.name \"YOUR NAME\"\n", + "git config checkout.defaultRemote origin\n", + "\n", + "git fetch --all\n", + "\n", + "git checkout -b main origin/main\n", + "```\n", + "```{note}\n", + "This option will checkout the code in your current directory, _without_ first making a separate `dales` destination directory.\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/something.ipynb b/book/running/something.ipynb new file mode 100644 index 0000000..4ec3076 --- /dev/null +++ b/book/running/something.ipynb @@ -0,0 +1,239 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Running a case with tracers\n", + "\n", + "DALES can handle an arbitrary number of tracers. Examples of tracers are aerosols, hydrometeors, chemical species, et cetera. We distinguish two types of tracers:\n", + "\n", + "- Internal tracers. These are tracers defined internally, by the model itself. For example, the the bulkmicrophysics schemes define various tracers that represent quantities like rain and cloud droplets. The user does not have to provide any input for these tracers.\n", + "- User-defined tracers. These tracers need to be provided by the user in a NetCDF file. \n", + "\n", + "## Preparing the NetCDF file" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First, we have to define a new tracer NetCDF file. This file has to be called `tracers..nc`, where `` corresponds to what you have set as `iexpnr` in the `&RUN` section of your namelist." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "import netCDF4 as nc\n", + "\n", + "tracers_nc = nc.Dataset(\"tracers.001.nc\", \"w\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Next, we'll create a dimension corresponding to the vertical levels. Tracers are defined at the full levels (cell centers), so the dimension we have to provide is `zt`. We don't have to provide the actual values of the levels, since those have already been read from `init.001.nc`. This example is based on the benchmark RICO case, which uses 126 vertical levels." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): \n", + " groups: \n" + ] + } + ], + "source": [ + "height_dim = tracers_nc.createDimension(\"zt\", size=126)\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Adding a tracer\n", + "Now we can define our tracer. For this example, we make a tracer that represents carbon dioxide (CO2): " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "root group (NETCDF4 data model, file format HDF5):\n", + " dimensions(sizes): zt(126)\n", + " variables(dimensions): float64 co2(zt)\n", + " groups: \n" + ] + } + ], + "source": [ + "co2 = tracers_nc.createVariable(\"co2\", \"f8\", (\"zt\",))\n", + "print(tracers_nc)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "And we provide some (fake) initial profile:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "co2[:] = np.ones(126) * 1e-6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Tracer attributes\n", + "We can provide a number of attributes for our new tracer. These attributes either provide extra information for output, or enable extra schemes for the tracer.\n", + "\n", + "| Attribute | Type | Description |\n", + "| ------------ | ------- | ----------- |\n", + "| `long_name` | String | Full name of the tracer |\n", + "| `unit` | String | Unit of the tracer |\n", + "| `molar_mass` | Float | Molar mass of the tracer |\n", + "| `lemis` | Integer | Tracer is emitted (1=True, 0=False)|\n", + "| `lreact` | Integer | Tracer is involved in chemistry |\n", + "| `ldep` | Integer | Tracer is deposited |\n", + "| `lags` | Integer | Tracer is involved in photosynthesis |\n", + "\n", + "Attributes can be set like this:" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "NetCDF: Not a valid ID", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[13], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mco2\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlong_name\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcarbon dioxide\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2\u001b[0m co2\u001b[38;5;241m.\u001b[39munit \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkg/kg\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m co2\u001b[38;5;241m.\u001b[39mmolar_mass \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m44.009\u001b[39m\u001b[38;5;124m\"\u001b[39m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4907\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.__setattr__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:4613\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4.Variable.setncattr\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1775\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._set_att\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:1700\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._get_format\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32msrc/netCDF4/_netCDF4.pyx:2113\u001b[0m, in \u001b[0;36mnetCDF4._netCDF4._ensure_nc_success\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: NetCDF: Not a valid ID" + ] + } + ], + "source": [ + "co2.long_name = \"carbon dioxide\"\n", + "co2.unit = \"kg/kg\"\n", + "co2.molar_mass = \"44.009\"\n", + "co2.lemis = 1\n", + "co2.lags = 1\n", + "\n", + "print(co2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Don't forget to close the NetCDF file:" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "tracers_nc.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can check the end result with `ncdump`:" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "netcdf tracers.001 {\n", + "dimensions:\n", + "\tzt = 126 ;\n", + "variables:\n", + "\tdouble co2(zt) ;\n", + "data:\n", + "\n", + " co2 = _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, \n", + " _, _, _, _, _, _, _ ;\n", + "}\n" + ] + } + ], + "source": [ + "!ncdump tracers.001.nc" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/testcase.ipynb b/book/running/testcase.ipynb new file mode 100644 index 0000000..c0080db --- /dev/null +++ b/book/running/testcase.ipynb @@ -0,0 +1,32 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# TEST CASE\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "dalesdocs", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.13.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/book/running/tracers.001.nc b/book/running/tracers.001.nc new file mode 100644 index 0000000..e935186 Binary files /dev/null and b/book/running/tracers.001.nc differ