Skip to content

Commit 969756a

Browse files
Merge branch 'ocean/unitialized_pointer_bug' into hotfix_v3.2
This merge introduces a fix that caused the PGI compiler to complain about null pointers when build in debug mode. * ocean/unitialized_pointer_bug: Fix unitialized pointer bug. Conflicts: src/core_ocean/mode_forward/mpas_ocn_time_integration_rk4.F src/core_ocean/mode_forward/mpas_ocn_time_integration_split.F src/core_ocean/shared/mpas_ocn_diagnostics.F
2 parents 6f6f3fb + bf3d7a6 commit 969756a

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

src/core_ocean/mode_forward/mpas_ocn_time_integration_rk4.F

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,17 +401,31 @@ subroutine ocn_time_integrator_rk4(domain, dt)!{{{
401401
call mpas_pool_get_array(provisStatePool, 'highFreqThickness', highFreqThicknessProvis, 1)
402402

403403
! advection of u uses u, while advection of layerThickness and tracers use normalTransportVelocity.
404-
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
405-
layerThicknessCur,layerThicknessEdge, normalVelocityProvis, &
406-
sshCur, highFreqThicknessProvis, rk_substep_weights(rk_step), &
407-
vertAleTransportTop, err)
404+
if (associated(highFreqThicknessProvis)) then
405+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
406+
layerThicknessCur,layerThicknessEdge, normalVelocityProvis, &
407+
sshCur, rk_substep_weights(rk_step), &
408+
vertAleTransportTop, err, highFreqThicknessProvis)
409+
else
410+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
411+
layerThicknessCur,layerThicknessEdge, normalVelocityProvis, &
412+
sshCur, rk_substep_weights(rk_step), &
413+
vertAleTransportTop, err)
414+
endif
408415

409416
call ocn_tend_vel(tendPool, provisStatePool, forcingPool, diagnosticsPool, meshPool, scratchPool, 1)
410417

411-
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
412-
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
413-
sshCur, highFreqThicknessProvis, rk_substep_weights(rk_step), &
414-
vertAleTransportTop, err)
418+
if (associated(highFreqThicknessProvis)) then
419+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
420+
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
421+
sshCur, rk_substep_weights(rk_step), &
422+
vertAleTransportTop, err, highFreqThicknessProvis)
423+
else
424+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
425+
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
426+
sshCur, rk_substep_weights(rk_step), &
427+
vertAleTransportTop, err)
428+
endif
415429

416430
call ocn_tend_thick(tendPool, forcingPool, diagnosticsPool, meshPool)
417431

src/core_ocean/mode_forward/mpas_ocn_time_integration_split.F

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,15 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
420420
421421
! compute vertAleTransportTop. Use u (rather than normalTransportVelocity) for momentum advection.
422422
! Use the most recent time level available.
423-
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
424-
layerThicknessCur, layerThicknessEdge, normalVelocityCur, &
425-
sshCur, highFreqThicknessNew, dt, vertAleTransportTop, err)
423+
if (associated(highFreqThicknessNew)) then
424+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
425+
layerThicknessCur, layerThicknessEdge, normalVelocityCur, &
426+
sshCur, dt, vertAleTransportTop, err, highFreqThicknessNew)
427+
else
428+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
429+
layerThicknessCur, layerThicknessEdge, normalVelocityCur, &
430+
sshCur, dt, vertAleTransportTop, err)
431+
endif
426432
427433
call ocn_tend_vel(tendPool, statePool, forcingPool, diagnosticsPool, meshPool, scratchPool, stage1_tend_time)
428434
@@ -1178,9 +1184,15 @@ subroutine ocn_time_integrator_split(domain, dt)!{{{
11781184
! compute vertAleTransportTop. Use normalTransportVelocity for advection of layerThickness and tracers.
11791185
! Use time level 1 values of layerThickness and layerThicknessEdge because
11801186
! layerThickness has not yet been computed for time level 2.
1181-
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
1182-
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
1183-
sshCur, highFreqThicknessNew, dt, vertAleTransportTop, err)
1187+
if (associated(highFreqThicknessNew)) then
1188+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
1189+
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
1190+
sshCur, dt, vertAleTransportTop, err, highFreqThicknessNew)
1191+
else
1192+
call ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, &
1193+
layerThicknessCur, layerThicknessEdge, normalTransportVelocity, &
1194+
sshCur, dt, vertAleTransportTop, err)
1195+
endif
11841196

11851197
call ocn_tend_thick(tendPool, forcingPool, diagnosticsPool, meshPool)
11861198

src/core_ocean/shared/mpas_ocn_diagnostics.F

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ end subroutine ocn_diagnostic_solve!}}}
697697
!
698698
!-----------------------------------------------------------------------
699699
subroutine ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, oldLayerThickness, layerThicknessEdge, &
700-
normalVelocity, oldSSH, newHighFreqThickness, dt, vertAleTransportTop, err)!{{{
700+
normalVelocity, oldSSH, dt, vertAleTransportTop, err, newHighFreqThickness)!{{{
701701

702702
!-----------------------------------------------------------------
703703
!
@@ -723,7 +723,7 @@ subroutine ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, oldLayerT
723723
real (kind=RKIND), dimension(:), intent(in) :: &
724724
oldSSH !< Input: sea surface height at old time
725725

726-
real (kind=RKIND), dimension(:,:), intent(in) :: &
726+
real (kind=RKIND), dimension(:,:), intent(in), optional :: &
727727
newHighFreqThickness !< Input: high frequency thickness. Alters ALE thickness.
728728

729729
real (kind=RKIND), intent(in) :: &
@@ -807,7 +807,11 @@ subroutine ocn_vert_transport_velocity_top(meshPool, verticalMeshPool, oldLayerT
807807
!
808808
! Compute desired thickness at new time
809809
!
810-
call ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, newHighFreqThickness, dt, ALE_thickness, err)
810+
if (present(newHighFreqThickness)) then
811+
call ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, dt, ALE_thickness, err, newHighFreqThickness)
812+
else
813+
call ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, dt, ALE_thickness, err)
814+
endif
811815

812816
!
813817
! Vertical transport through layer interfaces

src/core_ocean/shared/mpas_ocn_thick_ale.F

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module ocn_thick_ale
6969
!> (z-tilde), and imposes a minimum layer thickness.
7070
!
7171
!-----------------------------------------------------------------------
72-
subroutine ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, newHighFreqThickness, dt, ALE_thickness, err)!{{{
72+
subroutine ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, dt, ALE_thickness, err, newHighFreqThickness)!{{{
7373

7474
!-----------------------------------------------------------------
7575
!
@@ -87,7 +87,7 @@ subroutine ocn_ALE_thickness(meshPool, verticalMeshPool, oldSSH, div_hu_btr, new
8787
oldSSH, &!< Input: sea surface height at old time
8888
div_hu_btr !< Input: thickness-weighted barotropic divergence
8989

90-
real (kind=RKIND), dimension(:,:), intent(in) :: &
90+
real (kind=RKIND), dimension(:,:), intent(in), optional :: &
9191
newHighFreqThickness !< Input: high frequency thickness. Alters ALE thickness.
9292

9393
real (kind=RKIND), intent(in) :: &

0 commit comments

Comments
 (0)