Skip to content

Commit

Permalink
Fix non-standard white space (mom-ocean#109)
Browse files Browse the repository at this point in the history
* Fix non-standard white space

  Made widespread corrections to indentation and other white space issues to
conform to the MOM6 standards, as documented in the white space section of the
MOM6 style guide, at https://github.com/mom-ocean/MOM6/wiki/Code-style-guide.

- MOM6 code uses a 2-point indent scheme.

- There should be a space around all assignment (" = ") operators.

- The names of optional arguments do not use whitespace, to differentiate them
  from assignments.

- There is a space around the semicolons for stacked enddo statements.

After this change, greping for '^ [a-zA-Z]', '^   [a-zA-Z]' or '^     [a-zA-Z]'
does not find any lines in the MOM6 src or config_src/infra code.  All answers
and output are bitwise identical.
  • Loading branch information
Hallberg-NOAA authored Apr 14, 2022
1 parent d729c67 commit f54338a
Show file tree
Hide file tree
Showing 38 changed files with 726 additions and 728 deletions.
60 changes: 30 additions & 30 deletions config_src/infra/FMS1/MOM_diag_manager_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,36 @@ module MOM_diag_manager_infra
!> Initialize a diagnostic axis
integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM_domain, position, &
& direction, edges, set_name, coarsen, null_axis)
character(len=*), intent(in) :: name !< The name of this axis
real, dimension(:), intent(in) :: data !< The array of coordinate values
character(len=*), intent(in) :: units !< The units for the axis data
character(len=*), intent(in) :: cart_name !< Cartesian axis ("X", "Y", "Z", "T", or "N" for none)
character(len=*), &
optional, intent(in) :: long_name !< The long name of this axis
type(MOM_domain_type), &
optional, intent(in) :: MOM_Domain !< A MOM_Domain that describes the decomposition
integer, optional, intent(in) :: position !< This indicates the relative position of this
!! axis. The default is CENTER, but EAST and NORTH
!! are common options.
integer, optional, intent(in) :: direction !< This indicates the direction along which this
!! axis increases: 1 for upward, -1 for downward, or
!! 0 for non-vertical axes (the default)
integer, optional, intent(in) :: edges !< The axis_id of the complementary axis that
!! describes the edges of this axis
character(len=*), &
optional, intent(in) :: set_name !< A name to use for this set of axes.
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
!! by default.
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
!! id for use with scalars.

integer :: coarsening ! The degree of grid coarsening

if (present(null_axis)) then ; if (null_axis) then
! Return the special null axis id for scalars
MOM_diag_axis_init = null_axis_id
return
endif ; endif
character(len=*), intent(in) :: name !< The name of this axis
real, dimension(:), intent(in) :: data !< The array of coordinate values
character(len=*), intent(in) :: units !< The units for the axis data
character(len=*), intent(in) :: cart_name !< Cartesian axis ("X", "Y", "Z", "T", or "N" for none)
character(len=*), &
optional, intent(in) :: long_name !< The long name of this axis
type(MOM_domain_type), &
optional, intent(in) :: MOM_Domain !< A MOM_Domain that describes the decomposition
integer, optional, intent(in) :: position !< This indicates the relative position of this
!! axis. The default is CENTER, but EAST and NORTH
!! are common options.
integer, optional, intent(in) :: direction !< This indicates the direction along which this
!! axis increases: 1 for upward, -1 for downward, or
!! 0 for non-vertical axes (the default)
integer, optional, intent(in) :: edges !< The axis_id of the complementary axis that
!! describes the edges of this axis
character(len=*), &
optional, intent(in) :: set_name !< A name to use for this set of axes.
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
!! by default.
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
!! id for use with scalars.

integer :: coarsening ! The degree of grid coarsening

if (present(null_axis)) then ; if (null_axis) then
! Return the special null axis id for scalars
MOM_diag_axis_init = null_axis_id
return
endif ; endif

if (present(MOM_domain)) then
coarsening = 1 ; if (present(coarsen)) coarsening = coarsen
Expand Down
16 changes: 8 additions & 8 deletions config_src/infra/FMS1/MOM_domain_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1906,14 +1906,14 @@ end subroutine get_simple_array_j_ind

!> Invert the contents of a 1-d array
subroutine invert(array)
integer, dimension(:), intent(inout) :: array !< The 1-d array to invert
integer :: i, ni, swap
ni = size(array)
do i=1,ni
swap = array(i)
array(i) = array(ni+1-i)
array(ni+1-i) = swap
enddo
integer, dimension(:), intent(inout) :: array !< The 1-d array to invert
integer :: i, ni, swap
ni = size(array)
do i=1,ni
swap = array(i)
array(i) = array(ni+1-i)
array(ni+1-i) = swap
enddo
end subroutine invert

!> Returns the global shape of h-point arrays
Expand Down
60 changes: 30 additions & 30 deletions config_src/infra/FMS2/MOM_diag_manager_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,36 @@ module MOM_diag_manager_infra
!> Initialize a diagnostic axis
integer function MOM_diag_axis_init(name, data, units, cart_name, long_name, MOM_domain, position, &
& direction, edges, set_name, coarsen, null_axis)
character(len=*), intent(in) :: name !< The name of this axis
real, dimension(:), intent(in) :: data !< The array of coordinate values
character(len=*), intent(in) :: units !< The units for the axis data
character(len=*), intent(in) :: cart_name !< Cartesian axis ("X", "Y", "Z", "T", or "N" for none)
character(len=*), &
optional, intent(in) :: long_name !< The long name of this axis
type(MOM_domain_type), &
optional, intent(in) :: MOM_Domain !< A MOM_Domain that describes the decomposition
integer, optional, intent(in) :: position !< This indicates the relative position of this
!! axis. The default is CENTER, but EAST and NORTH
!! are common options.
integer, optional, intent(in) :: direction !< This indicates the direction along which this
!! axis increases: 1 for upward, -1 for downward, or
!! 0 for non-vertical axes (the default)
integer, optional, intent(in) :: edges !< The axis_id of the complementary axis that
!! describes the edges of this axis
character(len=*), &
optional, intent(in) :: set_name !< A name to use for this set of axes.
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
!! by default.
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
!! id for use with scalars.

integer :: coarsening ! The degree of grid coarsening

if (present(null_axis)) then ; if (null_axis) then
! Return the special null axis id for scalars
MOM_diag_axis_init = null_axis_id
return
endif ; endif
character(len=*), intent(in) :: name !< The name of this axis
real, dimension(:), intent(in) :: data !< The array of coordinate values
character(len=*), intent(in) :: units !< The units for the axis data
character(len=*), intent(in) :: cart_name !< Cartesian axis ("X", "Y", "Z", "T", or "N" for none)
character(len=*), &
optional, intent(in) :: long_name !< The long name of this axis
type(MOM_domain_type), &
optional, intent(in) :: MOM_Domain !< A MOM_Domain that describes the decomposition
integer, optional, intent(in) :: position !< This indicates the relative position of this
!! axis. The default is CENTER, but EAST and NORTH
!! are common options.
integer, optional, intent(in) :: direction !< This indicates the direction along which this
!! axis increases: 1 for upward, -1 for downward, or
!! 0 for non-vertical axes (the default)
integer, optional, intent(in) :: edges !< The axis_id of the complementary axis that
!! describes the edges of this axis
character(len=*), &
optional, intent(in) :: set_name !< A name to use for this set of axes.
integer, optional, intent(in) :: coarsen !< An optional degree of coarsening for the grid, 1
!! by default.
logical, optional, intent(in) :: null_axis !< If present and true, return the special null axis
!! id for use with scalars.

integer :: coarsening ! The degree of grid coarsening

if (present(null_axis)) then ; if (null_axis) then
! Return the special null axis id for scalars
MOM_diag_axis_init = null_axis_id
return
endif ; endif

if (present(MOM_domain)) then
coarsening = 1 ; if (present(coarsen)) coarsening = coarsen
Expand Down
16 changes: 8 additions & 8 deletions config_src/infra/FMS2/MOM_domain_infra.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1905,14 +1905,14 @@ end subroutine get_simple_array_j_ind

!> Invert the contents of a 1-d array
subroutine invert(array)
integer, dimension(:), intent(inout) :: array !< The 1-d array to invert
integer :: i, ni, swap
ni = size(array)
do i=1,ni
swap = array(i)
array(i) = array(ni+1-i)
array(ni+1-i) = swap
enddo
integer, dimension(:), intent(inout) :: array !< The 1-d array to invert
integer :: i, ni, swap
ni = size(array)
do i=1,ni
swap = array(i)
array(i) = array(ni+1-i)
array(ni+1-i) = swap
enddo
end subroutine invert

!> Returns the global shape of h-point arrays
Expand Down
2 changes: 1 addition & 1 deletion src/ALE/MOM_ALE.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ subroutine ALE_register_diags(Time, G, GV, US, diag, CS)
'm', conversion=GV%H_to_m, v_extensive=.true.)
cs%id_vert_remap_h_tendency = register_diag_field('ocean_model','vert_remap_h_tendency',diag%axestl,time, &
'Layer thicknesses tendency due to ALE regridding and remapping', &
'm s-1', conversion=GV%H_to_m*US%s_to_T, v_extensive = .true.)
'm s-1', conversion=GV%H_to_m*US%s_to_T, v_extensive=.true.)

end subroutine ALE_register_diags

Expand Down
2 changes: 1 addition & 1 deletion src/ALE/MOM_hybgen_remap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ subroutine hybgen_ppm_coefs(s, h_src, edges, nk, ns, thin, PCM_lay)
+ I_h0123(K)*( 2.*dp(k)*dp(k-1)*I_h12(K)*(s(k,i)-s(k-1,i)) * &
( h01_h112(K) - h23_h122(K) ) &
+ (dp(k)*as(k-1)*h23_h122(K) - dp(k-1)*as(k)*h01_h112(K)) )
ar(k-1) = al(k)
ar(k-1) = al(k)
enddo !k
ar(nk-1) = s(nk,i) ! last layer PCM
al(nk) = s(nk,i) ! last layer PCM
Expand Down
2 changes: 1 addition & 1 deletion src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ subroutine remapping_core_h(CS, n0, h0, u0, n1, h1, u1, h_neglect, h_neglect_edg
real, optional, intent(in) :: h_neglect_edge !< A negligibly small width
!! for the purpose of edge value
!! calculations in the same units as h0 [H]
logical, dimension(n0), optional, intent(in) :: PCM_cell !< If present, use PCM remapping for
logical, dimension(n0), optional, intent(in) :: PCM_cell !< If present, use PCM remapping for
!! cells in the source grid where this is true.

! Local variables
Expand Down
2 changes: 1 addition & 1 deletion src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
"If False, T/S are registered for advection. "//&
"This is intended only to be used in offline tracer mode "//&
"and is by default false in that case.", &
do_not_log = .true., default=.true. )
do_not_log=.true., default=.true.)
if (present(offline_tracer_mode)) then ! Only read this parameter in enabled modes
call get_param(param_file, "MOM", "OFFLINE_TRACER_MODE", CS%offline_tracer_mode, &
"If true, barotropic and baroclinic dynamics, thermodynamics "//&
Expand Down
2 changes: 1 addition & 1 deletion src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3053,7 +3053,7 @@ end subroutine apply_velocity_OBCs
!! boundary conditions, as developed by Mehmet Ilicak.
subroutine set_up_BT_OBC(OBC, eta, BT_OBC, BT_Domain, G, GV, US, MS, halo, use_BT_cont, &
integral_BT_cont, dt_baroclinic, Datu, Datv, BTCL_u, BTCL_v)
type(ocean_OBC_type), target, intent(inout) :: OBC !< An associated pointer to an OBC type.
type(ocean_OBC_type), target, intent(inout) :: OBC !< An associated pointer to an OBC type.
type(memory_size_type), intent(in) :: MS !< A type that describes the memory sizes of the
!! argument arrays.
real, dimension(SZIW_(MS),SZJW_(MS)), intent(in) :: eta !< The barotropic free surface height anomaly or
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,10 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, US, param
'Meridional Pressure Force Acceleration', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_ueffA = register_diag_field('ocean_model', 'ueffA', diag%axesCuL, Time, &
'Effective U-Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
y_cell_method='sum', v_extensive = .true.)
y_cell_method='sum', v_extensive=.true.)
CS%id_veffA = register_diag_field('ocean_model', 'veffA', diag%axesCvL, Time, &
'Effective V-Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
x_cell_method='sum', v_extensive = .true.)
x_cell_method='sum', v_extensive=.true.)

!CS%id_hf_PFu = register_diag_field('ocean_model', 'hf_PFu', diag%axesCuL, Time, &
! 'Fractional Thickness-weighted Zonal Pressure Force Acceleration', &
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,10 @@ subroutine initialize_dyn_unsplit(u, v, h, Time, G, GV, US, param_file, diag, CS
'Meridional Pressure Force Acceleration', 'm s-2', conversion=US%L_T2_to_m_s2)
CS%id_ueffA = register_diag_field('ocean_model', 'ueffA', diag%axesCuL, Time, &
'Effective U Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
y_cell_method='sum', v_extensive = .true.)
y_cell_method='sum', v_extensive=.true.)
CS%id_veffA = register_diag_field('ocean_model', 'veffA', diag%axesCvL, Time, &
'Effective V Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
x_cell_method='sum', v_extensive = .true.)
x_cell_method='sum', v_extensive=.true.)

id_clock_Cor = cpu_clock_id('(Ocean Coriolis & mom advection)', grain=CLOCK_MODULE)
id_clock_continuity = cpu_clock_id('(Ocean continuity equation)', grain=CLOCK_MODULE)
Expand Down
4 changes: 2 additions & 2 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,10 @@ subroutine initialize_dyn_unsplit_RK2(u, v, h, Time, G, GV, US, param_file, diag
'Meridional Pressure Force Acceleration', 'meter second-2', conversion=US%L_T2_to_m_s2)
CS%id_ueffA = register_diag_field('ocean_model', 'ueffA', diag%axesCuL, Time, &
'Effective U-Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
y_cell_method='sum', v_extensive = .true.)
y_cell_method='sum', v_extensive=.true.)
CS%id_veffA = register_diag_field('ocean_model', 'veffA', diag%axesCvL, Time, &
'Effective V-Face Area', 'm^2', conversion = GV%H_to_m*US%L_to_m, &
x_cell_method='sum', v_extensive = .true.)
x_cell_method='sum', v_extensive=.true.)

id_clock_Cor = cpu_clock_id('(Ocean Coriolis & mom advection)', grain=CLOCK_MODULE)
id_clock_continuity = cpu_clock_id('(Ocean continuity equation)', grain=CLOCK_MODULE)
Expand Down
14 changes: 7 additions & 7 deletions src/core/MOM_forcing_type.F90
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ module MOM_forcing_type
!! ice needs to be accumulated, and the rigidity explicitly
!! reset to zero at the driver level when appropriate.
real, pointer, dimension(:,:) :: &
ustk0 => NULL(), & !< Surface Stokes drift, zonal [m s-1]
vstk0 => NULL() !< Surface Stokes drift, meridional [m s-1]
ustk0 => NULL(), & !< Surface Stokes drift, zonal [m s-1]
vstk0 => NULL() !< Surface Stokes drift, meridional [m s-1]
real, pointer, dimension(:) :: &
stk_wavenumbers => NULL() !< The central wave number of Stokes bands [rad m-1]
stk_wavenumbers => NULL() !< The central wave number of Stokes bands [rad m-1]
real, pointer, dimension(:,:,:) :: &
ustkb => NULL(), & !< Stokes Drift spectrum, zonal [m s-1]
ustkb => NULL(), & !< Stokes Drift spectrum, zonal [m s-1]
!! Horizontal - u points
!! 3rd dimension - wavenumber
vstkb => NULL() !< Stokes Drift spectrum, meridional [m s-1]
vstkb => NULL() !< Stokes Drift spectrum, meridional [m s-1]
!! Horizontal - v points
!! 3rd dimension - wavenumber

Expand Down Expand Up @@ -1503,14 +1503,14 @@ subroutine register_forcing_type_diags(Time, diag, US, use_temperature, handles,
cmor_field_name='ave_evs', cmor_standard_name='water_evaporation_flux_area_averaged', &
cmor_long_name='Evaporation Where Ice Free Ocean over Sea Area Averaged')

handles%id_lprec_ga = register_scalar_field('ocean_model', 'lprec_ga', Time, diag,&
handles%id_lprec_ga = register_scalar_field('ocean_model', 'lprec_ga', Time, diag,&
long_name='Area integrated liquid precip into ocean', &
units='kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s, &
standard_name='rainfall_flux_area_averaged', &
cmor_field_name='ave_pr', cmor_standard_name='rainfall_flux_area_averaged', &
cmor_long_name='Rainfall Flux where Ice Free Ocean over Sea Area Averaged')

handles%id_fprec_ga = register_scalar_field('ocean_model', 'fprec_ga', Time, diag, &
handles%id_fprec_ga = register_scalar_field('ocean_model', 'fprec_ga', Time, diag, &
long_name='Area integrated frozen precip into ocean', &
units='kg m-2 s-1', conversion=US%RZ_T_to_kg_m2s, &
standard_name='snowfall_flux_area_averaged', &
Expand Down
2 changes: 1 addition & 1 deletion src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ end subroutine parse_segment_data_str

!> Parse all the OBC_SEGMENT_%%%_DATA strings again
!! to see which need tracer reservoirs (all pes need to know).
subroutine parse_for_tracer_reservoirs(OBC, PF, use_temperature)
subroutine parse_for_tracer_reservoirs(OBC, PF, use_temperature)
type(ocean_OBC_type), target, intent(inout) :: OBC !< Open boundary control structure
type(param_file_type), intent(in) :: PF !< Parameter file handle
logical, intent(in) :: use_temperature !< If true, T and S are used
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics/MOM_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ subroutine calculate_diagnostic_fields(u, v, h, uh, vh, tv, ADp, CDp, p_surf, &
! area mean SSS
if (CS%id_sosga > 0) then
do j=js,je ; do i=is,ie
surface_field(i,j) = tv%S(i,j,1)
surface_field(i,j) = tv%S(i,j,1)
enddo ; enddo
sosga = global_area_mean(surface_field, G)
call post_data(CS%id_sosga, sosga, CS%diag)
Expand Down
4 changes: 2 additions & 2 deletions src/equation_of_state/MOM_EOS_NEMO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ subroutine calculate_density_array_nemo(T, S, pressure, rho, start, npts, rho_re
rho(j) = ( zn + zr0 ) ! density
endif

enddo
enddo
end subroutine calculate_density_array_nemo

!> For a given thermodynamic state, calculate the derivatives of density with conservative
Expand Down Expand Up @@ -391,7 +391,7 @@ subroutine calculate_compress_nemo(T, S, pressure, rho, drho_dp, start, npts)
zt = T(j) !gsw_ct_from_pt(S(j),T(j)) !Convert potantial temp to conservative temp
zp = pressure(j)* Pa2db !Convert pressure from Pascal to decibar
call gsw_rho_first_derivatives(zs,zt,zp, drho_dp=drho_dp(j))
enddo
enddo
end subroutine calculate_compress_nemo

end module MOM_EOS_NEMO
2 changes: 1 addition & 1 deletion src/equation_of_state/MOM_TFreeze.F90
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ subroutine calculate_TFreeze_teos10_array(S, pres, T_Fr, start, npts)

if (S(j) < -1.0e-10) cycle !Can we assume safely that this is a missing value?
T_Fr(j) = gsw_ct_freezing_exact(zs,zp,saturation_fraction)
enddo
enddo

end subroutine calculate_TFreeze_teos10_array

Expand Down
Loading

0 comments on commit f54338a

Please sign in to comment.