Installation of LPJmL C Version 6.1.1

June 12, 2026 ยท View on GitHub

Overview

LPJmL is a dynamic global vegetation model. This document describes how to install LPJmL on your system. The code has been tested on the following platforms:

  • Linux
  • Mac OS X
  • Windows (using Cygwin or Microsoft C compiler)

Directory Structure

After extracting the source files, the directory structure will look like this:

--lpjml
  |
  +-config         : OS- and compiler-specific Makefiles
  +-bin            : Directory for executables and shell scripts
  +-man            : Manual pages root directory
  | +-man1         : Manual pages for programs and scripts
  | +-man3         : Manual pages for functions
  | +-man5         : Manual pages for file formats
  +-par            : Parameter files for PFTs and soils
  +-testcase_2cell : Mimimum 2-cell data set for test
  +-output         : Output data (created by `make test`)
  +-restart        : Restart data (created by `make test`)
  +-lib            : Library files (created by `make`)
  +-include        : Include files
  +-src            : Source tree
     +-numeric     : Source for numerical routines
     +-bstruct     : source for reading/writing restart files
     +-tools       : Source for tools
     +-pnet        : Library for distributed networks
     +-climate     : Climate code
     +-lpj         : LPJ functions
     +-soil        : Soil code
     +-grass       : Grass PFT code
     +-tree        : Tree PFT code
     +-crop        : Crop PFT code
     +-landuse     : Land use code
     +-spitfire    : Spitfire fire code
     +-reservoir   : Reservoir code
     +-socket      : Socket communication library
     +-coupler     : Coupler code
     +-image       : Coupler to IMAGE model
     +-netcdf      : NetCDF input/output functions
     +-utils       : Utility programs
     +-test        : Unit tests for source code using Ceedling

Installation Steps

1. Extract the Source Files

mkdir lpjml
cd lpjml
gzip -cd lpjml-6.1.1.tar.gz | tar -xf -

2. Configure for Your Operating System

On PIK's HPC "Eunice Foote"

Set the following modules:

module load intel/oneAPI/2024.0.0
module load udunits/2.2.28
module load json-c/0.17
module load netcdf-c

On a Linux System

Install the required libraries:

sudo apt-get install libnetcdf-dev
sudo apt-get install libudunits2-dev
sudo apt-get install libjson-c-dev

and optionally the MPICH parallel library:

sudo apt-get install mpich
sudo apt-get install openmpi-bin openmpi-common libopenmpi-dev

3. Run the Configuration Script

./configure.sh
  • If the script exits with the message Unsupported operating system, a Makefile.$osname is created from Makefile.gcc. You may need to modify it for your operating system/compiler.
  • If a MPI environment is detected, a parallel version of LPJmL will be built.
  • The configure script creates a copy of the following OS-specific makefiles from directory config:
FileDescription
Makefile.gccGNU C-compiler settings
Makefile.icxNew Intel C-compiler (icx) settings
Makefile.iccIntel C-compiler (icc) settings
Makefile.mpiiccIntel C-compiler icc and Intel MPI
Makefile.mpiicxIntel C-compiler icx and Intel MPI
Makefile.mpichGNU C-Compiler and MPI Chameleon settings
Makefile.win32Windows settings (used by configure.bat)

4. Compilation

Compile the code using:

make

This creates the lpjml executable in the bin directory.

make lpjcheck

creates lpjcheck utility to check JSON configuration files.

To compile all utility programs:

make utils

The following programs are created in the bin directory:

ProgramDescription
adddrainadd river basin to coordinate file
addheaderadd CLM header to binary file
arr2clmconvert 2-D float arrays into CLM file
asc2clmconvert ARC/Info ASCII files to CLM data files for LPJmL
backtraceprint backtrace from core
bin2cdfconvert binary output files into NetCDF files
binsumaggregate daily and monthly binary output
cat2bsqconcatenate output files from distributed LPJmL simulations
catclmconcatenate LPJmL climate data files
cdf2binconvert NetCDF files into raw binary data
cdf2clmconvert NetCDF files into CLM files
cdf2coordextract CLM grid file from NetCDF file
cdf2gridconvert grid NetCDF file into grid CLM or raw file
cdf2soilconvert NetCDF file into binary file
cfts26lu2clmconvert binary landuse data files to CLM data files for LPJmL
clm2cdfconvert CLM files into NetCDF files
cmpbincompare two binary output files
copyheadercopy CLM file header
country2cdfconvert country/region code file into NetCDF file
coupler_demoDemo program for coupling to a program witch socket communication
cru2clmconvert CRU data into file format suitable for LPJmL
cutclmcut LPJmL climate data files
cvrtclmconvert version of CLM file to version 3 or 4
cvrtsoilconvert text soil input data into binary data
drainage2cdfconvert CLM drainage file into NetCDF file
getcellindexget cell index from latitude, longitude values
getcountryextract grid cells for specified countries
grid2bsqconvert grid data file to CLM data files for LPJmL
headersizeprint header size of CLM files
json2restartconvert JSON file into LPJmL restart file
lpjcatconcatenate restart files from distributed LPJmL simulations.
lpjcheckcheck syntax of LPJmL configuration files
lpjfilesprint list of input/output files of LPJmL
lpjprintprint contents of restart file of LPJmL model runs
manage2jsconvert management *.par files to JSON files
mathclmperform mathematical operations with CLM files
mergeclmmerge LPJmL climate data files
printclmprint contents of CLM files for LPJmL
printdrainprint drainage map
printglobalprint global values for raw binary output files
printharvestprint global harvested carbon for crops and managed grasslands
printreservoirprint reservoir data
regridclmregrid CLM file to new grid
regridlpjregrid input data set for selected countries or specified grid file
regridsoilregrid binary soil file to different grid file
reservoir2cdfconvert CLM reservoir file into NetCDF file
restart2yamlconvert LPJmL restart file into YAML
river_section_input_climateregrid climate data
river_section_input_countrycodereggrid country code data
river_section_input_gridre-orders grid cells according to river sections
river_section_input_irrigregrid irrigation data
river_section_input_landuseregrid land-use data
river_section_input_soilregrid soil data
setclmset value in header of CLM files for LPJmL
soil2cdfconvert binary files into NetCDF files
splitclmcopy specific bands of clm data files
statclmprint statistics of clm files
txt2clmconvert text files to CLM data files for LPJmL
txt2gridconvert text files to CLM grid data files for LPJmL
water_use_inputcreate water use data from industrial, domestic, and livestock use

5. Installation

To install the binaries and necessary files to a specific directory, set the LPJROOT environment variable:

export LPJROOT=<installation directory>
make install

Compilation Flags

Compilation of LPJmL can be customized using the following flags in the LPJFLAGS section of Makefile.inc:

FlagDescription
CHECK_BOUNDARYcheck array boundaries of output
CHECK_BALANCEenable localy function balance checks
COUPLING_WITH_FMSenable coupling to FMS
DAILY_ESTABLISHMENTenable daily establishment
DEBUGdiagnostic output is generated for debugging purposes
DEBUG_BSTRUCTdiagnostic output is generated for reading/writing of restart
DEBUG_COUPLERdiagnostic output is generated for the coupler
DEBUG_IMAGEdiagnostic output is generated for the IMAGE coupler
DEBUG_Ndiagnostic output is generated for the nitrogen cycle
IMAGEinclude coupler to IMAGE model
LINEAR_DECAYuse linearized functions for litter decay
MICRO_HEATINGenable microbial heating
NRECOVERY_COSTcosts for N recovery enabled
PERMUTErandom permutation of PFT list
SAFEcode is compiled with additional checks
STRICT_JSONstrict JSON checking
USE_MPIcompile parallel version of LPJmL
USE_NETCDFenable NetCDF input/output
USE_RAND48use drand48() random number generator
USE_UDUNITSenable unit conversion in NetCDF files
USE_TIMINGenable timing for LPJmL functions for performace analysis
WITH_FIRE_MOISTUREenable moisture dependent fire emissions
WITH_FPEfloating point exceptions are enabled for debugging purposes

Running the Code

Sequential Version

Run the sequential version with:

./bin/lpjml lpjml_config.cjson

If running outside the root directory, set the LPJROOT environment variable:

export LPJROOT=$HOME/lpjml
export PATH=$PATH:$LPJROOT/bin

Peform a minimum 2-cell simulation:

make test

Parallel Version

Submit a job using SLURM or LoadLeveler:

bin/lpjsubmit ntasks LPJmL_args...

Or run interactively:

mpirun -np 32 ./bin/lpjml lpjml_config.cjson

Runtime Options of Lpjml

The following runtime options are defined:

OptionDescription
-Iincludepathadd include path for LPJmL configuration file
-Dmacro[=value]define macro
-hprint usage of lpjml
-lprint license
-vprint compiler used and LPJmL flags set
-vvverbosely print the actual values during reading of the configuration files
-pedanticstop on warnings
-print_noreadprint variable names not read from restart file
-ofileslist only all available output variables
-paramprint LPJmL parameter for soils and PFTs
-noppdisable preprocessing
-pp cmdset preprocessor program. Default is 'cpp'
-fpeenable floating point exceptions
-image hostset host where IMAGE model is running. Option is only available for the IMAGE version
-couple host[:port]set host and port where the coupled model is running
-wait timeset time to wait for connection to IMAGE/coupled model
-inpath dirinput directory path
-outpath diroutput directory path
-restartpath dirrestart directory path

Error Codes

If LPJmL fails, an error message is displayed in the format:

ERRORxxx: message
Error CodeDescriptionType
1Error reading configurationExternal
2Error initializing input dataExternal
3Error initializing gridExternal
4Invalid carbon balanceInternal
5Invalid water balanceInternal
6Negative dischargeInternal
7Negative fire probabilityInternal
8Negative soil moistureInternal
9Error allocating memoryExternal
10Negative stand fractionInternal
11Stand fraction sum errorInternal
12List is empty in dellistitemInternal
13Index out of range in dellistitemInternal
15Invalid year in getco2()External
16Crop fraction >1Internal
17No natural stand for deforestInternal
18Wrong cultivation typeInternal
19Floating point errorInternal
21PFT list is not empty in setasideInternal
22Negative establishment rateInternal
23Output channel is broken in socket connectionExternal
24Sending data to IMAGE model failedExternal
25Opening connection to IMAGE model failedExternal
26Not enough setaside stand createdInternal
27Forest left after deforestationInternal
28Outflow reservoir errorInternal
29Permafrost errorInternal
30Global waterbalance errorInternal
31Cannot store climate dataExternal
32NO FMS couplerExternal
33Cannot initialize soil temperatureExternal
34Invalid radiation moduleInternal
35Negative soil NO3Internal
36Negative soil NH4Internal
37Invalid nitrogen balanceInternal
38Invalid climate dataExternal
39Invalid FPC valueInternal
40Boundary check errorInternal
41Invalid time step in soiltemp()Internal
42Cannot read external flowExternal
43Opening connection to coupled model failedExternal
44Invalid uniform temp sign valueInternal
45Error initializing output dataExternal
46Invalid crop PHU optionInternal
47Invalid fire danger indexInternal
48Gamma function errorInternal
49Wetland errorInternal
50Invalid hag_beta errorExternal
51Invalid inundation stressInternal
52Error writing outputExternal
53Negative soil carbon errorInternal
  • External Errors: Caused by invalid or missing input files.
  • Internal Errors: Caused by issues in the LPJmL code and may require debugging.

Environment Variables

The following environment variables are used by LPJmL:

VariableDescription
LPPJNOPPdisables preprocessor if set to "true", same as -nopp option
LPJPEDANTICenables pedantic mode if set to "true", same as -pedantic option
LPJPREPdefines preprocessor command for LPJmL configuration file, default is "cpp"
LPJROOTdefines the root directory for LPJmL. This directory is added to the include directories of the preprocessor
LPJIMAGEsets host where IMAGE is running
LPJCOUPLEDHOSTsets host where the coupled model is running
LPJWAITsets time to wait for connection to IMAGE/coupled model
LPJINPATHpath appended to the input filenames. Only done for filenames without absolute path
LPJRESTARTPATHpath appended to the restart filenames. Only done for filenames without absolute path
LPJOPTIONScpp runtime options for LPJmL
LPJOUTPATHpath appended to the output filenames. Only done for filenames without absolute path

Man Pages

Manual pages are located in the $LPJROOT/man directory. Add them to your MANPATH:

export MANPATH=$MANPATH:$LPJROOT/man

Use the apropos command to list related man pages:

apropos lpj

Windows Installation (Without Cygwin)

For Windows, the code has been tested with the Microsoft C++ compiler and nmake. Install the Microsoft SDK and follow these steps:

  1. Unzip the source and data files.

  2. Configure the makefile:

    configure.bat
    
  3. Build the executable:

    nmake