Skip to content

Commit 6942270

Browse files
Fix type mismatch compiler error when gfortran 10 is used without '-fallow-argument-mismatch' flag (#770)
* Resolve argument mismatch errors when using gfortran * Switch from 'use mpi' to 'use mpi_f08' * More argument mismatch fixes * Merge Dom's ccpp-framework and ccpp-physics feature/depend_on_mpi braches * Check output_grid type and inline post compatibility * If output grid is 'cubed_sphere_grid' AND inline post is turned on print error and terminate the model. * Use type(MPI_Comm) in io/module_wrt_grid_comp.F90
1 parent fae9bc2 commit 6942270

13 files changed

+45
-48
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endif()
2222
### CCPP
2323
###############################################################################
2424

25+
set(MPI ON)
2526
add_subdirectory(ccpp)
2627

2728
###############################################################################

atmos_model.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ end subroutine update_atmos_radiation_physics
450450
! variable type are allocated for the global grid (without halo regions).
451451
! </INOUT>
452452
subroutine atmos_timestep_diagnostics(Atmos)
453-
use mpi
453+
use mpi_f08
454454
implicit none
455455
type (atmos_data_type), intent(in) :: Atmos
456456
!--- local variables---

ccpp/config/ccpp_prebuild_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
TYPEDEFS_NEW_METADATA = {
3030
'ccpp_types' : {
3131
'ccpp_t' : 'cdata',
32+
'MPI_Comm' : '',
3233
'ccpp_types' : '',
3334
},
3435
'machine' : {

ccpp/data/GFS_typedefs.F90

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module GFS_typedefs
22

3+
use mpi_f08
34
use machine, only: kind_phys, kind_dbl_prec, kind_sngl_prec
45
use physcons, only: con_cp, con_fvirt, con_g, rholakeice, &
56
con_hvap, con_hfus, con_pi, con_rd, con_rv, &
@@ -94,7 +95,7 @@ module GFS_typedefs
9495
type GFS_init_type
9596
integer :: me !< my MPI-rank
9697
integer :: master !< master MPI-rank
97-
integer :: fcst_mpi_comm !< forecast tasks mpi communicator
98+
type(MPI_Comm) :: fcst_mpi_comm !< forecast tasks mpi communicator
9899
integer :: fcst_ntasks !< total number of forecast tasks
99100
integer :: tile_num !< tile number for this MPI rank
100101
integer :: isc !< starting i-index for this MPI-domain
@@ -700,7 +701,7 @@ module GFS_typedefs
700701

701702
integer :: me !< MPI rank designator
702703
integer :: master !< MPI rank of master atmosphere processor
703-
integer :: communicator !< MPI communicator
704+
type(MPI_Comm) :: communicator !< MPI communicator
704705
integer :: ntasks !< MPI size in communicator
705706
integer :: nthreads !< OpenMP threads available for physics
706707
integer :: nlunit !< unit for namelist
@@ -3306,7 +3307,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
33063307
real(kind=kind_phys), dimension(:), intent(in) :: bk
33073308
logical, intent(in) :: restart
33083309
logical, intent(in) :: hydrostatic
3309-
integer, intent(in) :: communicator
3310+
type(MPI_Comm), intent(in) :: communicator
33103311
integer, intent(in) :: ntasks
33113312
integer, intent(in) :: nthreads
33123313

@@ -3316,9 +3317,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
33163317
integer :: seed0
33173318
logical :: exists
33183319
real(kind=kind_phys) :: tem
3319-
real(kind=kind_phys) :: rinc(5)
3320-
real(kind=kind_sngl_prec) :: rinc4(5)
3321-
real(kind=kind_dbl_prec) :: rinc8(5)
3320+
real(kind=kind_dbl_prec) :: rinc(5)
33223321
real(kind=kind_phys) :: wrk(1)
33233322
real(kind=kind_phys), parameter :: con_hr = 3600.
33243323

@@ -3974,7 +3973,6 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
39743973

39753974
real(kind=kind_phys) :: radar_tten_limits(2) = (/ limit_unspecified, limit_unspecified /)
39763975
integer :: itime
3977-
integer :: w3kindreal,w3kindint
39783976

39793977
!--- END NAMELIST VARIABLES
39803978

@@ -5608,19 +5606,7 @@ subroutine control_initialize (Model, nlunit, fn_nml, me, master, &
56085606
Model%cdec = -9999.
56095607
Model%clstp = -9999
56105608
rinc(1:5) = 0
5611-
call w3kind(w3kindreal,w3kindint)
5612-
if (w3kindreal == 8) then
5613-
rinc8(1:5) = 0
5614-
call w3difdat(jdat,idat,4,rinc8)
5615-
rinc = rinc8
5616-
else if (w3kindreal == 4) then
5617-
rinc4(1:5) = 0
5618-
call w3difdat(jdat,idat,4,rinc4)
5619-
rinc = rinc4
5620-
else
5621-
write(0,*)' FATAL ERROR: Invalid w3kindreal'
5622-
call abort
5623-
endif
5609+
call w3difdat(jdat,idat,4,rinc)
56245610
Model%phour = rinc(4)/con_hr
56255611
Model%fhour = (rinc(4) + Model%dtp)/con_hr
56265612
Model%zhour = mod(Model%phour,Model%fhzero)
@@ -6418,7 +6404,7 @@ subroutine control_print(Model)
64186404
print *, 'basic control parameters'
64196405
print *, ' me : ', Model%me
64206406
print *, ' master : ', Model%master
6421-
print *, ' communicator : ', Model%communicator
6407+
print *, ' communicator : ', Model%communicator%mpi_val
64226408
print *, ' nlunit : ', Model%nlunit
64236409
print *, ' fn_nml : ', trim(Model%fn_nml)
64246410
print *, ' fhzero : ', Model%fhzero

ccpp/data/GFS_typedefs.meta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3332,7 +3332,7 @@
33323332
long_name = MPI communicator
33333333
units = index
33343334
dimensions = ()
3335-
type = integer
3335+
type = MPI_Comm
33363336
[ntasks]
33373337
standard_name = number_of_mpi_tasks
33383338
long_name = number of MPI tasks in communicator

io/module_write_netcdf.F90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
!> @author Dusan Jovic @date Nov 1, 2017
1717
module module_write_netcdf
1818

19-
use mpi
19+
use mpi_f08
2020
use esmf
2121
use netcdf
2222
use module_fv3_io_def,only : ideflate, quantize_mode, quantize_nsd, zstandard_level, &
@@ -44,13 +44,15 @@ module module_write_netcdf
4444
!>
4545
!> @author Dusan Jovic @date Nov 1, 2017
4646
subroutine write_netcdf(wrtfb, filename, &
47-
use_parallel_netcdf, mpi_comm, mype, &
47+
use_parallel_netcdf, comm, mype, &
4848
grid_id, rc)
4949
!
50+
use mpi_f08
51+
5052
type(ESMF_FieldBundle), intent(in) :: wrtfb
5153
character(*), intent(in) :: filename
5254
logical, intent(in) :: use_parallel_netcdf
53-
integer, intent(in) :: mpi_comm
55+
type(MPI_Comm), intent(in) :: comm
5456
integer, intent(in) :: mype
5557
integer, intent(in) :: grid_id
5658
integer, optional,intent(out) :: rc
@@ -233,7 +235,7 @@ subroutine write_netcdf(wrtfb, filename, &
233235
if (par) then
234236
ncerr = nf90_create(trim(filename),&
235237
cmode=IOR(NF90_CLOBBER,NF90_NETCDF4),&
236-
comm=mpi_comm, info = MPI_INFO_NULL, ncid=ncid); NC_ERR_STOP(ncerr)
238+
comm=comm%mpi_val, info = MPI_INFO_NULL%mpi_val, ncid=ncid); NC_ERR_STOP(ncerr)
237239
else
238240
ncerr = nf90_create(trim(filename),&
239241
cmode=IOR(NF90_CLOBBER,NF90_NETCDF4),&

io/module_write_restart_netcdf.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
module module_write_restart_netcdf
99

10-
use mpi
10+
use mpi_f08
1111
use esmf
1212
use fms
1313
use mpp_mod, only : mpp_chksum ! needed for fms 2023.02
@@ -24,13 +24,13 @@ module module_write_restart_netcdf
2424

2525
!----------------------------------------------------------------------------------------
2626
subroutine write_restart_netcdf(wrtfb, filename, &
27-
use_parallel_netcdf, mpi_comm, mype, &
27+
use_parallel_netcdf, comm, mype, &
2828
rc)
2929
!
3030
type(ESMF_FieldBundle), intent(in) :: wrtfb
3131
character(*), intent(in) :: filename
3232
logical, intent(in) :: use_parallel_netcdf
33-
integer, intent(in) :: mpi_comm
33+
type(MPI_Comm), intent(in) :: comm
3434
integer, intent(in) :: mype
3535
integer, optional,intent(out) :: rc
3636
!
@@ -223,7 +223,7 @@ subroutine write_restart_netcdf(wrtfb, filename, &
223223
if (par) then
224224
ncerr = nf90_create(trim(filename),&
225225
cmode=IOR(NF90_CLOBBER,NF90_NETCDF4),&
226-
comm=mpi_comm, info = MPI_INFO_NULL, ncid=ncid); NC_ERR_STOP(ncerr)
226+
comm=comm%mpi_val, info = MPI_INFO_NULL%mpi_val, ncid=ncid); NC_ERR_STOP(ncerr)
227227
else
228228
ncerr = nf90_create(trim(filename),&
229229
! cmode=IOR(NF90_CLOBBER,NF90_64BIT_OFFSET),&

io/module_wrt_grid_comp.F90

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module module_wrt_grid_comp
2626
!
2727
!---------------------------------------------------------------------------------
2828
!
29-
use mpi
29+
use mpi_f08
3030
use esmf
3131
use fms_mod, only : uppercase
3232
use fms
@@ -67,7 +67,7 @@ module module_wrt_grid_comp
6767
integer,save :: itasks, jtasks !<-- # of write tasks in i/j direction in the current group
6868
integer,save :: ngrids
6969

70-
integer,save :: wrt_mpi_comm !<-- the mpi communicator in the write comp
70+
type(MPI_Comm),save :: wrt_mpi_comm !<-- the mpi communicator in the write comp
7171
integer,save :: idate(7), start_time(7)
7272
logical,save :: write_nsflip
7373
logical,save :: change_wrtidate=.false.
@@ -159,7 +159,7 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
159159
integer,dimension(2,6) :: decomptile
160160
integer,dimension(2) :: regDecomp !define delayout for the nest grid
161161
integer :: fieldCount
162-
integer :: vm_mpi_comm
162+
type(MPI_Comm) :: vm_mpi_comm
163163
character(40) :: fieldName
164164
type(ESMF_Config) :: cf, cf_output_grid
165165
type(ESMF_Info) :: info
@@ -242,7 +242,7 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
242242
!
243243
call ESMF_VMGetCurrent(vm=VM,rc=RC)
244244
call ESMF_VMGet(vm=VM, localPet=wrt_int_state%mype, &
245-
petCount=wrt_int_state%petcount,mpiCommunicator=vm_mpi_comm,rc=rc)
245+
petCount=wrt_int_state%petcount,mpiCommunicator=vm_mpi_comm%mpi_val,rc=rc)
246246
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
247247

248248
call mpi_comm_dup(vm_mpi_comm, wrt_mpi_comm, rc)
@@ -253,7 +253,7 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
253253
last_write_task = ntasks -1
254254
lprnt = lead_write_task == wrt_int_state%mype
255255

256-
call fms_init(wrt_mpi_comm)
256+
call fms_init(wrt_mpi_comm%mpi_val)
257257

258258
! print *,'in wrt, lead_write_task=', &
259259
! lead_write_task,'last_write_task=',last_write_task, &
@@ -386,6 +386,12 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
386386
print *,'grid_id= ', n, ' output_grid= ', trim(output_grid(n))
387387
end if
388388

389+
if (trim(output_grid(n)) == 'cubed_sphere_grid' .and. wrt_int_state%write_dopost) then
390+
write(0,*) 'wrt_initialize_p1: Inline post is not supported with cubed_sphere_grid outputs'
391+
call ESMF_LogWrite("wrt_initialize_p1: Inline post is not supported with cubed_sphere_grid output",ESMF_LOGMSG_ERROR,rc=RC)
392+
call ESMF_Finalize(endflag=ESMF_END_ABORT)
393+
end if
394+
389395
call ESMF_ConfigGetAttribute(config=CF, value=itasks,default=1,label ='itasks:',rc=rc)
390396
jtasks = ntasks
391397
if(itasks > 0 ) jtasks = ntasks/itasks
@@ -3386,7 +3392,7 @@ subroutine ioCompRun(comp, importState, exportState, clock, rc)
33863392
logical :: thereAreVerticals
33873393
integer :: ch_dimid, timeiso_varid
33883394
character(len=ESMF_MAXSTR) :: time_iso
3389-
integer :: wrt_mpi_comm
3395+
type(MPI_Comm) :: wrt_mpi_comm
33903396
type(ESMF_VM) :: vm
33913397

33923398
rc = ESMF_SUCCESS
@@ -3439,7 +3445,7 @@ subroutine ioCompRun(comp, importState, exportState, clock, rc)
34393445
call ESMF_GridCompGet(comp, localPet=localPet, petCount=petCount, vm=vm, rc=rc)
34403446
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
34413447

3442-
call ESMF_VMGet(vm=vm, mpiCommunicator=wrt_mpi_comm, rc=rc)
3448+
call ESMF_VMGet(vm=vm, mpiCommunicator=wrt_mpi_comm%mpi_val, rc=rc)
34433449
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
34443450

34453451
if (petCount > 1) then

io/post_fv3.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module post_fv3
22

3-
use mpi
3+
use mpi_f08
44

55
use module_fv3_io_def, only : wrttasks_per_group, filename_base, &
66
lon1, lat1, lon2, lat2, dlon, dlat, &
@@ -56,7 +56,7 @@ subroutine post_run_fv3(wrt_int_state,grid_id,mype,mpicomp,lead_write, &
5656
type(wrt_internal_state),intent(inout) :: wrt_int_state
5757
integer,intent(in) :: grid_id
5858
integer,intent(in) :: mype
59-
integer,intent(in) :: mpicomp
59+
type(MPI_Comm),intent(in) :: mpicomp
6060
integer,intent(in) :: lead_write
6161
integer,intent(in) :: itasks, jtasks
6262
integer,intent(in) :: mynfhr
@@ -586,7 +586,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
586586
type(wrt_internal_state),intent(in) :: wrt_int_state
587587
integer,intent(in) :: grid_id
588588
integer,intent(in) :: mype
589-
integer,intent(in) :: mpicomp
589+
type(MPI_Comm),intent(in) :: mpicomp
590590
!
591591
!-----------------------------------------------------------------------
592592
!

module_fcst_grid_comp.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module module_fcst_grid_comp
1515
!
1616
!---------------------------------------------------------------------------------
1717
!
18-
use mpi
18+
use mpi_f08
1919
use esmf
2020
use nuopc
2121

@@ -593,7 +593,7 @@ subroutine fcst_initialize(fcst_comp, importState, exportState, clock, rc)
593593
call ESMF_VMGetCurrent(vm=vm,rc=rc)
594594
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
595595

596-
call ESMF_VMGet(vm=vm, localPet=mype, mpiCommunicator=fcst_mpi_comm, &
596+
call ESMF_VMGet(vm=vm, localPet=mype, mpiCommunicator=fcst_mpi_comm%mpi_val, &
597597
petCount=fcst_ntasks, rc=rc)
598598
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
599599
if (mype == 0) write(*,*)'in fcst comp init, fcst_ntasks=',fcst_ntasks
@@ -615,7 +615,7 @@ subroutine fcst_initialize(fcst_comp, importState, exportState, clock, rc)
615615
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return
616616
if (mype == 0) print *,'af ufs config,restart_interval=',restart_interval
617617
!
618-
call fms_init(fcst_mpi_comm)
618+
call fms_init(fcst_mpi_comm%mpi_val)
619619
call mpp_init()
620620
initClock = mpp_clock_id( 'Initialization' )
621621
call mpp_clock_begin (initClock) !nesting problem

module_fv3_config.F90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
!>
77
!> @author Jun Wang @date 01/2017
88
module module_fv3_config
9+
10+
use mpi_f08
911
use esmf
1012

1113
implicit none
@@ -18,12 +20,11 @@ module module_fv3_config
1820
integer :: first_kdt
1921

2022
!> MPI communicator for the forecast grid component
21-
integer :: fcst_mpi_comm
23+
type(MPI_Comm) :: fcst_mpi_comm
2224

2325
!> Total number of mpi tasks for the forecast grid components
2426
integer :: fcst_ntasks
2527

26-
2728
!> ID number for the coupled grids
2829
integer :: cpl_grid_id
2930

0 commit comments

Comments
 (0)