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


/* Begin MPI profiling block */
#if defined(USE_WEAK_SYMBOLS) && !defined(USE_ONLY_MPI_NAMES) 
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#if defined(F77_NAME_UPPER)
#pragma weak MPI_CART_SUB = PMPI_CART_SUB
#pragma weak mpi_cart_sub__ = PMPI_CART_SUB
#pragma weak mpi_cart_sub_ = PMPI_CART_SUB
#pragma weak mpi_cart_sub = PMPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak MPI_CART_SUB = pmpi_cart_sub__
#pragma weak mpi_cart_sub__ = pmpi_cart_sub__
#pragma weak mpi_cart_sub_ = pmpi_cart_sub__
#pragma weak mpi_cart_sub = pmpi_cart_sub__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak MPI_CART_SUB = pmpi_cart_sub_
#pragma weak mpi_cart_sub__ = pmpi_cart_sub_
#pragma weak mpi_cart_sub_ = pmpi_cart_sub_
#pragma weak mpi_cart_sub = pmpi_cart_sub_
#else
#pragma weak MPI_CART_SUB = pmpi_cart_sub
#pragma weak mpi_cart_sub__ = pmpi_cart_sub
#pragma weak mpi_cart_sub_ = pmpi_cart_sub
#pragma weak mpi_cart_sub = pmpi_cart_sub
#endif



#elif defined(HAVE_PRAGMA_WEAK)

#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#pragma weak MPI_CART_SUB = PMPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#pragma weak mpi_cart_sub__ = pmpi_cart_sub__
#elif !defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#pragma weak mpi_cart_sub = pmpi_cart_sub
#else
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#pragma weak mpi_cart_sub_ = pmpi_cart_sub_
#endif

#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#if defined(F77_NAME_UPPER)
#pragma _HP_SECONDARY_DEF PMPI_CART_SUB  MPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma _HP_SECONDARY_DEF pmpi_cart_sub__  mpi_cart_sub__
#elif !defined(F77_NAME_LOWER_USCORE)
#pragma _HP_SECONDARY_DEF pmpi_cart_sub  mpi_cart_sub
#else
#pragma _HP_SECONDARY_DEF pmpi_cart_sub_  mpi_cart_sub_
#endif

#elif defined(HAVE_PRAGMA_CRI_DUP)
#if defined(F77_NAME_UPPER)
#pragma _CRI duplicate MPI_CART_SUB as PMPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma _CRI duplicate mpi_cart_sub__ as pmpi_cart_sub__
#elif !defined(F77_NAME_LOWER_USCORE)
#pragma _CRI duplicate mpi_cart_sub as pmpi_cart_sub
#else
#pragma _CRI duplicate mpi_cart_sub_ as pmpi_cart_sub_
#endif

#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));

#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));

#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));

#else
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));

#endif
#endif /* HAVE_PRAGMA_WEAK */
#endif /* USE_WEAK_SYMBOLS */
/* End MPI profiling block */


/* These definitions are used only for generating the Fortran wrappers */
#if defined(USE_WEAK_SYMBOLS) && defined(USE_ONLY_MPI_NAMES)
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#if defined(F77_NAME_UPPER)
#pragma weak mpi_cart_sub__ = MPI_CART_SUB
#pragma weak mpi_cart_sub_ = MPI_CART_SUB
#pragma weak mpi_cart_sub = MPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak MPI_CART_SUB = mpi_cart_sub__
#pragma weak mpi_cart_sub_ = mpi_cart_sub__
#pragma weak mpi_cart_sub = mpi_cart_sub__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak MPI_CART_SUB = mpi_cart_sub_
#pragma weak mpi_cart_sub__ = mpi_cart_sub_
#pragma weak mpi_cart_sub = mpi_cart_sub_
#else
#pragma weak MPI_CART_SUB = mpi_cart_sub
#pragma weak mpi_cart_sub__ = mpi_cart_sub
#pragma weak mpi_cart_sub_ = mpi_cart_sub
#endif
#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_CART_SUB")));

#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub__")));

#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub_")));

#else
extern FORT_DLL_SPEC void FORT_CALL MPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL mpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#endif
#endif

#endif

/* Map the name to the correct form */
#ifndef MPICH_MPI_FROM_PMPI
#if defined(USE_WEAK_SYMBOLS)
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
/* Define the weak versions of the PMPI routine*/
#ifndef F77_NAME_UPPER
extern FORT_DLL_SPEC void FORT_CALL PMPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER_2USCORE
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER_USCORE
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * );

#endif

#if defined(F77_NAME_UPPER)
#pragma weak pmpi_cart_sub__ = PMPI_CART_SUB
#pragma weak pmpi_cart_sub_ = PMPI_CART_SUB
#pragma weak pmpi_cart_sub = PMPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak PMPI_CART_SUB = pmpi_cart_sub__
#pragma weak pmpi_cart_sub_ = pmpi_cart_sub__
#pragma weak pmpi_cart_sub = pmpi_cart_sub__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak PMPI_CART_SUB = pmpi_cart_sub_
#pragma weak pmpi_cart_sub__ = pmpi_cart_sub_
#pragma weak pmpi_cart_sub = pmpi_cart_sub_
#else
#pragma weak PMPI_CART_SUB = pmpi_cart_sub
#pragma weak pmpi_cart_sub__ = pmpi_cart_sub
#pragma weak pmpi_cart_sub_ = pmpi_cart_sub
#endif /* Test on name mapping */

#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_CART_SUB")));

#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL PMPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub__")));

#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL PMPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub_")));

#else
extern FORT_DLL_SPEC void FORT_CALL PMPI_CART_SUB( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub__( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_cart_sub_( MPI_Fint *, MPI_Fint [], MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_cart_sub")));

#endif /* Test on name mapping */
#endif /* HAVE_MULTIPLE_PRAGMA_WEAK */
#endif /* USE_WEAK_SYMBOLS */

#ifdef F77_NAME_UPPER
#define mpi_cart_sub_ PMPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#define mpi_cart_sub_ pmpi_cart_sub__
#elif !defined(F77_NAME_LOWER_USCORE)
#define mpi_cart_sub_ pmpi_cart_sub
#else
#define mpi_cart_sub_ pmpi_cart_sub_
#endif /* Test on name mapping */

#ifdef F77_USE_PMPI
/* This defines the routine that we call, which must be the PMPI version
   since we're renaming the Fortran entry as the pmpi version.  The MPI name
   must be undefined first to prevent any conflicts with previous renamings. */
#undef MPI_Cart_sub
#define MPI_Cart_sub PMPI_Cart_sub 
#endif

#else

#ifdef F77_NAME_UPPER
#define mpi_cart_sub_ MPI_CART_SUB
#elif defined(F77_NAME_LOWER_2USCORE)
#define mpi_cart_sub_ mpi_cart_sub__
#elif !defined(F77_NAME_LOWER_USCORE)
#define mpi_cart_sub_ mpi_cart_sub
/* Else leave name alone */
#endif


#endif /* MPICH_MPI_FROM_PMPI */

/* Prototypes for the Fortran interfaces */
#include "fproto.h"
FORT_DLL_SPEC void FORT_CALL mpi_cart_sub_ ( MPI_Fint *v1, MPI_Fint v2[], MPI_Fint *v3, MPI_Fint *ierr ){
    int _ctsize;
    int *l2=0;
    {int _topotype;
    PMPI_Topo_test( (MPI_Comm)*v1, &_topotype );
    if (_topotype != MPI_CART) {
        _ctsize = 0;
    }
    else 
        PMPI_Cartdim_get( (MPI_Comm)*v1, &_ctsize );
    }

    if (_ctsize) {int li;
     l2 = (int *)MPL_malloc(_ctsize * sizeof(int), MPL_MEM_OTHER);
     for (li=0; li<_ctsize; li++) {
        l2[li] = MPII_FROM_FLOG(v2[li]);
     }
    }
    *ierr = MPI_Cart_sub( (MPI_Comm)(*v1), l2, (MPI_Comm *)(v3) );
    MPL_free( l2 );
}
