# $Id: Portfile 76611 2011-03-02 15:06:47Z mmoll@macports.org $

PortSystem      1.0

name            slepc
version         3.1-p6
revision        1
license         LGPL
categories      math science
maintainers     mmoll
description     Scalable Library for Eigenvalue Problem Computations
long_description    SLEPc is a software library for the solution of large \
    scale sparse eigenvalue problems on parallel computers. It is an \
    extension of PETSc and can be used for either standard or generalized \
    eigenproblems, with real or complex arithmetic. It can also be used for \
    computing a partial SVD of a large, sparse, rectangular matrix.
notes           "Add the following lines to your .bash_profile if you plan to\
                use the PETSC/SLEPC makefile rules in $prefix/lib/petsc/conf:\n\
                \texport PETSC_DIR=${prefix}/lib/petsc\n\
                \texport SLEPC_DIR=${prefix}/lib/petsc"

platforms       darwin
homepage        http://www.grycap.upv.es/slepc
master_sites    http://www.grycap.upv.es/slepc/download/distrib
distname        ${name}-${version}
universal_variant   no

checksums           md5     a57f717fa52d3a1fedd98137ca0325a3 \
                    sha1    dc90f7158067d5884f1301480bc053ea94058766 \
                    rmd160  6820a0603e2eeb89a5d569cdec27548ad813bc9e

depends_lib-append  port:petsc

extract.suffix  .tgz
configure.args        --prefix=${prefix}/lib/petsc
build.env-append      PETSC_DIR=${prefix}/lib/petsc PETSC_ARCH=installed-petsc SLEPC_DIR=${worksrcpath}
destroot.env-append   PETSC_DIR=${prefix}/lib/petsc PETSC_ARCH=installed-petsc SLEPC_DIR=${worksrcpath}
destroot.cmd-append   SLEPC_INSTALL_DIR=${destroot}${prefix}/lib/petsc

variant arpack description {compile with ARPACK support} {
    pre-fetch {
        if {![file exists ${prefix}/lib/libparpack.a]} {
            return -code error "Please install the mpi variant of arpack first."
        }
    }
    # This is a rather fragile way to figure out where the fortran library can be
    # found that is needed to link against libparpack.a:
    if {[file exists ${prefix}/lib/gcc44]} {
        set fortrandir ${prefix}/lib/gcc44
    } else {
        if {[file exists ${prefix}/lib/gcc43]} {
            set fortrandir ${prefix}/lib/gcc43
        } else {
            if {[file exists ${prefix}/lib/gcc42]} {
                set fortrandir ${prefix}/lib/gcc42
            } else {
                if {[file exists ${prefix}/lib/g95]} {
                    set fortrandir ${prefix}/lib/gcc95
                } else {
                    return -code error "Please install a fortran compiler by installing one of the following ports: gcc42, gcc43, gcc44, or g95."
                }
            }
        }
    }
    depends_lib-append      port:arpack
    configure.args-append   --with-arpack-dir=${fortrandir} \
                --with-arpack-flags=-lparpack,-larpack,-lgfortran,-lmpi_f77
}

livecheck.type  regex
livecheck.url   http://www.grycap.upv.es/slepc/download/download.htm
livecheck.regex slepc-(\[0-9.\]+(-p\[0-9\]+))\\.tgz
