Ticket #45617: Portfile

File Portfile, 10.6 KB (added by cram5431@…, 10 years ago)

Portfile rev 1

Line 
1# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2# $Id$
3
4PortSystem          1.0
5PortGroup           active_variants 1.1
6PortGroup           mpi 1.0
7
8name                abinit
9version             7.8.2
10revision            1
11categories          science
12platforms           darwin
13license             GPL-3
14maintainers         gmail.com:cram5431 \
15                    openmaintainer
16
17description         Full-featured atomic-scale first-principles simulation software
18
19long_description    ABINIT is a package whose main program allows one to find the total energy, \
20                    charge density and electronic structure of systems made of electrons and nuclei \
21                    (molecules and periodic solids) within Density Functional Theory (DFT), \
22                    using pseudopotentials and a planewave or wavelet basis. \
23                    ABINIT also includes options to optimize the geometry according to the DFT forces \
24                    and stresses, or to perform molecular dynamics simulations using these forces, \
25                    or to generate dynamical matrices, Born effective charges, and dielectric tensors, \
26                    based on Density-Functional Perturbation Theory, and many more properties. \
27                    Excited states can be computed within the Many-Body Perturbation Theory \
28                    (the GW approximation and the Bethe-Salpeter equation), and \
29                    Time-Dependent Density Functional Theory (for molecules). \
30                    In addition to the main ABINIT code, different utility programs are provided. \
31                    ABINIT is a project that favours development and collaboration.
32
33homepage            http://www.abinit.org
34master_sites        http://ftp.abinit.org/
35
36checksums           rmd160  c82fcc454ab7f337728fad33ca2d563887c15cba \
37                    sha256  793b8b5698f8a4231e34e62711e7d5f56fb276aa5bb3bad8303af0ae2f74aead
38
39depends_lib         port:atlas
40
41configure.args      --with-linalg-flavor="atlas" --enable-gw-dpc
42configure.optflags  -O3
43
44#This is a temporary measure for debugging configure failure on Mountain Lion buildslave.
45#checking for gcc... mpicc-mpich-mp
46#checking whether the C compiler works... no
47#configure.cmd       ./configure || true
48#post-configure {
49#    system -W ${worksrcpath} "cat config.log"
50#}
51
52build.cmd           make
53use_parallel_build  yes
54# We do not need to use ABINIT's own approach to parallel builds, which only is relevant if
55# the "fallbacks" are used, namely if we asked for etsf_io, libxc, wannier90, etc. support
56# but did not provide the libraries. That situation should never happen for this port.
57#build.target        multi multi_nprocs=4
58
59default_variants +etsf_io +libxc +wannier90
60
61#Restrict to gcc/clang because of dependencies
62compilers.choose    fc cc cxx cpp
63compilers.setup     -clang -dragonegg -llvm
64mpi.setup
65
66#Select mpi/gcc default:
67#  If a MPI variant is given, take it
68#  If not, check if there is a selected MPI; if yes, take it
69#  If there is no defaut MPI, take mpich
70#  If "sequential" or "-mpi(default)" variant, take no MPI
71set current_mpi "none"
72set mpi_default mpich
73set sequential [variant_isset sequential]
74if {!${sequential} } {
75    if { [mpi_variant_isset] } {
76        set current_mpi [mpi_variant_name]
77    } else {
78        if {![catch {set current_mpi [file link ${prefix}/etc/select/mpi/current]}]} {
79            if { ${current_mpi} eq "base" } { set current_mpi "none" }
80        }
81        if { ${current_mpi} eq "none"} { 
82            if {[info exists variations(${mpi_default})] && \
83                $variations(${mpi_default}) eq "-"} {
84                set sequential 1
85            } else {
86                set current_mpi ${mpi_default}
87                default_variants-append +${mpi_default}
88            }
89        }
90    }
91}
92if {${sequential}} {
93    if { [gcc_variant_isset] } {
94        default_variants-append +[c_variant_name]
95    } else {
96        default_variants-append +gcc48
97    }
98}
99
100pre-fetch {
101    if { [variant_isset libxc] } {
102        if { ![active_variants libxc [c_variant_name]] } {
103            ui_error "libxc must have been built with +[c_variant_name]"
104            return -code error "libxc must have been built with +[c_variant_name]"
105        }
106    }
107    if { [variant_isset netcdf] } {
108        if {![active_variants netcdf-fortran [c_variant_name]] } {
109            ui_error "netcdf-fortran must have been built with +[c_variant_name]"
110            return -code error "netcdf-fortran must have been built with +[c_variant_name]"
111        }
112    }
113    if { [variant_isset etsf_io] } {
114        if {![active_variants etsf_io [fortran_variant_name]] } {
115            ui_error "etsf_io must have been built with +[fortran_variant_name]"
116            return -code error "etsf_io must have been built with +[fortran_variant_name]"
117        }
118    }
119    if { [variant_isset fftw3] } {
120        if {![active_variants fftw-3 gfortran] || \
121            ![active_variants fftw-3-single gfortran]} {
122            ui_error "fftw-3 and nfftw-3-single must have been built with +gfortran:"
123            ui_error "This can be achieved by : sudo port -f install fftw-3-single +gfortran"
124            return -code error "fftw-3/fftw-3-single must have been built with +gfortran"
125        }
126    }
127}
128
129#Fix unnecessary rejection of libxc 2.1.0
130#Fix a openMP syntax error
131patchfiles patch-configure.diff \
132           patch-src-71_bse-haydock.F90.diff
133
134pre-configure {
135    if { [variant_isset etsf_io] } {
136            configure.args-append  --with-trio-flavor="netcdf+etsf_io"
137        } elseif { [variant_isset netcdf] } {
138            configure.args-append  --with-trio-flavor="netcdf"
139        } else {
140            configure.args-append  --with-trio-flavor="none"
141    }
142    set dft-flavor "none"
143    if { [variant_isset libxc] } {
144        if { ${dft-flavor} eq "none" } {
145            set dft-flavor "libxc"
146        } else {
147            set dft-flavor ${dft-flavor}"+libxc"
148        }
149    }
150    if { [variant_isset wannier90] } {
151        if { ${dft-flavor} eq "none" } {
152            set dft-flavor "wannier90"
153        } else {
154            set dft-flavor ${dft-flavor}"+wannier90"
155        }
156    }
157    if { [variant_isset atompaw] } {
158        if { ${dft-flavor} eq "none" } {
159            set dft-flavor "atompaw"
160        } else {
161            set dft-flavor ${dft-flavor}"+atompaw"
162        }
163    }
164#    if { [variant_isset bigdft] } {
165#        if { ${dft-flavor} eq "none" } {
166#            set dft-flavor "bigdft"
167#        } else {
168#            set dft-flavor ${dft-flavor}"+bigdft"
169#        }
170#    }
171    configure.args-append  --with-dft-flavor="${dft-flavor}"
172
173    configure.args-append  FCCPP="${configure.cpp} -ansi"
174
175    if { ${current_mpi} ne "none"} {
176        configure.args-append  --enable-mpi="yes" --enable-mpi-io="yes"
177        if {[string match *openmpi* ${current_mpi}]} {
178            configure.args-append   --with-mpi-level="1"
179        }
180        if { ![mpi_variant_isset] } {
181            configure.fc     ${mpi.fc}
182            configure.cc     ${mpi.cc}
183            configure.cxx    ${mpi.cxx}
184        }
185        if { ${mpi.exec} ne "" } {
186            configure.args-append  MPI_RUNNER=${mpi.exec}
187            test.env-append        MPIEXEC=${mpi.exec}
188        }
189    } else {
190        configure.args-append  --enable-mpi="no" --enable-mpi-io="no"
191    }
192}
193
194destroot {
195    xinstall -W ${worksrcpath}/src/98_main \
196     abinit aim anaddb band2eps bsepostproc conducti cut3d \
197     fftprof ioprof kss2wfk lapackprof macroave mrgddb \
198     mrggkk mrgscr optic ujdet vdw_kernelgen \
199     ${destroot}${prefix}/bin
200    if { [variant_isset atompaw] } {
201        xinstall -W ${worksrcpath}/fallbacks/exports/bin \
202         atompaw-abinit ${destroot}${prefix}/bin
203    }
204}
205
206#universal variant not allowed for libxc/etsf_io
207universal_variant   no
208
209# FIXME: this does not work.
210# test.run            yes
211# test.target         check-full
212
213variant fftw3 description {Build with support for fftw-3 FFT library} {
214    depends_lib-append      port:fftw-3
215    depends_lib-append      port:fftw-3-single
216#   require_active_variants fftw-3 gfortran
217#   require_active_variants fftw-3-single gfortran
218    if { [variant_isset threads] } {
219        configure.args-append   --with-fft-flavor="fftw3-threads"
220        configure.args-append   --with-fft-libs="-lfftw3_threads -lfftw3 -lfftw3f"
221    } else {
222        configure.args-append   --with-fft-flavor="fftw3"
223        configure.args-append   --with-fft-libs="-lfftw3 -lfftw3f"
224    }
225}
226
227variant threads description {Build with support for multi-thread support (openMP)} {
228    configure.args-append   --enable-openmp
229    configure.fcflags-append -fopenmp
230    configure.args-append   --with-linalg-libs="-L"${prefix}"/lib -ltatlas"
231    configure.args-append   --with-linalg-incs="-I"${prefix}"/include"
232}
233
234variant netcdf description {Build with support for NetCDF transferable I/O} {
235    depends_lib-append      port:netcdf-fortran
236    configure.args-append   --with-netcdf-incs="-I"${prefix}"/include"
237    configure.args-append   --with-netcdf-libs="-L"${prefix}"/lib -lnetcdf -lnetcdff"
238}
239
240variant etsf_io description {Build with support for ETSF_IO transferable I/O} {
241    depends_lib-append      port:etsf_io
242    configure.args-append   --with-etsf-io-incs="-I"${prefix}"/include/gcc"
243    configure.args-append   --with-netcdf-incs="-I"${prefix}"/include"
244    configure.args-append   --with-netcdf-libs="-L"${prefix}"/lib -lnetcdf -lnetcdff"
245}
246
247variant libxc description {Build with support for libXC exchange-correlation library} {
248    depends_lib-append      port:libxc
249    configure.args-append   --with-libxc-incs="-I"${prefix}"/include"
250}
251
252variant wannier90 description {Build with support for Wannier90} {
253    depends_lib-append      port:wannier90
254}
255
256variant atompaw description {Build including AtomPAW atomic dataset generator} {
257}
258
259variant sequential conflicts mpich mpich_devel openmpi openmpi_devel description {Build without MPI support} {
260}
261
262# FIXME: the code's build system will download BigDFT itself, which is contrary to the
263# way MacPorts should work. Make a bigdft port to support this.
264# There is an error compiling anyway, which could be fixed with a patch,
265# but it is unpatchable since the download occurs after the patch phase.
266
267#variant bigdft description {Build with support for the wavelet BigDFT library} {
268    # avoid this error (and equivalent with OpenCL)
269    # :info:build ar cru libCUDA.a 
270    # :info:build ar: no archive members specified
271#    patchfiles-append       patch-fallbacks-sources-bigdft-1.7.0.93-src-Makefile.in.diff
272#}
273
274livecheck.type      regex
275livecheck.url       ${homepage}/downloads/source-packages/abinit-1/releases/index.html
276livecheck.regex     ABINIT (\[0-9.\]+)
277