Skip to content

Commit d7476d5

Browse files
committed
Update ocean BGC threading
To make multi-threaded runs BFB with single-threaded runs in coupled cases.
1 parent 389da9a commit d7476d5

23 files changed

+63
-73
lines changed

src/core_ocean/mode_forward/mpas_ocn_time_integration_rk4.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ subroutine ocn_time_integrator_rk4(domain, dt)!{{{
439439
* highFreqThicknessTend(:, iCell)
440440
end do
441441
!$omp end do
442-
call mpas_threading_barrier()
443442
block => block % next
444443
end do
445444
@@ -642,7 +641,6 @@ subroutine ocn_time_integrator_rk4(domain, dt)!{{{
642641
normalTransportVelocity(:, iEdge) = normalVelocityNew(:, iEdge)
643642
end do
644643
!$omp end do
645-
call mpas_threading_barrier()
646644

647645
! Compute normalGMBolusVelocity and the tracer transport velocity
648646
if (config_use_standardGM) then
@@ -1161,7 +1159,6 @@ subroutine ocn_time_integrator_rk4_diagnostic_update(block, dt, rkWeight, err)!{
11611159
normalTransportVelocity(:, iEdge) = normalVelocityProvis(:, iEdge)
11621160
end do
11631161
!$omp end do
1164-
call mpas_threading_barrier()
11651162

11661163
! Compute normalGMBolusVelocity, relativeSlope and RediDiffVertCoef if respective flags are turned on
11671164
if (config_use_standardGM) then
@@ -1176,7 +1173,6 @@ subroutine ocn_time_integrator_rk4_diagnostic_update(block, dt, rkWeight, err)!{
11761173
end do
11771174
!$omp end do
11781175
end if
1179-
call mpas_threading_barrier()
11801176
! ------------------------------------------------------------------
11811177
! End: Accumulating various parametrizations of the transport velocity
11821178
! ------------------------------------------------------------------

src/core_ocean/mode_forward/mpas_ocn_time_integration_split.F

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
560560
561561
allocate(uTemp(nVertLevels))
562562
563-
!$omp do schedule(runtime) private(cell1, cell2, k, normalThicknessFluxSum, thicknessSum)
563+
!$omp do schedule(runtime)
564564
do iEdge = 1, nEdges
565565
cell1 = cellsOnEdge(1,iEdge)
566566
cell2 = cellsOnEdge(2,iEdge)
@@ -813,7 +813,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
813813
nEdges = nEdgesPtr
814814
nEdges = nEdgesArray( edgeHaloComputeCounter )
815815

816-
!$omp do schedule(runtime) private(cell1, cell2, CoriolisTerm, i, eoe)
816+
!$omp do schedule(runtime)
817817
do iEdge = 1, nEdges
818818

819819
temp_mask = edgeMask(1, iEdge)
@@ -1025,7 +1025,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
10251025
10261026
nEdges = nEdgesArray( edgeHaloComputeCounter )
10271027
1028-
!$omp do schedule(runtime) private(cell1, cell2, eoe, CoriolisTerm, i, sshCell1, sshCell2)
1028+
!$omp do schedule(runtime)
10291029
do iEdge = 1, nEdges
10301030
10311031
! asarje: added to avoid redundant computations based on mask
@@ -1338,7 +1338,7 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
13381338
useVelocityCorrection = 0
13391339
endif
13401340
1341-
!$omp do schedule(runtime) private(k, normalThicknessFluxSum, thicknessSum, normalVelocityCorrection)
1341+
!$omp do schedule(runtime)
13421342
do iEdge = 1, nEdges
13431343
13441344
! velocity for normalVelocityCorrectionection is normalBarotropicVelocity + normalBaroclinicVelocity + uBolus

src/core_ocean/shared/mpas_ocn_diagnostics.F

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,13 @@ subroutine ocn_diagnostic_solve(dt, statePool, forcingPool, meshPool, diagnostic
285285
! used -1e34 so error clearly occurs if these values are used.
286286
!
287287

288-
!$omp single
288+
!$omp master
289289
normalVelocity(:,nEdges+1) = -1e34
290290
layerThickness(:,nCells+1) = -1e34
291291
activeTracers(indexTemperature,:,nCells+1) = -1e34
292292
activeTracers(indexSalinity,:,nCells+1) = -1e34
293-
!$omp end single
293+
!$omp end master
294+
call mpas_threading_barrier()
294295

295296
call ocn_relativeVorticity_circulation(relativeVorticity, circulation, meshPool, normalVelocity, err)
296297

@@ -320,7 +321,7 @@ subroutine ocn_diagnostic_solve(dt, statePool, forcingPool, meshPool, diagnostic
320321
!
321322
allocate(div_hu(nVertLevels),div_huTransport(nVertLevels),div_huGMBolus(nVertLevels))
322323

323-
!$omp do schedule(runtime) private(invAreaCell1, iEdge, r_tmp, i, k)
324+
!$omp do schedule(runtime)
324325
do iCell = 1, nCells
325326
divergence(:, iCell) = 0.0_RKIND
326327
kineticEnergyCell(:, iCell) = 0.0_RKIND
@@ -364,7 +365,7 @@ subroutine ocn_diagnostic_solve(dt, statePool, forcingPool, meshPool, diagnostic
364365

365366
nEdges = nEdgesArray( 2 )
366367

367-
!$omp do schedule(runtime) private(eoe, i, k)
368+
!$omp do schedule(runtime)
368369
do iEdge = 1, nEdges
369370
tangentialVelocity(:, iEdge) = 0.0_RKIND
370371
! Compute v (tangential) velocities
@@ -621,7 +622,7 @@ subroutine ocn_diagnostic_solve(dt, statePool, forcingPool, meshPool, diagnostic
621622

622623
allocate(pTop(nVertLevels))
623624

624-
!$omp do schedule(runtime) private(k)
625+
!$omp do schedule(runtime)
625626
do iCell = 1, nCells
626627

627628
! assume atmospheric pressure at the surface is zero for now.
@@ -752,7 +753,7 @@ subroutine ocn_diagnostic_solve(dt, statePool, forcingPool, meshPool, diagnostic
752753

753754
nCells = nCellsArray( 1 )
754755

755-
!$omp do schedule(runtime) private(surfaceLayerDepth, sumSurfaceLayer, k, rSurfaceLayer)
756+
!$omp do schedule(runtime)
756757
do iCell=1,nCells
757758
surfaceLayerDepth = config_cvmix_kpp_surface_layer_averaging
758759
sumSurfaceLayer=0.0_RKIND
@@ -1168,7 +1169,7 @@ subroutine ocn_filter_btr_mode_vel(statePool, diagnosticsPool, meshPool, timeLev
11681169
11691170
call mpas_pool_get_dimension(meshPool, 'nEdges', nEdges)
11701171
1171-
!$omp do schedule(runtime) private(normalThicknessFluxSum, thicknessSum, k, vertSum)
1172+
!$omp do schedule(runtime)
11721173
do iEdge = 1, nEdges
11731174
11741175
! thicknessSum is initialized outside the loop because on land boundaries
@@ -1189,8 +1190,6 @@ subroutine ocn_filter_btr_mode_vel(statePool, diagnosticsPool, meshPool, timeLev
11891190
enddo ! iEdge
11901191
!$omp end do
11911192
1192-
call mpas_threading_barrier()
1193-
11941193
call mpas_timer_stop("ocn_filter_btr_mode_vel")
11951194
11961195
end subroutine ocn_filter_btr_mode_vel!}}}
@@ -1239,7 +1238,7 @@ subroutine ocn_filter_btr_mode_tend_vel(tendPool, statePool, diagnosticsPool, me
12391238
12401239
call mpas_pool_get_dimension(meshPool, 'nEdges', nEdges)
12411240
1242-
!$omp do schedule(runtime) private(normalThicknessFluxSum, thicknessSum, vertSum, k)
1241+
!$omp do schedule(runtime)
12431242
do iEdge = 1, nEdges
12441243
12451244
! thicknessSum is initialized outside the loop because on land boundaries
@@ -1450,8 +1449,7 @@ subroutine ocn_compute_KPP_input_fields(statePool, forcingPool, meshPool, diagno
14501449
densitySurfaceDisplaced, err, thermalExpansionCoeff, salineContractionCoeff, &
14511450
timeLevel)
14521451
1453-
!$omp do schedule(runtime) private(invAreaCell, deltaVelocitySquared, i, iEdge, factor, delU2, fracAbsorbed, &
1454-
!$omp fracAbsorbedRunoff)
1452+
!$omp do schedule(runtime)
14551453
do iCell = 1, nCells
14561454
invAreaCell = 1.0_RKIND / areaCell(iCell)
14571455
@@ -1514,8 +1512,6 @@ subroutine ocn_compute_KPP_input_fields(statePool, forcingPool, meshPool, diagno
15141512
enddo
15151513
!$omp end do
15161514
1517-
call mpas_threading_barrier()
1518-
15191515
! deallocate scratch space
15201516
call mpas_deallocate_scratch_field(thermalExpansionCoeffField, .true.)
15211517
call mpas_deallocate_scratch_field(salineContractionCoeffField, .true.)
@@ -1740,7 +1736,7 @@ subroutine ocn_compute_land_ice_flux_input_fields(meshPool, statePool, &
17401736
17411737
17421738
! average temperature and salinity over horizontal neighbors and the sub-ice-shelf boundary layer
1743-
!$omp do schedule(runtime) private(blThickness, iLevel, dz)
1739+
!$omp do schedule(runtime)
17441740
do iCell = 1, nCells
17451741
blThickness = 0.0_RKIND
17461742
blTempScratch(iCell) = 0.0_RKIND

src/core_ocean/shared/mpas_ocn_equation_of_state_jm.F

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ subroutine ocn_equation_of_state_jm_density(meshPool, scratchPool, nCells, k_dis
309309
enddo
310310
endif
311311

312-
!$omp do schedule(runtime) private(k, DRDT0, DKDT, DRHODT, DRDS0, DKDS, DRHODS)
312+
!$omp do schedule(runtime)
313313
do iCell=1,nCells
314314
if (displacement_type == 'surfaceDisplaced') then
315315
if(present(tracersSurfaceLayerValue)) then

src/core_ocean/shared/mpas_ocn_frazil_forcing.F

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,7 @@ subroutine ocn_frazil_forcing_build_arrays(domain, meshPool, forcingPool, diagno
451451
nCells = nCellsArray( 2 )
452452

453453
! loop over all columns
454-
!$omp do schedule(runtime) private(kBottomFrazil, k, columnTemperatureMin, sumNewFrazilIceThickness, &
455-
!$omp oceanFreezingTemperature, potential, freezingEnergy, meltingEnergy, &
456-
!$omp newFrazilIceThickness, meltedFrazilIceThickness)
454+
!$omp do schedule(runtime)
457455
do iCell=1,nCells
458456

459457
underLandIce = .false.

src/core_ocean/shared/mpas_ocn_gm.F

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ subroutine ocn_gm_compute_Bolus_velocity(diagnosticsPool, meshPool, scratchPool)
418418
! use relativeSlopeTaperingCell as a temporary space for smoothing of relativeSlopeTopOfCell
419419
relativeSlopeTaperingCell = relativeSlopeTopOfCell
420420
do iter = 1, 5
421-
!$omp barrier
422421

423422
nCells = nCellsArray( 2 )
424423

425-
!$omp do schedule(runtime) private(k, rtmp)
424+
!$omp do schedule(runtime)
426425
do iCell=1,nCells
427426
relativeSlopeTaperingCell(1, iCell) = 0.0_RKIND
428427
relativeSlopeTaperingCell(maxLevelCell(iCell):nVertLevels, iCell) = 0.0_RKIND
@@ -523,7 +522,7 @@ subroutine ocn_gm_compute_Bolus_velocity(diagnosticsPool, meshPool, scratchPool)
523522

524523
nEdges = nEdgesArray( 3 )
525524

526-
!$omp do schedule(runtime) private(cell1, cell2, k, BruntVaisalaFreqTopEdge, N)
525+
!$omp do schedule(runtime)
527526
do iEdge = 1, nEdges
528527
cell1 = cellsOnEdge(1,iEdge)
529528
cell2 = cellsOnEdge(2,iEdge)

src/core_ocean/shared/mpas_ocn_sea_ice.F

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ subroutine ocn_sea_ice_formation(meshPool, indexTemperature, indexSalinity, laye
135135

136136
density_ice = rho_ice
137137

138-
!$omp do schedule(runtime) private(maxLevel, netEnergyChange, k, freezingTemp, availableEnergyChange, energyChange, &
139-
!$omp temperatureChange, thicknessChange, iceThicknessChange, iTracer)
138+
!$omp do schedule(runtime)
140139
do iCell = 1, nCellsSolve ! Check performance of these two loop definitions
141140
! do iCell = nCellsSolve, 1, -1
142141
maxLevel = min(maxLevelCell(iCell), verticalLevelCap)

src/core_ocean/shared/mpas_ocn_surface_land_ice_fluxes.F

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, diagnosticsPool, &
491491
nCells = nCellsArray( size(nCellsArray) )
492492

493493
if(isomipOn) then
494-
!$omp do schedule(runtime) private(heatFlux)
494+
!$omp do schedule(runtime)
495495
do iCell = 1, nCells
496496
if (landIceMask(iCell) == 0) cycle
497497

@@ -795,7 +795,7 @@ subroutine compute_melt_fluxes( &
795795
.and. present(kappa_land_ice)
796796
Tlatent = latent_heat_fusion_mks/cp_sw
797797

798-
!$omp do schedule(runtime) private(iceHeatFluxCoeff, nu, iceDeltaT, T0, transferVelocityRatio, a, b, c)
798+
!$omp do schedule(runtime)
799799
do iCell = 1, nCells
800800
if (mask(iCell) == 0) cycle
801801

@@ -952,7 +952,7 @@ subroutine compute_HJ99_melt_fluxes( &
952952

953953
err = 0
954954
cpRatio = cp_land_ice/cp_sw
955-
!$omp do schedule(runtime) private(T0, transferVelocityRatio, Tlatent, eta, TlatentStar, a, b, c)
955+
!$omp do schedule(runtime) reduction(+:err)
956956
do iCell = 1, nCells
957957
if (mask(iCell) == 0) cycle
958958

@@ -975,9 +975,7 @@ subroutine compute_HJ99_melt_fluxes( &
975975
outInterfaceSalinity(iCell) = (-b + sqrt(b**2 - 4.0_RKIND*a*c*oceanSalinity(iCell)))/(2.0_RKIND*a)
976976
if (outInterfaceSalinity(iCell) .le. 0.0_RKIND) then
977977
err = 1
978-
call mpas_log_write( &
979-
'interfaceSalinity is negative.', &
980-
MPAS_LOG_CRIT)
978+
call mpas_log_write('interfaceSalinity is negative.', MPAS_LOG_CRIT)
981979
end if
982980
outInterfaceTemperature(iCell) = dTf_dS*outInterfaceSalinity(iCell)+T0
983981

src/core_ocean/shared/mpas_ocn_tendency.F

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ subroutine ocn_tend_tracer(tendPool, statePool, forcingPool, diagnosticsPool, me
628628
tracerGroupSurfaceFluxRemoved, dt, layerThickness, err)
629629
end if
630630

631+
632+
!$omp master
633+
631634
!
632635
! compute ecosystem source-sink tendencies and net surface fluxes
633636
! NOTE: must be called before ocn_tracer_surface_flux_tend
@@ -673,6 +676,9 @@ subroutine ocn_tend_tracer(tendPool, statePool, forcingPool, diagnosticsPool, me
673676
nTracerGroup, nCellsSolve, zMid, indexTemperature, indexSalinity, tracerGroupSurfaceFlux, err)
674677
endif
675678

679+
!$omp end master
680+
call mpas_threading_barrier()
681+
676682
!
677683
! ocean surface restoring
678684
!
@@ -974,7 +980,7 @@ subroutine ocn_tend_freq_filtered_thickness(tendPool, statePool, diagnosticsPool
974980

975981
allocate(div_hu(nVertLevels))
976982

977-
!$omp do schedule(runtime) private(div_hu_btr, invAreaCell, i, iEdge, k, totalThickness, flux)
983+
!$omp do schedule(runtime)
978984
do iCell = 1, nCells
979985
tend_lowFreqDivergence(:, iCell) = 0.0_RKIND
980986
tend_highFreqThickness(:, iCell) = 0.0_RKIND

src/core_ocean/shared/mpas_ocn_thick_ale.F

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ subroutine ocn_ALE_thickness(meshPool, verticalMeshPool, SSH, ALE_thickness, err
147147
!
148148
! ALE thickness alteration due to SSH (z-star)
149149
!
150-
!$omp do schedule(runtime) private(kMax, thicknessSum, k)
150+
!$omp do schedule(runtime)
151151
do iCell = 1, nCells
152152
kMax = maxLevelCell(iCell)
153153

@@ -182,7 +182,7 @@ subroutine ocn_ALE_thickness(meshPool, verticalMeshPool, SSH, ALE_thickness, err
182182
!
183183
if (config_use_min_max_thickness) then
184184

185-
!$omp do schedule(runtime) private(kMax, remainder, k, newThickness)
185+
!$omp do schedule(runtime)
186186
do iCell = 1, nCells
187187
kMax = maxLevelCell(iCell)
188188

0 commit comments

Comments
 (0)