KUL-RSDA / AquaCrop

AquaCrop source code endorsed by FAO
https://www.fao.org/aquacrop/en/
Other
54 stars 17 forks source link

Optional project files #305

Closed MaximeVdB closed 2 years ago

MaximeVdB commented 2 years ago

This PR introduces a new unit ac_project_input containing e.g. a ProjectInput_type derived type and a ProjectInput module variable of this type. This is used to (1) only read the PRO/PRM files once, instead of multiple times and (2) allow external programs like LIS to directly control this input data (so without having to write a PRO or PRM file).

Passes the full testsuite done with both DEBUG=0 FORTRAN_EXE=0 and DEBUG=1 FORTRAN_EXE=1 for both the foss-2018a toolchain and the singularity image.

@mbechtold Could you check that this works as intended with LIS? As you can see, there are convenience functions like allocate_project_input, set_project_input and get_project_input in ac_project_input that should be used for this purpose. E.g.:

! To set the Climate_Info attribute of the input associated with the third Run:
call set_project_input(3, 'Climate_Info', 'Subtropical climate')
! To get the VersionNr attribute of the input associated with the first Run:
real(dp) :: version
...
version = get_project_input(1, 'VersionNr', mold=1._dp)

@mbechtold So I also had a look whether the ListProjects file needed a similar treatment. But it seems like this file is already only used in procedures like StartTheProgram which are anyway only used when AquaCrop is ran as 'standalone'. So could you also check that you can simply omit those ListProjects.txt files when running with LIS?

MaximeVdB commented 2 years ago

Michel's LIS tests now succeed, and I re-checked the current branch by running the Perennial, Harvest and (selected) Europe tests with both DEBUG=0 FORTRAN_EXE=0 and DEBUG=1 FORTRAN_EXE=1 for both the foss-2018a toolchain and the singularity image (all passed).