1 | #include "madx.h" |
---|
2 | |
---|
3 | void |
---|
4 | pro_survey(struct in_cmd* cmd) |
---|
5 | /* calls survey module */ |
---|
6 | { |
---|
7 | struct name_list* nl = current_survey->par_names; |
---|
8 | struct command_parameter_list* pl = current_survey->par; |
---|
9 | struct sequence* keep_current; |
---|
10 | char *filename = NULL, *table_name; |
---|
11 | int pos, w_file; |
---|
12 | int iarc = 1, keep; |
---|
13 | |
---|
14 | (void)cmd; |
---|
15 | if (current_sequ == NULL) |
---|
16 | { |
---|
17 | warning("SURVEY, but no active sequence:", "ignored"); |
---|
18 | return; |
---|
19 | } |
---|
20 | if (debuglevel > 1) fprintf(prt_file, "enter Survey module\n"); |
---|
21 | keep = get_option("rbarc"); |
---|
22 | set_option("rbarc", &iarc); |
---|
23 | pos = name_list_pos("file", nl); |
---|
24 | if (nl->inform[pos]) |
---|
25 | { |
---|
26 | if ((filename = pl->parameters[pos]->string) == NULL) |
---|
27 | { |
---|
28 | if (pl->parameters[pos]->call_def != NULL) |
---|
29 | filename = pl->parameters[pos]->call_def->string; |
---|
30 | } |
---|
31 | if (filename == NULL) filename = permbuff("dummy"); |
---|
32 | w_file = 1; |
---|
33 | } |
---|
34 | else w_file = 0; |
---|
35 | pos = name_list_pos("table", nl); |
---|
36 | if(nl->inform[pos]) /* table name specified - overrides save */ |
---|
37 | { |
---|
38 | if ((table_name = pl->parameters[pos]->string) == NULL) |
---|
39 | table_name = pl->parameters[pos]->call_def->string; |
---|
40 | } |
---|
41 | else table_name = permbuff("survey"); |
---|
42 | survey_table = make_table(table_name, "survey", survey_table_cols, |
---|
43 | survey_table_types, current_sequ->n_nodes); |
---|
44 | add_to_table_list(survey_table, table_register); |
---|
45 | keep_current = current_sequ; |
---|
46 | survey_(); |
---|
47 | current_sequ = keep_current; |
---|
48 | if (w_file) out_table(table_name, survey_table, filename); |
---|
49 | set_option("rbarc", &keep); |
---|
50 | } |
---|
51 | |
---|
52 | void |
---|
53 | pro_use_survey(void) |
---|
54 | { |
---|
55 | /* Constructs artificial survey command for USE,SURVEY. |
---|
56 | The survey data are stored at the nodes. */ |
---|
57 | struct in_cmd* pro_use = new_in_cmd(10); |
---|
58 | struct name_list* usenl; |
---|
59 | int usepos; |
---|
60 | pro_use->label = NULL; |
---|
61 | pro_use->type = 0; |
---|
62 | pro_use->clone = pro_use->cmd_def = clone_command(find_command("survey",defined_commands)); |
---|
63 | usenl = pro_use->cmd_def->par_names; |
---|
64 | usepos = name_list_pos("table", usenl); |
---|
65 | pro_use->cmd_def->par->parameters[usepos]->string = tmpbuff("survey"); |
---|
66 | pro_use->cmd_def->par_names->inform[usepos] = 1; |
---|
67 | usepos = name_list_pos("file", usenl); |
---|
68 | pro_use->cmd_def->par->parameters[usepos]->string = NULL; |
---|
69 | pro_use->cmd_def->par_names->inform[usepos] = 0; |
---|
70 | current_survey=(pro_use->clone); |
---|
71 | pro_survey(pro_use); |
---|
72 | exec_delete_table("survey"); |
---|
73 | } |
---|
74 | |
---|
75 | |
---|