Repository: pyswmm/Stormwater-Management-Model (language: python)

Issue:
Add save_hotstart file to API ("Breadcrumbs" feature")

Hotstart save (aka "Bread Crumbs")
Continuing the great contribution from @jsadler2. 

Builds on top of #179 

Closes #253


Discussion / hints:

# [Codecov](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=h1) Report
> Merging [#252](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=desc) into [develop](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/commit/a8382270dd5f49f8da88ae2c9bca8f3b5e39da7e?src=pr&el=desc) will **increase** coverage by `0.46%`.
> The diff coverage is `81.66%`.

[![Impacted file tree graph](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/graphs/tree.svg?width=650&token=jalbaKc6Z8&height=150&src=pr)](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           develop     #252      +/-   ##
===========================================
+ Coverage    62.55%   63.02%   +0.46%     
===========================================
  Files           53       53              
  Lines        16672    16694      +22     
===========================================
+ Hits         10430    10521      +91     
+ Misses        6242     6173      -69
```


| [Impacted Files](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/swmm5.c](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/diff?src=pr&el=tree#diff-c3JjL3N3bW01LmM=) | `85.11% <100%> (ø)` | :arrow_up: |
| [src/hotstart.c](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/diff?src=pr&el=tree#diff-c3JjL2hvdHN0YXJ0LmM=) | `75% <80%> (+22.39%)` | :arrow_up: |
| [src/toolkitAPI.c](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/diff?src=pr&el=tree#diff-c3JjL3Rvb2xraXRBUEkuYw==) | `66.34% <84.61%> (+1.5%)` | :arrow_up: |
| [src/massbal.c](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/diff?src=pr&el=tree#diff-c3JjL21hc3NiYWwuYw==) | `79.02% <0%> (+0.21%)` | :arrow_up: |
| [src/infil.c](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252/diff?src=pr&el=tree#diff-c3JjL2luZmlsLmM=) | `61.51% <0%> (+3.49%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=footer). Last update [a838227...18fe690](https://codecov.io/gh/OpenWaterAnalytics/Stormwater-Management-Model/pull/252?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@bemcdonnell , thanks for pushing this forward.
@LRossman, I did just a tiny bit of refactoring for saving out to an HSF. Mainly passing the file structure pointer as an argument.  I can't imagine this will be a deal breaker - but it seems to make a little more sense this way considering we are opening up this as a new API feature.  
@LRossman, I'm also leaning toward changing the function names a little too.  `hotstart_open` has more of `hotstart_set_initial_state` behavior.  And `hotstart_close` has more of `hotstart_save_state`.  The proposed function names could be simpler, yes, but the idea is that they are a little more descriptive/less ambiguous. Thoughts?
@bemcdonnell as I'm reviewing this PR I noticed that the `hotstart.c` file being modified seems to come from v.5.1.012 (or maybe 5.1.011) and not 5.1.013 since the latter has a code section starting at line 77 removed whereas your file just has the section commented out. Now this may be moot, since there are no comments in the file marking any changes for v.5.1.013, but it has me concerned that the project may not be using all of the files from the latest EPA release (5.1.013) as its base.
I don't like creating 3 new functions for saving a hotstart file via the swmm_saveHotstart function. Here's how I would have done it without needing to change anything in the original SWMM code:
```
int DLLEXPORT swmm_saveHotstart(char *hsfile)
{
// Sanity checks go here
    else
    {
        TFile tmpHotstart1 = Fhotstart1;
        TFile tmpHotstart2 = Fhotstart2;
        Fhotstart1.mode = NO_FILE;
        Fhotstart2.mode = SAVE_FILE;
        sstrncpy(Fhotstart2.name, hsfile, MAXFNAME); 
        if (hotstart_open()) hotstart_close();
        Fhotstart2 = tmpHotstart2;
        Fhotstart1 = tmpHotstart1;
    }
    return error_getCode(error_code_index);
}
```

@bemcdonnell I am trying to think of reasons why the implementation suggested by @LRossman will not be ideal but can't think of any major ones save for I am generally apprehensive about using global variables and repurposing one like this makes me worry even more. However, it is less intrusive and accomplishes the same task. What do you think ?
@LRossman, I like the simplicity and elegance of your suggested implementation.  I wonder if perhaps we could consider a blended solution that could perhaps be more congruent with longer-term planning for this project (echoing @calebbuahin).  I could be being way too presumptuous here but what if we think about our end-goal as a place where we encapsulate all of the globals and separate concerns _better_?  By doing so, we can write code that is easily unit-testable.  I think opening up an issue to talk about more general roadmapping philosophy would be worth all of our time!  So you be the judge in this thread - Am I being presumptuous or not with my proposed end-goal? :-)

What I like about @jsadler2's and my proposed implementation is that we are passing file pointers into a function as an argument instead of telling this function to use a global.  To me, this makes the code a lot more readable.  What I don't like about the proposed implementation is exactly what you are saying @LRossman - we are explicitly calling `saveRouting` and `saveRunoff` in `toolkitAPI.c`.  Directly talking to those two functions outside of hotstart.c is NOT elegant.  I think `swmm_saveHotstart(char *flname)` should call a function like `hotstart_close(TFile flptr)`.  One thing I really do not like is using temporary variables to hold and store state. It doesn't feel as clean to me - but this is totally a personal style thing.   Passing file handles around is a nice step toward an encapsulation.  Also it will make it easier to unit test.  

What are your thoughts?


Oh and a quick response to what you found:
> @bemcdonnell as I'm reviewing this PR I noticed that the hotstart.c file being modified seems to come from v.5.1.012 (or maybe 5.1.011) and not 5.1.013

This came from a dev version of 5.1.013.  One of the last things that was done was comments were stripped away.  Looks like I introduced the comment back it when i resolved the merge conflicts into Jeff's code.  I promise this is the only thing that I brought back in ;-)
@bemcdonnell I thought that the focus of this project was to supply SWMM with a comprehensive API, only making changes to the core engine code when it was absolutely necessary, thus making it easier to keep in synch with the official EPA version of the code. Although I'm sure there are lots of places where refactoring might be called for, my response would be "if it ain't broke don't fix it".

That being said, I would endorse someone or group forking the code to another project (not just a branch) and re-architecting it from the ground up (not just applying piecemeal refactoring to the current code). It's been almost 15 years since SWMM 5 was first released so maybe the software development cycle has run its course.

One source of ideas for what the re-design might look like can be found in a white paper I wrote for the [ re-design of EPANET](https://github.com/OpenWaterAnalytics/next-net/files/2128973/EPANET.3.White.Paper.pdf). EPANET and SWMM have a lot in common from a structural point of view so the ideas presented there may be relevant.
@LRossman, I've elevated your last comment to a new Issue in #254.  I'm writing a response to it now!
@jackieff has been newly assigned to this since she sounded really excited to do it!  Thanks @jackieff !!!

Fix patch:
diff --git a/src/solver/include/toolkit.h b/src/solver/include/toolkit.h
index 79ade19dc..540fce63a 100644
--- a/src/solver/include/toolkit.h
+++ b/src/solver/include/toolkit.h
@@ -106,6 +106,15 @@ EXPORT_TOOLKIT int swmm_getSimulationParam(SM_SimSetting type, double *value);
  @return Error code
  */
 EXPORT_TOOLKIT int  swmm_setSimulationParam(SM_SimSetting type, double value);
+
+/**
+ @brief Use/override a hotstart file before the simulation starts.
+ @param type The property type code (see @ref SM_HotStart)
+ @param hsfile The file name of the hot start file that the user would like to use.
+ @return Error code
+*/
+EXPORT_TOOLKIT int swmm_hotstart(SM_HotStart type, const char *hsfile);
+
 /**
  @brief Gets Object Count
  @param type Option code (see @ref SM_ObjectType)
diff --git a/src/solver/include/toolkit_enums.h b/src/solver/include/toolkit_enums.h
index 5d7c9e1dc..89bf2ce14 100644
--- a/src/solver/include/toolkit_enums.h
+++ b/src/solver/include/toolkit_enums.h
@@ -93,6 +93,12 @@ typedef enum {
     SM_THREADS       = 14  /**< Number of Threads for this process */
 } SM_SimSetting;
 
+/// Hot Start File Manager
+typedef enum {
+    SM_HOTSTART_USE  = 0,  /**< Use Hotstart File */
+    SM_HOTSTART_SAVE = 1   /**< Save Hotstart File */
+} SM_HotStart;
+
 /// Node property codes
 typedef enum {
     SM_INVERTEL     = 0,  /**< Invert Elevation */
diff --git a/src/solver/include/toolkit_error.h b/src/solver/include/toolkit_error.h
index 3f58128ec..29ead3b3f 100644
--- a/src/solver/include/toolkit_error.h
+++ b/src/solver/include/toolkit_error.h
@@ -14,6 +14,7 @@ enum  ToolkitErrorType {
     ERR_TKAPI_UNDEFINED_LID      = 2010,
     ERR_TKAPI_MEMORY             = 2011,
     ERR_TKAPI_NO_INLET           = 2012,
+    ERR_TKAPI_SIM_RUNNING        = 2013,
 
     TKMAXERRMSG                  = 3000
 };
diff --git a/src/solver/include/toolkit_errors.txt b/src/solver/include/toolkit_errors.txt
index 4a9dd1f8e..1349f5a4b 100644
--- a/src/solver/include/toolkit_errors.txt
+++ b/src/solver/include/toolkit_errors.txt
@@ -13,3 +13,4 @@ ERR(2009, "\n API Key Error: Invalid Lid Unit Index")
 ERR(2010, "\n API Key Error: Undefined Subcatchment Lid")
 ERR(2011, "\n API Key Error: No memory allocated for return value")
 ERR(2012, "\n API Key Error: Specified link is not assigned an inlet")
+ERR(2013, "\n API Key Error: Simulation Already Started or Running.")
diff --git a/src/solver/toolkit.c b/src/solver/toolkit.c
index d61006f15..09d088672 100644
--- a/src/solver/toolkit.c
+++ b/src/solver/toolkit.c
@@ -461,6 +461,75 @@ EXPORT_TOOLKIT int  swmm_setSimulationParam(SM_SimSetting type, double value)
     return error_code;
 }
 
+EXPORT_TOOLKIT int swmm_hotstart(SM_HotStart type, const char *hsfile)
+///
+/// Input:   type = Hotstart option USE/SAVE (SM_HotStart)
+///          hotstart = file ID name (able to overwrite)
+/// Return   API Error
+/// Purpose: Allows selecting a HSF to use or save
+{
+    int error_code = 0;
+    // Check if Open
+    if(swmm_IsOpenFlag() == FALSE)
+    {
+        error_code = ERR_TKAPI_INPUTNOTOPEN;
+    }
+    // Check if Simulation is Started
+    else if (swmm_IsStartedFlag() == TRUE && type == SM_HOTSTART_USE)
+    {
+        error_code = ERR_TKAPI_SIM_RUNNING;
+    }
+    // Check if Simulation is NOT started
+    else if (swmm_IsStartedFlag() == FALSE && type == SM_HOTSTART_SAVE)
+    {
+        error_code = ERR_TKAPI_SIM_NRUNNING;
+    }
+    else
+    {
+        switch(type)
+        {
+            case SM_HOTSTART_USE:
+            {
+                // Fhotstart1 is the file to to be read
+                char fl_name[MAXFNAME];
+                sstrncpy(fl_name, hsfile, MAXFNAME);
+                Fhotstart1.mode = USE_FILE;
+                sstrncpy(Fhotstart1.name, fl_name, MAXFNAME);
+                break;
+            }
+            case SM_HOTSTART_SAVE:
+            {
+                // Storing Existing INP set HSFs
+                TFile tmpHotstart1 = Fhotstart1;
+                TFile tmpHotstart2 = Fhotstart2;
+                int _fl1_info = Fhotstart1.mode;
+                int _fl2_info = Fhotstart2.mode;
+                // Create info for New HSF
+                Fhotstart1.mode = NO_FILE;
+                Fhotstart2.mode = SAVE_FILE;
+                sstrncpy(Fhotstart2.name, hsfile, MAXFNAME);
+                // Saving Data
+                if (hotstart_open())
+                {
+                    hotstart_close();
+                    // Replacing INP set HSFs
+                    Fhotstart2 = tmpHotstart2;
+                    Fhotstart1 = tmpHotstart1;
+                    Fhotstart1.mode = _fl1_info;
+                    Fhotstart2.mode = _fl2_info;
+                }
+                else
+                {
+                    error_code = ERR_HOTSTART_FILE_OPEN;
+                }
+                break;
+            }
+            default: error_code = ERR_TKAPI_OUTBOUNDS; break;
+        }
+    }
+    return error_code;
+}
+
 EXPORT_TOOLKIT int  swmm_countObjects(SM_ObjectType type, int *count)
 ///
 /// Input:   type = object type (Based on SM_ObjectType enum)


Test patch:
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index c224b9e7d..598e7aaa6 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -20,7 +20,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [windows-2022, ubuntu-20.04, macos-10.15]
+        os: [windows-2022, ubuntu-20.04, macos-13.4]
         requirements: [requirements-swmm.txt]
         include:
           - os: windows-2022
@@ -58,9 +58,9 @@ jobs:
                 shell: bash
                 working-directory: ./ci-tools/linux
 
-          - os: macos-10.15
+          - os: macos-13.4
             sys_pkgs: brew install libomp #boost
-            boost_platform_version: 10.15
+            boost_platform_version: 13.4
             boost_toolsit: clang
             build_unit_test: make.zsh -t -g "Xcode"
             build_reg_test: make.zsh -g "Xcode"
@@ -111,11 +111,11 @@ jobs:
       # install boost on mac and linux
       - name: Install required system packages on mac and linux
         run: ${{ matrix.sys_pkgs }}
-        if: ${{ runner.os == 'macOS' }} 
+        if: ${{ runner.os == 'macOS' }}
 
       # boost takes a while to install on windows, so try to cache
       - name: Install boost
-        # if: ${{runner.os == 'Windows'}} 
+        # if: ${{runner.os == 'Windows'}}
         uses: MarkusJx/install-boost@v2.4.4
         id: install-boost
         with:
@@ -123,7 +123,7 @@ jobs:
             # A list of supported versions can be found here:
             # https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
             boost_version: 1.81.0
-            link: shared 
+            link: shared
             # OPTIONAL: Specify a custon install location
             # boost_install_dir: C:\some_directory
             # OPTIONAL: Specify a platform version
diff --git a/tests/solver/CMakeLists.txt b/tests/solver/CMakeLists.txt
index 021832fbb..0a1bdfe1a 100644
--- a/tests/solver/CMakeLists.txt
+++ b/tests/solver/CMakeLists.txt
@@ -38,6 +38,7 @@ set(solver_test_srcs
     test_solver.cpp
     test_stats.cpp
     test_inlets_and_drains.cpp
+    test_toolkit_hotstart.cpp
     # ADD NEW TEST SUITES TO EXISTING TOOLKIT TEST MODULE
 )
 
diff --git a/tests/solver/data/hotstart/Simulation1.inp b/tests/solver/data/hotstart/Simulation1.inp
new file mode 100644
index 000000000..3f2639fc3
--- /dev/null
+++ b/tests/solver/data/hotstart/Simulation1.inp
@@ -0,0 +1,217 @@
+[TITLE]
+;;Project Title/Notes
+Example 1
+
+[OPTIONS]
+;;Option             Value
+FLOW_UNITS           CFS
+INFILTRATION         HORTON
+FLOW_ROUTING         DYNWAVE
+LINK_OFFSETS         DEPTH
+MIN_SLOPE            0
+ALLOW_PONDING        NO
+SKIP_STEADY_STATE    NO
+
+START_DATE           01/01/1998
+START_TIME           00:00:00
+REPORT_START_DATE    01/01/1998
+REPORT_START_TIME    00:00:00
+END_DATE             01/02/1998
+END_TIME             12:00:00
+SWEEP_START          1/1
+SWEEP_END            12/31
+DRY_DAYS             5
+REPORT_STEP          01:00:00
+WET_STEP             00:15:00
+DRY_STEP             01:00:00
+ROUTING_STEP         0:01:00
+
+INERTIAL_DAMPING     PARTIAL
+NORMAL_FLOW_LIMITED  BOTH
+FORCE_MAIN_EQUATION  H-W
+VARIABLE_STEP        0.75
+LENGTHENING_STEP     0
+MIN_SURFAREA         0
+MAX_TRIALS           0
+HEAD_TOLERANCE       0
+SYS_FLOW_TOL         5
+LAT_FLOW_TOL         5
+;MINIMUM_STEP        0.5
+THREADS              1
+
+[FILES]
+SAVE HOTSTART INFILE_Simulation1.hsf
+
+[EVAPORATION]
+;;Data Source    Parameters
+;;-------------- ----------------
+CONSTANT         0.0
+DRY_ONLY         NO
+
+[RAINGAGES]
+;;Name           Format    Interval SCF      Source
+;;-------------- --------- ------ ------ ----------
+RG1              INTENSITY 1:00     1.0      TIMESERIES TS1
+
+[SUBCATCHMENTS]
+;;Name           Rain Gage        Outlet           Area     %Imperv  Width    %Slope   CurbLen  SnowPack
+;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ----------------
+1                RG1              9                10       50       500      0.01     0
+2                RG1              10               10       50       500      0.01     0
+3                RG1              13               5        50       500      0.01     0
+4                RG1              22               5        50       500      0.01     0
+5                RG1              15               15       50       500      0.01     0
+6                RG1              23               12       10       500      0.01     0
+7                RG1              19               4        10       500      0.01     0
+8                RG1              18               10       10       500      0.01     0
+
+[SUBAREAS]
+;;Subcatchment   N-Imperv   N-Perv     S-Imperv   S-Perv     PctZero    RouteTo    PctRouted
+;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
+1                0.001      0.10       0.05       0.05       25         OUTLET
+2                0.001      0.10       0.05       0.05       25         OUTLET
+3                0.001      0.10       0.05       0.05       25         OUTLET
+4                0.001      0.10       0.05       0.05       25         OUTLET
+5                0.001      0.10       0.05       0.05       25         OUTLET
+6                0.001      0.10       0.05       0.05       25         OUTLET
+7                0.001      0.10       0.05       0.05       25         OUTLET
+8                0.001      0.10       0.05       0.05       25         OUTLET
+
+[INFILTRATION]
+;;Subcatchment   MaxRate    MinRate    Decay      DryTime    MaxInfil
+;;-------------- ---------- ---------- ---------- ---------- ----------
+1                0.35       0.25       4.14       0.50       0
+2                0.7        0.3        4.14       0.50       0
+3                0.7        0.3        4.14       0.50       0
+4                0.7        0.3        4.14       0.50       0
+5                0.7        0.3        4.14       0.50       0
+6                0.7        0.3        4.14       0.50       0
+7                0.7        0.3        4.14       0.50       0
+8                0.7        0.3        4.14       0.50       0
+
+[JUNCTIONS]
+;;Name           Elevation  MaxDepth   InitDepth  SurDepth   Aponded
+;;-------------- ---------- ---------- ---------- ---------- ----------
+9                1000       3          0          0          0
+10               995        3          0          0          0
+13               995        3          0          0          0
+14               990        3          0          0          0
+15               987        3          0          0          0
+16               985        3          0          0          0
+17               980        3          0          0          0
+19               1010       3          0          0          0
+20               1005       3          0          0          0
+21               990        3          0          0          0
+22               987        3          0          0          0
+23               990        3          0          0          0
+24               984        3          0          0          0
+
+[OUTFALLS]
+;;Name           Elevation  Type       Stage Data       Gated    Route To
+;;-------------- ---------- ---------- ---------------- -------- ----------------
+18               975        FREE                        NO
+
+[CONDUITS]
+;;Name           From Node        To Node          Length     Roughness  InOffset   OutOffset  InitFlow   MaxFlow
+;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------
+1                9                10               400        0.01       0          0          0          0
+4                19               20               200        0.01       0          0          0          0
+5                20               21               200        0.01       0          0          0          0
+6                10               21               400        0.01       0          1          0          0
+7                21               22               300        0.01       1          1          0          0
+8                22               16               300        0.01       0          0          0          0
+10               17               18               400        0.01       0          0          0          0
+11               13               14               400        0.01       0          0          0          0
+12               14               15               400        0.01       0          0          0          0
+13               15               16               400        0.01       0          0          0          0
+14               23               24               400        0.01       0          0          0          0
+15               16               24               100        0.01       0          0          0          0
+16               24               17               400        0.01       0          0          0          0
+
+[XSECTIONS]
+;;Link           Shape        Geom1            Geom2      Geom3      Geom4      Barrels    Culvert
+;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ----------
+1                CIRCULAR     1.5              0          0          0          1
+4                CIRCULAR     1                0          0          0          1
+5                CIRCULAR     1                0          0          0          1
+6                CIRCULAR     1                0          0          0          1
+7                CIRCULAR     2                0          0          0          1
+8                CIRCULAR     2                0          0          0          1
+10               CIRCULAR     2                0          0          0          1
+11               CIRCULAR     1.5              0          0          0          1
+12               CIRCULAR     1.5              0          0          0          1
+13               CIRCULAR     1.5              0          0          0          1
+14               CIRCULAR     1                0          0          0          1
+15               CIRCULAR     2                0          0          0          1
+16               CIRCULAR     2                0          0          0          1
+
+[POLLUTANTS]
+;;Name           Units  Crain      Cgw        Crdii      Kdecay     SnowOnly   Co-Pollutant     Co-Frac    Cdwf       Cinit
+;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ----------
+TSS              MG/L   0.0        0.0        0          0.0        NO         *                0.0        0          0
+Lead             UG/L   0.0        0.0        0          0.0        NO         TSS              0.2        0          0
+
+[LANDUSES]
+;;               Sweeping   Fraction   Last
+;;Name           Interval   Available  Swept
+;;-------------- ---------- ---------- ----------
+Residential
+Undeveloped
+
+[COVERAGES]
+;;Subcatchment   Land Use         Percent
+;;-------------- ---------------- ----------
+1                Residential      100.00
+2                Residential      50.00
+2                Undeveloped      50.00
+3                Residential      100.00
+4                Residential      50.00
+4                Undeveloped      50.00
+5                Residential      100.00
+6                Undeveloped      100.00
+7                Undeveloped      100.00
+8                Undeveloped      100.00
+
+[LOADINGS]
+;;Subcatchment   Pollutant        Buildup
+;;-------------- ---------------- ----------
+
+[BUILDUP]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     Coeff3     Per Unit
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              SAT        50         0          2          AREA
+Residential      Lead             NONE       0          0          0          AREA
+Undeveloped      TSS              SAT        100        0          3          AREA
+Undeveloped      Lead             NONE       0          0          0          AREA
+
+[WASHOFF]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     SweepRmvl  BmpRmvl
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              EXP        0.1        1          0          0
+Residential      Lead             EMC        0          0          0          0
+Undeveloped      TSS              EXP        0.1        0.7        0          0
+Undeveloped      Lead             EMC        0          0          0          0
+
+[TIMESERIES]
+;;Name           Date       Time       Value
+;;-------------- ---------- ---------- ----------
+;RAINFALL
+TS1                         0:00       0.0
+TS1                         1:00       0.25
+TS1                         2:00       0.5
+TS1                         3:00       0.8
+TS1                         4:00       0.4
+TS1                         5:00       0.1
+TS1                         6:00       0.0
+TS1                         27:00      0.0
+TS1                         28:00      0.4
+TS1                         29:00      0.2
+TS1                         30:00      0.0
+
+[REPORT]
+;;Reporting Options
+INPUT      NO
+CONTROLS   NO
+SUBCATCHMENTS ALL
+NODES ALL
+LINKS ALL
diff --git a/tests/solver/data/hotstart/Simulation1_use_hot_start.inp b/tests/solver/data/hotstart/Simulation1_use_hot_start.inp
new file mode 100644
index 000000000..d3aba0d0b
--- /dev/null
+++ b/tests/solver/data/hotstart/Simulation1_use_hot_start.inp
@@ -0,0 +1,215 @@
+[TITLE]
+;;Project Title/Notes
+Example 1
+
+[OPTIONS]
+;;Option             Value
+FLOW_UNITS           CFS
+INFILTRATION         HORTON
+FLOW_ROUTING         DYNWAVE
+LINK_OFFSETS         DEPTH
+MIN_SLOPE            0
+ALLOW_PONDING        NO
+SKIP_STEADY_STATE    NO
+
+START_DATE           01/01/1998
+START_TIME           00:00:00
+REPORT_START_DATE    01/01/1998
+REPORT_START_TIME    00:00:00
+END_DATE             01/02/1998
+END_TIME             12:00:00
+SWEEP_START          1/1
+SWEEP_END            12/31
+DRY_DAYS             5
+REPORT_STEP          01:00:00
+WET_STEP             00:15:00
+DRY_STEP             01:00:00
+ROUTING_STEP         0:00:01
+
+INERTIAL_DAMPING     PARTIAL
+NORMAL_FLOW_LIMITED  BOTH
+FORCE_MAIN_EQUATION  H-W
+VARIABLE_STEP        0.75
+LENGTHENING_STEP     0
+MIN_SURFAREA         0
+MAX_TRIALS           0
+HEAD_TOLERANCE       0
+SYS_FLOW_TOL         5
+LAT_FLOW_TOL         5
+;MINIMUM_STEP        0.5
+THREADS              1
+
+
+[EVAPORATION]
+;;Data Source    Parameters
+;;-------------- ----------------
+CONSTANT         0.0
+DRY_ONLY         NO
+
+[RAINGAGES]
+;;Name           Format    Interval SCF      Source
+;;-------------- --------- ------ ------ ----------
+RG1              INTENSITY 1:00     1.0      TIMESERIES TS1
+
+[SUBCATCHMENTS]
+;;Name           Rain Gage        Outlet           Area     %Imperv  Width    %Slope   CurbLen  SnowPack
+;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ----------------
+1                RG1              9                10       50       500      0.01     0
+2                RG1              10               10       50       500      0.01     0
+3                RG1              13               5        50       500      0.01     0
+4                RG1              22               5        50       500      0.01     0
+5                RG1              15               15       50       500      0.01     0
+6                RG1              23               12       10       500      0.01     0
+7                RG1              19               4        10       500      0.01     0
+8                RG1              18               10       10       500      0.01     0
+
+[SUBAREAS]
+;;Subcatchment   N-Imperv   N-Perv     S-Imperv   S-Perv     PctZero    RouteTo    PctRouted
+;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
+1                0.001      0.10       0.05       0.05       25         OUTLET
+2                0.001      0.10       0.05       0.05       25         OUTLET
+3                0.001      0.10       0.05       0.05       25         OUTLET
+4                0.001      0.10       0.05       0.05       25         OUTLET
+5                0.001      0.10       0.05       0.05       25         OUTLET
+6                0.001      0.10       0.05       0.05       25         OUTLET
+7                0.001      0.10       0.05       0.05       25         OUTLET
+8                0.001      0.10       0.05       0.05       25         OUTLET
+
+[INFILTRATION]
+;;Subcatchment   MaxRate    MinRate    Decay      DryTime    MaxInfil
+;;-------------- ---------- ---------- ---------- ---------- ----------
+1                0.35       0.25       4.14       0.50       0
+2                0.7        0.3        4.14       0.50       0
+3                0.7        0.3        4.14       0.50       0
+4                0.7        0.3        4.14       0.50       0
+5                0.7        0.3        4.14       0.50       0
+6                0.7        0.3        4.14       0.50       0
+7                0.7        0.3        4.14       0.50       0
+8                0.7        0.3        4.14       0.50       0
+
+[JUNCTIONS]
+;;Name           Elevation  MaxDepth   InitDepth  SurDepth   Aponded
+;;-------------- ---------- ---------- ---------- ---------- ----------
+9                1000       3          0          0          0
+10               995        3          0          0          0
+13               995        3          0          0          0
+14               990        3          0          0          0
+15               987        3          0          0          0
+16               985        3          0          0          0
+17               980        3          0          0          0
+19               1010       3          0          0          0
+20               1005       3          0          0          0
+21               990        3          0          0          0
+22               987        3          0          0          0
+23               990        3          0          0          0
+24               984        3          0          0          0
+
+[OUTFALLS]
+;;Name           Elevation  Type       Stage Data       Gated    Route To
+;;-------------- ---------- ---------- ---------------- -------- ----------------
+18               975        FREE                        NO
+
+[CONDUITS]
+;;Name           From Node        To Node          Length     Roughness  InOffset   OutOffset  InitFlow   MaxFlow
+;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------
+1                9                10               400        0.01       0          0          0          0
+4                19               20               200        0.01       0          0          0          0
+5                20               21               200        0.01       0          0          0          0
+6                10               21               400        0.01       0          1          0          0
+7                21               22               300        0.01       1          1          0          0
+8                22               16               300        0.01       0          0          0          0
+10               17               18               400        0.01       0          0          0          0
+11               13               14               400        0.01       0          0          0          0
+12               14               15               400        0.01       0          0          0          0
+13               15               16               400        0.01       0          0          0          0
+14               23               24               400        0.01       0          0          0          0
+15               16               24               100        0.01       0          0          0          0
+16               24               17               400        0.01       0          0          0          0
+
+[XSECTIONS]
+;;Link           Shape        Geom1            Geom2      Geom3      Geom4      Barrels    Culvert
+;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ----------
+1                CIRCULAR     1.5              0          0          0          1
+4                CIRCULAR     1                0          0          0          1
+5                CIRCULAR     1                0          0          0          1
+6                CIRCULAR     1                0          0          0          1
+7                CIRCULAR     2                0          0          0          1
+8                CIRCULAR     2                0          0          0          1
+10               CIRCULAR     2                0          0          0          1
+11               CIRCULAR     1.5              0          0          0          1
+12               CIRCULAR     1.5              0          0          0          1
+13               CIRCULAR     1.5              0          0          0          1
+14               CIRCULAR     1                0          0          0          1
+15               CIRCULAR     2                0          0          0          1
+16               CIRCULAR     2                0          0          0          1
+
+[POLLUTANTS]
+;;Name           Units  Crain      Cgw        Crdii      Kdecay     SnowOnly   Co-Pollutant     Co-Frac    Cdwf       Cinit
+;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ----------
+TSS              MG/L   0.0        0.0        0          0.0        NO         *                0.0        0          0
+Lead             UG/L   0.0        0.0        0          0.0        NO         TSS              0.2        0          0
+
+[LANDUSES]
+;;               Sweeping   Fraction   Last
+;;Name           Interval   Available  Swept
+;;-------------- ---------- ---------- ----------
+Residential
+Undeveloped
+
+[COVERAGES]
+;;Subcatchment   Land Use         Percent
+;;-------------- ---------------- ----------
+1                Residential      100.00
+2                Residential      50.00
+2                Undeveloped      50.00
+3                Residential      100.00
+4                Residential      50.00
+4                Undeveloped      50.00
+5                Residential      100.00
+6                Undeveloped      100.00
+7                Undeveloped      100.00
+8                Undeveloped      100.00
+
+[LOADINGS]
+;;Subcatchment   Pollutant        Buildup
+;;-------------- ---------------- ----------
+
+[BUILDUP]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     Coeff3     Per Unit
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              SAT        50         0          2          AREA
+Residential      Lead             NONE       0          0          0          AREA
+Undeveloped      TSS              SAT        100        0          3          AREA
+Undeveloped      Lead             NONE       0          0          0          AREA
+
+[WASHOFF]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     SweepRmvl  BmpRmvl
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              EXP        0.1        1          0          0
+Residential      Lead             EMC        0          0          0          0
+Undeveloped      TSS              EXP        0.1        0.7        0          0
+Undeveloped      Lead             EMC        0          0          0          0
+
+[TIMESERIES]
+;;Name           Date       Time       Value
+;;-------------- ---------- ---------- ----------
+;RAINFALL
+TS1                         0:00       0.0
+TS1                         1:00       0.25
+TS1                         2:00       0.5
+TS1                         3:00       0.8
+TS1                         4:00       0.4
+TS1                         5:00       0.1
+TS1                         6:00       0.0
+TS1                         27:00      0.0
+TS1                         28:00      0.4
+TS1                         29:00      0.2
+TS1                         30:00      0.0
+
+[REPORT]
+;;Reporting Options
+INPUT      NO
+CONTROLS   NO
+SUBCATCHMENTS ALL
+NODES ALL
+LINKS ALL
diff --git a/tests/solver/data/hotstart/Simulation2.inp b/tests/solver/data/hotstart/Simulation2.inp
new file mode 100644
index 000000000..f6af08f88
--- /dev/null
+++ b/tests/solver/data/hotstart/Simulation2.inp
@@ -0,0 +1,217 @@
+[TITLE]
+;;Project Title/Notes
+Example 1
+
+[OPTIONS]
+;;Option             Value
+FLOW_UNITS           CFS
+INFILTRATION         HORTON
+FLOW_ROUTING         DYNWAVE
+LINK_OFFSETS         DEPTH
+MIN_SLOPE            0
+ALLOW_PONDING        NO
+SKIP_STEADY_STATE    NO
+
+START_DATE           01/01/1998
+START_TIME           00:00:00
+REPORT_START_DATE    01/01/1998
+REPORT_START_TIME    00:00:00
+END_DATE             01/02/1998
+END_TIME             12:00:00
+SWEEP_START          1/1
+SWEEP_END            12/31
+DRY_DAYS             5
+REPORT_STEP          01:00:00
+WET_STEP             00:15:00
+DRY_STEP             01:00:00
+ROUTING_STEP         0:01:00
+
+INERTIAL_DAMPING     PARTIAL
+NORMAL_FLOW_LIMITED  BOTH
+FORCE_MAIN_EQUATION  H-W
+VARIABLE_STEP        0.75
+LENGTHENING_STEP     0
+MIN_SURFAREA         0
+MAX_TRIALS           0
+HEAD_TOLERANCE       0
+SYS_FLOW_TOL         5
+LAT_FLOW_TOL         5
+;MINIMUM_STEP        0.5
+THREADS              1
+
+[FILES]
+SAVE HOTSTART INFILE_Simulation2.hsf
+
+[EVAPORATION]
+;;Data Source    Parameters
+;;-------------- ----------------
+CONSTANT         0.0
+DRY_ONLY         NO
+
+[RAINGAGES]
+;;Name           Format    Interval SCF      Source
+;;-------------- --------- ------ ------ ----------
+RG1              INTENSITY 1:00     1.0      TIMESERIES TS1
+
+[SUBCATCHMENTS]
+;;Name           Rain Gage        Outlet           Area     %Imperv  Width    %Slope   CurbLen  SnowPack
+;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ----------------
+1                RG1              9                10       50       500      0.01     0
+2                RG1              10               10       50       500      0.01     0
+3                RG1              13               5        50       500      0.01     0
+4                RG1              22               5        50       500      0.01     0
+5                RG1              15               15       50       500      0.01     0
+6                RG1              23               12       10       500      0.01     0
+7                RG1              19               4        10       500      0.01     0
+8                RG1              18               10       10       500      0.01     0
+
+[SUBAREAS]
+;;Subcatchment   N-Imperv   N-Perv     S-Imperv   S-Perv     PctZero    RouteTo    PctRouted
+;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
+1                0.001      0.10       0.05       0.05       25         OUTLET
+2                0.001      0.10       0.05       0.05       25         OUTLET
+3                0.001      0.10       0.05       0.05       25         OUTLET
+4                0.001      0.10       0.05       0.05       25         OUTLET
+5                0.001      0.10       0.05       0.05       25         OUTLET
+6                0.001      0.10       0.05       0.05       25         OUTLET
+7                0.001      0.10       0.05       0.05       25         OUTLET
+8                0.001      0.10       0.05       0.05       25         OUTLET
+
+[INFILTRATION]
+;;Subcatchment   MaxRate    MinRate    Decay      DryTime    MaxInfil
+;;-------------- ---------- ---------- ---------- ---------- ----------
+1                0.35       0.25       4.14       0.50       0
+2                0.7        0.3        4.14       0.50       0
+3                0.7        0.3        4.14       0.50       0
+4                0.7        0.3        4.14       0.50       0
+5                0.7        0.3        4.14       0.50       0
+6                0.7        0.3        4.14       0.50       0
+7                0.7        0.3        4.14       0.50       0
+8                0.7        0.3        4.14       0.50       0
+
+[JUNCTIONS]
+;;Name           Elevation  MaxDepth   InitDepth  SurDepth   Aponded
+;;-------------- ---------- ---------- ---------- ---------- ----------
+9                1000       3          0          0          0
+10               995        3          0          0          0
+13               995        3          0          0          0
+14               990        3          0          0          0
+15               987        3          0          0          0
+16               985        3          0          0          0
+17               980        3          0          0          0
+19               1010       3          0          0          0
+20               1005       3          0          0          0
+21               990        3          0          0          0
+22               987        3          0          0          0
+23               990        3          0          0          0
+24               984        3          0          0          0
+
+[OUTFALLS]
+;;Name           Elevation  Type       Stage Data       Gated    Route To
+;;-------------- ---------- ---------- ---------------- -------- ----------------
+18               975        FREE                        NO
+
+[CONDUITS]
+;;Name           From Node        To Node          Length     Roughness  InOffset   OutOffset  InitFlow   MaxFlow
+;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------
+1                9                10               400        0.01       0          0          0          0
+4                19               20               200        0.01       0          0          0          0
+5                20               21               200        0.01       0          0          0          0
+6                10               21               400        0.01       0          1          0          0
+7                21               22               300        0.01       1          1          0          0
+8                22               16               300        0.01       0          0          0          0
+10               17               18               400        0.01       0          0          0          0
+11               13               14               400        0.01       0          0          0          0
+12               14               15               400        0.01       0          0          0          0
+13               15               16               400        0.01       0          0          0          0
+14               23               24               400        0.01       0          0          0          0
+15               16               24               100        0.01       0          0          0          0
+16               24               17               400        0.01       0          0          0          0
+
+[XSECTIONS]
+;;Link           Shape        Geom1            Geom2      Geom3      Geom4      Barrels    Culvert
+;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ----------
+1                CIRCULAR     1.5              0          0          0          1
+4                CIRCULAR     1                0          0          0          1
+5                CIRCULAR     1                0          0          0          1
+6                CIRCULAR     1                0          0          0          1
+7                CIRCULAR     2                0          0          0          1
+8                CIRCULAR     2                0          0          0          1
+10               CIRCULAR     2                0          0          0          1
+11               CIRCULAR     1.5              0          0          0          1
+12               CIRCULAR     1.5              0          0          0          1
+13               CIRCULAR     1.5              0          0          0          1
+14               CIRCULAR     1                0          0          0          1
+15               CIRCULAR     2                0          0          0          1
+16               CIRCULAR     2                0          0          0          1
+
+[POLLUTANTS]
+;;Name           Units  Crain      Cgw        Crdii      Kdecay     SnowOnly   Co-Pollutant     Co-Frac    Cdwf       Cinit
+;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ----------
+TSS              MG/L   0.0        0.0        0          0.0        NO         *                0.0        0          0
+Lead             UG/L   0.0        0.0        0          0.0        NO         TSS              0.2        0          0
+
+[LANDUSES]
+;;               Sweeping   Fraction   Last
+;;Name           Interval   Available  Swept
+;;-------------- ---------- ---------- ----------
+Residential
+Undeveloped
+
+[COVERAGES]
+;;Subcatchment   Land Use         Percent
+;;-------------- ---------------- ----------
+1                Residential      100.00
+2                Residential      50.00
+2                Undeveloped      50.00
+3                Residential      100.00
+4                Residential      50.00
+4                Undeveloped      50.00
+5                Residential      100.00
+6                Undeveloped      100.00
+7                Undeveloped      100.00
+8                Undeveloped      100.00
+
+[LOADINGS]
+;;Subcatchment   Pollutant        Buildup
+;;-------------- ---------------- ----------
+
+[BUILDUP]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     Coeff3     Per Unit
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              SAT        50         0          2          AREA
+Residential      Lead             NONE       0          0          0          AREA
+Undeveloped      TSS              SAT        100        0          3          AREA
+Undeveloped      Lead             NONE       0          0          0          AREA
+
+[WASHOFF]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     SweepRmvl  BmpRmvl
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              EXP        0.1        1          0          0
+Residential      Lead             EMC        0          0          0          0
+Undeveloped      TSS              EXP        0.1        0.7        0          0
+Undeveloped      Lead             EMC        0          0          0          0
+
+[TIMESERIES]
+;;Name           Date       Time       Value
+;;-------------- ---------- ---------- ----------
+;RAINFALL
+TS1                         0:00       0.0
+TS1                         1:00       0.25
+TS1                         2:00       0.5
+TS1                         3:00       0.8
+TS1                         4:00       0.4
+TS1                         5:00       0.1
+TS1                         6:00       0.0
+TS1                         27:00      0.0
+TS1                         28:00      0.4
+TS1                         29:00      0.2
+TS1                         30:00      0.0
+
+[REPORT]
+;;Reporting Options
+INPUT      NO
+CONTROLS   NO
+SUBCATCHMENTS ALL
+NODES ALL
+LINKS ALL
diff --git a/tests/solver/data/hotstart/Simulation3.inp b/tests/solver/data/hotstart/Simulation3.inp
new file mode 100644
index 000000000..f0521e5a0
--- /dev/null
+++ b/tests/solver/data/hotstart/Simulation3.inp
@@ -0,0 +1,217 @@
+[TITLE]
+;;Project Title/Notes
+Example 1
+
+[OPTIONS]
+;;Option             Value
+FLOW_UNITS           CFS
+INFILTRATION         HORTON
+FLOW_ROUTING         DYNWAVE
+LINK_OFFSETS         DEPTH
+MIN_SLOPE            0
+ALLOW_PONDING        NO
+SKIP_STEADY_STATE    NO
+
+START_DATE           01/01/1998
+START_TIME           00:00:00
+REPORT_START_DATE    01/01/1998
+REPORT_START_TIME    00:00:00
+END_DATE             01/02/1998
+END_TIME             12:00:00
+SWEEP_START          1/1
+SWEEP_END            12/31
+DRY_DAYS             5
+REPORT_STEP          01:00:00
+WET_STEP             00:15:00
+DRY_STEP             01:00:00
+ROUTING_STEP         0:00:01
+
+INERTIAL_DAMPING     PARTIAL
+NORMAL_FLOW_LIMITED  BOTH
+FORCE_MAIN_EQUATION  H-W
+VARIABLE_STEP        0.75
+LENGTHENING_STEP     0
+MIN_SURFAREA         0
+MAX_TRIALS           0
+HEAD_TOLERANCE       0
+SYS_FLOW_TOL         5
+LAT_FLOW_TOL         5
+;MINIMUM_STEP        0.5
+THREADS              1
+
+[FILES]
+USE HOTSTART swmm_api_test_during_Simulation1.hsf
+
+[EVAPORATION]
+;;Data Source    Parameters
+;;-------------- ----------------
+CONSTANT         0.0
+DRY_ONLY         NO
+
+[RAINGAGES]
+;;Name           Format    Interval SCF      Source
+;;-------------- --------- ------ ------ ----------
+RG1              INTENSITY 1:00     1.0      TIMESERIES TS1
+
+[SUBCATCHMENTS]
+;;Name           Rain Gage        Outlet           Area     %Imperv  Width    %Slope   CurbLen  SnowPack
+;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ----------------
+1                RG1              9                10       50       500      0.01     0
+2                RG1              10               10       50       500      0.01     0
+3                RG1              13               5        50       500      0.01     0
+4                RG1              22               5        50       500      0.01     0
+5                RG1              15               15       50       500      0.01     0
+6                RG1              23               12       10       500      0.01     0
+7                RG1              19               4        10       500      0.01     0
+8                RG1              18               10       10       500      0.01     0
+
+[SUBAREAS]
+;;Subcatchment   N-Imperv   N-Perv     S-Imperv   S-Perv     PctZero    RouteTo    PctRouted
+;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
+1                0.001      0.10       0.05       0.05       25         OUTLET
+2                0.001      0.10       0.05       0.05       25         OUTLET
+3                0.001      0.10       0.05       0.05       25         OUTLET
+4                0.001      0.10       0.05       0.05       25         OUTLET
+5                0.001      0.10       0.05       0.05       25         OUTLET
+6                0.001      0.10       0.05       0.05       25         OUTLET
+7                0.001      0.10       0.05       0.05       25         OUTLET
+8                0.001      0.10       0.05       0.05       25         OUTLET
+
+[INFILTRATION]
+;;Subcatchment   MaxRate    MinRate    Decay      DryTime    MaxInfil
+;;-------------- ---------- ---------- ---------- ---------- ----------
+1                0.35       0.25       4.14       0.50       0
+2                0.7        0.3        4.14       0.50       0
+3                0.7        0.3        4.14       0.50       0
+4                0.7        0.3        4.14       0.50       0
+5                0.7        0.3        4.14       0.50       0
+6                0.7        0.3        4.14       0.50       0
+7                0.7        0.3        4.14       0.50       0
+8                0.7        0.3        4.14       0.50       0
+
+[JUNCTIONS]
+;;Name           Elevation  MaxDepth   InitDepth  SurDepth   Aponded
+;;-------------- ---------- ---------- ---------- ---------- ----------
+9                1000       3          0          0          0
+10               995        3          0          0          0
+13               995        3          0          0          0
+14               990        3          0          0          0
+15               987        3          0          0          0
+16               985        3          0          0          0
+17               980        3          0          0          0
+19               1010       3          0          0          0
+20               1005       3          0          0          0
+21               990        3          0          0          0
+22               987        3          0          0          0
+23               990        3          0          0          0
+24               984        3          0          0          0
+
+[OUTFALLS]
+;;Name           Elevation  Type       Stage Data       Gated    Route To
+;;-------------- ---------- ---------- ---------------- -------- ----------------
+18               975        FREE                        NO
+
+[CONDUITS]
+;;Name           From Node        To Node          Length     Roughness  InOffset   OutOffset  InitFlow   MaxFlow
+;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ----------
+1                9                10               400        0.01       0          0          0          0
+4                19               20               200        0.01       0          0          0          0
+5                20               21               200        0.01       0          0          0          0
+6                10               21               400        0.01       0          1          0          0
+7                21               22               300        0.01       1          1          0          0
+8                22               16               300        0.01       0          0          0          0
+10               17               18               400        0.01       0          0          0          0
+11               13               14               400        0.01       0          0          0          0
+12               14               15               400        0.01       0          0          0          0
+13               15               16               400        0.01       0          0          0          0
+14               23               24               400        0.01       0          0          0          0
+15               16               24               100        0.01       0          0          0          0
+16               24               17               400        0.01       0          0          0          0
+
+[XSECTIONS]
+;;Link           Shape        Geom1            Geom2      Geom3      Geom4      Barrels    Culvert
+;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ----------
+1                CIRCULAR     1.5              0          0          0          1
+4                CIRCULAR     1                0          0          0          1
+5                CIRCULAR     1                0          0          0          1
+6                CIRCULAR     1                0          0          0          1
+7                CIRCULAR     2                0          0          0          1
+8                CIRCULAR     2                0          0          0          1
+10               CIRCULAR     2                0          0          0          1
+11               CIRCULAR     1.5              0          0          0          1
+12               CIRCULAR     1.5              0          0          0          1
+13               CIRCULAR     1.5              0          0          0          1
+14               CIRCULAR     1                0          0          0          1
+15               CIRCULAR     2                0          0          0          1
+16               CIRCULAR     2                0          0          0          1
+
+[POLLUTANTS]
+;;Name           Units  Crain      Cgw        Crdii      Kdecay     SnowOnly   Co-Pollutant     Co-Frac    Cdwf       Cinit
+;;-------------- ------ ---------- ---------- ---------- ---------- ---------- ---------------- ---------- ---------- ----------
+TSS              MG/L   0.0        0.0        0          0.0        NO         *                0.0        0          0
+Lead             UG/L   0.0        0.0        0          0.0        NO         TSS              0.2        0          0
+
+[LANDUSES]
+;;               Sweeping   Fraction   Last
+;;Name           Interval   Available  Swept
+;;-------------- ---------- ---------- ----------
+Residential
+Undeveloped
+
+[COVERAGES]
+;;Subcatchment   Land Use         Percent
+;;-------------- ---------------- ----------
+1                Residential      100.00
+2                Residential      50.00
+2                Undeveloped      50.00
+3                Residential      100.00
+4                Residential      50.00
+4                Undeveloped      50.00
+5                Residential      100.00
+6                Undeveloped      100.00
+7                Undeveloped      100.00
+8                Undeveloped      100.00
+
+[LOADINGS]
+;;Subcatchment   Pollutant        Buildup
+;;-------------- ---------------- ----------
+
+[BUILDUP]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     Coeff3     Per Unit
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              SAT        50         0          2          AREA
+Residential      Lead             NONE       0          0          0          AREA
+Undeveloped      TSS              SAT        100        0          3          AREA
+Undeveloped      Lead             NONE       0          0          0          AREA
+
+[WASHOFF]
+;;Land Use       Pollutant        Function   Coeff1     Coeff2     SweepRmvl  BmpRmvl
+;;-------------- ---------------- ---------- ---------- ---------- ---------- ----------
+Residential      TSS              EXP        0.1        1          0          0
+Residential      Lead             EMC        0          0          0          0
+Undeveloped      TSS              EXP        0.1        0.7        0          0
+Undeveloped      Lead             EMC        0          0          0          0
+
+[TIMESERIES]
+;;Name           Date       Time       Value
+;;-------------- ---------- ---------- ----------
+;RAINFALL
+TS1                         0:00       0.0
+TS1                         1:00       0.25
+TS1                         2:00       0.5
+TS1                         3:00       0.8
+TS1                         4:00       0.4
+TS1                         5:00       0.1
+TS1                         6:00       0.0
+TS1                         27:00      0.0
+TS1                         28:00      0.4
+TS1                         29:00      0.2
+TS1                         30:00      0.0
+
+[REPORT]
+;;Reporting Options
+INPUT      NO
+CONTROLS   NO
+SUBCATCHMENTS ALL
+NODES ALL
+LINKS ALL
diff --git a/tests/solver/data/hotstart/use_hot_start_test.hsf b/tests/solver/data/hotstart/use_hot_start_test.hsf
new file mode 100644
index 000000000..d57d38ed5
Binary files /dev/null and b/tests/solver/data/hotstart/use_hot_start_test.hsf differ
diff --git a/tests/solver/test_solver.hpp b/tests/solver/test_solver.hpp
index e45e477b4..6af24963c 100644
--- a/tests/solver/test_solver.hpp
+++ b/tests/solver/test_solver.hpp
@@ -44,6 +44,15 @@ struct FixtureOpenClose{
     }
 };
 
+struct FixtureBeforeStart_TKAPI{
+    FixtureBeforeStart_TKAPI() {
+        swmm_open(DATA_PATH_INP, DATA_PATH_RPT, DATA_PATH_OUT);
+    }
+    ~FixtureBeforeStart_TKAPI() {
+        swmm_close();
+    }
+};
+
 struct FixtureBeforeStep{
     FixtureBeforeStep() {
         swmm_open(DATA_PATH_INP, DATA_PATH_RPT, DATA_PATH_OUT);
diff --git a/tests/solver/test_toolkit.cpp b/tests/solver/test_toolkit.cpp
index 5033ca54d..b9d6db8a6 100644
--- a/tests/solver/test_toolkit.cpp
+++ b/tests/solver/test_toolkit.cpp
@@ -22,6 +22,7 @@
 #define ERR_TKAPI_SIM_NRUNNING 2002
 #define ERR_TKAPI_WRONG_TYPE 2003
 #define ERR_TKAPI_OBJECT_INDEX 2004
+#define ERR_TKAPI_SIM_RUNNING 2013
 
 using namespace std;
 
@@ -41,6 +42,10 @@ BOOST_AUTO_TEST_CASE(model_not_open) {
     //Project
     error = swmm_getObjectIndex(SM_NODE, id, &index);
     BOOST_CHECK_EQUAL(error, ERR_TKAPI_INPUTNOTOPEN);
+    error = swmm_hotstart(SM_HOTSTART_USE, id);
+    BOOST_CHECK_EQUAL(error, ERR_TKAPI_INPUTNOTOPEN);
+    error = swmm_hotstart(SM_HOTSTART_SAVE, id);
+    BOOST_CHECK_EQUAL(error, ERR_TKAPI_INPUTNOTOPEN);
 
     //Gage
     error = swmm_getGagePrecip(0, SM_TOTALPRECIP, &val);
@@ -108,10 +113,23 @@ BOOST_AUTO_TEST_SUITE_END()
 
 BOOST_AUTO_TEST_SUITE(test_toolkitapi_fixture)
 
+// Testing for Before Simulation Start Error
+BOOST_FIXTURE_TEST_CASE(sim_before_start, FixtureBeforeStart_TKAPI) {
+    int error;
+    char fakehsf[] = "FakeHSF.hsf";
+
+    error = swmm_hotstart(SM_HOTSTART_SAVE, fakehsf);
+    BOOST_CHECK_EQUAL(error, ERR_TKAPI_SIM_NRUNNING);
+}
+
 // Testing for Simulation Started Error
 BOOST_FIXTURE_TEST_CASE(sim_started_check, FixtureBeforeStep) {
     int error;
+    char fakehsf[] = "FakeHSF.hsf";
 
+    //Project
+    error = swmm_hotstart(SM_HOTSTART_USE, fakehsf);
+    BOOST_CHECK_EQUAL(error, ERR_TKAPI_SIM_RUNNING);
     //Subcatchment
     error = swmm_setSubcatchParam(0, SM_WIDTH, 1);
     BOOST_CHECK_EQUAL(error, ERR_TKAPI_SIM_NRUNNING);
diff --git a/tests/solver/test_toolkit_hotstart.cpp b/tests/solver/test_toolkit_hotstart.cpp
new file mode 100644
index 000000000..617c17269
--- /dev/null
+++ b/tests/solver/test_toolkit_hotstart.cpp
@@ -0,0 +1,237 @@
+/*
+ *   test_toolkitAPI_hotstart.cpp
+ *
+ *   Created: 07/29/2019
+ *   Updated: 06/11/2023
+ *   Author: Bryant E. McDonnell and Jeff Sadler
+ *
+ *   Unit testing mechanics for the hotstart API using Boost Test.
+ */
+
+#include <boost/test/unit_test.hpp>
+#include "test_solver.hpp"
+#include <fstream>
+#include <iterator>
+
+#define HOTSTART_SWMM_SAVE_NORMAL "hotstart/INFILE_Simulation1.hsf"
+#define HOTSTART_API_SAVE_DURING_SIM1 "hotstart/swmm_api_test_during_Simulation1.hsf"
+#define HOTSTART_API_SAVE_AFTER_SIM1 "hotstart/swmm_api_test_after_Simulation1.hsf"
+#define HOTSTART_SWMM_SAVE_SIM2 "hotstart/INFILE_Simulation2.hsf"
+
+#define ERR_NONE 0
+#define ERR_HOTSTART_FILE_OPEN 331
+
+BOOST_AUTO_TEST_SUITE(test_hotstart)
+
+// Testing Run Simulation and Generate Hot Start File using Model (as normal)
+// and save a hot start file using the API swmm_saveHotstart()
+//
+// TEST #1 - Making and Comparing Hot Start Files.
+// In this test 2 simulations will be performed.  One simulation will
+// create hot start files at various time and the second simulation will
+// end at the
+//
+// Start Simulation 1
+// This simulation will produce 3 hot start files:
+//  1. API hotstart File at 1056 Steps into the model ~= 1998-1-1 2:59:58
+//     (HSF Name: HOTSTART_API_SAVE_DURING_SIM1)
+//  2. API created hotstart file at the end of the run
+//     (HSF Name: HOTSTART_API_SAVE_AFTER_SIM1)
+//  3. Normal SWMM [FILES] Generated HSF
+//     (HSF Name: HOTSTART_SWMM_SAVE_NORMAL)
+//
+//  Start Simulation 2
+//  This simulation will end at 1056 Steps into a simulation.
+//     (HSF Name: HOTSTART_SWMM_SAVE_SIM2
+//
+//  The follwing comparisons will be made from these artifacts
+//  1.  HOTSTART_SWMM_SAVE_NORMAL Should == HOTSTART_API_SAVE
+//  2.  HOTSTART_API_SAVE_DURING_SIM1 Should == HOTSTART_SWMM_SAVE_SIM2
+
+BOOST_AUTO_TEST_CASE(save_hotstart_file){
+    int error, step_ind;
+    int index;
+    int number_of_nodes;
+    double elapsedTime = 0.0;
+    double set_val;
+
+    // Start Simulation 1
+    swmm_open((char *)"hotstart/Simulation1.inp",
+              (char *)"hotstart/Simulation1.rpt",
+              (char *)"hotstart/Simulation1.out");
+    swmm_start(1);
+    step_ind = 0;
+    do
+    {
+        error = swmm_step(&elapsedTime);
+        step_ind += 1;
+        if (step_ind == 1056)
+        {
+          error = swmm_hotstart(SM_HOTSTART_SAVE, (char *) HOTSTART_API_SAVE_DURING_SIM1);
+          BOOST_CHECK_EQUAL(ERR_NONE, error);
+        }
+    }while (elapsedTime != 0 && !error);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    // Save New Hotstart File at the End of the Simulation
+    error = swmm_hotstart(SM_HOTSTART_SAVE, (char *) HOTSTART_API_SAVE_AFTER_SIM1);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    swmm_end();
+    swmm_report();
+    swmm_close();
+
+    // Start Simulation 2
+    swmm_open((char *)"hotstart/Simulation2.inp",
+              (char *)"hotstart/Simulation2.rpt",
+              (char *)"hotstart/Simulation2.out");
+    swmm_start(0);
+    step_ind = 0;
+    elapsedTime = 0.0;
+    do
+    {
+        error = swmm_step(&elapsedTime);
+        step_ind += 1;
+    }while (step_ind < 1056 && !error);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    swmm_end();
+    swmm_close();
+
+    std::ifstream ifs1(HOTSTART_SWMM_SAVE_NORMAL);
+    std::ifstream ifs2(HOTSTART_API_SAVE_AFTER_SIM1);
+    std::istream_iterator<char> b1(ifs1), e1;
+    std::istream_iterator<char> b2(ifs2), e2;
+    //iterate over the two hotstart files and check all of them
+    BOOST_CHECK_EQUAL_COLLECTIONS(b1, e1, b2, e2);
+
+    // Diff the three hot start files that come from the model.
+    std::ifstream ifsbench_1998(HOTSTART_SWMM_SAVE_SIM2);
+    std::ifstream ifs1_1998(HOTSTART_API_SAVE_DURING_SIM1);
+    std::istream_iterator<char> bench_1998(ifsbench_1998), ebench_1998;
+    std::istream_iterator<char> b_1998(ifs1_1998), e_1998;
+    // iterate over hotstart files and check all of them
+    BOOST_CHECK_EQUAL_COLLECTIONS(bench_1998, ebench_1998, b_1998, e_1998);
+
+    // Testing USE the new generated hotstart file
+    // Start Simulation 3
+    swmm_open((char *)"hotstart/Simulation3.inp",
+              (char *)"hotstart/Simulation3.rpt",
+              (char *)"hotstart/Simulation3.out");
+    swmm_start(0);
+    error = swmm_step(&elapsedTime);
+    // Iterate over nodes before stepping
+    error = swmm_countObjects(SM_NODE, &number_of_nodes);
+    // Known Values
+    std::vector<double> hotstart_vals {0.0046,
+                                       3.0,
+                                       3.0,
+                                       0.0117,
+                                       0.0,
+                                       0.0,
+                                       0.0,
+                                       0.0105,
+                                       0.0,
+                                       0.1209,
+                                       0.0,
+                                       0.0,
+                                       0.0484,
+                                       0.0};
+
+    for (index=0; index<number_of_nodes; index++)
+    {
+        error = swmm_getNodeResult(index, SM_NODEDEPTH, &set_val);
+        BOOST_CHECK_SMALL(set_val - hotstart_vals[index], 0.5);
+    }
+
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    swmm_end();
+    swmm_close();
+}
+
+BOOST_AUTO_TEST_CASE(use_hotstart_bad_file){
+    // Testing USE a bad hotstart file
+    int error;
+    double elapsedTime = 0.0;
+    char fkid[] = "bad_hsf.hsf";
+
+    swmm_open((char *)"hotstart/Simulation1_use_hot_start.inp",
+              (char *)"hotstart/Simulation1_use_hot_start_fail.rpt",
+              (char *)"hotstart/Simulation1_use_hot_start_fail.out");
+    error = swmm_hotstart(SM_HOTSTART_USE, fkid);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    error = swmm_start(0);
+    BOOST_CHECK_EQUAL(ERR_HOTSTART_FILE_OPEN, error);
+    swmm_end();
+    swmm_close();
+}
+
+BOOST_AUTO_TEST_CASE(save_hotstart_file_fail){
+    int error, step_ind;
+    double elapsedTime = 0.0;
+
+    // Start Simulation 1
+    swmm_open((char *)"hotstart/Simulation1_use_hot_start.inp",
+              (char *)"hotstart/Simulation1_use_hot_start_fail1.rpt",
+              (char *)"hotstart/Simulation1_use_hot_start_fail1.out");
+    swmm_start(0);
+    step_ind = 0;
+    do
+    {
+        error = swmm_step(&elapsedTime);
+        step_ind += 1;
+        if (step_ind == 2)
+        {
+          error = swmm_hotstart(SM_HOTSTART_SAVE, (char *) "");
+          BOOST_CHECK_EQUAL(ERR_HOTSTART_FILE_OPEN, error);
+        }
+    }while (elapsedTime != 0 && !error);
+    BOOST_CHECK_EQUAL(ERR_HOTSTART_FILE_OPEN, error);
+    swmm_end();
+    swmm_close();
+    //   ERROR 331: cannot open hot start interface file .
+}
+
+BOOST_AUTO_TEST_CASE(use_hotstart_file){
+    // Testing USE the new generated hotstart file
+    int error;
+    int index;
+    int number_of_nodes;
+    double elapsedTime = 0.0;
+    double set_val;
+    char fkid[] = "hotstart/use_hot_start_test.hsf";
+
+    swmm_open((char *)"hotstart/Simulation1_use_hot_start.inp",
+              (char *)"hotstart/Simulation1_use_hot_start.rpt",
+              (char *)"hotstart/Simulation1_use_hot_start.out");
+    error = swmm_hotstart(SM_HOTSTART_USE, fkid);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    error = swmm_start(0);
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    error = swmm_step(&elapsedTime);
+    // Iterate over nodes before stepping
+    error = swmm_countObjects(SM_NODE, &number_of_nodes);
+    // Known Values
+    std::vector<double> hotstart_vals {0.0046,
+                                       3.0,
+                                       3.0,
+                                       0.0117,
+                                       0.0,
+                                       0.0,
+                                       0.0,
+                                       0.0105,
+                                       0.0,
+                                       0.1209,
+                                       0.0,
+                                       0.0,
+                                       0.0484,
+                                       0.0};
+
+    for (index=0; index<number_of_nodes; index++)
+    {
+        error = swmm_getNodeResult(index, SM_NODEDEPTH, &set_val);
+        BOOST_CHECK_SMALL(set_val - hotstart_vals[index], 0.5);
+    }
+    BOOST_CHECK_EQUAL(ERR_NONE, error);
+    swmm_end();
+    swmm_close();
+}
+
+BOOST_AUTO_TEST_SUITE_END()