source: PSPA/madxPSPA/src/mad_gvar.c @ 447

Last change on this file since 447 was 430, checked in by touze, 11 years ago

import madx-5.01.00

File size: 15.5 KB
Line 
1#include "madx.h"
2
3/* Temporary file: global variables
4   these variables will be split over their respective modules...
5*/
6
7int  debuglevel = 1;
8
9/* Global structure variables by type (alphabetic) */
10
11struct char_array* aux_buff;       /* temporary buffer for many purposes */
12struct char_array* c_dum;
13struct char_array* c_join;
14struct char_array* work;
15struct char_array* l_wrk;
16
17struct char_array_list* char_buff; /* buffer for all sorts of strings */
18
19struct char_p_array* tmp_p_array;  /* temporary buffer for splits */
20struct char_p_array* tmp_l_array;  /* temporary buffer for special commands */
21struct char_p_array* line_buffer;  /* buffer for line expansion */
22
23struct command* current_beam = NULL;    /* current reference beam */
24struct command* probe_beam = NULL;      /* current beam */
25struct command* options = NULL;         /* current options */
26struct command* plot_options = NULL;    /* current plot options */
27struct command* current_error = NULL;   /* current error command */
28struct command* current_correct = NULL; /* current correct command */
29struct command* current_ibs = NULL;     /* current ibs command */
30struct command* current_touschek = NULL;/* current touschek command */
31struct command* current_survey = NULL;  /* current survey command */
32struct command* current_ptc = NULL;     /* current ptc command */
33struct command* current_twiss = NULL;   /* current twiss command */
34struct command* current_command = NULL; /* current command clone */
35struct command* current_gweight = NULL; /* current gweight clone */
36struct command* current_weight = NULL;  /* current weight clone */
37struct command* current_match = NULL;   /* current match comm. */
38struct command* current_eopt = NULL;    /* to keep eoption command */
39struct command* threader_par = NULL;    /* threader parameters */
40
41struct command_list* beam_list;         /* list of all beam commands */
42struct command_list* beta0_list;        /* list of user defined beta0s */
43struct command_list* defined_commands;  /* from dictionary */
44struct command_list* error_select;      /* current error select commands */
45struct command_list* optics_select;     /* current optics select commands */
46struct command_list* optics_list;       /* list of optics command/sequence */
47struct command_list* savebeta_list;
48struct command_list* seqedit_select;    /* current seqedit select commands */
49struct command_list* save_select;       /* current save select commands */
50struct command_list* slice_select;      /* current slice select commands */
51struct command_list* stored_commands;   /* list of stored commands */
52struct command_list* stored_match_var;  /* list of match vary commands */
53struct command_list* stored_track_start;/* list of track start commands */
54struct command_list* sector_select;     /* current sectormap select commands */
55
56struct command_list_list* table_deselect; /* list of table deselect lists */
57struct command_list_list* table_select;   /* list of all table select lists */
58
59struct constraint_list* comm_constraints; /* for each constraint command */
60struct double_array* cat_doubles;    /* Polish: constant values */
61struct double_array* doubles;        /* doubles buffer */
62struct double_array* twiss_deltas;   /* for deltap loop in twiss command */
63struct double_array* vary_vect;      /* for matching */
64struct double_array* vary_dvect;     /* for matching */
65struct double_array* fun_vect;       /* for matching */
66struct double_array* match_work[MATCH_WORK];/* work space for matching */
67
68struct el_list* drift_list;
69struct el_list* element_list;
70struct el_list* base_type_list;
71struct el_list* selected_elements;
72
73struct in_buff_list* in;      /* list of all active input buffers */
74struct in_buff_list* pro;     /* list of active processing buffers */
75
76struct int_array* deco;       /* Polish: coded expression */
77struct int_array* cat;        /* Polish: catgories */
78struct int_array* d_var;      /* Polish: variable references */
79struct int_array* oper;       /* Polish: operator references */
80struct int_array* func;       /* Polish: function references */
81struct int_array* s_range;    /* starts of ranges */
82struct int_array* e_range;    /* ends of ranges */
83struct int_array* sd_range;   /* starts of deselect ranges */
84struct int_array* ed_range;   /* ends of deselect ranges */
85struct int_array* match_i_work[MATCH_WORK];/* int work space for matching */
86
87struct in_cmd* this_cmd;      /* contains command just read */
88struct in_cmd* local_twiss[2] = {NULL, NULL};
89struct in_cmd* embedded_twiss_cmd = NULL;/* current plot command */
90
91struct in_cmd_list* buffered_cmds;
92
93struct macro_list* line_list;
94struct macro_list* macro_list;
95
96struct name_list* expr_chunks;
97struct name_list* occ_list;
98struct name_list* sxf_list;
99
100struct node* prev_node;
101struct node* current_node = NULL;
102struct node* debug_node = NULL;
103
104struct node_list* selected_ranges;/* filled by some select commands */
105struct node_list* sector_ranges;  /* filled by the sectormap select command */
106
107struct sequence* current_sequ;    /* pointer to currently used sequence */
108struct sequence* edit_sequ;       /* pointer to sequence being edited */
109
110struct sequence_list* sequences;  /* pointer to sequence list */
111struct sequence_list* match_sequs;/* pointer to sequence list for match */
112
113struct table* aperture_table;     /* current aperture table */
114struct table* ibs_table;          /* current ibs table */
115struct table* touschek_table;     /* current touschek table */
116struct table* summ_table;         /* current twiss summary table */
117struct table* twiss_table;        /* current twiss table */
118struct table* twiss_table_beam1;  /* current twiss table beam1 */
119struct table* twiss_table_beam2;  /* current twiss table beam2 */
120struct table* twiss_sector_table; /* used for sectormap */
121struct table* ptc_twiss_summary_table;/* holds summary data after one turn */
122struct table* map_table;          /* added for twiss_input_table */
123struct table_list* table_register;
124struct table_list* moments_tables = 0x0;/* tables for moments */
125
126struct table* embedded_twiss_table;/* current twiss table */
127struct table* normal_results;     /* ptc table containing the selected high order functions (such as dx,qx,anhx etc.) */
128
129struct table* errors_dipole;
130struct table* errors_field;
131struct table* errors_total;
132struct table* errors_read; /* table needed for IO of errors with PTC */
133
134struct table* survey_table;       /* current survey table */
135struct table* corr_table;         /* corrector table after orbit correction */
136struct table* corr_table1;        /* corrector table after orbit correction, beam 1 for two rings */
137struct table* corr_table2;        /* corrector table after orbit correction, beam 2 for two rings */
138struct table* mon_table;          /* monitor table after orbit correction */
139struct table* orbit_table;        /* orbit positions at monitors */
140struct table* sodd_table_70;      /* sodd output table detune_1_end */
141struct table* sodd_table_71;      /* sodd output table detune_1_all */
142struct table* sodd_table_72;      /* sodd output table detune_2_end */
143struct table* sodd_table_73;      /* sodd output table detune_2_all */
144struct table* sodd_table_74;      /* sodd output table distort_1_f_end */
145struct table* sodd_table_75;      /* sodd output table distort_1_h_end */
146struct table* sodd_table_76;      /* sodd output table distort_1_f_all */
147struct table* sodd_table_77;      /* sodd output table distort_1_h_all */
148struct table* sodd_table_78;      /* sodd output table distort_2_f_end */
149struct table* sodd_table_79;      /* sodd output table distort_2_h_end */
150struct table* target_table = NULL;/* current target table */
151struct table* model_table = NULL; /* current model table */
152struct table* orbin_table = NULL; /* current orbit table */
153
154
155struct table_list* optics_tables; /* contains optics tables from last twiss */
156struct table_list* table_register;/* contains all tables */
157
158struct table_list_list* all_table_lists; /* all table lists are entered here */
159
160struct variable* current_variable = NULL; /* set by act_value (table access) */
161struct var_list* variable_list;
162
163struct orb_cor*  correct_orbit;   /* information and links for orbit correction */
164struct orb_cor2* correct_orbit1;  /* information and links for orbit correction */
165struct orb_cor2* correct_orbit2;  /* information and links for orbit correction */
166struct orb_cor2* correct_orbit12; /* information and links for orbit correction */
167
168double corrl;                  /* global limit for orbit corrector strength  */
169
170struct table* efield_table;    /* field errors in table form  */
171FILE* fddata;
172FILE* fcdata;
173FILE* ftdata;
174FILE* fgdata;
175
176struct char_p_array* sdds_pat; /* array for selected sdds patterns */
177
178FILE* debug_file;              /* for debug output */
179FILE* stamp_file;              /* for debug output */
180FILE* out_file;                /* for table output */
181FILE* prt_file;                /* for echo output */
182FILE* sec_file = NULL;         /* for sector output in "embedded" twiss */
183FILE* tab_file;                /* for table input */
184
185/* Global simple variables by type */
186
187char  quote;                      /* current open single or double quote */
188char  int_format[20],             /* current integer format */
189      float_format[20],           /* current float format */
190      string_format[20];          /* current string format */
191char  var_form[1000];             /* buffer for the user-controlled formats */
192char  blank[] = "    ";
193char  none[] = "none";
194char  one_string[] = "1";
195char  aptwfile[FNAME_L] = "dummy";
196char* aux_char_pt;               /* for debug purposes */
197char* exx;
198char* current_link_group;
199char* current_range;             /* currently used range, or NULL */
200char* title = NULL;
201char* match_seqs[2];
202char* match_beta[2];
203char* match_range[2];
204char* track_filename;            /* track module file name start */
205char* track_fileext;             /* track module file name extension */
206char  track_plot_filename[NAME_L] = "madx_track"; /* plot module: output postscript file name in track mode */
207
208double pi, twopi, degrad, raddeg, e, clight, hbar;
209double penalty;
210double match_tol;
211double orbit0[6];
212double disp0[6];
213double sxf_suml = 0;
214double track_deltap=0;
215double oneturnmat[36];
216double fintx_plot;          /* to save the value of fintx for the reset_interpolation routine */
217
218const double zero = 0;
219const double one = 1;
220const double two = 2;
221const double ten_p_3 = 1.e3;
222const double ten_p_6 = 1.e6;
223const double ten_p_9 = 1.e9;
224const double ten_p_12 = 1.e12;
225const double ten_m_3 = 1.e-3;
226const double ten_m_6 = 1.e-6;
227const double ten_m_9 = 1.e-9;
228const double ten_m_12 = 1.e-12;
229const double ten_m_15 = 1.e-15;
230const double ten_m_16 = 1.e-16;
231const double ten_m_19 = 1.e-19;
232
233int add_error_opt = 0;      /* ADD error option, set with eoption */
234int embedded_flag = 0;      /* flag (= 1 when entering routine pro_embedded_twiss, 0 at exit) */
235int min_order = 1;          /* minimum required order */
236int print_correct_opt = 1;  /* PRINT options for orbit correction */
237int debug_correct_opt = 0;  /* DEBUG options for orbit correction */
238int assign_start = 0;       /* flag for multiple assign statements */
239int aux_count = 0;          /* for debug purposes */
240int beam_info = -1;         /* flag to print beam information once */
241int c_range_end;            /* node count of current range end */
242int c_range_start;          /* node count of current range start */
243int curr_obs_points;        /* current number of observation points */
244int current_calls = 0;      /* call counter in match */
245int current_call_lim = 0;   /* current call limit in match */
246int current_const = 0;      /* current constraint number in match */
247int default_beam_saved = 0; /* flag to avoid multiple save of default beam */
248int edit_is_on = 0;         /* != 0 if inside current sequence edit */
249int final_message = 0;      /* set to 1 when end message written */
250int group_is_on = 0;        /* true when inside group */
251int guess_flag = 0;         /* != 0 if coguess read */
252int in_stop = 0;            /* input buffer stop flag */
253int inbuf_level = 0;        /* input buffer level */
254int init_warn = 1;          /* intialisation warning level */
255int interactive;            /* non-zero if interactive */
256int irn_rand[NR_RAND];      /* for random generator */
257int keep_tw_print;          /* previous twiss print flag (match) */
258int loop_cnt = 0;           /* used to detect infinite loops */
259int match_calls = 0;        /* command call limit in match */
260int match_is_on = 0;        /* true when inside match command */
261int match_num_beta = 0;
262int match_num_range = 0;
263int match_num_seqs = 0;
264int mig_strategy;           /* migrad strategy (match) */
265int jac_strategy;           /* jacobian strategy (match) */
266int jac_repeat;             /* jacobian repeat (match) */
267double jac_cool;            /* jacobian cool factor (match) */
268double jac_balance;         /* jacobian balance cool factor (match) */
269double jac_random;          /* jacobian random factor (match) */
270int jac_bisec;              /* jacobian bisec factor (match) */
271double jac_cond;            /* jacobian svd cond. num (match) */
272int new_name_count = 0;     /* to make internal names */
273int next_rand = 0;          /* for random generator */
274int plots_made = 0;         /* set to 1 if plots are made */
275int polish_cnt = 0;         /* used to detect infinite loops */
276int print_match_summary = 0;/* activate the print option in the
277                               'mtgeti' and 'collect' routines (mtgeti->mtgetc) */
278int quote_toggle = 0;       /* for quote strings on input */
279int return_flag = 0;        /* 1 when "return" read */
280int scrap_count = 0;        /* running counter to make things unique */
281int seqedit_install = 0;    /* counter for seqedit installs */
282int seqedit_move = 0;       /* counter for seqedit moves */
283int seqedit_remove = 0;     /* counter for seqedit removes */
284int sequ_is_on = 0;         /* != 0 if inside current sequence decl. */
285int stamp_flag = 0;         /* checks for double delete when != 0 */
286int start_cnt = 0;          /* counter for start commands */
287int start_var = 0;          /* start of variables after predefined constants */
288int total_const = 0;        /* total no. of constraints in match */
289int total_vars = 0;         /* total no. of variables in match */
290int track_is_on = 0;        /* true when inside track command */
291int track_start_cnt = 0;    /* counter for track start commands */
292int twiss_success = 0;      /* set by twiss module to 1 if OK */
293int use_count = 0;          /* incremented by 1 every time use is executed */
294int vary_cnt = 0;           /* counter for vary commands */
295int watch_flag = 0;         /* produces debug output when != 0 */
296
297int na_err,                 /* current no. of alignment errors */
298    nf_err,                 /* current no. of field errors */
299    indent = 0,             /* current indentation count */
300    b_level = 0,            /* current brace level */
301    sxf_elem_cnt = 0,       /* element count */
302    tag_flag = 0,           /* if > 0, tag = parent name written */
303    tag_cnt = 0,            /* if > 0, tag = specified type code
304                               written for selected types only */
305    sxf_align_cnt = 0,      /* element with align errors count */
306    sxf_field_cnt = 0,      /* element with field errors count */
307    stop_flag = 0,          /* 1 if stop condition */
308    occnt_add = 0,          /* flag for element name modification */
309    b_indent[100],          /* list of indents */
310    add_indent[] = {1, 2, 2, 4, 7, 7, 7, 7, 7, 7};
311
312double
313    guess_orbit[6],
314    al_errors[ALIGN_MAX],
315    fd_errors[FIELD_MAX];
316
317char
318    line[MADX_LINE_MAX],
319    tag_type[MAX_TAG][16],
320    tag_code[MAX_TAG][16];
321
322time_t last_time;
323time_t start_time;
324
325char filenames[100][500];
326int  currentline[100];
327
328double** trackstrarpositions = 0x0; /* two dimensional array with track positions*/
329
Note: See TracBrowser for help on using the repository browser.