Skip to content

Commit

Permalink
Fix issues with unitialised variables (#350)
Browse files Browse the repository at this point in the history
* Fix issues with unitialised variables
* Initialise clocks in flux_exchange.F90 regardless of component
* fix clocks in ocean_model and integer formats in diagnostics
* updated FMS which fixes initialisation bugs

Co-authored-by: Russell Fiedler <[email protected]>
Co-authored-by: Aidan Heerdegen <[email protected]>
  • Loading branch information
3 people authored Dec 15, 2021
1 parent 4bfc52a commit b74873b
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 81 deletions.
7 changes: 4 additions & 3 deletions src/coupler/flux_exchange.F90
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,10 @@ module flux_exchange_mod
! DIRECT: same physical grid, same domain decomposition, can directly copy data
integer, parameter :: REGRID=1, REDIST=2, DIRECT=3
!Balaji: clocks moved into flux_exchange
integer :: cplClock, sfcClock, fluxAtmDnClock, fluxLandIceClock, &
fluxIceOceanClock, fluxOceanIceClock, regenClock, fluxAtmUpClock, &
cplOcnClock
!RASF Initialise to zero irrespective of model component
integer :: cplClock=0, sfcClock=0, fluxAtmDnClock=0, fluxLandIceClock=0, &
fluxIceOceanClock=0, fluxOceanIceClock=0, regenClock=0, fluxAtmUpClock=0, &
cplOcnClock=0

logical :: ocn_pe, ice_pe
integer, allocatable, dimension(:) :: ocn_pelist, ice_pelist
Expand Down
1 change: 1 addition & 0 deletions src/ice_sis/ice_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,7 @@ subroutine transport (Ice)
endif

uf = 0.0; vf = 0.0
uf0 = 0.0; vf0 = 0.0 !Must have a value in case of no subcycling
do k=2,km
call ice_advect(uc, vc, Ice%part_size(:,:,k))
call ice_advect(uc, vc, Ice%h_snow (:,:,k), uf0, vf0)
Expand Down
129 changes: 65 additions & 64 deletions src/mom5/ocean_core/ocean_model.F90
Original file line number Diff line number Diff line change
Expand Up @@ -499,71 +499,71 @@ module ocean_model_mod
#endif

! identification numbers for mpp clocks
integer :: id_init
integer :: id_advect
integer :: id_vmix
integer :: id_neutral
integer :: id_compute_visc_form_drag
integer :: id_submesoscale
integer :: id_sw
integer :: id_sponges_tracer
integer :: id_sponges_eta
integer :: id_sponges_velocity
integer :: id_sigma
integer :: id_tracer
integer :: id_bbc
integer :: id_sbc
integer :: id_flux_adjust
integer :: id_explicit_accel_a
integer :: id_explicit_accel_b
integer :: id_implicit_accel
integer :: id_bottom_smooth
integer :: id_surface_smooth
integer :: id_eta_and_pbot_tendency
integer :: id_eta_and_pbot_update
integer :: id_eta_and_pbot_diagnose
integer :: id_rho_dzt_tendency
integer :: id_dzt_dst_update
integer :: id_mass_forcing
integer :: id_barotropic_forcing
integer :: id_barotropic_update
integer :: id_velocity
integer :: id_xlandinsert
integer :: id_xlandmix
integer :: id_overflow
integer :: id_overflow_OFP
integer :: id_overexchange
integer :: id_mixdownslope
integer :: id_blob_update
integer :: id_blob_cell_update
integer :: id_blob_diagnose_depth
integer :: id_tcell_thickness_blob
integer :: id_update_L_thickness
integer :: id_update_E_thickness
integer :: id_rivermix
integer :: id_density
integer :: id_density_diag
integer :: id_otpm_source
integer :: id_otpm_bbc
integer :: id_otpm_tracer
integer :: id_diagnostics
integer :: id_tcell_thickness
integer :: id_ucell_thickness
integer :: id_update_halo_tracer
integer :: id_update_halo_velocity
integer :: id_oda
integer :: id_ocean_sfc
integer :: id_ocean_seg_end
integer :: id_tmask_limit
integer :: id_ocean
integer :: id_advect_gotm
integer :: id_increment_tracer
integer :: id_increment_eta
integer :: id_increment_velocity
integer :: id_salinity
integer :: id_wave
integer :: id_init=0
integer :: id_advect=0
integer :: id_vmix=0
integer :: id_neutral=0
integer :: id_compute_visc_form_drag=0
integer :: id_submesoscale=0
integer :: id_sw=0
integer :: id_sponges_tracer=0
integer :: id_sponges_eta=0
integer :: id_sponges_velocity=0
integer :: id_sigma=0
integer :: id_tracer=0
integer :: id_bbc=0
integer :: id_sbc=0
integer :: id_flux_adjust=0
integer :: id_explicit_accel_a=0
integer :: id_explicit_accel_b=0
integer :: id_implicit_accel=0
integer :: id_bottom_smooth=0
integer :: id_surface_smooth=0
integer :: id_eta_and_pbot_tendency=0
integer :: id_eta_and_pbot_update=0
integer :: id_eta_and_pbot_diagnose=0
integer :: id_rho_dzt_tendency=0
integer :: id_dzt_dst_update=0
integer :: id_mass_forcing =0
integer :: id_barotropic_forcing=0
integer :: id_barotropic_update=0
integer :: id_velocity=0
integer :: id_xlandinsert=0
integer :: id_xlandmix=0
integer :: id_overflow=0
integer :: id_overflow_OFP=0
integer :: id_overexchange=0
integer :: id_mixdownslope=0
integer :: id_blob_update=0
integer :: id_blob_cell_update=0
integer :: id_blob_diagnose_depth=0
integer :: id_tcell_thickness_blob=0
integer :: id_update_L_thickness=0
integer :: id_update_E_thickness=0
integer :: id_rivermix=0
integer :: id_density=0
integer :: id_density_diag=0
integer :: id_otpm_source=0
integer :: id_otpm_bbc=0
integer :: id_otpm_tracer=0
integer :: id_diagnostics=0
integer :: id_tcell_thickness=0
integer :: id_ucell_thickness=0
integer :: id_update_halo_tracer=0
integer :: id_update_halo_velocity=0
integer :: id_oda=0
integer :: id_ocean_sfc=0
integer :: id_ocean_seg_end=0
integer :: id_tmask_limit=0
integer :: id_ocean=0
integer :: id_advect_gotm=0
integer :: id_increment_tracer=0
integer :: id_increment_eta=0
integer :: id_increment_velocity=0
integer :: id_salinity=0
integer :: id_wave=0
#if defined(ACCESS_CM) || defined(ACCESS_OM)
integer :: id_sfix
integer :: id_sfix=0
#endif

public ocean_model_init
Expand Down Expand Up @@ -729,6 +729,7 @@ subroutine ocean_model_init(Ocean, Ocean_state, Time_init, Time_in, &
id_density = mpp_clock_id('(Ocean update density) ' ,grain=CLOCK_MODULE)
id_vmix = mpp_clock_id('(Ocean vertical mixing coeff) ' ,grain=CLOCK_MODULE)
id_neutral = mpp_clock_id('(Ocean neutral physics) ' ,grain=CLOCK_MODULE)
id_compute_visc_form_drag = mpp_clock_id('(Ocean viscous form drag) ' ,grain=CLOCK_MODULE)
id_submesoscale = mpp_clock_id('(Ocean submesoscale restrat)' ,grain=CLOCK_MODULE)
id_sw = mpp_clock_id('(Ocean shortwave) ' ,grain=CLOCK_MODULE)
id_sponges_eta = mpp_clock_id('(Ocean sponges_eta) ' ,grain=CLOCK_MODULE)
Expand Down
14 changes: 7 additions & 7 deletions src/mom5/ocean_diag/ocean_adv_vel_diag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ subroutine remapping_check
'==>Note: T-->U remapping error will be small (i.e., order 1e-20) only for spherical grids.'
endif

9000 format(//'==>Maximum T-->U remapping error = ',es10.3,' m/s at (i,j) = ','(',i4,',',i4,'),',' (lon,lat) = (',f7.2,',',f7.2,')')
9000 format(//'==>Maximum T-->U remapping error = ',es10.3,' m/s at (i,j) = ','(',i0,',',i0,'),',' (lon,lat) = (',f7.2,',',f7.2,')')

end subroutine remapping_check
! </SUBROUTINE> NAME="remapping_check"
Expand Down Expand Up @@ -564,7 +564,7 @@ subroutine cfl_check2(Time, Thickness, Adv_vel)

if (cflw >= large_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i0,a1,i0,a,i3,a,f6.3)') &
' Note: CFL velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',large_cfl_value

Expand All @@ -581,7 +581,7 @@ subroutine cfl_check2(Time, Thickness, Adv_vel)

if (cflw >= max_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i4,a1,i0,a,i0,a,f6.3)') &
' Note: CFL vertical velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',max_cfl_value

Expand Down Expand Up @@ -711,9 +711,9 @@ subroutine maximum_bottom_w(Adv_vel)
endif
endif

9112 format(/' Maximum T-cell bottom velocity (',es10.3,' m/s){error} at (i,j,k) = ','(',i4,',',i4,',',i4,'),',&
9112 format(/' Maximum T-cell bottom velocity (',es10.3,' m/s){error} at (i,j,k) = ','(',i0,',',i0,',',i0,'),',&
' (lon,lat,dpt) = (',f7.2,',',f7.2,',',f7.0,'m)')
9113 format(' Maximum U-cell bottom velocity (',es10.3,' m/s){slope} at (i,j,k) = ','(',i4,',',i4,',',i4,'),',&
9113 format(' Maximum U-cell bottom velocity (',es10.3,' m/s){slope} at (i,j,k) = ','(',i0,',',i0,',',i0,'),',&
' (lon,lat,dpt) = (',f7.2,',',f7.2,',',f7.0,'m)'/)

end subroutine maximum_bottom_w
Expand Down Expand Up @@ -799,15 +799,15 @@ subroutine max_continuity_error(Adv_vel, Thickness)

if (abs(bigt0) == bigt) then
bigt = bigt0/fudge
write (unit,'(a,es10.3,a,i4,a1,i3,a1,i3,a,f9.2,a,f9.2,a,f9.2,a/)') ' Maximum T-cell Continuity Error (',bigt,&
write (unit,'(a,es10.3,a,i0,a1,i0,a1,i0,a,f9.2,a,f9.2,a,f9.2,a/)') ' Maximum T-cell Continuity Error (',bigt,&
' m/s) is at (i,j,k) = (',it+Dom%ioff,',',jt+Dom%joff,',',kt,'), (lon,lat,dpt) = ('&
,Grd%xt(it,jt),',',Grd%yt(it,jt),',', Grd%zt(kt),' m)'
endif

if(horz_grid==MOM_BGRID) then
if (abs(bigu0) == bigu) then
bigu = bigu0/fudge
write (unit,'(/,a,es10.3,a,i4,a1,i3,a1,i3,a,f9.2,a,f9.2,a,f9.2,a)') ' Maximum U-cell Continuity Error (',bigu,&
write (unit,'(/,a,es10.3,a,i0,a1,i0,a1,i0,a,f9.2,a,f9.2,a,f9.2,a)') ' Maximum U-cell Continuity Error (',bigu,&
' m/s) is at (i,j,k) = (',iu+Dom%ioff,',',ju+Dom%joff,',',ku,'), (lon,lat,dpt) = ('&
,Grd%xu(iu,ju),',',Grd%yu(iu,ju),',', Grd%zt(ku),' m)'
endif
Expand Down
12 changes: 6 additions & 6 deletions src/mom5/ocean_diag/ocean_velocity_diag.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2847,7 +2847,7 @@ subroutine cfl_check1_bgrid(Time, Thickness, Velocity)

if (cflup == cflup0) then

write (unit,'(a,g10.3,a,f7.2,a,g10.3,a,i4,a,i4,a,i3,a,a,f12.3,a,f12.3,a,f10.3,a)')&
write (unit,'(a,g10.3,a,f7.2,a,g10.3,a,i0,a,i0,a,i3,a,a,f12.3,a,f12.3,a,f10.3,a)')&
' u (',cflum,' m/s) is ',cflup/fudge,' % of CFL (',abs(100.0*cflum/(cflup/fudge)), &
' m/s) at (i,j,k) = (',icflu+Dom%ioff,',',jcflu+Dom%joff,',',kcflu,'),', &
' (lon,lat,thk) = (',Grd%xu(icflu,jcflu),',',Grd%yu(icflu,jcflu),',', &
Expand All @@ -2861,7 +2861,7 @@ subroutine cfl_check1_bgrid(Time, Thickness, Velocity)

if (cflvp == cflvp0) then

write (unit,'(a,g10.3,a,f7.2,a,g10.3,a,i4,a,i4,a,i3,a,a,f12.3,a,f12.3,a,f10.3,a)') &
write (unit,'(a,g10.3,a,f7.2,a,g10.3,a,i0,a,i0,a,i3,a,a,f12.3,a,f12.3,a,f10.3,a)') &
' v (',cflvm,' m/s) is ',cflvp/fudge,' % of CFL (',abs(100.0*cflvm/(cflvp/fudge)), &
' m/s) at (i,j,k) = (',icflv+Dom%ioff,',',jcflv+Dom%joff,',',kcflv,'),', &
' (lon,lat,thk) = (',Grd%xu(icflv,jcflv),',',Grd%yu(icflv,jcflv),',', &
Expand Down Expand Up @@ -3048,7 +3048,7 @@ subroutine cfl_check2_bgrid(Time, Thickness, Velocity)

if (cflu >= large_cfl_value .or. cflv >= large_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i0,a1,i0,a,i3,a,f6.3)') &
' Note: CFL horizontal velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',large_cfl_value

Expand All @@ -3067,7 +3067,7 @@ subroutine cfl_check2_bgrid(Time, Thickness, Velocity)

if (cflu >= max_cfl_value .or. cflv >= max_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i0,a1,i0,a,i3,a,f6.3)') &
' Note: CFL horizontal velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',max_cfl_value

Expand Down Expand Up @@ -3168,7 +3168,7 @@ subroutine cfl_check2_cgrid(Time, Thickness, Velocity)

if (cflu >= large_cfl_value .or. cflv >= large_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i0,a1,i0,a,i3,a,f6.3)') &
' Note: CFL horizontal velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',large_cfl_value

Expand All @@ -3187,7 +3187,7 @@ subroutine cfl_check2_cgrid(Time, Thickness, Velocity)

if (cflu >= max_cfl_value .or. cflv >= max_cfl_value) then

write (unit,'(/,a,i4,a1,i3,a,i3,a,f6.3)') &
write (unit,'(/,a,i0,a1,i0,a,i3,a,f6.3)') &
' Note: CFL horizontal velocity limit exceeded at (i,j,k) = (',&
i+Dom%ioff, ',',j+Dom%joff,',',k,') by factor =',max_cfl_value

Expand Down
2 changes: 1 addition & 1 deletion src/mom5/ocean_param/neutral/ocean_nphysics_new.F90
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module ocean_nphysics_new_mod
real :: dtime
integer :: index_temp, index_salt

logical :: use_this_module
logical :: use_this_module = .false.

! for Tim%init=.true. and ocean_neutral.res.nc exists, but still wish
! to start from initial fields.
Expand Down

0 comments on commit b74873b

Please sign in to comment.