Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stepwat soilwat output new may #44

Merged
merged 115 commits into from
Apr 6, 2018
Merged

Conversation

BrendenBe1
Copy link
Contributor

Check SWA_master and dSWAbulk values to verify that available soil water is being calculated correctly in SWA_master. Also check in dSWAbulk that soilwater for each vegetation type at all critical values is correct.

ashishtiwari2006 and others added 30 commits May 10, 2017 17:23
…and changed stat_Output_AllSoilwatVariables to store PPT in month formate
@BrendenBe1
Copy link
Contributor Author

When using USE_TIMESTEP=0 and specifying DY and YR output for TEMP and PRECIP, and YR output for all other variables,the sw2_daily.csv and sw2_daily iteration files are blank. This occurs with either -o option or -o and -i option.

This functionality does not work with STEPWAT. We can not have multiple time periods for a single value when USE_TIMESTEP = 0

@kpalmqui
Copy link
Member

kpalmqui commented Feb 1, 2018

Yes, I know that USE_TIMESTEP = 0 was not previously functional in STEPWAT2. But Daniel's previous comment on Issue #120 in soil_save_output (copied below), indicated the potential for this functionality exists. @BrendenBe1 @dschlaep

We should discuss how long this would take/how easy it would be.

Daniel's comment:
With PR #126, I fixed bugs in the SOILWAT2-standalone output code and eliminated inefficiencies (e.g., the same output values were calculated multiple times, but only outputted once).

From documentation of SW_OUT_read:

We have two options to specify time steps:

  • The same time step(s) for every output: Add a line with the tag TIMESTEP,
    e.g., TIMESTEP dy mo yr will generate daily, monthly, and yearly output for
    every output variable. If there is a line with this tag, then this will
    override information provided in the column PERIOD.
  • A different time step for each output: Specify the time step in the column
    PERIOD for each output variable. Note: only one time step per output variable
    can be specified.
    */

However, either way, the global variable

OutPeriod timeSteps[SW_OUTNKEYS][SW_OUTNPERIODS];// array to keep track of the periods that will be used for each output
is holding information in the first

int used_OUTNPERIODS; // number of different time steps/periods that are used/requested
columns about the output for each output key separately. There is no restriction for STEPWAT2 to not set-up different and separate output periods for different output keys, e.g., to request daily and monthly for the eSW_Transp key and yearly for the eSW_Precip key:

used_OUTNPERIODS = 2;
timeSteps[eSW_Transp][0] = eSW_Day;
timeSteps[eSW_Transp][1] = eSW_Month;
timeSteps[eSW_Precip][0] = eSW_Year;
timeSteps[eSW_Precip][1] = SW_MISSING;
I added the ability to set timeSteps to SW_MISSING for rSOILWAT2 for which it works; I have not tested it for SOILWAT2-standalone and it may need a bit more careful coding in (some of) the switch (timeSteps[k][i]).

…values for veg types. Moved variables around to put them in locations that make the most logical sense.
@BrendenBe1
Copy link
Contributor Author

I was looking into making this work but I don't see an easy or quick way to implement it. Based off of Daniels comment it sounds like it is possible in rSOILWAT but the way that it is currently working in SOILWAT I don't see how to implement this without a big change to reading the input files.

@kpalmqui
Copy link
Member

kpalmqui commented Feb 2, 2018

@dschlaep - do you see an easy solution to implementing multiple (but potentially different) time periods for output variables in SOILWAT2? If this can't be implemented easily for now, I suppose we can add this as a long term goal.

@BrendenBe1 Thanks for your ongoing changes - I will plan on reviewing again once you address Daniel's comments, which I see you are actively working on.

@dschlaep
Copy link
Member

dschlaep commented Feb 4, 2018

@kpalmqui Re: easy solution to implementing multiple (but potentially different) time periods for output variables in SOILWAT2
--> I don't see an easy solution at the SOILWAT2 side (we would need to create a new input (file) with a matrix turning on/off each output x timestep combination) and I don't see the need for that.
--> I believed that was a request to be implemented as code in STEPWAT2?

  • Currently, STEPWAT2's function SXW_Init calls the function _write_sw_outin to overwrite SOILWAT2's outsetup.in input file which is then read in in the next lines of code of SXW_Init by calling the SOILWAT2 function SW_CTL_obtain_inputs.
  • Instead, you could get rid of _write_sw_outin and replace it with a new function new_foo that is called after SW_CTL_obtain_inputs -- the new function new_foo would externalize and manipulate the content of the global SOILWAT2 variables SW_Output and timeSteps (which are defined in SW_Output.c. Thereby, multiple (but potentially different) time periods could easily be implemented.

@kpalmqui
Copy link
Member

kpalmqui commented Feb 6, 2018

Note that _write_sw_outin has been removed from stepwat_soilwat_output_new_may. Perhaps it is clear to Brenden, but let's talk about and may sure he understands what you mean by "would externalize and manipulate the content of the global SOILWAT2 variables SW_Output and timeSteps (which are defined in SW_Output.c. ".

BrendenBe1 and others added 15 commits February 6, 2018 12:40
This function (_res_part_extra) is already called above on lines
123-124 and were accidentally duplicated here. We don’t need to call it
twice.
…OILWAT issue #157 SWA no longer requires SWCBULK to run SOILWAT or STEPWAT and is not broken if SWCBULK is set to another sumtype other than AVG.
…culations. The Values need testing under the STEPWAT flag and a few variables in the structure need altering still.
…ded due to moving the SWA calculations to SOILWAT.
Updated comment on what SWA represents
…0. Also added call to closeFile function and fixed some compiler warnings.
@BrendenBe1 BrendenBe1 merged commit b557678 into master Apr 6, 2018
@BrendenBe1 BrendenBe1 deleted the stepwat_soilwat_output_new_may branch April 12, 2018 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants