Skip to content

Commit

Permalink
Implemented Tao plot timer and increased number of plot points to 400…
Browse files Browse the repository at this point in the history
…1. (#1115)
  • Loading branch information
DavidSagan committed Aug 2, 2024
1 parent 562bfbe commit b862f8d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
3 changes: 1 addition & 2 deletions sim_utils/interfaces/sim_utils_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,7 @@ function real_str(r_num, n_signif, n_decimal) result (str)
import
implicit none
real(rp) r_num
integer n_signif
integer, optional :: n_decimal
integer, optional :: n_signif, n_decimal
character(:), allocatable :: str
end function

Expand Down
9 changes: 5 additions & 4 deletions sim_utils/string/real_str.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
!
! Input:
! r_num -- real(rp): Real number
! n_signif -- integer: Number of significant places.
! n_signif -- integer, optional: Number of significant places. If not present, n_decimal must be present.
! n_decimal -- integer, optional: If present, maximum number of places after the decimal point.
!
! Output:
Expand All @@ -22,13 +22,14 @@ function real_str(r_num, n_signif, n_decimal) result (str)
implicit none

real(rp) r_num
integer n_signif
integer, optional :: n_decimal
integer, optional :: n_signif, n_decimal
character(:), allocatable :: str
character(20) string

if (present(n_decimal)) then
if (abs(r_num) > 10.0_rp**(n_signif - n_decimal)) then
if (.not. present(n_signif)) then
write (string, '(f20.' // int_str(n_decimal) // ')') r_num
elseif (abs(r_num) > 10.0_rp**(n_signif - n_decimal)) then
write (string, '(f20.' // int_str(n_decimal) // ')') r_num
else
string = real_to_string(r_num, 20, n_signif = n_signif)
Expand Down
15 changes: 12 additions & 3 deletions tao/code/tao_cmd_end_calc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ subroutine tao_cmd_end_calc

type (tao_plot_region_struct), pointer :: r

real(rp) this_merit !not really used here
real(rp) tim, this_merit
integer i
logical err
character(*), parameter :: r_name = 'tao_cmd_end_calc'

! Note: tao_merit calls tao_lattice_calc.

this_merit = tao_merit()
this_merit = tao_merit()

! update variable values to reflect lattice values
! Update variable values to reflect lattice values

call run_timer('START')
call tao_plot_setup() ! transfer data to the plotting structures
if (associated(tao_hook_plot_setup_ptr)) call tao_hook_plot_setup_ptr()

Expand All @@ -43,6 +45,13 @@ subroutine tao_cmd_end_calc

call tao_draw_plots() ! Update the plotting window

call run_timer('READ', tim)
if (s%global%max_plot_time > 0 .and. tim > s%global%max_plot_time) then
call out_io(s_blank$, r_name, 'Time to plot is: ' // real_str(tim, n_decimal = 1) // ' seconds.', &
'To reduce plotting time try "set plot_page n_curve_pts = N" where N is less than the current ' // int_str(s%plot_page%n_curve_pts), &
'To turn off this message, "set global max_plot_time" to something negative or something greater than the plot time.')
endif

end subroutine tao_cmd_end_calc


1 change: 1 addition & 0 deletions tao/code/tao_show_this.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,7 @@ subroutine tao_show_this (what, result_id, lines, nl)
nl=nl+1; write(lines(nl), lmt) ' %label_lattice_elements = ', s%global%label_lattice_elements
nl=nl+1; write(lines(nl), lmt) ' %label_keys = ', s%global%label_keys
nl=nl+1; write(lines(nl), lmt) ' %lattice_calc_on = ', s%global%lattice_calc_on
nl=nl+1; write(lines(nl), rmt) ' %max_plot_time = ', s%global%max_plot_time
nl=nl+1; write(lines(nl), lmt) ' %only_limit_opt_vars = ', s%global%only_limit_opt_vars
nl=nl+1; write(lines(nl), lmt) ' %opt_match_auto_recalc = ', s%global%opt_match_auto_recalc
nl=nl+1; write(lines(nl), lmt) ' %opti_write_var_file = ', s%global%opti_write_var_file
Expand Down
3 changes: 2 additions & 1 deletion tao/code/tao_struct.f90
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ module tao_struct
real(rp) :: floor_plan_text_scale = 1.0 ! Scale used = floor_plan_text_scale * legend_text_scale
real(rp) :: lat_layout_shape_scale = 1.0
real(rp) :: lat_layout_text_scale = 1.0 ! Scale used = lat_layout_text_scale * legend_text_scale
integer :: n_curve_pts = 401 ! Default number of points for plotting a smooth curve.
integer :: n_curve_pts = 4001 ! Default number of points for plotting a smooth curve.
integer :: id_window = -1 ! X window id number.
logical :: delete_overlapping_plots = .true. ! Delete overlapping plots when a plot is placed?
logical :: draw_graph_title_suffix = .true. ! Draw the graph title suffix?
Expand Down Expand Up @@ -646,6 +646,7 @@ module tao_struct
real(rp) :: dmerit_stop_value = 0 ! Fractional Merit change below which an optimizer will stop.
real(rp) :: random_sigma_cutoff = -1 ! Cut-off in sigmas.
real(rp) :: delta_e_chrom = 0 ! Delta E used from chrom calc.
real(rp) :: max_plot_time = 5 ! If plotting time (seconds) exceeds this than a message is generated.
integer :: default_universe = 1 ! Default universe to work with.
integer :: default_branch = 0 ! Default lattice branch to work with.
integer :: n_opti_cycles = 20 ! Number of optimization cycles
Expand Down

0 comments on commit b862f8d

Please sign in to comment.