Skip to content

Commit

Permalink
Fix some minor Tao data bookkeeping.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan committed Aug 15, 2024
1 parent ee32234 commit 386fee3
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion tao/code/tao_abort_command_file.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ subroutine tao_abort_command_file()

!

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

do i = s%com%cmd_file_level, 1, -1
if (s%com%cmd_file(i)%paused .or. s%global%single_step) return
Expand Down
9 changes: 6 additions & 3 deletions tao/code/tao_data_and_eval_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,10 @@ recursive subroutine tao_evaluate_a_datum (datum, u, tao_lat, datum_value, valid

case ('expression:', 'expression.')

write (dflt_dat_index, '(i0)') datum%ix_d1
! Something like "expression:max(data::orbit.x|model)" needs dflt_dat_indx = "*"
!! write (dflt_dat_index, '(i0)') datum%ix_d1 ???? why was this used previously?
dflt_dat_index = '*'

e_str = datum%data_type(12:)
do
ix = index(e_str, 'ele::#[')
Expand Down Expand Up @@ -4540,8 +4543,8 @@ subroutine tao_evaluate_expression (expression, n_size, use_good_user, value, er

! if phrase is blank then return 0.0

call string_trim (phrase, phrase, ios)
if (ios == 0) then
call string_trim (phrase, phrase, ix)
if (ix == 0) then
call out_io (s_warn$, r_name, "Expression is blank")
call re_allocate (value, max(1, n_size))
value = 0.0
Expand Down
6 changes: 3 additions & 3 deletions tao/code/tao_get_user_input_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ 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 ('off') ! verbose if not running from a command file
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

Expand All @@ -151,7 +151,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('off')
call tao_quiet_set('cmd-file-end')
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 +285,7 @@ subroutine tao_get_user_input (cmd_out, prompt_str, wait_flag, cmd_in)
endif
endif

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

!-------------------------------------------------------------------------
Expand Down
12 changes: 11 additions & 1 deletion tao/code/tao_quiet_set.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,24 @@ subroutine tao_quiet_set (set)

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

else
call match_word (set, [character(12):: 'output', 'off', 'all'], ix, .false., .true., name)
call match_word (set, [character(12):: 'off', 'all', 'ALL'], ix, .false., .true., name)
if (ix < 1) then
call out_io (s_error$, r_name, 'BAD "quiet" COMMAND ARGUMENT: ' // set)
return
endif
endif

!

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

Expand Down
29 changes: 6 additions & 23 deletions tao/code/tao_set_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -482,30 +482,11 @@ subroutine tao_set_global_cmd (who, value_str)
endif

if (who == 'silent_run') then ! Old style syntax
call out_io (s_error$, r_name, 'The "set global silent_run" command has been replaced by "set global quiet = <logic>"')

if (s%com%cmd_file_level == 0) then
call out_io (s_error$, r_name, 'The "set global silent_run" command can only be used in command files.')
return
endif

call match_word (value_str, [character(8):: 'true', 'false'], ix)
if (ix == 1) then
call tao_quiet_set('all')
elseif (ix == 2) then
call tao_quiet_set('off')
else
call out_io (s_error$, r_name, 'BAD "silent_run" VALUE: ' // value_str)
endif
call out_io (s_error$, r_name, 'The "set global silent_run" command has been replaced by "set global quiet = <switch>". Nothing done!')
return
endif

if (who == 'quiet') then
if (s%com%cmd_file_level == 0) then
call out_io (s_error$, r_name, 'The "set global quiet" command can only be used in command files.')
return
endif

call tao_quiet_set (value_str)
return
endif
Expand Down Expand Up @@ -2369,7 +2350,8 @@ subroutine tao_set_data_cmd (who_str, value_str, silent)
character(*), parameter :: r_name = 'tao_set_data_cmd'
character(100) :: why_invalid, tmpstr
character, allocatable :: s_save(:)

character(16), parameter :: datum_char_params(6) = [character(16):: 'ele_name', 'ele_start_name', &
'ele_ref_name', 'data_type', 'merit_type', 'data_source']
logical, optional :: silent
logical err, l1

Expand Down Expand Up @@ -2509,9 +2491,10 @@ subroutine tao_set_data_cmd (who_str, value_str, silent)

allocate (s_save(size(s_dat))) ! Used to save old values in case of error

! If value_string has "|" then it must be a datum array
! If value_string has "|XXX" at the end and XXX is a datum string parameter then it must be a datum array.

if (index(value_str, '|') /= 0) then
ix = index(value_str, '|')
if (ix /= 0 .and. any(value_str(ix+1:) == datum_char_params)) then
call tao_find_data (err, value_str, str_array=s_value)
if (size(s_value) /= size(s_dat) .and. size(s_value) /= 1) then
call out_io (s_error$, r_name, 'ARRAY SIZES ARE NOT THE SAME')
Expand Down
10 changes: 5 additions & 5 deletions tao/doc/command-list.tex
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ \section{call}\index{commands!call}
\begin{example}
set global quiet = all
\end{example}
Note: quiet mode is automatically turned off at the end when a command file exits back to the
terminal level. See the \vn{Tao_global_struct Structure} section (\sref{s:tao.global.struct}) for
more details.
Note: the \vn{all} 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.

Examples:
\begin{example}
Expand Down Expand Up @@ -1200,8 +1200,8 @@ \subsection{set data}
Examples:
\begin{example}
set data *|ref = *|meas ! Set ref data = measured in current universe.
set data [email protected]|base = [email protected]|model
! Set the base orbit.x in universe 2 to model
set data [email protected]|ref = [email protected]|model
! Set the ref orbit.x in universe 2 to model.
set data beta.x[10]|weight = 1e-5 ! Set weight of datum.
set -silent d[1]|data_type = beta.a ! Set type_type.
\end{example}
Expand Down
3 changes: 2 additions & 1 deletion tao/doc/initialization.tex
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ \subsection{Tao\_global\_struct Structure}
optimizer_allow_user_abort = T ! See below.
optimizer_var_limit_warn = T ! Warn when vars reach a limit when optimizing?
plot_on = T ! Do plotting?
quiet = "off" ! Print to the terminal when using a command file?
quiet = "off" ! Suppress informational output to terminal.
rf_on = F ! RF cavities on?
svd_retreat_on_merit_increase = T
single_step = F ! Single step through a command file?
Expand Down Expand Up @@ -750,6 +750,7 @@ \subsection{Tao\_global\_struct Structure}
\begin{example}
off ! Normal verbose output
all ! Suppress command echo and other output.
ALL ! Suppress command echo and other output.
output ! Suppress output except for command echo.
\end{example}
If set to \vn{all}, output to the terminal during command file running will be suppressed (except
Expand Down

0 comments on commit 386fee3

Please sign in to comment.