From 5dc8f66fd06b2419b91686a37364905be4c40e80 Mon Sep 17 00:00:00 2001 From: Dusan Jovic Date: Thu, 24 Mar 2022 14:48:30 +0000 Subject: [PATCH] Resolve argument mismatch errors when using gfortran Switch from 'use mpi' to 'use mpi_f08' --- cellular_automata_global.F90 | 4 +++- cellular_automata_sgs.F90 | 4 +++- mpi_wrapper.F90 | 11 ++++++----- stochastic_physics.F90 | 8 ++++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/cellular_automata_global.F90 b/cellular_automata_global.F90 index 2f3f236..6451ab5 100644 --- a/cellular_automata_global.F90 +++ b/cellular_automata_global.F90 @@ -11,6 +11,7 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp nca,ncells,nlives,nfracseed,nseed,iseed_ca, mytile, & ca_smooth,nspinup,blocksize,nsmooth,ca_amplitude,mpiroot,mpicomm) +use mpi_f08 use kinddef, only: kind_dbl_prec use update_ca, only: update_cells_global,define_ca_domain use halo_exchange, only: atmosphere_scalar_field_halo @@ -30,7 +31,8 @@ subroutine cellular_automata_global(kstep,restart,first_time_step,ca1_cpl,ca2_cp !This program evolves a cellular automaton uniform over the globe -integer, intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,nsmooth,mpiroot,mpicomm +integer, intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,nsmooth,mpiroot +type(MPI_Comm), intent(in) :: mpicomm integer(kind=kind_dbl_prec), intent(in) :: iseed_ca integer, intent(in) :: mytile real(kind=kind_dbl_prec), intent(in) :: nfracseed,ca_amplitude diff --git a/cellular_automata_sgs.F90 b/cellular_automata_sgs.F90 index 2bd47f6..771f14c 100644 --- a/cellular_automata_sgs.F90 +++ b/cellular_automata_sgs.F90 @@ -12,6 +12,7 @@ subroutine cellular_automata_sgs(kstep,dtf,restart,first_time_step,sst,lsmsk,lak nca,ncells,nlives,nfracseed,nseed,iseed_ca, & nspinup,ca_trigger,blocksize,mpiroot,mpicomm) +use mpi_f08 use kinddef, only: kind_phys,kind_dbl_prec use update_ca, only: update_cells_sgs, define_ca_domain use random_numbers, only: random_01_CB @@ -41,7 +42,8 @@ subroutine cellular_automata_sgs(kstep,dtf,restart,first_time_step,sst,lsmsk,lak !CA_DEEP can be either number of plumes in a cluster (nca_plumes=true) or updraft !area fraction (nca_plumes=false) -integer,intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,mpiroot,mpicomm,mytile +integer,intent(in) :: kstep,ncells,nca,nlives,nseed,nspinup,mpiroot,mytile +type(MPI_Comm),intent(in) :: mpicomm integer(kind=kind_dbl_prec), intent(in) :: iseed_ca real(kind=kind_phys), intent(in) :: nfracseed,dtf,nthresh logical,intent(in) :: restart,ca_trigger,first_time_step diff --git a/mpi_wrapper.F90 b/mpi_wrapper.F90 index e756678..7ccd5a7 100644 --- a/mpi_wrapper.F90 +++ b/mpi_wrapper.F90 @@ -1,5 +1,7 @@ module mpi_wrapper + use mpi_f08 + implicit none private @@ -9,12 +11,10 @@ module mpi_wrapper public :: mp_reduce_min, mp_reduce_max, mp_reduce_sum public :: mp_bcst, mp_alltoall -#include "mpif.h" - integer, save :: mype = -999 integer, save :: npes = -999 integer, save :: root = -999 - integer, save :: comm = -999 + type(MPI_Comm), save :: comm logical, save :: initialized = .false. integer :: ierror @@ -78,7 +78,8 @@ logical function is_rootpe() end function is_rootpe subroutine mpi_wrapper_initialize(mpiroot, mpicomm) - integer, intent(in) :: mpiroot, mpicomm + integer, intent(in) :: mpiroot + type(MPI_Comm), intent(in) :: mpicomm if (initialized) return root = mpiroot comm = mpicomm @@ -92,7 +93,7 @@ subroutine mpi_wrapper_finalize() mype = -999 npes = -999 root = -999 - comm = -999 + comm%mpi_val = -999 initialized = .false. end subroutine mpi_wrapper_finalize diff --git a/stochastic_physics.F90 b/stochastic_physics.F90 index 70ba603..d6cdcee 100644 --- a/stochastic_physics.F90 +++ b/stochastic_physics.F90 @@ -2,6 +2,7 @@ !! the stochastic physics random pattern generators module stochastic_physics +use mpi_f08 use kinddef, only : kind_dbl_prec implicit none @@ -40,7 +41,8 @@ subroutine init_stochastic_physics(levs, blksz, dtp, sppt_amp, input_nml_file_in ! Interface variables -integer, intent(in) :: levs, nlunit, nthreads, mpiroot, mpicomm +integer, intent(in) :: levs, nlunit, nthreads, mpiroot +type(MPI_Comm), intent(in) :: mpicomm integer, intent(in) :: blksz(:) real(kind=kind_dbl_prec), intent(in) :: dtp real(kind=kind_dbl_prec), intent(out) :: sppt_amp @@ -277,8 +279,10 @@ subroutine init_stochastic_physics_ocn(delt,geoLonT,geoLatT,nx,ny,nz,pert_epbl_i real :: dx integer :: k,latghf,km +type(MPI_Comm) :: mpicomm_t ! FIXME once MOM6 updates to use mpi_f90 types rad2deg=180.0/con_pi -call mpi_wrapper_initialize(mpiroot,mpicomm) +mpicomm_t%mpi_val = mpicomm +call mpi_wrapper_initialize(mpiroot,mpicomm_t) gis_stochy_ocn%nodes = npes gis_stochy_ocn%mype = mype gis_stochy_ocn%nx=nx