agriculturalmodelexchangeinitiative / soiltemperaturemodels Goto Github PK
View Code? Open in Web Editor NEWAgricultural Model Exchange Initiative for Crop2ML components.
Agricultural Model Exchange Initiative for Crop2ML components.
File calculatesoiltemperature.f90 at function UpdateTemperature has a double definition of variable 'Temperature'.
It needs to be checked if this is right or wrong. Because there is a compilation error where one is output and input at same time.
The code was changed manually. Input function variable Temperature was modified to Temp.
STICS Stand alone model at subroutine layers_temp.f90 has the following source code generated for Fortran:
layer_temp(z - 1+1) = sum(temp_profile((up_depth(z - 1+1) + 1 - &
1):up_depth((z + 1 - 1)+1))) / layer_thick((z - 1)+1)
However, this generates an issue when accessing the indexes of tem_profile, were up_depth points to a wrong indexes.
The code should be changed to match the original source code which is:
layer_temp(z) = sum(temp_profile((up_depth(z) + 1 &
):up_depth(z+1))) / layer_thick((z - 1)+1)
WARNING: Commented subroutine to calculate hourly soil temperature. There was a floating point error when running with AMEI_DSSAT-Driver using the Crop2ML generated subroutine.
Teiki mentioned that was better to commented out because it is not being used and the subroutine call in the module was commented and it worked.
Commented subroutine in SoilTemperaturecomponent.f90
! call model_calculatehourlysoiltemperature(c, dayLength, maxTSoil, b, &
! a, minTSoil,hourlySoilT)
The code translated by Crop2ML in file layer_temp.f90 at layer_thickness2depth subroutine, produced an invalid statement for the layer_depth indexes. The index in Fortran should start in 1 and the math done creates always an index of 0.
Note that the Loop always starts count at 1 for z. See the code below.
layer_depth(z - 1+1) = sum(layer_thick(1 - 1:z))
New code:
layer_depth(z - 1+1) = sum(layer_thick(1:z))
File snowcovercalcutor.f90 at subroutine init_snowcovercalculator has a problem with C2ML generated Fortran source code for log function. The function in SIMPLACE init_snowcovercalculator is doing the following math:
Albedo = 0.0226 * LOG(cCarbonContent) / LOG(REAL(10)) + 0.1502
This math generates a division by zero in Fortran. The expression LOG(0.0) is considered invalid by gfortran (not ifort, I think) when delta is 0 constant. It is invalid.
The code was changed manually. A condition to check if cCarbonContent is greater than 0 was provided. See code below:
IF(cCarbonContent .GT. 0.0)THEN
Albedo = 0.0226 * LOG10(cCarbonContent) / LOG(REAL(10)) + 0.1502
ENDIF
Please have a look at the overview page attached where all variables needed are mentioned
Invalid character in the syntax for Fortran when declared the variable names. Fortran does not accept '' in the beginning to declare variables. All occurrences of '' where changed to ''. See example below:
REAL:: _SoilProfileDepthmm
REAL:: _TotalWaterContentmm
REAL:: _MaximumDumpingDepth
REAL:: _DumpingDepth
REAL:: _ScalingFactor
REAL:: _DepthBottom
REAL:: _RatioCenter
REAL:: _DepthFactor
REAL:: _DepthCenterLayer
As example, the name of variables should be changed to something like:
REAL:: SoilProfileDepthmm
REAL:: TotalWaterContentmm
REAL:: MaximumDumpingDepth
REAL:: DumpingDepth
REAL:: ScalingFactor
REAL:: DepthBottom
REAL:: RatioCenter
REAL:: DepthFactor
REAL:: DepthCenterLayer
Several subroutines contain this issue for BIOMA Parton and BIOMA SWAT only.
@fabiooliveira72
@chporter
You have made changes (assign TDL at 0.0) in the "rate calculation" part and I would like to know if it should be so.
TDL = 0.0
Is it not the value calculated by the initialization that should be used and updated day by day (like in your original code?
Fortran FUNCTION generated by Crop2ML does not have a type in the declaration to match with the RESULT. If there is no type in the function it is needed to declare the variable inside the scope of the function. If not, the compiler generates an error and cannot compile it.
FUNCTION SoilTempB(weatherMinTemp, &
deepTemperature) RESULT(res_cyml)
IMPLICIT NONE
REAL, INTENT(IN) :: weatherMinTemp
REAL, INTENT(IN) :: deepTemperature
INTEGER:: i_cyml_r
res_cyml = (weatherMinTemp + deepTemperature) / 2.0
END FUNCTION SoilTempB
The FUNCTION generated by CROP2ML for Fortran is missing the type.
Example, FUNCTION SoilTempB(Args) RESULT(res_cyml) must have the type explicit in the function.
REAL FUNCTION SoilTempB(Args) RESULT(res_cyml). If not there is a compilation error.
The code was changed manually added REAL type in the beginning of the function declaration.
SoilTemperatureMax/Min, SoilSurfaceTemperatureMax/Min
Temp_profile prev_temp_profile
Temp_profile prev_canopy_temp
CalculateSoilTemperature heatFlux
... are not clear - what does this exactly mean in the different models
STEMP.for at STEMP or STEMP_EPIC.for at STEMP_EPIC subroutine has a control variable for soil water named 'ISWWAT'. This variable is a character with only one character. However, Crop2ML is generating a CHARACTER(65).
The code was changed manually to CHARACTER in all occurences.
@plecharpent Fortran transformer doesn't not apply nint function to an array variable. It does't nost also transform "where statement". Please could you change this.
Dynamically allocated memory for some variables in STICS need to be declared as allocatable. CROP2ML is not generating it as allocatable, this produces a compilation issue to access the arrays. See below which are the files and variables change manually input variables in
Layers_temp.f90, line ~10-13
> REAL , DIMENSION(: ), INTENT(IN) :: temp_profile
> REAL , DIMENSION(: ), INTENT(OUT) :: layer_temp
New code:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(IN) :: temp_profile
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: layer_temp
Temp_profile.f90, line ~17:
> REAL , DIMENSION(: ), INTENT(OUT) :: prev_temp_profile
New code:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: prev_temp_profile
And line ~127:
> REAL , DIMENSION(: ), INTENT(OUT) :: temp_profile
New code:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: temp_profile
Update.f90 needs allocatable and dimension is wrong too needs to be changed (1) to (:). in line 14:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: prev_temp_profile
New code:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: prev_temp_profile
Soil_tempComponent.f90 needs allocatable the following variables, line ~27:
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(INOUT) :: prev_temp_profile
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: temp_profile
> REAL , ALLOCATABLE, DIMENSION(: ), INTENT(OUT) :: layer_temp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.