Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

SETERRORMODEQQ

Portability Subroutine: Sets the prompt mode for critical errors that by default generate system prompts.

Module

USE IFPORT

CALL SETERRORMODEQQ (pmode)

pmode

(Input) LOGICAL(4). Flag that determines whether a prompt is displayed when a critical error occurs.

Certain I/O errors cause the system to display an error prompt. For example, attempting to write to a disk drive with the drive door open generates an "Abort, Retry, Ignore" message. When the system starts up, system error prompting is enabled by default (pmode= .TRUE.). You can also enable system error prompts by calling SETERRORMODEQQ with pmode set to ERR$HARDPROMPT (defined in IFPORT.F90).

If prompt mode is turned off, critical errors that normally cause a system prompt are silent. Errors in I/O statements such as OPEN, READ, and WRITE fail immediately instead of being interrupted with prompts. This gives you more direct control over what happens when an error occurs. For example, you can use the ERR= specifier to designate an executable statement to branch to for error handling. You can also take a different action than that requested by the system prompt, such as opening a temporary file, giving a more informative error message, or exiting.

You can turn off prompt mode by setting pmode to .FALSE. or to the constant ERR$HARDFAIL (defined in IFPORT.F90).

Note that SETERRORMODEQQ affects only errors that generate a system prompt. It does not affect other I/O errors, such as writing to a nonexistent file or attempting to open a nonexistent file with STATUS='OLD'.

Example

 !PROGRAM 1
 !  DRIVE B door open
 OPEN (10, FILE = 'B:\NOFILE.DAT', ERR = 100)
 !  Generates a system prompt error here and waits for the user
 !  to respond to the prompt before continuing
 100   WRITE(*,*) ' Continuing'
 END

 ! PROGRAM 2
 !  DRIVE B door open
  USE IFPORT
  CALL SETERRORMODEQQ(.FALSE.)
  OPEN (10, FILE = 'B:\NOFILE.DAT', ERR = 100)
 !  Causes the statement at label 100 to execute
 !  without system prompt
 100   WRITE(*,*) ' Drive B: not available, opening      &
                    &alternative drive.'
  OPEN (10, FILE = 'C:\NOFILE.DAT')
  END