From 8a5fbd4121d0ce53068287ce568311508fa03562 Mon Sep 17 00:00:00 2001 From: David Sagan Date: Fri, 2 Aug 2024 00:45:51 -0400 Subject: [PATCH] Implemented Tao plot timer and increased number of plot points to 4001. --- sim_utils/interfaces/sim_utils_interface.f90 | 3 +-- sim_utils/string/real_str.f90 | 9 +++++---- tao/code/tao_cmd_end_calc.f90 | 15 ++++++++++++--- tao/code/tao_show_this.f90 | 1 + tao/code/tao_struct.f90 | 3 ++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/sim_utils/interfaces/sim_utils_interface.f90 b/sim_utils/interfaces/sim_utils_interface.f90 index 5dbbf4de78..ebe9958d5f 100644 --- a/sim_utils/interfaces/sim_utils_interface.f90 +++ b/sim_utils/interfaces/sim_utils_interface.f90 @@ -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 diff --git a/sim_utils/string/real_str.f90 b/sim_utils/string/real_str.f90 index 858ad8fdf0..7d30ad2274 100644 --- a/sim_utils/string/real_str.f90 +++ b/sim_utils/string/real_str.f90 @@ -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: @@ -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) diff --git a/tao/code/tao_cmd_end_calc.f90 b/tao/code/tao_cmd_end_calc.f90 index 77ad7676c5..0cd7bbc768 100644 --- a/tao/code/tao_cmd_end_calc.f90 +++ b/tao/code/tao_cmd_end_calc.f90 @@ -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() @@ -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 diff --git a/tao/code/tao_show_this.f90 b/tao/code/tao_show_this.f90 index 6d01dcd331..d500ae4520 100644 --- a/tao/code/tao_show_this.f90 +++ b/tao/code/tao_show_this.f90 @@ -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 diff --git a/tao/code/tao_struct.f90 b/tao/code/tao_struct.f90 index d7cd897fbf..e2187b129d 100644 --- a/tao/code/tao_struct.f90 +++ b/tao/code/tao_struct.f90 @@ -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? @@ -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