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

Tao version update. #1382

Merged
merged 3 commits into from
Feb 10, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions sim_utils/io/output_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,15 @@ module output_mod
! file_unit -- integer, optional: Unit number for writing to a file.
! -1 => No writing (initial default setting).
! print_and_capture -- logical, optional: If present then this sets whether output is printed to the terminal and/or
! captured for program use. See the out_io_print_and_caputure_setup routine documentation for more details.
! captured for program use. Note: How output capture works is also set by the out_io_print_and_caputure_setup routine.
! See the out_io_print_and_caputure_setup routine documentation for more details.
! min_level -- integer, optional: Minimum message status level to apply to.
! Default is s_blank$
! max_level -- integer, optional: Maximum message status level to apply to.
! Default is s_important$
! set -- out_io_output_direct_struct, optional: If present, use this structure to set where output goes.
! This structure can be used in place of specifying file_unit, etc. One way to use "set" is to first
! call this routine with the "get" argument to get the output direction state.
!
!
! Output:
! get -- out_io_output_direct_struct, optional: If present, capture the output direction state before any setting
Expand All @@ -170,7 +170,6 @@ subroutine output_direct (file_unit, print_and_capture, min_level, max_level, se
!

if (present(get)) get = out_io_direct

if (present(set)) out_io_direct = set

do i = integer_option(s_blank$, min_level), integer_option(s_important$, max_level)
Expand Down Expand Up @@ -731,7 +730,7 @@ end subroutine header_io
! The procedure for how a message is handled is as follows:
! First: When out_io is called, the message level is used to determine if anything is to be printed or captured at all.
! When a program is started, everything will pass this test for printing and/or capturing.
! This behavior can be modified by by calls to the output_direct routine.
! This behavior can be modified by calls to the output_direct routine.
! Second: If a message is to be printed and/or captured (passes the first step), then the internal print_on flag is used
! to determine if printing to the terminal and the internal capture_state flag is used to determine if capture is
! to be done. The initial setting of these flags is print_on = True and capture_state = 'OFF'.
Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_abort_command_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ subroutine tao_abort_command_file()
enddo

s%com%saved_cmd_line = ''
call tao_quiet_set('cmd-file-end')

end subroutine
1 change: 1 addition & 0 deletions tao/code/tao_call_cmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ subroutine tao_call_cmd (file_name, cmd_arg)

s%com%cmd_file(nl)%ix_unit = iu
s%com%cmd_file(nl)%full_name = full_name
s%com%cmd_file(nl)%quiet = s%com%cmd_file(nl0)%quiet

! Save command arguments.

Expand Down
1 change: 1 addition & 0 deletions tao/code/tao_close_command_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ subroutine tao_close_command_file()
endif

s%com%cmd_file_level = n - 1
call tao_quiet_set('cmd-file-end')

end subroutine
6 changes: 1 addition & 5 deletions tao/code/tao_get_user_input_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,11 @@ subroutine tao_get_user_input (cmd_out, prompt_str, wait_flag, cmd_in)
! If a command file is open then read a line from the file.

n_level = s%com%cmd_file_level
if (n_level == 0) call tao_quiet_set ('cmd-file-end') ! verbose if not running from a command file

if (n_level /= 0 .and. .not. s%com%cmd_file(n_level)%paused) then

if (s%global%single_step) then
call read_a_line ('Single_step: Press <return> to continue...', name, &
prompt_color = s%global%prompt_color, prompt_bold = boldit)

endif

call output_direct (print_and_capture = (s%global%quiet /= 'all'), min_level = s_blank$, max_level = s_dwarn$)
Expand All @@ -151,7 +148,7 @@ subroutine tao_get_user_input (cmd_out, prompt_str, wait_flag, cmd_in)
do
read (s%com%cmd_file(n_level)%ix_unit, '(a)', end = 8000, iostat = ios) cmd_out(ix+1:)
if (ios /= 0) then
call tao_quiet_set('cmd-file-end')
call tao_quiet_set('off')
call out_io (s_error$, r_name, 'CANNOT READ LINE FROM FILE: ' // s%com%cmd_file(n_level)%full_name)
goto 8000
endif
Expand Down Expand Up @@ -285,7 +282,6 @@ subroutine tao_get_user_input (cmd_out, prompt_str, wait_flag, cmd_in)
endif
endif

call tao_quiet_set('cmd-file-end')
return

!-------------------------------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion tao/code/tao_parse_command_args.f90
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,15 @@ subroutine tao_parse_command_args (error, cmd_line)
endif

case ('-quiet', '-silent_run') ! "-silent_run" is old syntax
s%init%quiet_arg = 'all'
if (i_arg < n_arg) then
call get_next_arg (arg0, s%init%quiet_arg, i_arg, n_arg)
if (s%init%quiet_arg(1:1) == '-') then
s%init%quiet_arg = 'all'
i_arg = i_arg - 1
endif
else
s%init%quiet_arg = 'all'
endif

case ('-reverse')
s%init%reverse_arg = present_str
Expand Down
13 changes: 9 additions & 4 deletions tao/code/tao_pipe_cmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ subroutine tao_pipe_cmd (input_str)
'wall3d_radius', 'wave'], ix, matched_name = command)

if (ix == 0) then
call out_io (s_error$, r_name, 'pipe what? "What" not recognized: ' // command)
call out_io (s_error$, r_name, 'pipe what? ' // quote(cmd) // ' is not recognized.')
return
endif

if (ix < 0) then
call out_io (s_error$, r_name, 'pipe what? Ambiguous command: ' // command)
call out_io (s_error$, r_name, 'pipe what? ' // quote(cmd) // ' is an ambiguous command.')
return
endif

Expand Down Expand Up @@ -4884,9 +4884,9 @@ subroutine tao_pipe_cmd (input_str)
! ele.e_tot, ele.p0c
! ele.mat6 ! Output: mat6(1,:), mat6(2,:), ... mat6(6,:)
! ele.vec0 ! Output: vec0(1), ... vec0(6)
! ele.{attribute} Where {attribute} is a Bmad syntax element attribute. (EG: ele.beta_a, ele.k1, etc.)
! ele.c_mat ! Output: c_mat11, c_mat12, c_mat21, c_mat22.
! ele.gamma_c ! Parameter associated with coupling c-matrix.
! ele.XXX ! Where XXX is a Bmad syntax element attribute. (EG: ele.beta_a, ele.k1, etc.)
!
! {elements} is a string to match element names to.
! Use "*" to match to all elements.
Expand Down Expand Up @@ -8063,12 +8063,15 @@ subroutine tao_pipe_cmd (input_str)

subroutine end_stuff(li, nl)


type (out_io_output_direct_struct) out_dir_state
character(n_char_show), allocatable :: li(:)
integer nl, i

!

call output_direct (get = out_dir_state)
call output_direct(print_and_capture = .true.)

if (doprint) then
call out_io (s_blank$, r_name, li(1:nl))
endif
Expand All @@ -8080,6 +8083,8 @@ subroutine end_stuff(li, nl)
close (iu_write)
endif

call output_direct (get = out_dir_state)

end subroutine

!----------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion tao/code/tao_print_command_line_info.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ subroutine tao_print_command_line_info
' -prompt_color <color> # Set color of prompt string. Default is blue. ', &
' -reverse # Reverse lattice element order? ', &
' -rf_on # Use "--rf_on" to turn off RF (default is now RF on) ', &
' -quiet # Suppress terminal output when running a command file? ', &
' -quiet <level> # Suppress terminal output when running a command file? ', &
' # Levels: "all" (default), "warnings". ', &
' -slice_lattice <ele_list> # Discards elements from lattice that are not in the list', &
' -start_branch_at <ele_name> # Start lattice branch at element. ', &
' -startup_file <file_name> # Commands to run after parsing Tao init file ', &
Expand Down
24 changes: 10 additions & 14 deletions tao/code/tao_quiet_set.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
!+
! Subroutine tao_quiet_set (set)
!
! Routine to set on/off silent command file running.
! Routine to set silent running.
! Note: s_important$, s_error$ and s_fatal$ levels are never supressed.
!
! Input:
! set -- logical: True is silent running is wanted.
Expand All @@ -12,26 +13,20 @@ subroutine tao_quiet_set (set)
use tao_struct
implicit none

type (out_io_output_direct_struct), save :: out_dir_save
integer ix
integer ix, n_level
character(*) set
character(12) name
character(*), parameter :: r_name = 'tao_quiet_set'

!

n_level = s%com%cmd_file_level

if (set == '') then
name = 'all'

elseif (set == 'cmd-file-end') then
if (s%global%quiet == 'All') then
name = 'off'
else
name = s%global%quiet
endif

elseif (set == 'ALL') then
name = set
name = s%com%cmd_file(n_level)%quiet

else
call match_word (set, [character(12):: 'off', 'all', 'warnings'], ix, .false., .true., name)
Expand All @@ -43,15 +38,16 @@ subroutine tao_quiet_set (set)

!

if (s%global%quiet == 'off') call output_direct(get = out_dir_save)
s%com%cmd_file(n_level)%quiet = name
s%global%quiet = name

select case (name)
case ('off')
call output_direct (set = out_dir_save)
call output_direct (-1, .true., s_blank$, s_dwarn$)
case ('warnings')
call output_direct (-1, .true., s_blank$, s_dwarn$)
call output_direct (-1, .false., s_warn$, s_dwarn$) ! Do not print
case ('all', 'ALL')
case ('all')
call output_direct (-1, .false., s_blank$, s_dwarn$) ! Do not print
end select

Expand Down
4 changes: 2 additions & 2 deletions tao/code/tao_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ module tao_struct
type tao_cmd_history_struct ! Record the command history
character(:), allocatable :: cmd ! The command
integer :: ix = 0 ! Command index (1st command has ix = 1, etc.)
!! logical :: cmd_file = '' ! Did command come from a command file
end type

!-----------------------------------------------------------------------
Expand Down Expand Up @@ -663,7 +662,7 @@ module tao_struct
integer :: datum_err_messages_max = 10 ! Maximum number of error messages per call to lattice_calc.
integer :: srdt_sxt_n_slices = 20 ! Number times to slice sextupoles for summation RDT calculation
logical :: srdt_use_cache = .true. ! Create cache for SRDT calculations. Can use lots of memory if srdt_*_n_slices large.
character(12) :: quiet = 'off' ! "all", or "output". Print I/O when running a command file?
character(12) :: quiet = 'off' ! Print I/O when running a command file?
character(16) :: random_engine = '' ! Non-beam random number engine
character(16) :: random_gauss_converter = '' ! Non-beam
character(16) :: track_type = 'single' ! or 'beam'
Expand Down Expand Up @@ -718,6 +717,7 @@ module tao_struct
character(200) :: dir = './'
integer :: ix_unit
character(40) :: cmd_arg(9) = '' ! Command file arguments.
character(12) :: quiet = 'off'
logical :: paused = .false. ! Is the command file paused?
integer :: n_line = 0 ! Current line number
logical :: reset_at_end = .true. ! Reset lattice_calc_on and plot_on at end of file?
Expand Down
28 changes: 13 additions & 15 deletions tao/doc/command-list.tex
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,10 @@ \section{call}\index{commands!call}
\begin{example}
set global quiet = all ! Suppress everything except errors
set global quiet = warnings ! Suppress just warnings.
set global quiet = off ! No suppression
\end{example}
Note: the \vn{all} setting (but not the \vn{warnings} setting) is automatically switched to \vn{off}
at the end when a command file exits back to the terminal level. To prevent this reset, set to
\vn{ALL} instead. See the \vn{Tao_global_struct Structure} section (\sref{s:tao.global.struct}) for
more details.

Note: if \vn{quiet} is set in a command file, the setting will persist to the end of the file and then
revert to what it was before the command file was run.

Examples:
\begin{example}
Expand Down Expand Up @@ -345,7 +343,7 @@ \section{create}\index{commands!create}
\end{example}

The \vn{create} command constructs various tao objects that would have
otherwise been created in tao initialiation.
otherwise been created in tao initialization.

% Use the command:
% help create <subcommand>
Expand Down Expand Up @@ -1740,14 +1738,14 @@ \subsection{set tune}
The \vn{-listing} option, if present, will, in addition to the tune change, generate a list of
quadrupoles varied along with variation coefficients.

It is sometimes desireable to veto from changing certain quadrupols (or overlays). The
It is sometimes desirable to veto from changing certain quadrupoles (or overlays). The
\vn{<veto_list>} of the \vn{-mask} option gives a list of quadrupoles {\em not} to use.
A tilde \vn{~} in front of an element name means that the element will not be vetoed. This
can be used to specify what quadrupoles to use (not veto). For example:
\begin{example}
set tune -mask *,~qf_\%\%,~qd_\% 0.23 0.45
\end{example}
In this example, the mask string has three ``words'' speparated by commas. The first word is
In this example, the mask string has three ``words'' separated by commas. The first word is
``\vn{*}'' which will veto everything. The second word \vn{~qf_\%} reinstates all elements whose
name starts with \vn{qf_} and has exactly two characters after the beginning \vn{qf_}. The third
word reinstates all elements that match the wild card pattern \vn{qd_\%}. The upshot is that only
Expand Down Expand Up @@ -3058,11 +3056,11 @@ \subsection{show spin}
\item Col 1: Name of mode
\item Col 2: Orbital tune.
\item Col 3: Q_spin + Q_mode + N where N is an integer that minimizes this expression.
The sum resonance occures when this is zero.
The sum resonance occurs when this is zero.
\item Col 4: Sum resonance strength. This number is only accurate if the value
of column 3 is small compared to one.
\item Col 5: Q_spin - Q_mode + N where N is an integer that minimizes this expression.
The difference resonance occures when this is zero.
The difference resonance occurs when this is zero.
\item Col 6: Difference resonance strength. This number is only accurate if the value
of column 5 is small compared to one.
\end{Itemize}
Expand All @@ -3082,11 +3080,11 @@ \subsection{show spin}
monomial ``[1 1 0 0 0 0]'' corresponds to $J_a$, and if RF is on then ``[1 1 2 2 3 3]'' corresponds
to $J_a*J_b^2*J_c^3$.

The \vn{-x_zero}, \vn{-y_zero}, and \vn{-z_zero} options are for testing if supressing certain terms
The \vn{-x_zero}, \vn{-y_zero}, and \vn{-z_zero} options are for testing if suppressing certain terms
in the linear part of the spin transport map for a set of elements selected by the user will
significantly affect the polarization. This is discussed in the section ``\vn{Linear dn/dpz
Calculation}'' in the \bmad manual. In particular, \vn{-x_zero} will zero the $\bfq_1$ and $\bfq_2$
terms in the $\arrowbfq$ vector (equivalent to zeroing $\bfG_x$ in the SLIM fromalism) for the spin
terms in the $\arrowbfq$ vector (equivalent to zeroing $\bfG_x$ in the SLIM formalism) for the spin
transport map of the chosen lattice elements. Similarly, \vn{-y_zero} and \vn{-z_zero} will zero
vertical and longitudinal components. Element list format (\sref{s:ele.list.format}), without any
embedded blanks, is used for the \vn{<ele_list>} list of elements to apply to.
Expand Down Expand Up @@ -3984,7 +3982,7 @@ \subsection{write bunch_comb}
\label{s:write.bunch.comb}

The \vn{write bunch_comb} command writes to a file bunch parameters (bunch sigma matrix, etc.) at
the ``comb'' points where these aggragrate bunch parameters are saved (\sref{s:beam.init}). Also see
the ``comb'' points where these aggregate bunch parameters are saved (\sref{s:beam.init}). Also see
the \vn{show beam -comb} (\sref{s:show.beam} and \vn{pipe bunch_comb} (\sref{p:bunch.comb})
commands. Syntax:
\begin{example}
Expand All @@ -3993,7 +3991,7 @@ \subsection{write bunch_comb}
\end{example}

There are three file types described below. For all types the file will contain a table. The rows of
the table correspond to different comb points. The columns of the table correspond to varias bunch
the table correspond to different comb points. The columns of the table correspond to various bunch
parameters calculated at the comb points.
\begin{description}
\item[-centroid] \Newline
Expand Down Expand Up @@ -4118,7 +4116,7 @@ \subsection{write field}
write field -ele Q1 -dr 0.01 0.02 0.05 -rmax 0.3 0.4 10.0 ! Same as above
\end{example}
The above examples both specify the same grid which will have an index range in $x$ of $[-30, 30]$,
ana range in $y$ of $[-20, 20]$,
and range in $y$ of $[-20, 20]$,

%% write gif --------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion tao/doc/cover-page.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

\begin{flushright}
\large
Revision: January 14, 2025 \\
Revision: February 7, 2025 \\
\end{flushright}

\vfill
Expand Down
17 changes: 9 additions & 8 deletions tao/doc/initialization.tex
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ \section{Tao Initialization Command Line Arguments}
\item[-prompt_color] \Newline
Sets the prompt string color to Blue. For different colors, use the \vn{set global prompt_color}
command (\sref{s:set}).
%
\item[-quiet <level>]

%
\item[-reverse]
Reverses the order of the lattice elements. Equivalent to setting
Expand Down Expand Up @@ -772,14 +775,12 @@ \subsection{Tao\_global\_struct Structure}
For use with command files. May be set to one of:
\begin{example}
off ! Normal verbose output
all ! Suppress command echo and other output.
ALL ! Suppress command echo and other output.
warnings ! Suppress warnings.
\end{example}
If set to \vn{all}, output to the terminal during command file running will be suppressed (except
for warning and error messages) until the command file (or files) returns to the command line level
at which point \vn{global%quiet} is automatically reset to \vn{off}. That is, \vn{global%quiet}
must be set each time it is desired to run a command file(s) silently.
all ! Suppress output except errors.
warnings ! Suppress warnings only.
\end{example}
If set to \vn{all}, output to the terminal will be suppressed except
for error messages. If set in a command file, the setting will revert to what it was
at the end of the command file.
%
\item{\vn{global%random_engine}} \Newline
\vn{global%random_engine} selects the algorithm used for generating the random
Expand Down
2 changes: 1 addition & 1 deletion tao/doc/pipe-interface-commands.json

Large diffs are not rendered by default.

Loading
Loading