/* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
 *  (C) 2014 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 *
 * This file is automatically generated by buildiface
 * DO NOT EDIT
 */

#include "cdesc.h"

int MPIR_Pack_external_cdesc(const char x0[], CFI_cdesc_t* x1, int x2, MPI_Datatype x3, CFI_cdesc_t* x4, MPI_Aint x5, MPI_Aint * x6)
{
    int err = MPI_SUCCESS;
    void *buf1 = x1->base_addr;
    int count1 = x2;
    MPI_Datatype dtype1 = x3;
    void *buf4 = x4->base_addr;

    if (buf1 == &MPIR_F08_MPI_BOTTOM) {
        buf1 = MPI_BOTTOM;
    }

    if (buf4 == &MPIR_F08_MPI_BOTTOM) {
        buf4 = MPI_BOTTOM;
    }

    if (x1->rank != 0 && !CFI_is_contiguous(x1)) {
        err = cdesc_create_datatype(x1, x2, x3, &dtype1);
        count1 = 1;
    }

    err = MPI_Pack_external(x0, buf1, count1, dtype1, buf4, x5, x6);

    if (dtype1 != x3)  MPI_Type_free(&dtype1);
    return err;
}
