subroutine baseline_set (what_base, action, plot_a, plot_b, do_set) use cesrv_struct use cesrv_interface implicit none type (p2_plot_struct) plot_a type (p2_plot_struct), optional :: plot_b integer what_base, action logical, optional :: do_set ! if (.not. logic_option (.false., do_set) .and. logic%plot_locked) return call base_set (plot_a) if (present(plot_b)) call base_set (plot_b) return !------------------------- contains subroutine base_set (p2) ! local implicit none type (p2_plot_struct), target :: p2 if (what_base == plot_model$ .and. action == subtract$) then if (p2%base == plot_ref_and_model$) then p2%base = plot_ref$ elseif (logic%opt_data == opt_twiss$) then if (p2%base == plot_model$) p2%base = plot_design$ else if (p2%base == plot_model$) p2%base = plot_none$ endif elseif (what_base == plot_ref$ .and. action == subtract$) then if (p2%base == plot_ref$) then p2%base = plot_design$ elseif (p2%base == plot_ref_and_model$) then p2%base = plot_model$ elseif (p2%base == plot_ref_and_model_and_base$) then p2%base = plot_model_and_base$ elseif (p2%base == plot_ref_and_fit$) then p2%base = plot_fit$ endif elseif (what_base == plot_model$ .and. action == add$) then if (p2%base == plot_ref$ .or. p2%base == plot_ref_and_model$) then p2%base = plot_ref_and_model$ else p2%base = plot_model$ endif elseif (what_base == plot_ref$ .and. action == add$) then if (p2%base == plot_model$ .or. p2%base == plot_ref_and_model$) then p2%base = plot_ref_and_model$ elseif (p2%base == plot_fit$ .or. p2%base == plot_ref_and_fit$) then p2%base = plot_ref_and_fit$ elseif (p2%base == plot_model_and_base$ .or. p2%base == plot_ref_and_model_and_base$) then p2%base = plot_ref_and_model_and_base$ else p2%base = plot_ref$ endif elseif (what_base == plot_model_and_base$ .and. action == add$) then if (p2%base == plot_ref$ .or. p2%base == plot_ref_and_model_and_base$) then p2%base = plot_ref_and_model_and_base$ else p2%base = plot_model_and_base$ endif elseif (what_base == plot_fit$ .and. action == add$) then if (p2%base == plot_ref$ .or. p2%base == plot_ref_and_fit$) then p2%base = plot_ref_and_fit$ else p2%base = plot_fit$ endif elseif (what_base == plot_design$ .and. action == subtract$) then if (p2%base == plot_design$) p2%base = plot_none$ elseif (what_base == plot_fit$ .and. action == subtract$) then if (p2%base == plot_fit$) then p2%base = plot_none$ elseif (p2%base == plot_ref_and_fit$) then p2%base = plot_ref$ endif elseif (action == add$) then p2%base = what_base elseif (action == set_to$) then p2%base = what_base else print *, 'INTERNAL ERROR IN BASELINE_SET!' call err_exit endif if (associated(p2%d2)) then p2%d2%p2 = p2 p2%d2%p2%plot1%p2 => p2%d2%p2 p2%d2%p2%plot2%p2 => p2%d2%p2 p2%d2%p2%plot3%p2 => p2%d2%p2 endif if (p2%where == 'TOP_PLOT' .and. .not. logic%opt_base_locked) logic%opt_base = p2%base end subroutine ! local end subroutine