#!/bin/bash -e # --------------------------------------------------------------------------- # # cmplr.env : Defines the compiler executable and its options for WW3 # # from the compiler keyword given in argument # # # # - supported compiler are SGI-MPT, INTEL, GNU, PORTLAND, CRAY # # # # # # use : cmplr.env cmplr # # # # cmplr : keyword based on a value and optional suffix, prefix and extras # # # # value : mpt / intel / gnu / pgi / cray # # suffix : _debug # # prefix : datarmor_ # # extras : so_ # # # # - examples : intel / pgi_debug / datarmor_mpt_debug / so_intel # # # # remarks : # # # # - template files comp.tmpl and link.tmpl will be used to create the # # comp and link file based on the following environment variables : # # $optc, $optl, $comp_seq, $comp_mpi, $optomp, $err_pattern, $warn_pattern # # # # # # M. Accensi # # August 2018 # # --------------------------------------------------------------------------- # ## Set some defaults (can be overriden by individual compiler sections) # grep pattern for errors/warnings in compiler output: err_pattern='[[:space:]]error[[:space:]]' warn_pattern='warn' # Binary I/O defaults to native endian: endian='native' # disable listing done by the compiler list='no' ############################### # MPT # ############################### if [ "$cmplr" == "mpt" ] || [ "$cmplr" == "mpt_debug" ] || [ "$cmplr" == "mpt_prof" ] || \ [ "$cmplr" == "datarmor_mpt" ] || [ "$cmplr" == "datarmor_mpt_debug" ] || [ "$cmplr" == "datarmor_mpt_prof" ] ; then # COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common compiler comp_seq='ifort' comp_mpi='ifort -lmpi' # Cray compiler if [ ! -z "$(echo $cmplr | grep wcoss_cray)" ] ; then comp_seq='ftn' comp_mpi='ftn' fi # OPTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common options optc='-c -module $path_m -no-fma -ip -g -i4 -real-size 32 -fp-model precise -assume byterecl -fno-alias -fno-fnalias' optl='-o $prog -g' endian='big_endian' # list options if [ "$list" == 'yes' ] ; then optc="$optc -list"; fi # omp options optomp="-openmp" # optimized options if [ -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O3" optl="$optl -O3" fi # profiling option if [ ! -z "$(echo $cmplr | grep prof)" ] ; then optc="$optc -p" optl="$optl -p" fi # debugging options if [ ! -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O0 -debug all -warn all -check all -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0" optl="$optl -O0 -traceback" fi # system-dependant options if [ ! -z "$(echo $cmplr | grep datarmor)" ] ; then optc="$optc -xcore-avx2" optl="$optl -xcore-avx2" else optc="$optc -xhost" optl="$optl -xhost" fi #Flags for CPP: cppad3procflag='-E' cppad3flag2=' ' cppad3flag3='-o' cppad3flag4='#' fi ############################### # INTEL # ############################### if [ "$cmplr" == "intel" ] || [ "$cmplr" == "intel_debug" ] || [ "$cmplr" == "intel_prof" ] || \ [ "$cmplr" == "so_intel" ] || [ "$cmplr" == "so_intel_debug" ] || [ "$cmplr" == "so_intel_prof" ] || \ [ "$cmplr" == "datarmor_intel" ] || [ "$cmplr" == "datarmor_intel_debug" ] || [ "$cmplr" == "datarmor_intel_prof" ] || \ [ "$cmplr" == "wcoss_cray" ] || [ "$cmplr" == "wcoss_dell_p3" ] || [ "$cmplr" == "cheyenne.intel" ] || \ [ "$cmplr" == "gaea.intel" ] || [ "$cmplr" == "jet.intel" ] || \ [ "$cmplr" == "wcoss2" ] || [ "$cmplr" == "s4.intel" ] || \ [ "$cmplr" == "expanse.intel" ] || \ [ "$cmplr" == "hera.intel" ] || [ "$cmplr" == "orion.intel" ] || [ "$cmplr" == "stampede.intel" ] || \ [ "$cmplr" == "ukmo_cray_intel" ] || [ "$cmplr" == "ukmo_cray_intel_debug" ]; then # COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # compiler comp_seq='ifort' comp_mpi='mpiifort' # cray compiler if [ ! -z "$(echo $cmplr | grep wcoss_cray)" ] || [ "$cmplr" == "gaea.intel" ] || [ "$cmplr" == "wcoss2" ] || [[ $cmplr == ukmo_cray* ]]; then comp_seq='ftn' comp_mpi='ftn' fi if [ ! -z "$(echo $cmplr | grep cheyenne)" ] ; then comp_seq='ifort' comp_mpi='mpif90' fi # OPTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common options optc='-c -module $path_m -no-fma -ip -g -traceback -i4 -real-size 32 -fp-model precise -assume byterecl -fno-alias -fno-fnalias -sox' optl='-o $prog -g' endian='big_endian' # list options if [ "$list" == 'yes' ] ; then optc="$optc -list"; fi # omp options if [ ! -z "$(echo $cmplr | grep datarmor)" ] || [ "$cmplr" == "hera.intel" ] || [ "$cmplr" == "orion.intel" ] || \ [ "$cmplr" == "wcoss_cray" ] || [ "$cmplr" == "wcoss_dell_p3" ] || [ "$cmplr" == "cheyenne.intel" ] || \ [ "$cmplr" == "gaea.intel" ] || [ "$cmplr" == "jet.intel" ] || [ "$cmplr" == "wcoss2" ] || \ [ "$cmplr" == "stampede.intel" ] || [ "$cmplr" == "s4.intel" ] || [ "$cmplr" == "expanse.intel" ] ; then optomp="-qopenmp" else optomp="-openmp" fi # optimized options if [ -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O3" optl="$optl -O3" fi # profiling option if [ ! -z "$(echo $cmplr | grep prof)" ] ; then optc="$optc -p" optl="$optl -p" fi # debugging options if [ ! -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O0 -debug all -warn all -check all -check noarg_temp_created -fp-stack-check -heap-arrays -traceback -fpe0" optl="$optl -O0 -traceback" fi # system-dependant options if [ ! -z "$(echo $cmplr | grep datarmor)" ] ; then optc="$optc -xcore-avx2" optl="$optl -xcore-avx2" elif [ ! -z "$(echo $cmplr | grep wcoss_cray)" ] ; then optc="$optc -xCORE-AVX2" optl="$optl -xCORE-AVX2" elif [ ! -z "$(echo $cmplr | grep wcoss2)" ] ; then optc="$optc" optl="$optl" elif [ ! -z "$(echo $cmplr | grep wcoss_dell_p3)" ] ; then optc="$optc -xHOST" optl="$optl -xHOST" elif [ ! -z "$(echo $cmplr | grep jet.intel)" ] ; then optc="$optc -axSSE4.2,AVX,CORE-AVX2,CORE-AVX512 -align array64byte -ip" optl="$optl -axSSE4.2,AVX,CORE-AVX2,CORE-AVX512 -align array64byte -ip" elif [[ $cmplr == ukmo_cray* ]]; then : # processor type set by ftn wrapper script. elif [ ! -z "$(echo $cmplr | grep s4)" ] ; then #Necessary to run on the Ivy partition optc="$optc -march=ivybridge" optl="$optl -march=ivybridge" else optc="$optc -xhost" optl="$optl -xhost" fi if [ ! -z "$(echo $cmplr | grep so)" ] ; then optc="$optc -fPIC" optl='-o $prog -g' fi #Flags for CPP: cppad3procflag='-E' cppad3flag2=' ' cppad3flag3='>' cppad3flag4='#' fi ############################### # GNU # ############################### if [ "$cmplr" == "gnu" ] || [ "$cmplr" == "gnu_debug" ] || [ "$cmplr" == "gnu_prof" ] || \ [ "$cmplr" == "so_gnu" ] || [ "$cmplr" == "so_gnu_debug" ] || [ "$cmplr" == "so_gnu_prof" ] || \ [ "$cmplr" == "hera.gnu" ] || [ "$cmplr" == "cheyenne.gnu" ] || \ [ "$cmplr" == "datarmor_gnu" ] || [ "$cmplr" == "datarmor_gnu_debug" ] || [ "$cmplr" == "datarmor_gnu_prof" ] || \ [ "$cmplr" == "ukmo_cray_gnu" ] || [ "$cmplr" == "ukmo_cray_gnu_debug" ] || [ "$cmplr" == "ukmo_cray_gnu_prof" ] ; then # COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Only match `error` and `warn` at beginning of line: err_pattern='^error' warn_pattern='^warn' # common compiler comp_seq='gfortran' comp_mpi='mpif90' # Cray compiler if [ ! -z "$(echo $cmplr | grep cray)" ] ; then comp_seq='ftn' comp_mpi='ftn' fi # OPTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common options optc='-c -J$path_m -g -fno-second-underscore -ffree-line-length-none' optl='-o $prog -g' endian='big_endian' # omp options optomp='-fopenmp' # optimized options if [ -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O3" optl="$optl -O3" fi # profiling option if [ ! -z "$(echo $cmplr | grep prof)" ] ; then optc="$optc -p" optl="$optl -p" fi # debugging options if [ ! -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O0 -Wall -fcheck=all -ffpe-trap=invalid,zero,overflow -frecursive -fbacktrace" optl="$optl -O0 -fbacktrace" fi # system-dependant options if [ ! -z "$(echo $cmplr | grep datarmor)" ] ; then optc="$optc -march=core-avx2" optl="$optl -march=core-avx2" elif [ ! -z "$(echo $cmplr | grep ukmo_cray)" ]; then # don't specify -march for Cray; processor specific tuning handled by ftn wrapper script optc="$optc -frecord-marker=4" else optc="$optc -march=native" optl="$optl -march=native" fi if [ ! -z "$(echo $cmplr | grep so)" ] ; then optc="$optc -fPIC" fi #Flags for CPP: cppad3procflag='-E' cppad3flag2=' ' cppad3flag3='-o' cppad3flag4='#' fi ############################### # PGI # ############################### if [ "$cmplr" == "pgi" ] || [ "$cmplr" == "pgi_debug" ] || [ "$cmplr" == "pgi_prof" ] || \ [ "$cmplr" == "datarmor_pgi" ] || [ "$cmplr" == "datarmor_pgi_debug" ] || [ "$cmplr" == "datarmor_pgi_debug" ] ; then # COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common compiler comp_seq='pgf90' comp_mpi='mpif90' # OPTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common options optc='-c -module $path_m -g -i4 -r4 -Kieee -byteswapio' optl='-o $prog -g' # list options if [ "$list" == 'yes' ] ; then optc="$optc -Mlist"; fi # omp options optomp="-mp" # optimized options if [ -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O3" optl="$optl -O3" fi # profiling option if [ ! -z "$(echo $cmplr | grep prof)" ] ; then optc="$optc -p" optl="$optl -p" fi # debugging options if [ ! -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O0 -Mbounds -Mchkfpstk -Mchkstk -Mdalign -Mdclchk -Mdepchk -Miomutex -Ktrap=fp -Mrecursive -traceback" optl="$optl -O0 -traceback" fi # system-dependant options if [ ! -z "$(echo $cmplr | grep datarmor)" ] ; then optc="$(echo $optc | sed 's/O3/O2/') -Mlist" optl="$optl" else optc="$optc" optl="$optl" fi #Flags for CPP: cppad3procflag='-E' cppad3flag2=' ' cppad3flag3='>' cppad3flag4='#' fi ############################### # Crayftn (CCE) ############################### if [ "$cmplr" == "ukmo_cray" ] || [ "$cmplr" == "ukmo_cray_debug" ] || \ [ "$cmplr" == "ukmo_cray_regtest" ]; then # COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common compiler comp_seq='ftn' comp_mpi='ftn' # cray compiler output needs more specific err/warn search patterns: err_pattern='crayftn: error' warn_pattern='crayftn: warn' # OPTIONS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # common options optc='-c -J$path_m -sdefault32 -eg' optl='-o $prog' # list options if [ "$list" == 'yes' ] ; then optc="$optc -hlist=a"; fi # omp options optomp="-h omp" # optimized options if [ -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O3" optl="$optl -O3" fi # debugging options if [ ! -z "$(echo $cmplr | grep debug)" ] ; then optc="$optc -O0 -g -Rbcps" optl="$optl -O0 -g" fi # regtest options: if [ ! -z "$(echo $cmplr | grep regtest)" ] ; then # -O1 best balance between compile time and runtime for regtests optc="$optc -O1" optl="$optl -O1" fi # system-dependant options # N/A #Flags for CPP: cppad3procflag='-eP' cppad3flag2=' ' cppad3flag3='#' cppad3flag4=' ' fi