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

Feature/initialize albedo cesm driver #712

Merged

Conversation

dgergel
Copy link
Contributor

@dgergel dgergel commented Apr 19, 2017

  • closes #
  • tests passed
  • new tests added
  • science test figures
  • ran uncrustify prior to final commit
  • ReleaseNotes entry

This PR adds functionality for computing gridcell-averaged albedo for all drivers at each timestep. The purpose of this is to initialize and correctly compute albedo in the CESM driver to pass to WRF, but it has been implemented in all drivers for the sake of consistency. It includes the following components and additions to the core structure of VIC:

  • new struct, gridcell_avg, to all_vars, where avg_albedo (gridcell-averaged albedo) is stored
  • new state file variable, STATE_AVG_ALBEDO, for reading and writing gridcell-averaged albedo
  • generation of gridcell-averaged albedo from a cold start so that we have a reasonable estimate of albedo prior to reading in forcing data during CESM driver initialization
  • new routine, calc_gridcell_avg_albedo.c, to vic_run to compute gridcell-averaged albedo at each time step
  • add new function, vic_initialize_albedo(), contained in vic_cesm_init_library.c, to CESM driver in cesm_interface_c.c for setting l2x albedo values to reasonable estimates during the initialization phase

dgergel and others added 23 commits April 18, 2017 17:13
…e/initialize_albedo_cesm_driver_2"

This reverts commit 191c157, reversing
changes made to a7e2bf2.
…dgergel/VIC into feature/initialize_albedo_cesm_driver_2
…o feature/initialize_albedo_cesm_driver_2""

This reverts commit e1d5d17.
…ve travis test debugging value from calc_gridcell_avg_albedo
@dgergel
Copy link
Contributor Author

dgergel commented May 2, 2017

@bartnijssen and @jhamman, this is (finally) ready for review.

@dgergel dgergel mentioned this pull request May 2, 2017
6 tasks
@@ -51,14 +51,16 @@ To check which release of VIC you are running:

1. Fixes Julian day for the first timestep in the dmy struct for the CESM driver.

3. Speed up NetCDF operations in the image/CESM drivers ([GH#684](https://github.com/UW-Hydro/VIC/pull/684))
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by the numbering and the edits on previous pull requests. Please fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This deletion was a mistake, it shouldn't have been here. Fixed.

double ***tmpT;
double **tmpZ;
int ErrorFlag;

cell_data_struct **cell;
energy_bal_struct **energy;
veg_var_struct **veg_var;
gridcell_avg_struct gridcell_avg;
Copy link
Member

Choose a reason for hiding this comment

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

This should be a pointer. You don't want to copy the whole structure, you just want to point to the structure


cell = all_vars->cell;
energy = all_vars->energy;
veg_var = all_vars->veg_var;
gridcell_avg = all_vars->gridcell_avg;
Copy link
Member

Choose a reason for hiding this comment

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

if gridcell_avg is a pointer, then this would read

gridcell_avg = &(all_vars->gridcell_avg);

Or just get rid of it. Seems to me that later in the same code you just use all_vars->gridcell_avg directly anyway, so you don't really need 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.

Yep - I just deleted it since I'm using all_vars->gridcell_avg instead.

}
}
}
all_vars->gridcell_avg.avg_albedo = albedo_sum;
Copy link
Member

Choose a reason for hiding this comment

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

See previous comment: Either use the local variable gridcell_avg (but change to a pointer) and use

gridcell_avg->avg_albedo = albedo_sum;

or get rid of local variable and just leave this as is.

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've left it as is and deleted the local variable gridcell_avg.

@@ -30,7 +30,7 @@
* @brief This routine creates the list of output data.
*****************************************************************************/
void
alloc_out_data(size_t ngridcells,
alloc_out_data(size_t ngridcells,
Copy link
Member

Choose a reason for hiding this comment

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

make sure you run all the code through uncrustify (see: https://github.com/UW-Hydro/VIC/tree/master/tools/code_format)

}
}

// compute gridcell-averaged albedo using average longwave
Copy link
Member

Choose a reason for hiding this comment

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

longwave should not be part of any albedo calculation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed - this was a typo, since I'm not actually using longwave

// compute gridcell-averaged albedo using average longwave
// and shortwave over gridcell

// compute gridcell-averaged albedo using average longwave shortwave
Copy link
Member

Choose a reason for hiding this comment

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

It still says longwave

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argh yes. This was careless.

@bartnijssen bartnijssen merged commit 7fb512c into UW-Hydro:develop Jun 6, 2017
@dgergel dgergel mentioned this pull request Aug 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants