Skip to content

Commit

Permalink
add caseid to statefile name by passing case metadata in to vic_cesm_…
Browse files Browse the repository at this point in the history
…run function
  • Loading branch information
dgergel committed Oct 9, 2016
1 parent 95d6983 commit 7e28f13
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion vic/drivers/cesm/cpl_mct/lnd_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ SUBROUTINE lnd_run_mct(EClock, cdata, x2l, l2x, cdata_s, x2s, s2x)
CALL lnd_import_mct(x2l)

!--- run vic
errno = vic_cesm_run(vclock)
errno = vic_cesm_run(vclock, cmeta)
IF (errno /= 0) THEN
CALL shr_sys_abort(subname//' ERROR: vic_cesm_run returned a errno /= 0')
ENDIF
Expand Down
2 changes: 1 addition & 1 deletion vic/drivers/cesm/include/vic_driver_cesm.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ 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);
void vic_cesm_finalize(void);
int vic_cesm_run(vic_clock *vclock);
int vic_cesm_run(vic_clock *vclock, case_metadata *cmeta);
void vic_force(void);
void vic_cesm_put_data(void);
void vic_cesm_run_model(void);
Expand Down
9 changes: 7 additions & 2 deletions vic/drivers/cesm/src/cesm_interface_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ vic_cesm_init(vic_clock *vclock,
timer_stop(&(global_timers[TIMER_VIC_INIT]));
// stop vic all timer
timer_stop(&(global_timers[TIMER_VIC_ALL]));

return EXIT_SUCCESS;
}

/******************************************************************************
* @brief Run function for CESM driver
*****************************************************************************/
int
vic_cesm_run(vic_clock *vclock)
vic_cesm_run(vic_clock *vclock,
case_metadata *cmeta)
{
extern filenames_struct filenames;
char state_filename[MAXSTRING];

// continue vic all timer
Expand All @@ -140,6 +141,10 @@ vic_cesm_run(vic_clock *vclock)

// if save:
if (vclock->state_flag) {
// assign case name to state file name
strncpy(filenames.statefile, trim(cmeta->caseid),
sizeof(filenames.statefile));
// write state file
vic_store(&dmy_current, state_filename);
write_rpointer_file(state_filename);
}
Expand Down
3 changes: 2 additions & 1 deletion vic/drivers/cesm/src/cesm_interface_f.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ END FUNCTION vic_cesm_init
!> @brief Run Interface
!--------------------------------------------------------------------------
INTERFACE
INTEGER(C_INT) FUNCTION vic_cesm_run(vclock) BIND(C, name='vic_cesm_run')
INTEGER(C_INT) FUNCTION vic_cesm_run(vclock, cmeta) BIND(C, name='vic_cesm_run')
USE, INTRINSIC :: ISO_C_BINDING
USE vic_cesm_def_mod
IMPLICIT NONE
TYPE(vic_clock), INTENT(in) :: vclock
TYPE(case_metadata), INTENT(in) :: cmeta
END FUNCTION vic_cesm_run
END INTERFACE

Expand Down
7 changes: 1 addition & 6 deletions vic/drivers/shared_image/src/vic_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
*****************************************************************************/

#include <vic_driver_shared_image.h>
#include <vic_driver_cesm.h>

/******************************************************************************
* @brief Save model state.
*****************************************************************************/
void
vic_store(dmy_struct *dmy_current,
case_metadata *cmeta,
char *filename)
{
extern filenames_struct filenames;
Expand Down Expand Up @@ -76,20 +74,17 @@ vic_store(dmy_struct *dmy_current,
end_time_num = time_num + offset;

// allocate dmy struct for end of current time step
// end_time_date = calloc(1, sizeof(*dmy_struct));
num2date(global_param.time_origin_num, end_time_num, 0.,
global_param.calendar, global_param.time_units,
&end_time_date);


// only open and initialize the netcdf file on the first thread
if (mpi_rank == VIC_MPI_ROOT) {
// create netcdf file for storing model state
sprintf(filename, "%s.%04i%02i%02i_%05u.nc",
cmeta->caseid, end_time_date.year,
filenames.statefile, end_time_date.year,
end_time_date.month, end_time_date.day,
end_time_date.dayseconds);

initialize_state_file(filename, &nc_state_file, dmy_current);

debug("writing state file: %s", filename);
Expand Down

0 comments on commit 7e28f13

Please sign in to comment.