Skip to content

Commit c8204aa

Browse files
committed
Changes to compile the library for coupled models
1 parent 45db677 commit c8204aa

4 files changed

Lines changed: 197 additions & 22 deletions

File tree

CMakeLists.txt

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
3636
"$<$<CONFIG:Debug>:${CABLE_GNU_Fortran_FLAGS_DEBUG}>"
3737
)
3838
endif()
39-
39+
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
4040
if(CABLE_LIBRARY)
4141

4242
add_library(
43-
cable_science
43+
cable
4444
STATIC
4545
src/science/albedo/cbl_albedo.F90
4646
src/science/albedo/cbl_snow_albedo.F90
@@ -70,18 +70,18 @@ if(CABLE_LIBRARY)
7070
src/science/casa-cnp/casa_rplant.F90
7171
src/science/casa-cnp/casa_sumcflux.F90
7272
src/science/casa-cnp/casa_variable.F90
73-
src/science/gw_hydro/cable_gw_hydro.F90
74-
src/science/gw_hydro/cable_psm.F90
73+
#src/science/gw_hydro/cable_gw_hydro.F90
74+
#src/science/gw_hydro/cable_psm.F90
7575
src/science/landuse/landuse3.F90
7676
src/science/landuse/landuse_constant.F90
7777
src/science/misc/cable_air.F90
7878
src/science/misc/cable_carbon.F90
7979
src/science/misc/cable_climate.F90
8080
src/science/pop/pop_constants.F90
8181
src/science/pop/pop_def.F90
82-
src/science/pop/POP.F90
83-
src/science/pop/pop_io.F90
84-
src/science/pop/POPLUC.F90
82+
#src/science/pop/POP.F90
83+
#src/science/pop/pop_io.F90
84+
#src/science/pop/POPLUC.F90
8585
src/science/pop/pop_types.F90
8686
src/science/radiation/cbl_init_radiation.F90
8787
src/science/radiation/cbl_radiation.F90
@@ -90,11 +90,11 @@ if(CABLE_LIBRARY)
9090
src/science/radiation/cbl_spitter.F90
9191
src/science/roughness/cable_roughness.F90
9292
src/science/roughness/roughnessHGT_effLAI_cbl.F90
93-
src/science/sli/cable_sli_main.F90
94-
src/science/sli/cable_sli_numbers.F90
95-
src/science/sli/cable_sli_roots.F90
96-
src/science/sli/cable_sli_solve.F90
97-
src/science/sli/cable_sli_utils.F90
93+
#src/science/sli/cable_sli_main.F90
94+
#src/science/sli/cable_sli_numbers.F90
95+
#src/science/sli/cable_sli_roots.F90
96+
#src/science/sli/cable_sli_solve.F90
97+
#src/science/sli/cable_sli_utils.F90
9898
src/science/soilsnow/cbl_conductivity.F90
9999
src/science/soilsnow/cbl_GW.F90
100100
src/science/soilsnow/cbl_hyd_redistrib.F90
@@ -122,14 +122,33 @@ if(CABLE_LIBRARY)
122122
src/params/cable_maths_constants_mod.F90
123123
src/util/cable_runtime_opts_mod.F90
124124
src/util/cable_common.F90
125-
src/coupled/esm16/casa_offline_inout.F90
126-
src/coupled/esm16/casa_ncdf.F90
127-
src/coupled/esm16/cable_iovars.F90
128-
src/coupled/esm16/cable_surface_types.F90
129-
src/coupled/esm16/cable_define_types.F90
130-
src/coupled/esm16/cable_phenology.F90
131-
src/coupled/esm16/cable_LUC_EXPT.F90
125+
src/coupled/esm/cable_iovars.F90
126+
src/coupled/esm/cable_surface_types.F90
127+
src/coupled/esm/cable_define_types.F90
128+
src/coupled/esm/cable_soil_params_mod.F90
129+
src/coupled/esm/cable_pft_params_mod.F90
130+
src/coupled/esm/casa_landuse.F90
131+
src/coupled/esm/LAI_canopy_height_cbl.F90
132+
#src/shared/casa_offline_inout.F90
133+
#src/shared/casa_ncdf.F90
134+
#src/shared/cable_phenology.F90
135+
#src/shared/cable_LUC_EXPT.F90
136+
src/coupled/shared/cable_canopy_type_mod.F90
137+
src/coupled/shared/cable_soilsnow_type_mod.F90
138+
src/coupled/shared/cable_soil_type_mod.F90
139+
src/coupled/shared/cable_veg_type_mod.F90
140+
src/util/cable_climate_type_mod.F90
141+
src/util/masks_cbl.F90
132142
)
143+
target_compile_definitions(cable PRIVATE UM_CBL)
144+
target_include_directories(cable PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
145+
146+
install(TARGETS cable
147+
EXPORT CABLEFortranTargets
148+
LIBRARY DESTINATION lib
149+
INCLUDES DESTINATION include)
150+
151+
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ TYPE INCLUDE)
133152

134153
else()
135154

build.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ while [ ${#} -gt 0 ]; do
6262
cmake_args+=(-DCABLE_MPI="ON")
6363
;;
6464
-l|--library)
65-
build_args+=(--target cable_science)
65+
build_args+=(--target cable)
6666
cmake_args+=(-DCABLE_LIBRARY="ON")
6767
do_install=0 # Disable installation when only building the science library
6868
;;
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
!******************************COPYRIGHT********************************************
2+
! (c) CSIRO 2022.
3+
! All rights reserved.
4+
!
5+
! This routine has been licensed to the other JULES partners for use and
6+
! distribution under the JULES collaboration agreement, subject to the terms and
7+
! conditions set out therein.
8+
!
9+
! [Met Office Ref SC0237]
10+
!******************************COPYRIGHT********************************************
11+
MODULE cbl_LAI_canopy_height_mod
12+
13+
!-----------------------------------------------------------------------------
14+
! Description:
15+
! Restricts the range of canopy height and LAI inherited from JULES/UM
16+
! spatial maps
17+
!
18+
! This MODULE is USEd by:
19+
! cable_land_albedo_mod_cbl.F90
20+
!
21+
! This MODULE contains 1 public Subroutine:
22+
! limit_HGT_LAI
23+
!
24+
! Code Owner: Please refer to ModuleLeaders.txt
25+
! This file belongs in CABLE SCIENCE
26+
!
27+
! Code Description:
28+
! Language: Fortran 90.
29+
! This code is written to JULES coding standards v1.
30+
!-----------------------------------------------------------------------------
31+
32+
IMPLICIT NONE
33+
PUBLIC :: limit_HGT_LAI
34+
PRIVATE
35+
36+
CONTAINS
37+
38+
SUBROUTINE Limit_HGT_LAI( HGT_pft_temp, LAI_pft_cbl, HGT_pft_cbl, mp, land_pts,&
39+
ntiles, npft, tile_pts, tile_index, tile_frac, &
40+
L_tile_pts, LAI_pft, HGT_pft, CLAI_thresh )
41+
42+
!*## Purpose
43+
!
44+
! This SUBROUTINE checks that input values of leaf area and canopy height
45+
! lie between set values (defined by PFT) and overwrites if necessary.
46+
! These limits are needed to ensure that the canopy roughness properties of
47+
! the land point are well behaved (see [[ruff_resist]]).
48+
!
49+
! The mapping from grid cells (land_pts,ntiles) to the (mp) structure
50+
! is also undertaken.
51+
!
52+
! **This SUBROUTINE is active when CABLE is run within a coupled model
53+
! (i.e. ACCESS)**
54+
!
55+
!## Method
56+
!
57+
! The cell-level input (land_pts,ntile) variables for leaf area `LAI_pft` and
58+
! canopy height `HGT_pft` are checked for
59+
!
60+
! - whether the land_pt has a non-zero fraction of that tile (if zero
61+
! fraction then LAI and canopy height are set to zero)
62+
! - whether the LAI lies above a minimum value `CLAI_thresh`
63+
! - whether the canopy height lies above a minimum value (which is PFT dependent)
64+
! - whether non-vegetated tiles have a non-zero canopy height.
65+
!
66+
! Outputs are `LAI_pft_cbl` and `HGT_pft_cbl`
67+
!
68+
! **WARNINGS**
69+
!
70+
! - INTENT statements need to be added to the argument lists
71+
! - hardwired indexing is used throughout. This SUBROUTINE assumes that
72+
! 1. non-vegetated tiles take indexes 14 and onwards
73+
! 2. tall vegetation occupies tile indexes 1-4
74+
! 3. other vegetation (shrubs/grasses/crops/wetlands) occupy tile indexes
75+
! 5-13
76+
! - the limits on canopy height are hardwired
77+
! 1. canopy height for tall vegetation is limited to be greater than 1m
78+
! 2. canopy height for other vegetation is limited to be greater than 0.1m
79+
80+
USE cable_surface_types_mod, ONLY: shrub_cable, evergreen_broadleaf, &
81+
deciduous_broadleaf, aust_temperate, &
82+
aust_tropical
83+
84+
IMPLICIT NONE
85+
86+
INTEGER, INTENT(IN) :: land_pts, ntiles, npft !! # land points here
87+
!! max # of tiles, PFTs
88+
!! CABLE 1-D vector of length "mp" active tiles
89+
INTEGER, INTENT(IN) :: mp !! total number of tiles
90+
91+
!! range limited LAI/ canopy height
92+
REAL, INTENT(OUT) :: HGT_pft_temp(land_pts,ntiles) !! UM dimensions (m)
93+
94+
!! PACKed to CABLE 1-D vector of length mp
95+
REAL, INTENT(OUT) :: LAI_pft_cbl(mp) !! veg%vlai
96+
REAL, INTENT(OUT) :: HGT_pft_cbl(mp) !! veg%hc
97+
98+
!! From UM spatial maps via restart or ancillary.
99+
REAL, INTENT(IN) :: tile_frac(land_pts,ntiles) !! frac. veg/non-veg type
100+
INTEGER, INTENT(IN) :: tile_pts(ntiles) !! # tiles per PFT type
101+
INTEGER, INTENT(IN) :: tile_index(land_pts,ntiles) !! land_pt index per tile
102+
!! updates monthly
103+
REAL, INTENT(IN) :: LAI_pft(land_pts, npft) !! LAI (m\(^2\)m\(^{-2}\))
104+
REAL, INTENT(IN) :: HGT_pft(land_pts, npft) !! canopy height (m)
105+
!! logical mask. TRUE if tilefrac > 0 0 (OR some threshold)
106+
LOGICAL, INTENT(IN) :: L_tile_pts(land_pts,ntiles)
107+
108+
!! scalar constant threshold for "cell" to be considred vegetated
109+
REAL, INTENT(IN) :: Clai_thresh ! minimum LAI threshold
110+
111+
!local vars
112+
INTEGER :: i,j, n
113+
REAL :: LAI_pft_temp(land_pts,ntiles) ! needed to filter spatail map
114+
115+
!Retain init where tile_frac=0
116+
LAI_pft_temp(:,:) = 0.0
117+
HGT_pft_temp(:,:) = 0.0
118+
119+
!Comensurate with restricted ordering of PFTs in UM. Not generically applicable
120+
DO n=1,ntiles
121+
DO j=1,tile_pts(n)
122+
123+
i = tile_index(j,n) ! landpt index
124+
125+
IF( tile_frac(i,n) .GT. 0.0 ) THEN
126+
127+
IF( n < shrub_cable ) THEN ! trees
128+
129+
LAI_pft_temp(i,n) = MAX( 0.99*CLAI_thresh, LAI_pft(i,n) )
130+
HGT_pft_temp(i,n) = MAX( 1.0, HGT_pft(i,n) )
131+
132+
ELSE IF( n >= shrub_cable .AND. n < aust_temperate ) THEN ! shrubs/grass
133+
134+
LAI_pft_temp(i,n) = MAX( 0.99*CLAI_thresh, LAI_pft(i,n) )
135+
HGT_pft_temp(i,n) = MAX( 0.1, HGT_pft(i,n) )
136+
137+
ELSE IF( n == aust_temperate .OR. n == aust_tropical ) THEN ! Aust. trees
138+
139+
LAI_pft_temp(i,n) = MAX( CLAI_thresh, LAI_pft(i,n) )
140+
HGT_pft_temp(i,n) = MAX( 1.0, HGT_pft(i,n) )
141+
142+
ENDIF
143+
144+
ENDIF
145+
146+
ENDDO
147+
ENDDO
148+
149+
!surface_type = PACK(surface_type_temp, um1%L_TILE_PTS)
150+
LAI_pft_cbl = PACK(LAI_pft_temp, l_tile_pts)
151+
HGT_pft_cbl = PACK(HGT_pft_temp, l_tile_pts)
152+
153+
END SUBROUTINE limit_HGT_LAI
154+
155+
END MODULE cbl_LAI_canopy_height_mod
156+

src/coupled/esm/cable_surface_types.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ MODULE cable_surface_types_mod
2424
INTEGER, PARAMETER :: c3_cropland = 9
2525
INTEGER, PARAMETER :: c4_cropland = 10
2626
INTEGER, PARAMETER :: wetland = 11
27-
INTEGER, PARAMETER :: empty1 = 12
28-
INTEGER, PARAMETER :: empty2 = 13
27+
INTEGER, PARAMETER :: aust_temperate = 12
28+
INTEGER, PARAMETER :: aust_tropical = 13
2929
INTEGER, PARAMETER :: barren_cable = 14
3030
INTEGER, PARAMETER :: urban_cable = 15
3131
INTEGER, PARAMETER :: lakes_cable = 16

0 commit comments

Comments
 (0)