Skip to content

Commit

Permalink
Merge branch 'hotfix-v7.1'
Browse files Browse the repository at this point in the history
This merge addresses several issues in the MPAS-Atmosphere model and
initialization, and it corrects several minor compilation issues.

MPAS-Atmosphere:
----------------

* In calculating moist air density in the real-data initialization case, virtual
  temperature, rather than temperature, should be used.

* An out-of-bounds array access in the GWDO scheme when running with multiple
  OpenMP threads has been corrected.

* A check has been added in the init_atmosphere core to ensure that the
  intermediate file interval and the 'surface' stream output interval are
  consistent.

* A non-standard BOZ-literal constant has been corrected in the
  module_ra_cam_support.F file. The non-standard constant lead to build
  failures, particularly with newer versions of the GNU compilers.

General software:
-----------------

* The logic to add PIO libraries to the definition of LIBS in the top-level
  Makefile has been updated to accommodate newer versions (approx. 2.5.2 or
  later) of the PIO library; without the fix to the Makefile, builds would
  fail with the message

  Checking for a usable PIO library...
  ************ ERROR ************
  Failed to compile a PIO test program
  Please ensure the PIO environment variable is set to the PIO installation directory
  ************ ERROR ************

* Various options for the 'gfortran' build target have been cleaned up.

* Occasional parallel build failures related to a race condition in the ezxml
  library compilation have been addressed.
  • Loading branch information
mgduda committed Sep 3, 2021
2 parents 51d5624 + 310e962 commit 7557b47
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 44 deletions.
32 changes: 19 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MODEL_FORMULATION =
MODEL_FORMULATION =


dummy:
Expand Down Expand Up @@ -219,14 +219,14 @@ gfortran:
"CC_SERIAL = gcc" \
"CXX_SERIAL = g++" \
"FFLAGS_PROMOTION = -fdefault-real-8 -fdefault-double-8" \
"FFLAGS_OPT = -O3 -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form" \
"CFLAGS_OPT = -O3 -m64" \
"CXXFLAGS_OPT = -O3 -m64" \
"LDFLAGS_OPT = -O3 -m64" \
"FFLAGS_DEBUG = -g -m64 -ffree-line-length-none -fconvert=big-endian -ffree-form -fbounds-check -fbacktrace -ffpe-trap=invalid,zero,overflow" \
"CFLAGS_DEBUG = -g -m64" \
"CXXFLAGS_DEBUG = -O3 -m64" \
"LDFLAGS_DEBUG = -g -m64" \
"FFLAGS_OPT = -O3 -ffree-line-length-none -fconvert=big-endian -ffree-form" \
"CFLAGS_OPT = -O3" \
"CXXFLAGS_OPT = -O3" \
"LDFLAGS_OPT = -O3" \
"FFLAGS_DEBUG = -g -ffree-line-length-none -fconvert=big-endian -ffree-form -fcheck=all -fbacktrace -ffpe-trap=invalid,zero,overflow" \
"CFLAGS_DEBUG = -g" \
"CXXFLAGS_DEBUG = -g" \
"LDFLAGS_DEBUG = -g" \
"FFLAGS_OMP = -fopenmp" \
"CFLAGS_OMP = -fopenmp" \
"CORE = $(CORE)" \
Expand Down Expand Up @@ -421,9 +421,9 @@ llvm:
"OPENMP = $(OPENMP)" \
"CPPFLAGS = $(MODEL_FORMULATION) -D_MPI" )

CPPINCLUDES =
FCINCLUDES =
LIBS =
CPPINCLUDES =
FCINCLUDES =
LIBS =

#
# If user has indicated a PIO2 library, define USE_PIO2 pre-processor macro
Expand Down Expand Up @@ -458,9 +458,15 @@ endif
# Depending on PIO version, libraries may be libpio.a, or libpiof.a and libpioc.a
# Keep open the possibility of shared libraries in future with, e.g., .so suffix
#
# Check if libpio.* exists and link -lpio if so, but we make an exception for
# libpio.settings (a file added in PIO2), which is not a library to link
ifneq ($(wildcard $(PIO_LIB)/libpio\.*), )
LIBS += -lpio
# Makefiles don't support "and" operators so we have nested "if" instead
ifneq "$(wildcard $(PIO_LIB)/libpio\.*)" "$(PIO_LIB)/libpio.settings"
LIBS += -lpio
endif
endif

ifneq ($(wildcard $(PIO_LIB)/libpiof\.*), )
LIBS += -lpiof
endif
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MPAS-v7.0
MPAS-v7.1
====

The Model for Prediction Across Scales (MPAS) is a collaborative project for
Expand Down
8 changes: 4 additions & 4 deletions src/core_atmosphere/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="atmosphere" core_abbrev="atm" version="7.0">
<registry model="mpas" core="atmosphere" core_abbrev="atm" version="7.1">

<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
Expand Down Expand Up @@ -1352,10 +1352,10 @@
description="weights for cell-centered second derivative, normal to edge, for transport scheme"/>

<var name="adv_coefs" type="real" dimensions="FIFTEEN nEdges" units="unitless"
description="Weighting coefficents used for reconstructing cell-based foelds at edges"/>
description="Weighting coefficients used for reconstructing cell-based fields at edges"/>

<var name="adv_coefs_3rd" type="real" dimensions="FIFTEEN nEdges" units="unitless"
description="Weighting coefficents used for reconstructing cell-based foelds at edges"/>
description="Weighting coefficients used for reconstructing cell-based fields at edges"/>

<var name="advCellsForEdge" type="integer" dimensions="FIFTEEN nEdges" units="-"
description="Cells used to reconstruct a cell-based field at an edge"/>
Expand Down Expand Up @@ -3009,7 +3009,7 @@
description="terrain height"/>

<var name="albedo12m" type="real" dimensions="nMonths nCells" units="unitless"
description="monthly-mean climatological aurface albedo"/>
description="monthly-mean climatological surface albedo"/>

<var name="greenfrac" type="real" dimensions="nMonths nCells" units="unitless"
description="monthly-mean climatological greeness fraction"/>
Expand Down
2 changes: 1 addition & 1 deletion src/core_atmosphere/physics/physics_wrf/module_bl_gwdo.F
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ subroutine gwdo2d(dudt, dvdt, dtaux2d, dtauy2d, &
dxy4p(its:ite,3) = dxy4(its:ite,4)
dxy4p(its:ite,4) = dxy4(its:ite,3)
!
cleff(its:ite) = dxmeter
cleff(its:ite) = dxmeter(its:ite)
!
! initialize arrays
!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MODULE module_ra_cam_support
implicit none
integer, parameter :: r8 = 8
real(r8), parameter:: inf = 1.e20 ! CAM sets this differently in infnan.F90
integer, parameter:: bigint = O'17777777777' ! largest possible 32-bit integer
integer, parameter:: bigint = int(O'17777777777') ! largest possible 32-bit integer

integer :: ixcldliq
integer :: ixcldice
Expand Down
2 changes: 1 addition & 1 deletion src/core_init_atmosphere/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="init_atmosphere" core_abbrev="init_atm" version="7.0">
<registry model="mpas" core="init_atmosphere" core_abbrev="init_atm" version="7.1">

<!-- **************************************************************************************** -->
<!-- ************************************** Dimensions ************************************** -->
Expand Down
20 changes: 18 additions & 2 deletions src/core_init_atmosphere/mpas_init_atm_cases.F
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ subroutine init_atm_setup_case(domain, stream_manager)
character(len=StrKIND), pointer :: xtime

type (MPAS_Time_type) :: curr_time, stop_time
type (MPAS_TimeInterval_type) :: clock_interval, lbc_stream_interval
type (MPAS_TimeInterval_type) :: clock_interval, lbc_stream_interval, surface_stream_interval
character(len=StrKIND) :: timeString

integer, pointer :: nCells
Expand Down Expand Up @@ -264,6 +264,21 @@ subroutine init_atm_setup_case(domain, stream_manager)
else if (config_init_case == 8 ) then
call mpas_log_write('real-data surface (SST) update test case ')
!
! Check that config_fg_interval matches the output_interval of the surface stream
!
clock_interval = mpas_get_clock_timestep(domain % clock, ierr=ierr)
surface_stream_interval = MPAS_stream_mgr_get_stream_interval(stream_manager, 'surface', MPAS_STREAM_OUTPUT, ierr)
if (clock_interval /= surface_stream_interval) then
call mpas_log_write('****************************************************************', messageType=MPAS_LOG_ERR)
call mpas_log_write('The intermediate SST file interval specified by ''config_fg_interval''', messageType=MPAS_LOG_ERR)
call mpas_log_write('does not match the output_interval for the ''surface'' stream.', messageType=MPAS_LOG_ERR)
call mpas_log_write('Please correct the namelist.init_atmosphere and/or', messageType=MPAS_LOG_ERR)
call mpas_log_write('streams.init_atmosphere files.', messageType=MPAS_LOG_ERR)
call mpas_log_write('****************************************************************', messageType=MPAS_LOG_CRIT)
end if
block_ptr => domain % blocklist
do while (associated(block_ptr))
call mpas_pool_get_subpool(block_ptr % structs, 'mesh', mesh)
Expand Down Expand Up @@ -4758,7 +4773,8 @@ subroutine init_atm_case_gfs(block, mesh, nCells, nEdges, nVertLevels, fg, state
t(k,iCell) = t(k,iCell) * (p0 / pressure(k,iCell)) ** (rgas / cp)
! RHO_ZZ
rho_zz(k,iCell) = pressure(k,iCell) / rgas / (p(k,iCell) * t(k,iCell))
rho_zz(k,iCell) = pressure(k,iCell) / rgas / (p(k,iCell) * t(k,iCell) &
* (1.0 + (rvord - 1.0) * scalars(index_qv,k,iCell)))
rho_zz(k,iCell) = rho_zz(k,iCell) / (1.0 + scalars(index_qv,k,iCell))
end do
end do
Expand Down
2 changes: 1 addition & 1 deletion src/core_landice/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="landice" core_abbrev="li" version="7.0">
<registry model="mpas" core="landice" core_abbrev="li" version="7.1">


<!-- ======================================================================= -->
Expand Down
2 changes: 1 addition & 1 deletion src/core_ocean/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="ocean" core_abbrev="ocn" version="7.0">
<registry model="mpas" core="ocean" core_abbrev="ocn" version="7.1">

<dims>
<dim name="nCells" units="unitless"
Expand Down
2 changes: 1 addition & 1 deletion src/core_seaice/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="seaice" core_abbrev="seaice" version="7.0">
<registry model="mpas" core="seaice" core_abbrev="seaice" version="7.1">

<dims>
<dim name="nCells"
Expand Down
2 changes: 1 addition & 1 deletion src/core_sw/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="sw" core_abbrev="sw" version="7.0">
<registry model="mpas" core="sw" core_abbrev="sw" version="7.1">
<dims>
<dim name="nCells"/>
<dim name="nEdges"/>
Expand Down
2 changes: 1 addition & 1 deletion src/core_test/Registry.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<registry model="mpas" core="test" core_abbrev="test" version="7.0">
<registry model="mpas" core="test" core_abbrev="test" version="7.1">
<dims>
<dim name="nCells"/>
<dim name="nEdges"/>
Expand Down
2 changes: 1 addition & 1 deletion src/external/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ esmf_time:
( cd esmf_time_f90; $(MAKE) FC="$(FC) $(FFLAGS)" CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS) -DHIDE_MPI" GEN_F90=$(GEN_F90) )

ezxml-lib:
( cd ezxml; $(MAKE) )
( cd ezxml; $(MAKE) OBJFILE="ezxml.o" )

clean:
( cd esmf_time_f90; $(MAKE) clean )
Expand Down
13 changes: 2 additions & 11 deletions src/external/ezxml/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
.SUFFIXES: .c .o

OBJS = ezxml.o

all: clean
$(MAKE) -j 1 library

library: $(OBJS)
$(OBJFILE): ezxml.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $(OBJFILE)

clean:
$(RM) *.o *.i

.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
4 changes: 2 additions & 2 deletions src/tools/input_gen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ EZXML_PATH= ../../external/ezxml

NL_OBJS = namelist_gen.o test_functions.o
ST_OBJS = streams_gen.o test_functions.o
XML_OBJS = $(EZXML_PATH)/ezxml.o
XML_OBJS = $(EZXML_PATH)/ezxml_tools.o

all: ezxml
($(MAKE) -j 1 namelist_gen CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)")
($(MAKE) -j 1 streams_gen CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)")

ezxml:
(cd $(EZXML_PATH); $(MAKE) CFLAGS="$(CFLAGS) $(TOOL_TARGET_ARCH)")
(cd $(EZXML_PATH); $(MAKE) CFLAGS="$(CFLAGS) $(TOOL_TARGET_ARCH)" OBJFILE="ezxml_tools.o")

namelist_gen: ezxml $(NL_OBJS) $(XML_OBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) -I$(EZXML_PATH) -o $@ $(NL_OBJS) $(XML_OBJS)
Expand Down
4 changes: 2 additions & 2 deletions src/tools/registry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ all: ezxml
($(MAKE) parse CPPFLAGS="$(CPPFLAGS)" CPPINCLUDES="$(CPPINCLUDES)")

ezxml:
(cd $(EZXML_PATH); $(MAKE) CFLAGS="$(CFLAGS) $(TOOL_TARGET_ARCH)")
(cd $(EZXML_PATH); $(MAKE) CFLAGS="$(CFLAGS) $(TOOL_TARGET_ARCH)" OBJFILE="ezxml_tools.o")

parse: $(OBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(EZXML_PATH)/ezxml.o -I$(EZXML_PATH) -o $@ $(OBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(EZXML_PATH)/ezxml_tools.o -I$(EZXML_PATH) -o $@ $(OBJS)

parse.o:

Expand Down

0 comments on commit 7557b47

Please sign in to comment.