Skip to content

Commit 630e2e1

Browse files
reconcile with dev-access-esm1.6 - interface code (#551)
# CABLE ## Description Reconcile developments in ESM1.6 with CABLE:main There are changes across utilities since directories as well BUT here it is only those in coupled/ that are considered. Post shuffling these files around to facilitate building a library. What happens to them is irrelevant really. These modified and added files are from dev-access-esm1.6. ## Testing - [x] Are the changes bitwise-compatible with the main branch? If working on an optional feature, are the results bitwise-compatible when this feature is off? If yes, copy benchcab output showing successful completion of the bitwise compatibility tests or equivalent results below this line. So - I haven't actually done the testing BUT considering none of these fits are even in the build they cant impact anything <!-- readthedocs-preview cable start --> ---- 📚 Documentation preview 📚: https://cable--551.org.readthedocs.build/en/551/ <!-- readthedocs-preview cable end -->
1 parent 6b24323 commit 630e2e1

23 files changed

+1934
-962
lines changed

src/coupled/ESM1.5/CABLEfilesFromESM1.5/allocate_soil_params_cbl.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MODULE allocate_soil_params_mod
1212

1313
SUBROUTINE allocate_soil_parameter_type(var, mp)
1414

15-
USE cable_params_mod, ONLY: soil_parameter_type
15+
USE cable_soil_type_mod, ONLY: soil_parameter_type
1616
USE cable_other_constants_mod, ONLY: nrb
1717

1818
!-----------------------------------------------------------------------------

src/coupled/ESM1.5/CABLEfilesFromESM1.5/allocate_veg_params_cbl.F90

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MODULE allocate_veg_params_mod
1212

1313
SUBROUTINE allocate_veg_parameter_type(var, mp)
1414

15-
USE cable_params_mod, ONLY: veg_parameter_type
15+
USE cable_veg_type_mod, ONLY: veg_parameter_type
1616
USE cable_other_constants_mod, ONLY: nrb !used as ambiguosly AND inconsistently as # rad. bands
1717
USE cable_other_constants_mod, ONLY: nscs ! number of soil carbon stores
1818
USE cable_other_constants_mod, ONLY: nvcs ! number of vegetation carbon stores

src/coupled/ESM1.5/CABLEfilesFromESM1.5/cable_cbm.F90

+154-98
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,82 @@
11
MODULE cable_cbm_module
22

3-
USE cable_canopy_module
3+
USE cable_canopy_module
44

5-
IMPLICIT NONE
5+
IMPLICIT NONE
66

7-
PRIVATE
8-
PUBLIC cbm
7+
PRIVATE
8+
PUBLIC cbm
99

1010
CONTAINS
1111

12-
SUBROUTINE cbm( dels, air, bgc, canopy, met, &
13-
bal, rad, rough, soil, &
14-
ssnow, sum_flux, veg, climate )
12+
SUBROUTINE cbm( dels, air, bgc, canopy, met, bal, rad, rough, soil, &
13+
ssnow, sum_flux, veg, climate )
1514

15+
!subrs:
16+
USE cbl_albedo_mod, ONLY: albedo
1617
USE cbl_init_radiation_module, ONLY: init_radiation
17-
USE cbl_albedo_mod, ONLY: albedo
18-
USE cbl_masks_mod, ONLY: fveg_mask, fsunlit_mask, fsunlit_veg_mask
18+
USE cbl_masks_mod, ONLY: fveg_mask, fsunlit_mask, fsunlit_veg_mask
1919
USE cbl_soil_snow_main_module, ONLY: soil_snow
20-
USE snow_aging_mod, ONLY : snow_aging
21-
22-
!jhan:pass these !data
20+
USE snow_aging_mod, ONLY: snow_aging
21+
USE cable_roughness_module, ONLY: ruff_resist
22+
USE cable_air_module, ONLY: define_air
23+
USE cable_canopy_module, ONLY: define_canopy
24+
25+
!data
26+
USE casadimension, ONLY: icycle
27+
USE cable_phys_constants_mod, ONLY: GRAV, CAPP
28+
USE cable_common_module
29+
USE cable_carbon_module
30+
31+
!jhan:mp must come from here until revise the mp that is also set
32+
USE cable_def_types_mod, ONLY: met_type, radiation_type, veg_parameter_type, &
33+
soil_parameter_type, roughness_type, &
34+
canopy_type, soil_snow_type, balances_type, &
35+
air_type, bgc_pool_type, sum_flux_type, &
36+
climate_type, mp, nrb
37+
38+
! data: scalars
2339
USE cable_other_constants_mod, ONLY: Ccoszen_tols => coszen_tols
24-
USE cable_other_constants_mod, ONLY : Crad_thresh => rad_thresh
40+
USE cable_other_constants_mod, ONLY: Crad_thresh => rad_thresh
2541
USE cable_other_constants_mod, ONLY: clai_thresh => lai_thresh
2642
USE cable_other_constants_mod, ONLY: cgauss_w => gauss_w
2743
USE cable_math_constants_mod, ONLY: cpi => pi
2844
USE cable_math_constants_mod, ONLY: cpi180 => pi180
45+
USE cable_phys_constants_mod, ONLY: tfrz
46+
USE grid_constants_mod_cbl, ONLY: ICE_SoilType!
2947
USE cable_surface_types_mod, ONLY: lakes_cable
30-
USE grid_constants_mod_cbl, ONLY: ICE_SoilType
31-
32-
33-
USE cable_common_module
34-
USE cable_carbon_module
35-
USE cable_def_types_mod
36-
USE cable_roughness_module
37-
USE cable_air_module
38-
USE casadimension, ONLY: icycle
39-
USE cable_phys_constants_mod, ONLY: GRAV, CAPP
40-
41-
42-
! CABLE model variables
43-
TYPE (air_type), INTENT(INOUT) :: air
44-
TYPE (bgc_pool_type), INTENT(INOUT) :: bgc
45-
TYPE (canopy_type), INTENT(INOUT) :: canopy
46-
TYPE (met_type), INTENT(INOUT) :: met
47-
TYPE (balances_type), INTENT(INOUT) :: bal
48-
TYPE (radiation_type), INTENT(INOUT) :: rad
49-
TYPE (roughness_type), INTENT(INOUT) :: rough
50-
TYPE (soil_snow_type), INTENT(INOUT) :: ssnow
51-
TYPE (sum_flux_type), INTENT(INOUT) :: sum_flux
52-
TYPE(climate_type), INTENT(INOUT) :: climate
53-
54-
TYPE (soil_parameter_type), INTENT(INOUT) :: soil
55-
TYPE (veg_parameter_type), INTENT(INOUT) :: veg
48+
USE cable_phys_constants_mod, ONLY: cEMLEAF=> EMLEAF
49+
USE cable_phys_constants_mod, ONLY: cEMSOIL=> EMSOIL
50+
USE cable_phys_constants_mod, ONLY: cSBOLTZ=> SBOLTZ
51+
52+
! CABLE model variables
53+
TYPE (air_type), INTENT(INOUT) :: air
54+
TYPE (bgc_pool_type), INTENT(INOUT) :: bgc
55+
TYPE (canopy_type), INTENT(INOUT) :: canopy
56+
TYPE (met_type), INTENT(INOUT) :: met
57+
TYPE (balances_type), INTENT(INOUT) :: bal
58+
TYPE (radiation_type), INTENT(INOUT) :: rad
59+
TYPE (roughness_type), INTENT(INOUT) :: rough
60+
TYPE (soil_snow_type), INTENT(INOUT) :: ssnow
61+
TYPE (sum_flux_type), INTENT(INOUT) :: sum_flux
62+
TYPE(climate_type), INTENT(INOUT) :: climate
63+
64+
TYPE (soil_parameter_type), INTENT(INOUT) :: soil
65+
TYPE (veg_parameter_type), INTENT(INOUT) :: veg
5666

57-
REAL, INTENT(IN) :: dels ! time setp size (s)
67+
REAL, INTENT(IN) :: dels ! time setp size (s)
5868

5969
!co-efficients usoughout init_radiation ` called from _albedo as well
6070
REAL :: c1(mp,nrb)
6171
REAL :: rhoch(mp,nrb)
6272
REAL :: xk(mp,nrb)
73+
REAL :: veg_wt(mp)
74+
REAL :: veg_trad(mp)
75+
REAL :: soil_wt(mp)
76+
REAL :: soil_trad(mp)
77+
REAL :: trad_corr(mp)
6378

79+
! local vars
6480
LOGICAL :: veg_mask(mp), sunlit_mask(mp), sunlit_veg_mask(mp)
6581
LOGICAL :: jls_standalone = .FALSE.
6682
LOGICAL :: jls_radiation = .FALSE.
@@ -75,7 +91,7 @@ SUBROUTINE cbm( dels, air, bgc, canopy, met, &
7591
ENDIF
7692

7793
CALL define_air (met, air)
78-
94+
7995
CALL fveg_mask( veg_mask, mp, Clai_thresh, canopy%vlaiw )
8096
CALL fsunlit_mask( sunlit_mask, mp, CRAD_THRESH,( met%fsd(:,1)+met%fsd(:,2) ) )
8197
CALL fsunlit_veg_mask( sunlit_veg_mask, veg_mask, sunlit_mask, mp )
@@ -99,12 +115,7 @@ SUBROUTINE cbm( dels, air, bgc, canopy, met, &
99115

100116
IF( cable_runtime%um_explicit ) THEN
101117

102-
!Ticket 331 refactored albedo code for JAC
103-
!#539 move of snow_Aging routine
104-
!CALL snow_aging(ssnow%snage,mp,dels,ssnow%snowd,ssnow%osnowd,ssnow%tggsn(:,1),&
105-
! ssnow%tgg(:,1),ssnow%isflag,veg%iveg,soil%isoilm)
106-
107-
call Albedo( ssnow%AlbSoilsn, soil%AlbSoil, &
118+
CALL Albedo( ssnow%AlbSoilsn, soil%AlbSoil, &
108119
mp, nrb, ICE_SoilType, lakes_cable, jls_radiation, veg_mask, &
109120
Ccoszen_tols, cgauss_w, &
110121
veg%iveg, soil%isoilm, veg%refl, veg%taul, &
@@ -126,67 +137,112 @@ SUBROUTINE cbm( dels, air, bgc, canopy, met, &
126137
!CanopyTransmit_beam, CanopyTransmit_dif,
127138
rad%reffbm, rad%reffdf &
128139
) !EffSurfRefl_beam, EffSurfRefl_dif
129-
130-
131140

132-
ENDIF
141+
ENDIF
133142

134-
! Calculate canopy variables:
135-
CALL define_canopy(bal,rad,rough,air,met,dels,ssnow,soil,veg, canopy, climate, sunlit_veg_mask, canopy%vlaiw )
136-
137-
ssnow%otss_0 = ssnow%otss
138-
ssnow%otss = ssnow%tss
139-
! RML moved out of following IF after discussion with Eva
140-
ssnow%owetfac = ssnow%wetfac
143+
! on 1st call tss, wetfac initialized in _um_init_soilsnow
144+
! on subsequent calls it has the value as updated in soilsnow
145+
IF( cable_runtime%um_explicit ) THEN
146+
ssnow%otss = ssnow%tss
147+
ssnow%owetfac = ssnow%wetfac
148+
! unfortunately for clarity here, define_canopy immediately sets
149+
! canopy%cansto = canopy%oldcansto, so we need this initialization
150+
canopy%oldcansto = canopy%cansto
151+
ENDIF
141152

142-
IF( cable_runtime%um ) THEN
143-
144-
IF( cable_runtime%um_implicit ) THEN
145-
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
146-
!#539 move of snow_Aging routine
147-
CALL snow_aging(ssnow%snage,mp,dels,ssnow%snowd,ssnow%osnowd,ssnow%tggsn(:,1),&
148-
ssnow%tgg(:,1),ssnow%isflag,veg%iveg,soil%isoilm)
149-
ENDIF
150-
151-
ELSE
152-
call soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
153-
!#539 move of snow_Aging routine
154-
CALL snow_aging(ssnow%snage,mp,dels,ssnow%snowd,ssnow%osnowd,ssnow%tggsn(:,1),&
155-
ssnow%tgg(:,1),ssnow%isflag,veg%iveg,soil%isoilm)
156-
ENDIF
157-
158-
ssnow%deltss = ssnow%tss-ssnow%otss
159-
! correction required for energy balance in online simulations
160-
IF( cable_runtime%um ) THEN
161-
162-
canopy%fhs = canopy%fhs + ( ssnow%tss-ssnow%otss ) * ssnow%dfh_dtg
163-
164-
canopy%fhs_cor = canopy%fhs_cor + ( ssnow%tss-ssnow%otss ) * ssnow%dfh_dtg
165-
166-
canopy%fh = canopy%fhv + canopy%fhs
153+
! Calculate canopy variables:
154+
CALL define_canopy( bal, rad, rough, air, met, dels, ssnow, soil, veg, canopy, &
155+
climate, sunlit_veg_mask, canopy%vlaiw )
167156

168-
canopy%fes = canopy%fes + ( ssnow%tss-ssnow%otss ) * &
169-
( ssnow%dfe_ddq * ssnow%ddq_dtg )
170-
!( ssnow%cls * ssnow%dfe_ddq * ssnow%ddq_dtg )
171-
172-
canopy%fes_cor = canopy%fes_cor + ( ssnow%tss-ssnow%otss ) * &
173-
( ssnow%cls * ssnow%dfe_ddq * ssnow%ddq_dtg )
157+
IF( cable_runtime%um_explicit ) THEN
158+
! reset tss, wetfac, cansto to value corresponding to beginning of timestep
159+
ssnow%tss = ssnow%otss
160+
ssnow%wetfac = ssnow%owetfac
161+
canopy%cansto = canopy%oldcansto
162+
ENDIF
174163

175-
ENDIF
164+
IF( cable_runtime%um_implicit ) THEN
165+
166+
CALL soil_snow(dels, soil, ssnow, canopy, met, bal,veg)
167+
!#539 move of snow_Aging routine
168+
CALL snow_aging(ssnow%snage,mp,dels,ssnow%snowd,ssnow%osnowd,ssnow%tggsn(:,1),&
169+
ssnow%tgg(:,1),ssnow%isflag,veg%iveg,soil%isoilm)
170+
171+
ssnow%deltss = ssnow%tss-ssnow%otss ! from ESM1.5 could substitute below
176172

177-
! need to adjust fe after soilsnow
178-
canopy%fev = canopy%fevc + canopy%fevw
173+
! correction required for energy balance in online simulations
174+
IF( cable_user%SOIL_STRUC=='default') THEN
175+
176+
canopy%fhs = canopy%fhs + ( ssnow%tss-ssnow%otss ) * ssnow%dfh_dtg
177+
canopy%fhs_cor = canopy%fhs_cor + ( ssnow%tss-ssnow%otss ) * ssnow%dfh_dtg
178+
canopy%fh = canopy%fhv + canopy%fhs
179+
180+
!INH rewritten in terms of %dfe_dtg - NB factor %cls was a bug
181+
canopy%fes = canopy%fes + ( ssnow%tss-ssnow%otss ) * ssnow%dfe_dtg
182+
!INH NB factor %cls in %fes_cor was a bug - see Ticket #135 #137
183+
canopy%fes_cor = canopy%fes_cor + (ssnow%tss-ssnow%otss) * ssnow%dfe_dtg
184+
185+
IF (cable_user%L_REV_CORR) THEN
186+
187+
!INH need to add on corrections to all terms in the soil energy balance
188+
canopy%fns_cor = canopy%fns_cor + (ssnow%tss-ssnow%otss)*ssnow%dfn_dtg
189+
190+
!NB %fns_cor also added onto out%Rnet and out%LWnet in cable_output and
191+
!cable_checks as the correction term needs to pass through the
192+
!canopy in entirity not be partially absorbed and %fns not used there
193+
!(as would be the case if rad%flws were changed)
194+
canopy%fns = canopy%fns + ( ssnow%tss-ssnow%otss )*ssnow%dfn_dtg
179195

180-
! Calculate total latent heat flux:
181-
canopy%fe = canopy%fev + canopy%fes
196+
canopy%ga_cor = canopy%ga_cor + ( ssnow%tss-ssnow%otss )*canopy%dgdtg
197+
canopy%ga = canopy%ga + ( ssnow%tss-ssnow%otss )*canopy%dgdtg
198+
199+
!assign all the correction to %fes to %fess - none to %fesp
200+
canopy%fess = canopy%fess + ( ssnow%tss-ssnow%otss ) * ssnow%dfe_dtg
201+
202+
ENDIF
182203

183-
! Calculate net radiation absorbed by soil + veg
184-
canopy%rnet = canopy%fns + canopy%fnv
204+
ENDIF
185205

186-
! Calculate radiative/skin temperature:
187-
rad%trad = ( ( 1.-rad%transd ) * canopy%tv**4 + &
188-
rad%transd * ssnow%tss**4 )**0.25
206+
ENDIF
189207

208+
! need to adjust fe after soilsnow
209+
canopy%fev = canopy%fevc + canopy%fevw
210+
211+
! Calculate total latent heat flux:
212+
canopy%fe = canopy%fev + canopy%fes
213+
214+
! Calculate net radiation absorbed by soil + veg
215+
canopy%rnet = canopy%fns + canopy%fnv
216+
217+
! Calculate radiative/skin temperature:
218+
!Jan 2018: UM assumes a single emissivity for the surface in the radiation scheme
219+
!To accommodate this a single value of is 1. is assumed in ACCESS
220+
! any leaf/soil emissivity /=1 must be incorporated into rad%trad.
221+
! check that emissivities (pft and nvg) set = 1 within the UM i/o configuration
222+
! CM2 - further adapted to pass the correction term onto %trad correctly
223+
224+
veg_wt = 1.0 - rad%transd
225+
veg_trad = Cemleaf * canopy%tv**4
226+
soil_wt = rad%transd
227+
soil_trad = Cemsoil * ssnow%tss**4
228+
229+
rad%trad = ( veg_wt * veg_trad ) + ( soil_wt * soil_trad )
230+
rad%trad = rad%trad**0.25
231+
232+
! In physical model only (i.e. without CASA-CNP)
233+
234+
!! calculate canopy%frp
235+
!CALL plantcarb(veg,bgc,met,canopy)
236+
!
237+
!!calculate canopy%frs
238+
!CALL soilcarb(soil, ssnow, veg, bgc, met, canopy)
239+
!
240+
!CALL carbon_pl(dels, soil, ssnow, veg, canopy, bgc)
241+
!
242+
!canopy%fnpp = -1.0* canopy%fpn - canopy%frp
243+
!canopy%fnee = canopy%fpn + canopy%frs + canopy%frp
244+
245+
RETURN
190246
END SUBROUTINE cbm
191247

192248
END MODULE cable_cbm_module

0 commit comments

Comments
 (0)