fpt and WinFPT Reference Manual - Command-line Commands
| SimCon Home | Ref Manual Home |
CHANGE ISAM FILE ACCESSES TO SUB-PROGRAM CALLS
Syntax:
[DO NOT] CHANGE ISAM [FILE] ACCESS[ES] [TO SUB-PROGRAM [CALLS]]
[DO NOT] CHANGE ISAM [FILE] ACCESS[ES] [TO SUBROUTINE [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.
Function:
ISAM (Indexed Sequential Access Method) files are files with content-addressable records. They are accessed by specifying key fields within the records, and records are read in ascending or descending order of the keys.
ISAM files are supported as a Fortran language extension under VMS. They are supported under Unix and Microsoft Windows by a library of subroutines and functions. The command CHANGE ISAM FILE ACCESSES TO SUB-PROGRAM CALLS converts the VMS language extensions to the sub-program calls.
fpt systematically identifies all input and output statements in the code which access, or which might access ISAM files. The statements are identified from syntax and from the logical unit numbers. ISAM file accesses are recognised from syntax by the use of keywords, for example:
OPEN(2,FILE='TREEDAT.DAT',ORGANIZATION='INDEXED' 1 ,KEY=(1:4:INTEGER,5:20:CHARACTER),STATUS='OLD') READ(2,KEYGE='Aphodius')DISTREC
Here, the argument 'INDEXED' and the keywords KEY= and KEYGE= unambiguously identify the accesses to be to ISAM files. Similarly, specification of ORGANIZATION='SEQUENTIAL' or 'RELATIVE', or use of numbered records, for example, REC=IREC, identify an I/O statement as non-ISAM.
Identification of ISAM statements from logical unit numbers is sometimes necessary because an ISAM and a non-ISAM statement may be syntactically indistinguishable. It is controlled by the commands:
[DO NOT] INFER INDEXED LOGICAL UNITS FROM USAGE
[NON-] INDEXED UNIT <integer>
TERMINAL INPUT LOGICAL UNIT = <integer>
TERMINAL OUTPUT LOGICAL UNIT = <integer>
NO TERMINAL INPUT LOGICAL UNIT
NO TERMINAL OUTPUT LOGICAL UNIT
It is assumed that ISAM files are never accessed through the terminal logical unit numbers.
If indexed logical units are inferred from usage, fpt checks all statements which use each unit, and classifies the units as always ISAM, sometimes ISAM and never ISAM. If run-time variables are used as logical unit numbers for ISAM files, fpt assumes that all units are at least sometimes ISAM. If run-time variables are used as logical unit numbers for non-ISAM files, fpt assumes that all logical units are at least sometimes non-ISAM.
If indexed logical unit numbers are not inferred from usage, fpt assumes that all units except the terminal I/O units may be used for ISAM files.
When fpt modifies a statement which accesses an ISAM file, it may replace a single statement with two or more statements. It is therefore necessary to remove labels from the ISAM statements, and to change IF statements which contain ISAM file accesses to IF-THEN-ELSE constructs. For example, the labelled statement:
DO 110 I=1,6 110 READ(8,KEY=SRCH(I),IOSTAT=ISTAT)CAND(I)
becomes
DO 110 I=1,6 C110 READ(8,KEY=SRCH(I),IOSTAT=ISTAT)CAND(I) CALL VXRMS_READ('UNIT=',8,'I4KEYEQ=',SRCH(I), 1 '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
When an I/O statementn is modified, the original statement is left in place in the code, but is commented-out. It is replaced by a subroutine call. The keywords affected are:
Keyword | Subroutine |
INQUIRE | VXRMS_INQUIRE |
OPEN | VXRMS_OPEN |
CLOSE | VXRMS_CLOSE |
READ | VXRMS_READ or VXRMS_FORMATTED_READ |
WRITE | VXRMS_WRITE or VXRMS_FORMATTED_WRITE |
REWRITE | VXRMS_REWRITE |
UNLOCK | VXRMS_UNLOCK |
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',KEY=(1:8,9:16,17:40) 1 ,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 argument | INTEGER*4 argument | String 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. The data is transferred to or from the ISAM 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
! WRITE (INDXFMLUN,'(2A1,I12)',IOSTAT=IOS) ! 1 CHAR(ICHAR('A')-1+I),CHAR(ICHAR('Z')+1-I),I WRITE (VXRMS_BUFFER,FMT='(2A1,I12)') 1 CHAR(ICHAR('A')-1+I), 1 CHAR(ICHAR('Z')+1-I),I CALL VXRMS_WRITE('UNIT=',INDXFMLUN,'IOSTAT=',IOS 1 ,%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
! 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)
In some cases, fpt cannot determine whether a particular statement accesses an ISAM file. Code is then generated to test the status of the file at run-time, and to execute either the original statement or the modified code. For example:
READ(20)J,K
becomes:
! READ (20)J,K IF (VXRMS_INDEXED(20)) THEN CALL VXRMS_INIT_BUFFER CALL VXRMS_READ('UNIT=',20,%VAL(0)) CALL VXRMS_FROM_BUFFER(J,4) CALL VXRMS_FROM_BUFFER(K,4) IF (VXRMS_IOSTAT .NE. 0) THEN CALL VXRMS_RUNTIME_ERROR(VXRMS_IOSTAT) ENDIF ELSE READ (20)J,K ENDIF
The subroutines VXRMS_OPEN and VXRMS_CLOSE maintain a record of the logical unit numbers open for ISAM access. This record is used by the function VXRMS_INDEXED to find the status of the unit.
Some statements which do not affect ISAM files are also changed by this process. For example, an OPEN statement for a non-ISAM direct access file automatically closes any ISAM file which is open on the same unit. Thus, the statement:
OPEN(20,FILE=SCRFILE,STATUS='NEW',ACCESS='DIRECT', 1 FORM='UNFORMATTED',RECL=128)
may become
IF (VXRMS_INDEXED(20)) THEN CALL VXRMS_CLOSE('UNIT=',20,%VAL(0)) ENDIF OPEN(20,FILE=SCRFILE,STATUS='NEW',ACCESS='DIRECT', 1 FORM='UNFORMATTED',RECL=128)
The function VXRMS_INDEXED, 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.
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 | No |
Default
ISAM file accesses are not changed by default.
Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.