OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
hotstart.c File Reference

Reading and writing of legacy hot-start state files. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "headers.h"
Include dependency graph for hotstart.c:

Macros

#define _CRT_SECURE_NO_DEPRECATE
 

Functions

int hotstart_open ()
 Restore configured input state and initialize configured hotstart outputs.
 
void hotstart_save ()
 Saves hotstart files whose specified save time has arrived.
 
int hotstart_save_to_file (const char *hotstartFile)
 Save the current runoff and routing state to a named version-4 hotstart file.
 
int hotstart_is_valid (const char *hotstartFile, int *inputFileVersion)
 Recognize a hotstart file's header and version.
 
void hotstart_close ()
 Saves and closes hotstart files that are to be written at end of simulation.
 

Detailed Description

Reading and writing of legacy hot-start state files.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com (OpenSWMM maintenance and extensions)
License
Apache-2.0 for OpenSWMM contributions; original EPA SWMM provenance is retained.

Macro Definition Documentation

◆ _CRT_SECURE_NO_DEPRECATE

#define _CRT_SECURE_NO_DEPRECATE

Function Documentation

◆ hotstart_close()

void hotstart_close ( void )

Saves and closes hotstart files that are to be written at end of simulation.

◆ hotstart_is_valid()

int hotstart_is_valid ( const char * hotstartFile,
int * inputFileVersion )

Recognize a hotstart file's header and version.

Parameters
[in]hotstartFileNon-null borrowed null-terminated path; opened in r+b mode, so writable access is required even though only the header is read.
[out]inputFileVersionNon-null caller-owned slot set to 1, 2, 3 or 4 on a recognized header; unchanged on reported open/format failure.
Returns
Zero for a recognized header, ERR_HOTSTART_FILE_OPEN on opening failure, or ERR_HOTSTART_FILE_FORMAT for an unrecognized version-1 header.
Note
This does not validate record counts, payload completeness or I/O status of every header read. The local stream is closed before returning.

◆ hotstart_open()

int hotstart_open ( void )

Restore configured input state and initialize configured hotstart outputs.

Returns
TRUE if input restoration and all output opens succeed, FALSE after a reported input/output initialization failure.
Postcondition
Successful output streams remain open for the hotstart lifecycle. On a later failure, earlier successful output opens remain for cleanup; this routine does not roll back model state restored from the input.
Here is the call graph for this function:

◆ hotstart_save()

void hotstart_save ( void )

Saves hotstart files whose specified save time has arrived.

◆ hotstart_save_to_file()

int hotstart_save_to_file ( const char * hotstartFile)

Save the current runoff and routing state to a named version-4 hotstart file.

Parameters
[in]hotstartFileNon-null borrowed null-terminated filename; relative paths are resolved through addAbsolutePath().
Returns
Zero after opening and writing the snapshot, or the opening error code from initializeSaveHotstartFile(). Individual writes/close are not checked.
Note
Creates or truncates the destination, closes its local stream, and frees its temporary descriptor. Allocation failure is not checked here.
Here is the call graph for this function: