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

Adds CN to classic driver. Still includes verbose option. #174

Closed
wants to merge 1 commit into from

Conversation

jhamman
Copy link
Member

@jhamman jhamman commented Dec 8, 2014

Initial pull request for adding CN to VIC.

What are our (@bartnijssen and @mabrunke) thoughts on:

  • Basic implementation,
  • Portability,
  • Documentation,
  • Location of CN/src code, and
  • Merging recent cleanup changes to the feature/CN branch.

@bartnijssen
Copy link
Member

Do we want to pull this directly into develop? I'd rather have a separate branch off develop into which we can merge this, so that develop remains a clean path to VIC 5

@mabrunke
Copy link

Bart:

I think a separate branch would be good for now at least until VICCN is a
little further advanced.

--Michael

Do we want to pull this directly into develop? I'd rather have a separate
branch off develop into which we can merge this, so that develop remains a
clean path to VIC 5


Reply to this email directly or view it on GitHub:
#174 (comment)

@jhamman
Copy link
Member Author

jhamman commented Dec 22, 2014

Agreed. Once, I have the drvier/RASM branch in a more stable state, we can edit this PR so that it points to that branch.

@jhamman
Copy link
Member Author

jhamman commented Jan 9, 2015

Ok, I just finished a first read through the code and here are some initial comments:

Logistics:
Code Review/Style/Comments:
  • We should think about how the C/Fortran interface looks. vic2clmtype_() takes 192 arguments which screams fragile. @bartnijssen and Tony Craig may have suggestions on how to do this.

  • Handle error codes. For example, here in vic_run(),

    if(options.CARBON == CN_NORMAL || options.CARBON == CN_ADECOMP) {
        ErrorFlag = VICCNInterface(rec, Nveg, npfts, dmy, gp, atmos, all_vars, soil_con, veg_con, veg_lib, cn);
    ...

    Once the branch is updated to the current develop branch, log_err() will be available allowing:

    if (!ErrorFlag) {
        log_err("Error calling VICCNInterface");
    }
  • Variable types and memory usage. cn_data_struct is quite large and includes only double precision variables.

    • What is 21 (e.g. onset_flag[21])? It would probably be better use a global size variable #define MAX_CN_LAYERS 21 and onset_flag[MAX_CN_LAYERS]
    • Use integer or bool datatypes for flags and counters (e.g. double onset_flag[21]; --> bool onset_flag[21];
  • Move "Record Carbon Cycling Variables" out of "Collect Water Balance Terms" function in put_data.c. Rather than putting this code in an existing function, its probably worth creating a collect_carbon_terms() function that is only called when CARBON == TRUE.

  • Remove hardcoded paths from Makefile

  • Remove verbose comments

  • Remove hard coded literals when possible from cn/src/VICCNInterface.c. Physical constants are in vic_run/include/physical_constants.h

Relevant Upcoming Changes:
  • Timestep units in global_param.dt are changing from hours to seconds.
  • MPI in driver/image. @bartnijssen can comment on which, if any changes will be necessary in this regard.
Next Steps:

Once we've settled on the changes to the classic driver, the next step is to port to the image mode and RASM drivers.

@tbohn
Copy link
Contributor

tbohn commented Jan 9, 2015

I agree with moving "collect carbon terms" into its own function - I should
have done it that way to begin with!

On Fri, Jan 9, 2015 at 4:07 PM, Joe Hamman notifications@github.com wrote:

Ok, I just finished a first read through the code and here are some
initial comments:
Logistics:

Code Review/Style/Comments:

  • We should think about how the C/Fortran interface looks.
    vic2clmtype_() takes 192 arguments which screams fragile. @bartnijssen
    https://github.com/bartnijssen and Tony Craig may have suggestions

    on how to do this.

    Handle error codes. For example, here in vic_run()
    https://github.com/mabrunke/VIC/blob/feature/CN/vic_run/src/vic_run.c#L370-L374
    ,

    if(options.CARBON == CN_NORMAL || options.CARBON == CN_ADECOMP) {
    ErrorFlag = VICCNInterface(rec, Nveg, npfts, dmy, gp, atmos, all_vars, soil_con, veg_con, veg_lib, cn);
    ...

    Once the branch is updated to the current develop branch, log_err()
    will be available allowing:

    if (!ErrorFlag) {
    log_err("Error calling VICCNInterface");
    }

    Variable types and memory usage. cn_data_struct is quite large and
    includes only double precision variables.

    • What is 21 (e.g. onset_flag[21])? It would probably be better use a
      global size variable #define MAX_CN_LAYERS 21 and
      onset_flag[MAX_CN_LAYERS]
      • Use integer or bool datatypes for flags and counters (e.g. double
        onset_flag[21]; --> bool onset_flag[21];
    • Move "Record Carbon Cycling Variables" out of "Collect Water
      Balance Terms" function in put_data.c. Rather than putting this code
      in an existing function, its probably worth creating a
      collect_carbon_terms() function that is only called when CARBON == TRUE
      .
  • Remove hardcoded paths from Makefile

  • Remove verbose comments

  • Remove hard coded literals when possible from cn/src/VICCNInterface.c.
    Physical constants are in vic_run/include/physical_constants.h

Relevant Upcoming Changes:

Next Steps:

Once we've settled on the changes to the classic driver, the next step is
to port to the image mode and RASM drivers.


Reply to this email directly or view it on GitHub
#174 (comment).

@bartnijssen
Copy link
Member

Some more comments with respect to organization (I haven't gone through the actual code yet):

  • Cleanly separate the CLM code that will be imported as a "block" or module (i.e. we will make no changes inside this) from the wrapper around it that will let this module be called from VIC.
  • Separate all the I/O from the physics (akin to vic_run() and the different drivers). We should be able to use the CN code with all the drivers (even if we originally implement it for only a subset), without any changes to the physics code.
  • Determine where all the pieces will live within the vic repo directory structure. In VIC5 this will have to be broken out into separate pieces rather than as 60+ files in cn/src

@jhamman
Copy link
Member Author

jhamman commented Aug 5, 2015

@mabrunke - I'm going to close this PR. Can you address the issues that @bartnijssen and I have brought up and open a new PR against this branch: https://github.com/UW-Hydro/VIC/tree/driver/cesm.

Also, while you are moving things around a bit, we have reorganized the VIC directory structure a bit to better support adding extensions into VIC, such as CN. This PR is a good example of how we're structuring things: #231. Following how the extension was added in #231, you'll want to add two extensions:

  • dynveg_stub
  • synveg_cn

@jhamman jhamman closed this Aug 5, 2015
@jhamman jhamman mentioned this pull request Aug 5, 2015
@jhamman jhamman mentioned this pull request Sep 15, 2015
14 tasks
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.

4 participants