subroutine set_params(line, do_all_universes, u_in, graph, err_flag) use cesrv_struct use cesrv_interface use super_universe_com use nonlin_bpm_mod use radiation_mod use bookkeeper_mod, only: set_on_off implicit none type (universe_struct), target :: u_in type (universe_struct), pointer :: u type (logic_struct) logic_saved type (graph_struct) graph real(rp) tw, cw, bw, pw, kw, sw, ow, custom_wgt, ew, exw, eyw, bxw, byw real(rp) energy_wgt, oxw, oyw, rtw, h_sep_wgt, v_sep_wgt real(rp) eta_x_wgt, eta_y_wgt, skew_wgt, n_part, beta_a_wgt, beta_b_wgt real(rp) phase_x_wgt, phase_y_wgt, tune_x_wgt, tune_y_wgt, beta_wgt real(rp) change_min, cbar12_wgt, opt_tolerance, orbit_x_wgt, orbit_y_wgt real(rp) k_wgt, k1_wgt, k2_wgt, steering_wgt, orbit_wgt real(rp) cbar11_wgt, cbar22_wgt, ac_eta_x_wgt, ac_eta_y_wgt real(rp) horizontal_wgt, vertical_wgt, hw, vw, x_kick_quad_wgt, y_kick_quad_wgt real(rp) chrom_wgt, var_wgt, skew_k2_wgt, num real(rp) bpm_tilt_wgt, mode_eta_x_wgt, mode_eta_y_wgt real(rp) cmat_a22_wgt, cmat_a12_wgt, cmat_b11_wgt, cmat_b12_wgt real(rp) q2x_out_wgt, q2x_in_wgt, q2y_out_wgt, q2y_in_wgt real(rp) qx_plus_qy_out_wgt, qx_plus_qy_in_wgt, qx_minus_qy_out_wgt, qx_minus_qy_in_wgt real(rp) q2x_wgt, q2y_wgt, qx_plus_qy_wgt, qx_minus_qy_wgt real(rp) q2_wgt, qx_wgt, q_wgt, q_in_wgt, q_out_wgt, xray_wgt, e_xray_wgt, p_xray_wgt integer i integer opt_loops, opt_cycles, ix, ixe integer ix_a(2), ix_b(2), ix_a1, ix_a2, ix_b1, ix_b2 character(*) line character(1) set_type character(60) str character(140) file_name logical do_all_universes, err_flag namelist / model_parameters / eta_x_wgt, eta_y_wgt, skew_wgt, & phase_x_wgt, phase_y_wgt, tune_x_wgt, tune_y_wgt, logic, & opt_loops, opt_cycles, change_min, bpm_tilt_wgt, mode_eta_x_wgt, mode_eta_y_wgt, & ix_a1, ix_a2, ix_b1, ix_b2, ix_a, ix_b, kw, custom_wgt, exw, eyw, & cbar12_wgt, opt_tolerance, ow, sw, tw, cw, bw, pw, n_part, & k_wgt, k1_wgt, k2_wgt, steering_wgt, orbit_wgt, energy_wgt, ew, & orbit_x_wgt, orbit_y_wgt, oxw, oyw, bxw, byw, beta_a_wgt, beta_b_wgt, & beta_wgt, rtw, h_sep_wgt, v_sep_wgt, cbar11_wgt, cbar22_wgt, & horizontal_wgt, vertical_wgt, hw, vw, ac_eta_x_wgt, ac_eta_y_wgt, & chrom_wgt, var_wgt, skew_k2_wgt, nonlin_bpm_use_coeff, & cmat_a22_wgt, cmat_a12_wgt, cmat_b11_wgt, cmat_b12_wgt, q2x_out_wgt, q2x_in_wgt, & x_kick_quad_wgt, y_kick_quad_wgt, q2y_out_wgt, q2y_in_wgt, & qx_plus_qy_out_wgt, qx_plus_qy_in_wgt, qx_minus_qy_out_wgt, qx_minus_qy_in_wgt, & q2x_wgt, q2y_wgt, qx_plus_qy_wgt, qx_minus_qy_wgt, & q2_wgt, qx_wgt, q_wgt, q_in_wgt, q_out_wgt, xray_wgt, e_xray_wgt, p_xray_wgt ! xray_wgt = -1; e_xray_wgt = -1; p_xray_wgt = -1 chrom_wgt = -1; var_wgt = -1; skew_k2_wgt = -1 kw = -1; tw = -1; cw = -1; bw = -1; pw = -1; ew = -1 sw = -1; ow = -1; ix_a = -1; ix_b = -1; vw = -1 beta_wgt = -1; rtw = -1; h_sep_wgt = -1; v_sep_wgt = -1 exw = -1; eyw = -1; bxw = -1; byw = -1; beta_a_wgt = -1; beta_b_wgt = -1 opt_loops = -1; opt_cycles = -1; opt_tolerance = -1; n_part = -1 change_min = -1; phase_x_wgt = -1; phase_y_wgt = -1; tune_x_wgt = -1 tune_y_wgt = -1; cbar12_wgt = -1; k_wgt = -1; k1_wgt = -1 k2_wgt = -1; steering_wgt = -1; orbit_wgt = -1 ix_a1 = -1; ix_a2 = -1; ix_b1 = -1; ix_b2 = -1; energy_wgt = -1 eta_x_wgt = -1; eta_y_wgt = -1; skew_wgt = -1 orbit_x_wgt = -1; orbit_y_wgt = -1; oxw = -1; oyw = -1 custom_wgt = -1; ac_eta_x_wgt = -1; ac_eta_y_wgt = -1 horizontal_wgt = -1; vertical_wgt = -1; hw = -1; vw = -1 cbar11_wgt = -1; cbar22_wgt = -1 mode_eta_x_wgt = -1; mode_eta_y_wgt = -1 bpm_tilt_wgt = -1; q2x_out_wgt = -1; q2x_in_wgt = -1 cmat_a22_wgt = -1; cmat_a12_wgt = -1; cmat_b11_wgt = -1; cmat_b12_wgt = -1 x_kick_quad_wgt = -1; y_kick_quad_wgt = -1 q2y_out_wgt = -1; q2y_in_wgt = -1 qx_plus_qy_out_wgt = -1; qx_plus_qy_in_wgt = -1; qx_minus_qy_out_wgt = -1; qx_minus_qy_in_wgt = -1 q2x_wgt = -1; q2y_wgt = -1; qx_plus_qy_wgt = -1; qx_minus_qy_wgt = -1 q2_wgt = -1; qx_wgt = -1; q_wgt = -1; q_in_wgt = -1; q_out_wgt = -1 ! switch "2q" to "q2" ixe = index(line, '=') ix = max(index(line, '2q'), index(line, '2Q')) if (ix /= 0 .and. ix < ixe) line(ix:ix+1) = 'Q2' ix = max(index(line, 'qx+qy'), index(line, 'QX+QY')) if (ix /= 0 .and. ix < ixe) line = line(:ix-1) // 'QX_PLUS_QY' // line(ix+5:) ix = max(index(line, 'qx-qy'), index(line, 'QX-QY')) if (ix /= 0 .and. ix < ixe) line = line(:ix-1) // 'QX_MINUS_QY' // line(ix+5:) ! look for "*=" or "/=" if (index(line, '*=') /= 0) then ix = index(line, '*=') line(ix:ix) = ' ' set_type = '*' elseif (index(line, '/=') /= 0) then ix = index(line, '/=') line(ix:ix) = ' ' set_type = '/' else set_type = '-' endif call string_trim (line, line, ix) ! if (downcase(line(1:ixe-1)) == 'logic%ac_eta_type') then call string_trim(line(ixe+1:), line, ix) call match_word2 (line, ac_eta_type_name, ix) if (ix < 1) then print '(2a,10a10)', 'BAD AC_ETA_TYPE NAME', 'Possibilities are: ',(ac_eta_type_name(i),i=1,size(ac_eta_type_name)) return else logic%ac_eta_type = ix endif call set_this_ac_eta_plot (graph%bottom1) call set_this_ac_eta_plot (graph%top1) return endif ! loop over all universes err_flag = .false. if (do_all_universes) then do i = 1, logic%u_num u => super%u_(i) call set_one_uni() if (err_flag) return enddo else u => u_in call set_one_uni() do i = 1, logic%u_num u => super%u_(i) u%var(:)%weight = u_in%var(:)%weight enddo endif !--------------------------------------------------------- contains subroutine set_one_uni() ! This section is for setting individual elements in an array. ix = index(line, '(') if (ix /= 0) then call str_upcase (line(:ix-1), line(:ix-1)) select case (line(:ix-1)) case ('HSTEER_WGT') call set_vector ('HSTEER_WGT', lbound(u%hsteer_kick%v, 1), u%hsteer_kick%v(:)%weight, & 1.0_rp, line(ix+1:), u%hsteer_kick%v(:)%dvar_dcu) case ('VSTEER_WGT') call set_vector ('VSTEER_WGT', lbound(u%vsteer_kick%v, 1), u%vsteer_kick%v(:)%weight, & 1.0_rp, line(ix+1:), u%hsteer_kick%v(:)%dvar_dcu) case ('VAR_WGT') call set_vector ('VAR_WGT', lbound(u%custom_var%v, 1), u%custom_var%v(:)%weight, 1.0_rp, line(ix+1:)) case ('QUAD_K1_WGT') call set_vector ('QUAD_K1_WGT', lbound(u%quad_k1%v, 1), u%quad_k1%v(:)%weight, 1.0_rp, line(ix+1:)) case ('BPM_TILT_WGT') call set_vector ('BPM_TILT_WGT', lbound(u%bpm_tilt%v, 1), u%bpm_tilt%v(:)%weight, 1.0_rp, line(ix+1:)) case ('SEX_K2_WGT') call set_vector ('SEX_K2_WGT', lbound(u%sex_k2%v, 1), u%sex_k2%v(:)%weight, 1.0_rp, line(ix+1:)) case ('ORBIT_X') call set_vector ('ORBIT_X', lbound(u%orbit%x%d, 1), u%orbit%x%d(:)%meas, 1e-3_rp, line(ix+1:)) call plotdo ('X', graph, .false., u) case ('ORBIT_Y') call set_vector ('ORBIT_Y', lbound(u%orbit%y%d, 1), u%orbit%y%d(:)%meas, 1e-3_rp, line(ix+1:)) call plotdo ('X', graph, .false., u) case ('REF_ORBIT_X') call set_vector ('REF_ORBIT_X', lbound(u%orbit%x%d, 1), u%orbit%x%d(:)%ref, 1e-3_rp, line(ix+1:)) ! Saved ref values do not make sense now so set to zero. print *, 'Note: setting steering saved reference values to 0!' u%hsteer_kick%v%saved_ref = 0 u%hsteer_kick%v%cu_saved_ref = 0 u%vsteer_kick%v%saved_ref = 0 u%vsteer_kick%v%cu_saved_ref = 0 call plotdo ('X', graph, .false., u) case ('REF_ORBIT_Y') call set_vector ('REF_ORBIT_Y', lbound(u%orbit%y%d, 1), u%orbit%y%d(:)%ref, 1e-3_rp, line(ix+1:)) ! Saved ref values do not make sense now so set to zero. print *, 'Note: setting steering saved reference values to 0!' u%hsteer_kick%v%saved_ref = 0 u%hsteer_kick%v%cu_saved_ref = 0 u%vsteer_kick%v%saved_ref = 0 u%vsteer_kick%v%cu_saved_ref = 0 call plotdo ('X', graph, .false., u) case ('ORBIT_X_WGT') call set_vector ('ORBIT_X_WGT', lbound(u%orbit%x%d, 1), u%orbit%x%d(:)%weight, 1.0_rp, line(ix+1:)) case ('ORBIT_Y_WGT') call set_vector ('ORBIT_Y_WGT', lbound(u%orbit%y%d, 1), u%orbit%y%d(:)%weight, 1.0_rp, line(ix+1:)) case ('PHASE_X_WGT') call set_vector ('PHASE_X_WGT', lbound(u%phase%x%d, 1), u%phase%x%d(:)%weight, 1.0_rp, line(ix+1:)) case ('PHASE_Y_WGT') call set_vector ('PHASE_Y_WGT', lbound(u%phase%y%d, 1), u%phase%y%d(:)%weight, 1.0_rp, line(ix+1:)) case ('ETA_X_WGT') call set_vector ('ETA_X_WGT', lbound(u%eta%x%d, 1), u%eta%x%d(:)%weight, 1.0_rp, line(ix+1:)) case ('ETA_Y_WGT') call set_vector ('ETA_Y_WGT', lbound(u%eta%y%d, 1), u%eta%y%d(:)%weight, 1.0_rp, line(ix+1:)) case ('AC_ETA_X_WGT') call set_vector ('AC_ETA_X_WGT', lbound(u%ac_eta%x%d, 1), u%ac_eta%x%d(:)%weight, 1.0_rp, line(ix+1:)) case ('AC_ETA_Y_WGT') call set_vector ('AC_ETA_Y_WGT', lbound(u%ac_eta%y%d, 1), u%ac_eta%y%d(:)%weight, 1.0_rp, line(ix+1:)) case ('BETA_A_WGT') call set_vector ('BETA_A_WGT', lbound(u%beta%x%d, 1), u%beta%x%d(:)%weight, 1.0_rp, line(ix+1:)) case ('BETA_B_WGT') call set_vector ('BETA_B_WGT', lbound(u%beta%y%d, 1), u%beta%y%d(:)%weight, 1.0_rp, line(ix+1:)) case ('CBAR12_WGT') call set_vector ('CBAR12_WGT', lbound(u%cbar%m12%d, 1), u%cbar%m12%d(:)%weight, 1.0_rp, line(ix+1:)) case ('CBAR22_WGT') call set_vector ('CBAR22_WGT', lbound(u%cbar%m22%d, 1), u%cbar%m22%d(:)%weight, 1.0_rp, line(ix+1:)) case ('CBAR11_WGT') call set_vector ('CBAR11_WGT', lbound(u%cbar%m11%d, 1), u%cbar%m11%d(:)%weight, 1.0_rp, line(ix+1:)) case default print *, 'ERROR: UNKNOWN PARAMETER: ' // line(:ix-1) err_flag = .true. end select return endif !------------------------------------------ ! This section for *not* setting individual elements of an array... ! That is, setting a variable in the model_parameters namelist defined above. ! First open a scratch file for a namelist read logic_saved = logic open (1, status = 'scratch', recl = 240) write (1, *) '&model_parameters' write (1, *) ' ', line write (1, *) '/end' rewind (1) read (1, nml = model_parameters, err = 9020, end = 9020) close (1) ! Special code for some special cases. if (logic%ac_eta_freq_range < 1 .or. logic%ac_eta_freq_range > 2) then print *, 'LOGIC%AC_ETA_FREQ_RANGE NUMBER OUT OF RANGE: ', logic%ac_eta_freq_range logic = logic_saved return endif ! Setting the species involves some bookkeeping... if (logic%beam_species /= logic_saved%beam_species) then if (logic%beam_species /= -1 .and. logic%beam_species /= 1) then print *, 'LOGIC%BEAM_SPECIES MUST BE SET TO -1 OR 1.' logic%beam_species = logic_saved%beam_species return endif call set_species (ix, err_flag) return endif if (hw >= 0) horizontal_wgt = hw if (vw >= 0) vertical_wgt = vw if (index(line, 'LOGIC%RADIATION_ON') /= 0) then logic%rf_on = logic%radiation_on call set_on_off (rfcavity$, u%ring, on_off_int(logic%rf_on), u%orb) bmad_com%radiation_damping_on = logic%radiation_on print *, 'Damping and RF are now: ', on_off(logic%radiation_on) endif if (index(line, 'LOGIC%') /= 0) return if (index(line, 'NONLIN_BPM_USE_COEFF') /= 0) return ! Setting of weights, etc. if (ew >= 0) energy_wgt = ew if (energy_wgt >= 0) then call set_this ('Energy_wgt', u%energy_data%d1%d(1)%weight, energy_wgt) elseif (opt_loops >= 0) then logic%opt_loops = opt_loops elseif (opt_cycles >= 0) then logic%opt_cycles = opt_cycles elseif (opt_tolerance >= 0) then call set_this ('Opt_tolerance', logic%opt_tolerance, opt_tolerance) elseif (change_min >= 0) then call set_this ('Change_min', logic%change_min, change_min) elseif (phase_x_wgt >= 0) then call set_this2 ('Phase_x_wgt', u%phase%x%d(:)%weight, phase_x_wgt) elseif (phase_y_wgt >= 0) then call set_this2 ('Phase_y_wgt', u%phase%y%d(:)%weight, phase_y_wgt) elseif (x_kick_quad_wgt >= 0) then call set_this2 ('X_kick_quad_wgt', u%x_kick_quad%v(:)%weight, x_kick_quad_wgt) elseif (y_kick_quad_wgt >= 0) then call set_this2 ('Y_kick_quad_wgt', u%y_kick_quad%v(:)%weight, y_kick_quad_wgt) elseif (eta_x_wgt >= 0) then call set_this2 ('Eta_x_wgt', u%eta%x%d(:)%weight, eta_x_wgt) elseif (eta_y_wgt >= 0) then call set_this2 ('Eta_y_wgt', u%eta%y%d(:)%weight, eta_y_wgt) elseif (ac_eta_x_wgt >= 0) then call set_this2 ('Ac_eta_x_wgt', u%ac_eta%x%d(:)%weight, ac_eta_x_wgt) elseif (ac_eta_y_wgt >= 0) then call set_this2 ('Ac_eta_y_wgt', u%ac_eta%y%d(:)%weight, ac_eta_y_wgt) elseif (mode_eta_x_wgt >= 0) then call set_this2 ('Mode_eta_x_wgt', u%mode_eta%x%d(:)%weight, mode_eta_x_wgt) elseif (mode_eta_y_wgt >= 0) then call set_this2 ('Mode_eta_y_wgt', u%mode_eta%y%d(:)%weight, mode_eta_y_wgt) elseif (orbit_wgt >= 0) then call set_this2 ('Orbit_x_wgt', u%orbit%x%d(:)%weight, orbit_wgt) call set_this2 ('Orbit_y_wgt', u%orbit%y%d(:)%weight, orbit_wgt) elseif (xray_wgt >= 0) then call set_this2 ('E_XRay_x_wgt', u%e_xray%x%d(:)%weight, xray_wgt) call set_this2 ('E_XRay_y_wgt', u%e_xray%y%d(:)%weight, xray_wgt) elseif (e_xray_wgt >= 0) then call set_this2 ('E_XRay_x_wgt', u%e_xray%x%d(:)%weight, e_xray_wgt) call set_this2 ('E_XRay_y_wgt', u%e_xray%y%d(:)%weight, e_xray_wgt) elseif (p_xray_wgt >= 0) then call set_this2 ('P_XRay_x_wgt', u%p_xray%x%d(:)%weight, p_xray_wgt) call set_this2 ('P_XRay_y_wgt', u%p_xray%y%d(:)%weight, p_xray_wgt) elseif (orbit_x_wgt >= 0) then call set_this2 ('Orbit_x_wgt', u%orbit%x%d(:)%weight, orbit_x_wgt) elseif (orbit_y_wgt >= 0) then call set_this2 ('Orbit_y_wgt', u%orbit%y%d(:)%weight, orbit_y_wgt) elseif (chrom_wgt >= 0) then call set_this2 ('Chrom_wgt', u%chrom%x%d(:)%weight, chrom_wgt) call set_this2 ('Chrom_wgt', u%chrom%y%d(:)%weight, chrom_wgt) elseif (var_wgt >= 0) then call set_this2 ('VAR_wgt', u%custom_var%v(:)%weight, var_wgt) elseif (k_wgt >= 0) then call set_this2 ('K1_wgt', u%quad_k1%v(:)%weight, k_wgt) elseif (k1_wgt >= 0) then call set_this2 ('K1_wgt', u%quad_k1%v(:)%weight, k1_wgt) elseif (skew_wgt >= 0) then call set_this2 ('Skew_wgt', u%skew_quad_k1%v(:)%weight, skew_wgt) elseif (skew_k2_wgt >= 0) then call set_this2 ('Skew_k2_wgt', u%skew_sex_k2%v(:)%weight, skew_k2_wgt) elseif (k2_wgt >= 0) then call set_this2 ('K2_wgt', u%sex_k2%v(:)%weight, k2_wgt) elseif (steering_wgt >= 0) then call set_this3 ('Horiz_wgt', u%hsteer_kick%v(:)%weight, steering_wgt, u%hsteer_kick%v(:)%dvar_dcu) call set_this3 ('Vert_wgt', u%vsteer_kick%v(:)%weight, steering_wgt, u%vsteer_kick%v(:)%dvar_dcu) u%hsteer_kick%v(101:)%weight = 0 ! hard bends do not have a weight elseif (h_sep_wgt >= 0) then call set_this2 ('H_sep_wgt', u%hsep_kick%v(:)%weight, h_sep_wgt) elseif (bpm_tilt_wgt >= 0) then call set_this2 ('bpm_tilt_wgt', u%bpm_tilt%v(:)%weight, bpm_tilt_wgt) elseif (kw >= 0) then if (logic%opt_vars == opt_sex$) then call set_this2 ('K2_wgt', u%sex_k2%v(:)%weight, kw) else call set_this2 ('K1_wgt', u%quad_k1%v(:)%weight, kw) endif elseif (cw >= 0) then call set_this2 ('Cbar12_wgt', u%cbar%m12%d(:)%weight, cw) elseif (sw >= 0) then if (logic%opt_vars == opt_steering$) then call set_this3 ('Horizontal_wgt', u%hsteer_kick%v(:)%weight, sw, u%hsteer_kick%v%dvar_dcu) call set_this3 ('Vertical_wgt', u%vsteer_kick%v(:)%weight, sw, u%vsteer_kick%v%dvar_dcu) u%hsteer_kick%v(101:)%weight = 0 ! hard bends do not have a weight elseif (logic%opt_vars == opt_sex$) then call set_this2 ('K2_wgt', u%sex_k2%v(:)%weight, sw) else call set_this2 ('Skew_wgt', u%skew_quad_k1%v(:)%weight, sw) endif elseif (custom_wgt >= 0) then call set_this2 ('Custom_wgt', u%custom_var%v(:)%weight, custom_wgt) elseif (horizontal_wgt >= 0) then call set_this3 ('Horizontal_wgt', u%hsteer_kick%v(:)%weight, & horizontal_wgt, u%hsteer_kick%v%dvar_dcu) elseif (vertical_wgt >= 0) then call set_this3 ('Vertical_wgt', u%vsteer_kick%v(:)%weight, & vertical_wgt, u%vsteer_kick%v%dvar_dcu) elseif (oxw >= 0) then call set_this2 ('Orbit_x_wgt', u%orbit%x%d(:)%weight, oxw) elseif (oyw >= 0) then call set_this2 ('Orbit_y_wgt', u%orbit%y%d(:)%weight, oyw) elseif (tune_x_wgt >= 0) then call set_this2 ('Tune_x_wgt', u%tune%x%d(:)%weight, tune_x_wgt) elseif (tune_y_wgt >= 0) then call set_this2 ('Tune_y_wgt', u%tune%y%d(:)%weight, tune_y_wgt) elseif (cbar12_wgt >= 0) then call set_this2 ('Cbar12_wgt', u%cbar%m12%d(:)%weight, cbar12_wgt) elseif (cbar11_wgt >= 0) then call set_this2 ('Cbar11_wgt', u%cbar%m11%d(:)%weight, cbar11_wgt) elseif (cbar22_wgt >= 0) then call set_this2 ('Cbar22_wgt', u%cbar%m22%d(:)%weight, cbar22_wgt) elseif (cmat_a22_wgt >= 0) then call set_this2 ('Cmat_a22_wgt', u%cmat_a%m22%d(:)%weight, cmat_a22_wgt) elseif (cmat_a12_wgt >= 0) then call set_this2 ('Cmat_a12_wgt', u%cmat_a%m12%d(:)%weight, cmat_a12_wgt) elseif (cmat_b11_wgt >= 0) then call set_this2 ('Cmat_b11_wgt', u%cmat_b%m11%d(:)%weight, cmat_b11_wgt) elseif (cmat_b12_wgt >= 0) then call set_this2 ('Cmat_b12_wgt', u%cmat_b%m12%d(:)%weight, cmat_b12_wgt) elseif (exw >= 0) then call set_this2 ('Eta_x_wgt', u%eta%x%d(:)%weight, exw) elseif (eyw >= 0) then call set_this2 ('Eta_y_wgt', u%eta%y%d(:)%weight, eyw) elseif (tw >= 0) then call set_this2 ('Tune_x_wgt', u%tune%x%d(:)%weight, tw) call set_this2 ('Tune_y_wgt', u%tune%y%d(:)%weight, tw) elseif (pw >= 0) then call set_this2 ('Phase_x_wgt', u%phase%x%d(:)%weight, pw) call set_this2 ('Phase_y_wgt', u%phase%y%d(:)%weight, pw) elseif (q2x_in_wgt >= 0) then call set_this2 ('2qx_in_wgt', u%q2x%a_in%d(:)%weight, q2x_in_wgt) elseif (q2x_out_wgt >= 0) then call set_this2 ('2qx_out_wgt', u%q2x%a_out%d(:)%weight, q2x_out_wgt) elseif (q2y_in_wgt >= 0) then call set_this2 ('2qy_in_wgt', u%q2y%a_in%d(:)%weight, q2y_in_wgt) elseif (q2y_out_wgt >= 0) then call set_this2 ('2qy_out_wgt', u%q2y%a_out%d(:)%weight, q2y_out_wgt) elseif (qx_plus_qy_in_wgt >= 0) then call set_this2 ('qx_plus_qy_in_wgt', u%qx_plus_qy%a_in%d(:)%weight, qx_plus_qy_in_wgt) elseif (qx_plus_qy_out_wgt >= 0) then call set_this2 ('qx_plus_qy_out_wgt', u%qx_plus_qy%a_out%d(:)%weight, qx_plus_qy_out_wgt) elseif (qx_minus_qy_in_wgt >= 0) then call set_this2 ('qx_minux_qy_in_wgt', u%qx_minus_qy%a_in%d(:)%weight, qx_minus_qy_in_wgt) elseif (qx_minus_qy_out_wgt >= 0) then call set_this2 ('qx_minus_qy_out_wgt', u%qx_minus_qy%a_out%d(:)%weight, qx_minus_qy_out_wgt) elseif (q2x_wgt >= 0) then call set_this2 ('2qx_in_wgt', u%q2x%a_in%d(:)%weight, q2x_wgt) call set_this2 ('2qx_out_wgt', u%q2x%a_out%d(:)%weight, q2x_wgt) elseif (q2y_wgt >= 0) then call set_this2 ('2qy_in_wgt', u%q2y%a_in%d(:)%weight, q2y_wgt) call set_this2 ('2qy_out_wgt', u%q2y%a_out%d(:)%weight, q2y_wgt) elseif (qx_plus_qy_wgt >= 0) then call set_this2 ('qx_plus_qy_in_wgt', u%qx_plus_qy%a_in%d(:)%weight, qx_plus_qy_wgt) call set_this2 ('qx_plus_qy_out_wgt', u%qx_plus_qy%a_out%d(:)%weight, qx_plus_qy_wgt) elseif (qx_minus_qy_wgt >= 0) then call set_this2 ('qx_minus_qy_in_wgt', u%qx_minus_qy%a_in%d(:)%weight, qx_minus_qy_wgt) call set_this2 ('qx_minus_qy_out_wgt', u%qx_minus_qy%a_out%d(:)%weight, qx_minus_qy_wgt) elseif (q2_wgt >= 0) then call set_this2 ('2qx_in_wgt', u%q2x%a_in%d(:)%weight, q2_wgt) call set_this2 ('2qx_out_wgt', u%q2x%a_out%d(:)%weight, q2_wgt) call set_this2 ('2qy_in_wgt', u%q2y%a_in%d(:)%weight, q2_wgt) call set_this2 ('2qy_out_wgt', u%q2y%a_out%d(:)%weight, q2_wgt) elseif (qx_wgt >= 0) then call set_this2 ('qx_plus_qy_in_wgt', u%qx_plus_qy%a_in%d(:)%weight, qx_wgt) call set_this2 ('qx_plus_qy_out_wgt', u%qx_plus_qy%a_out%d(:)%weight, qx_wgt) call set_this2 ('qx_minus_qy_in_wgt', u%qx_minus_qy%a_in%d(:)%weight, qx_wgt) call set_this2 ('qx_minus_qy_out_wgt', u%qx_minus_qy%a_out%d(:)%weight, qx_wgt) elseif (q_wgt >= 0) then call set_this2 ('2qx_in_wgt', u%q2x%a_in%d(:)%weight, q_wgt) call set_this2 ('2qx_out_wgt', u%q2x%a_out%d(:)%weight, q_wgt) call set_this2 ('2qy_in_wgt', u%q2y%a_in%d(:)%weight, q_wgt) call set_this2 ('2qy_out_wgt', u%q2y%a_out%d(:)%weight, q_wgt) call set_this2 ('qx_plus_qy_in_wgt', u%qx_plus_qy%a_in%d(:)%weight, q_wgt) call set_this2 ('qx_plus_qy_out_wgt', u%qx_plus_qy%a_out%d(:)%weight, q_wgt) call set_this2 ('qx_minus_qy_in_wgt', u%qx_minus_qy%a_in%d(:)%weight, q_wgt) call set_this2 ('qx_minus_qy_out_wgt', u%qx_minus_qy%a_out%d(:)%weight, q_wgt) elseif (q_in_wgt >= 0) then call set_this2 ('2qx_in_wgt', u%q2x%a_in%d(:)%weight, q_in_wgt) call set_this2 ('2qy_in_wgt', u%q2y%a_in%d(:)%weight, q_in_wgt) call set_this2 ('qx_plus_qy_in_wgt', u%qx_plus_qy%a_in%d(:)%weight, q_in_wgt) call set_this2 ('qx_minus_qy_in_wgt', u%qx_minus_qy%a_in%d(:)%weight, q_in_wgt) elseif (q_out_wgt >= 0) then call set_this2 ('2qx_out_wgt', u%q2x%a_out%d(:)%weight, q_out_wgt) call set_this2 ('2qy_out_wgt', u%q2y%a_out%d(:)%weight, q_out_wgt) call set_this2 ('qx_plus_qy_out_wgt', u%qx_plus_qy%a_out%d(:)%weight, q_out_wgt) call set_this2 ('qx_minus_qy_out_wgt', u%qx_minus_qy%a_out%d(:)%weight, q_out_wgt) elseif (beta_wgt >= 0) then call set_this2 ('Beta_a_wgt', u%beta%x%d(:)%weight, beta_wgt) call set_this2 ('Beta_b_wgt', u%beta%y%d(:)%weight, beta_wgt) elseif (beta_a_wgt >= 0) then call set_this2 ('Beta_a_wgt', u%beta%x%d(:)%weight, beta_a_wgt) elseif (beta_b_wgt >= 0) then call set_this2 ('Beta_b_wgt', u%beta%y%d(:)%weight, beta_b_wgt) elseif (bw >= 0) then call set_this2 ('Beta_a_wgt', u%beta%x%d(:)%weight, bw) call set_this2 ('Beta_b_wgt', u%beta%y%d(:)%weight, bw) elseif (bxw >= 0) then call set_this2 ('Beta_a_wgt', u%beta%x%d(:)%weight, bxw) elseif (byw >= 0) then call set_this2 ('Beta_b_wgt', u%beta%y%d(:)%weight, byw) elseif (ow >= 0) then call set_this2 ('Orbit_x_wgt', u%orbit%x%d(:)%weight, ow) call set_this2 ('Orbit_y_wgt', u%orbit%y%d(:)%weight, ow) elseif (ix_a(1) >= 0) then u%wave%ix_a1 = ix_a(1) u%wave%ix_a2 = ix_a(2) elseif (ix_b(1) >= 0) then u%wave%ix_b1 = ix_b(1) u%wave%ix_b2 = ix_b(2) elseif (ix_a1 >= 0) then u%wave%ix_a1 = ix_a1 elseif (ix_a2 >= 0) then u%wave%ix_a2 = ix_a2 elseif (ix_b1 >= 0) then u%wave%ix_b1 = ix_b1 elseif (ix_b2 >= 0) then u%wave%ix_b2 = ix_b2 elseif (n_part >= 0) then call set_this ('N_part', num, n_part) u%ring%param%n_part = num call plotdo ('X', graph, .false., u) endif ! return ! Here if namelist read failed 9020 print * print *, 'ERROR: CANNOT DECODE PARAMETER' close (1) err_flag = .true. end subroutine !--------------------------------------------------------------------------- ! contains subroutine set_this (who, weight, value) real(rp) weight, value character(*) who if (set_type == '*') then weight = weight * value elseif (set_type == '/') then weight = weight / value elseif (set_type == '-') then weight = value else print *, 'SET_PARAM INTERNAL ERROR!' call err_exit endif print '(3a, 1pe11.2)', ' Set: ', who, ' =', weight end subroutine !--------------------------------------------------------------------------- ! contains subroutine set_this2 (who, weight, value) real(rp) weight(:), value character(*) who if (set_type == '*') then weight = weight(1) * value elseif (set_type == '/') then weight = weight(1) / value elseif (set_type == '-') then weight = value else print *, 'SET_PARAM INTERNAL ERROR!' call err_exit endif print '(3a, 1pe11.2)', ' Set: ', who, ' =', weight(1) end subroutine set_this2 !--------------------------------------------------------------------------- ! contains subroutine set_this3 (who, weight, value, dvar_dcu) real(rp) weight(:), value, dvar_dcu(:) character(*) who if (set_type == '*') then where (dvar_dcu /= 0) weight = weight * value elseif (set_type == '/') then where (dvar_dcu /= 0) weight = weight / value elseif (set_type == '-') then where (dvar_dcu /= 0) weight = value / dvar_dcu**2 else print *, 'SET_PARAM INTERNAL ERROR!' call err_exit endif print '(3a, 1pe11.2)', ' Set: ', who, ' =', & sum(weight * dvar_dcu**2) / count(dvar_dcu /= 0) end subroutine !--------------------------------------------------------------------------- ! contains subroutine set_vector (who, lbnd, weight, scale, line, dvar_dcu) integer lbnd real(rp) weight(lbnd:), value real(rp), pointer :: pval(:) real(rp), optional :: dvar_dcu(lbnd:) real(rp) scale character(*) line, who character(40) line2, line3 integer j, ix1, ix2, ios ! j = index (line, ')') if (j == 0) then print *, 'ERROR: NO CLOSING ")".' err_flag = .true. return endif line2 = line(:j-1) line3 = line(j+1:) j = index (line2, ':') if (j == 0) then read (line2, *, iostat = ios) ix1 ix2 = ix1 else line2(j:j) = ' ' read (line2, *, iostat = ios) ix1, ix2 endif if (ios /= 0) then print *, 'ERROR READING ARRAY SUBSCRIPTS.' err_flag = .true. return endif if (ix2 < ix1) then print *, 'ERROR: 2ND ARRAY SUBSCRIPT LESS THAN THE FIRST!' err_flag = .true. return endif call string_trim (line3, line3, ix) if (line3(1:1) /= '=') then print *, 'ERROR: EXPECTED "=" AFTER ")". I AM CONFUSED.' err_flag = .true. return endif call string_trim (line3(2:), line3, ix) nullify(pval) select case (upcase(line3(1:ix))) case ('ORBIT_X'); pval(0:) => u%orbit%x%d(:)%meas case ('ORBIT_Y'); pval(0:) => u%orbit%y%d(:)%meas case ('REF_ORBIT_X'); pval(0:) => u%orbit%x%d(:)%ref case ('REF_ORBIT_Y'); pval(0:) => u%orbit%y%d(:)%ref case default read (line3, *, iostat = ios) value value = value * scale if (ios /= 0) then print *, 'ERROR READING VALUE' err_flag = .true. return endif end select call string_trim (line3(ix+1:), line3, ix) if (ix /= 0) then print *, 'ERROR: EXTRANEOUS CHARACTERS AT END OF LINE!' return endif select case (set_type) case ('*') weight(ix1:ix2) = weight(ix1:ix2) * value case ('/') weight(ix1:ix2) = weight(ix1:ix2) / value case ('-') if (associated(pval)) then weight(ix1:ix2) = pval(ix1:ix2) else weight(ix1:ix2) = value if (present(dvar_dcu)) then weight(ix1:ix2) = value * dvar_dcu(ix1:ix2)**2 else weight(ix1:ix2) = value endif endif case default print *, 'SET_PARAM INTERNAL ERROR!' call err_exit end select print '(3a, i3, a, i3, a)', ' Set: ', who, '(', ix1, ':', ix2, ')' end subroutine set_vector !--------------------------------------------------------------------------- ! contains subroutine set_this_ac_eta_plot (graph1) type (p2_plot_struct) graph1 ! if (graph1%d2%type == ac_eta_data$ .or. graph1%d2%type == ac_eta_yx_sincos$ .or. graph1%d2%type == ac_eta_c12$) then u => u_in select case (logic%ac_eta_type) case (c12$) call set_plot (graph1, u%ac_eta_c12) case (sincos$) call set_plot (graph1, u%ac_eta_yx) case (xy$) call set_plot (graph1, u%ac_eta) case default print *, 'internal error.' call err_exit endselect endif end subroutine set_this_ac_eta_plot end subroutine