Skip to content

Commit 0be7a65

Browse files
author
Marcos Longo
committed
1. Small correction in selective logging, there was a bogus 0.5 factor due to a mistake
in the derivation. Also changed the weight for plants so it related to basal area (this should only affect simulations using SimAmazonia2 when there is information about logged area, but no biomass info) 2. Renamed the decay rates for the soil carbon pools from K1, K2, K3 to something more intuitive (decay_rate_stsc, decay_rate_fsc, decay_rate_ssc). 3. Some changes in check_run.sh so it doesn't say finished when odyssey kills the job...
1 parent c94b0ab commit 0be7a65

File tree

6 files changed

+363
-353
lines changed

6 files changed

+363
-353
lines changed

ED/Template/check_run.sh

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ echo ${ncol}
1010

1111
here=`pwd`
1212
lonlat=${here}'/joborder.txt'
13+
desc=`basename ${here}`
1314

1415
#----- Determine the number of polygons to run. -------------------------------------------#
1516
let npolys=`wc -l ${lonlat} | awk '{print $1 }'`-3
@@ -135,23 +136,85 @@ do
135136
treefall=`echo ${oi} | awk '{print $87}'`
136137
#---------------------------------------------------------------------------------------#
137138

139+
#---------------------------------------------------------------------------------------#
140+
# Set some variables to check whether the simulation is running. #
141+
#---------------------------------------------------------------------------------------#
142+
jobname="${desc}-${polyname}"
143+
stdout="${here}/${polyname}/serial_out.out"
144+
stderr="${here}/${polyname}/serial_out.err"
145+
lsfout="${here}/${polyname}/serial_lsf.out"
146+
stopped=
147+
#---------------------------------------------------------------------------------------#
138148

139149

140-
if [ -s ${here}/${polyname}/serial_out.out ]
150+
#---------------------------------------------------------------------------------------#
151+
# Check whether the simulation is still running, and if not, why it isn't. #
152+
#---------------------------------------------------------------------------------------#
153+
if [ -s ${stdout} ]
141154
then
142-
fatal=`grep "FATAL ERROR" ${here}/${polyname}/serial_out.out | wc -l`
143-
simulating=`grep "Simulating: " ${here}/${polyname}/serial_out.out | tail -1`
144-
if [ ${fatal} -gt 0 ]
155+
#----- Check whether the simulation is running, and when in model time it is. -------#
156+
running=`bjobs -J ${jobname} 2> /dev/null | grep RUN | wc -l`
157+
simline=`grep "Simulating: " ${stdout} | tail -1`
158+
runtime=`echo ${simline} | awk '{print $3}'`
159+
#------------------------------------------------------------------------------------#
160+
161+
162+
163+
#----- Check for segmentation violations. -------------------------------------------#
164+
if [ -s ${stderr} ]
165+
then
166+
segv1=`grep -i "sigsegv" ${stderr} | wc -l`
167+
segv2=`grep -i "segmentation fault" ${stderr} | wc -l`
168+
let sigsegv=${segv1}+${segv2}
169+
else
170+
sigsegv=0
171+
fi
172+
#------------------------------------------------------------------------------------#
173+
174+
175+
176+
#----- Check whether met files are missing... (bad start) ---------------------------#
177+
metbs1=`grep "Cannot open met driver input file" ${stdout} | wc -l`
178+
metbs2=`grep "Specify ED_MET_DRIVER_DB properly" ${stdout} | wc -l`
179+
let metmiss=${metbs1}+${metbs2}
180+
#------------------------------------------------------------------------------------#
181+
182+
183+
184+
#----- Check for other possible outcomes. -------------------------------------------#
185+
stopped=`grep "FATAL ERROR" ${stdout} | wc -l`
186+
crashed=`grep "IFLAG1 problem." ${stdout} | wc -l`
187+
the_end=`grep "ED execution ends" ${stdout} | wc -l`
188+
#------------------------------------------------------------------------------------#
189+
190+
191+
192+
#------------------------------------------------------------------------------------#
193+
# Plot a message so the user knows what is going on. #
194+
#------------------------------------------------------------------------------------#
195+
if [ ${running} -gt 0 ] && [ ${sigsegv} -eq 0 ]
196+
then
197+
echo -e ${opt} "${off} :-) ${polyname} is running (${runtime})..."
198+
elif [ ${sigsegv} -gt 0 ]
199+
then
200+
echo -e ${opt} "${off}>:-# ${polyname} HAD SEGMENTATION VIOLATION... <==========="
201+
elif [ ${crashed} -gt 0 ]
202+
then
203+
echo -e ${opt} "${off} :-( ${polyname} HAS CRASHED (RK4 PROBLEM)... <==========="
204+
elif [ ${metmiss} -gt 0 ]
145205
then
146-
echo -e ${opt} ${off}':-( '${polyname}' HAS CRASHED ... <======================'
147-
elif [ -s ${here}/${polyname}/serial_lsf.out ]
206+
echo -e ${opt} "${off} :-/ ${polyname} DID NOT FIND MET DRIVERS... <==========="
207+
elif [ ${stopped} -gt 0 ]
208+
then
209+
echo -e ${opt} "${off} :-S ${polyname} STOPPED (UNKNOWN REASON)... <==========="
210+
elif [ ${the_end} -gt 0 ]
148211
then
149-
echo -e ${opt} ${off}':-D '${polyname}' has finished ...'
212+
echo -e ${opt} "${off}o/\o ${polyname} has finished..."
150213
else
151-
echo -e ${opt} ${off}':-) '${polyname}' is running. '${simulating}'...'
214+
echo -e ${opt} "${off}<:-| ${polyname} status is unknown..."
152215
fi
153216
else
154-
echo -e ${opt} ${off}':-| '${polyname}' is pending ...'
217+
echo -e ${opt} ${off}' :-| '${polyname}' is pending ...'
155218
fi
156219
done
157220

ED/src/dynamics/disturbance.f90

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ subroutine apply_disturbances(cgrid)
5555
use pft_coms , only : include_pft ! ! intent(in)
5656
use allometry , only : area_indices ! ! function
5757
use mortality , only : disturbance_mortality ! ! subroutine
58+
use consts_coms , only : lnexp_max ! ! intent(in)
5859
implicit none
5960
!----- Arguments. -------------------------------------------------------------------!
6061
type(edtype) , target :: cgrid
@@ -245,6 +246,7 @@ subroutine apply_disturbances(cgrid)
245246
if (ploughed .or. abandoned .or. natural .or. logged) then
246247
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
247248
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
249+
total_distrate = min(lnexp_max,max(0.,total_distrate))
248250
dA = csite%area(ipa) * ( 1.0 - exp(- total_distrate) )
249251
area = area + dA
250252
end if
@@ -331,6 +333,7 @@ subroutine apply_disturbances(cgrid)
331333
if (ploughed .or. abandoned .or. natural .or. logged) then
332334
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
333335
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
336+
total_distrate = min(lnexp_max,max(0.,total_distrate))
334337
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))
335338

336339
area_fac = dA / csite%area(onsp+new_lu)
@@ -602,6 +605,7 @@ subroutine apply_disturbances(cgrid)
602605
if (ploughed .or. abandoned .or. natural .or. logged) then
603606
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
604607
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
608+
total_distrate = min(lnexp_max,max(0.,total_distrate))
605609
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))
606610
area = area + dA
607611
end if
@@ -697,6 +701,7 @@ subroutine apply_disturbances(cgrid)
697701
if (ploughed) then
698702
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
699703
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
704+
total_distrate = min(lnexp_max,max(0.,total_distrate))
700705
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))
701706

702707
area_fac = dA / csite%area(onsp+new_lu)
@@ -713,6 +718,7 @@ subroutine apply_disturbances(cgrid)
713718
i = (new_lu-2)*mypfts+1+ipft
714719
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
715720
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
721+
total_distrate = min(lnexp_max,max(0.,total_distrate))
716722
dA = csite%area(ipa) &
717723
* (1.0 - exp(- total_distrate))
718724
dA = dA / real(mypfts)
@@ -1113,14 +1119,14 @@ subroutine site_disturbance_rates(month, year, cgrid)
11131119

11141120
!------------------------------------------------------------------------!
11151121
! If this patch is secondary and mature, compute the weighted aver- !
1116-
! age of the probability of harvest, using the number of plants as the !
1117-
! weight. !
1122+
! age of the probability of harvest, using the basal area as the weight. !
11181123
!------------------------------------------------------------------------!
11191124
if (mature_plantation .or. mature_secondary) then
11201125
cohortloop: do ico=1,cpatch%ncohorts
11211126
ipft = cpatch%pft(ico)
11221127
if (cpatch%dbh(ico) >= cpoly%mindbh_secondary(ipft,isi)) then
1123-
weight = cpatch%nplant(ico) * csite%area(ipa)
1128+
weight = cpatch%nplant(ico) * cpatch%basarea(ico) &
1129+
* csite%area(ipa)
11241130
pharvest = pharvest &
11251131
+ cpoly%probharv_secondary(ipft,isi) * weight
11261132
sumweight = sumweight + weight
@@ -1135,7 +1141,8 @@ subroutine site_disturbance_rates(month, year, cgrid)
11351141
end if
11361142
end do patchloop
11371143
end if
1138-
cpoly%disturbance_rates(2,2,isi) = -0.5 * log(1.0 - pharvest)
1144+
!----- Convert the probability into disturbance rate. -------------------------#
1145+
cpoly%disturbance_rates(2,2,isi) = - log(1.0 - pharvest)
11391146
!------------------------------------------------------------------------------!
11401147

11411148

ED/src/dynamics/soil_respiration.f90

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ subroutine resp_f_decomp(csite,ipa,Lc)
389389
use ed_state_vars, only : sitetype ! ! structure
390390
use decomp_coms , only : r_stsc & ! intent(in)
391391
, N_immobil_supply_scale & ! intent(in)
392-
, K1 & ! intent(in)
392+
, decay_rate_stsc & ! intent(in)
393393
, n_decomp_lim ! ! intent(in)
394394
use pft_coms , only : c2n_structural & ! intent(in)
395395
, c2n_slow ! ! intent(in)
@@ -415,7 +415,7 @@ subroutine resp_f_decomp(csite,ipa,Lc)
415415
end if
416416

417417
if (n_decomp_lim == 1) then
418-
N_immobilization_demand = csite%A_decomp(ipa) * Lc * K1 &
418+
N_immobilization_demand = csite%A_decomp(ipa) * Lc * decay_rate_stsc &
419419
* csite%structural_soil_C(ipa) &
420420
* ((1.0 - r_stsc) / c2n_slow - 1.0 / c2n_structural)
421421

@@ -443,15 +443,15 @@ end subroutine resp_f_decomp
443443
!------------------------------------------------------------------------------------------!
444444
subroutine resp_rh(csite,ipa,Lc)
445445

446-
use ed_state_vars, only : sitetype ! ! structure
447-
use consts_coms , only : kgCday_2_umols ! ! intent(in)
448-
use decomp_coms , only : K1 & ! intent(in)
449-
, K2 & ! intent(in)
450-
, K3 & ! intent(in)
451-
, r_fsc & ! intent(in)
452-
, r_ssc & ! intent(in)
453-
, r_stsc & ! intent(in)
454-
, cwd_frac ! ! intent(in)
446+
use ed_state_vars, only : sitetype ! ! structure
447+
use consts_coms , only : kgCday_2_umols ! ! intent(in)
448+
use decomp_coms , only : decay_rate_stsc & ! intent(in)
449+
, decay_rate_fsc & ! intent(in)
450+
, decay_rate_ssc & ! intent(in)
451+
, r_fsc & ! intent(in)
452+
, r_ssc & ! intent(in)
453+
, r_stsc & ! intent(in)
454+
, cwd_frac ! ! intent(in)
455455

456456
implicit none
457457
!----- Arguments. ----------------------------------------------------------------------!
@@ -467,10 +467,12 @@ subroutine resp_rh(csite,ipa,Lc)
467467

468468

469469
!----- The following variables have units of [umol_CO2/m2/s]. --------------------------!
470-
fast_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * K2 * csite%fast_soil_C(ipa)
471-
structural_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * Lc * K1 &
470+
fast_C_loss = kgCday_2_umols * csite%A_decomp(ipa) &
471+
* decay_rate_fsc * csite%fast_soil_C(ipa)
472+
structural_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * Lc * decay_rate_stsc &
472473
* csite%structural_soil_C(ipa)* csite%f_decomp(ipa)
473-
slow_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * K3 * csite%slow_soil_C(ipa)
474+
slow_C_loss = kgCday_2_umols * csite%A_decomp(ipa) &
475+
* decay_rate_ssc * csite%slow_soil_C(ipa)
474476
!---------------------------------------------------------------------------------------!
475477

476478
!----- Find the heterotrophic respiration and the fraction due to CWD. -----------------!
@@ -498,9 +500,9 @@ subroutine update_C_and_N_pools(cgrid)
498500
use ed_state_vars, only : edtype & ! structure
499501
, polygontype & ! structure
500502
, sitetype ! ! structure
501-
use decomp_coms , only : K1 & ! intent(in)
502-
, K2 & ! intent(in)
503-
, K3 & ! intent(in)
503+
use decomp_coms , only : decay_rate_fsc & ! intent(in)
504+
, decay_rate_stsc & ! intent(in)
505+
, decay_rate_ssc & ! intent(in)
504506
, r_stsc ! ! intent(in)
505507
use pft_coms , only : c2n_slow & ! intent(in)
506508
, c2n_structural ! ! intent(in)
@@ -544,23 +546,26 @@ subroutine update_C_and_N_pools(cgrid)
544546
end if
545547

546548
!----- Fast pools. ------------------------------------------------------------!
547-
fast_C_loss = csite%today_A_decomp(ipa) * K2 * csite%fast_soil_C(ipa)
548-
fast_N_loss = csite%today_A_decomp(ipa) * K2 * csite%fast_soil_N(ipa)
549+
fast_C_loss = csite%today_A_decomp(ipa) * decay_rate_fsc &
550+
* csite%fast_soil_C(ipa)
551+
fast_N_loss = csite%today_A_decomp(ipa) * decay_rate_fsc &
552+
* csite%fast_soil_N(ipa)
549553

550554
!----- Structural pools. ------------------------------------------------------!
551-
structural_C_loss = csite%today_Af_decomp(ipa) * Lc * K1 &
555+
structural_C_loss = csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
552556
* csite%structural_soil_C(ipa)
553-
structural_L_loss = csite%today_Af_decomp(ipa) * Lc * K1 &
557+
structural_L_loss = csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
554558
* csite%structural_soil_L(ipa)
555559

556560
!----- Slow pools. ------------------------------------------------------------!
557561
slow_C_input = (1.0 - r_stsc) * structural_C_loss
558-
slow_C_loss = csite%today_A_decomp(ipa) * K3 * csite%slow_soil_C(ipa)
562+
slow_C_loss = csite%today_A_decomp(ipa) * decay_rate_ssc &
563+
* csite%slow_soil_C(ipa)
559564

560565
!----- Mineralized pool. ------------------------------------------------------!
561566
csite%mineralized_N_input = fast_N_loss + slow_C_loss / c2n_slow
562567
csite%mineralized_N_loss = csite%total_plant_nitrogen_uptake(ipa) &
563-
+ csite%today_Af_decomp(ipa) * Lc * K1 &
568+
+ csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
564569
* csite%structural_soil_C(ipa) &
565570
* ( (1.0 - r_stsc) / c2n_slow - 1.0 / c2n_structural)
566571

0 commit comments

Comments
 (0)