Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docs-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
# Include all include::ed files outside doc/ directory!
- 'src/README.unit_testing'
- 'tools/README'
- 'tools/mksurfdata_esmf/README.md'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docs-omnibus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
# Include all include::ed files outside doc/ directory!
- 'src/README.unit_testing'
- 'tools/README'
- 'tools/mksurfdata_esmf/README.md'

pull_request:
# Run on pull requests that change the listed files
Expand All @@ -23,6 +24,7 @@ on:
# Include all include::ed files outside doc/ directory!
- 'src/README.unit_testing'
- 'tools/README'
- 'tools/mksurfdata_esmf/README.md'

workflow_dispatch:

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
# Include all include::ed files outside doc/ directory!
- 'src/README.unit_testing'
- 'tools/README'
- 'tools/mksurfdata_esmf/README.md'

pull_request:
# Run on pull requests that change the listed files
Expand All @@ -26,6 +27,7 @@ on:
# Include all include::ed files outside doc/ directory!
- 'src/README.unit_testing'
- 'tools/README'
- 'tools/mksurfdata_esmf/README.md'

workflow_dispatch:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.. todo::
Delete this page? Domain files aren't needed with nuopc.

``gen_domain`` to create a domain file for datm from a mapping file. ``gen_domain`` is a tool that is a part of CIME. The domain file is then used by BOTH DATM AND CLM to define the grid and land-mask. The general data flow is shown in two figures. :numref:`Figure mkmapdata.sh` shows the general flow for a general global case (or for a regional grid that DOES include ocean). :numref:`Figure mknoocnmap.pl` shows the use of ``mknoocnmap.pl`` (see :ref:`using-mkocnmap`) to create a regional or single-point map file that is then run through ``gen_domain`` to create the domain file for it. As stated before :numref:`Figure Data_Flow_Legend` is the legend for both of these figures. See `the $CIMEROOT/tools/mapping/gen_domain_files/README <https://github.com/ESMCI/cime/blob/master/tools/mapping/gen_domain_files/README>`_ file for more help on ``gen_domain``.
``gen_domain`` to create a domain file for datm from a mapping file. ``gen_domain`` is a tool that is a part of CIME. The domain file is then used by BOTH DATM AND CLM to define the grid and land-mask. The general data flow is shown in two figures. :numref:`Figure mkmapdata.sh` shows the general flow for a general global case (or for a regional grid that DOES include ocean). :numref:`Figure mknoocnmap.pl` shows the use of ``mknoocnmap.pl`` (see :ref:`using-mkocnmap`) to create a regional or single-point map file that is then run through ``gen_domain`` to create the domain file for it. See `the $CIMEROOT/tools/mapping/gen_domain_files/README <https://github.com/ESMCI/cime/blob/master/tools/mapping/gen_domain_files/README>`_ file for more help on ``gen_domain``.

Here we create domain files for a regular global domain.

Expand Down
219 changes: 1 addition & 218 deletions doc/source/users_guide/using-clm-tools/creating-surface-datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,221 +2,4 @@

.. _creating-surface-datasets:

===========================
Creating Surface Datasets
===========================

<!-- ======= -->
## mksurfdata_esmf Purpose
<!-- ======= -->
This tool is intended to generate fsurdat files (surface datasets) and landuse files for the
CTSM. It can generate global, regional, and single-point fsurdat files, as long
as a mesh file is available for the grid.

The subset_data tool allows users to make fsurdat files from existing fsurdat
files when a mesh file is unavailable. Generally, users are encouraged to use the
subset_data tool for generating regional and single-point fsurdat files (see note about regional grids at the end).

<!-- ======= -->
## Building
<!-- ======= -->

<!-- ============= -->
### Build Requirements
<!-- ============= -->

mksurfdata_esmf is a distributed memory parallel program (using Message Passing
Interface -- MPI) that utilizes both ESMF (Earth System Modelling Framework)
for regridding as well as PIO (Parallel I/O) and NetCDF output. As
such, libraries must be built for the following:

1. MPI
2. NetCDF
3. PIO
4. ESMF

In addition for the build: python, bash-shell, CMake and GNU-Make are required

These libraries need to be built such that they can all work together in the
same executable. Hence, the above order may be required in building them.

CTSM submodules that are required are: cime and ccs_config. See [Building](#building-the-executable) on getting
those. A python environment that includes particular packages is also required
we demonstrate how to use the ctsm_pylib environment that we support in CTSM.

Note, PNETCDF is an optional library that can be used, but is NOT required.

#### Use cime to manage the build requirements

See [IMPORTANT NOTE](important note-only-working-on-derecho-currently)

For users working on cime machines you can use the build script to build the
tool. On other machines you'll need to do a port to cime and tell how to build
for that machine. That's talked about in the cime documentation.
And you'll have to make some modifications to the build script.

https://github.com/ESMCI/cime/wiki/Porting-Overview

Machines that already run CTSM or CESM have been ported to cime. So if you can
run the model on your machine, you will be able to build the tool there.

To get a list of the machines that have been ported to cime:

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
cd ../../cime/scripts # or ../../../../cime/scripts for a CESM checkout
./query_config --machines
```

#### NOTE:
In addition to having a port to cime, the machine also needs to have PIO built
and able to be referenced with the env variable PIO which will need to be in
the porting instructions for the machine. An independent PIO library
is available on supported CESM machines.

<!-- ============================================== -->
#### IMPORTANT NOTE: ONLY WORKING ON DERECHO CURRENTLY
<!-- ============================================== -->


> [!IMPORTANT]
> Currently we have run and tested mksurfdata_esmf on Derecho. Please see this github issue about mksurfdata_esmf on other CESM machines:

https://github.com/ESCOMP/CTSM/issues/2341

<!-- ================== -->
### Building the executable
<!-- ================== -->

Before starting, be sure that you have run

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./bin/git-fleximod update # Assuming at the top level of the CTSM/CESM checkout
```

This will bring in CIME and ccs_config which are required for building.

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./gen_mksurfdata_build # For machines with a cime build
```

Note: The pio_iotype value gets set and written to a simple .txt file
by this build script. The value depends on your machine. If not running
on derecho, casper, or izumi, you may need to update this, though
a default value does get set for other machines.

<!-- ========================= -->
## Running for a single submission
<!-- ========================= -->

### Setup ctsm_pylib
Work in the ctsm_pylib environment, which requires the following steps when
running on Derecho. On other machines it will be similar but might be different
in order to get conda in your path and activate the ctsm_pylib environment.

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
module load conda
cd ../.. # or ../../../.. for a CESM checkout)
./py_env_create # Assuming at the top level of the CTSM/CESM checkout
conda activate ctsm_pylib
```

to generate your target namelist:

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./gen_mksurfdata_namelist --help
```

for example try --res 1.9x2.5 --start-year 1850 --end-year 1850:

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./gen_mksurfdata_namelist --res <resolution> --start-year <year1> --end-year <year2>
```

> [!TIP]
> **IF FILES ARE MISSING FROM** /inputdata, a target namelist will be generated
> but with a generic name and with warning to run `./download_input_data` next.
> **IF A SMALLER SET OF FILES IS STILL MISSING AFTER RUNNING** `./download_input_data`
> and rerunning `./gen_mksurfdata_namelist`, then rerun
> `./gen_mksurfdata_namelist with your options needed.
> and rerun `./download_input_data` until
> `./gen_mksurfdata_namelist` finds all files.

Example, to generate your target jobscript (again use --help for instructions):

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./gen_mksurfdata_jobscript_single --number-of-nodes 2 --tasks-per-node 128 --namelist-file target.namelist
qsub mksurfdata_jobscript_single.sh
```

Read note about regional grids at the end.

<!-- ========================================= -->
## Running for the generation of multiple datasets
<!-- ========================================= -->
Work in the ctsm_pylib environment, as explained in earlier section.
gen_mksurfdata_jobscript_multi runs `./gen_mksurfdata_namelist` for you

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
./gen_mksurfdata_jobscript_multi --number-of-nodes 2 --scenario global-present
qsub mksurfdata_jobscript_multi.sh
```

If you are looking to generate all (or a large number of) the datasets or the
single-point (1x1) datasets, you are best off using the Makefile. For example

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
make all # ...or
make all-subset
```

As of 2024/9/12 one needs to generate NEON and PLUMBER2 fsurdat files by
running ./neon_surf_wrapper and ./plumber2_surf_wrapper manually in the
/tools/site_and_regional directory.

<!-- = -->
## NOTES
<!-- = -->

# Guidelines for input datasets to mksurfdata_esmf

> [!TIP]
> ALL raw datasets \*.nc **FILES MUST NOT BE NetCDF4**.

Example to convert to CDF5

``` shell
nccopy -k cdf5 oldfile newfile
```

> [!TIP]
> The LAI raw dataset \*.nc **FILE MUST HAVE** an "unlimited" time dimension

Example to change time to unlimted dimension using the NCO operator ncks.

``` shell
ncks --mk_rec_dmn time file_with_time_equals_12.nc -o file_with_time_unlimited.nc
```

### IMPORTANT KNOWN PROBLEMS

- See github issue https://github.com/ESCOMP/CTSM/issues/3141
- In general we recommend using subset_data and/or fsurdat_modifier for regional grids

<!-- = -->
## FINAL COMMENT
<!-- = -->

The ``$CTSMROOT/tools/mksurfdata_esmf/README.md`` documents the same instructions for creating fsurdat/landuse files needed to run CLM. We repeat that file here:

.. include:: ../../../../tools/mksurfdata_esmf/README.md
:literal:

.. mdinclude:: ../../../../tools/mksurfdata_esmf/README.md
61 changes: 22 additions & 39 deletions tools/mksurfdata_esmf/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Instructions for Using mksurfdata_esmf to Create Surface Datasets

## Table of contents
1. [Purpose](#purpose)
1. [Building](#building)
1. [Running a Single Submission](#running-for-a-single-submission)
1. [Running for Multiple Datasets](#running-for-the-generation-of-multiple-datasets)
1. [Notes](#notes)

<!-- ======= -->
## Purpose
<!-- ======= -->
Expand Down Expand Up @@ -41,16 +34,14 @@ In addition for the build: python, bash-shell, CMake and GNU-Make are required
These libraries need to be built such that they can all work together in the
same executable. Hence, the above order may be required in building them.

CTSM submodules that are required are: cime and ccs_config. See [Building](#building-the-executable) on getting
CTSM submodules that are required are: cime and ccs_config. See :ref:`Building the executable<building-the-executable>` on getting
those. A python environment that includes particular packages is also required
we demonstrate how to use the ctsm_pylib environment that we support in CTSM.

Note, PNETCDF is an optional library that can be used, but is NOT required.

#### Use cime to manage the build requirements

See [IMPORTANT NOTE](important note-only-working-on-derecho-currently)

For users working on cime machines you can use the build script to build the
tool. On other machines you'll need to do a port to cime and tell how to build
for that machine. That's talked about in the cime documentation.
Expand All @@ -69,21 +60,17 @@ cd ../../cime/scripts # or ../../../../cime/scripts for a CESM checkout
./query_config --machines
```

#### NOTE:
In addition to having a port to cime, the machine also needs to have PIO built
and able to be referenced with the env variable PIO which will need to be in
the porting instructions for the machine. An independent PIO library
is available on supported CESM machines.
.. note::

<!-- ============================================== -->
#### IMPORTANT NOTE: ONLY WORKING ON DERECHO CURRENTLY
<!-- ============================================== -->
In addition to having a port to cime, the machine also needs to have PIO built and able to be referenced with the env variable PIO which will need to be in the porting instructions for the machine. An independent PIO library is available on supported CESM machines.

.. caution::

> [!IMPORTANT]
> Currently we have run and tested mksurfdata_esmf on Derecho. Please see this github issue about mksurfdata_esmf on other CESM machines:
**ONLY WORKING ON DERECHO CURRENTLY**

Currently we have run and tested ``mksurfdata_esmf`` on Derecho. Please see [this GitHub issue](https://github.com/ESCOMP/CTSM/issues/2341) about ``mksurfdata_esmf`` on other CESM machines.

https://github.com/ESCOMP/CTSM/issues/2341
.. _building-the-executable:

<!-- ================== -->
### Building the executable
Expand Down Expand Up @@ -139,16 +126,12 @@ for example try --res 1.9x2.5 --start-year 1850 --end-year 1850:
./gen_mksurfdata_namelist --res <resolution> --start-year <year1> --end-year <year2>
```

> [!TIP]
> **IF FILES ARE MISSING FROM** /inputdata, a target namelist will be generated
> but with a generic name and with warning to run `./download_input_data` next.
> **IF A SMALLER SET OF FILES IS STILL MISSING AFTER RUNNING** `./download_input_data`
> and rerunning `./gen_mksurfdata_namelist`, then rerun
> `./gen_mksurfdata_namelist with your options needed.
> and rerun `./download_input_data` until
> `./gen_mksurfdata_namelist` finds all files.
.. tip::
**IF FILES ARE MISSING FROM** /inputdata, a target namelist will be generated but with a generic name and with warning to run ``./download_input_data`` next.

**IF A SMALLER SET OF FILES IS STILL MISSING AFTER RUNNING** ``./download_input_data`` and rerunning ``./gen_mksurfdata_namelist``, then rerun ``./gen_mksurfdata_namelist`` with your options needed. and rerun ``./download_input_data`` until ``./gen_mksurfdata_namelist`` finds all files.

Example, to generate your target jobscript (again use --help for instructions):
Example, to generate your target jobscript (again use --help for instructions):

``` shell
# Assuming pwd is the tools/mksurfdata_esmf directory
Expand Down Expand Up @@ -189,30 +172,30 @@ for example try --res 1.9x2.5 --start-year 1850 --end-year 1850:

# Guidelines for input datasets to mksurfdata_esmf

> [!TIP]
> ALL raw datasets \*.nc **FILES MUST NOT BE NetCDF4**.
.. tip::

ALL raw datasets \*.nc **FILES MUST NOT BE NetCDF4**.

Example to convert to CDF5

``` shell
nccopy -k cdf5 oldfile newfile
```

> [!TIP]
> The LAI raw dataset \*.nc **FILE MUST HAVE** an "unlimited" time dimension
.. tip::
The LAI raw dataset \*.nc **FILE MUST HAVE** an "unlimited" time dimension

Example to change time to unlimted dimension using the NCO operator ncks.

``` shell
ncks --mk_rec_dmn time file_with_time_equals_12.nc -o file_with_time_unlimited.nc
```

### IMPORTANT THERE HAVE BEEN PROBLEMS with REGIONAL grids!!
###

.. caution::

> [!CAUTION]
> See
>
> https://github.com/ESCOMP/CTSM/issues/2430
IMPORTANT THERE HAVE BEEN PROBLEMS with REGIONAL grids!! See https://github.com/ESCOMP/CTSM/issues/2430

In general we recommend using subset_data and/or fsurdat_modifier
for regional grids.
Expand Down