From 0498d5e73fc9af07f98f3d83b66a6932183f31f9 Mon Sep 17 00:00:00 2001 From: Ben Andre Date: Tue, 11 Oct 2016 16:18:35 -0600 Subject: [PATCH 1/2] Create FatesConstantMod to hold global constants Create FatesConstantMod to hold global cosntants for things like string length, kind types, spval and other immutable data. Initial values based on similar constants in CLM. Fixes: #135 User interface changes?: none Code review: self Test suite: ed - yellowstone gnu, intel, pgi Test baseline: 49733e8 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass --- .../clm/src/ED/main/FatesConstantsMod.F90 | 21 +++++++++++++++++++ components/clm/src/ED/main/HistoryIOMod.F90 | 19 +++++++++-------- 2 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 components/clm/src/ED/main/FatesConstantsMod.F90 diff --git a/components/clm/src/ED/main/FatesConstantsMod.F90 b/components/clm/src/ED/main/FatesConstantsMod.F90 new file mode 100644 index 0000000000..be01937c4f --- /dev/null +++ b/components/clm/src/ED/main/FatesConstantsMod.F90 @@ -0,0 +1,21 @@ +module FatesConstantsMod + ! This module is used to define global _immutable_ data. Everything in + ! this module must have the parameter attribute. + + implicit none + + public + + ! kinds + integer, parameter :: fates_r8 = selected_real_kind(12) ! 8 byte real + + ! string lengths + integer, parameter :: fates_avg_flag_length = 3 + integer, parameter :: fates_short_string_length = 32 + integer, parameter :: fates_long_string_length = 199 + + ! various magic numbers + real(fates_r8), parameter :: fates_special_value = 1.0e36_fates_r8 ! special value for real data, compatible with clm. + integer, parameter :: fates_int_special_value = -9999 ! keep this negative to avoid conflicts with possible valid values + +end module FatesConstantsMod diff --git a/components/clm/src/ED/main/HistoryIOMod.F90 b/components/clm/src/ED/main/HistoryIOMod.F90 index 3456b54e89..b21edabe18 100644 --- a/components/clm/src/ED/main/HistoryIOMod.F90 +++ b/components/clm/src/ED/main/HistoryIOMod.F90 @@ -1,7 +1,8 @@ Module HistoryIOMod - use shr_kind_mod , only : r8 => shr_kind_r8 + use FatesConstantsMod, only : r8 => fates_r8 + use FatesConstantsMod, only : fates_avg_flag_length, fates_short_string_length, fates_long_string_length use FatesGlobals , only : fates_log use EDTypesMod , only : cp_hio_ignore_val use pftconMod , only : pftcon @@ -127,7 +128,7 @@ Module HistoryIOMod ! This structure is not allocated by thread, but the upper and lower boundaries ! of the dimension for each thread is saved in the clump_ entry type iovar_dim_type - character(len=32) :: name ! This should match the name of the dimension + character(fates_short_string_length) :: name ! This should match the name of the dimension integer :: lb ! lower bound integer :: ub ! upper bound integer,allocatable :: clump_lb(:) ! lower bound of thread's portion of HIO array @@ -150,7 +151,7 @@ Module HistoryIOMod ! This structure is not multi-threaded type iovar_dimkind_type - character(len=32) :: name ! String labelling this IO type + character(fates_short_string_length) :: name ! String labelling this IO type integer :: ndims ! number of dimensions in this IO type integer, allocatable :: dimsize(:) ! The size of each dimension logical :: active @@ -162,15 +163,15 @@ Module HistoryIOMod ! This type is instanteated in the HLM-FATES interface (clmfates_interfaceMod.F90) type iovar_def_type - character(len=32) :: vname - character(len=24) :: units - character(len=128) :: long - character(len=24) :: use_default ! States whether a variable should be turned + character(len=fates_short_string_length) :: vname + character(len=fates_short_string_length) :: units + character(len=fates_long_string_length) :: long + character(len=fates_short_string_length) :: use_default ! States whether a variable should be turned ! on the output files by default (active/inactive) ! It is a good idea to set inactive for very large ! or infrequently used output datasets - character(len=24) :: vtype - character(len=1) :: avgflag + character(len=fates_short_string_length) :: vtype + character(len=fates_avg_flag_length) :: avgflag integer :: upfreq ! Update frequency (this is for checks and flushing) ! 1 = dynamics "dyn" (daily) ! 2 = production "prod" (prob model tstep) From a6aaaa45cdecf3729b90056bdca5ade6bf38323f Mon Sep 17 00:00:00 2001 From: Ben Andre Date: Wed, 12 Oct 2016 16:28:57 -0600 Subject: [PATCH 2/2] Remove special value constants from FatesConstantsmod The special values added int FatestConstantsMod weren't used at this time, and it's unclear if we need a fates specific set of special values, or if we only want to use the host value. Removing until needed. Testing: since this only removed unused code, compiled and ran: SMS_D_Ld5.f45_f45.ICLM45ED.yellowstone_intel.clm-edTest - passed --- components/clm/src/ED/main/FatesConstantsMod.F90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/clm/src/ED/main/FatesConstantsMod.F90 b/components/clm/src/ED/main/FatesConstantsMod.F90 index be01937c4f..244f6f6505 100644 --- a/components/clm/src/ED/main/FatesConstantsMod.F90 +++ b/components/clm/src/ED/main/FatesConstantsMod.F90 @@ -14,8 +14,4 @@ module FatesConstantsMod integer, parameter :: fates_short_string_length = 32 integer, parameter :: fates_long_string_length = 199 - ! various magic numbers - real(fates_r8), parameter :: fates_special_value = 1.0e36_fates_r8 ! special value for real data, compatible with clm. - integer, parameter :: fates_int_special_value = -9999 ! keep this negative to avoid conflicts with possible valid values - end module FatesConstantsMod