;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  6/25/2003   by    Fu Jie Huang
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defvar mpi-libmpi-loaded ())
(defvar mpi-libmpi ())
(defvar mpi-cpheader-cmd ())
(defvar mpi-libname "libmpi")
(defvar mpi-version 1.1)

(defvar MPI_Datatype -gptr-)
(defvar to-mpi-datatype to-gptr)
(defvar MPI_Comm -gptr-)
(defvar to-mpi-comm to-gptr)
(defvar MPI_Aint -int-)
(defvar to-mpi-aint to-int)
(defvar MPI_Op -gptr-)
(defvar to-mpi-op to-gptr)
(defvar MPI_Group -gptr-)
(defvar to-mpi-group to-gptr)
(defvar MPI_Errhandler -gptr-)
(defvar to-mpi-errhandler to-gptr)
(defvar MPI_Request -gptr-)
(defvar to-mpi-request to-gptr)

(when (not mpi-init)
  (error "Lush was not compiled with option --with-mpi") )

(when (not mpi-libmpi-loaded)
  (cond 
   (mpi-libmpi t)
   ((progn 
      (let* ((lib (find-shared-or-static-library mpi-libname)))
	(when (and lib (filep lib))
	  (setq mpi-libmpi lib)))))
   (t (printf "libmpi.so(.a) could not be found\n")
      (printf "make sure you have it somewhere\n")
      (printf "in standard paths (e.g. in /usr/lib)\n")
      (printf "so that i can find it.\n")
      (printf "If it's in a non-standard place, do\n")
      (printf "(defparameter mpi-libmpi \"yourmpilibrary\")")
      (printf "before loading this file\n")
      (printf "(see %s for more details)\n" file-being-loaded)
      (error "cannot configure mpi")))
  
  (setq mpi-libmpi-loaded t)
  (setq mpi-cpheader-cmd
        '(progn
           (cpheader "#include <mpi.h>")))
)


     
   
