Index: Portfile
===================================================================
--- Portfile	(revision 142485)
+++ Portfile	(working copy)
@@ -2,10 +2,10 @@
 # $Id$
 
 PortSystem          1.0
-PortGroup           active_variants 1.1
+PortGroup           mpi 1.0
 
 name                abinit
-version             7.10.2
+version             7.10.5
 revision            2
 categories          science
 platforms           darwin
@@ -32,19 +32,19 @@
 homepage            http://www.abinit.org
 master_sites        http://ftp.abinit.org/
 
-checksums           rmd160  cf4078c1eab2cc3200e084379738939cafda5ba2 \
-                    sha256  cbead80096d97f1c8d08ccb3b9b2851ac1e56accaebe551d9ab29757e9cd531e
+checksums           rmd160  f77a9db5bcd97bcc46ea11a96bbf8f17cb1a19b3 \
+                    sha256  e9376a3e34790bce90992f28e5fa8554b51ba467bf5709c7fd25d300e7c4f56a
 
-depends_lib         port:atlas
+# or vecLibFort, or OpenBLAS(-devel)
+depends_lib-append  port:atlas
 
-configure.args      --with-linalg-flavor="atlas" --enable-gw-dpc
+compilers.choose    cc fc
+# g95 is not compatible with OpenMP
+mpi.setup           default require_fortran -g95
+
+configure.args-append  --with-linalg-flavor="atlas" --enable-gw-dpc --enable-fox
 configure.optflags  -O3
 
-# FIXME: not right for g95? would be -ffree-line-length-huge. This is really the configure script's job? Not easy to set this right for MPI g95.
-# If this is not set, there will be some compilation failures, due to inadequate provisions by the code for compilers that don't accept long lines.
-configure.fcflags-append -ffree-line-length-none
-
-build.cmd           make
 use_parallel_build  yes
 
 # We do not need to use ABINIT's own approach to parallel builds, which only is relevant if
@@ -54,80 +54,19 @@
 
 default_variants +etsf_io +libxc
 # Do not put +wannier90 since tests fail for wannier90 use.
-if { ![variant_isset gcc46] && ![variant_isset gcc47] && ![variant_isset gcc48] && ![variant_isset gcc49] } {
-    if { ![variant_isset openmpi] } {
-        default_variants    +mpich
-    } elseif { ![variant_isset mpich] } {
-        default_variants    +openmpi
-    } else {
-        default_variants    +gcc49
-    }
-}
 
-# FIXME: use compiler and MPI port groups
-
-pre-fetch {
-    set fortran unknown
-    set fortrans { gcc42 gcc43 gcc44 gcc45 gcc46 gcc47 gcc48 gcc49 g95 }
-
-    foreach fc_name ${fortrans} {
-        if { [variant_isset ${fc_name}] } {
-            set fortran ${fc_name}
-        } elseif { [variant_isset openmpi] } {
-            if { [_portnameactive openmpi-default] } {
-                if { [active_variants openmpi-default ${fc_name}] } { set fortran ${fc_name} }
-            } elseif { [_portnameactive openmpi-devel-default] } {
-                if { [active_variants openmpi-devel-default ${fc_name}] } { set fortran ${fc_name} }
-            }
-        } elseif { [variant_isset mpich] } {
-            if { [_portnameactive mpich-default] } {
-                if { [active_variants mpich-default ${fc_name}] } { set fortran ${fc_name} }
-            } elseif { [_portnameactive mpich-devel-default] } {
-                if { [active_variants mpich-devel-default ${fc_name}] } { set fortran ${fc_name} }
-            }
+pre-configure {
+    if {[fortran_variant_name] eq "g95"} {
+        configure.fcflags-append -ffree-line-length-huge
+        if {[variant_isset threads]} {
+            ui_error "You can select only one of +g95 and +threads."
+            return -code error "+g95 and +threads are not compatible since g95 does not support OpenMP."
         }
+    } else {
+        configure.fcflags-append -ffree-line-length-none
     }
 
-    if { ${fortran} eq "unknown" } {
-        if { [variant_isset openmpi] } {
-            ui_error "Variant +openmpi requires openmpi to have been built with Fortran support."
-            return -code error "Variant +openmpi requires openmpi to have been built with Fortran support."
-        } elseif { [variant_isset mpich] } {
-            ui_error "Variant +mpich requires mpich-default/mpich-devel-default to have been built with Fortran support."
-            return -code error "Variant +mpich requires mpich-default/mpich-devel-default to have been built with Fortran support."
-        } else {
-            ui_error "Internal error: cannot determine Fortran compiler."
-            return -code error "Internal error: cannot determine Fortran compiler."
-        }
-    }
-
-    if { [variant_isset libxc] } {
-        if { ![active_variants libxc ${fortran}] } {
-            ui_error "libxc must have been built with +${fortran}."
-            return -code error "libxc must have been built with +${fortran}."
-        }
-    }
-
-    if { [variant_isset netcdf] } {
-        if {![active_variants netcdf-fortran ${fortran}] } {
-            ui_error "netcdf-fortran must have been built with +${fortran}."
-            return -code error "netcdf-fortran must have been built with +${fortran}."
-        }
-    }
-
     if { [variant_isset etsf_io] } {
-        if {![active_variants etsf_io ${fortran}] } {
-            ui_error "etsf_io must have been built with +${fortran}."
-            return -code error "etsf_io must have been built with +${fortran}."
-        }
-    }
-
-#   No need to check compiler for wannier90
-#   No need to check compiler for fftw-3
-}
-
-pre-configure {
-    if { [variant_isset etsf_io] } {
             configure.args-append  --with-trio-flavor="netcdf+etsf_io"
         } elseif { [variant_isset netcdf] } {
             configure.args-append  --with-trio-flavor="netcdf"
@@ -187,52 +126,21 @@
 test.target         built-in fast
 # wannier90 test will probably fail.
 
-variant gcc46 conflicts gcc47 gcc48 gcc49 openmpi mpich description {Build with GCC 4.6} {
-    configure.compiler  macports-gcc-4.6
-    configure.args-append  FCCPP="${configure.cpp} -ansi"
-}
-
-variant gcc47 conflicts gcc46 gcc48 gcc49 openmpi mpich description {Build with GCC 4.7} {
-    configure.compiler  macports-gcc-4.7
-    configure.args-append  FCCPP="${configure.cpp} -ansi"
-}
-
-variant gcc48 conflicts gcc46 gcc47 gcc49 openmpi mpich description {Build with GCC 4.8} {
-    configure.compiler  macports-gcc-4.8
-    configure.args-append  FCCPP="${configure.cpp} -ansi"
-}
-
-variant gcc49 conflicts gcc46 gcc47 gcc48 openmpi mpich description {Build with GCC 4.9} {
-    configure.compiler  macports-gcc-4.9
-    configure.args-append  FCCPP="${configure.cpp} -ansi"
-}
-
-variant openmpi conflicts gcc46 gcc47 gcc48 gcc49 mpich description {Build parallel version with OpenMPI} {
-    depends_lib-append     path:bin/mpif90-openmpi-mp:openmpi-default
-    configure.fc           mpif90-openmpi-mp
-    configure.cc           mpicc-openmpi-mp
-    configure.cxx          mpicxx-openmpi-mp
+pre-configure {
     configure.args-append  FCCPP="${configure.cc} -E -ansi"
-    configure.args-append  --enable-mpi="yes" --enable-mpi-io="yes" --with-mpi-level="1"
-    configure.args-append  MPI_RUNNER=${prefix}/bin/mpiexec-openmpi-mp
-    test.env-append        MPIEXEC=${prefix}/bin/mpiexec-openmpi-mp
+    if {[mpi_variant_isset]} {
+        configure.args-append  MPI_RUNNER=${mpi.exec}
+        test.env-append        MPIEXEC=${mpi.exec}
+        configure.args-append  --enable-mpi="yes" --enable-mpi-io="yes"
+    } else {
+        configure.args-append  --enable-mpi="no"
+    }
 }
 
-variant mpich conflicts gcc46 gcc47 gcc48 gcc49 openmpi description {Build parallel version with MPICH} {
-    depends_lib-append     path:bin/mpif90-mpich-mp:mpich-default
-    configure.fc           mpif90-mpich-mp
-    configure.cc           mpicc-mpich-mp
-    configure.cxx          mpicxx-mpich-mp
-    configure.args-append  FCCPP="${configure.cc} -E -ansi"
-    configure.args-append  --enable-mpi="yes" --enable-mpi-io="yes"
-    configure.args-append  MPI_RUNNER=${prefix}/bin/mpiexec-mpich-mp
-    test.env-append        MPIEXEC=${prefix}/bin/mpiexec-mpich-mp
-}
-
 variant fftw3 description {Build with support for fftw-3 FFT library} {
-    # FIXME: these need to be installed with some Fortran variant
-    depends_lib-append      port:fftw-3
-    depends_lib-append      port:fftw-3-single
+    depends_lib-append      port:fftw-3 port:fftw-3-single
+    compilers.enforce_some_fortran fftw-3 fftw-3-single
+    
     if { [variant_isset threads] } {
         configure.args-append   --with-fft-flavor="fftw3-threads"
         configure.args-append   --with-fft-libs="-lfftw3_threads -lfftw3 -lfftw3f"
@@ -242,7 +150,8 @@
     }
 }
 
-variant threads description {Build with support for multi-thread support (openMP)} {
+variant threads description {Build with support for OpenMP threads} {
+    # not compatible with g95. What about threaded FFTW3?
     configure.args-append   --enable-openmp
     configure.fcflags-append -fopenmp
     configure.args-append   --with-linalg-libs="-L${prefix}/lib -ltatlas"
@@ -251,6 +160,7 @@
 
 variant netcdf description {Build with support for NetCDF transferable I/O} {
     depends_lib-append      port:netcdf-fortran
+    compilers.enforce_fortran netcdf-fortran
     configure.args-append   --with-netcdf-incs="-I${prefix}/include"
     configure.args-append   --with-netcdf-libs="-L${prefix}/lib -lnetcdf -lnetcdff"
 }
@@ -257,11 +167,13 @@
 
 variant etsf_io requires netcdf description {Build with support for ETSF_IO transferable I/O} {
     depends_lib-append      port:etsf_io
+    compilers.enforce_fortran etsf_io
     configure.args-append   --with-etsf-io-incs="-I${prefix}/include/gcc"
 }
 
 variant libxc description {Build with support for libXC exchange-correlation library} {
     depends_lib-append      port:libxc
+    compilers.enforce_fortran libxc
     configure.args-append   --with-libxc-incs="-I${prefix}/include"
 }
 
@@ -281,9 +193,10 @@
 #    patchfiles-append       patch-fallbacks-sources-bigdft-1.7.0.93-src-Makefile.in.diff
 #}
 
-variant atompaw description {Build including AtomPAW atomic dataset generator} {
-}
+# FIXME: same problem as for BigDFT, it gets downloaded. Make a separate port.
+#variant atompaw description {Build including AtomPAW atomic dataset generator} {
+#}
  
 livecheck.type      regex
-livecheck.url       ${homepage}/downloads/source-packages/abinit-1/releases/index.html
-livecheck.regex     ABINIT (\[0-9.\]+)
+livecheck.url       ${homepage}/downloads/abinit-packages
+livecheck.regex     ABINIT v (\[0-9.\]+)
