1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
*DECK AEXDIR
SUBROUTINE AEXDIR (NFICH,LBLOC,DATA,IADRES,LGSEG)
*
*-----------------------------------------------------------------------
*
*Purpose:
* Read infomation from a direct access file. Component of a FORTRAN-77
* emulator of the SAPHYR archive system.
*
*Copyright:
* Copyright (C) 1999 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version
*
*Author(s): A. Hebert
*
*Parameters: input
* NFICH unit number of the direct access file.
* LBLOC direct access buffer length.
* IADRES offset, from start of file where data is extracted from
* or where data is to be stored.
* LGSEG number of words to read from or write into file.
*
*Parameters: output
* DATA address in memory where data is to be moved or extracted.
*
*-----------------------------------------------------------------------
*
IMPLICIT INTEGER(A-Z)
INTEGER DATA(LGSEG),LNEWAD(2)
INTEGER, ALLOCATABLE, DIMENSION(:) :: WRK
*
ALLOCATE(WRK(LBLOC))
INDEX=IADRES
ID=0
NROLD=0
10 NREC=1+INDEX/LBLOC
N=MOD(INDEX,LBLOC)
LMIN=1
20 IF(NREC.NE.NROLD) THEN
* --------------------------------------------------------
READ(NFICH,REC=NREC,ERR=90,IOSTAT=IR) (WRK(I),I=1,LBLOC)
* --------------------------------------------------------
NROLD=NREC
ENDIF
NGRO=MIN(LBLOC+LMIN-N-1,2)
DO 30 L=LMIN,NGRO
N=N+1
LNEWAD(L)=WRK(N)
30 CONTINUE
IF(NGRO.EQ.2) GO TO 40
NREC=NREC+1
N=0
LMIN=NGRO+1
GO TO 20
40 LINFO=LNEWAD(2)
IF(ID+LINFO.GT.LGSEG) CALL XABORT('AEXDIR: DIRECT ACCESS READ FA'
1 //'ILURE(1).')
NREC=1+(INDEX+2)/LBLOC
N=MOD(INDEX+2,LBLOC)
LMIN=1
50 IF(NREC.NE.NROLD) THEN
* --------------------------------------------------------
READ(NFICH,REC=NREC,ERR=90,IOSTAT=IR) (WRK(I),I=1,LBLOC)
* --------------------------------------------------------
NROLD=NREC
ENDIF
NGRO=MIN(LBLOC+LMIN-N-1,LINFO)
DO 60 L=LMIN,NGRO
N=N+1
DATA(ID+L)=WRK(N)
60 CONTINUE
IF(NGRO.EQ.LINFO) GO TO 70
NREC=NREC+1
N=0
LMIN=NGRO+1
GO TO 50
*
70 INDEX=LNEWAD(1)
ID=ID+LNEWAD(2)
IF(ID.EQ.LGSEG) GO TO 80
GO TO 10
80 DEALLOCATE(WRK)
IF(LNEWAD(1).NE.-1) CALL XABORT('AEXDIR: DIRECT ACCESS READ FAIL'
1 //'URE(3).')
RETURN
90 CALL XABORT('AEXDIR: DIRECT ACCESS READ FAILURE(2).')
END
|