forked from yzhphy/NeatIBP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignIBPReduction.wl
133 lines (96 loc) · 3.65 KB
/
AssignIBPReduction.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
127
128
129
130
131
132
133
(* ::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["Unable to open config file "<>workingPath<>missionInput<>". Exiting.";Exit[]]]
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<>"/"]
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,
Exit[];
]
Switch[IBPReductionMethod,
"None",
script="echo \"IBPReductionMethod=None, will not perform IBP reduction.\"\n";
,
"Kira",
KiraCommandRefined=StringRiffle[
DeleteCases[
StringSplit[KiraCommand," "]
,""]
," "];
If[!FileExistsQ[FermatPath],
Print["***File at ",FermatPath," does not exist. Exiting."];
Exit[];
];
If[FileNameSplit[FermatPath][[-1]]=!="fer64",
Print["***FermatPath ",FermatPath," should be specified to \"fer64\". Exiting."];
Exit[];
];
If[Count[
FileExistsQ/@Select[
StringSplit[KiraCommandRefined," "],
FileNameSplit[#][[-1]]==="kira"&
]
,True]<1,
Print["***KiraCommand \"",KiraCommand,"\" is not an correct kira command. Please check. Exiting."];
Exit[];
];(*kira command may include some settings*)
Switch[EnvVarSetter,
"export",
script="export FERMATPATH=\""<>FermatPath<>"\"";
(*script=script<>"\n"<>"export KiraCommand=\""<>KiraCommand<>"\"";*)
,
"setenv",
script="setenv FERMATPATH \""<>FermatPath<>"\"";
(*script=script<>"\n"<>"setenv KiraCommand \""<>KiraCommand<>"\"";*)
,
_,
Print[" ***EnvVarSetter \"",EnvVarSetter,"\" is not supported yet."];
Print["Valid values:"];
Print["\t1. export"];
Print["\t2. setenv"];
Print["Please check the spelling or contact the developers of NeatIBP."];
Print["Exiting."];
Exit[];
];
script=script<>"\n"<>ShellProcessor<>" "<>packagePath<>
"interfaces/Kira/interface/run_kira_reduction.sh \""<>KiraCommandRefined<>"\" "<>outputPath<>"\n";
,
"FFNumerical",
script=MathematicaCommand<>" "<>packagePath<>"FFSolveIBP.wl "<>outputPath<>"\n";
,
_,
(*this should have been excluded by initialization, but... better double checked*)
Print["***Err: Unkown IBPReductionMethod ",IBPReductionMethod];(*we'd better use PrintAndLog*)
Exit[];
]
Export[outputPath<>"tmp/assigned_reduction_script.sh",script,"Text"]