Skip to content

Commit 6b643f6

Browse files
authored
Upgrade MPAS to version 8.2.1 (#288)
Currently, CAM-SIMA uses MPAS at commit `ed6f8e39ec0a811b6d079ca0fc6f9fb6e30bad23`, which is half way between MPAS versions 8.0.1 and 8.1.0. This PR upgrades MPAS to version 8.2.1, which was released on August 7, 2024. * MPAS dynamical core and its subdriver in CAM-SIMA now support MPI Fortran 2008 interface through the `mpi_f08` module. It can be enabled by defining the `MPAS_USE_MPI_F08` macro in `CPPFLAGS`. * The log file (e.g., `log.atmosphere.0000.out`) produced by MPAS dynamical core now correctly indicates its git version string. Before, it would always show "N/A" in the log, which is not very helpful. Now, if the git submodule of MPAS is aligned at a tag, it will just show the tag name (e.g., "v8.2.1"). Otherwise, if the git submodule of MPAS is not aligned at a tag, it will show the nearest tag name, the number of commits after that tag and the abbreviated commit hash (e.g., "v8.0.1-54-ged6f8e39e"). * Tidy up the build directory of MPAS dynamical core.
2 parents 278d7f3 + 7e059d1 commit 6b643f6

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
path = src/dynamics/mpas/dycore
99
url = https://github.com/MPAS-Dev/MPAS-Model.git
1010
fxsparse = ../.mpas_sparse_checkout
11-
fxtag = ed6f8e39ec0a811b6d079ca0fc6f9fb6e30bad23
11+
fxtag = v8.2.1
1212
fxrequired = AlwaysRequired
1313
fxDONOTUSEurl = https://github.com/MPAS-Dev/MPAS-Model.git
1414
[submodule "ncar-physics"]

src/dynamics/mpas/Makefile.in.CESM

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ ifeq ($(strip $(LIBROOT)),)
44
LIBROOT = ..
55
endif
66

7+
ifeq ($(strip $(SRCROOT)),)
8+
$(warning `SRCROOT` should not be empty. Defaulting to `..`)
9+
10+
SRCROOT = ..
11+
MPAS_SRC_ROOT = $(SRCROOT)
12+
else
13+
MPAS_SRC_ROOT = $(SRCROOT)/src/dynamics/mpas/dycore
14+
endif
15+
716
#
817
# Define and export variables used by MPAS build infrastructure.
918
#
@@ -19,7 +28,7 @@ export BUILD_TARGET = N/A
1928
export CORE = atmosphere
2029
export EXE_NAME = atmosphere_model
2130
export GEN_F90 = false
22-
export GIT_VERSION = N/A
31+
export GIT_VERSION = $(shell git -C "$(MPAS_SRC_ROOT)" describe --always --dirty --tags || echo "N/A")
2332
export NAMELIST_SUFFIX = atmosphere
2433

2534
# Customize variables (e.g., build options) for use with CESM.
@@ -57,9 +66,9 @@ all:
5766
@echo 'Users are responsible to provide all necessary build options via environment variables or command line arguments.'
5867
@echo ''
5968
@echo 'Usage hints:'
60-
@echo ' `make libmpas-prepare ESM="CESM" LIBROOT="..."`'
61-
@echo ' `make libmpas-build ESM="CESM" LIBROOT="..."`'
62-
@echo ' `make libmpas-clean ESM="CESM" LIBROOT="..."`'
69+
@echo ' `make libmpas-prepare ESM="CESM" LIBROOT="..." SRCROOT="..."`'
70+
@echo ' `make libmpas-build ESM="CESM" LIBROOT="..." SRCROOT="..."`'
71+
@echo ' `make libmpas-clean ESM="CESM" LIBROOT="..." SRCROOT="..."`'
6372

6473
.PHONY: libmpas-prepare
6574
libmpas-prepare: libmpas-archiver-script.txt libmpas-no-physics libmpas-prefix-namelist-groups libmpas-preview
@@ -116,7 +125,6 @@ $(LIBROOT)/libmpas.a: libmpas.a
116125

117126
libmpas.a: $(AUTOCLEAN_DEPS) dycore externals frame ops subdrv
118127
$(AR) $(ARFLAGS) < libmpas-archiver-script.txt
119-
@find -P . -name "*.mod" -type f -exec $(LN) "{}" . ";"
120128

121129
.PHONY: libmpas-clean
122130
libmpas-clean: clean
@@ -131,4 +139,5 @@ subdrv: driver/dyn_mpas_subdriver.o
131139

132140
%.o: %.F90 dycore frame ops
133141
( cd $(<D); $(FC) $(CPPFLAGS) $(FFLAGS) -c $(<F) $(CPPINCLUDES) $(FCINCLUDES) -I../framework -I../operators -I../core_$(CORE) -I../core_$(CORE)/dynamics )
134-
$(LN) $(@) .
142+
$(LN) $(*).mod .
143+
$(LN) $(*).o .

src/dynamics/mpas/driver/dyn_mpas_subdriver.F90

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ module dyn_mpas_subdriver
1010
use, intrinsic :: iso_fortran_env, only: output_unit
1111

1212
! Modules from external libraries.
13+
#ifdef MPAS_USE_MPI_F08
14+
use mpi_f08, only: mpi_comm_null, mpi_comm_rank, mpi_success, &
15+
mpi_comm_type => mpi_comm, operator(==)
16+
#else
1317
use mpi, only: mpi_comm_null, mpi_comm_rank, mpi_success
18+
#endif
1419
use pio, only: pio_char, pio_int, pio_real, pio_double, &
1520
file_desc_t, iosystem_desc_t, pio_file_is_open, pio_iosystem_is_active, &
1621
pio_inq_varid, pio_inq_varndims, pio_inq_vartype, pio_noerr
@@ -47,6 +52,7 @@ module dyn_mpas_subdriver
4752
mpas_pool_add_dimension, mpas_pool_get_dimension, &
4853
mpas_pool_get_field, mpas_pool_get_field_info, &
4954
mpas_pool_initialize_time_levels
55+
use mpas_stream_inquiry, only: mpas_stream_inquiry_new_streaminfo
5056
use mpas_stream_manager, only: postread_reindex, prewrite_reindex, postwrite_reindex
5157
use mpas_string_utils, only: mpas_string_replace
5258
use mpas_timekeeping, only: mpas_get_clock_time, mpas_get_time
@@ -76,7 +82,11 @@ end subroutine model_error_if
7682

7783
! Initialized by `dyn_mpas_init_phase1`.
7884
integer :: log_unit = output_unit
85+
#ifdef MPAS_USE_MPI_F08
86+
type(mpi_comm_type) :: mpi_comm = mpi_comm_null
87+
#else
7988
integer :: mpi_comm = mpi_comm_null
89+
#endif
8090
integer :: mpi_rank = 0
8191
logical :: mpi_rank_root = .false.
8292

@@ -447,7 +457,11 @@ end function stringify
447457
!-------------------------------------------------------------------------------
448458
subroutine dyn_mpas_init_phase1(self, mpi_comm, model_error_impl, log_unit, mpas_log_unit)
449459
class(mpas_dynamical_core_type), intent(inout) :: self
460+
#ifdef MPAS_USE_MPI_F08
461+
type(mpi_comm_type), intent(in) :: mpi_comm
462+
#else
450463
integer, intent(in) :: mpi_comm
464+
#endif
451465
procedure(model_error_if) :: model_error_impl
452466
integer, intent(in) :: log_unit
453467
integer, intent(in) :: mpas_log_unit(2)
@@ -503,7 +517,7 @@ subroutine dyn_mpas_init_phase1(self, mpi_comm, model_error_impl, log_unit, mpas
503517
call self % debug_print('Calling mpas_framework_init_phase1')
504518

505519
! Initialize MPAS framework with supplied MPI communicator group.
506-
call mpas_framework_init_phase1(self % domain_ptr % dminfo, mpi_comm=self % mpi_comm)
520+
call mpas_framework_init_phase1(self % domain_ptr % dminfo, external_comm=self % mpi_comm)
507521

508522
call self % debug_print('Setting up core')
509523

@@ -706,6 +720,15 @@ subroutine dyn_mpas_init_phase2(self, pio_iosystem)
706720
! Initialize MPAS framework with supplied PIO system descriptor.
707721
call mpas_framework_init_phase2(self % domain_ptr, io_system=pio_iosystem)
708722

723+
! Instantiate `streaminfo` but do not actually initialize it. Any queries made to it will always return `.false.`.
724+
! This is the intended behavior because MPAS as a dynamical core is not responsible for managing IO.
725+
self % domain_ptr % streaminfo => mpas_stream_inquiry_new_streaminfo()
726+
727+
if (.not. associated(self % domain_ptr % streaminfo)) then
728+
call self % model_error('Stream info instantiation failed for core ' // trim(self % domain_ptr % core % corename), &
729+
subname, __LINE__)
730+
end if
731+
709732
ierr = self % domain_ptr % core % define_packages(self % domain_ptr % packages)
710733

711734
if (ierr /= 0) then
@@ -714,7 +737,8 @@ subroutine dyn_mpas_init_phase2(self, pio_iosystem)
714737
end if
715738

716739
ierr = self % domain_ptr % core % setup_packages( &
717-
self % domain_ptr % configs, self % domain_ptr % packages, self % domain_ptr % iocontext)
740+
self % domain_ptr % configs, self % domain_ptr % streaminfo, &
741+
self % domain_ptr % packages, self % domain_ptr % iocontext)
718742

719743
if (ierr /= 0) then
720744
call self % model_error('Package setup failed for core ' // trim(self % domain_ptr % core % corename), &

src/dynamics/mpas/dycore

Submodule dycore updated 309 files

0 commit comments

Comments
 (0)