Skip to content

Commit

Permalink
Fix to groundwater parameter initialisations that can impact the soil…
Browse files Browse the repository at this point in the history
… conductivity (#491)

# CABLE

Thank you for submitting a pull request to the CABLE Project.

## Description

Fixes #490 

Working on the groundwater implementation, I have found that the
function `total_soil_conductivity` depends on some GW parameters that
aren't correctly implemented. This is to fix this.

## Type of change

Please delete options that are not relevant.

- [x] Bug fix

## Testing
Since this requires MPI to test the impact, I haven't used
modelevaluation.org to analyse the results. I have run benchcab with the
spatial configuration for:
1. main with `cable_user%soil_thermal_fix = .TRUE`
1. main with `cable_user%soil_thermal_fix = .FALSE`
1. this branch with `cable_user%soil_thermal_fix = .TRUE`
2. this branch with `cable_user%soil_thermal_fix = .FALSE`

Case 3 - Case 1 allow to gauge the total effect of the change. Case 2 -
Case 1 give a measure of the change compared to the initial fix to the
soil conductivity. Case 4 - Case 2 shows whether there are any impacts
beyond the soil conductivity (without explicitly finding these other
sources).

The comparison of case 4 and case 2 with `cdo diffn` shows there are no
differences when `cable_user%soil_thermal_fix` is false.

The largest effect for this branch is found on the ground flux but the
effect is limited (right plot) compared to the effect of
`soil_thermal_fix` (left plot):

![ground_flux_effect](https://github.com/user-attachments/assets/0cd7e6e7-0ba2-4f91-86fd-45cccc08b75b)
These are time-mean values of the differences between the simulations.

Please add a reviewer when ready for review.


<!-- readthedocs-preview cable start -->
----
📚 Documentation preview 📚:
https://cable--491.org.readthedocs.build/en/491/

<!-- readthedocs-preview cable end -->
  • Loading branch information
ccarouge authored Nov 29, 2024
2 parents 8c970f2 + c2b67c7 commit dfef1b9
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/offline/cable_mpicommon.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MODULE cable_mpicommon

! base number of input fields: must correspond to CALLS to
! MPI_address (field ) in *_mpimaster/ *_mpiworker
INTEGER, PARAMETER :: nparam = 330
INTEGER, PARAMETER :: nparam = 340

! MPI: extra params sent only if nsoilparmnew is true
INTEGER, PARAMETER :: nsoilnew = 1
Expand Down
60 changes: 60 additions & 0 deletions src/offline/cable_mpimaster.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,66 @@ SUBROUTINE master_cable_params (comm,met,air,ssnow,veg,bgc,soil,canopy,&
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%zse_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%css_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%cnsd_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%clay_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%sand_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%silt_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%org_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%rhosoil_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%smpc_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1

bidx = bidx + 1
CALL MPI_Get_address (soil%wbc_vec(off,1), displs(bidx), ierr)
CALL MPI_Type_create_hvector (ms, r2len, r2stride, MPI_BYTE, &
& types(bidx), ierr)
blen(bidx) = 1


!1D
bidx = bidx + 1
Expand Down
40 changes: 40 additions & 0 deletions src/offline/cable_mpiworker.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,46 @@ SUBROUTINE worker_cable_params (comm,met,air,ssnow,veg,bgc,soil,canopy,&
bidx = bidx + 1
CALL MPI_Get_address (soil%sfc_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%zse_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%css_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%cnsd_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%clay_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%sand_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%silt_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%org_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%rhosoil_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%smpc_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len

bidx = bidx + 1
CALL MPI_Get_address (soil%wbc_vec, displs(bidx), ierr)
blen(bidx) = ms * r2len


!1d
Expand Down
20 changes: 14 additions & 6 deletions src/offline/cable_parameters.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,11 @@ SUBROUTINE write_default_params(met, air, ssnow, veg, bgc, &
incnsd(landpt(e)%ilon, landpt(e)%ilat)

!possibly heterogeneous soil properties
! Set all heterogeneous soil properties to their equivalent uniform values.
! These values can be overridden later on by input values in files.
! `smpc_vec` and `wbc_vec` are only used in the ground water and have no
! equivalent in the uniform parameters (non _vec). So we do not initialise
! these variables when we are not using the ground water scheme.
DO klev=1,ms

soil%clay_vec(landpt(e)%cstart:landpt(e)%cend,klev) = &
Expand All @@ -1400,6 +1405,15 @@ SUBROUTINE write_default_params(met, air, ssnow, veg, bgc, &
soil%watr(landpt(e)%cstart:landpt(e)%cend,klev) = &
REAL(inWatr(landpt(e)%ilon, landpt(e)%ilat),r_2)

soil%zse_vec(landpt(e)%cstart:landpt(e)%cend,klev) = &
REAL(soil%zse(landpt(e)%cstart:landpt(e)%cend), r_2)

soil%css_vec(landpt(e)%cstart:landpt(e)%cend, klev) = &
REAL(incss(landpt(e)%ilon, landpt(e)%ilat), r_2)

soil%cnsd_vec(landpt(e)%cstart:landpt(e)%cend, klev) = &
REAL(incnsd(landpt(e)%ilon, landpt(e)%ilat), r_2)

END DO

!Aquifer properties same as bottom soil layer for now
Expand Down Expand Up @@ -2147,12 +2161,6 @@ SUBROUTINE derived_parameters(soil, sum_flux, bal, ssnow, veg, rough)

if ((gw_params%MaxSatFraction .lt. -9999.9) .and. (mp .eq. 1)) soil%slope(:) = 0.01

ELSE !not gw model

!These are not used when gw_model == false
soil%watr = 0._r_2
soil%GWwatr = 0._r_2

END IF

IF (cable_user%soil_thermal_fix) then
Expand Down

0 comments on commit dfef1b9

Please sign in to comment.