Skip to content

Commit

Permalink
Merge pull request #36 from EcoExtreML/add_timestep
Browse files Browse the repository at this point in the history
Add variable DurationSize to config file
  • Loading branch information
geek-yang authored Apr 1, 2022
2 parents a16e8c2 + 1f7c24f commit 73a239d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Integrated code of SCOPE and STEMMUS.
the model runs at the site scale. For example, if we put the
`FI-Hyy_1996-2014_FLUXNET2015_Met.nc` here, the model runs at the `FI-Hyy`
site.
- DurationSize: total number of time steps in which model runs. It can be
`NA` or a number. Example `DurationSize=17520` runs the model for one year a
half-hour time step i.e. `365*24*2=17520`.

To edit the config file, open the file with a text editor and change the
paths. The variable names e.g. `SoilPropertyPath` should not be changed.
Expand Down Expand Up @@ -178,6 +181,9 @@ Dutch National supercomputer hosted at SURF.
`FI-Hyy_1996-2014_FLUXNET2015_Met.nc` here, the model runs at the `FI-Hyy`
site.
- VegetationPropertyPath: path to required data except `Plumber2_data` and `SoilProperty`.
- DurationSize: total number of time steps in which model runs. It can be
`NA` or a number. Example `DurationSize=17520` runs the model for one year a
half-hour time step i.e. `365*24*2=17520`.

To edit the config file, open the file with a text editor and change the
paths. The variable name e.g. `SoilPropertyPath` should not be changed.
Expand Down
3 changes: 2 additions & 1 deletion config_file_crib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ SoilPropertyPath=/data/shared/EcoExtreML/STEMMUS_SCOPEv1.0.0/input/SoilProperty/
InputPath=/home/jovyan/private/06_STEMMUS_SCOPE/GitEcoExtreML/data/
OutputPath=/home/jovyan/private/06_STEMMUS_SCOPE/GitEcoExtreML/data/output/
ForcingPath=/data/shared/EcoExtreML/STEMMUS_SCOPEv1.0.0/input/Plumber2_data/
ForcingFileName=FI-Hyy_1996-2014_FLUXNET2015_Met.nc
ForcingFileName=FI-Hyy_1996-2014_FLUXNET2015_Met.nc
DurationSize=NA
3 changes: 2 additions & 1 deletion config_file_snellius.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ InputPath=/scratch-shared/ecoextreml/stemmus_scope/input/
OutputPath=/scratch-shared/ecoextreml/stemmus_scope/output/
ForcingPath=/projects/0/einf2480/forcing/plumber2_data/
ForcingFileName=FI-Hyy_1996-2014_FLUXNET2015_Met.nc
VegetationPropertyPath=/projects/0/einf2480/model_parameters/vegetation_property/
VegetationPropertyPath=/projects/0/einf2480/model_parameters/vegetation_property/
DurationSize=17520
Binary file modified exe/STEMMUS_SCOPE
Binary file not shown.
6 changes: 5 additions & 1 deletion src/+io/read_config.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [SoilPropertyPath, InputPath, OutputPath, ForcingPath, ForcingFileName] = read_config(config_file)
function [SoilPropertyPath, InputPath, OutputPath, ForcingPath, ForcingFileName, DurationSize] = read_config(config_file)

file_id = fopen(config_file);
config = textscan(file_id,'%s %s', 'HeaderLines',0, 'Delimiter', '=');
Expand All @@ -23,3 +23,7 @@

indx = find(strcmp(config_vars, 'ForcingFileName'));
ForcingFileName = config_paths{indx};

% value of DurationSize is optional and can be NA
indx = find(strcmp(config_vars, 'DurationSize'));
DurationSize = str2double(config_paths{indx});
20 changes: 17 additions & 3 deletions src/filesread.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%%%%%% Set paths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global SoilPropertyPath InputPath OutputPath ForcingPath ForcingFileName
global SoilPropertyPath InputPath OutputPath ForcingPath ForcingFileName DurationSize
global CFG

%% CFG is a path to a config file
Expand All @@ -9,7 +9,7 @@

%% Read the CFG file. Due to using MATLAB compiler, we cannot use run(CFG)
disp (['Reading config from ',CFG])
[SoilPropertyPath, InputPath, OutputPath, ForcingPath, ForcingFileName] = io.read_config(CFG);
[SoilPropertyPath, InputPath, OutputPath, ForcingPath, ForcingFileName, DurationSize] = io.read_config(CFG);

%%%%%%% Prepare input files. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
global DELT IGBP_veg_long latitude longitude reference_height canopy_height sitename
Expand All @@ -29,8 +29,22 @@
time1=ncread(ForcingFilePath,'time');
t1=datenum(startyear,1,1,0,0,0);
DELT=time1(2);

%get time length of forcing file
time_length=length(time1);

%Set the end time of the main loop in STEMMUS_SCOPE.m
Dur_tot=length(time1);
%using config file or time length of forcing file
if isnan(DurationSize)
Dur_tot=time_length;
else
if (DurationSize>time_length)
Dur_tot=time_length;
else
Dur_tot=DurationSize;
end
end

dt=time1(2)/3600/24;
t2=datenum(endyear,12,31,23,30,0);
T=t1:dt:t2;
Expand Down

0 comments on commit 73a239d

Please sign in to comment.