Skip to content
Open
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
27 changes: 2 additions & 25 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
Copyright 2025 Raytheon Company

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

Licensed under: https://opensource.org/license/bsd-2-clause

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

All rights reserved. Based on Government sponsored work under contract GS-35F-204GA.

-----------------


“Software code created by U.S. Government employees is not subject to copyright
in the United States (17 U.S.C. §105). The United States/Department of Commerce
reserve all rights to seek and obtain copyright protection in countries other
than the United States for Software authored in its entirety by the Department
of Commerce. To this end, the Department of Commerce hereby grants to Recipient
a royalty-free, nonexclusive license to use, copy, and create derivative works
of the Software outside of the United States.”

Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -222,4 +199,4 @@ of the Software outside of the United States.”
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and

limitations under the License.
38 changes: 37 additions & 1 deletion src/bmi_cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
else {
model->soil_reservoir.is_aet_rootzone = FALSE;
model->soil_reservoir.n_soil_layers = 1;
model->soil_reservoir.soil_layer_depths_m = NULL;
model->soil_reservoir.delta_soil_layer_depth_m = NULL;
}

/*--------------------END OF ROOT ZONE ADJUSTED AET DEVELOPMENT -rlm ------------------------------*/
Expand Down Expand Up @@ -1367,6 +1369,11 @@ static int Initialize (Bmi *self, const char *file)
cfe_bmi_data_ptr->gw_reservoir.coeff_secondary = 0.0; // 0.0 means that secondary outlet is not applied
cfe_bmi_data_ptr->gw_reservoir.exponent_secondary = 1.0; // linear

// Not used in gw reservoir
cfe_bmi_data_ptr->gw_reservoir.smc_profile = NULL;
cfe_bmi_data_ptr->gw_reservoir.soil_layer_depths_m = NULL;
cfe_bmi_data_ptr->gw_reservoir.delta_soil_layer_depth_m = NULL;

// Initialize soil conceptual reservoirs
//LKC Remove alpha_fc
init_soil_reservoir(cfe_bmi_data_ptr);
Expand Down Expand Up @@ -1512,6 +1519,10 @@ static int Finalize (Bmi *self)
free(model->forcing_data_precip_kg_per_m2);
if( model->forcing_data_time != NULL )
free(model->forcing_data_time);
if( model->forcing_file != NULL ){
free(model->forcing_file);
}


if( model->giuh_ordinates != NULL )
free(model->giuh_ordinates);
Expand All @@ -1521,7 +1532,10 @@ static int Finalize (Bmi *self)
free(model->runoff_queue_m_per_timestep);
if( model->flux_Qout_m != NULL )
free(model->flux_Qout_m);


if( model->soil_reservoir.smc_profile != NULL )
free(model->soil_reservoir.smc_profile);

/* xinanjiang_dev: changing name to the more general "direct runoff"
if( model->flux_Schaake_output_runoff_m != NULL )
free(model->flux_Schaake_output_runoff_m);*/
Expand Down Expand Up @@ -2996,6 +3010,27 @@ cfe_state_struct *new_bmi_cfe(void)
data = (cfe_state_struct *) calloc(1, sizeof(cfe_state_struct));
data->time_step_size = 3600;
data->time_step_fraction = 1.0;
// NJF Ensure that all "optional" pointers are initialized to NULL
// Should probabably ensure that *all* pointers are initialized to NULL
// but that would require some more significant refactoring...
data->soil_reservoir.smc_profile = NULL;
data->soil_reservoir.soil_layer_depths_m = NULL;
data->soil_reservoir.delta_soil_layer_depth_m = NULL;
data->nash_surface_params.nash_storage = NULL;
data->forcing_file = NULL;

data->forcing_data_precip_kg_per_m2 = NULL;
data->forcing_data_time = NULL;
data->giuh_ordinates = NULL;
data->nash_storage_subsurface = NULL;
data->runoff_queue_m_per_timestep = NULL;
data->flux_Qout_m = NULL;
data->infiltration_excess_m = NULL;
data->flux_from_deep_gw_to_chan_m = NULL;
data->flux_direct_runoff_m = NULL;
data->flux_lat_m = NULL;
data->flux_nash_lateral_runoff_m = NULL;
data->flux_perc_m = NULL;

return data;
}
Expand Down Expand Up @@ -3169,6 +3204,7 @@ extern void init_soil_reservoir(cfe_state_struct* cfe_ptr)
}*/

extern void initialize_volume_trackers(cfe_state_struct* cfe_ptr) {
cfe_ptr->vol_struct.volstart = 0.0;
cfe_ptr->vol_struct.volin = 0;
cfe_ptr->vol_struct.vol_runoff = 0;
cfe_ptr->vol_struct.vol_infilt = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,6 @@ void Xinanjiang_partitioning_scheme(double water_input_depth_m, double field_cap
// double infiltration_depth_m amount of water partitioned as infiltration (soil water input) this time step [m]
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------

// local variables
double tension_water_m, free_water_m, max_tension_water_m, max_free_water_m, pervious_runoff_m,water_input_pervious_fraction_m;
double impervious_fraction, impervious_runoff_m;
Expand Down