Skip to content

Commit 1128b83

Browse files
authored
Merge pull request #22 from ACME-Climate/bishtgautam/fixes-for-gcc5
Fixes for gcc5
2 parents a72c92c + 054405b commit 1128b83

File tree

13 files changed

+214
-174
lines changed

13 files changed

+214
-174
lines changed

src/betr/betr_core/TracerParamsMod.F90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ subroutine calc_bunsen_coeff(bounds, lbj, ubj, jtops, numf, filter, &
570570
c = filter(fc)
571571
if(n>=jtops(c))then
572572
bunsencef_col(c,n, k)= henrycef_col(c,n,k)*t_soisno(c,n)/12.2_r8
573-
! if(n==1)print*,k,betrtracer_vars%tracernames(trcid),henrycef_col(c,n,k)
574573
!add the pH effect for tracers that can exist in multiple aqueous phases
575574
if(is_h2o(trcid))then
576575
!for water isotopes
@@ -1376,8 +1375,6 @@ subroutine calc_tracer_infiltration(bounds, jtops, numf, filter, bunsencef_topso
13761375
tracer_flx_infl(c,j) = bunsencef_topsoi(c,betrtracer_vars%volatilegroupid(j)) * &
13771376
tracerboundarycond_vars%tracer_gwdif_concflux_top_col(c,1,j) * qflx_adv(c,0)
13781377

1379-
! print*,'trcflx',j,betrtracer_vars%tracernames(j),tracer_flx_infl(c,j),&
1380-
! bunsencef_topsoi(c,betrtracer_vars%volatilegroupid(j))
13811378
else
13821379
tracer_flx_infl(c,j) = 0._r8
13831380
endif
@@ -1691,7 +1688,6 @@ subroutine calc_aerecond(bounds, col, pft, num_soilp, filter_soilp, jwt, &
16911688
do fp = 1, num_soilp
16921689
p = filter_soilp (fp)
16931690
c = pft%column(p)
1694-
16951691
! Calculate aerenchyma diffusion
16961692
if (j > jwt(c) .and. t_soisno(c,j) > tfrz .and. pftvarcon%is_grass_patch(pft%itype(p))) then
16971693
! Attn EK: This calculation of aerenchyma properties is very uncertain. Let's check in once all

src/betr/betr_core/TracerStateType.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ function int_mass_mobile_col(this, lbj, ubj, c, j, dz, bstatus)result(int_mass)
319319
call bstatus%reset()
320320

321321
int_mass = dot_sum(this%tracer_conc_mobile_col(c,lbj:ubj,j), dz, bstatus)
322-
323322
end function int_mass_mobile_col
324323

325324
!-----------------------------------------------------------------------
@@ -431,7 +430,6 @@ subroutine retrieve_hist(this, bounds, lbj, ubj, state_2d, state_1d, betrtracer_
431430
state_1d(begc:endc, addone(idtemp1d))=this%tracer_soi_molarmass_col(begc:endc, jj)
432431
state_1d(begc:endc, addone(idtemp1d))=this%end_tracer_molarmass_col(begc:endc, jj)
433432
enddo
434-
435433
end associate
436434
end subroutine retrieve_hist
437435

src/betr/betr_dtype/BeTR_biogeophysInputType.F90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ module BeTR_biogeophysInputType
1515
!waterstate
1616
real(r8), pointer :: h2osoi_liq_col(:,:) => null() !liquid water (kg/m2) (new) (-nlevsno+1:nlevgrnd)
1717
real(r8), pointer :: h2osoi_ice_col(:,:) => null() !ice lens (kg/m2) (new) (-nlevsno+1:nlevgrnd)
18-
real(r8), pointer :: h2osoi_liq_old(:,:) => null() !liquid water (kg/m2) (old) (-nlevsno+1:nlevgrnd)
19-
real(r8), pointer :: h2osoi_ice_old(:,:) => null() !ice lens (kg/m2) (old) (-nlevsno+1:nlevgrnd)
2018
real(r8), pointer :: h2osoi_liqvol_col(:,:) => null() !volumetric liquid water content
2119
real(r8), pointer :: h2osoi_icevol_col(:,:) => null() !volumetric ice water content
2220
real(r8), pointer :: h2osoi_vol_col(:,:) => null() !volumetric water content, total
@@ -182,8 +180,6 @@ subroutine InitAllocate(this, bounds)
182180
allocate (this%finundated_col( begc:endc ) ) ! fraction of column that is inundated, this is for bgc caclulation in betr
183181
allocate (this%h2osoi_liq_col( begc:endc,lbj:ubj ) ) !liquid water (kg/m2) (new) (-nlevsno+1:nlevgrnd)
184182
allocate (this%h2osoi_ice_col( begc:endc,lbj:ubj ) ) !ice lens (kg/m2) (new) (-nlevsno+1:nlevgrnd)
185-
allocate (this%h2osoi_liq_old( begc:endc,lbj:ubj ) ) !liquid water (kg/m2) (old) (-nlevsno+1:nlevgrnd)
186-
allocate (this%h2osoi_ice_old( begc:endc,lbj:ubj ) ) !ice lens (kg/m2) (old) (-nlevsno+1:nlevgrnd)
187183
allocate (this%h2osoi_liqvol_col( begc:endc,lbj:ubj ) ) !volumetric liquid water content
188184
allocate (this%h2osoi_icevol_col( begc:endc,lbj:ubj ) ) !volumetric ice water content
189185
allocate (this%h2osoi_vol_col( begc:endc,lbj:ubj ) ) !volumetric water content, total

src/betr/betr_main/BetrBGCMod.F90

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ subroutine tracer_gw_transport(betr_time, bounds, lbj, ubj, col, pft, jtops, num
617617
betrtracer_vars, &
618618
tracercoeff_vars, tracerstate_vars,bstatus)
619619
if(bstatus%check_status())return
620-
!x print*,'do_transport'
621620
!do diffusive and advective transport, assuming aqueous and gaseous phase are in equilbrium
622621
do kk = 1 , 2
623622
if (transp_pathway(kk) == diffusion_scheme .and. diffusion_on) then
@@ -734,7 +733,6 @@ subroutine do_tracer_advection(betr_time, bounds, lbj, ubj, col, pft, &
734733
character(len=255) :: subname = 'do_tracer_advection'
735734
character(len=betr_errmsg_len) :: msg
736735

737-
!x print*,'do_advection'
738736
call bstatus%reset()
739737
SHR_ASSERT_ALL((ubound(jtops) == (/bounds%endc/)) , errMsg(mod_filename,__LINE__),bstatus)
740738
if(bstatus%check_status())return
@@ -884,7 +882,7 @@ subroutine do_tracer_advection(betr_time, bounds, lbj, ubj, col, pft, &
884882
tracer_conc_mobile_col(bounds%begc:bounds%endc, lbj:ubj,adv_trc_group(1:ntrcs)), &
885883
trc_conc_out(:,:,1:ntrcs), &
886884
leaching_mass(bounds%begc:bounds%endc,1:ntrcs), seep_mass(bounds%begc:bounds%endc, 1:ntrcs))
887-
!x print*,'semilag',bstatus%check_status(),trim(bstatus%print_msg())
885+
888886
if(bstatus%check_status())return
889887
!do soil-root tracer exchange
890888
do k = 1, ntrcs
@@ -917,7 +915,6 @@ subroutine do_tracer_advection(betr_time, bounds, lbj, ubj, col, pft, &
917915
endif
918916
enddo
919917

920-
!print*,'!do error budget and tracer flux update'
921918
do k = 1, ntrcs
922919
trcid = adv_trc_group(k)
923920
do fc = 1, num_soilc
@@ -1250,8 +1247,9 @@ subroutine do_tracer_gw_diffusion(bounds, lbj, ubj, jtops, num_soilc, filter_soi
12501247
diff_surf(c,k) * dtime_loc(c)
12511248
endif
12521249
else
1253-
write(msg,*) 'mass bal error dif '//trim(tracernames(trcid))//new_line('A'), 'mass 0/1',mass0, mass1,'col=',c, &
1254-
new_line('A')//'err=', err_tracer(c,k), 'dmass=',dmass(c,k), ' dif=', diff_surf(c,k)*dtime_loc(c), &
1250+
write(msg,*) 'mass bal error dif '//trim(tracernames(trcid))//new_line('A'), 'mass 0/1',mass0, &
1251+
mass1,'col=',c, &
1252+
new_line('A')//'err=', err_tracer(c,k), 'dmass=',dmass(c,k), ' dif=', diff_surf(c,k)*dtime_loc(c), &
12551253
' prod=',dot_sum(x=local_source(c,jtops(c):ubj,k),y=dz(c,jtops(c):ubj),bstatus=bstatus)*dtime_loc(c)
12561254

12571255
if(bstatus%check_status())return

src/betr/betr_main/TracerBalanceMod.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ subroutine betr_tracer_massbalance_check(betr_time, bounds, col, numf, filter,
142142
else
143143
err_rel = errtracer(c,kk)/max(abs(beg_tracer_molarmass(c,kk)),abs(end_tracer_molarmass(c,kk)))
144144
endif
145-
146145
if(abs(err_rel)>err_min_rel .and. do_betr_output)then
147146
write(msg,*)'error exceeds the tolerance for tracer '//tracernames(kk), &
148147
new_line('A'),'err=',errtracer(c,kk), ' col=',c, &
@@ -154,6 +153,8 @@ subroutine betr_tracer_massbalance_check(betr_time, bounds, col, numf, filter,
154153
new_line('A'),errMsg(mod_filename, __LINE__)
155154
call tracerflux_vars%flux_display(c,kk,betrtracer_vars, msg1)
156155
msg = trim(msg)//new_line('A')//trim(msg1)
156+
print*,trim(msg)
157+
pause
157158
call betr_status%set_msg(msg=msg, err=-1)
158159
return
159160
endif
@@ -229,6 +230,7 @@ subroutine betr_tracer_mass_summary(bounds, col, lbj, ubj, numf, filter, betrtra
229230
frozenid(jj),dz(c,1:nlevtrc_soil),betr_status)
230231
if(betr_status%check_status())return
231232
endif
233+
232234
enddo
233235
enddo
234236
end associate

src/betr/betr_math/MathfuncMod.F90

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module MathfuncMod
3131
public :: pd_decomp
3232
public :: num2str
3333
public :: fpmax
34-
34+
public :: bisnan
3535
interface cumsum
3636
module procedure cumsum_v, cumsum_m
3737
end interface cumsum
@@ -586,4 +586,17 @@ function fpmax(inval)result(ans)
586586
ans = max(inval, 0._r8)
587587
return
588588
end function fpmax
589+
590+
!-------------------------------------------------------------------------------
591+
function bisnan(inval)result(ans)
592+
593+
!DESCRIPTION
594+
!determine if the variable is nan
595+
implicit none
596+
real(r8), intent(in) :: inval
597+
598+
logical :: ans
599+
600+
ans = (inval/=inval)
601+
end function bisnan
589602
end module MathfuncMod

src/betr/betr_rxns/MockBGCReactionsType.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ subroutine set_boundary_conditions(this, bounds, num_soilc, filter_soilc, dz_top
250250
do fc = 1, num_soilc
251251
c = filter_soilc(fc)
252252
irt = 1.e3_r8/(forc_tbot(c)*rgas)
253-
254253
!eventually, the following code will be implemented using polymorphism
255254
tracerboundarycond_vars%tracer_gwdif_concflux_top_col(c,1:2,betrtracer_vars%id_trc_n2) = forc_pbot(c)*0.78084_r8*irt !mol m-3, contant boundary condition, as concentration
256255
tracerboundarycond_vars%tracer_gwdif_concflux_top_col(c,1:2,betrtracer_vars%id_trc_o2) = forc_pbot(c)*0.20946_r8*irt !mol m-3, contant boundary condition, as concentration

src/driver/alm/ALMbetrNLMod.F90

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ subroutine betr_readNL(NLFilename)
4040
character(len=1), parameter :: quote = ''''
4141
namelist / betr_inparm / reaction_method, &
4242
advection_on, diffusion_on, reaction_on, ebullition_on
43-
43+
logical :: esm_on
4444
! ----------------------------------------------------------------------
4545
! Read namelist from standard input.
4646
! ----------------------------------------------------------------------
@@ -49,8 +49,8 @@ subroutine betr_readNL(NLFilename)
4949
advection_on = .true.
5050
diffusion_on = .true.
5151
reaction_on = .true.
52-
ebullition_on =.true.
53-
52+
ebullition_on = .true.
53+
esm_on = .true.
5454
if ( masterproc )then
5555

5656
unitn = getavu()
@@ -75,6 +75,7 @@ subroutine betr_readNL(NLFilename)
7575

7676
write(betr_namelist_buffer,*) '&betr_parameters'//new_line('A'), &
7777
' reaction_method='//quote//trim(reaction_method)//quote//new_line('A'), &
78+
' esm_on=',trim(log2str(esm_on)),new_line('A'),&
7879
' advection_on=',trim(log2str(advection_on)),new_line('A'), &
7980
' diffusion_on=',trim(log2str(diffusion_on)),new_line('A'), &
8081
' reaction_on=',trim(log2str(reaction_on)),new_line('A'), &

src/driver/alm/BeTRSimulationALM.F90

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ module BeTRSimulationALM
3434
procedure, public :: StepWithDrainage => ALMStepWithDrainage
3535
procedure, public :: SetBiophysForcing => ALMSetBiophysForcing
3636
!unique subroutines
37-
procedure, public :: DiagnoseDtracerFreezeThaw => ALMDiagnoseDtracerFreezeThaw
3837
procedure, public :: CalcDewSubFlux => ALMCalcDewSubFlux
3938
procedure, public :: SoilFluxStateRecv => ALMBetrSoilFluxStateRecv
4039
procedure, public :: CalcSmpL => ALMCalcSmpL
4140
procedure, public :: PlantSoilBGCSend => ALMBetrPlantSoilBGCSend
4241
procedure, public :: PlantSoilBGCRecv => ALMBetrPlantSoilBGCRecv
42+
procedure, public :: set_active => ALMset_active
4343
end type betr_simulation_alm_type
4444

4545
public :: create_betr_simulation_alm
@@ -207,6 +207,24 @@ subroutine ALMStepWithoutDrainage(this, bounds, col, pft)
207207
call endrun(msg=this%bsimstatus%print_msg())
208208
end subroutine ALMStepWithoutDrainage
209209

210+
!---------------------------------------------------------------------------------
211+
subroutine ALMset_active(this,bounds,col)
212+
213+
!
214+
!DESCRIPTION
215+
!activate columuns that are active in alm
216+
use ColumnType , only : column_type
217+
implicit none
218+
! !ARGUMENTS:
219+
class(betr_simulation_alm_type) , intent(inout) :: this
220+
type(bounds_type) , intent(in) :: bounds
221+
type(column_type) , intent(in) :: col ! column type
222+
223+
integer :: c
224+
do c = bounds%begc, bounds%endc
225+
this%active_col(c) = (this%active_col(c) .and. col%active(c))
226+
enddo
227+
end subroutine ALMset_active
210228
!---------------------------------------------------------------------------------
211229
subroutine ALMStepWithDrainage(this, bounds, col)
212230
!DESCRIPTION
@@ -523,43 +541,6 @@ subroutine ALMBetrPlantSoilBGCRecv(this, bounds, num_soilc, filter_soilc,&
523541
end subroutine ALMBetrPlantSoilBGCRecv
524542
!------------------------------------------------------------------------
525543

526-
subroutine ALMDiagnoseDtracerFreezeThaw(this, bounds, num_nolakec, filter_nolakec, col, lun)
527-
!
528-
! DESCRIPTION
529-
! aqueous tracer partition based on freeze-thaw
530-
!
531-
! USES
532-
use ColumnType , only : column_type
533-
use LandunitType , only : landunit_type
534-
use WaterStateType , only : waterstate_type
535-
implicit none
536-
!
537-
! Arguments
538-
class(betr_simulation_alm_type), intent(inout) :: this
539-
type(bounds_type) , intent(in) :: bounds
540-
integer , intent(in) :: num_nolakec ! number of column non-lake points in column filter
541-
integer , intent(in) :: filter_nolakec(:) ! column filter for non-lake points
542-
type(landunit_type) , intent(in) :: lun
543-
! type(waterstate_type), intent(in) :: waterstate_vars
544-
type(column_type) , intent(in) :: col ! column type
545-
546-
!temporary variables
547-
type(betr_bounds_type) :: betr_bounds
548-
integer :: fc, c
549-
550-
call this%BeTRSetBounds(betr_bounds)
551-
552-
call this%BeTRSetcps(bounds, col)
553-
554-
do fc = 1, num_nolakec
555-
c = filter_nolakec(fc)
556-
if(.not. this%active_col(c))cycle
557-
call this%betr(c)%diagnose_dtracer_freeze_thaw(betr_bounds, this%num_soilc, this%filter_soilc, &
558-
this%biophys_forc(c))
559-
enddo
560-
end subroutine ALMDiagnoseDtracerFreezeThaw
561-
562-
!------------------------------------------------------------------------
563544
subroutine ALMCalcDewSubFlux(this, &
564545
bounds, col, num_hydrologyc, filter_soilc_hydrologyc)
565546
!DESCRIPTION
@@ -716,6 +697,7 @@ subroutine ALMSetBiophysForcing(this, bounds, col, pft, carbonflux_vars, waterst
716697
type(soilstate_type) , optional, intent(in) :: soilstate_vars
717698

718699
integer :: p, pi, c
700+
integer :: npft_loc
719701

720702
call this%BeTRSetBiophysForcing(bounds, col, pft, 1, nlevsoi, carbonflux_vars, waterstate_vars, &
721703
waterflux_vars, temperature_vars, soilhydrology_vars, atm2lnd_vars, canopystate_vars, &
@@ -724,15 +706,23 @@ subroutine ALMSetBiophysForcing(this, bounds, col, pft, carbonflux_vars, waterst
724706

725707
!the following will be ALM specific
726708
!big leaf model
709+
!set profiles autotrohpic respiration
727710
do c = bounds%begc, bounds%endc
728-
do pi = 1, betr_maxpatch_pft
729-
if (pi <= col%npfts(c)) then
730-
p = col%pfti(c) + pi - 1
731-
if (pft%active(p)) then
732-
this%biophys_forc(c)%rr_patch(pi,1:nlevsoi) = carbonflux_vars%rr_patch(p) !* root_prof(p,1:nlevsoi)
711+
npft_loc = ubound(carbonflux_vars%rr_patch,1)-lbound(carbonflux_vars%rr_patch,1)+1
712+
if(npft_loc /= col%npfts(c) .and. col%pfti(c) /= lbound(carbonflux_vars%rr_patch,1)) then
713+
do pi = 1, betr_maxpatch_pft
714+
this%biophys_forc(c)%rr_patch(pi,1:nlevsoi) = 0._r8
715+
enddo
716+
else
717+
do pi = 1, betr_maxpatch_pft
718+
if (pi <= col%npfts(c)) then
719+
p = col%pfti(c) + pi - 1
720+
if (pft%active(p)) then
721+
this%biophys_forc(c)%rr_patch(pi,1:nlevsoi) = carbonflux_vars%rr_patch(p) !* root_prof(p,1:nlevsoi)
722+
endif
733723
endif
734-
endif
735-
enddo
724+
enddo
725+
endif
736726
enddo
737727
!dvgm
738728
!

0 commit comments

Comments
 (0)