diff --git a/ompi/mpi/fortran/use-mpi-f08/bcast_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/bcast_init_ts.c.in index 5de740bbde7..e872a72d8ec 100644 --- a/ompi/mpi/fortran/use-mpi-f08/bcast_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/bcast_init_ts.c.in @@ -21,7 +21,6 @@ * $HEADER$ */ - PROTOTYPE VOID bcast_init(BUFFER_ASYNC x, COUNT count, DATATYPE datatype, RANK root, COMM comm, INFO info, REQUEST_OUT request) { @@ -29,7 +28,7 @@ PROTOTYPE VOID bcast_init(BUFFER_ASYNC x, COUNT count, DATATYPE datatype, MPI_Comm c_comm; MPI_Info c_info; MPI_Request c_req; - MPI_Datatype c_type, c_datatype; + MPI_Datatype c_type, c_datatype = MPI_DATATYPE_NULL; void *buffer = OMPI_CFI_BASE_ADDR(x); @COUNT_TYPE@ c_count = (@COUNT_TYPE@) *count; int c_root = OMPI_FINT_2_INT(*root); @@ -49,12 +48,12 @@ PROTOTYPE VOID bcast_init(BUFFER_ASYNC x, COUNT count, DATATYPE datatype, c_ierr = @INNER_CALL@(OMPI_F2C_BOTTOM(buffer), c_count, - c_datatype, + (c_datatype == MPI_DATATYPE_NULL) ? c_type : c_datatype, c_root, c_comm, c_info, &c_req); - if (c_datatype != c_type) { + if (MPI_DATATYPE_NULL != c_datatype && c_datatype != c_type) { ompi_datatype_destroy(&c_datatype); } if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); diff --git a/ompi/mpi/fortran/use-mpi-f08/gather_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/gather_init_ts.c.in index 270cb1b7601..85ad3eb9bc4 100644 --- a/ompi/mpi/fortran/use-mpi-f08/gather_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/gather_init_ts.c.in @@ -27,7 +27,8 @@ PROTOTYPE VOID gather_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, { int c_ierr; MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_senddatatype, c_recvtype; + MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_senddatatype = MPI_DATATYPE_NULL; MPI_Info c_info; MPI_Request c_request; int c_root = OMPI_FINT_2_INT(*root); @@ -87,7 +88,7 @@ PROTOTYPE VOID gather_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, c_recvtype, c_root, c_comm, c_info, &c_request); - if (c_senddatatype != c_sendtype) { + if (MPI_DATATYPE_NULL != c_senddatatype && c_senddatatype != c_sendtype) { ompi_datatype_destroy(&c_senddatatype); } if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); diff --git a/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in b/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in index f3cd3577ce2..10e8b8bb5d0 100644 --- a/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in +++ b/ompi/mpi/fortran/use-mpi-f08/gatherv_init_ts.c.in @@ -27,7 +27,8 @@ PROTOTYPE VOID gatherv_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, INFO info, REQUEST_OUT request) { MPI_Comm c_comm; - MPI_Datatype c_sendtype, c_senddatatype, c_recvtype; + MPI_Datatype c_sendtype, c_recvtype; + MPI_Datatype c_senddatatype = MPI_DATATYPE_NULL; MPI_Info c_info; MPI_Request c_request; int idx = 0, c_ierr; @@ -102,7 +103,7 @@ PROTOTYPE VOID gatherv_init(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype, c_recvtype, c_root, c_comm, c_info, &c_request); - if (c_senddatatype != c_sendtype) { + if (MPI_DATATYPE_NULL != c_senddatatype && c_senddatatype != c_sendtype) { ompi_datatype_destroy(&c_senddatatype); } if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);