Skip to content

Commit

Permalink
Add the old move command and also moves the openmp.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias committed Sep 9, 2019
1 parent 0678074 commit 75f0f11
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 2,589 deletions.
1 change: 1 addition & 0 deletions src/mad_dict.c
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
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
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

0 comments on commit 75f0f11

Please sign in to comment.