From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QWjeC-0004oD-HB for garchives@archives.gentoo.org; Wed, 15 Jun 2011 06:32:16 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CC56D1C05A; Wed, 15 Jun 2011 06:32:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 838651C05A for ; Wed, 15 Jun 2011 06:32:07 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D6BDE1B4024 for ; Wed, 15 Jun 2011 06:32:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 1274C8003C for ; Wed, 15 Jun 2011 06:32:06 +0000 (UTC) From: "Justin Lecher" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Justin Lecher" Message-ID: <4c92ec7f9e4061c7f772039395d409ff517676b7.jlec@gentoo> Subject: [gentoo-commits] proj/sci:master commit in: eclass/ X-VCS-Repository: proj/sci X-VCS-Files: eclass/fortran-2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: jlec X-VCS-Committer-Name: Justin Lecher X-VCS-Revision: 4c92ec7f9e4061c7f772039395d409ff517676b7 Date: Wed, 15 Jun 2011 06:32:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 7667a398e7fc9f439138c3e97008b0e2 commit: 4c92ec7f9e4061c7f772039395d409ff517676b7 Author: Justin Lecher gentoo org> AuthorDate: Wed Jun 15 06:31:56 2011 +0000 Commit: Justin Lecher gentoo org> CommitDate: Wed Jun 15 06:31:56 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/sci.git;a=3Dc= ommit;h=3D4c92ec7f fortan-2.eclass in progress Signed-off-by: Justin Lecher gentoo.org> --- eclass/fortran-2.eclass | 114 +++++++++++++++++++++++++++++------------= ------ 1 files changed, 70 insertions(+), 44 deletions(-) diff --git a/eclass/fortran-2.eclass b/eclass/fortran-2.eclass index e5509be..5ebf8ca 100644 --- a/eclass/fortran-2.eclass +++ b/eclass/fortran-2.eclass @@ -13,12 +13,12 @@ # @DESCRIPTION: # If you need a fortran compiler, inherit this eclass. This eclass tests= for # working fortran compilers. Optional, it checks for openmp capability o= f the -# current fortran compiler through FC_NEED_OPENMP=3D1. +# current fortran compiler through FORTRAN_NEED_OPENMP=3D1. # Only phase function exported is pkg_setup. =20 -# @ECLASS-VARIABLE: FC_NEED_OPENMP +# @ECLASS-VARIABLE: FORTRAN_NEED_OPENMP # @DESCRIPTION: -# Set FC_NEED_OPENMP=3D1 in order to test FC for openmp capabilities +# Set FORTRAN_NEED_OPENMP=3D1 in order to test FC for openmp capabilitie= s # # Default is 0 =20 @@ -29,16 +29,45 @@ RDEPEND=3D"${DEPEND}" =20 # internal function # -# FUNCTION: _have-valid-fortran +# FUNCTION: _speaks_fortran_generic # DESCRIPTION: -# Check whether FC returns a working fortran compiler -_have-valid-fortran() { - local base=3D${T}/test-tc-fortran +# Takes fortran compiler as argument. +# Checks whether the passed fortran compiler is working +_speaks_fortran_generic() { + local base=3D${T}/test-fortran-generic + local fcomp=3D${1} + + [[ -z ${fcomp} ]] && die "_speaks_fortran_generic needs one argument" + cat <<- EOF > "${base}.f" end EOF - $(tc-getFC "$@") "${base}.f" -o "${base}" >&/dev/null + ${fcomp} "${base}.f" -o "${base}" >&/dev/null local ret=3D$? + + rm -f "${base}"* + return ${ret} +} + +# internal function +# +# FUNCTION: _speaks_fortran_2003 +# DESCRIPTION: +# Takes fortran compiler as argument. +# Checks whether the passed fortran compiler is working +_speaks_fortran_2003() { + local base=3D${T}/test-fortran-2003 + local fcomp=3D${1} + + [[ -z ${fcomp} ]] && die "_speaks_fortran_2003 needs one argument" + + cat <<- EOF > "${base}.f" + procedure(), pointer :: p + end + EOF + ${fcomp} "${base}.f" -o "${base}" >&/dev/null + local ret=3D$? + rm -f "${base}"* return ${ret} } @@ -50,26 +79,19 @@ _have-valid-fortran() { # See if the fortran supports OpenMP. _fortran-has-openmp() { local flag - case $(tc-getFC) in - *gfortran*|pathf*) - flag=3D-fopenmp ;; - ifort) - flag=3D-openmp ;; - mpi*) - local _fcomp=3D$($(tc-getFC) -show | awk '{print $1}') - FC=3D${_fcomp} _fortran-has-openmp - return $? ;; - *) - return 0 ;; - esac local base=3D${T}/test-fc-openmp - # leave extra leading space to make sure it works on fortran 77 as well + cat <<- EOF > "${base}.f" - call omp_get_num_threads - end + call omp_get_num_threads + end EOF - $(tc-getFC "$@") ${flag} "${base}.f" -o "${base}" >&/dev/null - local ret=3D$? + + for flag in -fopenmp -xopenmp -openmp -mp -omp -qsmp=3Domp; do + $(tc-getFC "$@") ${flag} "${base}.f" -o "${base}" >&/dev/null + local ret=3D$? + (( ${ret} )) || break + done + rm -f "${base}"* return ${ret} } @@ -85,6 +107,8 @@ get_fcomp() { case $(tc-getFC) in *gfortran* ) echo "gfortran" ;; + *g77* ) + echo "g77" ;; ifort ) echo "ifc" ;; pathf*) @@ -101,30 +125,32 @@ get_fcomp() { # @DESCRIPTION: # Setup functionallity, checks for a valid fortran compiler and optional= ly for its openmp support. fortran-2_pkg_pretend() { - _have-valid-fortran || \ + local dialect + + _speaks_fortran_generic $(tc-getFC) || \ + _speaks_fortran_generic $(tc-getF77) || \ die "Please emerge the current gcc with USE=3Dfortran or export FC def= ining a working fortran compiler" - export FC=3D$(tc-getFC) - export F77=3D$(tc-getFC) - export F90=3D$(tc-getFC) - export F95=3D$(tc-getFC) - if [[ ${FC_NEED_OPENMP} =3D=3D 1 ]]; then - _fortran-has-openmp || \ - die "Please emerge current gcc with USE=3Dopenmp or export FC with com= piler that supports OpenMP" - fi -} =20 + [[ -n ${FORTRAN_STANDARD} ]] || FORTRAN_STANDARD=3D"77" =20 -# @FUNCTION: fortran-2_pkg_setup -# @DESCRIPTION: -# Setup functionallity, checks for a valid fortran compiler and optional= ly for its openmp support, used in EAPI < 4. -fortran-2_pkg_setup() { - has ${EAPI:-0} 0 1 2 3 && fortran-2_pkg_pretend + for dialect in ${FORTRAN_STANDARD}; do + case ${dialect} in + 77|90|95) _speaks_fortran_generic $(tc-getFC) || \ + die "Your fortran compiler does not speak the Fortran ${dialect}" ;; + 2003) _speaks_fortran_${dialect} $(tc-getFC) || \ + die "Your fortran compiler does not speak the Fortran ${dialect}" ;; + 2008) die "Future";; + *) die "This dialect is not a fortran ";; + esac + done + + if [[ ${FORTRAN_NEED_OPENMP} =3D=3D 1 ]]; then + _fortran-has-openmp || \ + die "Please emerge current gcc with USE=3Dopenmp or export FC with co= mpiler that supports OpenMP" + fi } =20 case "${EAPI:-0}" in - 0|1|2|3) - EXPORT_FUNCTIONS pkg_setup;; - 4) - EXPORT_FUNCTIONS pkg_pretend;; + 4) EXPORT_FUNCTIONS pkg_pretend;; *) die "EAPI=3D${EAPI} is not supported" ;; esac