From 9517ba2aa37deeeb156dbdf873a68519a2e4d969 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 11:55:22 -0400 Subject: [PATCH 01/11] Allowing a restart with surface height greater than crest height to pass --- src/glm_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/glm_init.c b/src/glm_init.c index 94b7d5f..35b5c47 100644 --- a/src/glm_init.c +++ b/src/glm_init.c @@ -1569,7 +1569,7 @@ void initialise_lake(int namlst) Lake[i].Salinity = the_sals[i]; } - if (the_heights[num_heights-1] > CrestHeight) { + if (the_heights[num_heights-1] > CrestHeight && restart_variables == NULL) { fprintf(stderr, " ERROR: maximum height is greater than crest level\n"); exit(1); } From 08e06a88b600a55d3517980cb1af0862f85b6409 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 12:33:46 -0400 Subject: [PATCH 02/11] adding error checks and messages --- src/glm_init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/glm_init.c b/src/glm_init.c index 35b5c47..2639275 100644 --- a/src/glm_init.c +++ b/src/glm_init.c @@ -1570,7 +1570,12 @@ void initialise_lake(int namlst) } if (the_heights[num_heights-1] > CrestHeight && restart_variables == NULL) { - fprintf(stderr, " ERROR: maximum height is greater than crest level\n"); + fprintf(stderr, " ERROR: initial first height of %f is greater than crest level of %f \n", the_heights[num_heights-1], CrestHeight); + exit(1); + } + + if (the_heights[num_heights-1] > MaxHeight) { + fprintf(stderr, " ERROR: initial first height of %f is greater than maximum height of %f \n", the_heights[num_heights-1], MaxHeight); exit(1); } num_depths = num_heights; From 7f37150250e3255d9dace892b5d51a9bd9866db5 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 20:38:33 -0400 Subject: [PATCH 03/11] add stoptime & startTOD to do_overland flows --- src/glm_flow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glm_flow.c b/src/glm_flow.c index 2e22b2c..afaa7af 100644 --- a/src/glm_flow.c +++ b/src/glm_flow.c @@ -482,7 +482,7 @@ AED_REAL do_outflows(int jday) * level. Add in stack volumes when calculating overflow. * * After overflow, delete stack volumes from the structure. * ******************************************************************************/ -AED_REAL do_overflow(int jday) +AED_REAL do_overflow(int jday, int startTOD, int stoptime) { AED_REAL VolSum = Lake[surfLayer].Vol1; AED_REAL DrawHeight = 0.; @@ -501,7 +501,7 @@ AED_REAL do_overflow(int jday) AED_REAL ovfl_Q, ovfl_dz; ovfl_dz = MAX( Lake[surfLayer].Height - CrestHeight, zero ); - ovfl_Q = 2./3. * crest_factor * pow(2*g,0.5) * crest_width * pow(ovfl_dz,1.5); + ovfl_Q = 2./3. * crest_factor * pow(2*g,0.5) * crest_width * pow(ovfl_dz,1.5) * (stoptime - startTOD); ovfl_Q = MIN( (VolSum - VolAtCrest) , ovfl_Q ); do_single_outflow(CrestHeight, ovfl_Q , NULL); From 54a0a2677e8c1d312c4ae04140e821cf85f6f7bb Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 20:53:40 -0400 Subject: [PATCH 04/11] removing error message in crest height --- src/glm_init.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/glm_init.c b/src/glm_init.c index 2639275..0d7b9c9 100644 --- a/src/glm_init.c +++ b/src/glm_init.c @@ -1569,11 +1569,6 @@ void initialise_lake(int namlst) Lake[i].Salinity = the_sals[i]; } - if (the_heights[num_heights-1] > CrestHeight && restart_variables == NULL) { - fprintf(stderr, " ERROR: initial first height of %f is greater than crest level of %f \n", the_heights[num_heights-1], CrestHeight); - exit(1); - } - if (the_heights[num_heights-1] > MaxHeight) { fprintf(stderr, " ERROR: initial first height of %f is greater than maximum height of %f \n", the_heights[num_heights-1], MaxHeight); exit(1); From 6f2d3d7488cb4bbf49fdee79d278e55a51d7baf3 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 21:23:17 -0400 Subject: [PATCH 05/11] adding day_fraction as a input into the overland and seepage --- src/glm_flow.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/glm_flow.c b/src/glm_flow.c index afaa7af..bbd2283 100644 --- a/src/glm_flow.c +++ b/src/glm_flow.c @@ -405,7 +405,7 @@ void do_single_outflow(AED_REAL HeightOfOutflow, AED_REAL flow, OutflowDataType * Loop through all outflows and process - return the difference between * * total volume before and after. * ******************************************************************************/ -AED_REAL do_outflows(int jday) +AED_REAL do_outflows(int jday, AED_REAL day_fraction) { int i; AED_REAL DrawHeight = -1; //# Height of withdraw [m from bottom] @@ -461,12 +461,12 @@ AED_REAL do_outflows(int jday) if (seepage) { if (seepage_rate>zero) { // Darcy's Law used, so input rate is hydraulic conductivity (m/day) x hydraulic head - SeepDraw = seepage_rate * Lake[surfLayer].Height * Lake[surfLayer].LayerArea * 0.95; + SeepDraw = seepage_rate * Lake[surfLayer].Height * Lake[surfLayer].LayerArea * 0.95 * day_fraction; } else { // Constant seepage assumed, so input rate is dh (m/day) // 0.95 added since the effective area of seeping is probably // a bit less than max area of water innundation??? - SeepDraw = -seepage_rate * Lake[surfLayer].LayerArea * 0.95; + SeepDraw = -seepage_rate * Lake[surfLayer].LayerArea * 0.95 * day_fraction; } do_single_outflow(0., SeepDraw, NULL); } @@ -482,7 +482,7 @@ AED_REAL do_outflows(int jday) * level. Add in stack volumes when calculating overflow. * * After overflow, delete stack volumes from the structure. * ******************************************************************************/ -AED_REAL do_overflow(int jday, int startTOD, int stoptime) +AED_REAL do_overflow(int jday, AED_REAL day_fraction) { AED_REAL VolSum = Lake[surfLayer].Vol1; AED_REAL DrawHeight = 0.; @@ -501,7 +501,7 @@ AED_REAL do_overflow(int jday, int startTOD, int stoptime) AED_REAL ovfl_Q, ovfl_dz; ovfl_dz = MAX( Lake[surfLayer].Height - CrestHeight, zero ); - ovfl_Q = 2./3. * crest_factor * pow(2*g,0.5) * crest_width * pow(ovfl_dz,1.5) * (stoptime - startTOD); + ovfl_Q = 2./3. * crest_factor * pow(2*g,0.5) * crest_width * pow(ovfl_dz,1.5) * day_fraction * iSecsPerDay; ovfl_Q = MIN( (VolSum - VolAtCrest) , ovfl_Q ); do_single_outflow(CrestHeight, ovfl_Q , NULL); From 756ebcde33cedee92478d3cf438ccf87662ac346 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 21:25:10 -0400 Subject: [PATCH 06/11] adding day_fraction --- src/glm_flow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glm_flow.h b/src/glm_flow.h index f538cc4..6506762 100644 --- a/src/glm_flow.h +++ b/src/glm_flow.h @@ -32,8 +32,8 @@ #include "glm.h" -AED_REAL do_outflows(int jday); -AED_REAL do_overflow(int jday); +AED_REAL do_outflows(int jday, AED_REAL day_fraction); +AED_REAL do_overflow(int jday, AED_REAL day_fraction); AED_REAL do_inflows(void); #endif From 05433ccb0d3fb40ce7762227fdcc78d6ea7480ff Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 21:30:44 -0400 Subject: [PATCH 07/11] add day_fraction to do_models --- src/glm_model.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/glm_model.c b/src/glm_model.c index 2cb005b..3c29ef9 100644 --- a/src/glm_model.c +++ b/src/glm_model.c @@ -274,6 +274,7 @@ void do_model(int jstart, int nsave) AED_REAL Elev[MaxInf]; int jday, ntot, stepnum, stoptime; int i, j; + AED_REAL day_fraction; /*------------------------------------------------------------------------*/ @@ -378,10 +379,11 @@ void do_model(int jstart, int nsave) SurfData.dailyInflow = do_inflows(); //# Do inflow for all streams //# Extract withdrawal from all offtakes - SurfData.dailyOutflow = do_outflows(jday); + day_fraction = (stoptime - startTOD) / iSecsPerDay; + SurfData.dailyOutflow = do_outflows(jday, day_fraction); //# Take care of any overflow - SurfData.dailyOverflow = do_overflow(jday); + SurfData.dailyOverflow = do_overflow(jday, day_fraction); //# Enforce layer limits check_layer_thickness(); @@ -447,6 +449,7 @@ void do_model_non_avg(int jstart, int nsave) AED_REAL SWold, SWnew, DailyKw, DailyEvap; int jday, ntot, stepnum, stoptime; int i, j; + AED_REAL day_fraction; /*************************************************************************** *CAB Note: these WQ arrays should be sized to Num_WQ_Vars not MaxVars, * @@ -534,11 +537,12 @@ void do_model_non_avg(int jstart, int nsave) SurfData.dailyInflow = do_inflows(); if (Lake[surfLayer].Vol1 > zero) { - //# Extract withdrawal from all offtakes - SurfData.dailyOutflow = do_outflows(jday); + //# Extract withdrawal from all offtakes + day_fraction = (stoptime - startTOD) / iSecsPerDay; + SurfData.dailyOutflow = do_outflows(jday, day_fraction); - //# Take care of any overflow - SurfData.dailyOverflow = do_overflow(jday); + //# Take care of any overflow + SurfData.dailyOverflow = do_overflow(jday, day_fraction); } //# Enforce layer limits @@ -599,7 +603,8 @@ void do_model_coupled(int step_start, int step_end, AED_REAL WQNew[MaxInf * MaxVars]; int jday, ntot, stepnum, stoptime, cDays; int i, j; - + AED_REAL day_fraction; + /*------------------------------------------------------------------------*/ memset(WQNew, 0, sizeof(AED_REAL)*MaxInf*MaxVars); @@ -675,11 +680,12 @@ void do_model_coupled(int step_start, int step_end, SurfData.dailyInflow = do_inflows(); if (Lake[surfLayer].Vol1 > zero) { - //# Extract withdrawal from all offtakes - SurfData.dailyOutflow = do_outflows(jday); + //# Extract withdrawal from all offtakes + day_fraction = (stoptime - startTOD) / iSecsPerDay; + SurfData.dailyOutflow = do_outflows(jday, day_fraction); - //# Take care of any overflow - SurfData.dailyOverflow = do_overflow(jday); + //# Take care of any overflow + SurfData.dailyOverflow = do_overflow(jday, day_fraction); } //# Enforce layer limits From 0f9fa3c9fb80e2f0ebd8ceb3c7c094c322887bb8 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 28 Aug 2024 21:40:49 -0400 Subject: [PATCH 08/11] cleaning up calculation of day_fraction --- src/glm_model.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/glm_model.c b/src/glm_model.c index 3c29ef9..dcf370e 100644 --- a/src/glm_model.c +++ b/src/glm_model.c @@ -307,6 +307,7 @@ void do_model(int jstart, int nsave) //# If it is the last day, adjust the stop time for the day if necessary if (ntot == nDates) stoptime = stopTOD; if (stoptime == 0) break; + day_fraction = (stoptime - startTOD) / iSecsPerDay; //# Initialise daily values for volume & heat balance reporting (lake.csv) SurfData.dailyRain = 0.; SurfData.dailyEvap = 0.; @@ -327,7 +328,7 @@ void do_model(int jstart, int nsave) //# (stoptime - startTOD) allow for partial dates at the the beginning and end of //# simulation for (i = 0; i < NumInf; i++) { - Inflows[i].FlowRate = (FlowOld[i] + FlowNew[i]) / 2.0 * (stoptime - startTOD) ; + Inflows[i].FlowRate = (FlowOld[i] + FlowNew[i]) / 2.0 * day_fraction * iSecsPerDay; Inflows[i].TemInf = (TempOld[i] + TempNew[i]) / 2.0; Inflows[i].SalInf = (SaltOld[i] + SaltNew[i]) / 2.0; Inflows[i].SubmElev = Elev[i]; @@ -341,7 +342,7 @@ void do_model(int jstart, int nsave) read_daily_outflow(jday, NumOut, DrawNew); //# To get daily outflow (i.e. m3/day) times by the seconds in the current day for (i = 0; i < NumOut; i++) - Outflows[i].Draw = (DrawOld[i] + DrawNew[i]) / 2.0 * (stoptime - startTOD) ; + Outflows[i].Draw = (DrawOld[i] + DrawNew[i]) / 2.0 * day_fraction * iSecsPerDay ; read_daily_withdraw_temp(jday, &WithdrTempNew); WithdrawalTemp = (WithdrTempOld + WithdrTempNew) / 2.0; @@ -379,7 +380,6 @@ void do_model(int jstart, int nsave) SurfData.dailyInflow = do_inflows(); //# Do inflow for all streams //# Extract withdrawal from all offtakes - day_fraction = (stoptime - startTOD) / iSecsPerDay; SurfData.dailyOutflow = do_outflows(jday, day_fraction); //# Take care of any overflow @@ -480,6 +480,7 @@ void do_model_non_avg(int jstart, int nsave) //# If it is the last day, adjust the stop time for the day if necessary if (ntot == nDates) stoptime = stopTOD; if (stoptime == 0) break; + day_fraction = (stoptime - startTOD) / iSecsPerDay; //# Initialise daily values for volume & heat balance reporting (lake.csv) SurfData.dailyRain = 0.; SurfData.dailyEvap = 0.; @@ -498,7 +499,7 @@ void do_model_non_avg(int jstart, int nsave) //# To get daily inflow (i.e. m3/day) times by SecsPerDay for (i = 0; i < NumInf; i++) { - Inflows[i].FlowRate = FlowNew[i] * (stoptime - startTOD) ; + Inflows[i].FlowRate = FlowNew[i] * day_fraction * iSecsPerDay; Inflows[i].TemInf = TempNew[i]; Inflows[i].SalInf = SaltNew[i]; Inflows[i].SubmElev = Elev[i]; @@ -514,7 +515,7 @@ void do_model_non_avg(int jstart, int nsave) //# (stoptime - startTOD) allow for partial dates at the the beginning and end of //# simulation for (i = 0; i < NumOut; i++) - Outflows[i].Draw = DrawNew[i] * (stoptime - startTOD) ; + Outflows[i].Draw = DrawNew[i] * day_fraction * iSecsPerDay ; read_daily_withdraw_temp(jday, &WithdrTempNew); WithdrawalTemp = WithdrTempNew; @@ -538,7 +539,6 @@ void do_model_non_avg(int jstart, int nsave) if (Lake[surfLayer].Vol1 > zero) { //# Extract withdrawal from all offtakes - day_fraction = (stoptime - startTOD) / iSecsPerDay; SurfData.dailyOutflow = do_outflows(jday, day_fraction); //# Take care of any overflow @@ -628,6 +628,7 @@ void do_model_coupled(int step_start, int step_end, //# If it is the last day, adjust the stop time for the day if necessary if (ntot == nDates) stoptime = stopTOD; if (stoptime == 0) break; + day_fraction = (stoptime - startTOD) / iSecsPerDay; //# Initialise daily values for volume & heat balance reporting (lake.csv) SurfData.dailyRain = 0.; SurfData.dailyEvap = 0.; @@ -645,7 +646,7 @@ void do_model_coupled(int step_start, int step_end, //# (stoptime - startTOD) allow for partial dates at the the beginning and end of //# simulation for (i = 0; i < NumInf; i++) { - Inflows[i].FlowRate = FlowNew[i] * (stoptime - startTOD); + Inflows[i].FlowRate = FlowNew[i] * day_fraction * iSecsPerDay; // Inflows[i].TemInf = TempNew[i]; // Inflows[i].SalInf = SaltNew[i]; for (j = 0; j < Num_WQ_Vars; j++) { @@ -657,7 +658,7 @@ void do_model_coupled(int step_start, int step_end, // read_daily_outflow(jday, NumOut, DrawNew); //# To get daily outflow (i.e. m3/day) times by SecsPerDay for (i = 0; i < NumOut; i++) - Outflows[i].Draw = DrawNew[i] * (stoptime - startTOD); + Outflows[i].Draw = DrawNew[i] * day_fraction * iSecsPerDay; // read_daily_withdraw_temp(jday, &WithdrTempNew); // WithdrawalTemp = WithdrTempNew; @@ -681,7 +682,6 @@ void do_model_coupled(int step_start, int step_end, if (Lake[surfLayer].Vol1 > zero) { //# Extract withdrawal from all offtakes - day_fraction = (stoptime - startTOD) / iSecsPerDay; SurfData.dailyOutflow = do_outflows(jday, day_fraction); //# Take care of any overflow From 6845b7f776e28db3c8cce49d5b2b4684c0e8b1e4 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Wed, 25 Sep 2024 15:48:51 -0400 Subject: [PATCH 09/11] fixing issue with writing output when not starting on 00 hr --- src/glm_model.c | 56 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/src/glm_model.c b/src/glm_model.c index dcf370e..ca7b230 100644 --- a/src/glm_model.c +++ b/src/glm_model.c @@ -397,14 +397,20 @@ void do_model(int jstart, int nsave) today = jday; #endif write_output(jday, SecsPerDay, nsave, stepnum); + write_diags(jday, calculate_lake_number()); + write_balance(jday); write_step += nsave; - if ( write_step > last_step ) write_step = last_step; #if PLOTS plotstep++; today = -1; #endif } + + if(ntot == nDates & stepnum < nsave){ + fprintf(stderr, " ERROR: NO netcdf output generated because nsave is less total number of time steps in simuluation\n"); + } + /********************************************************************** * End of daily calculations, Prepare for next day and return. * @@ -430,9 +436,6 @@ void do_model(int jstart, int nsave) printf(" Running day %8d, %4.2f%% of days complete%c", jday, ntot*100./nDates, EOLN); fflush(stdout); } - - write_diags(jday, calculate_lake_number()); - write_balance(jday); } //# do while (ntot < nDates) if (quiet < 2) { printf("\n"); fflush(stdout); } /*----------########### End of main daily loop ################-----------*/ @@ -556,13 +559,20 @@ void do_model_non_avg(int jstart, int nsave) today = jday; #endif write_output(jday, SecsPerDay, nsave, stepnum); + write_diags(jday, calculate_lake_number()); + write_balance(jday); write_step += nsave; - if ( write_step > last_step ) write_step = last_step; + + //if ( write_step > last_step ) write_step = last_step; #if PLOTS plotstep++; today = -1; #endif } + + if(ntot == nDates & stepnum < nsave){ + fprintf(stderr, " ERROR: NO netcdf output generated because nsave is less total number of time steps in simuluation\n"); + } /********************************************************************** * End of daily calculations, Prepare for next day and return. * @@ -578,9 +588,6 @@ void do_model_non_avg(int jstart, int nsave) printf(" Running day %8d, %4.2f%% of days complete%c", jday, ntot*100./nDates, EOLN); fflush(stdout); } - - write_diags(jday, calculate_lake_number()); - write_balance(jday); } //# do while (ntot < nDates) if (quiet < 2) { printf("\n"); fflush(stdout); } /*----------########### End of main daily loop ################-----------*/ @@ -699,31 +706,39 @@ void do_model_coupled(int step_start, int step_end, today = jday; #endif write_output(jday, SecsPerDay, nsave, stepnum); + write_diags(jday, calculate_lake_number()); + write_balance(jday); write_step += nsave; - if ( write_step > last_step ) write_step = last_step; + + //if ( write_step > last_step ) write_step = last_step; #if PLOTS plotstep++; today = -1; + + #endif + } + + if(ntot == nDates & stepnum < nsave){ + fprintf(stderr, " ERROR: NO netcdf output generated because nsave is less total number of time steps in simuluation\n"); } /********************************************************************** * End of daily calculations, Prepare for next day and return. * **********************************************************************/ SWold = SWnew; - + #ifdef XPLOTS if ( xdisp ) flush_all_plots(); else #endif - if (quiet < 2) { + if (quiet < 2) { printf(" Running day %8d, %4.2f%% of days complete%c", jday, ntot*100./nDates, EOLN); fflush(stdout); } - write_diags(jday, calculate_lake_number()); - write_balance(jday); + } //# do while (ntot < nDates) if (quiet < 2) { printf("\n"); fflush(stdout); } /*----------########### End of main daily loop ################-----------*/ @@ -753,12 +768,14 @@ int do_subdaily_loop(int stepnum, int jday, int stoptime, int nsave, AED_REAL SW **************************************************************************/ iclock = startTOD; last_step = stepnum + ((stoptime - iclock) / noSecs); + if(stepnum == 0){ write_step = stepnum + nsave; - if ( iclock != 0 ) { - int t = mod(((stoptime - iclock) / noSecs), nsave); - if ( t != 0 ) write_step = stepnum + t; } - if ( write_step > last_step ) write_step = last_step; + //if ( iclock != 0 ) { + // int t = mod(((stoptime - iclock) / noSecs), nsave); + // if ( t != 0 ) write_step = stepnum + t; + //} + // printf("last step %d write_step %d\n", last_step, write_step); startTOD = 0; /* from now on start at the beginning of the day */ @@ -828,14 +845,13 @@ int do_subdaily_loop(int stepnum, int jday, int stoptime, int nsave, AED_REAL SW //# then do not output in the subdaily. Output writing is moved to the //# daily loop so it occurs after the inflow and output calculations. - if ( stepnum == write_step && (iclock + noSecs) != SecsPerDay) { + if ( stepnum == write_step && (iclock + noSecs) != SecsPerDay && stepnum != last_step) { #if PLOTS today = jday; #endif write_output(jday, iclock, nsave, stepnum); write_step += nsave; - if ( write_step > last_step ) write_step = last_step; #if PLOTS //if (++n_steps_done > END_STEPS) { int i; for (i = 0; i < NumLayers; i++) show_l_line(2, Lake[i].Height); flush_all_plots(); } plotstep++; @@ -852,6 +868,8 @@ int do_subdaily_loop(int stepnum, int jday, int stoptime, int nsave, AED_REAL SW iclock += noSecs; yearday += part_day_per_step; } //# do while (iclock < iSecsPerDay) + + //if ( write_step > last_step ) write_step = last_step; /************************************************************************** * End of sub-daily loop * **************************************************************************/ From 8e2e5114e60e07d985ebb36106d71b3eefd7a788 Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Sat, 28 Sep 2024 15:49:33 -0400 Subject: [PATCH 10/11] Update glm_model.c --- src/glm_model.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/glm_model.c b/src/glm_model.c index ca7b230..94b168a 100644 --- a/src/glm_model.c +++ b/src/glm_model.c @@ -296,6 +296,8 @@ void do_model(int jstart, int nsave) MetData = MetOld; SWold = MetOld.ShortWave; + write_output(jday, SecsPerDay, nsave, stepnum); + jday = jstart - 1; /************************************************************************** * Loop over all days * @@ -472,6 +474,8 @@ void do_model_non_avg(int jstart, int nsave) stoptime = iSecsPerDay; SWold = 0.; + write_output(jday, SecsPerDay, nsave, stepnum); + jday = jstart - 1; /************************************************************************** * Loop over all days * @@ -623,6 +627,8 @@ void do_model_coupled(int step_start, int step_end, stoptime = iSecsPerDay; SWold = 0.; + write_output(jday, SecsPerDay, nsave, stepnum); + cDays = step_end - step_start + 1; jday = step_start - 1; /************************************************************************** From 779d619c5adeaafc52fb463d1d5b5f5c54cc6e3c Mon Sep 17 00:00:00 2001 From: Quinn Thomas Date: Sat, 28 Sep 2024 15:57:00 -0400 Subject: [PATCH 11/11] moving where write_output first occurs --- src/glm_model.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/glm_model.c b/src/glm_model.c index 94b168a..eb82811 100644 --- a/src/glm_model.c +++ b/src/glm_model.c @@ -295,10 +295,10 @@ void do_model(int jstart, int nsave) read_daily_met(jstart, &MetOld); MetData = MetOld; SWold = MetOld.ShortWave; + + jday = jstart - 1; write_output(jday, SecsPerDay, nsave, stepnum); - - jday = jstart - 1; /************************************************************************** * Loop over all days * **************************************************************************/ @@ -473,10 +473,10 @@ void do_model_non_avg(int jstart, int nsave) stepnum = 0; stoptime = iSecsPerDay; SWold = 0.; + + jday = jstart - 1; write_output(jday, SecsPerDay, nsave, stepnum); - - jday = jstart - 1; /************************************************************************** * Loop over all days * **************************************************************************/ @@ -627,10 +627,12 @@ void do_model_coupled(int step_start, int step_end, stoptime = iSecsPerDay; SWold = 0.; - write_output(jday, SecsPerDay, nsave, stepnum); + cDays = step_end - step_start + 1; jday = step_start - 1; + + write_output(jday, SecsPerDay, nsave, stepnum); /************************************************************************** * Loop over all days * **************************************************************************/