Source code modifications with SourceMods

Source code modifications with SourceMods#

Many CESM customizations can be made through namelist settings. However, some changes require modifying the model source code directly. These are referred to as source modifications.

Rather than editing files in the CESM source tree, the recommended approach is to copy the file you want to modify into the appropriate SourceMods directory within your case. During the build process, CESM automatically uses the modified file in SourceMods instead of the original source file.

For example, if you want to modify a CAM source file for a case named case01, copy the file into:

case01/SourceMods/src.cam

and make your changes there.

The typical workflow for a source code modification is:

  1. Locate the source file or subroutine you want to modify in the CESM source code.

  2. Copy the file into the appropriate SourceMods directory in your case.

  3. Edit the copied file.

  4. Rebuild and run the model.

The SourceMods directory contains component-specific subdirectories. Common examples include:

Directory

Component

SourceMods/src.cam

Atmosphere (CAM)

SourceMods/src.clm

Land (CLM)

SourceMods/src.cice

Sea Ice (CICE)

SourceMods/src.mom

Ocean (MOM)

SourceMods/src.mosart

River Transport (MOSART)

Using SourceMods keeps your modifications isolated within a case, making it easier to track changes, reproduce experiments, and update CESM without altering the original source code.

CESM directories and namelists

Figure: Overview of the CESM directories and the SourceMods directories.