A similar approach to the one described for CFX in is also possible for STAR-CD as shown in the following snippet (Thanks to one of our users for the feedback!):
[shell]
#!/bin/bash -l
#PBS -l nodes=2:ppn=4
#PBS -l walltime=24:00:00
#PBS -N somename
# Change to the directory where qsub was made
cd $PBS_O_WORKDIR
### add the module of the STAR-CD version, e.g. 4.02
module add star-cd/4.02_64bit
# specify the time needed to write the result and info files, e.g. 900 seconds
export TIME4SAVE=900
#automatically detect how much time this job requested and
#adjust the sleep accordingly
( sleep ` qstat -f $PBS_JOBID | awk -v t=$TIME4SAVE \
‘{if ( $0 ~ /Resource_List.walltime/ ) \
{ split($3,duration,”:”); \
print duration[1]*3600+duration[2]*60+duration[3]-t }}’ `; \
star -abort ) >& /dev/null &
export SLEEP_ID=$!
# the normal STAR-CD start follows …
star -dp `cat $PBS_NODEFILE`
pkill -P $SLEEP_ID
[/shell]