Skip to content

Commit

Permalink
Merge pull request #389 from chrislxj/master
Browse files Browse the repository at this point in the history
New create_test updates and new output variables
  • Loading branch information
CoLM-SYSU authored Feb 27, 2025
2 parents 3dc58e1 + 8701573 commit ac7665a
Show file tree
Hide file tree
Showing 13 changed files with 529 additions and 194 deletions.
6 changes: 5 additions & 1 deletion main/BGC/MOD_BGC_CNSummary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ MODULE MOD_BGC_CNSummary
USE MOD_Namelist, only: DEF_USE_NITRIF, DEF_USE_DiagMatrix
USE MOD_Vars_PFTimeInvariants, only: pftclass
USE MOD_Vars_PFTimeVariables, only:irrig_method_p
USE MOD_Vars_TimeInvariants, only: BD_all
USE MOD_BGC_Vars_TimeVariables, only: &
totlitc, totsomc, totcwdc, decomp_cpools, decomp_cpools_vr, ctrunc_soil,ctrunc_veg, ctrunc_vr, &
totlitn, totsomn, totcwdn, decomp_npools, decomp_npools_vr, ntrunc_soil,ntrunc_veg, ntrunc_vr, &
totvegc, totvegn, totcolc, totcoln, sminn, sminn_vr, &
totvegc, totvegn, totcolc, totcoln, sminn, sminn_vr, totsoiln_vr, &
leafc, frootc, livestemc, deadstemc, livecrootc, deadcrootc, leafc_storage, frootc_storage, livestemc_storage, &
deadstemc_storage, livecrootc_storage, deadcrootc_storage, leafc_xfer, frootc_xfer, livestemc_xfer, &
deadstemc_xfer, livecrootc_xfer, deadcrootc_xfer, xsmrpool, &
Expand Down Expand Up @@ -262,16 +263,19 @@ SUBROUTINE soilbiogeochem_nitrogenstate_summary(i,nl_soil,dz_soi,ndecomp_pools)
totcwdn(i) = 0._r8
sminn(i) = 0._r8
ntrunc_soil(i) = 0._r8
totsoiln_vr(1:nl_soil,i) = 0 ! soil total nitrogen (gN/gsoil * 100%)

DO l = 1, ndecomp_pools
decomp_npools(l,i) = 0._r8
DO j = 1, nl_soil
decomp_npools(l,i) = decomp_npools(l,i) + decomp_npools_vr(j,l,i) * dz_soi(j)
totsoiln_vr(j,i) = totsoiln_vr(j,i) + decomp_npools_vr(j,l,i) / (BD_all(j,i) * 1000) * 100 !(unit %)
ENDDO
ENDDO

DO j = 1, nl_soil
sminn(i) = sminn(i) + sminn_vr(j,i) * dz_soi(j)
totsoiln_vr(j,i) = totsoiln_vr(j,i) + sminn_vr(j,i) / (BD_all(j,i) * 1000) * 100 !(unit %)
ENDDO

DO l = 1, ndecomp_pools
Expand Down
28 changes: 17 additions & 11 deletions main/BGC/MOD_BGC_Vars_TimeVariables.F90
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ MODULE MOD_BGC_Vars_TimeVariables
real(r8), allocatable :: decomp_npools_vr (:,:,:) ! vertical resolved: soil decomposition (litter, cwd, soil) nitrogen (gN m-3)
real(r8), allocatable :: decomp_npools (:,:) ! soil decomposition (litter, cwd, soil) nitrogen (gN m-2)
real(r8), allocatable :: decomp_npools_vr_Cap (:,:,:) ! vertical resolved: soil decomposition (litter, cwd, soil organic matter) carbon Capacity (gC m-3)
real(r8), allocatable :: totsoiln_vr (:,:) ! vertical resolved: total soil nitrogen (%: gN/gSoil*100)
real(r8), allocatable :: ntrunc_vr (:,:) ! currently not used
real(r8), allocatable :: ntrunc_veg (:) ! currently not used
real(r8), allocatable :: ntrunc_soil (:) ! currently not used
Expand Down Expand Up @@ -462,6 +463,7 @@ SUBROUTINE allocate_BGCTimeVariables
allocate (decomp_npools_vr (nl_soil_full,ndecomp_pools,numpatch)) ; decomp_npools_vr (:,:,:) = spval
allocate (decomp_npools (ndecomp_pools,numpatch)) ; decomp_npools (:,:) = spval
allocate (decomp_npools_vr_Cap (nl_soil_full,ndecomp_pools,numpatch)) ; decomp_npools_vr_Cap(:,:,:) = spval
allocate (totsoiln_vr (nl_soil,numpatch)) ; totsoiln_vr (:,:) = spval
allocate (ntrunc_vr (nl_soil,numpatch)) ; ntrunc_vr (:,:) = spval
allocate (ntrunc_veg (numpatch)) ; ntrunc_veg (:) = spval
allocate (ntrunc_soil (numpatch)) ; ntrunc_soil (:) = spval
Expand Down Expand Up @@ -756,6 +758,7 @@ SUBROUTINE deallocate_BGCTimeVariables ()
deallocate (decomp_npools_vr )
deallocate (decomp_npools )
deallocate (decomp_npools_vr_Cap )
deallocate (totsoiln_vr )
deallocate (ntrunc_vr )
deallocate (ntrunc_veg )
deallocate (ntrunc_soil )
Expand Down Expand Up @@ -955,7 +958,8 @@ SUBROUTINE WRITE_BGCTimeVariables (file_restart)
CALL ncio_write_vector (file_restart, 'altmax_lastyear_indx ', 'patch', landpatch, altmax_lastyear_indx )

CALL ncio_write_vector (file_restart, 'decomp_npools_vr ', 'soil_full', nl_soil_full, 'ndecomp_pools', ndecomp_pools, &
'patch', landpatch, decomp_npools_vr)
'patch', landpatch, decomp_npools_vr)
CALL ncio_write_vector (file_restart, 'totsoiln_vr ', 'soil' , nl_soil, 'patch', landpatch, totsoiln_vr )
IF(DEF_USE_DiagMatrix)THEN
CALL ncio_write_vector (file_restart, 'decomp_npools_vr_Cap ', 'soil_full', nl_soil_full, 'ndecomp_pools', ndecomp_pools, &
'patch', landpatch, decomp_npools_vr_Cap)
Expand Down Expand Up @@ -1118,15 +1122,16 @@ SUBROUTINE READ_BGCTimeVariables (file_restart)
CALL ncio_read_vector (file_restart, 'altmax_lastyear_indx ', landpatch, altmax_lastyear_indx )

CALL ncio_read_vector (file_restart, 'decomp_npools_vr ', nl_soil_full, ndecomp_pools, landpatch, decomp_npools_vr)
CALL ncio_read_vector (file_restart, 'totsoiln_vr ', nl_soil, landpatch, totsoiln_vr, defval = 1._r8)
IF(DEF_USE_DiagMatrix)THEN
CALL ncio_read_vector (file_restart, 'decomp_npools_vr_Cap ', nl_soil_full, ndecomp_pools, landpatch, decomp_npools_vr_Cap, defval = 1._r8)
CALL ncio_read_vector (file_restart, 'decomp_npools_vr_Cap ',nl_soil_full, ndecomp_pools, landpatch, decomp_npools_vr_Cap, defval = 1._r8)
ENDIF
CALL ncio_read_vector (file_restart, 'ntrunc_vr ', nl_soil, landpatch, ntrunc_vr )
CALL ncio_read_vector (file_restart, 'ntrunc_veg ', landpatch, ntrunc_veg )
CALL ncio_read_vector (file_restart, 'ntrunc_soil ', landpatch, ntrunc_soil )
CALL ncio_read_vector (file_restart, 'sminn_vr ', nl_soil, landpatch, sminn_vr )
CALL ncio_read_vector (file_restart, 'smin_no3_vr ', nl_soil, landpatch, smin_no3_vr )
CALL ncio_read_vector (file_restart, 'smin_nh4_vr ', nl_soil, landpatch, smin_nh4_vr )
CALL ncio_read_vector (file_restart, 'ntrunc_vr ', nl_soil, landpatch, ntrunc_vr )
CALL ncio_read_vector (file_restart, 'ntrunc_veg ', landpatch, ntrunc_veg )
CALL ncio_read_vector (file_restart, 'ntrunc_soil ', landpatch, ntrunc_soil )
CALL ncio_read_vector (file_restart, 'sminn_vr ', nl_soil, landpatch, sminn_vr )
CALL ncio_read_vector (file_restart, 'smin_no3_vr ', nl_soil, landpatch, smin_no3_vr)
CALL ncio_read_vector (file_restart, 'smin_nh4_vr ', nl_soil, landpatch, smin_nh4_vr)

IF(DEF_USE_NITRIF)THEN
CALL ncio_read_vector (file_restart, 'tCONC_O2_UNSAT ', nl_soil, landpatch, tconc_o2_unsat )
Expand Down Expand Up @@ -1379,8 +1384,9 @@ SUBROUTINE check_BGCTimeVariables ()

CALL check_vector_data ('decomp_npools_vr ', decomp_npools_vr )
CALL check_vector_data ('decomp_npools ', decomp_npools )
CALL check_vector_data ('totsoiln_vr ', totsoiln_vr )
IF(DEF_USE_DiagMatrix)THEN
CALL check_vector_data ('decomp_npools_vr_Cap',decomp_npools_vr_Cap)
CALL check_vector_data ('decomp_npools_vr_Cap ',decomp_npools_vr_Cap )
ENDIF
CALL check_vector_data ('ntrunc_vr ', ntrunc_vr )
CALL check_vector_data ('ntrunc_veg ', ntrunc_veg )
Expand All @@ -1391,8 +1397,8 @@ SUBROUTINE check_BGCTimeVariables ()
CALL check_vector_data ('smin_nh4_vr ', smin_nh4_vr )

IF(DEF_USE_NITRIF)THEN
CALL check_vector_data ('tCONC_O2_UNSAT ', tconc_o2_unsat )
CALL check_vector_data ('tO2_DECOMP_DEPTH_UNSAT ', to2_decomp_depth_unsat )
CALL check_vector_data ('tCONC_O2_UNSAT ', tconc_o2_unsat )
CALL check_vector_data ('tO2_DECOMP_DEPTH_UNSAT ', to2_decomp_depth_unsat)
ENDIF

CALL check_vector_data ('sminn ', sminn )
Expand Down
45 changes: 45 additions & 0 deletions main/MOD_Hist.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,46 @@ SUBROUTINE hist_out (idate, deltim, itstamp, etstamp, ptstamp, &
a_fpi, file_hist, 'f_fpi', itime_in_file, sumarea, filter, &
'fraction of immobalization','unitless')

CALL write_history_variable_2d ( DEF_hist_vars%totvegc, &
a_totvegc, file_hist, 'f_totvegc', itime_in_file, sumarea, filter, &
'total vegetation carbon','gC m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totlitc, &
a_totlitc, file_hist, 'f_totlitc', itime_in_file, sumarea, filter, &
'total litter carbon','gC m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totsomc, &
a_totsomc, file_hist, 'f_totsomc', itime_in_file, sumarea, filter, &
'total soil organic carbon','gC m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totcwdc, &
a_totcwdc, file_hist, 'f_totcwdc', itime_in_file, sumarea, filter, &
'total coarse woody debris carbon','gC m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totcolc, &
a_totcolc, file_hist, 'f_totcolc', itime_in_file, sumarea, filter, &
'total ecosystem carbon','gC m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totvegn, &
a_totvegn, file_hist, 'f_totvegn', itime_in_file, sumarea, filter, &
'total vegetation nitrogen','gN m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totlitn, &
a_totlitn, file_hist, 'f_totlitn', itime_in_file, sumarea, filter, &
'total litter nitrogen','gN m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totsomn, &
a_totsomn, file_hist, 'f_totsomn', itime_in_file, sumarea, filter, &
'total soil organic nitrogen','gN m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totcwdn, &
a_totcwdn, file_hist, 'f_totcwdn', itime_in_file, sumarea, filter, &
'total coarse woody debris nitrogen','gN m-2')

CALL write_history_variable_2d ( DEF_hist_vars%totcoln, &
a_totcoln, file_hist, 'f_totcoln', itime_in_file, sumarea, filter, &
'total ecosystem nitrogen','gN m-2')

! autotrophic respiration
CALL write_history_variable_2d ( DEF_hist_vars%ar , &
a_ar, file_hist, 'f_ar', itime_in_file, sumarea, filter, &
Expand Down Expand Up @@ -1464,6 +1504,11 @@ SUBROUTINE hist_out (idate, deltim, itstamp, etstamp, ptstamp, &
a_sminn_vr, file_hist, 'f_sminn_vr', itime_in_file, 'soil', 1, nl_soil, &
sumarea, filter,'mineral nitrogen density in soil layers','gN/m3')

! total nitrogen percentage in soil layers
CALL write_history_variable_3d ( DEF_hist_vars%totsoiln_vr, &
a_totsoiln_vr, file_hist, 'f_totsoiln_vr', itime_in_file, 'soil', 1, nl_soil, &
sumarea, filter,'Total nitrogen in soil layers, percentage of total soil nitrogen mass in total soil mass','%')

! bulk density in soil layers
CALL write_history_variable_3d ( DEF_hist_vars%BD_all, &
a_BD_all, file_hist, 'f_BD_all', itime_in_file, 'soil', 1, nl_soil, &
Expand Down
55 changes: 55 additions & 0 deletions main/MOD_Vars_1DAccFluxes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ MODULE MOD_Vars_1DAccFluxes
real(r8), allocatable :: a_hr (:)
real(r8), allocatable :: a_fpg (:)
real(r8), allocatable :: a_fpi (:)
real(r8), allocatable :: a_totvegc (:)
real(r8), allocatable :: a_totlitc (:)
real(r8), allocatable :: a_totcwdc (:)
real(r8), allocatable :: a_totsomc (:)
real(r8), allocatable :: a_totcolc (:)
real(r8), allocatable :: a_totvegn (:)
real(r8), allocatable :: a_totlitn (:)
real(r8), allocatable :: a_totcwdn (:)
real(r8), allocatable :: a_totsomn (:)
real(r8), allocatable :: a_totcoln (:)
real(r8), allocatable :: a_gpp_enftemp (:) !1
real(r8), allocatable :: a_gpp_enfboreal (:) !2
real(r8), allocatable :: a_gpp_dnfboreal (:) !3
Expand Down Expand Up @@ -323,6 +333,7 @@ MODULE MOD_Vars_1DAccFluxes
real(r8), allocatable :: a_soil2n_vr (:,:)
real(r8), allocatable :: a_soil3n_vr (:,:)
real(r8), allocatable :: a_cwdn_vr (:,:)
real(r8), allocatable :: a_totsoiln_vr (:,:)
real(r8), allocatable :: a_litr1cCap_vr(:,:)
real(r8), allocatable :: a_litr2cCap_vr(:,:)
real(r8), allocatable :: a_litr3cCap_vr(:,:)
Expand Down Expand Up @@ -566,6 +577,16 @@ SUBROUTINE allocate_acc_fluxes
allocate (a_hr (numpatch))
allocate (a_fpg (numpatch))
allocate (a_fpi (numpatch))
allocate (a_totvegc (numpatch))
allocate (a_totlitc (numpatch))
allocate (a_totcwdc (numpatch))
allocate (a_totsomc (numpatch))
allocate (a_totcolc (numpatch))
allocate (a_totvegn (numpatch))
allocate (a_totlitn (numpatch))
allocate (a_totcwdn (numpatch))
allocate (a_totsomn (numpatch))
allocate (a_totcoln (numpatch))
allocate (a_gpp_enftemp (numpatch)) !1
allocate (a_gpp_enfboreal (numpatch)) !2
allocate (a_gpp_dnfboreal (numpatch)) !3
Expand Down Expand Up @@ -719,6 +740,7 @@ SUBROUTINE allocate_acc_fluxes
allocate (a_soil2n_vr (1:nl_soil, numpatch))
allocate (a_soil3n_vr (1:nl_soil, numpatch))
allocate (a_cwdn_vr (1:nl_soil, numpatch))
allocate (a_totsoiln_vr (1:nl_soil, numpatch))
allocate (a_sminn_vr (1:nl_soil, numpatch))
allocate (decomp_vr_tmp (1:nl_soil, numpatch))

Expand Down Expand Up @@ -962,6 +984,16 @@ SUBROUTINE deallocate_acc_fluxes ()
deallocate (a_hr )
deallocate (a_fpg )
deallocate (a_fpi )
deallocate (a_totvegc )
deallocate (a_totlitc )
deallocate (a_totcwdc )
deallocate (a_totsomc )
deallocate (a_totcolc )
deallocate (a_totvegn )
deallocate (a_totlitn )
deallocate (a_totcwdn )
deallocate (a_totsomn )
deallocate (a_totcoln )
deallocate (a_gpp_enftemp ) !1
deallocate (a_gpp_enfboreal ) !2
deallocate (a_gpp_dnfboreal ) !3
Expand Down Expand Up @@ -1115,6 +1147,7 @@ SUBROUTINE deallocate_acc_fluxes ()
deallocate (a_soil2n_vr )
deallocate (a_soil3n_vr )
deallocate (a_cwdn_vr )
deallocate (a_totsoiln_vr )
deallocate (a_sminn_vr )
deallocate (decomp_vr_tmp )
deallocate (a_litr1cCap_vr)
Expand Down Expand Up @@ -1359,6 +1392,16 @@ SUBROUTINE FLUSH_acc_fluxes ()
a_hr (:) = spval
a_fpg (:) = spval
a_fpi (:) = spval
a_totvegc (:) = spval
a_totlitc (:) = spval
a_totcwdc (:) = spval
a_totsomc (:) = spval
a_totcolc (:) = spval
a_totvegn (:) = spval
a_totlitn (:) = spval
a_totcwdn (:) = spval
a_totsomn (:) = spval
a_totcoln (:) = spval
a_gpp_enftemp (:) = spval
a_gpp_enfboreal (:) = spval
a_gpp_dnfboreal (:) = spval
Expand Down Expand Up @@ -1508,6 +1551,7 @@ SUBROUTINE FLUSH_acc_fluxes ()
a_soil2n_vr (:,:) = spval
a_soil3n_vr (:,:) = spval
a_cwdn_vr (:,:) = spval
a_totsoiln_vr (:,:) = spval

a_litr1cCap_vr (:,:) = spval
a_litr2cCap_vr (:,:) = spval
Expand Down Expand Up @@ -1844,6 +1888,16 @@ SUBROUTINE accumulate_fluxes
CALL acc1d (decomp_hr , a_hr )
CALL acc1d (fpg , a_fpg )
CALL acc1d (fpi , a_fpi )
CALL acc1d (totvegc , a_totvegc )
CALL acc1d (totlitc , a_totlitc )
CALL acc1d (totcwdc , a_totcwdc )
CALL acc1d (totsomc , a_totsomc )
CALL acc1d (totcolc , a_totcolc )
CALL acc1d (totvegn , a_totvegn )
CALL acc1d (totlitn , a_totlitn )
CALL acc1d (totcwdn , a_totcwdn )
CALL acc1d (totsomn , a_totsomn )
CALL acc1d (totcoln , a_totcoln )
CALL acc1d (gpp_enftemp , a_gpp_enftemp )
CALL acc1d (gpp_enfboreal , a_gpp_enfboreal )
CALL acc1d (gpp_dnfboreal , a_gpp_dnfboreal )
Expand Down Expand Up @@ -2077,6 +2131,7 @@ SUBROUTINE accumulate_fluxes
ENDDO
ENDDO
CALL acc2d (decomp_vr_tmp, a_cwdn_vr )
CALL acc2d (totsoiln_vr , a_totsoiln_vr )

DO i = 1, numpatch
DO j = 1, nl_soil
Expand Down
23 changes: 20 additions & 3 deletions run/scripts/SummaryTest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ SummaryTest()
fi

TestCaseLists=$2
TestType=$4
nfile=`cat $TestCaseLists|wc -l`
for CaseName in `awk '{print $1}' $TestCaseLists`
for ListCase in `awk '{print $1}' $TestCaseLists`
do
CaseName=${TestType}_${ListCase}
echo $CaseName
for Var in $Varlist
do
Expand Down Expand Up @@ -79,12 +81,13 @@ done
}


while getopts ":hn:f:i:" options ;
while getopts ":hn:f:i:t:" options ;
do
case $options in
n) TestName="$OPTARG" ;;
f) TestCaseList="$OPTARG" ;;
i) Varlist="$OPTARG" ;;
t) TestType="$OPTARG" ;;
h) Help; exit;;
*) echo "invalid option: $@";exit ;;
esac
Expand All @@ -102,6 +105,18 @@ else
fi
fi

if [ -z "${TestType}" ]; then
echo
echo Error: TestType '(-t)' is missing
exit
else
case $TestType in
SMS);;
RES);;
*)echo Error: TestType $TestType is invalid
esac
fi

if [ -z "$Varlist" ];then
Varlist="All"
else
Expand All @@ -111,8 +126,10 @@ else
Submit_Mksrfdata);;
Submit_Mkinidata);;
Submit_Case);;
Submit_Restart);;
RestartMatch);;
*) echo "invalid Var option: $Varlist"; exit;;
esac
fi

SummaryTest $TestName $TestCaseList $Varlist
SummaryTest $TestName $TestCaseList $Varlist $TestType
Loading

0 comments on commit ac7665a

Please sign in to comment.