1 | /****************************************************************************/ |
---|
2 | /* void read_script(const char *param_file_name, bool rd_lat) |
---|
3 | |
---|
4 | Purpose: |
---|
5 | read script written by the user. |
---|
6 | 1) User can specify lattice file name, vacuum chamber name, and bool flags such as tune |
---|
7 | tracking flag, tune shift with energy flag, etc. |
---|
8 | 2) In this function, Lattice is read, bool flags are set. |
---|
9 | |
---|
10 | Input: |
---|
11 | param_file_name user script name |
---|
12 | |
---|
13 | Output: |
---|
14 | none |
---|
15 | |
---|
16 | Return: |
---|
17 | global values and global bool flags |
---|
18 | |
---|
19 | Global variables: |
---|
20 | bool flags |
---|
21 | |
---|
22 | specific functions: |
---|
23 | Read_Lattice() |
---|
24 | |
---|
25 | Comments: |
---|
26 | Written by Jianfeng Zhang 03/2011 soleil |
---|
27 | |
---|
28 | ****************************************************************************/ |
---|
29 | |
---|
30 | /* files */ |
---|
31 | |
---|
32 | // girder file |
---|
33 | char girder_file[max_str]; |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | // multipole files; for soleil lattice |
---|
38 | char multipole_file[max_str]; |
---|
39 | // multipole file for soleil lattice |
---|
40 | char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str]; |
---|
41 | // files to set sources of coupling; for SOLEIL lattice |
---|
42 | char virtualskewquad_file[max_str]; |
---|
43 | |
---|
44 | //errors |
---|
45 | //char fe_file[max_str]; //the same as multipole_file[max_str]???? |
---|
46 | |
---|
47 | /* COD correction */ |
---|
48 | int nwh = 56, nwv = 56; //number of singular values for SVD correction |
---|
49 | |
---|
50 | /* ID compensation */ |
---|
51 | char IDCq_name[max_str][11]; |
---|
52 | |
---|
53 | |
---|
54 | //multipole field error correction (SOLEIL based) |
---|
55 | char hcorr_file[max_str], vcorr_file[max_str]; //files with the status of hcorr/vcorr status, |
---|
56 | //to choose which correctors are used for orbit correction |
---|
57 | //default name of special elements in lattice |
---|
58 | char hcorr_name[max_str] = "", vcorr_name[max_str] = ""; |
---|
59 | char skew_quad_name[max_str] = "", bpm_name[max_str] = ""; |
---|
60 | char gs_name[max_str] = "", ge_name[max_str] = ""; |
---|
61 | |
---|
62 | #define OLD_LATTICE |
---|
63 | |
---|
64 | /* Read script */ |
---|
65 | void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCommand UserCommandFlag[]) |
---|
66 | { |
---|
67 | |
---|
68 | |
---|
69 | char str[max_str]="voidstring", dummy[max_str]="voidstring", nextpara[max_str]="voidpara"; |
---|
70 | char in[max_str]; //temporary line with preceding white space |
---|
71 | char *line; //line to store the command without preceding white space |
---|
72 | char name[max_str]="voidname"; |
---|
73 | char lat_file[max_str]="voidlattice"; |
---|
74 | char EndName[]="void"; |
---|
75 | |
---|
76 | FILE *inf; |
---|
77 | const bool prt = false; // for debugging printout each line of input file |
---|
78 | long int LineNum=0L; |
---|
79 | long int NameLen=0L; |
---|
80 | int idummy=0; |
---|
81 | char full_param_file_name[max_str]; |
---|
82 | char lat_FileName[max_str]; |
---|
83 | //bool TuneTracFlag; |
---|
84 | char *pch; |
---|
85 | |
---|
86 | |
---|
87 | // Manipulation of the parameter file |
---|
88 | strcpy(dummy, param_file_name); |
---|
89 | pch = strstr (dummy,".prm"); // search for extension .prm |
---|
90 | /* remove additional .prm if exist */ |
---|
91 | if (pch != NULL) strncpy(pch,"\0",1); |
---|
92 | |
---|
93 | sprintf(full_param_file_name,"%s.prm",dummy); |
---|
94 | if (prt) printf("\n reading in script file: %s\n",full_param_file_name); |
---|
95 | |
---|
96 | // |
---|
97 | inf = file_read(full_param_file_name); |
---|
98 | |
---|
99 | |
---|
100 | // read parameter file, line by line |
---|
101 | // while (fgets(line, max_str, inf) != NULL) { |
---|
102 | while (line = fgets(in, max_str, inf)) { |
---|
103 | |
---|
104 | /* kill preceding whitespace generated by "table" key |
---|
105 | or "space" key, but leave \n |
---|
106 | so we're guaranteed to have something*/ |
---|
107 | while(*line == ' ' || *line == '\t') { |
---|
108 | line++; |
---|
109 | } |
---|
110 | |
---|
111 | if(prt) |
---|
112 | printf("cfg: %s",line); |
---|
113 | |
---|
114 | LineNum++; |
---|
115 | |
---|
116 | /* read the end of line symbol '\n','\r' or '\r\n' at different operation system*/ |
---|
117 | if (strstr(line, "#") == NULL && strcmp(line,"\n") != 0 && |
---|
118 | strcmp(line,"\r") != 0 && strcmp(line,"\r\n") != 0) { |
---|
119 | // get initial command token |
---|
120 | sscanf(line, "%s", name); |
---|
121 | //initialize the nextpara for each new command line |
---|
122 | strcpy(nextpara,"voidpara"); |
---|
123 | |
---|
124 | |
---|
125 | //find the sequence of the bool flag in user input script |
---|
126 | NameLen = strlen(name); |
---|
127 | EndName[0] = name[NameLen-4]; |
---|
128 | EndName[1] = name[NameLen-3]; |
---|
129 | EndName[2] = name[NameLen-2]; |
---|
130 | EndName[3] = name[NameLen-1]; |
---|
131 | |
---|
132 | //find the bool flag whose last 4 character are 'Flag' |
---|
133 | if(strcmp(EndName,"Flag")==0) |
---|
134 | CommNo++; |
---|
135 | |
---|
136 | |
---|
137 | /*read file names................. */ |
---|
138 | /* set file directory*/ |
---|
139 | if (strcmp("in_dir", name) == 0) |
---|
140 | sscanf(line, "%*s %s", in_dir); |
---|
141 | /* lattice file......*/ |
---|
142 | else if (strcmp("lat_file", name) == 0){ |
---|
143 | sscanf(line, "%*s %s", lat_file); |
---|
144 | sprintf(lat_FileName, "%s%s", in_dir, lat_file); |
---|
145 | if(rd_lat) { |
---|
146 | #ifdef OLD_LATTICE |
---|
147 | fprintf(stderr, "Reading lattice"); |
---|
148 | Read_Lattice(lat_FileName); |
---|
149 | #else |
---|
150 | /* fprintf(stderr, "Reading lattice with new parser\n"); |
---|
151 | sprintf(lat_FileName, "%s%s.lat", in_dir, lat_file); |
---|
152 | parse_lattice_flat(lat_FileName, "new.flat"); |
---|
153 | fprintf(stderr, "Parse the lattice into new.flat\n"); |
---|
154 | rdmfile("new.flat"); |
---|
155 | sprintf(lat_FileName, "%s%s", in_dir, lat_file); |
---|
156 | */ |
---|
157 | #endif |
---|
158 | } |
---|
159 | |
---|
160 | } |
---|
161 | |
---|
162 | /* other file names.....*/ |
---|
163 | else if (strcmp("multipole_file", name) == 0){ |
---|
164 | sscanf(line, "%*s %s", str); |
---|
165 | sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/ |
---|
166 | } //virtual skew quadrupole file; for soleil lattice |
---|
167 | else if (strcmp("virtualskewquad_file", name) == 0){ |
---|
168 | sscanf(line, "%*s %s", str); |
---|
169 | sprintf(virtualskewquad_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/ |
---|
170 | } |
---|
171 | |
---|
172 | /* read in bool flags */ |
---|
173 | else if (strcmp("QuadFringeOnFlag", name) == 0){ |
---|
174 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
175 | } |
---|
176 | else if (strcmp("QuadFringeOffFlag", name) == 0){ |
---|
177 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
178 | } |
---|
179 | else if (strcmp("RFvoltageFlag", name) == 0){ |
---|
180 | sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt)); |
---|
181 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
182 | } |
---|
183 | |
---|
184 | //read chamber file flat |
---|
185 | else if (strcmp("ReadChamberFlag", name) == 0){ |
---|
186 | sscanf(line, "%*s %s", str); |
---|
187 | sprintf(UserCommandFlag[CommNo].chamber_file,"%s%s", in_dir, str); |
---|
188 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
189 | } |
---|
190 | //read field error, GENERIC command |
---|
191 | else if (strcmp("ReadfefileFlag", name) == 0){ |
---|
192 | sscanf(line, "%*s %s", str); |
---|
193 | sprintf(UserCommandFlag[CommNo].fe_file,"%s%s", in_dir, str); |
---|
194 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
195 | } |
---|
196 | //read misalignment error, then do orbit correction |
---|
197 | else if (strcmp("ReadaefileFlag", name) == 0){ |
---|
198 | sscanf(line, "%*s %s", str); |
---|
199 | sprintf(UserCommandFlag[CommNo].ae_file,"%s%s", in_dir, str); |
---|
200 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
201 | } |
---|
202 | //read multipole errors; specific for SOLEIL lattice |
---|
203 | else if (strcmp("ReadMultipoleFlag", name) == 0){ |
---|
204 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
205 | }else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles |
---|
206 | sscanf(line, "%*s %s", str); |
---|
207 | sprintf(fic_hcorr,"%s%s", in_dir, str); |
---|
208 | }else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles |
---|
209 | sscanf(line, "%*s %s", str); |
---|
210 | sprintf(fic_vcorr,"%s%s", in_dir, str); |
---|
211 | }else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles |
---|
212 | sscanf(line, "%*s %s", str); |
---|
213 | sprintf(fic_skew,"%s%s", in_dir, str); |
---|
214 | } |
---|
215 | // for soleil lattice |
---|
216 | else if (strcmp("ReadVirtualSkewquadFlag", name) == 0){ |
---|
217 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
218 | } |
---|
219 | //print twiss parameters flag |
---|
220 | else if (strcmp("PrintTwissFlag", name) == 0){ |
---|
221 | sscanf(line, "%*s %s",nextpara); |
---|
222 | |
---|
223 | if(strcmp(nextpara,"voidpara")!=0) |
---|
224 | sscanf(line, "%*s %s", UserCommandFlag[CommNo]._PrintTwiss_twiss_file); |
---|
225 | |
---|
226 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
227 | } |
---|
228 | //print close orbit(COD) flag |
---|
229 | else if (strcmp("PrintCODFlag", name) == 0){ |
---|
230 | sscanf(line, "%*s %s",nextpara); |
---|
231 | |
---|
232 | if(strcmp(nextpara,"voidpara")!=0) |
---|
233 | sscanf(line, "%*s %s", UserCommandFlag[CommNo]._PrintCOD_cod_file); |
---|
234 | |
---|
235 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
236 | } |
---|
237 | //print the cooridinates using tracking at each element |
---|
238 | else if (strcmp("PrintTrackFlag", name) == 0){ |
---|
239 | sscanf(line, "%*s %s",nextpara); |
---|
240 | |
---|
241 | if(strcmp(nextpara,"voidpara")!=0) |
---|
242 | sscanf(line, "%*s %s %lf %lf %lf %lf %lf %lf %ld", |
---|
243 | UserCommandFlag[CommNo]._PrintTrack_track_file, |
---|
244 | &(UserCommandFlag[CommNo]._PrintTrack_x), |
---|
245 | &(UserCommandFlag[CommNo]._PrintTrack_px), |
---|
246 | &(UserCommandFlag[CommNo]._PrintTrack_y), |
---|
247 | &(UserCommandFlag[CommNo]._PrintTrack_py), |
---|
248 | &(UserCommandFlag[CommNo]._PrintTrack_delta), |
---|
249 | &(UserCommandFlag[CommNo]._PrintTrack_ctau), |
---|
250 | &(UserCommandFlag[CommNo]._PrintTrack_nmax)); |
---|
251 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
252 | } |
---|
253 | //print close orbit(COD) flag |
---|
254 | else if (strcmp("PrintGirderFlag", name) == 0){ |
---|
255 | sscanf(line, "%*s %s", girder_file); |
---|
256 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
257 | } |
---|
258 | |
---|
259 | |
---|
260 | else if (strcmp("TuneTracFlag", name) == 0){ |
---|
261 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
262 | } |
---|
263 | else if (strcmp("ChromTracFlag", name) == 0){ |
---|
264 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
265 | } |
---|
266 | // FMA |
---|
267 | else if (strcmp("FmapFlag", name) == 0){ |
---|
268 | strcpy(dummy, ""); |
---|
269 | |
---|
270 | sscanf(line, "%*s %s",nextpara); |
---|
271 | |
---|
272 | if(strcmp(nextpara,"voidpara")!=0) |
---|
273 | sscanf(line, "%*s %s %ld %ld %ld %lf %lf %lf %s", |
---|
274 | UserCommandFlag[CommNo]._FmapFlag_fmap_file, |
---|
275 | &(UserCommandFlag[CommNo]._FmapFlag_nxpoint), |
---|
276 | &(UserCommandFlag[CommNo]._FmapFlag_nypoint), |
---|
277 | &(UserCommandFlag[CommNo]._FmapFlag_nturn), |
---|
278 | &(UserCommandFlag[CommNo]._FmapFlag_xmax), |
---|
279 | &(UserCommandFlag[CommNo]._FmapFlag_ymax), |
---|
280 | &(UserCommandFlag[CommNo]._FmapFlag_delta), |
---|
281 | dummy); |
---|
282 | |
---|
283 | if(strcmp(dummy, "true") == 0) |
---|
284 | UserCommandFlag[CommNo]._FmapFlag_diffusion = true; |
---|
285 | else if(strcmp(dummy, "false") == 0) |
---|
286 | UserCommandFlag[CommNo]._FmapFlag_diffusion = false; |
---|
287 | |
---|
288 | // FmapFlag = true; |
---|
289 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
290 | } |
---|
291 | // FMA dp |
---|
292 | else if (strcmp("FmapdpFlag", name) == 0){ |
---|
293 | strcpy(dummy, ""); |
---|
294 | sscanf(line, "%*s %s",nextpara); |
---|
295 | |
---|
296 | if(strcmp(nextpara,"voidpara")!=0) |
---|
297 | sscanf(line, "%*s %s %ld %ld %ld %lf %lf %lf %s", |
---|
298 | UserCommandFlag[CommNo]._FmapdpFlag_fmapdp_file, |
---|
299 | &(UserCommandFlag[CommNo]._FmapdpFlag_nxpoint), |
---|
300 | &(UserCommandFlag[CommNo]._FmapdpFlag_nepoint), |
---|
301 | &(UserCommandFlag[CommNo]._FmapdpFlag_nturn), |
---|
302 | &(UserCommandFlag[CommNo]._FmapdpFlag_xmax), |
---|
303 | &(UserCommandFlag[CommNo]._FmapdpFlag_emax), |
---|
304 | &(UserCommandFlag[CommNo]._FmapdpFlag_z), |
---|
305 | dummy); |
---|
306 | |
---|
307 | if(strcmp(dummy, "true") == 0) |
---|
308 | UserCommandFlag[CommNo]._FmapdpFlag_diffusion = true; |
---|
309 | else if(strcmp(dummy, "false") == 0) |
---|
310 | UserCommandFlag[CommNo]._FmapdpFlag_diffusion = false; |
---|
311 | |
---|
312 | // FmapdpFlag = true; |
---|
313 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
314 | } |
---|
315 | else if (strcmp("AmplitudeTuneShiftFlag", name) == 0){ |
---|
316 | sscanf(line, "%*s %s",nextpara); |
---|
317 | |
---|
318 | if(strcmp(nextpara,"voidpara")!=0) |
---|
319 | sscanf(line, "%*s %s %s %ld %ld %ld %lf %lf %lf", |
---|
320 | UserCommandFlag[CommNo]._AmplitudeTuneShift_nudx_file, |
---|
321 | UserCommandFlag[CommNo]._AmplitudeTuneShift_nudz_file, |
---|
322 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nxpoint), |
---|
323 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nypoint), |
---|
324 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nturn), |
---|
325 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_xmax), |
---|
326 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_ymax), |
---|
327 | &(UserCommandFlag[CommNo]._AmplitudeTuneShift_delta)); |
---|
328 | |
---|
329 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
330 | } |
---|
331 | else if (strcmp("EnergyTuneShiftFlag", name) == 0){ |
---|
332 | sscanf(line, "%*s %s",nextpara); |
---|
333 | |
---|
334 | if(strcmp(nextpara,"voidpara")!=0) |
---|
335 | sscanf(line, "%*s %s %ld %ld %lf", |
---|
336 | UserCommandFlag[CommNo]._EnergyTuneShift_nudp_file, |
---|
337 | &(UserCommandFlag[CommNo]._EnergyTuneShift_npoint), |
---|
338 | &(UserCommandFlag[CommNo]._EnergyTuneShift_nturn), |
---|
339 | &(UserCommandFlag[CommNo]._EnergyTuneShift_deltamax)); |
---|
340 | |
---|
341 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
342 | |
---|
343 | } |
---|
344 | else if (strcmp("ErrorCouplingFlag", name) == 0){ |
---|
345 | sscanf(line, "%*s %ld %lf",&(UserCommandFlag[CommNo].err_seed),&(UserCommandFlag[CommNo].err_rms)); |
---|
346 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
347 | |
---|
348 | } |
---|
349 | else if (strcmp("ErrorCoupling2Flag", name) == 0){ |
---|
350 | sscanf(line, "%*s %ld %lf",&(UserCommandFlag[CommNo].err_seed),&(UserCommandFlag[CommNo].err_rms)); |
---|
351 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
352 | |
---|
353 | } |
---|
354 | else if (strcmp("CouplingFlag", name) == 0){ |
---|
355 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
356 | |
---|
357 | }//momentum compact factor |
---|
358 | else if (strcmp("MomentumAccFlag", name) == 0){ |
---|
359 | sscanf(line, "%*s %s",nextpara); |
---|
360 | |
---|
361 | if(strcmp(nextpara,"voidpara")!=0){ |
---|
362 | sscanf(line, "%*s %s %s %ld %ld %lf %lf %ld %lf %lf %ld %ld %lf", |
---|
363 | UserCommandFlag[CommNo]._MomentumAccFlag_momacc_file, |
---|
364 | UserCommandFlag[CommNo]._MomentumAccFlag_TrackDim, |
---|
365 | &(UserCommandFlag[CommNo]._MomentumAccFlag_istart), |
---|
366 | &(UserCommandFlag[CommNo]._MomentumAccFlag_istop), |
---|
367 | &(UserCommandFlag[CommNo]._MomentumAccFlag_deltaminp), |
---|
368 | &(UserCommandFlag[CommNo]._MomentumAccFlag_deltamaxp), |
---|
369 | &(UserCommandFlag[CommNo]._MomentumAccFlag_nstepp), |
---|
370 | &(UserCommandFlag[CommNo]._MomentumAccFlag_deltaminn), |
---|
371 | &(UserCommandFlag[CommNo]._MomentumAccFlag_deltamaxn), |
---|
372 | &(UserCommandFlag[CommNo]._MomentumAccFlag_nstepn), |
---|
373 | &(UserCommandFlag[CommNo]._MomentumAccFlag_nturn), |
---|
374 | &(UserCommandFlag[CommNo]._MomentumAccFlag_zmax)); |
---|
375 | } |
---|
376 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
377 | } |
---|
378 | |
---|
379 | // generic one, fit for 1 family of quadrupoles |
---|
380 | else if (strcmp("FitTuneFlag", name) == 0){ |
---|
381 | sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd, |
---|
382 | &(UserCommandFlag[CommNo].targetnux),&(UserCommandFlag[CommNo].targetnuz)); |
---|
383 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
384 | } |
---|
385 | // fit for 2 families,specific for the soleil lattice in which the quadrupole is cut into 2 parts |
---|
386 | else if (strcmp("FitTune4Flag", name) == 0){ |
---|
387 | sscanf(line, "%*s %s %s %s %s %lf %lf",UserCommandFlag[CommNo].qf1,UserCommandFlag[CommNo].qf2, |
---|
388 | UserCommandFlag[CommNo].qd1,UserCommandFlag[CommNo].qd2, |
---|
389 | &(UserCommandFlag[CommNo].targetnux),&(UserCommandFlag[CommNo].targetnuz)); |
---|
390 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
391 | } |
---|
392 | else if (strcmp("FitChromFlag", name) == 0){ |
---|
393 | sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].sxm1,UserCommandFlag[CommNo].sxm2, |
---|
394 | &(UserCommandFlag[CommNo].targetksix),&(UserCommandFlag[CommNo].targetksiz)); |
---|
395 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
396 | } |
---|
397 | // else if (strcmp("GirderErrorFlag", name) == 0){ |
---|
398 | // strcpy(UserCommand[CommandNo-1],name); |
---|
399 | // // GirderErrorFlag = true; |
---|
400 | // |
---|
401 | // } |
---|
402 | // else if (strcmp("SigmaFlag", name) == 0){ |
---|
403 | // strcpy(UserCommand[CommandNo-1],name); |
---|
404 | // // SigmaFlag = true; |
---|
405 | // |
---|
406 | // } |
---|
407 | // else if (strcmp("PX2Flag", name) == 0){ |
---|
408 | // strcpy(UserCommand[CommandNo-1],name); |
---|
409 | // // PX2Flag = true; |
---|
410 | // |
---|
411 | // } |
---|
412 | else if (strcmp("InducedAmplitudeFlag", name) == 0){ |
---|
413 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
414 | } |
---|
415 | // else if (strcmp("CodeComparaisonFlag", name) == 0){ |
---|
416 | // strcpy(UserCommand[CommandNo-1],name); |
---|
417 | // // CodeComparaisonFlag = true; |
---|
418 | // |
---|
419 | // } |
---|
420 | else if (strcmp("EtaFlag", name) == 0){ |
---|
421 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
422 | }//phase space |
---|
423 | else if (strcmp("PhaseSpaceFlag", name) == 0) { |
---|
424 | sscanf(line, "%*s %s",nextpara); |
---|
425 | //if the next para is not empty, then use the user set value, otherwise use default value |
---|
426 | if(strcmp(nextpara,"voidpara") != 0){ |
---|
427 | sscanf(line, "%*s %s %s %lf %lf %lf %lf %lf %lf %ld %s", |
---|
428 | UserCommandFlag[CommNo]._Phase_phase_file, |
---|
429 | UserCommandFlag[CommNo]._Phase_Dim, |
---|
430 | &(UserCommandFlag[CommNo]._Phase_X), |
---|
431 | &(UserCommandFlag[CommNo]._Phase_Px), |
---|
432 | &(UserCommandFlag[CommNo]._Phase_Y), |
---|
433 | &(UserCommandFlag[CommNo]._Phase_Py), |
---|
434 | &(UserCommandFlag[CommNo]._Phase_delta), |
---|
435 | &(UserCommandFlag[CommNo]._Phase_ctau), |
---|
436 | &(UserCommandFlag[CommNo]._Phase_nturn), |
---|
437 | str); |
---|
438 | } |
---|
439 | //radiation damping |
---|
440 | if (strcmp(str, "true") == 0) |
---|
441 | UserCommandFlag[CommNo]._Phase_Damping = true; |
---|
442 | else if (strcmp(str, "false") == 0) |
---|
443 | UserCommandFlag[CommNo]._Phase_Damping = false; |
---|
444 | |
---|
445 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
446 | } |
---|
447 | //calculate Touschek lifetime |
---|
448 | else if (strcmp("TouschekFlag", name) == 0){ |
---|
449 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
450 | |
---|
451 | }//intra beam scattering |
---|
452 | else if (strcmp("IBSFlag", name) == 0){ |
---|
453 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
454 | }//momentum acceptance is got by tracking, then cal touschek lifetime |
---|
455 | else if (strcmp("TousTrackFlag", name) == 0){ |
---|
456 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
457 | } |
---|
458 | //bpms and h/v correctors used for orbit correction |
---|
459 | else if (strcmp("bpm_name", name) == 0){ |
---|
460 | sscanf(line, "%*s %s", bpm_name); /* the name of bpm */ |
---|
461 | } |
---|
462 | else if (strcmp("h_corr", name) == 0){ |
---|
463 | sscanf(line, "%*s %s", hcorr_name); /* the name of H corrector used for COD correction*/ |
---|
464 | } |
---|
465 | else if (strcmp("v_corr", name) == 0){ |
---|
466 | sscanf(line, "%*s %s", vcorr_name); /* the name of V corrector used for COD correction*/ |
---|
467 | } |
---|
468 | else if (strcmp("qt", name) == 0){ |
---|
469 | sscanf(line, "%*s %s", skew_quad_name); /* name of skew quadrupoles */ |
---|
470 | } |
---|
471 | else if (strcmp("gs", name) == 0){ |
---|
472 | sscanf(line, "%*s %s", gs_name); /* name of start of the girder */ |
---|
473 | } |
---|
474 | else if (strcmp("ge", name) == 0){ |
---|
475 | sscanf(line, "%*s %s", ge_name); /* name of end of the girder */ |
---|
476 | } |
---|
477 | else if (strcmp("normalcut", name) == 0){ |
---|
478 | sscanf(line, "%*s %d", &idummy); |
---|
479 | fprintf(stdout,"User value for cutting at n sigma-s the normal distributions\n"); |
---|
480 | setrancut(idummy); /* set normal cut for computation: random data are n sigma-s*/ |
---|
481 | } |
---|
482 | //flag to do orbit correction |
---|
483 | else if (strcmp("CODCorrectFlag", name) == 0){ |
---|
484 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
485 | } |
---|
486 | //set parameters for COD correction |
---|
487 | else if (strcmp("n_orbit", name) == 0){ |
---|
488 | sscanf(line, "%*s %d", &n_orbit); |
---|
489 | } |
---|
490 | else if (strcmp("nwh", name) == 0){ |
---|
491 | sscanf(line, "%*s %d", &nwh); |
---|
492 | } |
---|
493 | else if (strcmp("nwv", name) == 0){ |
---|
494 | sscanf(line, "%*s %d", &nwv); |
---|
495 | } |
---|
496 | else if (strcmp("hcorr_file", name) == 0){ |
---|
497 | sscanf(line, "%*s %s", str); |
---|
498 | sprintf(hcorr_file,"%s%s", in_dir, str); /* add file directory*/ |
---|
499 | } |
---|
500 | else if (strcmp("vcorr_file", name) == 0){ |
---|
501 | sscanf(line, "%*s %s", str); |
---|
502 | sprintf(vcorr_file,"%s%s", in_dir, str); /* add file directory*/ |
---|
503 | } |
---|
504 | //ID correction |
---|
505 | else if (strcmp("IDCorrFlag", name) == 0) |
---|
506 | strcpy(UserCommandFlag[CommNo].CommandStr,name); |
---|
507 | else if (strcmp("scl_dbetax", name) == 0)//scaling of dbetax, for ID correction |
---|
508 | sscanf(line, "%*s %lf", &scl_dbetax); |
---|
509 | else if (strcmp("scl_dbetay", name) == 0)//scaling of dbetay, for ID correction |
---|
510 | sscanf(line, "%*s %lf", &scl_dbetay); |
---|
511 | else if (strcmp("scl_dnux", name) == 0)//scaling of dnux, for ID correction |
---|
512 | sscanf(line, "%*s %lf", &scl_dnux); |
---|
513 | else if (strcmp("scl_dnuy", name) == 0)//scaling of dnuy, for ID correction |
---|
514 | sscanf(line, "%*s %lf", &scl_dnuy); |
---|
515 | else if (strcmp("scl_nux", name) == 0) //scaling of nux, for ID correction |
---|
516 | sscanf(line, "%*s %lf", &scl_nux); |
---|
517 | else if (strcmp("scl_nuy", name) == 0) //scaling of nuy, for ID correction |
---|
518 | sscanf(line, "%*s %lf", &scl_nuy); |
---|
519 | else if (strcmp("ID_step", name) == 0)//ID steps, for ID correction |
---|
520 | sscanf(line, "%*s %lf", &ID_step); |
---|
521 | else if (strcmp("N_calls", name) == 0) // ID correction parameters |
---|
522 | sscanf(line, "%*s %d", &N_calls); |
---|
523 | else if (strcmp("N_steps", name) == 0) |
---|
524 | sscanf(line, "%*s %d", &N_steps); |
---|
525 | else if (strcmp("N_Fam", name) == 0) |
---|
526 | sscanf(line, "%*s %d", &N_Fam); |
---|
527 | else if (strcmp("IDCquads", name) == 0) { |
---|
528 | sscanf(line, "%*s %s %s %s %s %s %s %s %s %s %s %s", |
---|
529 | IDCq_name[0], IDCq_name[1], IDCq_name[2], IDCq_name[3], |
---|
530 | IDCq_name[4], IDCq_name[5], IDCq_name[6], IDCq_name[7], |
---|
531 | IDCq_name[8], IDCq_name[9], IDCq_name[10]); |
---|
532 | } |
---|
533 | else{ |
---|
534 | printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum); |
---|
535 | exit_(1); |
---|
536 | } |
---|
537 | } |
---|
538 | /* continue read in the line */ |
---|
539 | else |
---|
540 | continue; |
---|
541 | } |
---|
542 | fclose(inf); |
---|
543 | } |
---|
544 | |
---|