Skip to content

AgriculturalModelExchangeInitiative/FortranApsimCampbell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APSIM Soil Temperature Campbell Model – Fortran Implementation with Wrapper

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.


📂 Repository Structure

.
├── 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

🌱 Model Description

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

🧰 Prerequisites

  • A Fortran compiler (e.g. gfortran)
  • GNU Make (for building with the provided Makefile)
  • Unix/Linux environment (WSL works fine on Windows)

🏗️ Building the Model

In the root directory of the repository:

make clean
make

This will compile the Fortran sources in src/ and create an executable (usually in the build/ folder).


🚀 Running the Model

You can run the compiled model from the repository root:

./build/my_program

Make 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

⚙️ Customization

  • Modify main.f90 if 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.f90 contains utility functions that can be extended for data preprocessing.

🧪 Example Directory Layout

FortranApsimCampbell/
├── Data/
│   ├── WeatherData/
│   │   └── example_weather_file.txt
│   ├── SoilData.txt
│   └── WeatherMetadata.txt
├── src/
│   ├── SoiltempComponent.f90
│   └── soiltemperature.f90
├── build/
│   └── soiltemp (executable)
└── main.f90

📜 References

  • Campbell, G. S. (1985). Soil Physics with BASIC. Elsevier.
  • APSIM Initiative — Original model reference and documentation.

🤝 Contributing

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.


📄 License

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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published