Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the old move command and also moves the openmp. #815

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/latexuguide/control.tex
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ \section{OPTION}
\texttt{NO\_FATAL\_STOP} & false & Prevents madx from stopping in case of a fatal error \\
& & \textbf{Use at your own risk !} \\
\hline
\texttt{KEEP\_EXP\_MOVE}& true & keeps the expression of the location after a move command \\
\hline
\texttt{RBARC} & true & converts the RBEND straight length into the arc length \\
\texttt{THIN\_FOC} & true & enables the $1/\rho^2$ focusing of thin dipoles \\
\texttt{BBORBIT} & false & the closed orbit is modified by beam-beam kicks \\
Expand Down
1 change: 1 addition & 0 deletions src/mad_dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ const char *const_command_def =
"twiss_print = [l, true, true], "
"warn = [l, true, true], "
"update_from_parent = [l, false, true], "
"keep_exp_move = [l, true, false], "
/* BB and SPCH related options */
"bborbit = [l, false, true], " /* frs */
"bb_ultra_relati = [l, false, true], " /* frs */
Expand Down
116 changes: 115 additions & 1 deletion src/mad_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,115 @@ seq_install(struct in_cmd* cmd)
}

static void
seq_move(struct in_cmd* cmd)
seq_move_noexpression(struct in_cmd* cmd)
/* executes move command */
{
char *name, *from_name;
double at, by, to, from = zero;
int any = 0, k;
struct node *node, *next;
struct element* el;
int pos;
name = command_par_string_user("element", cmd->clone);
if (name)
{
if (strcmp(name, "selected") == 0)
{
if (seqedit_select->curr == 0)
{
warning("no active select commands:", "ignored"); return;
}
else
{
if (!par_present("by", cmd->clone))
{
warning("no 'by' given,", "ignored"); return;
}
by = command_par_value("by", cmd->clone);
if (get_select_ranges(edit_sequ, seqedit_select, selected_ranges)
== 0) any = 1;
node = edit_sequ->start;
while (node != edit_sequ->end)
{
node = node->next; node->moved = 0;
}
node = edit_sequ->start;
while (node != NULL && node != edit_sequ->end)
{
next = node->next;
if (node->moved == 0)
{
if (any
|| name_list_pos(node->name, selected_ranges->list) > -1)
{
name = NULL;
for (k = 0; k < seqedit_select->curr; k++)
{
if (node->p_elem != NULL) name = node->p_elem->name;
if (name != NULL && strchr(name, '$') == NULL &&
pass_select_el(node->p_elem,
seqedit_select->commands[k])) break;
}
if (k < seqedit_select->curr)
{
at = node->position + by;
el = node->p_elem;
if (remove_one(node) > 0)
{
node = install_one(el, NULL, at, NULL, at);
node->moved = 1;
seqedit_move++;
}
}
}
}
node = next;
}
}
}
else
{
strcpy(c_dum->c, name);
square_to_colon(c_dum->c);
if ((pos = name_list_pos(c_dum->c, edit_sequ->nodes->list)) > -1)
{
node = edit_sequ->nodes->nodes[pos];
if (!par_present("by", cmd->clone))
{
if (!par_present("to", cmd->clone))
{
warning("no position given,", "ignored"); return;
}
to = command_par_value("to", cmd->clone);
from_name = command_par_string_user("from", cmd->clone);
if (from_name)
{
if ((from = hidden_node_pos(from_name, edit_sequ)) == INVALID)
{
warning("ignoring 'from' reference to unknown element:",
from_name);
return;
}
}
at = to + from;
}
else
{
by = command_par_value("by", cmd->clone);
at = node->position + by;
}
el = node->p_elem;
if (remove_one(node) > 0)
{
install_one(el, NULL, at, NULL, at);
seqedit_move++;
}
}
}
}
}
static void
seq_move_expression(struct in_cmd* cmd)
/* executes move command */
{
char *name, *from_name=NULL;
Expand Down Expand Up @@ -1233,6 +1341,12 @@ seq_move(struct in_cmd* cmd)
}
}

static void
seq_move(struct in_cmd* cmd){
int keep_exp = get_option("keep_exp_move");
if(keep_exp) seq_move_expression(cmd);
else seq_move_noexpression(cmd);
}

static void
seq_reflect(struct in_cmd* cmd)
Expand Down
3 changes: 2 additions & 1 deletion src/trrun.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3481,9 +3481,10 @@ subroutine tttrans(track,ktrack)
t_z = node_value('ds ')

!---- Loop over particles

call ttdrf(-t_z,track,ktrack)
!$OMP PARALLEL PRIVATE(i)
!$OMP DO
call ttdrf(-t_z,track,ktrack)
do i = 1, ktrack
! Add vector to particle coordinates
track(1,i) = track(1,i) - t_x
Expand Down