FPT and WinFPT Reference Manual - Command-line Commands

| SimCon Home | Reference Manual Home |


CHANGE ALL I/O TO SUB-PROGRAM CALLS

Syntax:

[DO NOT] CHANGE [ALL] I/O TO SUB-PROGRAM CALLS

Licensing:

This command is supported by a special version of FPT developed in collaboration with Sector7 Inc. An additional licence is required for its use. Please contact customer support if this is required.

Important Note - Libraries for Use with this Command:

Please see the notes on Fortran compilation for the VX/Tools libraries.

Function:

This command is used when migrating code from VMS to other operating systems.

All Fortran I/O statements are replaced by calls to Sector7's VX/Tools RMS library routines. These are the statements introduced by the keywords:

   ACCEPT      BACKSPACE   CLOSE       DELETE
   ENDFILE     INQUIRE     OPEN        PRINT
   READ        REWRITE     TYPE        UNLOCK
   WRITE

Note that terminal I/O statements are changed by this command. To leave terminal I/O unchanged, please use the command CHANGE FILE I/O TO SUB-PROGRAM CALLS.

Labelled Statements and IF Statement Clauses

When FPT modifies an I/O statement, it may replace a single statement with two or more statements. It is therefore necessary to remove labels, and to change IF statements which contain I/O sub-statements to IF-THEN-ELSE constructs. For example, the labelled statement:

DO 110 I=1,6 110 READ(4,IOSTAT=ISTAT)CAND(I)

becomes

DO 110 I=1,6 !110 READ(4, IOSTAT=ISTAT)CAND(I) CALL VXRMS_READ('UNIT=',4,'IOSTAT=',ISTAT,%VAL(0)) CALL VXRMS_FROM_BUFFER(CAND(I),124) 110 CONTINUE

In this case, the original statement label is moved to a CONTINUE statement after the original statement. If the label is a GOTO destination, the CONTINUE statement is written before the original statement. Please see the commands REMOVE LABELS FROM EXECUTABLE STATEMENTS and CHANGE IF TO IF-THEN for a description of this process.

Replacement of the I/O Statements

The original I/O statement is left in place in the code, but is commented-out. It is replaced by a subroutine call. The subroutines are:

Keyword

Subroutine

ACCEPT

VXRMS_READ

BACKSPACE

VXRMS_BACKSPACE

CLOSE

VXRMS_CLOSE

DELETE

VXRMS_DELETE

ENDFILE

VXRMS_ENDFILE

INQUIRE

VXRMS_INQUIRE

OPEN

VXRMS_OPEN

PRINT

VXRMS_WRITE

READ

VXRMS_READ or VXRMS_FORMATTED_READ

REWRITE

VXRMS_REWRITE

TYPE

VXRMS_WRITE

UNLOCK

VXRMS_UNLOCK

WRITE

VXRMS_WRITE or VXRMS_FORMATTED_WRITE

The I/O statement control list is replaced by a series of arguments in which the original argument labels are replaced by strings. Thus, for example:

OPEN (COLORLUN,FILE='COLOR.ISM',STATUS='OLD' 1 ,ORGANIZATION='INDEXED' 1 ,KEY=(1:8,9:16,17:40),ACCESS='KEYED',RECL=128, 1 ,IOSTAT=IOS)

becomes

CALL VXRMS_OPEN('UNIT=',COLORLUN,'FILE=','COLOR.ISM', 1 'STATUS=','OLD','ORGANIZATION=','INDEXED','KEY=',1,8, 1 'CHARACTER','ASCENDING','KEY=',9,16,'CHARACTER', 1 'ASCENDING','KEY=',17,40,'CHARACTER','ASCENDING', 1 'ACCESS=','KEYED','RECL=',128,'IOSTAT=',IOS,%VAL(0))

Note that the defaults UNIT= for the unit number and CHARACTER and ASCENDING for the key attributes have been supplied. The argument list is terminated by a null, written as %VAL(0).

In most cases, the argument labels are replaced by the label text, including the '=' sign if this is present, converted to a string. The argument labels KEY= in a READ statement (where it is a synonym for KEYEQ=), KEYEQ=, KEYGE=, KEYGT=, KEYLE= and KEYLT= are changed to strings which indicate the data type of the key. They become:

Label

INTEGER*2

INTEGER*4

String


Argument

Argument

Argument

KEY=

'I2KEYEQ='

'I4KEYEQ='

'SKEYEQ='

KEYEQ=

'I2KEYEQ='

'I4KEYEQ='

'SKEYEQ='

KEYGE=

'I2KEYGE='

'I4KEYGE='

'SKEYGE='

KEYGT=

'I2KEYGT='

'I4KEYGT='

'SKEYGT=

KEYLE=

'I2KEYLE='

'I4KEYLE='

'SKEYLE='

KEYLT=

'I2KEYLT='

'I4KEYLT='

'SKEYLT='

When an I/O list is also present, in READ, WRITE and REWRITE statements, the treatment depends on whether or not the file is formatted. If a format is specified, FPT writes data to, or reads data from an internal character array or file. The data is transferred to or from the target file by the VXRMS_READ, VXRMS_WRITE or VXRMS_REWRITE call. For example:

WRITE (INDXFMLUN,'(2A1,I12)') 1 CHAR(ICHAR('A')-1+I),CHAR(ICHAR('Z')+1-I),I

becomes

C WRITE (INDXFMLUN,'(2A1,I12)',IOSTAT=IOS) C 1 CHAR(ICHAR('A')-1+I),CHAR(ICHAR('Z')+1-I),I WRITE (VXRMS_BUFFER,FMT='(2A1,I12)')CHAR(ICHAR('A')-1+I), 1 CHAR(ICHAR('Z')+1-I),I CALL VXRMS_WRITE('UNIT=',INDXFMLUN,'IOSTAT=',IOS,%VAL(0))

If the I/O statement is unformatted, FPT writes the data to, or reads the data from a buffer, and the buffer is packed or unpacked by calls to the subroutines VXRMS_TO_BUFFER or VXRMS_FROM_BUFFER. These routines keep track of internal pointers into the buffer. The pointers are initialised by a call to VXRMS_INIT_BUFFER. For example:

READ (KEYEQ=4,UNIT=INDXUFLUN,IOSTAT=IOS)J,K

becomes

C READ (KEYEQ=4,UNIT=INDXUFLUN,IOSTAT=IOS)J,K CALL VXRMS_INIT_BUFFER CALL VXRMS_READ('I4KEYEQ=',4,'UNIT=',INDXUFLUN, 1 'IOSTAT=',IOS,%VAL(0)) CALL VXRMS_FROM_BUFFER(J,4) CALL VXRMS_FROM_BUFFER(K,4)

Diagnostic Returns

In cases where IOSTAT is not captured and there is no END= or ERR= handler, the VX/Tools run-time system handles any fatal error.

Insertion of Declarations

The COMMON block containing VXRMS_IOSTAT and the attributes of the other sub-programs are declared in the INCLUDE file vxrms_cmn.fpi. An INCLUDE statement is automatically inserted in the header of every sub-program which requires these declarations. vxrms_cmn.fpi is distributed as part of the VX/Tools library.

Where to use this command:

Operating system command line

Yes


Configuration file, config.fsp

Yes


Specification (FSP) files, *.fsp

Yes


Interactively, to FPT> prompt:

Yes


Interactive command files

Yes


Embedded in the Fortran code

Yes


Default:

I/O statements are not changed by default.


Copyright ©1995 to 2014 Software Validation Ltd. All rights reserved.