1 |
#! /bin/csh -f |
2 |
|
3 |
echo $0 $* |
4 |
|
5 |
if ($?WORKFLOW_ROOT) then |
6 |
set WFDIR = $WORKFLOW_DATA |
7 |
set WFCODE = $WORKFLOW_ROOT |
8 |
else |
9 |
echo Need WORKFLOW_ROOT variable to be set. |
10 |
exit 1 |
11 |
endif |
12 |
|
13 |
# Call with at least task, target, and task as key=value pairs |
14 |
# e.g. maketasks.csh task=<taskname> target=<target> command=<command> |
15 |
# Any of the following keywords can be set on the calling line. |
16 |
|
17 |
# set defaults and collect args |
18 |
|
19 |
set task = "NOT_SPECIFIED" |
20 |
set parallelOK = 0 |
21 |
set maxrange = NaN # |
22 |
set target = "NOT_SPECIFIED" |
23 |
set retain = 1 |
24 |
set note = "" |
25 |
set state = 0 |
26 |
set command = "NOT_SPECIFIED" |
27 |
set manager = taskmanager.csh |
28 |
|
29 |
while ( $#argv > 0) |
30 |
foreach keyname (task parallelOK maxrange retain target note command manager ) |
31 |
if ($1 =~ $keyname=*) then |
32 |
set $1 |
33 |
break |
34 |
endif |
35 |
end # foreach |
36 |
shift |
37 |
end #while |
38 |
|
39 |
echo $task "$task" |
40 |
if ("$task" == "NOT_SPECIFIED") then |
41 |
echo task must be specified |
42 |
exit |
43 |
endif |
44 |
if ("$target" == "NOT_SPECIFIED") then |
45 |
echo product must be specified |
46 |
exit |
47 |
endif |
48 |
if ("$command" == "NOT_SPECIFIED") then |
49 |
echo command must be specified |
50 |
exit |
51 |
else if (!( -x $WFCODE/$command)) then |
52 |
echo STOP - in task $task the command $command must be executable. |
53 |
exit 1 |
54 |
endif |
55 |
if ("$maxrange" == "NaN") then |
56 |
echo maxrange must be specified |
57 |
exit |
58 |
endif |
59 |
if (!( -x $WFCODE/$manager)) then |
60 |
echo STOP - in task $task the taskmanager $manager must be executable. |
61 |
exit 1 |
62 |
endif |
63 |
|
64 |
set isdash = `echo $task | grep '-' | wc -l` |
65 |
if ($isdash) then |
66 |
echo STOP, the task name may not contain a dash, $task |
67 |
exit |
68 |
endif |
69 |
|
70 |
set isdash = `echo $target | grep '-' | wc -l` |
71 |
if ($isdash) then |
72 |
echo STOP, the target gate name may not contain a dash, $target |
73 |
exit |
74 |
endif |
75 |
|
76 |
set taskid = $task"-19930101-000" |
77 |
|
78 |
cd $WFDIR |
79 |
if (-e tasks/$task) then |
80 |
echo task $task already exists, remove then repeat command |
81 |
exit |
82 |
endif |
83 |
mkdir tasks/$task |
84 |
cd tasks/$task |
85 |
|
86 |
echo "$task" > task |
87 |
echo "$parallelOK" > parallelOK |
88 |
echo "$maxrange" > maxrange |
89 |
echo "$retain" > retain |
90 |
echo "$target" > target |
91 |
echo "$note" > note |
92 |
echo "$state" > state |
93 |
echo "$taskid" > taskid |
94 |
echo "$command" > command |
95 |
echo "$manager" > manager |
96 |
|
97 |
mkdir preconditions |
98 |
mkdir active |
99 |
mkdir done |
100 |
mkdir archive |
101 |
mkdir archive/ok |
102 |
mkdir archive/failed |
103 |
mkdir archive/logs |
104 |
mkdir logs |
105 |
|
106 |
# If and only if, completed OK task records are to be kept, uncomment the following |
107 |
# touch DEBUG |