source: trunk/dports/science/berkeleygw/Portfile

Last change on this file was 152561, checked in by dstrubbe@…, 13 months ago

berkeleygw: Update to version 1.2.0. FFTW-3 is now used by default; +fftw2 uses FFTW-2. Take advantage of fixes that enable broader cpp usage. Better scalapack compatibility checking. A couple of patches to build system. Use gsed in testsuite. Enable OpenMP threads.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.9 KB
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: Portfile 152561 2016-09-12 17:31:18Z ryandesign@macports.org $
3
4PortSystem          1.0
5PortGroup           mpi 1.0
6PortGroup           linear_algebra 1.0
7
8name                berkeleygw
9version             1.2.0
10categories          science
11platforms           darwin
12license             BSD
13maintainers         dstrubbe
14
15description         GW/Bethe-Salpeter equation
16long_description    BerkeleyGW is a set of computer codes that calculate the quasiparticle properties \
17                    and the optical responses of a large variety of materials from bulk periodic crystals \
18                    to nanostructures such as slabs, wires and molecules, using many-body perturbation theory \
19                    (the GW approximation and Bethe-Salpeter equation).
20homepage            http://www.berkeleygw.org
21master_sites        ${homepage}/releases
22
23checksums           rmd160  26933a24c10ba03457c667bc5f2d3ca21df2a436 \
24                    sha256  1305dc8587af666fe437bc2561a9106b2b0bcdbe91980b8f1ae7bbd491ce1e25
25
26distfiles           BGW-${version}.tar.gz
27# needed for case-sensitive filesystems
28worksrcdir          BerkeleyGW-${version}
29
30depends_lib         port:fftw-3
31if {![variant_isset fftw2]} {
32    compilers.enforce_some_fortran  fftw-3
33}
34
35# May fail with +mpich +gcc5. Use +mpich +gfortran instead.
36# In file included from /opt/local/include/mpich-gcc5/mpi.h:2231:0,
37#                  from icm.cpp:86:
38# /opt/local/include/mpich-gcc5/mpicxx.h:22:4: error: #error 'Please use the same version of GCC and g++ for compiling MPICH and user MPI programs'
39#  #  error 'Please use the same version of GCC and g++ for compiling MPICH and user MPI programs'
40#     ^
41
42# WHAT DO WE DO WHEN meaning of 'gfortran' is updated? No record... Maybe rename to gfortran5 etc. ?
43
44# test hangs in Epsilon with OpenMPI, for unknown reason.
45# dragonegg fails to link with error
46#   Undefined symbols for architecture x86_64:
47#   "_llvm.objectsize.i64", referenced from:
48#   _spg_get_international in libsymspg.a(spglib.o)
49#   _spg_get_schoenflies in libsymspg.a(spglib.o)
50compilers.choose    fc cc cxx cpp
51mpi.setup           require_fortran -dragonegg -openmpi -openmpi_devel -gfortran -clang -llvm
52# FIXME: +gfortran just needs smarter setting of cpp to the one from gcc;
53#clang and llvm only useful with +g95 currently (which is useless)
54
55# just for cpp
56if {[variant_isset g95]} {
57    depends_build-append  port:llvm-gcc42
58}
59
60# FIXME: this unnecessarily enforces scalapack also had same C compiler as we are using.
61if {[mpi_variant_isset]} {
62    depends_lib-append  port:scalapack
63    if {![mpi_variant_isset]} {
64        ui_error "+scalapack requires an MPI variant. Choose +mpich, +mpich_devel, +openmpi, or +openmpi_devel."
65        return -code error "+scalapack requires an MPI variant."
66    }
67}
68
69# fftw is not universal
70universal_variant   no
71
72configure {
73    system -W ${worksrcpath} "sed 's|/opt/local|${prefix}|' < config/generic.serial.macos.mk > arch.mk"
74    reinplace -W ${worksrcpath} "s|MATHFLAG += -DHDF5||" arch.mk
75    if {![variant_isset hdf5]} {
76        system -W ${worksrcpath} "echo 'HDF5LIB=' >> arch.mk"
77    }
78}
79
80patchfiles          patch-Common-common-rules.mk.diff \
81                    patch-Makefile.diff
82
83build.target        all-flavors
84use_parallel_build  yes
85
86destroot.post_args  INSTDIR=${destroot}${prefix}
87
88test.run            yes
89
90
91#depends_build       port:gsed
92pre-test {
93    reinplace -W ${worksrcpath}/testsuite "s|sed|gsed|" Graphene/Graphene.test Graphene/Graphene_3D.test \
94        Si-EPM/Si.test Si-EPM/Si_cplx_spin.test
95
96    if {[mpi_variant_isset]} {
97        test.args-append    TESTSCRIPT="MPIEXEC=${prefix}/bin/${mpi.exec} make check-parallel"
98        test.target         check-jobscript
99
100        # FIXME: what about with threads? set OMP_NUM_THREADS=2 and divide ncpus by 2.
101        if {![catch {sysctl hw.ncpu} ncpus]} {
102            test.env-append BGW_TEST_MPI_NPROCS=$ncpus
103        }
104        ui_msg "Running testsuite in parallel with $ncpus MPI tasks"       
105    } else {
106        test.target         check
107    }
108}
109
110notes {
111    For the purposes of record-keeping and support, please register an account at www.berkeleygw.org.
112}
113
114pre-build {
115    build.args-append   LINK="${configure.fc}" CC_COMP=${configure.cxx} C_COMP=${configure.cc} C_LINK=${configure.cxx} \
116                        LAPACKLIB="-L${prefix}/lib/ ${linalglib}"
117
118    set mathflag ""
119    if {[variant_isset hdf5]} {
120        set mathflag "${mathflag} -DHDF5"
121    }
122   
123    if {[variant_isset fftw2]} {
124        build.args-append  FFTWLIB="-L${prefix}/lib/ -ldfftw"
125    } else {
126        if {[variant_isset threads]} {
127            build.args-append  FFTWLIB="-L${prefix}/lib/ -lfftw3 -lfftw3_threads"
128        } else {
129            build.args-append  FFTWLIB="-L${prefix}/lib/ -lfftw3"
130        }
131        set mathflag "${mathflag} -DUSEFFTW3"
132    }
133
134    if {[variant_isset g95]} {
135        set configure.cpp     llvm-cpp-4.2
136    }
137
138    if {[variant_isset g95]} {
139        build.args-append COMPFLAG="-DG95" FCPP="${configure.cpp} -P -C" \
140                          F90free="${prefix}/bin/g95 -ffree-form -ffree-line-length-huge -fno-second-underscore" \
141                          MOD_OPT="-fmod="
142        # test, destroot args needed just to avoid trying to build in the test/openmp directory unnecessarily
143        test.args-append  COMPFLAG="-DG95"
144        destroot.args-append  COMPFLAG="-DG95"
145    } else {
146        # gcc is default in arch.mk so most things do not need to be modified
147        build.args-append FCPP="${configure.cpp} -C" \
148            F90free="${configure.fc} -ffree-form -ffree-line-length-none -fno-second-underscore"
149    }
150
151    if {[variant_isset threads]} {
152        set paraflag "-DOMP"
153    } else {
154        set paraflag ""
155    }
156   
157    if {[mpi_variant_isset]} {
158        set mathflag "${mathflag} -DUSESCALAPACK"
159        set paraflag "${paraflag} -DMPI"
160        build.args-append C_PARAFLAG="-DPARA" SCALAPACKLIB="-L${prefix}/lib/ -lscalapack"
161    }
162
163    build.args-append   MATHFLAG="${mathflag}" PARAFLAG="${paraflag}"
164    test.args-append    MATHFLAG="${mathflag}" PARAFLAG="${paraflag}"
165}
166
167variant threads description {Build with OpenMP support} conflicts g95 {
168    set configure.fc "${configure.fc} -fopenmp"
169}
170
171variant debug description {Add debug flags for more checking and output, but slower runs.} {
172    build.args-append    DEBUGFLAG="-DDEBUG -DVERBOSE"
173}
174
175variant hdf5 description {Build with HDF5 support for faster epsmat I/O} {
176    depends_lib-append          port:hdf5
177    require_active_variants     port:hdf5 hl
178    compilers.enforce_fortran   hdf5
179}
180
181variant fftw2 description {Build with FFTW-2} {
182    depends_lib-replace        port:fftw-3 port:fftw
183    # fftw port always has a Fortran variant
184}
185
186livecheck.type      none
187# This is broken currently due to changes in the settings to the code's webpage.
188#livecheck.type      regex
189#livecheck.url       ${homepage}/?q=node/6
190#livecheck.regex     BGW-(\[0-9.\]+).tar.gz
Note: See TracBrowser for help on using the repository browser.