SUBROUTINE OPEN_MON_TEMP_FILE(LUN) C---------------------------------------------------------------------- C- C- Purpose and Methods : Manage a temporary file for repeated reads and C- writes. The first time this routine is called, a file is created with C- STATUS='SCRATCH'. If the file is already open when this routine is C- called, simply REWIND the file. Calling EOF_MON_TEMP_FILE writes a C- FORTRAN end of file marker to the file. Calling CLOSE_MON_TEMP_FILE C- closes and deletes the file. C- C- Inputs : none C- Outputs : LUN The logical unit to use. C- Controls: none C- C- Created 14-APR-1992 Philippe Laurens, Steven Klocek C- C---------------------------------------------------------------------- IMPLICIT NONE C INTEGER LUN LOGICAL FILE_OPEN, FIRST INTEGER SAVELUN SAVE FILE_OPEN, FIRST, SAVELUN DATA FIRST / .TRUE. /, FILE_OPEN /.FALSE./ C PARAMETER FNAME = 'TRGMON_TMP.DAT' C INTEGER IERR C IF (FIRST .EQV. .TRUE.) THEN FIRST = .FALSE. CALL GTUNIT(521, SAVELUN, IERR) IF (IERR .NE. 0) THEN CALL ERRMSG('GTUNIT', 'OPEN_MON_TEMP_FILE', & 'Could not allocate unit number', 'F') ENDIF ENDIF C LUN = SAVELUN C IF (FILE_OPEN .EQV. .TRUE.) THEN REWIND LUN GOTO 999 ENDIF C OPEN (UNIT=LUN, FILE=FNAME, ERR=100, STATUS='SCRATCH') FILE_OPEN = .TRUE. GOTO 999 C 100 CONTINUE CALL ERRMSG('OPEN ERROR', 'OPEN_MON_TEMP_FILE', & 'Could not open file ' // FNAME, 'F') C---------------------------------------------------------------------- 999 RETURN C C C ENTRY EOF_MON_TEMP_FILE C---------------------------------------------------------------------- C- C- Purpose and Methods : Write a FORTRAN end of file record to the current C- temporary file. C- C- Inputs : none C- Outputs : file output C- Controls: none C- C- Created 14-APR-1992 Philippe Laurens, Steven Klocek C- C---------------------------------------------------------------------- IF (FILE_OPEN .EQV. .TRUE.) THEN ENDFILE SAVELUN REWIND SAVELUN ENDIF RETURN C C C ENTRY CLOSE_MON_TEMP_FILE C---------------------------------------------------------------------- C- C- Purpose and Methods : Close the temporary file, and clear the flag which C- indicates that the file is open. Since the file was opened with C- STATUS='SCRATCH', the file should be deleted on close. C- C- Inputs : none C- Outputs : none C- Controls: none C- C- Created 14-APR-1992 Philippe Laurens, Steven Klocek C- C---------------------------------------------------------------------- IF (FILE_OPEN .EQV. .TRUE.) THEN CLOSE(SAVELUN) FILE_OPEN = .FALSE. ENDIF RETURN C END