From 075eebb065a5a22be446227b836d72ba6d5cabd0 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Mon, 11 Apr 2022 16:02:12 -0400 Subject: [PATCH] Removal of non-standard extensions 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. --- src/core/MOM_open_boundary.F90 | 2 +- src/diagnostics/MOM_diagnostics.F90 | 3 --- src/tracer/MOM_tracer_hor_diff.F90 | 2 +- src/user/ISOMIP_initialization.F90 | 4 ++-- src/user/dumbbell_initialization.F90 | 2 +- src/user/seamount_initialization.F90 | 2 +- 6 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/core/MOM_open_boundary.F90 b/src/core/MOM_open_boundary.F90 index bda0b2df38..39ceccaf49 100644 --- a/src/core/MOM_open_boundary.F90 +++ b/src/core/MOM_open_boundary.F90 @@ -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 diff --git a/src/diagnostics/MOM_diagnostics.F90 b/src/diagnostics/MOM_diagnostics.F90 index ef71d9286c..22c0ddf8de 100644 --- a/src/diagnostics/MOM_diagnostics.F90 +++ b/src/diagnostics/MOM_diagnostics.F90 @@ -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.") diff --git a/src/tracer/MOM_tracer_hor_diff.F90 b/src/tracer/MOM_tracer_hor_diff.F90 index 3d2b322759..f3d77d2ef3 100644 --- a/src/tracer/MOM_tracer_hor_diff.F90 +++ b/src/tracer/MOM_tracer_hor_diff.F90 @@ -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 diff --git a/src/user/ISOMIP_initialization.F90 b/src/user/ISOMIP_initialization.F90 index 7386a008e6..b0601e2165 100644 --- a/src/user/ISOMIP_initialization.F90 +++ b/src/user/ISOMIP_initialization.F90 @@ -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 @@ -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 diff --git a/src/user/dumbbell_initialization.F90 b/src/user/dumbbell_initialization.F90 index 20beebc67f..2bc2533de5 100644 --- a/src/user/dumbbell_initialization.F90 +++ b/src/user/dumbbell_initialization.F90 @@ -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 diff --git a/src/user/seamount_initialization.F90 b/src/user/seamount_initialization.F90 index 3dba7bfe59..a112737248 100644 --- a/src/user/seamount_initialization.F90 +++ b/src/user/seamount_initialization.F90 @@ -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