playbooks/roles/ood-applications/files/bc_paraview/template/script.sh.erb (62 lines of code) (raw):

#!/usr/bin/env bash <%- require "yaml" node_arrays = YAML.load_file("/etc/ood/config/apps/bc_desktop/config/node_arrays.yml") slot_type = node_arrays.find { |slot_type| slot_type["name"] == context.target } gpu_count = slot_type["gpuCount"].to_i -%> # Clean the environment module purge # Set working directory to home directory cd "${HOME}" # Launch Xfce Window Manager and Panel source "<%= session.staged_root.join("xfce_kiosk.sh") %>" <%- if gpu_count > 0 -%> GL_LAUNCHER="vglrun" PARAVIEW_SERVER_IMPL="egl" PARAVIEW_EXTRA_ARGS= <%- else -%> GL_LAUNCHER= PARAVIEW_SERVER_IMPL="osmesa" PARAVIEW_EXTRA_ARGS="--mesa --backend swr" <%- end -%> set -x -e # Start ParaView PARAVIEW_HOME_DIR="<%= context.paraview_home %>" PARAVIEW_VERSION="<%= context.version %>" PARAVIEW_CLIENT="glx/bin/paraview" PARAVIEW_SERVER="$PARAVIEW_SERVER_IMPL/bin/pvserver" # Set the timeout for the ParaView server (in minutes) # -5 minutes to allow for client to connect and start rendering bc_num_hours=<%= context.bc_num_hours %> PARAVIEW_SERVER_TIMEOUT=$((bc_num_hours * 60 - 5)) source /etc/profile.d/modules.sh module use /usr/share/Modules/modulefiles module load mpi/mvapich2 if [[ -v PBS_NODEFILE ]]; then # PBS RANKS=`cat $PBS_NODEFILE | wc -l` HOSTFILE=$PBS_NODEFILE elif [[ -v SLURM_JOB_NODELIST ]]; then # SLURM if [[ -v SLURM_NTASKS ]]; then RANKS=$SLURM_NTASKS else RANKS=$SLURM_TASKS_PER_NODE fi HOSTFILE=$SLURM_JOB_NODELIST fi if [ $RANKS -gt 1 ]; then # Launch pvserver only if more than one MPI-rank is requested PARAVIEW_EXTRA_ARGS="$PARAVIEW_EXTRA_ARGS --url cs://$(hostname):11111" ( # avoids oversubscription errors export MV2_ENABLE_AFFINITY=0 $GL_LAUNCHER mpirun -np $RANKS \ $PARAVIEW_HOME_DIR/$PARAVIEW_VERSION/$PARAVIEW_SERVER \ --system-mpi \ --timeout $PARAVIEW_SERVER_TIMEOUT ) & fi # Launch ParaView client $GL_LAUNCHER $PARAVIEW_HOME_DIR/$PARAVIEW_VERSION/$PARAVIEW_CLIENT $PARAVIEW_EXTRA_ARGS