Skip to content

Commit

Permalink
Fix Bmad parser to convert tab characters to blanks. (#1089)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Jul 27, 2024
1 parent 07dca6d commit 4d69838
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 69 deletions.
6 changes: 3 additions & 3 deletions bmad/modules/mode3_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ subroutine eigen_decomp_6mat(mat, eval, evec, err_flag, tunes)
CALL la_geev(A, eval_r, eval_i, VR=VR, INFO=i_error)
eval = cmplx(eval_r, eval_i, rp)
if ( i_error /= 0 ) THEN
call out_io (s_fatal$, r_name, "la_geev returned error: \i0\ ", i_error)
call out_io (s_error$, r_name, "la_geev returned error: \i0\ ", i_error)
if (global_com%exit_on_error) call err_exit
eval = 0.0d0
evec = 0.0d0
Expand Down Expand Up @@ -731,7 +731,7 @@ subroutine order_evecs_by_tune (evec, eval, mat_tunes, abz_tunes, err_flag)
tz1 = count(abs(mat_tunes(1:3)) < 0.0001)
tz2 = count(abs(abz(1:3)) < 0.0001)
if (tz1 > 1 .or. tz1 /= tz2) then
call out_io (s_fatal$, r_name, "tunes is not fully populated.")
call out_io (s_error$, r_name, "tunes is not fully populated.")
if (global_com%exit_on_error) call err_exit
return
endif
Expand All @@ -753,7 +753,7 @@ subroutine order_evecs_by_tune (evec, eval, mat_tunes, abz_tunes, err_flag)
val(6) = max(dtune(1,3), dtune(2,2), dtune(3,1))

if (minval(val, 1) > 0.1) then
call out_io (s_fatal$, r_name, "Unable to match input tunes with calculated tunes.", &
call out_io (s_error$, r_name, "Unable to match input tunes with calculated tunes.", &
'Input tunes: \3f14.5\ ', &
'Calculated tunes: \3f14.5\ ', r_array = [abz(1:3)/twopi, mat_tunes(1:3)/twopi])
return
Expand Down
6 changes: 4 additions & 2 deletions bmad/parsing/bmad_parser_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2931,7 +2931,6 @@ recursive subroutine load_parse_line (action, ix_start, end_of_file, err_flag)
character(*) action
character(n_parse_line) :: line
character(1) quote_mark, last_char
character(1), parameter :: tab = achar(9)

logical :: end_of_file, flush_this, has_blank
logical, optional :: err_flag
Expand Down Expand Up @@ -2977,8 +2976,9 @@ recursive subroutine load_parse_line (action, ix_start, end_of_file, err_flag)
! With advance = 'no' an ios = 0 means that a full line has *not* been read.
read (bp_com%current_file%f_unit, '(a)', iostat = bp_com%ios_next_chunk, &
advance = 'no') bp_com%next_chunk

if (bp_com%ios_next_chunk == iostat_eor) then
! Nothing to do
call detab(bp_com%next_chunk)
else
bp_com%next_chunk = ''
endif
Expand Down Expand Up @@ -3008,6 +3008,8 @@ recursive subroutine load_parse_line (action, ix_start, end_of_file, err_flag)
elseif (bp_com%ios_next_chunk /= 0) then
bp_com%next_chunk = ''
endif

call detab(bp_com%next_chunk)
bp_com%current_file%i_line = bp_com%current_file%i_line + 1
endif

Expand Down
5 changes: 5 additions & 0 deletions sim_utils/interfaces/sim_utils_interface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ subroutine date_and_time_stamp (string, numeric_month, include_zone)
logical, optional :: numeric_month, include_zone
end subroutine

subroutine detab(str)
implicit none
character(*) str
end subroutine

function determinant (mat) result (det)
import
implicit none
Expand Down
2 changes: 1 addition & 1 deletion sim_utils/math/da2_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function da2_inverse(ta) result (ta_inv)
n = ubound(ta, 1)

if (ta(0,0) == 0) then
call out_io (s_fatal$, r_name, 'INVERSE OF TAYLOR SERIES WITH CONSTANT TERM ZERO IS NOT POSSIBLE')
call out_io (s_error$, r_name, 'INVERSE OF TAYLOR SERIES WITH CONSTANT TERM ZERO IS NOT POSSIBLE')
if (global_com%exit_on_error) call err_exit
return
endif
Expand Down
4 changes: 2 additions & 2 deletions sim_utils/math/fft_1d.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

subroutine fft_1d (arr, isign)

use output_mod, only: out_io, rp, global_com, s_fatal$, real_garbage$
use output_mod, only: out_io, rp, global_com, s_error$, real_garbage$
use, intrinsic :: iso_c_binding

implicit none
Expand All @@ -35,7 +35,7 @@ subroutine fft_1d (arr, isign)
case (-1)
call dfftw_plan_dft_1d(plan, size(arr), arr, arr, FFTW_FORWARD, FFTW_ESTIMATE)
case default
call out_io(s_fatal$, r_name, 'BAD ISIGN ARGUMENT.')
call out_io(s_error$, r_name, 'BAD ISIGN ARGUMENT.')
if (global_com%exit_on_error) call err_exit
arr = real_garbage$
return
Expand Down
2 changes: 1 addition & 1 deletion sim_utils/math/random_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ subroutine super_sobseq (x, ran_state)
end do

if (j > sobseq_maxbit) then
call out_io (s_fatal$, r_name, 'SOBSEQ_MAXBIT TOO SMALL')
call out_io (s_error$, r_name, 'SOBSEQ_MAXBIT TOO SMALL')
if (global_com%exit_on_error) call err_exit
return
endif
Expand Down
2 changes: 1 addition & 1 deletion sim_utils/math/rotation_3d_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ subroutine axis_angle_to_w_mat (axis, angle, w_mat)
norm = norm2(axis)
if (norm == 0) then
w_mat = 0
call out_io (s_fatal$, r_name, 'ZERO AXIS LENGTH WITH NON-ZERO ROTATION!')
call out_io (s_error$, r_name, 'ZERO AXIS LENGTH WITH NON-ZERO ROTATION!')
if (global_com%exit_on_error) call err_exit
return
endif
Expand Down
2 changes: 1 addition & 1 deletion sim_utils/math/spline_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function create_a_spline (r0, r1, slope0, slope1) result (spline)
dy = r1(2) - r0(2)

if (dx == 0) then
call out_io (s_fatal$, r_name, 'X DISTANCE BETWEEN POINTS IS ZERO.')
call out_io (s_error$, r_name, 'X DISTANCE BETWEEN POINTS IS ZERO.')
if (global_com%exit_on_error) call err_exit
return
endif
Expand Down
4 changes: 2 additions & 2 deletions sim_utils/math/super_recipes_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ end function func
endif

if ((fa > 0.0 .and. fb > 0.0) .or. (fa < 0.0 .and. fb < 0.0)) then
call out_io (s_fatal$, r_name, 'ROOT NOT BRACKETED!, \es12.4\ at \es12.4\ and \es12.4\ at \es12.4\ ', &
call out_io (s_error$, r_name, 'ROOT NOT BRACKETED!, \es12.4\ at \es12.4\ and \es12.4\ at \es12.4\ ', &
r_array = [fa, a, fb, b])
x_zero = 1d100
status = -1
Expand Down Expand Up @@ -925,7 +925,7 @@ end function func
fb = func(b, status); if (status /= 0) return
end do

call out_io (s_fatal$, r_name, 'EXCEEDED MAXIMUM ITERATIONS!')
call out_io (s_error$, r_name, 'EXCEEDED MAXIMUM ITERATIONS!')
status = -2
x_zero = b

Expand Down
2 changes: 1 addition & 1 deletion sim_utils/matrix/mat_eigen.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ subroutine mat_eigen (mat, eigen_val, eigen_vec, error, print_err)
call la_geev(mat2, eval_r, eval_i, vr = vec, info = ier)
error = (ier /= 0)
if (error) then
if (logic_option(.true., print_err)) call out_io (s_fatal$, r_name, "la_geev returned error: \i0\ ", ier)
if (logic_option(.true., print_err)) call out_io (s_error$, r_name, "la_geev returned error: \i0\ ", ier)
eigen_val = 0.0d0
eigen_vec = 0.0d0
return
Expand Down
4 changes: 2 additions & 2 deletions sim_utils/matrix/mat_symp_conj.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

function mat_symp_conj(mat) result (mat_conj)

use output_mod, only: rp, out_io, s_fatal$, global_com
use output_mod, only: rp, out_io, s_error$, global_com

implicit none

Expand All @@ -29,7 +29,7 @@ function mat_symp_conj(mat) result (mat_conj)
nn = size(mat, 1)

if (mod(nn, 2) /= 0 .or. nn /= size(mat, 2)) then
call out_io (s_fatal$, r_name, 'ARRAY SIZE IS NOT EVEN!')
call out_io (s_error$, r_name, 'ARRAY SIZE IS NOT EVEN!')
if (global_com%exit_on_error) call err_exit
endif

Expand Down
4 changes: 2 additions & 2 deletions sim_utils/matrix/mat_symp_conj_i.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

function mat_symp_conj_i(mat) result (mat_conj)

use output_mod, only: rp, out_io, s_fatal$, global_com
use output_mod, only: rp, out_io, s_error$, global_com

implicit none

Expand All @@ -29,7 +29,7 @@ function mat_symp_conj_i(mat) result (mat_conj)
nn = size(mat, 1)

if (mod(nn, 2) /= 0 .or. nn /= size(mat, 2)) then
call out_io (s_fatal$, r_name, 'ARRAY SIZE IS NOT EVEN!')
call out_io (s_error$, r_name, 'ARRAY SIZE IS NOT EVEN!')
if (global_com%exit_on_error) call err_exit
endif

Expand Down
Loading

0 comments on commit 4d69838

Please sign in to comment.