From 5317327fc80c24132e37f29928b6665e754360f1 Mon Sep 17 00:00:00 2001 From: Diana Gergel Date: Tue, 5 Sep 2017 09:51:50 -0700 Subject: [PATCH] Feature/cesm timingtables secsday columns (#746) * populate nrecs, endyear, endmonth and endday in global_param struct for secs/day columns in timing tables for CESM driver * ran uncrustify * add release notes entry * update PR number in release notes entry --- docs/Development/ReleaseNotes.md | 8 ++++++-- vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90 | 2 +- vic/drivers/cesm/include/vic_driver_cesm.h | 3 ++- vic/drivers/cesm/src/cesm_interface_c.c | 5 ++++- vic/drivers/cesm/src/cesm_interface_f.F90 | 3 ++- vic/drivers/cesm/src/vic_cesm_time.c | 16 ++++++++++++++++ 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/Development/ReleaseNotes.md b/docs/Development/ReleaseNotes.md index ce4cdcf84..450c58742 100644 --- a/docs/Development/ReleaseNotes.md +++ b/docs/Development/ReleaseNotes.md @@ -79,9 +79,13 @@ To check which release of VIC you are running: Updates the cesm_put_data.c routine in the CESM driver to include the correct signs for the wind stresses and fixes a bug in calculating friction velocity (previously it was missing a square root). - [GH#744] (https://github.com/UW-Hydro/VIC/pull/744) + [GH#744](https://github.com/UW-Hydro/VIC/pull/744) - Updates the cesm_interface_c.c routine to include missing timers and the VIC RUN timer in the CESM driver. + Updates the cesm_interface_c.c routine to include missing timers and the VIC RUN timer in the CESM driver. + + [GH#746](https://github.com/UW-Hydro/VIC/pull/746) + + Updates the cesm_interface_c.c routine in the CESM driver to populate the nrecs, endyear, endmonth and endday fields in the global_param struct to make them available to vic_finalize for timing tables (specifically the secs/day columns). 3. Speed up NetCDF operations in the image/CESM drivers ([GH#684](https://github.com/UW-Hydro/VIC/pull/684)) diff --git a/vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90 b/vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90 index 7173aa594..22a889cd4 100644 --- a/vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90 +++ b/vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90 @@ -415,7 +415,7 @@ SUBROUTINE lnd_final_mct(EClock, cdata, x2l, l2x, cdata_s, x2s, s2x) CHARACTER(len=*), PARAMETER :: subname = '(lnd_final_mct)' !--- clean up - errno = vic_cesm_final() + errno = vic_cesm_final(vclock) IF (errno /= 0) THEN CALL shr_sys_abort(subname//' ERROR: vic_cesm_final returned a errno /= 0') diff --git a/vic/drivers/cesm/include/vic_driver_cesm.h b/vic/drivers/cesm/include/vic_driver_cesm.h index 6a55e3507..b883b3f79 100644 --- a/vic/drivers/cesm/include/vic_driver_cesm.h +++ b/vic/drivers/cesm/include/vic_driver_cesm.h @@ -159,6 +159,7 @@ typedef struct { void advance_vic_time(void); void assert_time_insync(vic_clock *vclock, dmy_struct *dmy); +void finalize_cesm_time(vic_clock *vclock); void get_global_param(FILE *); void initialize_cesm_time(void); void initialize_l2x_data(void); @@ -178,7 +179,7 @@ void validate_options(option_struct *options); void vic_cesm_alloc(void); int vic_cesm_init_mpi(int MPI_COMM_VIC_F); int vic_cesm_init(vic_clock *vclock, case_metadata *cmeta); -int vic_cesm_final(void); +int vic_cesm_final(vic_clock *vclock); void vic_cesm_finalize(void); int vic_cesm_run(vic_clock *vclock); void vic_force(void); diff --git a/vic/drivers/cesm/src/cesm_interface_c.c b/vic/drivers/cesm/src/cesm_interface_c.c index 041bc155b..df4f0336c 100644 --- a/vic/drivers/cesm/src/cesm_interface_c.c +++ b/vic/drivers/cesm/src/cesm_interface_c.c @@ -189,13 +189,16 @@ vic_cesm_run(vic_clock *vclock) * @brief Finalize function for CESM driver *****************************************************************************/ int -vic_cesm_final() +vic_cesm_final(vic_clock *vclock) { // continue vic all timer timer_continue(&(global_timers[TIMER_VIC_ALL])); // start vic final timer timer_start(&(global_timers[TIMER_VIC_FINAL])); + // finalize time + finalize_cesm_time(vclock); + // clean up vic_cesm_finalize(); diff --git a/vic/drivers/cesm/src/cesm_interface_f.F90 b/vic/drivers/cesm/src/cesm_interface_f.F90 index 4cf07718d..df510caa8 100644 --- a/vic/drivers/cesm/src/cesm_interface_f.F90 +++ b/vic/drivers/cesm/src/cesm_interface_f.F90 @@ -89,10 +89,11 @@ END FUNCTION vic_cesm_run !> @brief Finalize Interface !-------------------------------------------------------------------------- INTERFACE - INTEGER(C_INT) FUNCTION vic_cesm_final() BIND(C, name='vic_cesm_final') + INTEGER(C_INT) FUNCTION vic_cesm_final(vclock) BIND(C, name='vic_cesm_final') USE, INTRINSIC :: ISO_C_BINDING USE vic_cesm_def_mod IMPLICIT NONE + TYPE(vic_clock), INTENT(in) :: vclock END FUNCTION vic_cesm_final END INTERFACE diff --git a/vic/drivers/cesm/src/vic_cesm_time.c b/vic/drivers/cesm/src/vic_cesm_time.c index ec46bd8c4..d7083e51f 100644 --- a/vic/drivers/cesm/src/vic_cesm_time.c +++ b/vic/drivers/cesm/src/vic_cesm_time.c @@ -65,6 +65,22 @@ initialize_cesm_time(void) global_param.time_units, &dmy_current); } +/****************************************************************************** + * @brief Finalize cesm time + *****************************************************************************/ +void +finalize_cesm_time(vic_clock *vclock) +{ + extern size_t current; + extern global_param_struct global_param; + + // populate fields in global_param needed for timing tables + global_param.nrecs = current; + global_param.endyear = vclock->current_year; + global_param.endmonth = vclock->current_month; + global_param.endday = vclock->current_day; +} + /****************************************************************************** * @brief Advance one timestep *****************************************************************************/