1 //===-- runtime/iostat.cpp ------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "flang/Runtime/iostat.h" 10 11 namespace Fortran::runtime::io { 12 const char *IostatErrorString(int iostat) { 13 switch (iostat) { 14 case IostatOk: 15 return "No error"; 16 case IostatEnd: 17 return "End of file during input"; 18 case IostatEor: 19 return "End of record during non-advancing input"; 20 case IostatUnflushable: 21 return "FLUSH not possible"; 22 case IostatInquireInternalUnit: 23 return "INQUIRE on internal unit"; 24 case IostatGenericError: 25 return "I/O error"; // dummy value, there's always a message 26 case IostatRecordWriteOverrun: 27 return "Excessive output to fixed-size record"; 28 case IostatRecordReadOverrun: 29 return "Excessive input from fixed-size record"; 30 case IostatInternalWriteOverrun: 31 return "Internal write overran available records"; 32 case IostatErrorInFormat: 33 return "Bad FORMAT"; 34 case IostatErrorInKeyword: 35 return "Bad keyword argument value"; 36 case IostatEndfileDirect: 37 return "ENDFILE on direct-access file"; 38 case IostatEndfileUnwritable: 39 return "ENDFILE on read-only file"; 40 case IostatOpenBadRecl: 41 return "OPEN with bad RECL= value"; 42 case IostatOpenUnknownSize: 43 return "OPEN of file of unknown size"; 44 case IostatOpenBadAppend: 45 return "OPEN(POSITION='APPEND') of unpositionable file"; 46 case IostatWriteToReadOnly: 47 return "Attempted output to read-only file"; 48 case IostatReadFromWriteOnly: 49 return "Attempted input from write-only file"; 50 case IostatBackspaceNonSequential: 51 return "BACKSPACE on non-sequential file"; 52 case IostatBackspaceAtFirstRecord: 53 return "BACKSPACE at first record"; 54 case IostatRewindNonSequential: 55 return "REWIND on non-sequential file"; 56 case IostatWriteAfterEndfile: 57 return "WRITE after ENDFILE"; 58 case IostatFormattedIoOnUnformattedUnit: 59 return "Formatted I/O on unformatted file"; 60 case IostatUnformattedIoOnFormattedUnit: 61 return "Unformatted I/O on formatted file"; 62 case IostatListIoOnDirectAccessUnit: 63 return "List-directed or NAMELIST I/O on direct-access file"; 64 case IostatUnformattedChildOnFormattedParent: 65 return "Unformatted child I/O on formatted parent unit"; 66 case IostatFormattedChildOnUnformattedParent: 67 return "Formatted child I/O on unformatted parent unit"; 68 case IostatChildInputFromOutputParent: 69 return "Child input from output parent unit"; 70 case IostatChildOutputToInputParent: 71 return "Child output to input parent unit"; 72 case IostatShortRead: 73 return "Read from external unit returned insufficient data"; 74 case IostatMissingTerminator: 75 return "Sequential record missing its terminator"; 76 case IostatBadUnformattedRecord: 77 return "Erroneous unformatted sequential file record structure"; 78 case IostatUTF8Decoding: 79 return "UTF-8 decoding error"; 80 case IostatUnitOverflow: 81 return "UNIT number is out of range"; 82 case IostatBadRealInput: 83 return "Bad REAL input value"; 84 case IostatBadScaleFactor: 85 return "Bad REAL output scale factor (kP)"; 86 case IostatBadAsynchronous: 87 return "READ/WRITE(ASYNCHRONOUS='YES') on unit without " 88 "OPEN(ASYNCHRONOUS='YES')"; 89 case IostatBadWaitUnit: 90 return "WAIT(UNIT=) for a bad unit number"; 91 case IostatBOZInputOverflow: 92 return "B/O/Z input value overflows variable"; 93 case IostatIntegerInputOverflow: 94 return "Integer input value overflows variable"; 95 case IostatRealInputOverflow: 96 return "Real or complex input value overflows type"; 97 case IostatCannotReposition: 98 return "Attempt to reposition a unit which is connected to a file that can " 99 "only be processed sequentially"; 100 case IostatOpenAlreadyConnected: 101 return "OPEN of file already connected to another unit"; 102 case IostatBadWaitId: 103 return "WAIT(ID=nonzero) for an ID value that is not a pending operation"; 104 case IostatTooManyAsyncOps: 105 return "Too many asynchronous operations pending on unit"; 106 case IostatBadBackspaceUnit: 107 return "BACKSPACE on unconnected unit"; 108 case IostatBadUnitNumber: 109 return "Negative unit number is not allowed"; 110 default: 111 return nullptr; 112 } 113 } 114 115 } // namespace Fortran::runtime::io 116