|
| 1 | +/* |
| 2 | + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
| 3 | + * University Research and Technology |
| 4 | + * Corporation. All rights reserved. |
| 5 | + * Copyright (c) 2004-2005 The University of Tennessee and The University |
| 6 | + * of Tennessee Research Foundation. All rights |
| 7 | + * reserved. |
| 8 | + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 9 | + * University of Stuttgart. All rights reserved. |
| 10 | + * Copyright (c) 2004-2005 The Regents of the University of California. |
| 11 | + * All rights reserved. |
| 12 | + * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. |
| 13 | + * Copyright (c) 2015-2019 Research Organization for Information Science |
| 14 | + * and Technology (RIST). All rights reserved. |
| 15 | + * $COPYRIGHT$ |
| 16 | + * |
| 17 | + * Additional copyrights may follow |
| 18 | + * |
| 19 | + * $HEADER$ |
| 20 | + */ |
| 21 | + |
| 22 | +#include "ompi_config.h" |
| 23 | + |
| 24 | +#include "ompi/communicator/communicator.h" |
| 25 | +#include "ompi/errhandler/errhandler.h" |
| 26 | +#include "ompi/mpi/fortran/use-mpi-f08/ts/bindings.h" |
| 27 | +#include "ompi/constants.h" |
| 28 | +#include "ompi/mpi/fortran/base/constants.h" |
| 29 | +#include "ompi/mpi/fortran/base/fortran_base_strings.h" |
| 30 | + |
| 31 | +static const char FUNC_NAME[] = "MPI_Pack_external"; |
| 32 | + |
| 33 | +void ompi_pack_external_ts(char *datarep, CFI_cdesc_t* x1, MPI_Fint *incount, |
| 34 | + MPI_Fint *datatype, CFI_cdesc_t* x2, |
| 35 | + MPI_Aint *outsize, MPI_Aint *position, |
| 36 | + MPI_Fint *ierr, int datarep_len) |
| 37 | +{ |
| 38 | + int ret, c_ierr; |
| 39 | + char *c_datarep; |
| 40 | + MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype); |
| 41 | + void *inbuf = x1->base_addr; |
| 42 | + char *outbuf = x2->base_addr; |
| 43 | + int c_incount = OMPI_FINT_2_INT(*incount); |
| 44 | + |
| 45 | + /* Convert the fortran string */ |
| 46 | + |
| 47 | + if (OMPI_SUCCESS != (ret = ompi_fortran_string_f2c(datarep, datarep_len, |
| 48 | + &c_datarep))) { |
| 49 | + c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_SELF, ret, FUNC_NAME); |
| 50 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 51 | + return; |
| 52 | + } |
| 53 | + |
| 54 | + OMPI_CFI_2_C(x1, c_incount, c_type, c_datatype, c_ierr); |
| 55 | + if (MPI_SUCCESS != c_ierr) { |
| 56 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 57 | + OMPI_ERRHANDLER_INVOKE(MPI_COMM_SELF, c_ierr, FUNC_NAME); |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + OMPI_CFI_CHECK_CONTIGUOUS(x2, c_ierr); |
| 62 | + if (MPI_SUCCESS != c_ierr) { |
| 63 | + if (c_datatype != c_type) { |
| 64 | + ompi_datatype_destroy(&c_datatype); |
| 65 | + } |
| 66 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 67 | + OMPI_ERRHANDLER_INVOKE(MPI_COMM_SELF, c_ierr, FUNC_NAME); |
| 68 | + return; |
| 69 | + } |
| 70 | + |
| 71 | + c_ierr = PMPI_Pack_external(c_datarep, OMPI_F2C_BOTTOM(inbuf), |
| 72 | + c_incount, |
| 73 | + c_datatype, outbuf, |
| 74 | + *outsize, |
| 75 | + position); |
| 76 | + if (c_datatype != c_type) { |
| 77 | + ompi_datatype_destroy(&c_datatype); |
| 78 | + } |
| 79 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 80 | + |
| 81 | + free(c_datarep); |
| 82 | +} |
0 commit comments