Skip to content

Commit

Permalink
Removal of non-standard extensions
Browse files Browse the repository at this point in the history
This patch removes any non-standard compiler extensions from the source
and replaces them with equivalent standard statements.

Specifically, this allows the code to be compiled with GCC using the
-std=f2018 flag.

None of these changes impact GFDL testing, since all extensions were
supported by GNU, Intel, and PGI, but at least offer some greater
assurance that the code will compile and behave more predicably on
as-yet untested platforms.

The specific changes are outlined below:

* `loc() == 0` tests have been replaced with `associated()` where
  appropriate.  (If field is not a pointer then it was removed, since
  using loc() was already a very bad idea.)

* the `dfloat()` type conversion was replaced with `real()`.
  For consistency with existing MOM code, the `kind` remains
  unspecified.  Technically this could represent an answer change, but
  was only applied to nz, which is always a very small integer.

* `abort()` is an extension, and is replaced with the compliant (and
  admittedly platform-dependent) `error stop` statement.
  • Loading branch information
marshallward committed Apr 12, 2022
1 parent 7a147ad commit d8bc963
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1741,7 +1741,7 @@ subroutine parse_segment_param_real(segment_str, var, param_value, debug )
endif
enddo
if (m==0) then
call abort()
error stop
endif

! Process first word which will start with the fieldname
Expand Down
3 changes: 0 additions & 3 deletions src/diagnostics/MOM_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ subroutine calculate_diagnostic_fields(u, v, h, uh, vh, tv, ADp, CDp, p_surf, &
! This value is roughly (pi / (the age of the universe) )^2.
absurdly_small_freq2 = 1e-34*US%T_to_s**2

if (loc(CS)==0) call MOM_error(FATAL, &
"calculate_diagnostic_fields: Module must be initialized before used.")

if (.not. CS%initialized) call MOM_error(FATAL, &
"calculate_diagnostic_fields: Module must be initialized before used.")

Expand Down
2 changes: 1 addition & 1 deletion src/tracer/MOM_tracer_hor_diff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, G, GV, US, CS, Reg, tv, do_online

if (.not. associated(CS)) call MOM_error(FATAL, "MOM_tracer_hor_diff: "// &
"register_tracer must be called before tracer_hordiff.")
if (LOC(Reg)==0) call MOM_error(FATAL, "MOM_tracer_hor_diff: "// &
if (.not. associated(Reg)) call MOM_error(FATAL, "MOM_tracer_hor_diff: "// &
"register_tracer must be called before tracer_hordiff.")
if (Reg%ntr == 0 .or. (CS%KhTr <= 0.0 .and. .not. VarMix%use_variable_mixing)) return

Expand Down
4 changes: 2 additions & 2 deletions src/user/ISOMIP_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ subroutine ISOMIP_initialize_thickness ( h, depth_tot, G, GV, US, param_file, tv
case ( REGRIDDING_SIGMA ) ! Initial thicknesses for sigma coordinates
if (just_read) return ! All run-time parameters have been read, so return.
do j=js,je ; do i=is,ie
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / dfloat(nz)
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / real(nz)
enddo ; enddo

case default
Expand Down Expand Up @@ -574,7 +574,7 @@ subroutine ISOMIP_initialize_sponges(G, GV, US, tv, depth_tot, PF, use_ALE, CSp,

case ( REGRIDDING_SIGMA ) ! Initial thicknesses for sigma coordinates
do j=js,je ; do i=is,ie
h(i,j,:) = GV%Z_to_H * (depth_tot(i,j) / dfloat(nz))
h(i,j,:) = GV%Z_to_H * (depth_tot(i,j) / real(nz))
enddo ; enddo

case default
Expand Down
2 changes: 1 addition & 1 deletion src/user/dumbbell_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ subroutine dumbbell_initialize_thickness ( h, depth_tot, G, GV, US, param_file,
case ( REGRIDDING_SIGMA ) ! Initial thicknesses for sigma coordinates
if (just_read) return ! All run-time parameters have been read, so return.
do j=js,je ; do i=is,ie
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / dfloat(nz)
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / real(nz)
enddo ; enddo

end select
Expand Down
2 changes: 1 addition & 1 deletion src/user/seamount_initialization.F90
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ subroutine seamount_initialize_thickness (h, depth_tot, G, GV, US, param_file, j
case ( REGRIDDING_SIGMA ) ! Initial thicknesses for sigma coordinates
if (just_read) return ! All run-time parameters have been read, so return.
do j=js,je ; do i=is,ie
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / dfloat(nz)
h(i,j,:) = GV%Z_to_H * depth_tot(i,j) / real(nz)
enddo ; enddo

end select
Expand Down

0 comments on commit d8bc963

Please sign in to comment.