Skip to content

Commit

Permalink
Changes for compilation and regtesting on UK Met Office Cray HPC:
Browse files Browse the repository at this point in the history
  * Added cray_xc to the cmplr.env and w3_setup scripts.
  * Added cray_xc.CCE (Cray Compiler Envrionment) specific comp and link scripts.
  * Explicitly disable OMP in cray comp scripts for non-OMP compilation (Cray compiler enables by default). Note that is still enabled in link script as OMP library is always required by SCRIP code.
  * Updated matrix_ukmo_cray to run everything on a shared node using mpiexec - compilation is not efficient on compute nodes.
  * Add -eg switch (allows use of GOTO jumps into DO loops for SEC1 switch
  * Addition of GNU compilers on Cray architecture.
  • Loading branch information
ukmo-ccbunney committed Sep 25, 2019
1 parent 5362e11 commit d85e386
Show file tree
Hide file tree
Showing 7 changed files with 1,053 additions and 2 deletions.
54 changes: 54 additions & 0 deletions model/bin/cmplr.env
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,61 @@ if [ "$cmplr" == "pgi" ] || [ "$cmplr" == "pgi_debug" ] || \
fi


###############################
# Cray XC #
###############################

if [ "$cmplr" == "cray_xc" ] || [ "$cmplr" == "cray_xc_debug" ]; then

# COMPILER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# common compiler
comp_seq='ftn'
comp_mpi='ftn'

# 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
if [ "$omp_mod" = 'yes' ] ; then
optc="$optc -h omp"
optl="$optl -h omp"
else
# by default, OMP is enabled on Cray ftn:
optc="$optc -h noomp"

# ... but don't disable at link stage as is currently needed by SCRIP
#optl="$optl -h noomp"
fi

# 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
fi



Expand Down
215 changes: 215 additions & 0 deletions model/bin/comp.cray_xc.CCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#!/bin/bash
# --------------------------------------------------------------------------- #
# comp : Compiler script for use in ad3 (customized for hardware and #
# optimization). Note that this script will not be replaced if part #
# of WAVEWATCH III is re-installed. Used by ad3. #
# #
# use : comp name #
# name: name of source code file without the extension. #
# #
# error codes : 1 : input error #
# 2 : no environment file $ww3_env found. #
# 3 : error in creating scratch directory. #
# 4 : w3adc error. #
# 5 : compiler error. #
# #
# remarks : #
# #
# - This script runs from the scratch directory, where it should remain. #
# #
# - For this script to interact with ad3, it needs to generate / leave #
# following files : #
# $name.f90 : Source code (generated by ad3). #
# $name.o : Object module. #
# $name.l : Listing file. #
# comp.stat.$name : status file of compiler, containing number of #
# erorrs and number of warnings (generated by comp). #
# #
# - Upon (first) installation of WAVEWATCH III the user needs to check the #
# following parts of this script : #
# sec. 2.b : Provide correct compiler/options. #
# sec. 3.a : Provide correct error capturing. #
# sec. 3.d : Remove unnecessary files. #
# #
# This version is for use with the Cray Compiler Environment (CCE) on the #
# Cray XC architecture (running Cray Linux Environment). #
# #
# Note that netCDF library paths may be automatically provided to the #
# compiler via the "module" environment. In this case, it might be #
# necessary to comment out the NETCDF_CONFIG section in 2.b.1 #
# #
# Chris Bunney #
# UK Met Office #
# Apr 2019 #
# #
# Hendrik L. Tolman #
# June 2012 #
# --------------------------------------------------------------------------- #
# 1. Preparations #
# --------------------------------------------------------------------------- #
# 1.a Check and process input

if [ "$#" != '1' ]
then
echo "usage: comp name" ; exit 1
fi
name="$1"

# 1.b Initial clean-up - - - - - - - - - - - - - - - - - - - - - - - - - - - -

rm -f $name.l
rm -f $name.o
rm -f comp.stat.$name

# 1.c Set listing option - - - - - - - - - - - - - - - - - - - - - - - - - - -

list=' -h list=a'

# --------------------------------------------------------------------------- #
# 2. Compile #
# --------------------------------------------------------------------------- #
# Add here the correct compiler call including command line options
# Note: - do not invoke a link step
# - if possible, generate a listing $name.l
# - make sure the compiler point to the proper directory where the
# modules are stored ($m_path), see examples below.

# 2.a Determine file extension - - - - - - - - - - - - - - - - - - - - - - - -
# .f90 assumes free format, .f assumes fixed format, change if necessary
# *** file extension (fext) is set and exported by calling program (ad3) ***
# *** (nothing to do here) ***

# 2.b Perform compilation - - - - - - - - - - - - - - - - - - - - - - - - - -
# Save compiler exit code in $OK
#
# Cray compiler on Cray Linux Environment -------------------------------------
# 2.b.1 Build options and determine compiler name
#
# Cray specific flags:
# -J : set path to read/write *.mod files
# -h list=a : create compiler .lst file (set above)
# -eg : Allow branching (GOTO) into DO loops (needed for /SEC1 switch)
# -O[0123] : General optimization level.
# -Rbcps : Runtime bounds, array conformance and pointer association checking.
opt="-c $list -J$path_m -eg"

# Cray compiler optimization settings (select one):
## DEBUG:
# opt="$opt -g -O0 -Rbcps"
## OPER:
#opt="$opt -O3"
## REGTESTS (01 best balance between compile time and runtime for regtests)
opt="$opt -O1"

## CHRISB: Leave the byte order as it is.
# if [ "$name" != 'gx_outp' ] && [ "$name" != 'gx_outf' ] && \
# [ "$name" != 'ww3_gspl' ]
# then
# opt="$opt -byteswapio"
# fi

# Same call to compiler wrapper used for both parallel and serial compilation:
if [ "$mpi_mod" = 'yes' ]
then
comp=ftn
else
comp=ftn
fi

if [ "$omp_mod" = 'yes' ]
then
opt="$opt -h omp"
else
opt="$opt -h noomp"
fi

# netcdf library dir
if [ "$netcdf_compile" = 'yes' ]
then
case $WWATCH3_NETCDF in
NC3) opt="$opt -I$NETCDF_INCDIR" ;;
NC4) if [ "$mpi_mod" = 'no' ]; then comp="`$NETCDF_CONFIG --fc`"; fi
opt="$opt -I`$NETCDF_CONFIG --includedir`" ;;
esac
fi

opt="$opt -I$path_i"
opt="$opt $ESMF_F90COMPILEPATHS"
opt="$opt $EXTRA_COMP_OPTIONS"

# 2.b.2 Compile
$comp $opt $name.$fext > $name.out 2> $name.err
OK="$?"

# 2.b.2 Process listing

if [ -s $name.lst ]
then
mv $name.lst $name.l
fi

# 2.b.3 Add test output to listing for later viewing

if [ -s $name.l ]
then
echo '------------' >> $name.l
echo "$comp $opt" >> $name.l
echo '------------' >> $name.l
cat $name.out >> $name.l 2> /dev/null
echo '------------' >> $name.l
cat $name.err >> $name.l 2> /dev/null
echo '------------' >> $name.l
fi

# --------------------------------------------------------------------------- #
# 3. Postprocessing #
# --------------------------------------------------------------------------- #
# 3.a Capture errors
# nr_err : number of errors.
# nr_war : number of errors.

nr_err='0'
nr_war='0'
if [ -s $name.err ]; then
nr_err=$(grep "crayftn: ERROR" $name.err | wc -l)
nr_war=$(grep "crayftn: WARN" $name.err | wc -l)
else
if [ "$OK" != '0' ]
then
nr_err='1'
fi
fi

# 3.b Make file comp.stat.$name - - - - - - - - - - - - - - - - - - - - - - - - - -

echo "ERROR $nr_err" > comp.stat.$name
echo "WARNING $nr_war" >> comp.stat.$name

# 3.c Prepare listing - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# if compiler does not provide listing, make listing from source code
# and compiler messages. Second input line for w3list identifies if
# comment lines are to be numbered.

if [ ! -f $name.l ]
then
echo "$name.$fext" > w3list.inp
echo "T" >> w3list.inp
w3list < w3list.inp 2> /dev/null
rm -f w3list.inp
mv w3list.out $name.l
echo '------------' >> $name.l
echo "$comp $opt" >> $name.l
echo '------------' >> $name.l
cat $name.out >> $name.l #2> /dev/null
echo '------------' >> $name.l
cat $name.err >> $name.l #2> /dev/null
echo '------------' >> $name.l
fi

# 3.d Remove unwanted files - - - - - - - - - - - - - - - - - - - - - - - - -
# include here unwanted files generated by the compiler

rm -f $name.out
rm -f $name.err

# end of comp --------------------------------------------------------------- #
Loading

0 comments on commit d85e386

Please sign in to comment.