!+ ! check_current (ok, current) ! ! Output: ! ok -- Logical: If False then calling routine should abort the measurement. ! current -- Real(rp), optional: Current in Amp. !- subroutine check_current (ok, current) use cesrv_struct use cesrv_interface use input_mod implicit none real(rp), optional :: current integer ix_train, cur, ipol, ix_mamp integer :: ix_train_to_mamp(9) = (/ 1, 21, 41, 62, 82, 102, 123, 143, 163 /) integer :: cur_min = 20 ! uA minimum current logical ok character(40) line ! ok = .true. do ! CSRBPM_COMD is set in the set_species routine. call vmgetn ('CSRBPM COMD ', 9, 9, ix_train) ix_mamp = ix_train_to_mamp(ix_train) call vmgetn ('CSRBPM COMD ', 8, 8, ipol) ! Right now can only check the 2ns mamp when looking at train 1. if (ipol == 1) then ! e+ call vxgetn ('CSR POS MAMP', ix_mamp, ix_mamp, cur) if (ix_train == 1 .and. cur < cur_min) call vxgetn ('POS 2NS MAMP', 1, 1, cur) else call vxgetn ('CSR ELE MAMP', ix_mamp, ix_mamp, cur) if (ix_train == 1 .and. cur < cur_min) call vxgetn ('ELE 2NS MAMP', 1, 1, cur) endif if (present(current)) current = cur * 1e-6 if (cur > cur_min) return ! print *, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' print *, '!!! THERE DOES NOT SEEM TO BE ANY CURRENT IN THE TRAIN LOOKED AT BY XETEC !!!' print *, '!!! [Note: SPECIES IS SET BY CESRV AND NOT CONTROLLED BY XETEC] !!!' print *, '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' print * if (logic%command_file_open) then call speech ('CESRV PROBLEM: THERE DOES NOT SEEM TO BE ANY CURRENT IN THE TRAIN LOOKED AT BY XETEC. ' // & 'PLEASE PROVIDE ASSISTANCE.') endif call read_a_line ('Do you want to CHECK again, ABORT, or GO ahead? (CR = CHECK)', line) call str_upcase(line, line) if (len_trim(line) == 0) cycle if (index('CHECK', trim(line)) == 1) cycle if (index('GO', trim(line)) == 1) return if (index('ABORT', trim(line)) == 1) then if (logic%command_file_open) then print *, 'TO BE SAFE I AM CLOSING THE COMMAND FILE...' close (logic%iu_command_file) logic%command_file_open = .false. ok = .false. endif return endif enddo end subroutine