From c78428c45e28b72b0a53835dda81824d8338f000 Mon Sep 17 00:00:00 2001 From: Sean Bryan Date: Thu, 28 Nov 2024 11:10:17 +1100 Subject: [PATCH] Move site initialisation to cable_driver_init_site --- src/offline/cable_driver_init.F90 | 20 ++++++++++++++++++-- src/offline/cable_offline_driver.F90 | 6 ++++-- src/offline/cable_serial.F90 | 22 ++++------------------ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/offline/cable_driver_init.F90 b/src/offline/cable_driver_init.F90 index ed2f3d02d..a9aa171d0 100644 --- a/src/offline/cable_driver_init.F90 +++ b/src/offline/cable_driver_init.F90 @@ -27,7 +27,8 @@ MODULE cable_driver_init_mod globalMetfile, & set_group_output_values, & timeunits, & - exists + exists, & + calendar USE casadimension, ONLY : icycle USE casavariable, ONLY : casafile USE cable_namelist_util, ONLY : & @@ -39,6 +40,7 @@ MODULE cable_driver_init_mod USE cable_input_module, ONLY : open_met_file USE CABLE_PLUME_MIP, ONLY : PLUME_MIP_TYPE, PLUME_MIP_INIT USE CABLE_CRU, ONLY : CRU_TYPE, CRU_INIT + USE CABLE_site, ONLY : site_TYPE, site_INIT IMPLICIT NONE PRIVATE @@ -236,14 +238,28 @@ SUBROUTINE cable_driver_init_gswp(mpi_grp, GSWP_MID, NRRRR) END SUBROUTINE cable_driver_init_gswp - SUBROUTINE cable_driver_init_site() + SUBROUTINE cable_driver_init_site(site) !* Model initialisation routine (site met specific). + ! Site experiment, e.g. AmazonFace (spinup or transient run type). + TYPE (site_TYPE), INTENT(OUT) :: site + + CHARACTER(len=9) :: str1, str2, str3 IF (.NOT. l_casacnp) THEN WRITE(*,*) "MetType=site only works with CASA-CNP turned on" STOP 991 END IF + CALL site_INIT( site ) + WRITE(str1,'(i4)') cable_user%YearStart + str1 = ADJUSTL(str1) + WRITE(str2,'(i2)') 1 + str2 = ADJUSTL(str2) + WRITE(str3,'(i2)') 1 + str3 = ADJUSTL(str3) + timeunits="seconds since "//TRIM(str1)//"-"//TRIM(str2)//"-"//TRIM(str3)//"00:00" + calendar = 'standard' + END SUBROUTINE cable_driver_init_site SUBROUTINE cable_driver_init_default(dels, koffset, kend) diff --git a/src/offline/cable_offline_driver.F90 b/src/offline/cable_offline_driver.F90 index fbae75f01..bcecb045f 100644 --- a/src/offline/cable_offline_driver.F90 +++ b/src/offline/cable_offline_driver.F90 @@ -11,6 +11,7 @@ PROGRAM cable_offline_driver USE cable_common_module, ONLY : cable_user USE CABLE_PLUME_MIP, ONLY : PLUME_MIP_TYPE USE CABLE_CRU, ONLY : CRU_TYPE + USE CABLE_site, ONLY : site_TYPE IMPLICIT NONE @@ -25,6 +26,7 @@ PROGRAM cable_offline_driver INTEGER, ALLOCATABLE :: GSWP_MID(:,:) !! NetCDF file IDs for GSWP met forcing TYPE(PLUME_MIP_TYPE) :: PLUME TYPE(CRU_TYPE) :: CRU + TYPE (site_TYPE) :: site call mpi_mod_init() mpi_grp = mpi_grp_t() @@ -41,7 +43,7 @@ PROGRAM cable_offline_driver CASE('cru') CALL cable_driver_init_cru(dels, koffset, CRU) CASE('site') - CALL cable_driver_init_site() + CALL cable_driver_init_site(site) CALL cable_driver_init_default(dels, koffset, kend) CASE('') CALL cable_driver_init_default(dels, koffset, kend) @@ -51,7 +53,7 @@ PROGRAM cable_offline_driver END SELECT IF (mpi_grp%size == 1) THEN - CALL serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, CRU) + CALL serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, CRU, site) ELSE IF (mpi_grp%rank == 0) THEN CALL mpidrv_master(mpi_grp%comm, trunk_sumbal, dels, koffset, kend, PLUME, CRU) diff --git a/src/offline/cable_serial.F90 b/src/offline/cable_serial.F90 index 63db529b7..11df02a73 100644 --- a/src/offline/cable_serial.F90 +++ b/src/offline/cable_serial.F90 @@ -132,7 +132,7 @@ MODULE cable_serial PLUME_MIP_INIT USE CABLE_CRU, ONLY: CRU_TYPE, CRU_GET_SUBDIURNAL_MET - USE CABLE_site, ONLY: site_TYPE, site_INIT, site_GET_CO2_Ndep + USE CABLE_site, ONLY: site_TYPE, site_GET_CO2_Ndep ! LUC_EXPT only USE CABLE_LUC_EXPT, ONLY: LUC_EXPT_TYPE, LUC_EXPT_INIT @@ -153,7 +153,7 @@ MODULE cable_serial CONTAINS -SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, CRU) +SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, CRU, site) !! Offline serial driver. DOUBLE PRECISION, INTENT(IN) :: trunk_sumbal !! Reference value for quasi-bitwise reproducibility checks. @@ -164,6 +164,7 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, INTEGER, ALLOCATABLE, INTENT(INOUT) :: GSWP_MID(:,:) !! NetCDF file IDs for GSWP met forcing TYPE(PLUME_MIP_TYPE), INTENT(IN) :: PLUME TYPE(CRU_TYPE), INTENT(IN) :: CRU + TYPE (site_TYPE), INTENT(IN) :: site ! timing variables INTEGER, PARAMETER :: kstart = 1 ! start of simulation @@ -185,7 +186,7 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, count_sum_casa ! number of time steps over which casa pools & !and fluxes are aggregated (for output) - CHARACTER :: dum*9, str1*9, str2*9, str3*9 + CHARACTER :: dum*9 ! CABLE variables TYPE (met_type) :: met ! met input variables @@ -217,7 +218,6 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, ! vh_js ! TYPE (POP_TYPE) :: POP TYPE(POPLUC_TYPE) :: POPLUC - TYPE (site_TYPE) :: site TYPE (LUC_EXPT_TYPE) :: LUC_EXPT TYPE (landuse_mp) :: lucmp CHARACTER :: cyear*4 @@ -332,20 +332,6 @@ SUBROUTINE serialdrv(trunk_sumbal, NRRRR, dels, koffset, kend, GSWP_MID, PLUME, kend = NINT(24.0*3600.0/dels) * LOY ELSE IF ( TRIM(cable_user%MetType) .EQ. 'site' ) THEN ! site experiment eg AmazonFace (spinup or transient run type) - - IF ( CALL1 ) THEN - CALL CPU_TIME(etime) - CALL site_INIT( site ) - WRITE(str1,'(i4)') CurYear - str1 = ADJUSTL(str1) - WRITE(str2,'(i2)') 1 - str2 = ADJUSTL(str2) - WRITE(str3,'(i2)') 1 - str3 = ADJUSTL(str3) - timeunits="seconds since "//TRIM(str1)//"-"//TRIM(str2)//"-"//TRIM(str3)//"00:00" - calendar = 'standard' - - ENDIF kend = NINT(24.0*3600.0/dels) * LOY ! get koffset to add to time-step of sitemet IF (TRIM(site%RunType)=='historical') THEN