aboutsummaryrefslogtreecommitdiff
blob: 0a28ae19af74ca80777b78bf72a27e6adc8bd441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

inherit fortran versionator

MY_P="${P/-/}"

DESCRIPTION="Model-independent Parameter ESTimation for model calibration and
predictive uncertainty analysis."
HOMEPAGE="http://www.pesthomepage.org"
SRC_URI="http://www.pesthomepage.org/getfiles.php?file=${MY_P}.tar.zip -> ${P}.tar.zip
	doc? ( http://www.pesthomepage.org/files/pestman.pdf
	       http://www.pesthomepage.org/files/addendum.pdf )"

# License is poorly specified on the SSPA web site.  It only says that
# Pest is freeware.
LICENSE="public-domain"
SLOT="0"
KEYWORDS="~amd64"
IUSE="doc"
DEPEND="app-arch/unzip"
RDEPEND=""

MAKEOPTS="${MAKEOPTS} -j1"

# Need a Fortran 90 compiler.
FORTRAN="gfortran ifc"

S="${WORKDIR}/${PN}"

src_unpack() {
	mkdir "${S}" && cd "${S}"
	unpack "${P}.tar.zip"
	unpack ./"${MY_P}.tar"
}

src_prepare() {
	# I decided it was cleaner to make all edits with sed, rather than a patch.
	sed -i \
		-e "s;^F90=.*;F90=${FORTRANC};" \
		-e "s;^LD=.*;LD=${FORTRANC};" \
		 *.mak makefile
	sed -i \
		-e "s;^FFLAGS=.*;FFLAGS=${FFLAGS:--O2} -c;" \
		 *.mak
	sed -i \
		-e "s;^INSTALLDIR=.*;INSTALLDIR=${D}/usr/bin;" \
		-e 's;^install :;install :\n\tinstall -d $(INSTALLDIR);' \
		 makefile

	# These changes are just for 12.1 - should go away
	sed -i \
	    -e 's/\(.*jco2jco .*jco2jco.*\)/\1 openun.o/' \
	    -e 's/\(.*jcochek .*jcochek.o.*\)/\1 openun.o/' pestutl1.mak
	sed -i -e '/.*integer.*ies2ipar.*$/ d' cmaes_p.F sceua_p.F
}

src_compile() {
	emake cppp || die "cppp emake failed"
	for mfile in pest.mak ppest.mak pestutl1.mak pestutl2.mak pestutl3.mak pestutl4.mak pestutl5.mak pestutl6.mak sensan.mak mpest.mak
		do
			emake -f ${mfile} all || die "${mfile} emake failed"
			emake clean || die "emake clean failed"
		done
}

src_install() {
	emake install || die "emake install failed"

	if use doc ; then
		dodoc "${DISTDIR}"/pestman.pdf
		dodoc "${DISTDIR}"/addendum.pdf
	fi

}

src_test() {
	ebegin "Running d_test"
	make d_test || die "make d_test failed"
	eend $?
}