# -*- python -*-
# Petsc installation file, KSL supercomputing team
from ksl.process.install.installer import *
from copy import copy
from string import Template

base = installer()
variants = []

base.name='petsc'
base.version='dev-aug30'
base.release='1'
base.license='BSD-like'
base.vendor='Argonne National Laboratories - MCS Division'
base.url='http://www.mcs.anl.gov/petsc/petsc-as/'
base.summary='Portable Extensible Toolkit for Scientific Computation'
base.packager='aron'
base.source='petsc-dev-16784.tar.gz'
base.category='math'
base.description=\
"""PETSc, pronounced PET-see (the S is silent), is a suite of data
structures and routines for the scalable (parallel) solution of
scientific applications modeled by partial differential equations.  It
employs the MPI standard for parallelism.    
"""

base.paths    = []
base.binaries = []
base.includes=['./include']
base.libdirs=['./lib'] 

# these libraries all appear to be independent
base.libs=['libpetsc.a']
base.compile_modules=[]
base.required_modules=['blas']
base.notes=\
"""
Build Notes:
* Fortran support
* uses ESSL (no multithreading support)
* optimization has been enabled
"""

o0 = unpack_overlay,'petsc_bgp_overlay.tar.gz'
s1 = (shell_command, 'export PETSC_DIR=`pwd` && export PETSC_ARCH=bgp-xlc-fast')
s2 = (templated_shell_command,
      Template('mv configure_shaheen.py bgp-xlc-fast.py && PLIBS="$$LDFLAGS $$LIBS" && ./bgp-xlc-fast.py --with-shared=0 --prefix=$target_dir --with-clanguage=c --COPTFLAGS="$$CFLAGS -O3 -qhot" --CXXOPTFLAGS="$$CXXFLAGS -O3 -qhot" --FOPTFLAGS="$$FFLAGS -O3 -qhot" --LIBS="$$PLIBS -O3" --CC="$$CC" --CXX="$$CXX" --FC="$$FC" --with-debugging=0'))
s3 = make
s4 = make_install  
s5 = (templated_shell_command,
      Template('cp -R * $target_dir'))
 
xlc_install = (o0, s1, s2, s3, s4, s5) 

base.tag = '-bgp_xlc_fast'

ppc450d = copy(base)
ppc450d.build_host = 'ppc64'
ppc450d.compile_modules = ['ibm']
ppc450d.target_arch = 'ppc450d'
ppc450d.install_steps = xlc_install
ppc450d.mod_magic = \
'''
setenv PETSC_DIR "$::env(KSL_PETSC_DIR)"
setenv PETSC_ARCH bgp-xlc-fast
'''
variants.append(ppc450d)


