From 90c01807431a4a71edde29e5968888f29bfa38a8 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 20 Aug 2019 11:29:46 -0700 Subject: [PATCH 1/9] created new procedure to condense setting FATES time --- src/utils/clmfates_interfaceMod.F90 | 113 ++++++++++++++++++---------- 1 file changed, 75 insertions(+), 38 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 84c4e5901f..925c9b30f5 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -197,6 +197,11 @@ module CLMFatesInterfaceMod ! developer will at least question its usage (RGK) private :: hlm_bounds_to_fates_bounds + ! ThGetAndSetFatesTimeis function is used to get the current time from the CIME + ! time procedures and then set to the fates global time variables during restart, + ! init_coldstart, and dynamics_driv function calls + private :: GetAndSetTime + logical :: debug = .false. character(len=*), parameter, private :: sourcefile = & @@ -513,11 +518,11 @@ subroutine init(this, bounds_proc ) call FatesReportParameters(masterproc) end subroutine init - - ! =================================================================================== - - subroutine check_hlm_active(this, nc, bounds_clump) - +init +init================================= +init +init +init ! --------------------------------------------------------------------------------- ! This subroutine is not currently used. It is just a utility that may come ! in handy when we have dynamic sites in FATES @@ -579,22 +584,9 @@ subroutine dynamics_driv(this, nc, bounds_clump, & integer :: c ! column index (HLM) integer :: ifp ! patch index integer :: p ! HLM patch index - integer :: yr ! year (0, ...) - integer :: mon ! month (1, ..., 12) - integer :: day ! day of month (1, ..., 31) - integer :: sec ! seconds of the day integer :: nlevsoil ! number of soil layers at the site integer :: nld_si ! site specific number of decomposition layers - integer :: current_year - integer :: current_month - integer :: current_day - integer :: current_tod - integer :: current_date - integer :: jan01_curr_year - integer :: reference_date - integer :: days_per_year - real(r8) :: model_day - real(r8) :: day_of_year + !----------------------------------------------------------------------- ! --------------------------------------------------------------------------------- @@ -606,24 +598,8 @@ subroutine dynamics_driv(this, nc, bounds_clump, & ! and it keeps all the boundaries in one location ! --------------------------------------------------------------------------------- - days_per_year = get_days_per_year() - call get_curr_date(current_year,current_month,current_day,current_tod) - current_date = current_year*10000 + current_month*100 + current_day - jan01_curr_year = current_year*10000 + 100 + 1 - - call get_ref_date(yr, mon, day, sec) - reference_date = yr*10000 + mon*100 + day - - call timemgr_datediff(reference_date, sec, current_date, current_tod, model_day) - - call timemgr_datediff(jan01_curr_year,0,current_date,sec,day_of_year) - - call SetFatesTime(current_year, current_month, & - current_day, current_tod, & - current_date, reference_date, & - model_day, floor(day_of_year), & - days_per_year, 1.0_r8/dble(days_per_year)) - + ! Set the FATES global time and date variables + call GetAndSetTime do s=1,this%fates(nc)%nsites @@ -1173,7 +1149,8 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & this%fates(nc)%sites, & this%fates(nc)%bc_out) - + ! Set the FATES global time and date variables + !call GetAndSetTime ! ------------------------------------------------------------------------ ! Update history IO fields that depend on ecosystem dynamics @@ -1289,6 +1266,9 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins call this%wrap_update_hlmfates_dyn(nc,bounds_clump, & waterstate_inst,canopystate_inst,frictionvel_inst) + ! Set the FATES global time and date variables + !call GetAndSetTime + ! ------------------------------------------------------------------------ ! Update history IO fields that depend on ecosystem dynamics ! ------------------------------------------------------------------------ @@ -2505,4 +2485,61 @@ subroutine hlm_bounds_to_fates_bounds(hlm, fates) end subroutine hlm_bounds_to_fates_bounds + ! ====================================================================================== + + subroutine GetAndSetTime() + + ! CLM MODULES + use clm_time_manager , only : get_days_per_year, & + get_curr_date, & + get_ref_date, & + timemgr_datediff, & + + ! FATES MODULES + use FatesInterfaceMod , only : SetFatesTime + + ! LOCAL VARIABLES + integer :: yr ! year (0, ...) + integer :: mon ! month (1, ..., 12) + integer :: day ! day of month (1, ..., 31) + integer :: sec ! seconds of the day + integer :: current_year + integer :: current_month + integer :: current_day + integer :: current_tod + integer :: current_date + integer :: jan01_curr_year + integer :: reference_date + integer :: days_per_year + real(r8) :: model_day + real(r8) :: day_of_year + + + ! Get the current date and determine the set the start of the current year + call get_curr_date(current_year,current_month,current_day,current_tod) + current_date = current_year*10000 + current_month*100 + current_day + jan01_curr_year = current_year*10000 + 100 + 1 + + ! Get the reference date components and compute the date + call get_ref_date(yr, mon, day, sec) + reference_date = yr*10000 + mon*100 + day + + ! Get the defined number of days per year + days_per_year = get_days_per_year() + + ! Determine the model day + call timemgr_datediff(reference_date, sec, current_date, current_tod, model_day) + + ! Determine the current DOY + call timemgr_datediff(jan01_curr_year,0,current_date,sec,day_of_year) + + ! Set the FATES global time variables + call SetFatesTime(current_year, current_month, & + current_day, current_tod, & + current_date, reference_date, & + model_day, floor(day_of_year), & + days_per_year, 1.0_r8/dble(days_per_year)) + + end subroutine GetAndSetTime + end module CLMFatesInterfaceMod From 31ce51c67e8058acc1e0cefa6aacdfd08c4a6f29 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 20 Aug 2019 12:38:42 -0700 Subject: [PATCH 2/9] fixing accidental deletion --- src/utils/clmfates_interfaceMod.F90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 925c9b30f5..5f542e5cb7 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -518,11 +518,11 @@ subroutine init(this, bounds_proc ) call FatesReportParameters(masterproc) end subroutine init -init -init================================= -init -init -init + + ! =================================================================================== + + subroutine check_hlm_active(this, nc, bounds_clump) + ! --------------------------------------------------------------------------------- ! This subroutine is not currently used. It is just a utility that may come ! in handy when we have dynamic sites in FATES From d8003c32262086441927faf7b2e24d62bad316fe Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 20 Aug 2019 13:20:15 -0700 Subject: [PATCH 3/9] Correcting small error --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 5f542e5cb7..7f1be3fa27 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -2493,7 +2493,7 @@ subroutine GetAndSetTime() use clm_time_manager , only : get_days_per_year, & get_curr_date, & get_ref_date, & - timemgr_datediff, & + timemgr_datediff ! FATES MODULES use FatesInterfaceMod , only : SetFatesTime From cd30b77bc5f322df903d1ac60a0427ec7fafee10 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 27 Aug 2019 14:25:49 -0700 Subject: [PATCH 4/9] adding in GetAndSet procedure call --- src/utils/clmfates_interfaceMod.F90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 7f1be3fa27..f2d5d557cd 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -197,7 +197,7 @@ module CLMFatesInterfaceMod ! developer will at least question its usage (RGK) private :: hlm_bounds_to_fates_bounds - ! ThGetAndSetFatesTimeis function is used to get the current time from the CIME + ! The GetAndSetFatesTimeis function is used to get the current time from the CIME ! time procedures and then set to the fates global time variables during restart, ! init_coldstart, and dynamics_driv function calls private :: GetAndSetTime @@ -1149,9 +1149,6 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & this%fates(nc)%sites, & this%fates(nc)%bc_out) - ! Set the FATES global time and date variables - !call GetAndSetTime - ! ------------------------------------------------------------------------ ! Update history IO fields that depend on ecosystem dynamics ! ------------------------------------------------------------------------ @@ -1193,6 +1190,10 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins integer :: s integer :: c + + ! Set the FATES global time and date variables + call GetAndSetTime + nclumps = get_proc_clumps() !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s,c,j,vol_ice,eff_porosity) From ca0be0736eae27389e3d4f7b92d053ad64a2810b Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Thu, 3 Oct 2019 13:47:15 -0700 Subject: [PATCH 5/9] adding GetandSetTime to restart subroutine --- src/utils/clmfates_interfaceMod.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index f2d5d557cd..3ac39debf5 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -962,6 +962,9 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & ! I think that is it... ! --------------------------------------------------------------------------------- + ! Set the FATES global time and date variables + call GetAndSetTime + if(.not.initialized) then initialized=.true. @@ -1267,9 +1270,6 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins call this%wrap_update_hlmfates_dyn(nc,bounds_clump, & waterstate_inst,canopystate_inst,frictionvel_inst) - ! Set the FATES global time and date variables - !call GetAndSetTime - ! ------------------------------------------------------------------------ ! Update history IO fields that depend on ecosystem dynamics ! ------------------------------------------------------------------------ From ac16068ef6a75ecf5ee344d24c2e3cbadaa014c7 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Fri, 11 Oct 2019 11:26:59 -0700 Subject: [PATCH 6/9] removing calls to GetandSet in restart and cold_init subroutines. First appears to be not necessary and second screws up the cold start --- src/utils/clmfates_interfaceMod.F90 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 6079a7017a..3c81cf928b 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -965,9 +965,6 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & ! I think that is it... ! --------------------------------------------------------------------------------- - ! Set the FATES global time and date variables - call GetAndSetTime - if(.not.initialized) then initialized=.true. @@ -1197,9 +1194,6 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins integer :: c - ! Set the FATES global time and date variables - call GetAndSetTime - nclumps = get_proc_clumps() !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s,c,j,vol_ice,eff_porosity) From 4adf9863c04f1f9e3985ca0c5eac9e96abe40915 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Tue, 12 Nov 2019 13:34:39 -0800 Subject: [PATCH 7/9] Revert "removing calls to GetandSet in restart and cold_init subroutines. First appears to be not necessary and second screws up the cold start" This reverts commit ac16068ef6a75ecf5ee344d24c2e3cbadaa014c7. --- src/utils/clmfates_interfaceMod.F90 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 3c81cf928b..6079a7017a 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -965,6 +965,9 @@ subroutine restart( this, bounds_proc, ncid, flag, waterstate_inst, & ! I think that is it... ! --------------------------------------------------------------------------------- + ! Set the FATES global time and date variables + call GetAndSetTime + if(.not.initialized) then initialized=.true. @@ -1194,6 +1197,9 @@ subroutine init_coldstart(this, waterstate_inst, canopystate_inst, soilstate_ins integer :: c + ! Set the FATES global time and date variables + call GetAndSetTime + nclumps = get_proc_clumps() !$OMP PARALLEL DO PRIVATE (nc,bounds_clump,s,c,j,vol_ice,eff_porosity) From 020a0a309f61dcb428cfff6eb9c626050cbc91d1 Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 16 Dec 2019 13:32:52 -0800 Subject: [PATCH 8/9] updating GetandSetTime function comment referencing correct time function source --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 6079a7017a..803c298d37 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -197,7 +197,7 @@ module CLMFatesInterfaceMod ! developer will at least question its usage (RGK) private :: hlm_bounds_to_fates_bounds - ! The GetAndSetFatesTimeis function is used to get the current time from the CIME + ! The GetAndSetFatesTime function is used to get the current time from the CLM ! time procedures and then set to the fates global time variables during restart, ! init_coldstart, and dynamics_driv function calls private :: GetAndSetTime From f6f871b0cfc6fc14a07f363c726400bb76fd84bf Mon Sep 17 00:00:00 2001 From: Gregory Lemieux Date: Mon, 16 Dec 2019 13:36:33 -0800 Subject: [PATCH 9/9] fixing comment typo --- src/utils/clmfates_interfaceMod.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/clmfates_interfaceMod.F90 b/src/utils/clmfates_interfaceMod.F90 index 803c298d37..9986fb5e74 100644 --- a/src/utils/clmfates_interfaceMod.F90 +++ b/src/utils/clmfates_interfaceMod.F90 @@ -197,7 +197,7 @@ module CLMFatesInterfaceMod ! developer will at least question its usage (RGK) private :: hlm_bounds_to_fates_bounds - ! The GetAndSetFatesTime function is used to get the current time from the CLM + ! The GetAndSetTime function is used to get the current time from the CLM ! time procedures and then set to the fates global time variables during restart, ! init_coldstart, and dynamics_driv function calls private :: GetAndSetTime