-
Notifications
You must be signed in to change notification settings - Fork 415
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
Clean up and initial fix for exact restart - classic driver #481
Conversation
- Haven't done for lake - Separate carbon variables for veg_var - All floats are printed with 6 digits after decimal points (instead of 4)
- This change helps reduce (but not eliminate) restarting error when using ascii format in classic driver caused by precision error when writing state file
FULL_ENERGY=TRUE or FROZEN_SOIL=TRUE; otherwise, these variables will not be used, so don't need to be initialized: energy.Cs_node energy.kappa_node energy.moist energy.ice
…classic_driver Conflicts: vic/vic_run/include/vic_def.h
@@ -156,4 +156,4 @@ depend: .depend | |||
$(CC) $(CFLAGS) -M $(SRCS) > $@ | |||
|
|||
clean:: | |||
\rm -f .depend | |||
\rm -f .depend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the changes to the image driver Makefile? They are not part of this PR and I don't think we want to hard code the hydra paths in there like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this should not be committed...
@@ -146,7 +146,7 @@ write_model_state(all_vars_struct *all_vars, | |||
filep->statefile); | |||
} | |||
else { | |||
fprintf(filep->statefile, " %f ", soil_con->dz_node[nidx]); | |||
fprintf(filep->statefile, " %.16g ", soil_con->dz_node[nidx]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest defining a header variable to handle this repetitive format. E.g.
#define ASCII_STATE_FLOAT_FMT " %.16g "
Or something with a shorter but descriptive name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure will do.
} | ||
} | ||
|
||
/* Write foliage temperature */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to also increment the Nbytes count to include the size of Tfoliage, on line 103 (I can't seem to add an inline comment to that line of this diff, so I'm adding the note here). You can look at how the other variables are done and pattern Tfoliage after them. It should be a simple 1-liner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Will do. I haven't really tested for binary format - should we actually have a binary version of the sample data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean a binary version of the initial state file? (whether the state files are binary is independent of whether the forcings or outputs are binary)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I was thinking about a complete binary sample dataset, but specifically to this problem testing binary i/o for the state file is enough. Thanks!
@yixinmao I've finished looking it over. Other than my 2 comments, it looks good. This is of course an important improvement in making the restarts more accurate. It also helps clean up the code, which will help us maintain the code in the future. |
This PR is addressing part of issue #479 .
Changes related to exact restart:
energy.Tfoliage
to write and read in the state fileClean up:
Cleanly separated state and flux variables in vic_def.h and print_library_shared.c
In
initialize_*.c
, all state and flux variables are now initialized to zero (before some were missing); ininitalize_soil.c
, moved computation for derived variables intocompute_derived_state_vars
.In
compute_derived_state_vars
, only computed the four variables whenFROZEN_SOIL=TRUE
:energy.Cs_node
energy.kappa_node
energy.moist
energy.ice