static void NextUnFmtRec( void ) { //================================ if( _LogicalRecordOrganization( IOCB->fileinfo ) ) { if( CheckLogicalRecord( IOCB->fileinfo ) ) { NextRec(); return; } } IOErr( IO_UNFMT_RECL ); }
void UpdateRecNum( ftnfile *fcb ) { //==================================== if( _NoRecordOrganization( fcb ) ) return; if( _LogicalRecordOrganization( fcb ) ) { if( (fcb->flags & FTN_LOGICAL_RECORD) == 0 ) { // increment record count if this is first // physical record of logical record ++fcb->recnum; } // next record will be part of a logical record fcb->flags |= FTN_LOGICAL_RECORD; } else { ++fcb->recnum; } }
intstar4 __fortran FNEXTRECL( intstar4 *unit ) { //=================================================== ftnfile *fcb; signed_32 size; fcb = Files; while( fcb && ( *unit != fcb->unitid ) ) { fcb = fcb->link; } // Lots of error checks if( ( fcb == NULL ) || ( fcb->fileptr == NULL ) || !_LogicalRecordOrganization( fcb ) || ( IOCB && (IOCB->flags & IOF_ACTIVE) && (IOCB->fileinfo == fcb) ) ) { return( -1 ); } size = FGetVarRecLen( fcb->fileptr ); IOOk( fcb->fileptr ); return( size ); }
int IOMain( void (*io_rtn)( void ) ) { //================================== int io_stmt; int io_stat; // turn of IOF_SETIOCB so that we can detect "i/o already active" - by // the time we call IOMain(), no one should be checking IOF_SETIOCB IOCB->flags &= ~IOF_SETIOCB; io_stmt = IOCB->iostmt; if( ( Spawn( io_rtn ) != 0 ) && ( IOCB->fileinfo != NULL ) && ( ( io_stmt == IO_READ ) || ( io_stmt == IO_WRITE ) ) ) { IOCB->fileinfo->col = 0; // so next statement starts new record if( ( io_stmt == IO_READ ) && _LogicalRecordOrganization( IOCB->fileinfo ) ) { SkipLogicalRecord( IOCB->fileinfo ); } IOCB->fileinfo->flags &= ~FTN_LOGICAL_RECORD; // in case we got EOF if( IOCB->set_flags & SET_INTERNAL ) { DiscoFile( IOCB->fileinfo ); } } if( __XcptFlags & XF_IO_INTERRUPTED ) { RTErr( KO_INTERRUPT ); } if( __XcptFlags & XF_FATAL_ERROR ) { __ReleaseIOSys(); // so other threads can continue Suicide(); } io_stat = IOCB->status; if( IOCB->set_flags & SET_IOSPTR ) { // set up IOSTAT *IOCB->iosptr = io_stat; } if( io_stat == 0 ) { while( IOCB->typ != PT_NOTYPE ) { // flush the io list IOCB->typ = IOTypeRtn(); } } if( io_stmt == IO_READ ) { // Consider: READ( 1, *, END=10 ) // ... // 10 WRITE( 1, * ) 'write after EOF' // the record number got incremented, so if an EOF condition // was encounterd we must adjust the record number so that // we don't get IO_PAST_EOF on the write if( ( IOCB->set_flags & SET_INTERNAL ) == 0 ) { // Consider: READ(5,*,IOSTAT=IOS) I // READ(5,*) I // If the first read gets EOF, then we must clear eof before // doing the next read so that we don't get EOF again. // Note: This is to be done only for files that don't have an // EOF (like TERMINAL). ClearEOF(); } } #if defined( __MT__ ) && !defined( _SA_LIBRARY ) // we cannot release the i/o system for READ/WRITE statements since // co-routines are not done yet if( (io_stmt != IO_READ) && (io_stmt != IO_WRITE) ) #endif __ReleaseIOSys(); __XcptFlags &= ~XF_IO_INTERRUPTABLE; return( io_stat ); }