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

Clean up and initial fix for exact restart - classic driver #481

Merged
merged 27 commits into from
May 2, 2016

Conversation

yixinmao
Copy link
Contributor

@yixinmao yixinmao commented Apr 24, 2016

This PR is addressing part of issue #479 .

Changes related to exact restart:

  • Raised ascii state variable outputs to %.16g
  • Added the prognostic state var energy.Tfoliage to write and read in the state file

Clean 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); in initalize_soil.c, moved computation for derived variables into compute_derived_state_vars.

  • In compute_derived_state_vars, only computed the four variables when FROZEN_SOIL=TRUE:

    energy.Cs_node
    energy.kappa_node
    energy.moist
    energy.ice

ymao added 19 commits April 6, 2016 16:19
    - 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
Copy link
Member

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.

Copy link
Contributor Author

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...

@jhamman
Copy link
Member

jhamman commented Apr 25, 2016

@yixinmao - I'm made a few minor comments. You have failing tests on all drivers and there are a bunch of compiler warnings to address. Once you've cleaned thigs up here, ping @tbohn for the next review.

@@ -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]);
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will do.

@yixinmao
Copy link
Contributor Author

yixinmao commented Apr 25, 2016

@jhamman I have addressed all your comments (thank you!). @tbohn do you want to take a look at the current version again?

}
}

/* Write foliage temperature */
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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)

Copy link
Contributor Author

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!

@tbohn
Copy link
Contributor

tbohn commented Apr 27, 2016

@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.

@jhamman jhamman merged commit 1a9888b into UW-Hydro:develop May 2, 2016
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.

3 participants