Skip to content

Commit

Permalink
Add uninitialised variables check to CI build (#361)
Browse files Browse the repository at this point in the history
* Add uninitialised variables check to CI build
* Make optional preprocessor labels into comments
* gotm-4.0: Changed parameter to single precision to match call.
* Fixed some double ifdef defined preprocessor directives
* Removed all preprocessor comment like labels
* Undefine preprocessor types before reusing
* Fix formatting and update do/enddo in icarus.F90
* Rewrote deprecated arithmetic if statement for 20.04 compatibility
* Make init checks depend on setting DEBUG in build
* Only run debug compilation with non-atmosphere configs
  • Loading branch information
aidanheerdegen authored Feb 10, 2022
1 parent b74873b commit b68f137
Show file tree
Hide file tree
Showing 43 changed files with 167 additions and 120 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ jobs:
LIBACCESSOM2_ROOT: ${{ env.libaccessom2_dir }}
run: |
env
./MOM_compile.csh --type ${{ matrix.TYPE }} --platform github --use_netcdf4
case "${{ matrix.TYPE }}" in
CM2M|ICCM|ESM2M)
debug=""
;;
*)
debug="--debug"
;;
esac
echo ./MOM_compile.csh $debug --type ${{ matrix.TYPE }} --platform github --use_netcdf4
./MOM_compile.csh $debug --type ${{ matrix.TYPE }} --platform github --use_netcdf4
# ----------
# Test MOM-solo only currently
Expand All @@ -97,6 +106,7 @@ jobs:
uses: actions/checkout@v2
with:
repository: mom-ocean/MOM5-examples
ref: master
path: MOM5-examples

- name: Run bowl1 cold start
Expand Down
6 changes: 5 additions & 1 deletion bin/mkmf.template.github
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ FPPFLAGS := $(INCLUDE)

CFLAGS := -D__IFC -O2 -no-pie $(shell nc-config --cflags) -I/usr/include/openmpi $(INCLUDE)

FFLAGS := -O2 -no-pie -fcray-pointer -fdefault-real-8 -ffree-line-length-none -fno-range-check $(shell nf-config --fflags)
FFLAGS := -O -g -no-pie -fcray-pointer -fdefault-real-8 -ffree-line-length-none -fno-range-check $(shell nf-config --fflags)

ifdef DEBUG
FFLAGS := $(FFLAGS) -Wuninitialized -Wno-maybe-uninitialized -fcheck=bounds -Werror
endif

LDFLAGS += -no-pie $(LIBS)

Expand Down
2 changes: 2 additions & 0 deletions exp/MOM_compile.csh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ if ( $help ) then
echo
echo "--platform followed by the platform name that has a corresponding environ file in the ../bin dir, default is gfortran"
echo
echo "--debug make a debugging build"
echo
echo "--use_netcdf4 use NetCDF4, the default is NetCDF4. Warning: many of the standard experiments don't work with NetCDF4."
echo
echo "--no_environ do not source platform specific environment. Allows customising/overriding default environment"
Expand Down
10 changes: 5 additions & 5 deletions src/atmos_fv_dynamics/model/dyn_core.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module dyn_core

#ifdef MARS_GCM
use fv_pack, only: p_ref, fv_sponge_damp, fv_sponge_lev
#endif MARS_GCM
#endif


use pft_module, only: pft2d
Expand Down Expand Up @@ -249,7 +249,7 @@ subroutine cd_core(im, jm, km, nq, nx, jfirst, jlast, &
allocate( fc(im,jsfc:jnfc) )
#else
allocate( fc(jsfc:jnfc) )
#endif
#endif


#ifndef USE_LIMA
Expand Down Expand Up @@ -322,7 +322,7 @@ subroutine cd_core(im, jm, km, nq, nx, jfirst, jlast, &
call get_eta_level(km, p_ref, pfull, phalf, 0.01)
#else
call get_eta_level(km, 1.E5, pfull, phalf, 0.01)
#endif MARS_GCM
#endif


do k=1,km
Expand Down Expand Up @@ -891,7 +891,7 @@ subroutine geop_d(ptop, pe, delp, pk, wz, hs, pt, im, jm, km, &
real dp
#ifndef MARS_GCM
parameter (dpmin = 0.02) ! unit: pascal
#endif
#endif
integer :: ixjs, ixje


Expand Down Expand Up @@ -1034,7 +1034,7 @@ subroutine geopk(ptop, pe, delp, pk, wz, hs, pt, im, jm, km, &
#else
! rjw Note that dpmin was 0.02 in the memphis code
parameter (dpmin = 0.1) ! unit: pascal
#endif MARS_GCM
#endif

call fv_print_chksums( 'Entering geopk' )
call fv_array_check( LOC(hs) )
Expand Down
22 changes: 11 additions & 11 deletions src/atmos_fv_dynamics/model/fv_arrays.F90
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ module fv_arrays_mod
#ifdef MARS_GCM
real, allocatable :: delp_dt(:,:,:)
real, allocatable :: mars_sfc_budg(:,:,:)
#endif MARS_GCM
#endif

!! declarations from fv_pack.F90.1D2D
#ifdef MARS_GCM
integer, parameter :: NUMPTRS=28
#else
integer, parameter :: NUMPTRS=26
#endif MARS_GCM
#endif

integer(POINTER_KIND) :: ptrArray(NUMPTRS) !this array contains addresses to all the variables to be shared
!between physics and dynamics.
Expand Down Expand Up @@ -163,7 +163,7 @@ module fv_arrays_mod
ptr_u_srf, ptr_v_srf, ptr_u_dt, ptr_v_dt, ptr_t_dt, ptr_q_dt
# ifdef MARS_GCM
public :: ptr_delp_dt, ptr_mars_sfc_budg
# endif MARS_GCM
# endif

#else
!arrays themselves are public
Expand All @@ -173,9 +173,9 @@ module fv_arrays_mod
u_srf, v_srf, u_dt, v_dt, t_dt, q_dt
# ifdef MARS_GCM
public :: delp_dt, mars_sfc_budg
# endif MARS_GCM
# endif

#endif use_shared_pointers
#endif

contains

Expand Down Expand Up @@ -311,7 +311,7 @@ subroutine fv_arrays_init( nx, ny, nz, nt, shalo, nhalo, ighost, domain )
#ifdef MARS_GCM
allocate( delp_dt(isg:ieg, js:je, nz) )
allocate( mars_sfc_budg(isg:ieg, js:je, 5) )
#endif MARS_GCM
#endif
end if
isp = isg; iep = ieg
jsp = js; jep = je
Expand Down Expand Up @@ -347,7 +347,7 @@ subroutine fv_arrays_init( nx, ny, nz, nt, shalo, nhalo, ighost, domain )
#ifdef MARS_GCM
ptr_delp_dt = LOC(delp_dt)
ptr_mars_sfc_budg = LOC(mars_sfc_budg)
#endif MARS_GCM
#endif
!the array ptrArray is now filled by equivalence()
ptrArray( 1) = ptr_u
ptrArray( 2) = ptr_v
Expand Down Expand Up @@ -378,7 +378,7 @@ subroutine fv_arrays_init( nx, ny, nz, nt, shalo, nhalo, ighost, domain )
#ifdef MARS_GCM
ptrArray(27) = ptr_delp_dt
ptrArray(28) = ptr_mars_sfc_budg
#endif MARS_GCM
#endif
endif
call mpp_pset_broadcast_ptr( pset, ptrArray )
ptr_u = ptrArray( 1)
Expand Down Expand Up @@ -410,7 +410,7 @@ subroutine fv_arrays_init( nx, ny, nz, nt, shalo, nhalo, ighost, domain )
#ifdef MARS_GCM
ptr_delp_dt = ptrArray(27)
ptr_mars_sfc_budg = ptrArray(28)
#endif MARS_GCM
#endif
!isp,... index limits when you divide the computational domain by npex
isp = is
iep = ie
Expand Down Expand Up @@ -556,7 +556,7 @@ subroutine fv_print_chksums(caller)
delp_dt(isg:ieg,js:je,:) )
call mpp_pset_print_chksum( pset, trim(caller)//' mars_sfc_budg=', &
mars_sfc_budg(isg:ieg,js:je,:) )
#endif MARS_GCM
#endif
call mpp_pset_print_stack_chksum(pset, caller)
#endif
return
Expand Down Expand Up @@ -599,7 +599,7 @@ subroutine fv_arrays_exit
#ifdef MARS_GCM
deallocate ( delp_dt )
deallocate ( mars_sfc_budg )
#endif MARS_GCM
#endif


end if
Expand Down
6 changes: 3 additions & 3 deletions src/atmos_fv_dynamics/model/fv_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use fv_arrays_mod, only: is,ie,js,je, isd,ied,jsd,jed, isg,ieg,jsg,jeg
# ifdef MARS_GCM
use fv_arrays_mod, only: ptr_delp_dt, ptr_mars_sfc_budg
# endif MARS_GCM
# endif

#else
!get arrays from fv_arrays_mod
Expand All @@ -28,9 +28,9 @@

# ifdef MARS_GCM
use fv_arrays_mod, only: delp_dt, mars_sfc_budg
# endif MARS_GCM
# endif

#endif use_shared_pointers
#endif

implicit none

4 changes: 2 additions & 2 deletions src/atmos_fv_dynamics/model/fv_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,11 @@ subroutine fv_dynamics(im, jm, km, jfirst, jlast, &

#if !defined (SW_DYN)
call mp_send4d_ns(im, jm, km, 1, jfirst, jlast, 1, km, ng_d, ng_d, pt)
#endif
#endif
call mp_send4d_ns(im, jm, km, 1, jfirst, jlast, 1, km, ng_d, ng_d, delpf)
#if !defined (SW_DYN)
call mp_recv4d_ns(im, jm, km, 1, jfirst, jlast, 1, km, ng_d, ng_d, pt)
#endif
#endif
call mp_recv4d_ns(im, jm, km, 1, jfirst, jlast, 1, km, ng_d, ng_d, delpf)
call fv_array_sync()
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/atmos_fv_dynamics/model/fv_pack.F90
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ module fv_pack
tra_step, dyn_step, dry_mass, print_freq, icase, &
#ifdef MARS_GCM
p_ref, fv_sponge_lev, fv_sponge_damp, &
#endif MARS_GCM
#endif
layout, fv_pset_stack
#else
namelist /fv_core_nml/nlon, mlat, nlev, &
Expand All @@ -201,7 +201,7 @@ module fv_pack
use_tendency, do_ch4_chem, pft_phys, age_tracer, &
#ifdef MARS_GCM
p_ref, fv_sponge_lev, fv_sponge_damp, &
#endif MARS_GCM
#endif
print_freq, icase, layout

#endif
Expand Down Expand Up @@ -422,7 +422,7 @@ subroutine fv_init(ndt)
endif !}
#endif

#endif
#endif

call tm_register_tracers (MODEL_ATMOS, ncnst, nt_prog, pnats, num_family)
if(mpp_pe() == mpp_root_pe()) then
Expand Down Expand Up @@ -592,7 +592,7 @@ subroutine fv_init(ndt)

#ifdef MARS_GCM
cp_vir = 0.0
#endif
#endif

!--------------------------------------------
! Set up horizontal grid geometrical factors:
Expand Down Expand Up @@ -1400,7 +1400,7 @@ subroutine drymadj( im, jm, km, jfirst, jlast, ng, &
enddo
enddo
endif
#endif MARS_GCM
#endif

1000 continue
call fv_array_sync() !probably needed before gmean
Expand Down
8 changes: 4 additions & 4 deletions src/atmos_fv_dynamics/model/fv_point.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#ifdef MARS_GCM
real :: delp_dt(isg:ieg, js:je, nlev)
real :: mars_sfc_budg(isg:ieg, js:je, 5)
#endif MARS_GCM
#endif
pointer( p_u, u )
pointer( p_v, v )
pointer( p_delp, delp )
Expand Down Expand Up @@ -60,7 +60,7 @@
#ifdef MARS_GCM
pointer( p_delp_dt, delp_dt )
pointer( p_mars_sfc_budg, mars_sfc_budg )
#endif MARS_GCM
#endif
!point all the shared pointers
p_u = ptr_u
p_v = ptr_v
Expand Down Expand Up @@ -91,6 +91,6 @@
#ifdef MARS_GCM
p_delp_dt = ptr_delp_dt
p_mars_sfc_budg = ptr_mars_sfc_budg
#endif MARS_GCM
#endif

#endif use_shared_pointers
#endif
8 changes: 4 additions & 4 deletions src/atmos_fv_dynamics/model/update_fv_phys.F90
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ subroutine update_fv_phys ( dt, nq, full_phys, nudge, Time )
enddo

endif
#endif
#endif

! Average tendencies for scalars at poles (make it single-valued)
! This is necessary because the the physics/land/ocean use different grid
Expand All @@ -160,7 +160,7 @@ subroutine update_fv_phys ( dt, nq, full_phys, nudge, Time )
#ifdef MARS_GCM
!!!! call polavg( delp_dt(1,beglat,k), nlon, mlat, beglat, endlat)
!!!! This is carried out in fv_phys.F90
#endif MARS_GCM
#endif

if ( use_tendency ) then
do j=beglat,endlat
Expand Down Expand Up @@ -234,7 +234,7 @@ subroutine update_fv_phys ( dt, nq, full_phys, nudge, Time )
enddo
! endif
enddo
#endif
#endif
endif

enddo ! -----------------------k-loop------------------
Expand Down Expand Up @@ -358,7 +358,7 @@ subroutine update_fv_phys ( dt, nq, full_phys, nudge, Time )
endif
call fv_array_sync()
u_ghosted = .false.
#endif SPMD
#endif
call fv_print_chksums( 'Exiting update_fv_phys' )
end subroutine update_fv_phys

Expand Down
16 changes: 8 additions & 8 deletions src/atmos_fv_dynamics/tools/fv_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module fv_diagnostics
#ifdef MARS_GCM
use fv_pack, only: p_ref
use fv_phys_mod, only: mars_mass_budget
#endif MARS_GCM
#endif

! --- tracer manager ---
use tracer_manager_mod, only : get_tracer_names, get_number_tracers
Expand Down Expand Up @@ -91,7 +91,7 @@ subroutine fv_diag_init(axes, Time)
trange = (/ 50., 350. /) ! temperature
#else
trange = (/ 100., 350. /) ! temperature
#endif
#endif
arange = (/ 0., 20. /) ! age-of-air
slprange = (/800., 1200./) ! sea-level-pressure

Expand All @@ -104,7 +104,7 @@ subroutine fv_diag_init(axes, Time)
call get_eta_level(nlev, p_ref, pfull, phalf, 0.01)
#else
call get_eta_level(nlev, 1.E5, pfull, phalf, 0.01)
#endif
#endif

id_lonb=diag_axis_init('lonb', lonb, 'degrees_E', 'x', 'longitude edges', &
set_name=mod_name , Domain2=fv_domain )
Expand Down Expand Up @@ -236,7 +236,7 @@ subroutine fv_diag_init(axes, Time)
enddo
! for higher tracer number we take the default missing values from FMS
do i = nt_phys+1, ncnst
#endif MARS_GCM
#endif
call get_tracer_names ( MODEL_ATMOS, i, tname, tlongname, tunits )
id_tracer(i) = register_diag_field ( mod_name, trim(tname), &
axes(1:3), Time, trim(tlongname), &
Expand Down Expand Up @@ -278,7 +278,7 @@ subroutine fv_diag_init(axes, Time)
endif
endif
enddo
#endif
#endif
!-------

endif !}
Expand Down Expand Up @@ -475,7 +475,7 @@ subroutine fv_diag( Time, im, jm, km, jfirst, jlast, nq, zvir, dt_atmos, hs_phys
call drymadj(im, jm, km, jfirst, jlast, ng_d, .true., kappa, &
ptop, ps, delp, pe, pk, peln, pkz, nq, &
q, .false.)
#endif MARS_GCM
#endif
call pmaxmin('U', ua, qmin, qmax, im*(jlast-jfirst+1), km, 1.)
call pmaxmin('V', va, qmin, qmax, im*(jlast-jfirst+1), km, 1.)
endif
Expand Down Expand Up @@ -595,7 +595,7 @@ subroutine fv_diag( Time, im, jm, km, jfirst, jlast, nq, zvir, dt_atmos, hs_phys
if(qmin < 50.) call error_mesg('fv_diagnostics:','too cold', FATAL)
#else
if(qmin < 100.) call error_mesg('fv_diagnostics:','too cold', FATAL)
#endif
#endif
endif

endif
Expand Down Expand Up @@ -776,7 +776,7 @@ subroutine fv_diag( Time, im, jm, km, jfirst, jlast, nq, zvir, dt_atmos, hs_phys
endif
endif
enddo
#endif
#endif
!-------

! Check tracer mass. Unit:
Expand Down
Loading

0 comments on commit b68f137

Please sign in to comment.