Skip to content

Commit

Permalink
1. Small correction in selective logging, there was a bogus 0.5 facto…
Browse files Browse the repository at this point in the history
…r 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...
  • Loading branch information
Marcos Longo committed Aug 29, 2012
1 parent c94b0ab commit 0be7a65
Show file tree
Hide file tree
Showing 6 changed files with 363 additions and 353 deletions.
81 changes: 72 additions & 9 deletions ED/Template/check_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echo ${ncol}

here=`pwd`
lonlat=${here}'/joborder.txt'
desc=`basename ${here}`

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

#---------------------------------------------------------------------------------------#
# Set some variables to check whether the simulation is running. #
#---------------------------------------------------------------------------------------#
jobname="${desc}-${polyname}"
stdout="${here}/${polyname}/serial_out.out"
stderr="${here}/${polyname}/serial_out.err"
lsfout="${here}/${polyname}/serial_lsf.out"
stopped=
#---------------------------------------------------------------------------------------#


if [ -s ${here}/${polyname}/serial_out.out ]
#---------------------------------------------------------------------------------------#
# Check whether the simulation is still running, and if not, why it isn't. #
#---------------------------------------------------------------------------------------#
if [ -s ${stdout} ]
then
fatal=`grep "FATAL ERROR" ${here}/${polyname}/serial_out.out | wc -l`
simulating=`grep "Simulating: " ${here}/${polyname}/serial_out.out | tail -1`
if [ ${fatal} -gt 0 ]
#----- Check whether the simulation is running, and when in model time it is. -------#
running=`bjobs -J ${jobname} 2> /dev/null | grep RUN | wc -l`
simline=`grep "Simulating: " ${stdout} | tail -1`
runtime=`echo ${simline} | awk '{print $3}'`
#------------------------------------------------------------------------------------#



#----- Check for segmentation violations. -------------------------------------------#
if [ -s ${stderr} ]
then
segv1=`grep -i "sigsegv" ${stderr} | wc -l`
segv2=`grep -i "segmentation fault" ${stderr} | wc -l`
let sigsegv=${segv1}+${segv2}
else
sigsegv=0
fi
#------------------------------------------------------------------------------------#



#----- Check whether met files are missing... (bad start) ---------------------------#
metbs1=`grep "Cannot open met driver input file" ${stdout} | wc -l`
metbs2=`grep "Specify ED_MET_DRIVER_DB properly" ${stdout} | wc -l`
let metmiss=${metbs1}+${metbs2}
#------------------------------------------------------------------------------------#



#----- Check for other possible outcomes. -------------------------------------------#
stopped=`grep "FATAL ERROR" ${stdout} | wc -l`
crashed=`grep "IFLAG1 problem." ${stdout} | wc -l`
the_end=`grep "ED execution ends" ${stdout} | wc -l`
#------------------------------------------------------------------------------------#



#------------------------------------------------------------------------------------#
# Plot a message so the user knows what is going on. #
#------------------------------------------------------------------------------------#
if [ ${running} -gt 0 ] && [ ${sigsegv} -eq 0 ]
then
echo -e ${opt} "${off} :-) ${polyname} is running (${runtime})..."
elif [ ${sigsegv} -gt 0 ]
then
echo -e ${opt} "${off}>:-# ${polyname} HAD SEGMENTATION VIOLATION... <==========="
elif [ ${crashed} -gt 0 ]
then
echo -e ${opt} "${off} :-( ${polyname} HAS CRASHED (RK4 PROBLEM)... <==========="
elif [ ${metmiss} -gt 0 ]
then
echo -e ${opt} ${off}':-( '${polyname}' HAS CRASHED ... <======================'
elif [ -s ${here}/${polyname}/serial_lsf.out ]
echo -e ${opt} "${off} :-/ ${polyname} DID NOT FIND MET DRIVERS... <==========="
elif [ ${stopped} -gt 0 ]
then
echo -e ${opt} "${off} :-S ${polyname} STOPPED (UNKNOWN REASON)... <==========="
elif [ ${the_end} -gt 0 ]
then
echo -e ${opt} ${off}':-D '${polyname}' has finished ...'
echo -e ${opt} "${off}o/\o ${polyname} has finished..."
else
echo -e ${opt} ${off}':-) '${polyname}' is running. '${simulating}'...'
echo -e ${opt} "${off}<:-| ${polyname} status is unknown..."
fi
else
echo -e ${opt} ${off}':-| '${polyname}' is pending ...'
echo -e ${opt} ${off}' :-| '${polyname}' is pending ...'
fi
done

15 changes: 11 additions & 4 deletions ED/src/dynamics/disturbance.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ subroutine apply_disturbances(cgrid)
use pft_coms , only : include_pft ! ! intent(in)
use allometry , only : area_indices ! ! function
use mortality , only : disturbance_mortality ! ! subroutine
use consts_coms , only : lnexp_max ! ! intent(in)
implicit none
!----- Arguments. -------------------------------------------------------------------!
type(edtype) , target :: cgrid
Expand Down Expand Up @@ -245,6 +246,7 @@ subroutine apply_disturbances(cgrid)
if (ploughed .or. abandoned .or. natural .or. logged) then
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
total_distrate = min(lnexp_max,max(0.,total_distrate))
dA = csite%area(ipa) * ( 1.0 - exp(- total_distrate) )
area = area + dA
end if
Expand Down Expand Up @@ -331,6 +333,7 @@ subroutine apply_disturbances(cgrid)
if (ploughed .or. abandoned .or. natural .or. logged) then
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
total_distrate = min(lnexp_max,max(0.,total_distrate))
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))

area_fac = dA / csite%area(onsp+new_lu)
Expand Down Expand Up @@ -602,6 +605,7 @@ subroutine apply_disturbances(cgrid)
if (ploughed .or. abandoned .or. natural .or. logged) then
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
total_distrate = min(lnexp_max,max(0.,total_distrate))
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))
area = area + dA
end if
Expand Down Expand Up @@ -697,6 +701,7 @@ subroutine apply_disturbances(cgrid)
if (ploughed) then
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
total_distrate = min(lnexp_max,max(0.,total_distrate))
dA = csite%area(ipa) * (1.0 - exp(- total_distrate))

area_fac = dA / csite%area(onsp+new_lu)
Expand All @@ -713,6 +718,7 @@ subroutine apply_disturbances(cgrid)
i = (new_lu-2)*mypfts+1+ipft
total_distrate = cpoly%disturbance_rates (new_lu,old_lu,isi) &
+ cpoly%disturbance_memory(new_lu,old_lu,isi)
total_distrate = min(lnexp_max,max(0.,total_distrate))
dA = csite%area(ipa) &
* (1.0 - exp(- total_distrate))
dA = dA / real(mypfts)
Expand Down Expand Up @@ -1113,14 +1119,14 @@ subroutine site_disturbance_rates(month, year, cgrid)

!------------------------------------------------------------------------!
! If this patch is secondary and mature, compute the weighted aver- !
! age of the probability of harvest, using the number of plants as the !
! weight. !
! age of the probability of harvest, using the basal area as the weight. !
!------------------------------------------------------------------------!
if (mature_plantation .or. mature_secondary) then
cohortloop: do ico=1,cpatch%ncohorts
ipft = cpatch%pft(ico)
if (cpatch%dbh(ico) >= cpoly%mindbh_secondary(ipft,isi)) then
weight = cpatch%nplant(ico) * csite%area(ipa)
weight = cpatch%nplant(ico) * cpatch%basarea(ico) &
* csite%area(ipa)
pharvest = pharvest &
+ cpoly%probharv_secondary(ipft,isi) * weight
sumweight = sumweight + weight
Expand All @@ -1135,7 +1141,8 @@ subroutine site_disturbance_rates(month, year, cgrid)
end if
end do patchloop
end if
cpoly%disturbance_rates(2,2,isi) = -0.5 * log(1.0 - pharvest)
!----- Convert the probability into disturbance rate. -------------------------#
cpoly%disturbance_rates(2,2,isi) = - log(1.0 - pharvest)
!------------------------------------------------------------------------------!


Expand Down
51 changes: 28 additions & 23 deletions ED/src/dynamics/soil_respiration.f90
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ subroutine resp_f_decomp(csite,ipa,Lc)
use ed_state_vars, only : sitetype ! ! structure
use decomp_coms , only : r_stsc & ! intent(in)
, N_immobil_supply_scale & ! intent(in)
, K1 & ! intent(in)
, decay_rate_stsc & ! intent(in)
, n_decomp_lim ! ! intent(in)
use pft_coms , only : c2n_structural & ! intent(in)
, c2n_slow ! ! intent(in)
Expand All @@ -415,7 +415,7 @@ subroutine resp_f_decomp(csite,ipa,Lc)
end if

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

Expand Down Expand Up @@ -443,15 +443,15 @@ end subroutine resp_f_decomp
!------------------------------------------------------------------------------------------!
subroutine resp_rh(csite,ipa,Lc)

use ed_state_vars, only : sitetype ! ! structure
use consts_coms , only : kgCday_2_umols ! ! intent(in)
use decomp_coms , only : K1 & ! intent(in)
, K2 & ! intent(in)
, K3 & ! intent(in)
, r_fsc & ! intent(in)
, r_ssc & ! intent(in)
, r_stsc & ! intent(in)
, cwd_frac ! ! intent(in)
use ed_state_vars, only : sitetype ! ! structure
use consts_coms , only : kgCday_2_umols ! ! intent(in)
use decomp_coms , only : decay_rate_stsc & ! intent(in)
, decay_rate_fsc & ! intent(in)
, decay_rate_ssc & ! intent(in)
, r_fsc & ! intent(in)
, r_ssc & ! intent(in)
, r_stsc & ! intent(in)
, cwd_frac ! ! intent(in)

implicit none
!----- Arguments. ----------------------------------------------------------------------!
Expand All @@ -467,10 +467,12 @@ subroutine resp_rh(csite,ipa,Lc)


!----- The following variables have units of [umol_CO2/m2/s]. --------------------------!
fast_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * K2 * csite%fast_soil_C(ipa)
structural_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * Lc * K1 &
fast_C_loss = kgCday_2_umols * csite%A_decomp(ipa) &
* decay_rate_fsc * csite%fast_soil_C(ipa)
structural_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * Lc * decay_rate_stsc &
* csite%structural_soil_C(ipa)* csite%f_decomp(ipa)
slow_C_loss = kgCday_2_umols * csite%A_decomp(ipa) * K3 * csite%slow_soil_C(ipa)
slow_C_loss = kgCday_2_umols * csite%A_decomp(ipa) &
* decay_rate_ssc * csite%slow_soil_C(ipa)
!---------------------------------------------------------------------------------------!

!----- Find the heterotrophic respiration and the fraction due to CWD. -----------------!
Expand Down Expand Up @@ -498,9 +500,9 @@ subroutine update_C_and_N_pools(cgrid)
use ed_state_vars, only : edtype & ! structure
, polygontype & ! structure
, sitetype ! ! structure
use decomp_coms , only : K1 & ! intent(in)
, K2 & ! intent(in)
, K3 & ! intent(in)
use decomp_coms , only : decay_rate_fsc & ! intent(in)
, decay_rate_stsc & ! intent(in)
, decay_rate_ssc & ! intent(in)
, r_stsc ! ! intent(in)
use pft_coms , only : c2n_slow & ! intent(in)
, c2n_structural ! ! intent(in)
Expand Down Expand Up @@ -544,23 +546,26 @@ subroutine update_C_and_N_pools(cgrid)
end if

!----- Fast pools. ------------------------------------------------------------!
fast_C_loss = csite%today_A_decomp(ipa) * K2 * csite%fast_soil_C(ipa)
fast_N_loss = csite%today_A_decomp(ipa) * K2 * csite%fast_soil_N(ipa)
fast_C_loss = csite%today_A_decomp(ipa) * decay_rate_fsc &
* csite%fast_soil_C(ipa)
fast_N_loss = csite%today_A_decomp(ipa) * decay_rate_fsc &
* csite%fast_soil_N(ipa)

!----- Structural pools. ------------------------------------------------------!
structural_C_loss = csite%today_Af_decomp(ipa) * Lc * K1 &
structural_C_loss = csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
* csite%structural_soil_C(ipa)
structural_L_loss = csite%today_Af_decomp(ipa) * Lc * K1 &
structural_L_loss = csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
* csite%structural_soil_L(ipa)

!----- Slow pools. ------------------------------------------------------------!
slow_C_input = (1.0 - r_stsc) * structural_C_loss
slow_C_loss = csite%today_A_decomp(ipa) * K3 * csite%slow_soil_C(ipa)
slow_C_loss = csite%today_A_decomp(ipa) * decay_rate_ssc &
* csite%slow_soil_C(ipa)

!----- Mineralized pool. ------------------------------------------------------!
csite%mineralized_N_input = fast_N_loss + slow_C_loss / c2n_slow
csite%mineralized_N_loss = csite%total_plant_nitrogen_uptake(ipa) &
+ csite%today_Af_decomp(ipa) * Lc * K1 &
+ csite%today_Af_decomp(ipa) * Lc * decay_rate_stsc &
* csite%structural_soil_C(ipa) &
* ( (1.0 - r_stsc) / c2n_slow - 1.0 / c2n_structural)

Expand Down
Loading

0 comments on commit 0be7a65

Please sign in to comment.