Skip to content

Commit 99cffec

Browse files
committed
use-mpi-f08: fix prototypes and more
In the course of checking out a user reported problem: https://www.mail-archive.com/users@lists.open-mpi.org//msg35382.html it was discovered that many of the f08 entry points were improperly treating 'c' int args to the internal ompi*_f functions as fortran integers. This commit fixes that and also addressed the problem reported by the user. It was a special case where they were building the fortran bindings with non-default integer size which happened to no longer match the 'c' int. The fact that this problem wasn't seen before just shows that probably 99% of the time the default Fortran integer kind is compatible with 'c' int. Signed-off-by: Howard Pritchard <howardp@lanl.gov>
1 parent 120b71b commit 99cffec

33 files changed

+139
-102
lines changed

ompi/mpi/fortran/use-mpi-f08/add_error_string_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
subroutine MPI_Add_error_string_f08(errorcode,string,ierror)
1313
use :: ompi_mpifh_bindings, only : ompi_add_error_string_f
14+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1415
implicit none
1516
integer, intent(in) :: errorcode
1617
character(len=*), intent(in) :: string
1718
integer, optional, intent(out) :: ierror
1819
integer :: c_ierror
1920

20-
call ompi_add_error_string_f(errorcode, string, c_ierror, len(string))
21+
call ompi_add_error_string_f(errorcode, string, c_ierror, len(string,KIND=C_INT))
2122
if (present(ierror)) ierror = c_ierror
2223

2324
end subroutine MPI_Add_error_string_f08

ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h

Lines changed: 68 additions & 68 deletions
Large diffs are not rendered by default.

ompi/mpi/fortran/use-mpi-f08/close_port_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
subroutine MPI_Close_port_f08(port_name,ierror)
1313
use :: ompi_mpifh_bindings, only : ompi_close_port_f
14+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1415
implicit none
1516
CHARACTER(LEN=*), INTENT(IN) :: port_name
1617
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
1718
integer :: c_ierror
1819

19-
call ompi_close_port_f(port_name,c_ierror,len(port_name))
20+
call ompi_close_port_f(port_name,c_ierror,len(port_name,KIND=C_INT))
2021
if (present(ierror)) ierror = c_ierror
2122

2223
end subroutine MPI_Close_port_f08

ompi/mpi/fortran/use-mpi-f08/comm_accept_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
subroutine MPI_Comm_accept_f08(port_name,info,root,comm,newcomm,ierror)
1313
use :: mpi_f08_types, only : MPI_Info, MPI_Comm
1414
use :: ompi_mpifh_bindings, only : ompi_comm_accept_f
15+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1516
implicit none
1617
CHARACTER(LEN=*), INTENT(IN) :: port_name
1718
TYPE(MPI_Info), INTENT(IN) :: info
@@ -22,7 +23,7 @@ subroutine MPI_Comm_accept_f08(port_name,info,root,comm,newcomm,ierror)
2223
integer :: c_ierror
2324

2425
call ompi_comm_accept_f(port_name,info%MPI_VAL,root,comm%MPI_VAL,newcomm%MPI_VAL, &
25-
c_ierror,len(port_name))
26+
c_ierror,len(port_name,KIND=C_INT))
2627
if (present(ierror)) ierror = c_ierror
2728

2829
end subroutine MPI_Comm_accept_f08

ompi/mpi/fortran/use-mpi-f08/comm_connect_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
subroutine MPI_Comm_connect_f08(port_name,info,root,comm,newcomm,ierror)
1313
use :: mpi_f08_types, only : MPI_Info, MPI_Comm
1414
use :: ompi_mpifh_bindings, only : ompi_comm_connect_f
15+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1516
implicit none
1617
CHARACTER(LEN=*), INTENT(IN) :: port_name
1718
TYPE(MPI_Info), INTENT(IN) :: info
@@ -22,7 +23,7 @@ subroutine MPI_Comm_connect_f08(port_name,info,root,comm,newcomm,ierror)
2223
integer :: c_ierror
2324

2425
call ompi_comm_connect_f(port_name,info%MPI_VAL,root,comm%MPI_VAL,newcomm%MPI_VAL, &
25-
c_ierror,len(port_name))
26+
c_ierror,len(port_name,KIND=C_INT))
2627
if (present(ierror)) ierror = c_ierror
2728

2829
end subroutine MPI_Comm_connect_f08

ompi/mpi/fortran/use-mpi-f08/comm_create_from_group_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
subroutine MPI_Comm_create_from_group_f08(group, stringtag, info, errhandler, newcomm, ierror)
1515
use :: mpi_f08_types, only : MPI_Comm, MPI_Group, MPI_Errhandler, MPI_Info
1616
use :: ompi_mpifh_bindings, only : ompi_comm_create_from_group_f
17+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1718
implicit none
1819
TYPE(MPI_Group), INTENT(IN) :: group
1920
CHARACTER(LEN=*), INTENT(IN) :: stringtag
@@ -24,7 +25,7 @@ subroutine MPI_Comm_create_from_group_f08(group, stringtag, info, errhandler, ne
2425
integer :: c_ierror
2526

2627
call ompi_comm_create_from_group_f(group%MPI_VAL, stringtag, info%MPI_VAL, errhandler%MPI_VAL, &
27-
newcomm%MPI_VAL, c_ierror, len(stringtag))
28+
newcomm%MPI_VAL, c_ierror, len(stringtag,KIND=C_INT))
2829
if (present(ierror)) ierror = c_ierror
2930

3031
end subroutine MPI_Comm_create_from_group_f08

ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
subroutine MPI_Comm_get_name_f08(comm,comm_name,resultlen,ierror)
1313
use :: mpi_f08_types, only : MPI_Comm, MPI_MAX_OBJECT_NAME
1414
use :: ompi_mpifh_bindings, only : ompi_comm_get_name_f
15+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1516
implicit none
1617
TYPE(MPI_Comm), INTENT(IN) :: comm
1718
CHARACTER(LEN=*), INTENT(OUT) :: comm_name
@@ -20,7 +21,7 @@ subroutine MPI_Comm_get_name_f08(comm,comm_name,resultlen,ierror)
2021
integer :: c_ierror
2122

2223
call ompi_comm_get_name_f(comm%MPI_VAL,comm_name,resultlen,c_ierror, &
23-
len(comm_name))
24+
len(comm_name,KIND=C_INT))
2425
if (present(ierror)) ierror = c_ierror
2526

2627
end subroutine MPI_Comm_get_name_f08

ompi/mpi/fortran/use-mpi-f08/comm_set_name_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
subroutine MPI_Comm_set_name_f08(comm,comm_name,ierror)
1313
use :: mpi_f08_types, only : MPI_Comm
1414
use :: ompi_mpifh_bindings, only : ompi_comm_set_name_f
15+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1516
implicit none
1617
TYPE(MPI_Comm), INTENT(IN) :: comm
1718
CHARACTER(LEN=*), INTENT(IN) :: comm_name
1819
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
1920
integer :: c_ierror
2021

21-
call ompi_comm_set_name_f(comm%MPI_VAL,comm_name,c_ierror,len(comm_name))
22+
call ompi_comm_set_name_f(comm%MPI_VAL,comm_name,c_ierror,len(comm_name,KIND=C_INT))
2223
if (present(ierror)) ierror = c_ierror
2324

2425
end subroutine MPI_Comm_set_name_f08

ompi/mpi/fortran/use-mpi-f08/comm_spawn_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ subroutine MPI_Comm_spawn_f08(command,argv,maxprocs,info,root,comm,intercomm, &
1414
array_of_errcodes,ierror)
1515
use :: mpi_f08_types, only : MPI_Info, MPI_Comm
1616
use :: ompi_mpifh_bindings, only : ompi_comm_spawn_f
17+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1718
implicit none
1819
CHARACTER(LEN=*), INTENT(IN) :: command, argv(*)
1920
INTEGER, INTENT(IN) :: maxprocs, root
@@ -27,7 +28,7 @@ subroutine MPI_Comm_spawn_f08(command,argv,maxprocs,info,root,comm,intercomm, &
2728
call ompi_comm_spawn_f(command,argv,maxprocs, &
2829
info%MPI_VAL,root,comm%MPI_VAL,intercomm%MPI_VAL, &
2930
array_of_errcodes,c_ierror, &
30-
len(command), len(argv))
31+
len(command,KIND=C_INT), len(argv,KIND=C_INT))
3132
if (present(ierror)) ierror = c_ierror
3233

3334
end subroutine MPI_Comm_spawn_f08

ompi/mpi/fortran/use-mpi-f08/comm_spawn_multiple_f08.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ subroutine MPI_Comm_spawn_multiple_f08(count,array_of_commands,array_of_argv, &
1515
comm,intercomm,array_of_errcodes,ierror)
1616
use :: mpi_f08_types, only : MPI_Info, MPI_Comm
1717
use :: ompi_mpifh_bindings, only : ompi_comm_spawn_multiple_f
18+
use, intrinsic :: ISO_C_BINDING, only : C_INT
1819
implicit none
1920
INTEGER, INTENT(IN) :: count, root
2021
INTEGER, INTENT(IN) :: array_of_maxprocs(count)
@@ -33,7 +34,7 @@ subroutine MPI_Comm_spawn_multiple_f08(count,array_of_commands,array_of_argv, &
3334
call ompi_comm_spawn_multiple_f(count,array_of_commands,array_of_argv, &
3435
array_of_maxprocs,array_of_info(:)%MPI_VAL,root, &
3536
comm%MPI_VAL,intercomm%MPI_VAL,array_of_errcodes,c_ierror, &
36-
len(array_of_commands), len(array_of_argv))
37+
len(array_of_commands,KIND=C_INT), len(array_of_argv,KIND=C_INT))
3738
if (present(ierror)) ierror = c_ierror
3839

3940
end subroutine MPI_Comm_spawn_multiple_f08

0 commit comments

Comments
 (0)