Fortran · File status code

IOSTAT -2 — End-of-Record Condition

What does IOSTAT -2 — End-of-Record Condition mean in Fortran?

Signaled only on a non-advancing READ (ADVANCE='NO') when the current record runs out before the whole input list has been filled — there is more to read, but not on this line. Advancing (the default) reads never produce this value; they simply move to the next record instead.

IOSTAT -2 — End-of-Record ConditionIntel Fortran · gfortran

Condition

Signaled only on a non-advancing READ (ADVANCE='NO') when the current record runs out before the whole input list has been filled — there is more to read, but not on this line. Advancing (the default) reads never produce this value; they simply move to the next record instead.

Fix

Add an EOR= specifier or check IOSTAT for this specific negative value (or use IS_IOSTAT_EOR()) after non-advancing reads, then either pad the unfilled variables or issue a follow-up READ to continue on the next record.

Related file status code