Correction to Fortran-77 OTS for I/D Tasks Using Virtual Arrays Gary L. Maxwell Lawrence M. Baker U.S. Geological Survey Menlo Park, California In the course of our separate investigations on using PLAS directives and in developing Supervisor mode libraries, we have discovered a bug in the Fortran-77 V5.0-12 OTS. Symptoms of the bug include a "Virtual array initialization failure" message from Fortran or a segment fault caused when Virtual arrays are first accessed by an I/D space task. This problem can occur when the Instruction Space of the task is between 28K and 32K words in length, or when a resident library (such as FCSRES) is linked into the I/D task using APR 7. The following program will exhibit the problem: File TSTBUG.FTN: Program TSTBUG C Virtual Ivfill(8192) C Do 1000 I = 1, 8192 Ivfill(I) = I 1000 Continue Do 2000 I = 1, 8192 If (Ivfill(I) .ne. I) Stop 'Verify error' 2000 Continue Stop End File FILLIS.MAC: .title fillis ; ; Build a 28 KW instruction space array ; .psect fcode,i,ro .blkw 28.*1024. ; Load it up, folks .end Compile, assemble, and build as follows: >F77 TSTBUG=TSTBUG/TR:ALL >MAC FILLIS=FILLIS >TKB TSTBUG/ID=TSTBUG,FILLIS The above program will fail with a Virtual array initialization error. The problem is due to an error in the Fortran OTS routine $VINIT. When the Virtual array PLAS window is created, Fortran uses information provided by the Task Builder to determine which APR to use to map the Virtual array window. For I/D space tasks, the Task Builder correctly determines which D-Space APR should be used by Fortran for Virtual arrays. However, Fortran does not make any distinction between I/D and non-I/D tasks. Fortran will always attempt to map the Virtual array in I-Space. For I/D tasks that are not using APR 7 for instructions or data, Virtual arrays still work correctly. This is because the Executive will automatically map the D-Space APR along with the I-Space APR if the D-Space APR is not currently in use. However, if the task uses APR 7 for instructions, or is mapped to a resident library through APR 7, Fortran will try to remap APR 7 I-Space, causing an eventual failure. The correction to $VINIT which follows will work regardless of whether a task is or is not built as an I/D space task. This is possible by the use of an undocumented bit mask in the status word of the Window Definition Block, WS.EDS (Effective Data Space). This mask is the sum of WS.UDS (User Data Space) and WS.SIS (Supervisor Instruction Space). When used, the M-Plus Executive will map the window based on whether the task uses Data Space: if it does, the window is mapped in D-Space; otherwise, the window is mapped in I-Space. When the OTS is corrected, the program example above will work correctly. Correction file VINIT.PAT: .Title $VINIT .Enabl Lc .Ident /F7705Z/ ; ; VINIT.PAT -- Correction for F77 OTS module $VINIT ; (Original Ident: F77005) ; ; Corrections: ; ; GMLB01 -- Use WS.EDS bit mask to set up mapping ; in I-space for non I/D tasks and D-Space ; for I/D tasks. ; ; Original file checksum: 25372 ; Correction file checksum: 5712 ; .Mcall Wdbdf$ Wdbdf$ ; Window Definition Block Offsets .Psect $$OTSI,CON,RO,REL,LCL,I $$$ = . . = $$$ + 62 Mov #,(R0)+ ; Store window status .End To correct the OTS, follow the instructions in the Fortran-77 Installation Guide, or use the following command sequence: >LBR VINIT.OBJ;1=SYSLIB/EX:$VINIT >MAC VINIT.POB=VINIT.PAT >PAT VINIT.OBJ;2=VINIT.OBJ;1/CS:025372,VINIT.POB/CS:005712 >LBR SYSLIB/RP=VINIT.OBJ;2 Module "$VINIT" replaced >