-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLaunchIBPReduction.wl
126 lines (79 loc) · 2.99 KB
/
LaunchIBPReduction.wl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
(* ::Package:: *)
commandLineMode=True
If[commandLineMode,
(*workingPath=$CommandLine[[-1]];(*we can specify working path in command line*)
If[workingPath==="-script",workingPath=Directory[]<>"/"];
If[!DirectoryQ[workingPath],
Print["Warning: the argument working path ",workingPath," does not exist."];
workingPath=Directory[]<>"/";
Print["\t\t redefining working path as current working folder: ",workingPath,"."];
];*)
packagePath=DirectoryName[$InputFileName];
AbsMissionInput=$CommandLine[[-1]];
workingPath=DirectoryName[AbsMissionInput];(*is this really used?*)
missionInput=FileNameSplit[AbsMissionInput][[-1]];
MathematicaCommand=Import[packagePath<>"/preload/MathematicaCommand.txt"];
ShellProcessor=Import[packagePath<>"/preload/ShellProcessor.txt"];
EnvVarSetter=Import[packagePath<>"/preload/EnvVarSetter.txt"];
,
Print["WARNING: program is not running in command line mode!"];
workingPath=NotebookDirectory[];
packagePath="/home/zihao/projects/SyzygyRed/Parallelization/github/NeatIBP/";
outputPath="";
]
(*AppendTo[$Path,workingPath];*)
If[Get[packagePath<>"default_settings.txt"]===$Failed,Exit[0]]
If[Get[workingPath<>missionInput]===$Failed,Print[
"echo \"Unable to open config file "<>workingPath<>missionInput<>". Exiting.\""
];
Exit[]
]
(*renaming the setting, because NeatIBP... actually, dose not perform "reduction" by default*)
If[ValueQ[ReductionOutputName],
If[ReductionOutputName=!=OutputName,
If[OutputName==="Untitled",
ReductionOutputName=ReductionOutputName;
(*use ReductionOutputName*)
,
ReductionOutputName=OutputName
]
]
,
ReductionOutputName=OutputName
]
If[CutIndices==="spanning cuts",
(*PrintAndLog[
"!!![Notice]: the config setting CutIndices=\"spanning cuts\" is an out-of-date gramma since v1.1.0.0.\n",
"It is still supported, but it is recommended to use the equivalent, new gramma: \n";
"\tCutIndices={};\n",
"\tSpanningCutsMode=True;"
];*)(*not print in this .wl*)
CutIndices={};
SpanningCutsMode=True;
]
If[outputPath===Automatic,
outputPath=workingPath<>"outputs/"<>ReductionOutputName<>"/";
]
If[Intersection[StringSplit[outputPath,""],{" ","\t","\n","?","@","#","$","*","&","(",")","\"","\'","|"}]=!={},
Print["echo \"Path "<>outputPath<>" is illegal. Exiting.\""];
Exit[0];
]
If[StringSplit[outputPath,""][[-1]]=!="/",outputPath=outputPath<>"/"]
If[!FileExistsQ[outputPath<>"results/summary.txt"],
Exit[0];(*summary failed*)
]
SetDirectory[workingPath]
TimeString[]:=Module[{at},at=FromAbsoluteTime[AbsoluteTime[]];StringRiffle[#,"_"]&[(ToString[Floor[#]]&/@at[[1,1;;6]])]<>"_"<>ToString[Floor[1000*(#-Floor[#])&[ at[[1,6]]]]]]
If[PerformIBPReduction=!=True,
finishedTagFile="results/NeatIBP_finished.tag";
script="";
script=script<>"sleep 1.5"<>"\n";
(*
so that when the HQ sees NeatIBP_finished.tag
the math kernel is really vacant
*)
script=script<>" >> "<>outputPath<>finishedTagFile<>"\n";
,
script=Import[outputPath<>"tmp/assigned_reduction_script.sh","Text"];
]
Print[script]