Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for HDF5 array outputs #33

Merged
merged 8 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/input_output.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Here is a typical global file taken from the examples folder:
0

%Where to put write hydrographs
%(0 = no output, 1 = .dat file, 2 = .csv file, 3 = database, 5 = .h5)
%(0 = no output, 1 = .dat file, 2 = .csv file, 3 = database, 5 = .h5 packet, 6 = .h5 array)
5 5.0 outputs.h5

%Where to put peakflow data
Expand Down Expand Up @@ -388,7 +388,8 @@ where :math:`A` is the upstream of the link, measured in km2.
A time series flag of ``1`` indicates the results of the simulation will be saved as a .dat file. The filename complete with a path must be specified. If a file with the name and path given already exists, it is overwritten.
A time series flag of ``2`` indicates the results will be stored as a .csv file.
A time series flag of ``3`` indicates the results will be uploaded into the database described by the given .dbc file. In this case, a table name accessible by the queries in the .dbc file must be specified.
A time series flag of ``5`` indicates indicates the results will be stored as a .h5 HDF5 file.
A time series flag of ``5`` indicates the results will be stored as a .h5 HDF5 file with a packet layout compatible with PyTable.
A time series flag of ``6`` indicates the results will be stored as a .h5 HDF5 file with an 3D array layout. Time, link id and output indexes are given as additional 1D "dimension" arrays. Selected outputs in :ref:`Solver Outputs` must have the same type (ASYNCH_FLOAT).

This section is independent of the section for Link IDs to Save described below (see :ref:`Global Parameters`) For example, if link ids are specified in the Link IDs to Save section and the time series flag in the Time Series Locations set to ``0``, no output is generated. Similarly, if *the time series id flag* is set to ``0`` in the Link IDs to Save section and the time series flag is set to ``1``, a .dat file with ``0`` time series is produced.

Expand Down
8 changes: 3 additions & 5 deletions examples/clearcreek.gbl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
0 %Parameters to filenames

%Components to print
4
Time
LinkID
2
State0
State6

Expand Down Expand Up @@ -55,8 +53,8 @@ Classic
0

%Where to put write hydrographs
%(0 = no output, 1 = .dat file, 2 = .csv file, 3 = database)
1 5.0 clearcreek.dat
%(0 = no output, 1 = .dat file, 2 = .csv file, 3 = database, 5 = .h5 packet, 6 = .h5 array)
6 5.0 clearcreek.h5

%Where to put peakflow data
%(0 = no output, 1 = .pea file, 2 = database)
Expand Down
4 changes: 0 additions & 4 deletions ide/msvc/asynch/asynch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@
</ClCompile>
<ClCompile Include="..\..\..\src\optparse.c" />
</ItemGroup>
<ItemGroup>
<None Include="$(RootDir)\src\LICENSE" />
<None Include="$(RootDir)\src\makefile" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\asynchlib\asynchlib.vcxproj">
<Project>{b7c669bc-cb73-4fd5-b095-65aa2c1d6d1b}</Project>
Expand Down
4 changes: 0 additions & 4 deletions ide/msvc/asynch/asynch.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,4 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="$(RootDir)\src\LICENSE" />
<None Include="$(RootDir)\src\makefile" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion ide/msvc/asynchlib/asynchlib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
</ItemGroup>
<ItemGroup>
<None Include="$(RootDir)\LICENSE" />
<None Include="$(RootDir)\makefile" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
1 change: 0 additions & 1 deletion ide/msvc/asynchlib/asynchlib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,5 @@
</ItemGroup>
<ItemGroup>
<None Include="$(RootDir)\LICENSE" />
<None Include="$(RootDir)\makefile" />
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions src/asynch_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,9 @@ int Asynch_Check_Peakflow_Output(AsynchSolver* asynch, char* name)

int Asynch_Delete_Temporary_Files(AsynchSolver* asynch)
{
if (asynch->outputfile)
fclose(asynch->outputfile);

int ret_val = RemoveTemporaryFiles(asynch->globals, asynch->my_save_size, NULL);
//if(ret_val == 1) printf("[%i]: Error deleting temp file. File does not exist.\n");
if (ret_val != 0) printf("[%i]: Error [%i] while deleting temp file.\n", my_rank, ret_val);
Expand Down
4 changes: 3 additions & 1 deletion src/config_gbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ GlobalVars* Read_Global_Data(
globals->hydros_loc_filename = NULL;
globals->hydro_table = NULL;

if (globals->hydros_loc_flag == 1 || globals->hydros_loc_flag == 2 || globals->hydros_loc_flag == 4 || globals->hydros_loc_flag == 5)
if (globals->hydros_loc_flag == 1 || globals->hydros_loc_flag == 2 || globals->hydros_loc_flag == 4 || globals->hydros_loc_flag == 5 || globals->hydros_loc_flag == 6)
{
globals->hydros_loc_filename = (char*)malloc(ASYNCH_MAX_PATH_LENGTH * sizeof(char));
valsread = sscanf(line_buffer, "%*u %lf %s", &(globals->print_time), globals->hydros_loc_filename);
Expand All @@ -448,12 +448,14 @@ GlobalVars* Read_Global_Data(
if (globals->hydros_loc_flag == 2 && !CheckFilenameExtension(globals->hydros_loc_filename, ".csv")) return NULL;
if (globals->hydros_loc_flag == 4 && !CheckFilenameExtension(globals->hydros_loc_filename, ".rad")) return NULL;
if (globals->hydros_loc_flag == 5 && !CheckFilenameExtension(globals->hydros_loc_filename, ".h5")) return NULL;
if (globals->hydros_loc_flag == 6 && !CheckFilenameExtension(globals->hydros_loc_filename, ".h5")) return NULL;
//globals->output_flag = (globals->hydros_loc_flag == 1) ? 0 : 1;

if (globals->hydros_loc_flag == 1) RemoveSuffix(globals->hydros_loc_filename, ".dat");
else if (globals->hydros_loc_flag == 2) RemoveSuffix(globals->hydros_loc_filename, ".csv");
else if (globals->hydros_loc_flag == 4) RemoveSuffix(globals->hydros_loc_filename, ".rad");
else if (globals->hydros_loc_flag == 5) RemoveSuffix(globals->hydros_loc_filename, ".h5");
else if (globals->hydros_loc_flag == 6) RemoveSuffix(globals->hydros_loc_filename, ".h5");
}
else if (globals->hydros_loc_flag == 3)
{
Expand Down
2 changes: 1 addition & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void OutputFunc_Init(
output_func->PreparePeakflowOutput = NULL;

//Create Final Time Series Output
if (hydros_loc_flag == 1 || hydros_loc_flag == 2 || hydros_loc_flag == 4 || hydros_loc_flag == 5)
if (hydros_loc_flag == 1 || hydros_loc_flag == 2 || hydros_loc_flag == 4 || hydros_loc_flag == 5 || hydros_loc_flag == 6)
output_func->CreateOutput = &DumpTimeSerieFile;
else if (hydros_loc_flag == 3)
{
Expand Down
Loading