C=======================================================================
C @(#) $Id$
C-----------------------------------------------------------------------
C
C-----------------------------------------------------------------------
C     Windows multiport: Import MPI 'named constants'
C-----------------------------------------------------------------------
C
#if defined(CFX5_OS_WINNT) || defined(CFX5_OS_WINNT_AMD64)
#if defined(CFX5_MPTMPI)
!DEC$ ATTRIBUTES DLLIMPORT :: /WFMPI_IN_PLACE/
!DEC$ ATTRIBUTES DLLIMPORT :: /WFMPI_BOTTOM/
!DEC$ ATTRIBUTES DLLIMPORT :: /WFMPI_STATUS_IGNORE/
!DEC$ ATTRIBUTES DLLIMPORT :: /WFMPI_STATUSES_IGNORE/
#endif
#endif
C
C ------------------------------
C     Preprocessor includes
C ------------------------------
C
#include "cfd_parallel_mpi_undef.h"
#include "mpif.h"
#include "cfd_parallel_mpi_undef.h"
#include "cfd_parallel_mpi_int8.h"
C
C-----------------------------------------------------------------------
C     Windows: Interface for MPI routines with varying arguments
C-----------------------------------------------------------------------
C
#if defined(CFX5_OS_WINNT) || defined(CFX5_OS_WINNT_AMD64)
C
C---- Int64 wrapper: Solver (Fortran) -> wrapper (C) -> MPI
C                    Interface is for the wrapper
C
#if defined(CFX5_ATTR_INT64) && defined(CFX5_MPI_INT64)

#define __dec_attr__ DEFAULT, VARYING
C
C---- No wrapper : Solver (Fortran) -> MPI
C                  Interface is for MPI
C                  (MSMPI has a different calling convention)
C
#else

#if defined(CFX5_IBMMPI) || defined(CFX5_IMPI) || defined(CFX5_MPTMPI)
#define __dec_attr__ DEFAULT, VARYING
#elif defined(CFX5_MSMPI)
#define __dec_attr__ C, REFERENCE, VARYING
#endif

#endif
C
C---- Interface definitions
C
      INTERFACE

      SUBROUTINE MPI_PACK (I1,I2,I3,I4,I5,I6,I7,I8)
!DEC$ ATTRIBUTES __dec_attr__::MPI_PACK
      INTEGER I1,I2,I3,I4,I5,I6,I7,I8
      END SUBROUTINE MPI_PACK

      SUBROUTINE MPI_UNPACK (I1,I2,I3,I4,I5,I6,I7,I8)
!DEC$ ATTRIBUTES __dec_attr__::MPI_UNPACK
      INTEGER I1,I2,I3,I4,I5,I6,I7,I8
      END SUBROUTINE MPI_UNPACK

      SUBROUTINE MPI_SEND (I1,I2,I3,I4,I5,I6,I7,I8)
!DEC$ ATTRIBUTES __dec_attr__::MPI_SEND
      INTEGER I1,I2,I3,I4,I5,I6,I7,I8
      END SUBROUTINE MPI_SEND

      SUBROUTINE MPI_RECV (I1,I2,I3,I4,I5,I6,I7,I8)
!DEC$ ATTRIBUTES __dec_attr__::MPI_RECV
      INTEGER I1,I2,I3,I4,I5,I6,I7,I8
      END SUBROUTINE MPI_RECV

      SUBROUTINE MPI_BCAST (I1,I2,I3,I4,I5,I6)
!DEC$ ATTRIBUTES __dec_attr__::MPI_BCAST
      INTEGER I1,I2,I3,I4,I5,I6
      END SUBROUTINE MPI_BCAST

      END INTERFACE
#endif
C
C-----------------------------------------------------------------------
C     Parameter definitions and common blocks
C-----------------------------------------------------------------------
C
C---- RCVSEC = time interval for timed receive
C
      INTEGER         RCVSEC
      PARAMETER      (RCVSEC=10)
C
C---- Declare buffers for MPI
C
      INTEGER         MPISBF(10000),MPIRBF(10000),MPIBBF(10000)
      COMMON /PARMPI/ MPISBF, MPIRBF, MPIBBF

      INTEGER         DATPOS, DATMAX
      PARAMETER      (DATMAX=5000)
      COMMON /DATMPI/ DATPOS
C
C---- MPI communicators
C
      INTEGER             CFX5_MPI_COMM, CFX5_MPI_GROUP,
     &                    CFX5_MPI_COMM_COL, CFX5_MPI_COMM_LVL
      COMMON /PARCOM_MPI/ CFX5_MPI_COMM, CFX5_MPI_GROUP,
     &                    CFX5_MPI_COMM_COL, CFX5_MPI_COMM_LVL
C
C-----------------------------------------------------------------------
C     Word length for buffers
C-----------------------------------------------------------------------
C
#if defined CRAY

#define   __character_word_length__ 1
#define     __logical_word_length__ 8
#define     __integer_word_length__ 8
#define        __real_word_length__ 8
#define      __double_word_length__ 8

#else

#define   __character_word_length__ 1
#define     __logical_word_length__ 4
#if defined(CFX5_ATTR_INT64)
#define     __integer_word_length__ 8
#else
#define     __integer_word_length__ 4
#endif
#ifdef DOUBLE_PRECISION
#define        __real_word_length__ 8
#else
#define        __real_word_length__ 4
#endif
#define      __double_word_length__ 8

#endif
C
C-----------------------------------------------------------------------
C     Data types
C-----------------------------------------------------------------------
C
#if defined(CFX5_ATTR_INT64)
#define             __mpi_integer__ MPI_INTEGER8
#else
#define             __mpi_integer__ MPI_INTEGER
#endif
#define           __mpi_2integer4__ MPI_2INTEGER
#ifdef DOUBLE_PRECISION
#define                __mpi_real__ MPI_DOUBLE_PRECISION
#else
#define                __mpi_real__ MPI_REAL
#endif
#define              __mpi_double__ MPI_DOUBLE_PRECISION
#define             __mpi_2double__ MPI_2DOUBLE_PRECISION
#define             __mpi_logical__ MPI_LOGICAL
#define              __mpi_string__ MPI_CHARACTER
