From b89b6a1a8cf4d858f08b45c02985fe37fd5e9b74 Mon Sep 17 00:00:00 2001 From: David Sagan Date: Tue, 27 Aug 2024 22:39:26 -0400 Subject: [PATCH] Fix bug in bmad to mad not outputting all the elements. --- bmad/modules/bmad_routine_interface.f90 | 4 +- bmad/output/write_lat_file_mod.f90 | 41 +++++------- .../write_lattice_in_foreign_format.f90 | 63 +++++++------------ code_examples/mpi_mp/mpi_mp.f90 | 6 +- tao/version/tao_version_mod.f90 | 2 +- .../bmad_to_mad_sad_elegant.f90 | 1 + 6 files changed, 45 insertions(+), 72 deletions(-) diff --git a/bmad/modules/bmad_routine_interface.f90 b/bmad/modules/bmad_routine_interface.f90 index 4a8dd2044d..a52eef4dd1 100644 --- a/bmad/modules/bmad_routine_interface.f90 +++ b/bmad/modules/bmad_routine_interface.f90 @@ -3344,14 +3344,14 @@ subroutine write_digested_bmad_file (digested_name, lat, n_files, file_names, e end subroutine subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_orbit, use_matrix_model, & - include_apertures, dr12_drift_max, ix_start, ix_end, ix_branch, converted_lat, err) + include_apertures, dr12_drift_max, ix_branch, converted_lat, err) import implicit none type (lat_struct), target :: lat type (lat_struct), optional, target :: converted_lat type (coord_struct), allocatable, optional :: ref_orbit(:) real(rp), optional :: dr12_drift_max - integer, optional :: ix_start, ix_end, ix_branch + integer, optional :: ix_branch character(*) out_type, out_file_name logical, optional :: use_matrix_model, include_apertures, err end subroutine diff --git a/bmad/output/write_lat_file_mod.f90 b/bmad/output/write_lat_file_mod.f90 index ed1606bf51..eab3c2b8e5 100644 --- a/bmad/output/write_lat_file_mod.f90 +++ b/bmad/output/write_lat_file_mod.f90 @@ -474,13 +474,13 @@ end subroutine value_to_line !------------------------------------------------------------------------- !------------------------------------------------------------------------- !+ -! Subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_start, ix_end, ix_branch, converted_lat, err) +! Subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_branch, converted_lat, err) ! ! Private routine used by write_lat_in_sad_format and not for general use. ! See write_lat_in_sad_format for details about the argument list. !- -subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_start, ix_end, ix_branch, converted_lat, err) +subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_branch, converted_lat, err) implicit none @@ -504,9 +504,9 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st integer, parameter :: sad_fshift$ = 5 integer, parameter :: sad_mark_offset$ = 6 -integer, optional :: ix_start, ix_end, ix_branch +integer, optional :: ix_branch integer, allocatable :: n_repeat(:), an_indexx(:) -integer i, j, n, ib, iout, iu, ix, ix1, ix2, ios, ie1, ie2, ie2_orig, n_taylor_order_saved, ix_ele +integer i, j, n, ib, iout, iu, ix, ix1, ix2, ios, ie2_orig, n_taylor_order_saved, ix_ele integer s_count, j_count, n_elsep_warn, n_name_change_warn integer ix_manch, n_names, aperture_at, ix_pole_max, ix_match integer :: ix_line_min, ix_line_max, n_warn_max = 10 @@ -548,9 +548,7 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st call multipole_init (ab_ele, magnetic$) null_ele%key = null_ele$ -ie1 = integer_option(1, ix_start) -ie2 = integer_option(branch%n_ele_track, ix_end) -ie2_orig = ie2 +ie2_orig = branch%n_ele_track allocate (names(branch%n_ele_max), an_indexx(branch%n_ele_max)) ! list of element names @@ -598,7 +596,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st if (ele%key == patch$ .and. ele%old_value(sad_fshift$) /= 0 .and. ix_ele <= ie2_orig) then ele%ix_ele = -1 - ie2 = ie2 - 1 endif enddo @@ -611,11 +608,11 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st old_bs_field = 0 n_name_change_warn = 0 n_elsep_warn = 0 -ix_ele = ie1 - 1 +ix_ele = 0 do ix_ele = ix_ele + 1 - if (ix_ele > ie2) exit + if (ix_ele > branch_out%n_ele_track) exit ele => branch_out%ele(ix_ele) val => ele%value @@ -661,7 +658,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st write (sol_ele%name, '(a, i0)') 'SOL_', s_count call insert_element (lat_out, sol_ele, ix_ele, branch_out%ix_branch) sol_ele => branch_out%ele(ix_ele) - ie2 = ie2 + 1 ix_ele = ix_ele + 1 ele => branch_out%ele(ix_ele) val => ele%value @@ -772,11 +768,9 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st aperture_at = ele%aperture_at ! Save since ele pointer will be invalid after the insert if (aperture_at == both_ends$ .or. aperture_at == downstream_end$ .or. aperture_at == continuous$) then call insert_element (lat_out, col_ele, ix_ele+1, branch_out%ix_branch) - ie2 = ie2 + 1 endif if (aperture_at == both_ends$ .or. aperture_at == upstream_end$ .or. aperture_at == continuous$) then call insert_element (lat_out, col_ele, ix_ele, branch_out%ix_branch) - ie2 = ie2 + 1 endif ix_ele = ix_ele - 1 ! Want to process the element again on the next loop. @@ -793,7 +787,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st val(roll$) = 0 ! So on next iteration will not create extra kickers. call insert_element (lat_out, kicker_ele, ix_ele, branch_out%ix_branch) call insert_element (lat_out, kicker_ele, ix_ele+2, branch_out%ix_branch) - ie2 = ie2 + 2 cycle endif @@ -810,7 +803,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st write (ab_ele%name, '(a1, a, i0)') key_name(ele%key), 'MULTIPOLE_', j_count call insert_element (lat_out, ab_ele, ix_ele, branch_out%ix_branch) call insert_element (lat_out, ab_ele, ix_ele+2, branch_out%ix_branch) - ie2 = ie2 + 2 cycle endif endif @@ -839,7 +831,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st do i = ix1+1, ix2 branch_out%ele(i)%ix_ele = -1 ! mark for deletion enddo - ie2 = ie2 - (ix2 - ix1 - 1) else call create_planar_wiggler_model (ele, lat_model) endif @@ -849,7 +840,6 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st do j = 1, lat_model%n_ele_track call insert_element (lat_out, lat_model%ele(j), ix_ele+j-1, branch_out%ix_branch) enddo - ie2 = ie2 + lat_model%n_ele_track - 1 cycle endif @@ -858,7 +848,7 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st ! If there is a finite bs_field then create a final null_ele element if (bs_field /= 0) then - ele => branch_out%ele(ie2) + ele => branch_out%ele(branch_out%n_ele_track) if (ele%key == marker$) then ele%key = null_ele$ ele%old_value(sad_bz$) = bs_field @@ -866,9 +856,8 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st s_count = s_count + 1 write (null_ele%name, '(a, i0)') 'SOL_', s_count null_ele%old_value(sad_bz$) = bs_field - ie2 = ie2 + 1 - call insert_element (lat_out, null_ele, ie2, branch_out%ix_branch) - ele => branch_out%ele(ie2) + call insert_element (lat_out, null_ele, branch_out%n_ele_track, branch_out%ix_branch) + ele => branch_out%ele(branch_out%n_ele_track-1) endif ele%old_value(sad_bound$) = 1 @@ -877,11 +866,11 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st ! For a patch that is *not* associated with the edge of a solenoid: A z_offset must be split into a drift + patch -ix_ele = ie1 - 1 +ix_ele = 0 do ix_ele = ix_ele + 1 - if (ix_ele > ie2) exit + if (ix_ele > branch_out%n_ele_track) exit ele => branch_out%ele(ix_ele) val => ele%value @@ -913,7 +902,7 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st n_names = 0 ! number of names stored in the list old_bs_field = 0 -do ix_ele = ie1, ie2 +do ix_ele = 1, branch_out%n_ele_track ele => branch_out%ele(ix_ele) val => ele%value @@ -1309,7 +1298,7 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st write (iu, '(a)') write (line_out, '(2a)') 'LINE ASC = (' -do n = ie1, ie2 +do n = 1, branch_out%n_ele_track ele => branch_out%ele(n) if (ele%sub_key == not_set$) cycle @@ -1325,7 +1314,7 @@ subroutine write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_st ! Output line if long enough or at end - if (n == ie2) then + if (n == branch_out%n_ele_track) then line_out = trim(line_out) // ')' write (iu, '(2a)') trim(line_out), ';' line_out = ' ' diff --git a/bmad/output/write_lattice_in_foreign_format.f90 b/bmad/output/write_lattice_in_foreign_format.f90 index 8bd6b1b138..58ace8b79f 100644 --- a/bmad/output/write_lattice_in_foreign_format.f90 +++ b/bmad/output/write_lattice_in_foreign_format.f90 @@ -1,6 +1,6 @@ !+ ! Subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_orbit, & -! use_matrix_model, include_apertures, dr12_drift_max, ix_start, ix_end, ix_branch, converted_lat, err) +! use_matrix_model, include_apertures, dr12_drift_max, ix_branch, converted_lat, err) ! ! Subroutine to write a Elegant, MAD-8, MAD-X, OPAL, SAD, JULIA, or XSIF lattice file using the ! information in a lat_struct. Optionally, only part of the lattice can be generated. @@ -45,10 +45,6 @@ ! with an aperture so in this case this argument is ignored. ! dr12_drift_max -- real(rp), optional: Max deviation for drifts allowed before a correction matrix element ! is added. Default value is 1d-5. A negative number means use default. -! ix_start -- integer, optional: Starting index of lat%ele(i) -! used for output. -! ix_end -- integer, optional: Ending index of lat%ele(i) -! used for output. ! ix_branch -- Integer, optional: Index of lattice branch to use. Default = 0. ! ! Output: @@ -58,7 +54,7 @@ !- subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_orbit, & - use_matrix_model, include_apertures, dr12_drift_max, ix_start, ix_end, ix_branch, converted_lat, err) + use_matrix_model, include_apertures, dr12_drift_max, ix_branch, converted_lat, err) use mad_mod, dummy2 => write_lattice_in_foreign_format use bmad, dummy => write_lattice_in_foreign_format @@ -88,10 +84,10 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or real(rp) knl(0:n_pole_maxx), tilts(0:n_pole_maxx), a_pole(0:n_pole_maxx), b_pole(0:n_pole_maxx) real(rp) tilt, x_pitch, y_pitch, etilt, epitch, eyaw, offset(3), w_mat(3,3) -integer, optional :: ix_start, ix_end, ix_branch +integer, optional :: ix_branch integer, allocatable :: n_repeat(:), an_indexx(:) integer i, j, ib, j2, k, n, ix, i_unique, i_line, iout, iu, n_names, j_count, f_count, ix_ele -integer ie, ie1, ie2, ios, a_count, ix_lord, ix_match, iv, ifa, ix_pole_max +integer ie, ios, a_count, ix_lord, ix_match, iv, ifa, ix_pole_max integer ix1, ix2, n_lord, aperture_at, n_name_change_warn, n_elsep_warn, n_taylor_order_saved integer :: ix_line_min, ix_line_max, n_warn_max = 10 @@ -118,7 +114,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ! SAD translation if (out_type == 'SAD') then - call write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_start, ix_end, ix_branch, converted_lat, err) + call write_lat_in_sad_format (out_file_name, lat, include_apertures, ix_branch, converted_lat, err) return endif @@ -175,9 +171,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call multipole_init (ab_ele, magnetic$) null_ele%key = null_ele$ -ie1 = integer_option(1, ix_start) -ie2 = integer_option(branch%n_ele_track, ix_end) - allocate (names(branch%n_ele_max+10), an_indexx(branch%n_ele_max+10)) ! list of element names call out_io (s_info$, r_name, & @@ -225,11 +218,11 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or nullify(first_sol_edge) n_name_change_warn = 0 n_elsep_warn = 0 -ix_ele = ie1 - 1 +ix_ele = 0 do ix_ele = ix_ele + 1 - if (ix_ele > ie2) exit + if (ix_ele > branch_out%n_ele_track) exit ele => branch_out%ele(ix_ele) if (ele%key == -1) cycle ! Has been marked for delection @@ -269,11 +262,9 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or aperture_at = ele%aperture_at ! Save since ele pointer will be invalid after the insert if (aperture_at == both_ends$ .or. aperture_at == downstream_end$ .or. aperture_at == continuous$) then call insert_element (lat_out, col_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1 endif if (aperture_at == both_ends$ .or. aperture_at == upstream_end$ .or. aperture_at == continuous$) then call insert_element (lat_out, col_ele, ix_ele, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1 endif ix_ele = ix_ele - 1 ! Want to process the element again on the next loop. @@ -291,7 +282,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or val(roll$) = 0 ! So on next iteration will not create extra kickers. call insert_element (lat_out, kicker_ele, ix_ele, branch_out%ix_branch, orbit_out) call insert_element (lat_out, kicker_ele, ix_ele+2, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 2 cycle endif @@ -320,7 +310,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or write (ab_ele%name, '(a1, a, i0)') key_name(ele%key), 'MULTIPOLE_', j_count call insert_element (lat_out, ab_ele, ix_ele, branch_out%ix_branch, orbit_out) call insert_element (lat_out, ab_ele, ix_ele+2, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 2 cycle endif endif @@ -358,7 +347,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call insert_element (lat_out, kicker_ele, ix_ele+1, branch_out%ix_branch, orbit_out) call insert_element (lat_out, taylor_ele, ix_ele+2, branch_out%ix_branch, orbit_out) call insert_element (lat_out, kicker_ele, ix_ele+3, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 3 cycle endif endif @@ -384,7 +372,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or write (taylor_ele%name, '(a, i0)') 'Q_FRINGE_IN', f_count call insert_element (lat_out, taylor_ele, ie, branch_out%ix_branch, orbit_out) ie = ie + 1 - ie2 = ie2 + 1 endif if (ifa == exit_end$ .or. ifa == both_ends$) then @@ -393,7 +380,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call ele_to_taylor (quad_ele, branch_out%param, orbit_out(ie), orbital_taylor = taylor_ele%taylor) write (taylor_ele%name, '(a, i0)') 'Q_FRINGE_OUT', f_count call insert_element (lat_out, taylor_ele, ie+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1 endif cycle @@ -435,7 +421,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call kill_taylor (taylor_a) call kill_taylor (taylor_b) ie = ie + 1 - ie2 = ie2 + 1 endif if (at_this_ele_end(exit_end$, nint(ele%value(fringe_at$))) .or. ele%value(dg$) /= 0) then @@ -457,7 +442,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call insert_element (lat_out, taylor_ele, ie+1, branch_out%ix_branch, orbit_out) call kill_taylor (taylor_a) call kill_taylor (taylor_b) - ie2 = ie2 + 1 endif ele%value(fringe_type$) = basic_bend$ @@ -484,7 +468,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or taylor_ele%name = 'TAYLOR_' // ele%name call insert_element (lat_out, taylor_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1 ix_ele = ix_ele + 1 cycle endif @@ -510,7 +493,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call insert_element (lat_out, drift_ele, ix_ele+1, branch_out%ix_branch, orbit_out) call insert_element (lat_out, taylor_ele, ix_ele+2, branch_out%ix_branch, orbit_out) call insert_element (lat_out, drift_ele, ix_ele+3, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 2 cycle ! Non matrix model... @@ -554,7 +536,6 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or call insert_element (lat_out, lat_model%ele(j), ix_ele+j, branch_out%ix_branch, orbit_out) enddo - ie2 = ie2 + lat_model%n_ele_track - 1 cycle endif endif @@ -563,11 +544,11 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ! For a patch that is *not* associated with the edge of a solenoid: A z_offset must be split into a drift + patch -ix_ele = ie1 - 1 +ix_ele = 0 do ix_ele = ix_ele + 1 - if (ix_ele > ie2) exit + if (ix_ele > branch_out%n_ele_track) exit ele => branch_out%ele(ix_ele) if (ele%key == -1) cycle @@ -623,7 +604,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or select case (out_type) case ('MAD-8', 'MAD-X', 'XSIF') - ele => branch_out%ele(ie1-1) + ele => branch_out%ele(0) write (line_out, '(7a)') 'beam_def: Beam, Particle = ', trim(species_name(branch_out%param%particle)), & ', Energy = ', re_str(1d-9*ele%value(E_TOT$)), ', Npart = ', re_str(branch_out%param%n_part), trim(eol_char) @@ -634,11 +615,11 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ! write element parameters n_names = 0 ! number of names stored in the list -ix_ele = ie1 - 1 +ix_ele = 0 -do ! ix_ele = 1e1, ie2 +do ix_ele = ix_ele + 1 - if (ix_ele > ie2) exit + if (ix_ele > branch_out%n_ele_track) exit ele => branch_out%ele(ix_ele) if (ele%key == -1) cycle @@ -857,7 +838,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ab_ele%name = trim(orig_name) // '__' // int_str(i) write (line_out, '(2a)') trim(ab_ele%name) // ': mult' call insert_element(lat_out, ab_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1; ix_ele = ix_ele + 1 + ix_ele = ix_ele + 1 call value_to_line (line_out, knl(i), 'knl', 'R') call value_to_line (line_out, tilts(i), 'tilt', 'R') line_out = trim(line_out) // ', order = ' // int_str(i) @@ -1211,7 +1192,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or if (val(x_offset$) /= 0 .or. val(y_offset$) /= 0 .or. val(z_offset$) /= 0) then drift_ele%name = trim(orig_name) // '__t' call insert_element(lat_out, drift_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1; ix_ele = ix_ele + 1 + ix_ele = ix_ele + 1 line_out = trim(drift_ele%name) // ': translation' call value_to_line (line_out, val(x_offset$), 'dx', 'R') call value_to_line (line_out, val(y_offset$), 'dy', 'R') @@ -1222,21 +1203,21 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or if (val(x_pitch$) /= 0) then drift_ele%name = trim(orig_name) // '__y' call insert_element(lat_out, drift_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1; ix_ele = ix_ele + 1 + ix_ele = ix_ele + 1 call write_line(trim(drift_ele%name) // ': yrotation, angle = ' // re_str(-val(x_pitch$))) endif if (val(y_pitch$) /= 0) then drift_ele%name = trim(orig_name) // '__x' call insert_element(lat_out, drift_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1; ix_ele = ix_ele + 1 + ix_ele = ix_ele + 1 call write_line(trim(drift_ele%name) // ': xrotation, angle = ' // re_str(-val(y_pitch$))) endif if (val(tilt$) /= 0) then drift_ele%name = trim(orig_name) // '__s' call insert_element(lat_out, drift_ele, ix_ele+1, branch_out%ix_branch, orbit_out) - ie2 = ie2 + 1; ix_ele = ix_ele + 1 + ix_ele = ix_ele + 1 call write_line(trim(drift_ele%name) // ': srotation, angle = ' // re_str(val(tilt$))) endif @@ -1426,7 +1407,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or init_needed = .true. line = ' ' -do n = ie1, ie2 +do n = 1, branch_out%n_ele_track ele => branch_out%ele(n) if (ele%key == null_ele$) cycle ! Will happen with patch elements translated to MAD-X if (ele%key == -1) cycle @@ -1455,7 +1436,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ! Output line if long enough or at end - if (n == ie2 .or. iout > 48) then + if (n == branch_out%n_ele_track .or. iout > 48) then line_out = trim(line_out) // ')' write (iu, '(2a)') trim(line_out), trim(eol_char) line_out = ' ' @@ -1499,7 +1480,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or allocate (n_repeat(n_names)) n_repeat = 0 - do ix_ele = ie1, ie2 + do ix_ele = 1, branch_out%n_ele_track ele => branch_out%ele(ix_ele) val => ele%value @@ -1540,7 +1521,7 @@ subroutine write_lattice_in_foreign_format (out_type, out_file_name, lat, ref_or ! Write twiss parameters for a non-closed lattice. if (branch_out%param%geometry == open$ .and. (out_type == 'MAD-8' .or. out_type == 'MAD-X' .or. out_type == 'XSIF')) then - ele => branch_out%ele(ie1-1) + ele => branch_out%ele(0) orb_start = lat%particle_start beta = ele%value(p0c$) / ele%value(E_tot$) write (iu, '(a)') diff --git a/code_examples/mpi_mp/mpi_mp.f90 b/code_examples/mpi_mp/mpi_mp.f90 index 0344f10e6e..4a58bfbe78 100644 --- a/code_examples/mpi_mp/mpi_mp.f90 +++ b/code_examples/mpi_mp/mpi_mp.f90 @@ -16,7 +16,7 @@ program mpi_mp logical master -real(8) myx, myx_powers(npowers) +real(8) myx(1), myx_powers(npowers) real(8), allocatable :: x(:), x_powers(:,:) call mpi_init(mpierr) ! Introduce yourself to the MPI daemon @@ -80,6 +80,8 @@ program mpi_mp write(*,'(i14,20f14.5)') i, x(i), x_powers(i,:) enddo else + ! Note: myx must be a vector since call to mpi_recv above uses a vector and gfortran + ! can flag this as an error. call mpi_recv(myx, 1, MPI_DOUBLE_PRECISION, 0, 1, MPI_COMM_WORLD, mpistatus, mpierr) thread_check = -8088 @@ -88,7 +90,7 @@ program mpi_mp !$OMP SHARED(myx,myx_powers,thread_check) do i=1,npowers thread_check(omp_get_thread_num()+1) = omp_get_thread_num() - myx_powers(i) = myx**i + myx_powers(i) = myx(1)**i enddo !$OMP END PARALLEL DO write(*,'(a,i3,a,20i3)') "mpi slave: ", myrank, " has omp thread numbers: ", thread_check diff --git a/tao/version/tao_version_mod.f90 b/tao/version/tao_version_mod.f90 index 94779800f9..ed30f4aac6 100644 --- a/tao/version/tao_version_mod.f90 +++ b/tao/version/tao_version_mod.f90 @@ -6,5 +6,5 @@ !- module tao_version_mod -character(*), parameter :: tao_version_date = "2024/08/18 18:29:54" +character(*), parameter :: tao_version_date = "2024/08/24 21:18:45" end module diff --git a/util_programs/bmad_to_mad_sad_elegant/bmad_to_mad_sad_elegant.f90 b/util_programs/bmad_to_mad_sad_elegant/bmad_to_mad_sad_elegant.f90 index df7a6e32c8..6730f53e38 100644 --- a/util_programs/bmad_to_mad_sad_elegant/bmad_to_mad_sad_elegant.f90 +++ b/util_programs/bmad_to_mad_sad_elegant/bmad_to_mad_sad_elegant.f90 @@ -97,6 +97,7 @@ program bmad_to_mad_sad_elegant ! Get the lattice call file_suffixer (file_name, file_name, 'bmad', .false.) +bmad_com%auto_bookkeeper = .false. call bmad_parser (file_name, lat) if (out_type /= '-sad') then call twiss_and_track (lat, orbit, status, use_particle_start = .true.)