FAQs

[Q] How to compile and run DSSAT on Linux/MAC?

The most recent version is v4.8.2 (Check latest RELEASE here).

For DSSAT to be functional it is supported by data base management programs for soil, weather, and crop management and experimental data, and by utilities and application programs. The crop simulation models simulate growth, development and yield as a function of the soil-plant-atmosphere dynamics.

Questions about usage of DSSAT ecosystem [contact us].

This post assumes:

  • You have access to the source code of CSM via GitHub.
  • You have good knowledge of DSSAT and CSM in general.
  • You have good knowledge of running CSM from the command line.
  • You have installed GNU Fortran compiler (more information).
  • We recommend having the latest versions always.
  • You feel comfortable handling files and executing programs from the command line on Linux.

On Windows, even with the DSSAT shell program, the actual model behind the interface runs on the command line, reading input files in plain ASCII format, writing output files again in plain ASCII format. You might have thought this seemed to be an old-school way (“What is DOS?”, “Who uses Fortran?”); this way in fact provides great flexibility and scalability – including the possibility of porting the program into other operating systems (as long as there is a modern Fortran compiler, that is). Besides, as computer scientists put it, there is only few things in the Earth faster than well-compiled Fortran programs.

The idea is simple: once you can compile the core executable program of DSSAT, you can run it on Linux (or any other platform). Here are few minor tricks that you’d need to know.

 

How-To

The source directory structure

DSSAT cropping system model (CSM) design is a modular structure in which components separate along scientific discipline lines and are structured to allow easy replacement or addition of modules. It has one Soil module, a Crop Template module which can simulate different crops by defining species input files, an interface to add individual crop models if they have the same design and interface, a weather module, and a module for dealing with competition for light and water among the soil, plants, and atmosphere. It is also designed for incorporation into various application packages, ranging from those that help researchers adapt and test the CSM to those that operate the DSSAT /CSM to simulate production over time and space for different purposes.

Structure of the code

.
├── build
│   └── ...
├── cmake
│   └── Modules
│       ├── SetCompileFlag.cmake
│       └── SetFortranFlags.cmake
├── Data
|   ├── Genotype
|   ├── Pest
|   └── StandardData 
├── <source files>
├── CMakeLists.txt
├── distclean.cmake
├── README.md
└── ...

Compiling the code

The code is compatible with the CMake utility for generating MakeFile and setting up projects for a variety of IDEs and compilers. To use this feature, first download and install CMake. Then set up a CMake project by pointing to the source code directory and the build directory.

Configuring the build

It is usually preferred that you do an out-of-source build. To do this, create a build/ directory at the top level of your project and build there. This folder is created to organize all working files inside it, avoiding messing up your source folder. During compilation and linking, working folders are created automatically inside this folder. Any libraries created end up in mod/, as well as compiled Fortran .mod files. The executable will end up in bin/.

$ mkdir build
$ cd build
$ cmake ..
$ make

When you do this, temporary CMake files will not be created in your src/ directory.

As written, this template will allow you to specify one of three different sets of compiler flags. The default is DEBUG. You can change this using to RELEASE or DEBUG using

$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG

or

$ cmake .. -DCMAKE_BUILD_TYPE=RELEASE

You can provide all kind of information CMake. See more information at [CMake Tutorial].

One usable examples could be:

$ cmake -G "Unix Makefiles" -DCMAKE_Fortran_COMPILER=ifort ..

In this example we are specifying the fortran compiler and the kind of project we want as result (make file project).

CMakeLists.txt

This file contains all the configuration needed to set up the project.
Edit this file to make your own configuration and add new projects. Comment/Uncomment any lines pertaining to options you may need.

distclean.cmake

This is a CMake script that will remove all files and folder that are created after running make. You can run this code in one of two ways:

  • Execute cmake -P distclean.cmake. (The -P option to cmake will execute a CMake script)
  • Execute make distclean after your Makefile has been generated.

cmake/Modules/

This directory contains CMake scripts that aid in configuring the build system.

SetCompileFlag.cmake

This file defines a function that will test a set of compiler flags to see which one works and adds that flag to a list of compiler flags. This is used to set compile flags when you don’t know which compiler will be used.

SetFortranFlags.cmake

This file uses the function from SetCompilerFlag.cmake to set the DEBUG, TESTING, and RELEASE compile flags for your build. You might want to inspect this file and edit the flags to your liking.

Data

This folder contains model-specific data for genotypes pest, standard model data, code files, DSSATPRO files, etc.

Best DSSAT coding practices

See: Non-threatening best practice DSSAT Fortran coding guidelines.

 

The data directory structure

The experimental datasets are distributed with the DSSAT Cropping System Model (see dssat-csm-os GitHub repository) and contain at least one experimental dataset for each crop simulation model, including management, soils, and weather data.

 

Structure of the data

.
├── Alfalfa
├── Bahia
├── ...
├── Soil
├── ...
├── Weather
├── Wheat
├── YieldForecast
└── README.md

Additional model-specific data files are included in the DSSAT source code repository under the “Data” folder. These include model-specific data for genotypes, pest, standard model data, code files, DSSATPRO files, etc.

.
├── Genotype
├── Pest
├── StandardData
├── Data.CDE
├── Detail.CDE
├── DSSATPRO.v48
├── ...
└── README.md

The files in this repository can be combined with the files in the Data folder of the source repository to replicate the directory structure of the Windows installation of DSSAT v4.8.2 (e.g., with Genotype directory at the same level as the Alfalfa directory and the CDE files in the root directory).

 

Test your CSM installation

To test your DSSAT-CSM model installation, execute the model from the Maize data directory using the following command line structure:

path+executable A UFGA8201.MZX

where UFGA8201.MZX is the name of a file containing details of a field experiment. This command should run the model for this particular experimnt and generate outputs for six treatments in files Summary.OUT, PlantGro.OUT, and other files.

That’s it!

Let us know if you have any questions or problems through [contact us].

Enjoy DSSAT!

 

Tags: ,

About Jawoo Koo

Research Fellow at International Food Policy Research Institute (IFPRI), Washington, DC. Working on the meso-scale crop systems modeling applicaitons for Sub-Saharan Africa region.

No comments yet.

Leave a Comment

Remember to play nicely folks, nobody likes a troll.