Skip to content

Commit 31e185c

Browse files
authored
Merge pull request #3640 from ekluzek/restructure_ciso_for_omp
Restructure Carbon Isotope streams for OpenMP
2 parents 670098d + ff57ce7 commit 31e185c

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

src/biogeochem/CNCIsoAtmTimeSeriesReadMod.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ subroutine C13Streams( bounds )
696696
! !LOCAL VARIABLES:
697697
integer :: g ! Indices
698698

699+
! TODO: Keep the Advance commented out until we can change answers
700+
!call atm_c13_stream%Advance( )
699701
call atm_c13_stream%Interp( bounds)
700702

701703
do g = bounds%begg, bounds%endg

src/biogeophys/PhotosynthesisMod.F90

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,8 +2067,7 @@ subroutine PhotosynthesisTotal (bounds, fn, filterp, &
20672067
!
20682068
! Determine total photosynthesis
20692069
!
2070-
use CIsoAtmTimeseriesMod, only : C14BombSpike, C13TimeSeries
2071-
use CIsoAtmTimeseriesMod, only : rc13_atm_grc, rc14_atm_grc
2070+
use CIsoAtmTimeseriesMod, only : rc13_atm_grc, rc14_atm_grc ! Atmospheric Carbon isotope timeseries data
20722071
! !ARGUMENTS:
20732072
type(bounds_type) , intent(in) :: bounds
20742073
integer , intent(in) :: fn ! size of pft filter
@@ -2113,11 +2112,6 @@ subroutine PhotosynthesisTotal (bounds, fn, filterp, &
21132112
fpsn_wp => photosyns_inst%fpsn_wp_patch & ! Output: [real(r8) (:) ] product-limited photosynthesis (umol CO2 /m**2 /s)
21142113
)
21152114

2116-
! Get the current C13/C14 ratio in the atmosphere from timeseries data or the fixed values
2117-
! These calls fill the data: rc13_atm_grc and rc14_atm_grc
2118-
if ( use_c14 ) call C14BombSpike(bounds)
2119-
if ( use_c13 ) call C13TimeSeries(bounds, atm2lnd_inst)
2120-
21212115
do f = 1, fn
21222116
p = filterp(f)
21232117
g = patch%gridcell(p)

src/cpl/share_esmf/CTSMForce2DStreamBaseType.F90

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,16 @@ subroutine Advance(this)
278278
integer :: sec ! seconds into current date for nstep+1
279279
integer :: mcdate ! Current model date (yyyymmdd)
280280
integer :: rc ! Error return code
281-
281+
#ifdef _OPENMP
282+
logical, external :: omp_in_parallel
283+
#endif
284+
285+
#ifdef _OPENMP
286+
if ( omp_in_parallel() )then
287+
call endrun( 'CTSM forcing Streams Advance is being called from within an OMP loop and should NOT be', &
288+
file=sourcefile, line=__LINE__ )
289+
end if
290+
#endif
282291
! Advance sdat stream
283292
call get_curr_date(year, mon, day, sec)
284293
mcdate = year*10000 + mon*100 + day

src/main/clm_driver.F90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
118118
use laiStreamMod , only : lai_advance
119119
use FATESFireFactoryMod , only : scalar_lightning
120120
use FatesInterfaceTypesMod, only : fates_dispersal_cadence_none
121+
use CIsoAtmTimeseriesMod, only : C14BombSpike, C13TimeSeries
121122
!
122123
! !ARGUMENTS:
123124
implicit none
@@ -408,6 +409,14 @@ subroutine clm_drv(doalb, nextsw_cday, declinp1, declin, rstwr, nlend, rdate, ro
408409
call PrescribedSoilMoistureAdvance( bounds_proc )
409410
call t_stopf('prescribed_sm')
410411
endif
412+
if ( use_cn )then
413+
! Get the current C13/C14 ratio in the atmosphere from timeseries data or the fixed values
414+
! These calls fill the data: rc13_atm_grc and rc14_atm_grc
415+
! NOTE: These calls need to happen outside loops over nclumps (as streams are not threadsafe).
416+
! TODO: This should probably be moved to CNVegetationFacade in the InterpFileInputs subroutine
417+
if ( use_c14 ) call C14BombSpike(bounds_proc)
418+
if ( use_c13 ) call C13TimeSeries(bounds_proc, atm2lnd_inst)
419+
end if
411420
! ============================================================================
412421
! Initialize the column-level mass balance checks for water, carbon & nitrogen.
413422
!

0 commit comments

Comments
 (0)