subroutine event_display_write_control_file(ireturn_code) c c c This routine writes a short control file indicating the frequency with c which events should be written to disk for consumption by the display c routine. c c George Gollin, g-gollin@uiuc.edu, 1999. c c #include "event_display_data.inc" #include "event_display.inc" c c logical file_exists c c c return code is 0 if I managed to write the file c 1 if I couldn't open the file c 2 if I couln't write to the opened file c c ireturn_code=0 c c c does the control file exist? If so, I want to delete it, then recreate it. c Do in a loop, in case file is busy and I can't delete it... keep trying. do itry=1,1000 inquire(file=file_control(1:lenocc(file_control)), . exist=file_exists) if(file_exists) then call system('rm '//file_control(1:lenocc(file_control))) else go to 5 end if end do c c 5 continue c c c Now open the control file: open(lun_control, file=file_control(1:lenocc(file_control)), . status='new', form='formatted', iostat=io_err) c c c problems opening file? if(io_err .ne. 0) then c print *,' event_display couldn.t open the control file', . file_control print *,' iostat returned by open was... ',io_err c ireturn_code=1 return endif c c c so far so good: write the number to be read by Thierry's code to the file: write(lun_control, *, iostat=io_err1) number_for_control_file c c also, for diagnostic purposes, write what I think the display's IP is... write(lun_control, *, iostat=io_err2) hostname c c c problems writing the file? if(io_err1 .ne. 0 .or. io_err2 .ne. 0) then c print *, . ' event_display_write_control_file couldn.t write to', . ' control file ',file_control(1:lenocc(file_control)) print *,' iostat returned was... ',io_err1, io_err2 c ireturn_code=2 close(lun_control, iostat=io_err) return endif c c close(lun_control, iostat=io_err) return end