subroutine hec_ped_read c c read pedestal from file c implicit none c include'hec_par.inc' !shared parameters include'hec_datacard.inc' !datacard values include'hec_ped.inc' !pedestal values c integer run_no_ped !run number from ped file integer ic !adc channel number integer i integer n real ped real rms c c open input pedestal file and read run number c open (unit=io_ped(2), file='ped_in.dat', status='old', err=3) read (io_ped(2), *, err=2, end=2) run_no_ped print *, ' *** reading ped file for run number ', run_no_ped c c read pedestals c n = 0 do i = 1, i_adc_dim read (io_ped(2), *, err=2, end=1) ic, ped, rms if (ic .gt. 0 .and. ic .le. i_adc_dim) then adc_ped_run(ic) = ped adc_rms_run(ic) = rms n = n + 1 else print *, ' *** bad channel number in pedestal file', ic endif enddo c c if everything is ok: print, close file and return c 1 continue print *, ' *** pedestal file read for ', n, ' adc channels' if (pr_ped .ne. 0) call hec_ped_print close (unit=io_ped(2)) return c 2 continue print *, ' *** error reading pedestal file from unit ', io_ped(2) close (unit=io_ped(2)) stop c 3 continue print *, ' *** error opening pedestal file from unit ', io_ped(2) stop c end