This repository contains a Fortran implementation of the APSIM Soil Temperature Campbell model generated by PyCrop2ML, including a wrapper structure for easier integration with external workflows and data management.
The project is organized to be clear and reproducible: source code is in src/, data files in Data/, and build tools (e.g., Makefile) at the root level.
.
├── Data/
│ ├── WeatherData/ # Folder containing weather input files
│ ├── SoilData.txt # Soil data input
│ ├── SoilMetadata.txt # Metadata for soil variables
│ ├── Treatment.txt # Treatment/management data
│ └── WeatherMetadata.txt # Metadata for weather variables
│
├── src/
│ ├── SoiltempComponent.f90 # Main component implementation
│ ├── list_sub.f90 # Utility and helper subroutines
│ └── soiltemperature.f90 # Core soil temperature model
│
├── build/ # Compilation outputs (object files, binaries)
├── Makefile # Build instructions
├── howtorun.txt # Example usage and run instructions
├── main.f90 # Main program / wrapper driver
└── README.md # Documentation
This implementation reproduces the Campbell soil temperature module used in APSIM, written in modern Fortran.
It includes:
- Layer-by-layer soil temperature calculations
- Daily meteorological forcing (from
Data/WeatherData) - Soil properties and management from metadata text files
- Modular design to allow integration into larger crop or system models
- A Fortran compiler (e.g. gfortran)
- GNU Make (for building with the provided
Makefile) - Unix/Linux environment (WSL works fine on Windows)
In the root directory of the repository:
make clean
makeThis will compile the Fortran sources in src/ and create an executable (usually in the build/ folder).
You can run the compiled model from the repository root:
./build/my_programMake sure the Data/ folder is present and contains:
- Weather input files in
Data/WeatherData/ - Soil and metadata text files in
Data/
For more details on how to execute specific simulations or adapt file paths, refer to:
howtorun.txt
- Modify
main.f90if you need to adapt the wrapper for coupling with other models. - Data paths can be made relative to parent directories to keep the project portable.
list_sub.f90contains utility functions that can be extended for data preprocessing.
FortranApsimCampbell/
├── Data/
│ ├── WeatherData/
│ │ └── example_weather_file.txt
│ ├── SoilData.txt
│ └── WeatherMetadata.txt
├── src/
│ ├── SoiltempComponent.f90
│ └── soiltemperature.f90
├── build/
│ └── soiltemp (executable)
└── main.f90
- Campbell, G. S. (1985). Soil Physics with BASIC. Elsevier.
- APSIM Initiative — Original model reference and documentation.
Contributions, improvements, or wrappers in other languages are welcome.
If you find a bug or want to request a feature, please open an Issue or submit a Pull Request.
This project is distributed for research and educational purposes.
Please cite appropriately if you use or adapt the model.
✍️ Author: Cyrille Midingoyi
🌐 CIRAD — Laboratoire Interdisciplinaire de Modélisation Sol-Culture-Arbre (LIMA)