#!/bin/bash -l # # Simple script testing all available compiler modules on cray: # Check if C++ compiler is working. # # Chrsitoph Niethammer (C) 2011 # compilers="pgi gcc cray intel" compiler_version_cmd() { case $1 in cray|gcc|intel) cmd="CC --version" ;; pgi) cmd="CC -V" ;; *) echo "Unknown compiler $1" esac echo $cmd $cmd } compiler_check_stat_h() { cmd="CC stat_h.cpp" echo $cmd $cmd } compiler_check_stdexcept() { cmd="CC stdexcept.cpp" echo $cmd $cmd } compiler_check_helloworld() { cmd="cc hello.c" echo $cmd $cmd } swap_env() { currentPrgEnv=$(module li 2>&1 | awk '/PrgEnv/{print $2}') if [ "$1" == gcc ] ; then newPrgEnv="gnu" else newPrgEnv=$1 fi module swap $currentPrgEnv PrgEnv-$newPrgEnv } if [ ! -z $1 ] ; then compilers=$@ fi for compiler in $compilers; do for version in $(module av $compiler -l 2>&1 | awk "/^$compiler\//{print \$1}" | awk -F'/' '{print $2}'); do logfile="$compiler-$version.log" echo -en "testing $compiler/$version ... " error=0 swap_env $compiler 2>$logfile >$logfile || error=1 module swap $compiler $compiler/$version 2>>$logfile >>$logfile || error=1 compiler_version_cmd $compiler 2>>$logfile >>$logfile || error=1 compiler_check_helloworld $compiler 2>>$logfile >>$logfile || error=1 compiler_check_stdexcept $compiler 2>> $logfile >>$logfile || error=1 compiler_check_stat_H $compiler 2>> $logfile >>$logfile || error=1 if [ $error != 0 ] ; then echo "failed :-(" echo "Error msg:" echo "--------------------------------------------------" cat $logfile echo "--------------------------------------------------" echo "" else echo "success :-)" fi done done 2>&1 | tee compiler-test.log