Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic tbg help #226

Merged
merged 5 commits into from
Feb 24, 2014
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions src/tools/bin/tbg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright 2013 Axel Huebl, Rene Widera, Richard Pausch
# Copyright 2013-2014 Axel Huebl, Rene Widera, Richard Pausch
#
# This file is part of PIConGPU.
#
Expand Down Expand Up @@ -30,11 +30,11 @@


#######################
# $1 name of variable with template descriptions
# $1 name of variable with template descriptions
########################
function tooltpl_replace
{

eval tooltpl_replace_data="\$$1"
eval tooltpl_replace_input="\$$2"

Expand Down Expand Up @@ -77,12 +77,12 @@ function run_cfg_and_get_solved_variables
do
eval "$i"
done
#filter all TBG variables

#filter all TBG variables
tooltbl_env=`set | grep "^[[:alpha:]][[:alnum:]_]*=.*" | grep -v tooltpl `

data="$tooltbl_env"

unresolved_vars=`echo -e "$data" | grep "\![[:alpha:]][[:alnum:]_]*" | wc -l`
unresolved_vars_old=$(( unresolved_vars + 1))

Expand Down Expand Up @@ -121,7 +121,7 @@ function check_final
not_replaced_cnt=`echo $not_replaced | wc -w`

if [ $not_replaced_cnt -gt 0 ] ; then
echo "WARNING: $not_replaced_cnt variable(s) _not_ replaced from template (tpl):"
echo "ERROR: $not_replaced_cnt variable(s) _not_ replaced from template (tpl):"
echo $not_replaced

#create an OR concated pattern
Expand All @@ -134,6 +134,9 @@ function check_final
n=$(( n+1 ))
echo $org_line | awk -v line=$n '{ if ($0 ~ /'$nrv_or'/) print "line "line }'
done < <(echo -e "$org_file")

# abort script (will no be submitted)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo? will not be submitted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, will fix

exit 1
fi
}

Expand All @@ -146,20 +149,21 @@ function get_tooltpl_value
cat /dev/stdin | grep $1 | cut -d"=" -f2- | tooltpl_replace $2
}

function absulte_path()
function absolute_path()
{
cd $1
pwd
}

help()
{
echo "tbg (template batch generator) create new folder for a batch job"
echo "and copy in all importend files"
echo "TBG (template batch generator)"
echo "create a new folder for a batch job and copy in all important files"
echo ""
echo "usage: tbg -c cfgFile [-s submitsystem] [-t templateFile] [-p project] [-o \"VARNAME1=10 VARNAME2=5\"] [-h] destinationPath"
echo ""
echo "-c | --cfg file - Configuration file to set up batch file."
echo "-s | --submit command - Submit command (qsub, \"qsub -h\", sbatch, ...)"
echo "-t | --tpl file - Template to create a batch file from."
echo " tbg will use stdin, if no file is specified."
echo "-p | --project folder - Project folder containing sourcecode and binaries"
Expand All @@ -171,14 +175,13 @@ help()
echo "destinationPath - Directory for simulation output. "
echo " "
echo " "
echo "tbg exports the following variables, which can used in cfg and tpl files any time:"
echo "TBG exports the following variables, which can be used in cfg and tpl files at any time:"
echo " TBG_jobName - name of the job"
echo " TBG_jobNameShort - short name of the job, without blanks"
echo " TBG_cfgPath - absolut path to cfg file"
echo " TBG_cfgFile - full absolut path and name of cfg file"
echo " TBG_projectPath - absolut project path (see option --project)"
echo " TBG_dstPath - absolute path to destination directory"

}

#!/bin/bash
Expand Down Expand Up @@ -245,7 +248,7 @@ if [ ! -f $cfg_file ] ; then
exit 1;
fi

projectPath=`absulte_path $projectPath`
projectPath=`absolute_path $projectPath`

job_name=`basename "$outDir"`
# (up to 15 characters, no blank spaces, reduce to alphanumeric characters)
Expand Down Expand Up @@ -278,7 +281,7 @@ export TBG_jobName="$job_name"
export TBG_jobNameShort="$job_shortname"
cfgFileName=`basename $cfg_file`
cfgRelativPath=`dirname $cfg_file`
export TBG_cfgPath=`absulte_path "$cfgRelativPath"`
export TBG_cfgPath=`absolute_path "$cfgRelativPath"`
export TBG_cfgFile="$TBG_cfgPath/$cfgFileName"

export TBG_projectPath="$projectPath"
Expand Down Expand Up @@ -310,4 +313,6 @@ check_final tbg/submit.start "$tooltpl_file_data"

if [ -n "$submit_command" ] ; then
$submit_command tbg/submit.start
else
echo "nothing to submit (-s option set?)"
fi