Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI communicator generalizations #1277

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions model/bin/build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ create_file_list()
prop=
sourcet="w3parall w3triamd w3gridmd $stx $flx $nlx $btx $is $uostmd"
IO='w3iogrmd'
aux="constants w3servmd w3arrymd w3dispmd w3gsrumd w3timemd w3nmlgridmd $pdlibyow $memcode"
aux="constants mpicomm w3servmd w3arrymd w3dispmd w3gsrumd w3timemd w3nmlgridmd $pdlibyow $memcode"
if [ "$scrip" = 'SCRIP' ]
then
aux="$aux scrip_constants scrip_grids scrip_iounitsmod"
Expand All @@ -819,42 +819,42 @@ create_file_list()
prop=
sourcet="$pdlibcode $pdlibyow $db $tr $trx $bt $setupcode $stx $flx $nlx $btx $is wmmdatmd w3parall $uostmd"
IO='w3iogrmd w3iorsmd'
aux="constants w3triamd w3servmd w3arrymd w3dispmd w3gsrumd w3timemd" ;;
aux="constants mpicomm w3triamd w3servmd w3arrymd w3dispmd w3gsrumd w3timemd" ;;
ww3_bound)
core=
data="w3adatmd $memcode w3gdatmd w3wdatmd w3idatmd w3odatmd"
prop="$smcm"
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $tr $trx $stx $nlx $btx $is wmmdatmd w3parall w3triamd $uostmd"
IO='w3iobcmd w3iogrmd w3dispmd w3gsrumd'
aux="constants w3servmd w3timemd w3arrymd w3cspcmd w3nmlboundmd" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3cspcmd w3nmlboundmd" ;;
ww3_bounc)
core=
data="w3adatmd $memcode w3gdatmd w3wdatmd w3idatmd w3odatmd"
prop="$smcm"
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $stx $nlx $btx $is wmmdatmd w3parall w3triamd $uostmd"
IO='w3iobcmd w3iogrmd w3dispmd w3gsrumd'
aux="constants w3servmd w3arrymd w3timemd w3cspcmd w3nmlbouncmd" ;;
aux="constants mpicomm w3servmd w3arrymd w3timemd w3cspcmd w3nmlbouncmd" ;;
ww3_prep)
core='w3fldsmd'
data="$memcode w3gdatmd w3adatmd w3idatmd w3odatmd w3wdatmd wmmdatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3triamd $stx $flx $nlx $btx $is $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd $tidecode w3arrymd w3dispmd w3gsrumd w3parall" ;;
aux="constants mpicomm w3servmd w3timemd $tidecode w3arrymd w3dispmd w3gsrumd w3parall" ;;
ww3_prnc)
core='w3fldsmd'
data="$memcode w3gdatmd w3adatmd w3idatmd w3odatmd w3wdatmd wmmdatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3triamd $stx $flx $nlx $btx $is w3parall $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd w3tidemd w3nmlprncmd" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd w3tidemd w3nmlprncmd" ;;
ww3_prtide)
core='w3fldsmd'
data="wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop="$pr $smcm"
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3triamd $stx $nlx $btx $is w3parall $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
ww3_shel)
core='w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd'
data="wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
Expand All @@ -863,7 +863,7 @@ create_file_list()
sourcet="$sourcet $is $db $tr $bs $refcode $igcode w3parall $uostmd"
IO="w3iogrmd w3iogomd w3iopomd w3iotrmd w3iorsmd w3iobcmd $oasismd $agcmmd $ogcmmd $igcmmd"
IO="$IO w3iosfmd w3partmd"
aux="constants w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd"
aux="$aux w3nmlshelmd $pdlibyow" ;;
ww3_multi|ww3_multi_esmf)
if [ "$prog" = "ww3_multi" ]
Expand All @@ -879,7 +879,7 @@ create_file_list()
sourcet="$pdlibcode $pdlibyow $setupcode w3parall w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $ic $is $db $tr $bs $refcode $igcode $uostmd"
IO='w3iogrmd w3iogomd w3iopomd wmiopomd'
IO="$IO w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants $tidecode w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux"
aux="constants mpicomm $tidecode w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux"
aux="$aux wmunitmd w3nmlmultimd"
if [ "$scrip" = 'SCRIP' ]
then
Expand All @@ -899,7 +899,7 @@ create_file_list()
sourcet="$pdlibcode $pdlibyow w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $db $tr $bs $refcode $igcode $is $ic $uostmd"
IO='w3iogrmd w3iogomd w3iopomd wmiopomd'
IO="$IO w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux $tidecode"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3cspcmd w3gsrumd $mprfaux $tidecode"
aux="$aux wmunitmd w3nmlmultimd"
if [ "$scrip" = 'SCRIP' ]
then
Expand All @@ -917,104 +917,104 @@ create_file_list()
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $tr $trx $stx $flx $nlx $btx $is $uostmd"
IO='w3iogrmd w3iogomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux" ;;
ww3_ounf)
core='w3initmd'
data="wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode w3parall w3triamd $stx $flx $nlx $btx $is $uostmd"
IO='w3iogrmd w3iogomd w3iorsmd w3iopomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3nmlounfmd $smco w3ounfmetamd w3metamd" ;;
ww3_outp)
core=
data="wmmdatmd w3parall w3triamd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $setupcode $flx $ln $st $nl $bt $ic $is $db $tr $bs $igcode $uostmd"
IO='w3bullmd w3iogrmd w3iopomd w3partmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd" ;;
ww3_ounp)
core=
data="wmmdatmd w3parall w3triamd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $setupcode $flx $ln $st $nl $bt $ic $is $db $tr $bs $igcode $uostmd"
IO='w3bullmd w3iogrmd w3iopomd w3partmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3nmlounpmd" ;;
ww3_trck)
core=
data="$memcode w3gdatmd w3odatmd"
prop=
sourcet=
IO=
aux="constants w3servmd w3timemd w3gsrumd" ;;
aux="constants mpicomm w3servmd w3timemd w3gsrumd" ;;
ww3_trnc)
core=
data="$memcode w3gdatmd w3odatmd"
prop=
sourcet=
IO=
aux="constants w3servmd w3timemd w3gsrumd w3nmltrncmd" ;;
aux="constants mpicomm w3servmd w3timemd w3gsrumd w3nmltrncmd" ;;
ww3_grib)
core=
data="w3parall wmmdatmd w3triamd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode $stx $flx $nlx $btx $is $uostmd"
IO='w3iogrmd w3iogomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux" ;;
ww3_gspl)
core='w3fldsmd'
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3parall w3triamd $stx $flx $nlx $btx $is $uostmd"
IO="w3iogrmd $oasismd $agcmmd $ogcmmd $igcmmd"
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd $tidecode" ;;
ww3_gint)
core=
data="w3parall wmmdatmd $memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
IO='w3iogrmd w3iogomd'
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $st $nl $is $uostmd"
aux="constants w3triamd w3servmd w3arrymd w3dispmd w3timemd w3gsrumd"
aux="constants mpicomm w3triamd w3servmd w3arrymd w3dispmd w3timemd w3gsrumd"
aux="$aux" ;;
gx_outf)
core=
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3parall w3triamd $stx $flx $nlx $btx $tr $bs $is $uostmd"
IO='w3iogrmd w3iogomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux" ;;
gx_outp)
core=
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3parall w3triamd $ln $flx $st $nlx $btx $tr $bs $is $ic $uostmd"
IO='w3iogrmd w3iopomd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd" ;;
ww3_systrk)
core='w3strkmd'
data="$memcode w3gdatmd w3adatmd w3idatmd w3odatmd w3wdatmd"
prop=
sourcet="$pdlibcode $pdlibyow $db $bt $setupcode wmmdatmd w3dispmd w3triamd $ln $stx $flx $nlx $btx $tr $bs $is $uostmd"
IO=
aux="constants w3servmd w3timemd w3arrymd w3gsrumd w3parall" ;;
aux="constants mpicomm w3servmd w3timemd w3arrymd w3gsrumd w3parall" ;;
libww3|libww3.so)
core='w3fldsmd w3initmd w3wavemd w3wdasmd w3updtmd'
data='wmmdatmd w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd'
prop="$pr $smcm"
sourcet="w3triamd w3srcemd $dsx $flx $ln $st $nl $bt $ic $is $db $tr $bs $refcode $igcode $uostmd"
IO='w3iogrmd w3iogomd w3iopomd w3iotrmd w3iorsmd w3iobcmd w3iosfmd w3partmd'
aux="constants w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd" ;;
aux="constants mpicomm w3servmd w3timemd $tidecode w3arrymd w3dispmd w3cspcmd w3gsrumd" ;;
ww3_uprstr)
core=
data='wmmdatmd w3triamd w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd'
prop=
sourcet="$memcode $pdlibcode $pdlibyow $flx $ln $st $nl $bt $ic $is $db $tr $bs $uostmd"
IO='w3iogrmd w3iogomd w3iorsmd'
aux="constants w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="constants mpicomm w3servmd w3timemd w3arrymd w3dispmd w3gsrumd"
aux="$aux w3parall w3nmluprstrmd" ;;
esac

Expand Down
1 change: 1 addition & 0 deletions model/src/cmake/src_list.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(c_src w3getmem.c)
# Core files always built
set(ftn_src
constants.F90
mpicomm.F90
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear to me if this should only be included if you have the MPI switch and therefore be added in model/src/cmake/switches.json instead.

Copy link
Author

@jmsexton03 jmsexton03 Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try to include ifdefs to make mpicomm.F90 not affect anything if it was compiled without MPI, but I can try to change this to model/src/cmake/switches.json since that sounds cleaner (I will wait on this fix for further clarity on whether a separate module is needed)

w3adatmd.F90
w3arrymd.F90
w3bullmd.F90
Expand Down
2 changes: 1 addition & 1 deletion model/src/cmake/switches.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
},
{
"name": "NL2",
"build_files": ["w3snl2md.F90", "mod_xnl4v5.f90", "serv_xnl4v5.f90", "mod_fileio.f90", "mod_constants.f90"],
"build_files": ["w3snl2md.F90", "mod_xnl4v5.f90", "serv_xnl4v5.f90", "mod_fileio.f90", "mod_constants.f90", "mod_mpicomm.f90"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see a file mod_mpicomm.f90.

Also I think mpicomm.F90 should be adde with the MPI switch not NL2.

Copy link
Author

@jmsexton03 jmsexton03 Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert this change, I was initially confused about whether mod files were separately needed
(I will wait on this fix for further clarity on whether a separate module is needed)

"conflicts": ["OMPG", "OMPH"]
},
{
Expand Down
61 changes: 61 additions & 0 deletions model/src/mpicomm.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
!> @file
!> @brief Defines MPI communicator id as constants for global use.
!>
!> @author H. L. Tolman @date 05-Jun-2018
!>
#include "w3macros.h"

!>
!> @brief Define some mpi constants for global use
!>
!> @author J. M. Sexton @date 19-Jul-2024
!>
!
!
!/ ------------------------------------------------------------------- /
MODULE MPICOMM
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly lightweight routine, should we add this to an existing file such as constants?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the ramifications would be here, I'll consult with one of my collaborators who'd originally suggested having it as a separate file. I believe the intent was to make it more portable and obviously defined. Would w3parall.F90 be appropriate? I do see that IS_ESMF_COMPONENT is in constants.F90

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move things to another location if that's your preference. When you know, can you point me to where specifically so that I can push an update?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w3parall is mostly for unstructured grids, where as this is for all grids, so I think constants might be a better choice. Others can weigh in on this thought too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, and I'm also interested in others thoughts 🙂 I was originally looking at w3parall because the SYNCHRONIZE_GLOBAL_ARRAY has been useful in our coupling tests so far, although I do see now that the header for this file indicates it's "Parallel routines for implicit solver"

!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | H. L. Tolman |
!/ | FORTRAN 90 |
!/ | Last update : 19-Jul-2024 |
!/ +-----------------------------------+
!/
!/ 19-Jul-2024 : Add MPI SubCommunicator variable ( version 7.xx )
!/
!/ Copyright 2009-2024 National Weather Service (NWS),
!/ National Oceanic and Atmospheric Administration. All rights
!/ reserved. WAVEWATCH III is a trademark of the NWS.
!/ No unauthorized use without permission.
!/
! 1. Purpose :
!
! Define some mpi constants for global use
!
! 2. Variables and types :
!
! Name Type Scope Description
! ----------------------------------------------------------------
! MPI_COMM_WW3 Int Global Value for mpi (sub)communicator for WW3
! IS_EXTERNAL_COMPONENT Bool Global General logical similar to IS_ESMF_COMPONENT
! ----------------------------------------------------------------
!/ ------------------------------------------------------------------- /
!/
!

INTEGER :: MPI_COMM_WW3=0 !< MPI_COMM_WW3
!
! Parameters in support of running as ESMF component
!
! --- Flag indicating whether or not the model has been invoked as an
! external Component. This flag is set to true in the external
! module during initialization.
LOGICAL :: IS_EXTERNAL_COMPONENT = .FALSE. !< IS_EXTERNAL_COMPONENT Flag for model invoked via external executable.
!
CONTAINS

!/
!/ End of module MPICOMM ------------------------------------------- /
!/
END MODULE MPICOMM
2 changes: 1 addition & 1 deletion model/src/w3gsrumd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9631,7 +9631,7 @@ SUBROUTINE EXTCDE(IEXIT)
LOGICAL :: RUN
CALL MPI_INITIALIZED ( RUN, IERR_MPI )
IF ( RUN ) THEN
CALL MPI_ABORT ( MPI_COMM_WORLD, IEXIT, IERR_MPI )
CALL MPI_ABORT ( MPI_COMM_WW3, IEXIT, IERR_MPI )
END IF
#endif
CALL EXIT(IEXIT)
Expand Down
1 change: 1 addition & 0 deletions model/src/w3initmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD,
UA, UD, U10, U10D, AS
#ifdef W3_MPI
USE W3ADATMD, ONLY: MPI_COMM_WAVE, MPI_COMM_WCMP
USE MPICOMM, ONLY: MPI_COMM_WW3
#endif
USE W3IDATMD, ONLY: FLLEV, FLCUR, FLWIND, FLICE, FLTAUA, FLRHOA,&
FLMDN, FLMTH, FLMVS, FLIC1, FLIC2, FLIC3, &
Expand Down
6 changes: 5 additions & 1 deletion model/src/w3servmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ MODULE W3SERVMD
!/ ------------------------------------------------------------------- /

! module default
#ifdef W3_MPI
USE MPICOMM, ONLY: MPI_COMM_WW3
#endif
!
implicit none

PUBLIC
Expand Down Expand Up @@ -864,7 +868,7 @@ SUBROUTINE EXTCDE ( IEXIT, UNIT, MSG, FILE, LINE, COMM )
IF (PRESENT(COMM)) THEN
WRITE(*,'(/A,I6/)') 'EXTCDE COMM=', COMM
END IF
CALL MPI_ABORT ( MPI_COMM_WORLD, IEXIT, IERR_MPI )
CALL MPI_ABORT ( MPI_COMM_WW3, IEXIT, IERR_MPI )
END IF
END IF
#endif
Expand Down
Loading
Loading