From 536c91a3832bf0451d37aaeadf38c0ae64349c54 Mon Sep 17 00:00:00 2001 From: Daniel Schlaepfer Date: Tue, 7 May 2024 09:52:10 -0400 Subject: [PATCH] Fixes for implementing domain/spinup in rSOILWAT2 --- include/SW_Output_outarray.h | 2 -- src/SW_Control.c | 19 +++++++++++++++++-- src/SW_Output_get_functions.c | 9 --------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/SW_Output_outarray.h b/include/SW_Output_outarray.h index 39c63cef2..519b55d7c 100644 --- a/include/SW_Output_outarray.h +++ b/include/SW_Output_outarray.h @@ -93,8 +93,6 @@ extern "C" { #if defined(SWNETCDF) #undef iOUT #undef iOUT2 -#else - #undef iOUTnc #endif diff --git a/src/SW_Control.c b/src/SW_Control.c index dc23804bd..2970af360 100644 --- a/src/SW_Control.c +++ b/src/SW_Control.c @@ -657,6 +657,17 @@ void SW_CTL_run_spinup(SW_ALL* sw, LOG_INFO* LogInfo) { int debug = 0; #endif + #ifdef SWDEBUG + if (debug) { + swprintf( + "'SW_CTL_run_spinup': " + "mode = %d, duration = %d (# years), " + "scope = %d [# calendar years out of %d-%d]\n", + mode, duration, scope, sw->Model.startyr, finalyr + ); + } + #endif + switch ( mode ) { case 2: // initialize structured array @@ -705,7 +716,11 @@ void SW_CTL_run_spinup(SW_ALL* sw, LOG_INFO* LogInfo) { *cur_yr = years[ yrIdx ]; #ifdef SWDEBUG - if (debug) swprintf("\n'SW_CTL_run_spinup': simulate year = %d\n", *cur_yr); + if (debug) { + swprintf( + "'SW_CTL_run_spinup': simulate year = %d | %d\n", yrIdx + 1, *cur_yr + ); + } #endif SW_CTL_run_current_year(sw, NULL, LogInfo); @@ -914,7 +929,7 @@ void SW_CTL_run_sw(SW_ALL* sw_template, SW_DOMAIN* SW_Domain, unsigned long ncSu SW_CTL_main(&local_sw, SW_OutputPtrs, LogInfo); if(LogInfo->stopRun) { - return; // Exit function prematurely due to error + goto freeMem; // Free memory and exit function prematurely due to error } #if defined(SWNETCDF) diff --git a/src/SW_Output_get_functions.c b/src/SW_Output_get_functions.c index ea0f3849d..99e0ee22a 100644 --- a/src/SW_Output_get_functions.c +++ b/src/SW_Output_get_functions.c @@ -35,15 +35,6 @@ #include "include/SW_Output.h" -#ifdef RSOILWAT -#include -#include -#include -#endif - -#ifdef STEPWAT -#include -#endif #if defined(SWNETCDF) #include // defines NC_FILL_DOUBLE