Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gwu479/Summa-Actors
  • numerical_simulations_lab/actors/Summa-Actors
2 results
Show changes
Showing
with 4447 additions and 197 deletions
#ifndef SUMMAMANGER_H_
#define SUMMAMANGER_H_
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "JobActor.h"
#include <iostream>
#include <chrono>
#include <string>
#include "json.hpp"
#include <fstream>
#include "global.h"
struct summa_manager {
// Timing Information
std::chrono::time_point<std::chrono::system_clock> start;
std::chrono::time_point<std::chrono::system_clock> end;
double duration;
// Program Parameters
int startGRU; // starting GRU for the simulation
int numGRU; // number of GRUs to compute
std::string configPath;// path to the fileManager.txt file
// Information about the jobs
int numFailed = 0; // Number of jobs that have failed
// Values Set By Summa_Actors_Settings.json
int maxGRUPerJob; // maximum number of GRUs a job can compute at once
int outputStrucSize;
caf::actor currentJob; // Reference to the current job actor
};
/**
* @brief Function to spawn a job actor
*/
void spawnJob(stateful_actor<summa_manager>* self);
void parseSettings(stateful_actor<summa_manager>* self, std::string configPath);
#endif
\ No newline at end of file
This diff is collapsed.
...@@ -18,8 +18,10 @@ ...@@ -18,8 +18,10 @@
! You should have received a copy of the GNU General Public License ! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>. ! along with this program. If not, see <http://www.gnu.org/licenses/>.
module def_output_module module def_output_actors_module
USE data_types,only:var_i
USE data_types,only:var_i
USE actor_data_types,only:netcdf_gru_actor_info
USE netcdf USE netcdf
USE netcdf_util_module,only:netcdf_err ! netcdf error handling function USE netcdf_util_module,only:netcdf_err ! netcdf error handling function
USE netcdf_util_module,only:nc_file_close ! close NetCDF files USE netcdf_util_module,only:nc_file_close ! close NetCDF files
...@@ -70,119 +72,167 @@ contains ...@@ -70,119 +72,167 @@ contains
! ********************************************************************************************************** ! **********************************************************************************************************
! public subroutine def_output: define model output file ! public subroutine def_output: define model output file
! ********************************************************************************************************** ! **********************************************************************************************************
subroutine def_output(summaVersion,buildTime,gitBranch,gitHash,nGRU,nHRU,nSoil,infile,ncid_c,err,message) subroutine def_output(ncid,startGRU,nGRU,nHRU,actor_info,err,message)
USE globalData,only:structInfo ! information on the data structures USE globalData,only:structInfo ! information on the data structures
USE globalData,only:forc_meta,attr_meta,type_meta ! metaData structures USE globalData,only:forc_meta,attr_meta,type_meta ! metaData structures
USE globalData,only:prog_meta,diag_meta,flux_meta,deriv_meta ! metaData structures USE globalData,only:prog_meta,diag_meta,flux_meta,deriv_meta ! metaData structures
USE globalData,only:mpar_meta,indx_meta ! metaData structures USE globalData,only:mpar_meta,indx_meta ! metaData structures
USE globalData,only:bpar_meta,bvar_meta,time_meta ! metaData structures USE globalData,only:bpar_meta,bvar_meta,time_meta ! metaData structures
USE globalData,only:model_decisions ! model decisions USE globalData,only:model_decisions ! model decisions
USE globalData,only:outFreq ! output frequencies USE globalData,only:outFreq ! output frequencies
USE globalData,only:fname ! Some global variabels required in the writing process
! USE globalData,only:ncid USE globalData,only:nHRUrun
USE var_lookup,only:maxVarFreq ! # of available output frequencies USE globalData,only:nGRUrun
USE get_ixname_module,only:get_freqName ! get name of frequency from frequency index USE globalData,only:gru_struc
USE globalData,only:fileout
! declare dummy variables ! modules that are not globalData
character(*),intent(in) :: summaVersion ! SUMMA version USE var_lookup,only:maxVarFreq ! # of available output frequencies
character(*),intent(in) :: buildTime ! build time USE get_ixname_module,only:get_freqName ! get name of frequency from frequency index
character(*),intent(in) :: gitBranch ! git branch USE summaFileManager,only:OUTPUT_PATH,OUTPUT_PREFIX ! define output file
character(*),intent(in) :: gitHash ! git hash USE globalData,only:outputTimeStep ! output time step
integer(i4b),intent(in) :: nGRU ! number of GRUs
integer(i4b),intent(in) :: nHRU ! number of HRUs ! ---------------------------------------------------------------------------------------
integer(i4b),intent(in) :: nSoil ! number of soil layers in the first HRU (used to define fixed length dimensions) ! * Dummy Variables
character(*),intent(in) :: infile ! file suffix ! ---------------------------------------------------------------------------------------
type(var_i),intent(inout) :: ncid_c ! id of output file type(var_i),pointer :: ncid ! id of output file
integer(i4b),intent(out) :: err ! error code integer(i4b),intent(in) :: startGRU ! startGRU for the entire job (for file creation)
character(*),intent(out) :: message ! error message integer(i4b),intent(in) :: nGRU ! number of GRUs
! local variables integer(i4b),intent(in) :: nHRU ! number of HRUs
integer(i4b) :: ivar ! loop through model decisions type(netcdf_gru_actor_info),intent(out):: actor_info ! netcdf actor information
integer(i4b) :: iFreq ! loop through output frequencies character(*),intent(out) :: message ! error message
integer(i4b) :: iStruct ! loop through structure types integer(i4b),intent(out) :: err ! error code
character(len=32) :: fstring ! string to hold model output freuqnecy
character(len=256) :: cmessage ! temporary error message ! ---------------------------------------------------------------------------------------
! * Local Subroutine Variables
! initialize errors ! ---------------------------------------------------------------------------------------
err=0; message="def_output/" integer(i4b) :: ivar ! loop through model decisions
integer(i4b) :: iFreq ! loop through output frequencies
! close files if already open integer(i4b) :: iStruct ! loop through structure types
do iFreq=1,maxvarFreq character(len=32) :: fstring ! string to hold model output freuqnecy
if (ncid_c%var(iFreq)/=integerMissing) then character(len=256) :: cmessage ! temporary error message
call nc_file_close(ncid_c%var(iFreq),err,cmessage) integer(i4b) :: iGRU
if(err/=0)then; message=trim(message)//trim(cmessage); return; end if character(LEN=256) :: startGRUString ! String Variable to convert startGRU
character(LEN=256) :: numGRUString ! String Varaible to convert numGRU
character(len=1024) :: fname ! temporary filename
! initialize errors
err=0; message="def_output/"
! allocate space for the output file ID array
if (.not.allocated(ncid%var))then
allocate(ncid%var(maxVarFreq))
ncid%var(:) = integerMissing
endif endif
end do
! initialize netcdf file id ! Set the global variable for the number of HRU and GRU in run
nGRUrun = nGRU
! ncid(:) = integerMissing nHRUrun = nGRU
! create initial file ! create the name of the new files
! each file will have a master name with a frequency appended at the end: write(unit=startGRUString,fmt=*)startGRU
! e.g., xxxxxxxxx_timestep.nc (for output at every model timestep) write(unit=numGRUString,fmt=*) nGRU
! e.g., xxxxxxxxx_monthly.nc (for monthly model output) fileout = trim(OUTPUT_PATH)//trim(OUTPUT_PREFIX)//"GRU"&
do iFreq=1,maxvarFreq //trim(adjustl(startGRUString))//"-"//trim(adjustl(numGRUString))
! skip frequencies that are not needed
! close files if already open
if(.not.outFreq(iFreq)) cycle do iFreq=1,maxvarFreq
if (ncid%var(iFreq)/=integerMissing) then
! create file call nc_file_close(ncid%var(iFreq),err,cmessage)
fstring = get_freqName(iFreq) if(err/=0)then
fname = trim(infile)//'_'//trim(fstring)//'.nc' message=trim(message)//trim(cmessage)
call ini_create(nGRU,nHRU,nSoil,trim(fname),ncid_c%var(iFreq),err,cmessage) print*, message
if(err/=0)then; message=trim(message)//trim(cmessage); return; end if return
! print*,'Created output file: '//trim(fname) end if
endif
! define SUMMA version end do
do iVar=1,4
! write attributes
if(iVar==1) call put_attrib(ncid_c%var(iFreq),'summaVersion', summaVersion, err, cmessage) ! SUMMA version
if(iVar==2) call put_attrib(ncid_c%var(iFreq),'buildTime' , buildTime , err, cmessage) ! build time
if(iVar==3) call put_attrib(ncid_c%var(iFreq),'gitBranch' , gitBranch , err, cmessage) ! git branch ! create initial file
if(iVar==4) call put_attrib(ncid_c%var(iFreq),'gitHash' , gitHash , err, cmessage) ! git hash ! each file will have a master name with a frequency appended at the end:
! check errors ! e.g., xxxxxxxxx_timestep.nc (for output at every model timestep)
if(err/=0)then; message=trim(message)//trim(cmessage); return; end if ! e.g., xxxxxxxxx_monthly.nc (for monthly model output)
end do do iFreq=1,maxvarFreq
! skip frequencies that are not needed
! define model decisions
do iVar = 1,size(model_decisions) if(.not.outFreq(iFreq)) cycle
if(model_decisions(iVar)%iDecision.ne.integerMissing)then
call put_attrib(ncid_c%var(iFreq),model_decisions(iVar)%cOption,model_decisions(iVar)%cDecision,err,cmessage) ! create file
if(err/=0)then; message=trim(message)//trim(cmessage); return; end if fstring = get_freqName(iFreq)
end if fname = trim(fileout)//'_'//trim(fstring)//'.nc'
end do call ini_create(nGRU,nHRU,gru_struc(1)%hruInfo(1)%nSoil,trim(fname),ncid%var(iFreq),err,cmessage)
if(err/=0)then; message=trim(message)//trim(cmessage); print*, message; return; end if
! define variables
do iStruct = 1,size(structInfo) ! define model decisions
select case (trim(structInfo(iStruct)%structName)) do iVar = 1,size(model_decisions)
case('attr' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU, noTime,attr_meta, outputPrecision, err,cmessage) ! local attributes HRU if(model_decisions(iVar)%iDecision.ne.integerMissing)then
case('type' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU, noTime,type_meta, nf90_int, err,cmessage) ! local classification call put_attrib(ncid%var(iFreq),model_decisions(iVar)%cOption,model_decisions(iVar)%cDecision,err,cmessage)
case('mpar' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU, noTime,mpar_meta, outputPrecision, err,cmessage) ! model parameters if(err/=0)then
case('bpar' ); call def_variab(ncid_c%var(iFreq),iFreq,needGRU, noTime,bpar_meta, outputPrecision, err,cmessage) ! basin-average param message=trim(message)//trim(cmessage)
case('indx' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,indx_meta, nf90_int, err,cmessage) ! model variables print*, message
case('deriv'); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,deriv_meta,outputPrecision, err,cmessage) ! model derivatives return
case('time' ); call def_variab(ncid_c%var(iFreq),iFreq, noHRU,needTime,time_meta, nf90_int, err,cmessage) ! model derivatives end if
case('forc' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,forc_meta, outputPrecision, err,cmessage) ! model forcing data end if
case('prog' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,prog_meta, outputPrecision, err,cmessage) ! model prognostics end do
case('diag' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,diag_meta, outputPrecision, err,cmessage) ! model diagnostic variables
case('flux' ); call def_variab(ncid_c%var(iFreq),iFreq,needHRU,needTime,flux_meta, outputPrecision, err,cmessage) ! model fluxes ! define variables
case('bvar' ); call def_variab(ncid_c%var(iFreq),iFreq,needGRU,needTime,bvar_meta, outputPrecision, err,cmessage) ! basin-average variables do iStruct = 1,size(structInfo)
case('id' ); cycle ! ids -- see write_hru_info() select case (trim(structInfo(iStruct)%structName))
case default; err=20; message=trim(message)//'unable to identify lookup structure'; case('attr' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,attr_meta, outputPrecision, err,cmessage) ! local attributes HRU
end select case('type' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,type_meta, nf90_int, err,cmessage) ! local classification
! error handling case('mpar' ); call def_variab(ncid%var(iFreq),iFreq,needHRU, noTime,mpar_meta, outputPrecision, err,cmessage) ! model parameters
if(err/=0)then;err=20;message=trim(message)//trim(cmessage)//'[structure = '//trim(structInfo(iStruct)%structName);return;end if case('bpar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU, noTime,bpar_meta, outputPrecision, err,cmessage) ! basin-average param
end do ! iStruct case('indx' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,indx_meta, nf90_int, err,cmessage) ! model variables
! write HRU dimension and ID for each output file case('deriv' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,deriv_meta,outputPrecision, err,cmessage) ! model derivatives
call write_hru_info(ncid_c%var(iFreq), err, cmessage); if(err/=0) then; message=trim(message)//trim(cmessage); return; end if case('time' ); call def_variab(ncid%var(iFreq),iFreq, noHRU,needTime,time_meta, nf90_int, err,cmessage) ! model derivatives
case('forc' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,forc_meta, outputPrecision, err,cmessage) ! model forcing data
end do case('prog' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,prog_meta, outputPrecision, err,cmessage) ! model prognostics
case('diag' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,diag_meta, outputPrecision, err,cmessage) ! model diagnostic variables
case('flux' ); call def_variab(ncid%var(iFreq),iFreq,needHRU,needTime,flux_meta, outputPrecision, err,cmessage) ! model fluxes
case('bvar' ); call def_variab(ncid%var(iFreq),iFreq,needGRU,needTime,bvar_meta, outputPrecision, err,cmessage) ! basin-average variables
case('id' ); cycle
case('lookup'); cycle ! ids -- see write_hru_info()
case default; err=20; message=trim(message)//'unable to identify lookup structure';
end select
! error handling
if(err/=0)then
err=20
message=trim(message)//trim(cmessage)//'[structure = '//trim(structInfo(iStruct)%structName)
print*, message
return
end if
end do ! iStruct
! write HRU dimension and ID for each output file
call write_hru_info(ncid%var(iFreq), err, cmessage)
if(err/=0) then
message=trim(message)//trim(cmessage)
print*, message
return
end if
! define timing variables for actors code
! TODO: Add attributes to these variables
err = nf90_def_var(ncid%var(iFreq),"run_time",outputPrecision,(/gru_DimID/),actor_info%run_time_var_id)
err = nf90_def_var(ncid%var(iFreq),"init_duration",outputPrecision,(/gru_DimID/),actor_info%init_duration_var_id)
err = nf90_def_var(ncid%var(iFreq),"forcing_duration",outputPrecision,(/gru_DimID/),actor_info%forcing_duration_var_id)
err = nf90_def_var(ncid%var(iFreq),"run_physics_duration",outputPrecision,(/gru_DimID/),actor_info%run_physics_duration_var_id)
err = nf90_def_var(ncid%var(iFreq),"write_output_duration",outputPrecision,(/gru_DimID/),actor_info%write_output_duration_var_id)
err = nf90_def_var(ncid%var(iFreq),"successful",nf90_int,(/gru_DimID/),actor_info%state_var_id)
err = nf90_def_var(ncid%var(iFreq),"num_attempts",nf90_int,(/gru_DimID/),actor_info%num_attempts_var_id)
err = nf90_def_var(ncid%var(iFreq),"rel_tol",outputPrecision,(/gru_DimID/),actor_info%rel_tol_var_id)
err = nf90_def_var(ncid%var(iFreq),"abs_tol",outputPrecision,(/gru_DimID/),actor_info%abs_tol_var_id)
if(err/=0) then; message=trim(message)//trim(cmessage); print*, message; return; end if
end do
end subroutine def_output end subroutine def_output
! ********************************************************************************************************** ! **********************************************************************************************************
! private subroutine ini_create: initial create ! private subroutine ini_create: initial create
! ********************************************************************************************************** ! **********************************************************************************************************
subroutine ini_create(nGRU,nHRU,nSoil,infile,ncid,err,message) subroutine ini_create(nGRU,nHRU,nSoil,infile,ncid,err,message)
! variables to define number of steps per file (total number of time steps, step length, etc.) ! variables to define number of steps per file (total number of time steps, step length, etc.)
USE multiconst,only:secprday ! number of seconds per day USE multiconst,only:secprday ! number of seconds per day
! model decisions ! model decisions
...@@ -486,4 +536,4 @@ end subroutine def_output ...@@ -486,4 +536,4 @@ end subroutine def_output
end subroutine end subroutine
end module def_output_module end module def_output_actors_module
#include "file_access_actor.hpp"
#include "forcing_file_info.hpp"
#include "fortran_data_types.hpp"
#include "message_atoms.hpp"
#include "json.hpp"
#include "auxilary.hpp"
using json = nlohmann::json;
namespace caf {
behavior file_access_actor(stateful_actor<file_access_state>* self, int start_gru, int num_gru,
File_Access_Actor_Settings file_access_actor_settings, actor parent) {
aout(self) << "\n----------File_Access_Actor Started----------\n";
// Set Up timing Info we wish to track
self->state.file_access_timing = TimingInfo();
self->state.file_access_timing.addTimePoint("read_duration");
self->state.file_access_timing.addTimePoint("write_duration");
// Save the parameters passed from job_actor
self->state.file_access_actor_settings = file_access_actor_settings;
self->state.parent = parent;
self->state.num_gru = num_gru;
self->state.start_gru = start_gru;
self->state.err = 0;
self->state.num_output_steps = self->state.file_access_actor_settings.num_timesteps_in_output_buffer;
fileAccessActor_init_fortran(self->state.handle_forcing_file_info,
&self->state.numFiles,
&self->state.num_steps,
&self->state.file_access_actor_settings.num_timesteps_in_output_buffer,
self->state.handle_ncid,
&self->state.start_gru,
&self->state.num_gru,
&self->state.num_gru, // Filler for num_hrus
&self->state.err);
if (self->state.err != 0) {
aout(self) << "ERROR: File Access Actor - File_Access_init_Fortran\n";
if (self->state.err == 100) {
self->send(self->state.parent, file_access_error::mDecisions_error, self);
} else {
self->send(self->state.parent, file_access_error::unhandleable_error, self);
}
return {};
}
aout(self) << "Simluations Steps: " << self->state.num_steps << "\n";
// Inital Files Have Been Loaded - Send Message to Job_Actor to Start Simulation
self->send(self->state.parent, init_gru_v);
// initalize the forcingFile array
self->state.filesLoaded = 0;
for (int i = 1; i <= self->state.numFiles; i++) {
self->state.forcing_file_list.push_back(Forcing_File_Info(i));
}
// Check that the number of timesteps in the output buffer is not greater than the number of timesteps in the simulation
if (self->state.num_steps < self->state.file_access_actor_settings.num_timesteps_in_output_buffer) {
self->state.num_output_steps = self->state.num_steps;
self->state.file_access_actor_settings.num_timesteps_in_output_buffer = self->state.num_steps;
}
// Set up the output container
self->state.output_container = new Output_Container(self->state.file_access_actor_settings.num_partitions_in_output_buffer,
self->state.num_gru,
self->state.file_access_actor_settings.num_timesteps_in_output_buffer,
self->state.num_steps);
return {
// Message from the HRU actor to get the forcing file that is loaded
[=](access_forcing, int currentFile, caf::actor refToRespondTo) {
if (currentFile <= self->state.numFiles) {
if(self->state.forcing_file_list[currentFile - 1].isFileLoaded()) { // C++ starts at 0 Fortran starts at 1
// Send the HRU actor the new forcing file
// then tell it to get back to running
self->send(refToRespondTo, new_forcing_file_v,
self->state.forcing_file_list[currentFile - 1].getNumSteps(),
currentFile);
} else {
self->state.file_access_timing.updateStartPoint("read_duration");
// Load the file
read_forcingFile(self->state.handle_forcing_file_info, &currentFile,
&self->state.stepsInCurrentFile, &self->state.start_gru,
&self->state.num_gru, &self->state.err);
if (self->state.err != 0) {
aout(self) << "ERROR: Reading Forcing" << std::endl;
}
self->state.filesLoaded += 1;
self->state.forcing_file_list[currentFile - 1].updateNumSteps(self->state.stepsInCurrentFile);
self->state.file_access_timing.updateEndPoint("read_duration");
// Check if we have loaded all forcing files
if(self->state.filesLoaded <= self->state.numFiles) {
self->send(self, access_forcing_internal_v, currentFile + 1);
}
// Send the HRU actor the new forcing file
// then tell it to get back to running
self->send(refToRespondTo, new_forcing_file_v,
self->state.forcing_file_list[currentFile - 1].getNumSteps(),
currentFile);
}
} else {
aout(self) << currentFile << " is larger than expected for a forcing file request from an HRU" << std::endl;
}
},
// Internal Message to load all forcing files, calling this message allows other messages to be processed
[=](access_forcing_internal, int currentFile) {
if (self->state.filesLoaded <= self->state.numFiles &&
currentFile <= self->state.numFiles) {
if (self->state.forcing_file_list[currentFile - 1].isFileLoaded()) {
aout(self) << "File Loaded when shouldn't be \n";
}
self->state.file_access_timing.updateStartPoint("read_duration");
read_forcingFile(self->state.handle_forcing_file_info, &currentFile,
&self->state.stepsInCurrentFile, &self->state.start_gru,
&self->state.num_gru, &self->state.err);
if (self->state.err != 0) {
aout(self) << "ERROR: Reading Forcing" << std::endl;
}
self->state.filesLoaded += 1;
self->state.forcing_file_list[currentFile - 1].updateNumSteps(self->state.stepsInCurrentFile);
self->state.file_access_timing.updateEndPoint("read_duration");
self->send(self, access_forcing_internal_v, currentFile + 1);
} else {
aout(self) << "All Forcing Files Loaded \n";
}
},
// Message from HRU Actor so it knows how many timesteps it can write before waiting
[=] (get_num_output_steps) { return self->state.num_output_steps; },
[=](write_output, int index_gru, int index_hru, caf::actor hru_actor) {
self->state.file_access_timing.updateStartPoint("write_duration");
Output_Partition *output_partition = self->state.output_container->getOutputPartition(index_gru);
output_partition->setGRUReadyToWrite(hru_actor);
if (output_partition->isReadyToWrite()) {
writeOutput(self, output_partition);
}
self->state.file_access_timing.updateEndPoint("write_duration");
},
[=](restart_failures) {
self->state.output_container->reconstruct();
},
[=](run_failure, int local_gru_index) {
self->state.file_access_timing.updateStartPoint("write_duration");
Output_Partition *output_partition = self->state.output_container->getOutputPartition(local_gru_index);
output_partition->addFailedGRUIndex(local_gru_index);
if (output_partition->isReadyToWrite()) {
writeOutput(self, output_partition);
}
self->state.file_access_timing.updateEndPoint("write_duration");
},
[=](finalize) {
aout(self) << "File Access Actor: Deallocating Structure" << std::endl;
self->state.output_container->~Output_Container(); // Delete Output Container
FileAccessActor_DeallocateStructures(self->state.handle_forcing_file_info, self->state.handle_ncid);
aout(self) << "\n________________FILE_ACCESS_ACTOR TIMING INFO RESULTS________________\n";
aout(self) << "Total Read Duration = " << self->state.file_access_timing.getDuration("read_duration").value_or(-1.0) << " Seconds\n";
aout(self) << "Total Write Duration = " << self->state.file_access_timing.getDuration("write_duration").value_or(-1.0) << " Seconds\n";
self->quit();
return std::make_tuple(self->state.file_access_timing.getDuration("read_duration").value_or(-1.0),
self->state.file_access_timing.getDuration("write_duration").value_or(-1.0));
},
};
}
void writeOutput(stateful_actor<file_access_state>* self, Output_Partition* partition) {
int num_timesteps_to_write = partition->getNumStoredTimesteps();
int start_gru = partition->getStartGRUIndex();
int max_gru = partition->getMaxGRUIndex();
bool write_param_flag = partition->isWriteParams();
writeOutput_fortran(self->state.handle_ncid, &num_timesteps_to_write,
&start_gru, &max_gru, &write_param_flag, &self->state.err);
partition->updateTimeSteps();
int num_steps_before_next_write = partition->getNumStoredTimesteps();
std::vector<caf::actor> hrus_to_update = partition->getReadyToWriteList();
for (int i = 0; i < hrus_to_update.size(); i++) {
self->send(hrus_to_update[i], num_steps_before_write_v, num_steps_before_next_write);
self->send(hrus_to_update[i], run_hru_v);
}
partition->resetReadyToWriteList();
}
} // end namespace
\ No newline at end of file
#include "forcing_file_info.hpp"
Forcing_File_Info::Forcing_File_Info(int file_ID) {
this->file_ID = file_ID;
this->num_steps = 0;
this->is_loaded = false;
}
int Forcing_File_Info::getNumSteps() {
return this->num_steps;
}
bool Forcing_File_Info::isFileLoaded() {
return this->is_loaded;
}
void Forcing_File_Info::updateIsLoaded() {
this->is_loaded = true;
}
void Forcing_File_Info::updateNumSteps(int num_steps) {
this->num_steps = num_steps;
this->is_loaded = true;
}
This diff is collapsed.
This diff is collapsed.
character(len=64), parameter :: summaVersion = ''
character(len=64), parameter :: buildTime = ''
character(len=64), parameter :: gitBranch = ''
character(len=64), parameter :: gitHash = ''
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#ifndef COMMONFUNCTIONS_H_ #include "global.hpp"
#define COMMONFUNCTIONS_H_
#include <chrono>
// Gobal Flag for Debuging only main function will change this
bool debug;
/**
* Return the time between to time points
*/
double calculateTime(std::chrono::time_point<std::chrono::system_clock> start,
std::chrono::time_point<std::chrono::system_clock> end);
double calculateTime(std::chrono::time_point<std::chrono::system_clock> start, double calculateTime(std::chrono::time_point<std::chrono::system_clock> start,
...@@ -20,8 +6,3 @@ double calculateTime(std::chrono::time_point<std::chrono::system_clock> start, ...@@ -20,8 +6,3 @@ double calculateTime(std::chrono::time_point<std::chrono::system_clock> start,
return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count(); return std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
} }
#endif
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.