1 C-----------------------------------------------------------------------
3 C$$$ F90-MODULE DOCUMENTATION BLOCK
5 C F90-MODULE: BACIO_MODULE BYTE-ADDRESSABLE I/O MODULE
6 C PRGMMR: IREDELL ORG: NP23 DATE: 98-06-04
8 C ABSTRACT: MODULE TO SHARE FILE DESCRIPTORS
9 C IN THE BYTE-ADDESSABLE I/O PACKAGE.
11 C PROGRAM HISTORY LOG:
15 C LANGUAGE: FORTRAN 90
18 INTEGER,EXTERNAL:: BA_CIO
19 INTEGER,DIMENSION(999),SAVE
:: FD
=999*0
20 INTEGER,DIMENSION(20),SAVE
:: BAOPTS
=0
23 C-----------------------------------------------------------------------
24 SUBROUTINE BASETO
(NOPT
,VOPT
)
25 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
27 C SUBPROGRAM: BASETO BYTE-ADDRESSABLE SET OPTIONS
28 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
30 C ABSTRACT: SET OPTIONS FOR BYTE-ADDRESSABLE I/O.
31 C ALL OPTIONS DEFAULT TO 0.
32 C OPTION 1: BLOCKED READING OPTION
33 C IF THE OPTION VALUE IS 1, THEN THE READING IS BLOCKED
34 C INTO FOUR 4096-BYTE BUFFERS. THIS MAY BE EFFICIENT IF
35 C THE READS WILL BE REQUESTED IN MUCH SMALLER CHUNKS.
36 C OTHERWISE, EACH CALL TO BAREAD INITIATES A PHYSICAL READ.
38 C PROGRAM HISTORY LOG:
41 C USAGE: CALL BASETO(NOPT,VOPT)
43 C NOPT INTEGER OPTION NUMBER
44 C VOPT INTEGER OPTION VALUE
47 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
50 C LANGUAGE: FORTRAN 90
55 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56 IF(NOPT
.GE
.1.AND
.NOPT
.LE
.20) BAOPTS
(NOPT
)=VOPT
57 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 C-----------------------------------------------------------------------
60 SUBROUTINE BAOPEN
(LU
,CFN
,IRET
)
61 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
63 C SUBPROGRAM: BAOPEN BYTE-ADDRESSABLE OPEN
64 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
66 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE.
68 C PROGRAM HISTORY LOG:
71 C USAGE: CALL BAOPEN(LU,CFN,IRET)
73 C LU INTEGER UNIT TO OPEN
74 C CFN CHARACTER FILENAME TO OPEN
75 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
77 C IRET INTEGER RETURN CODE
80 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
83 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
86 C LANGUAGE: FORTRAN 90
92 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
93 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
97 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98 IRET
=BA_CIO
(BACIO_OPENRW
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
99 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101 C-----------------------------------------------------------------------
102 SUBROUTINE BAOPENR
(LU
,CFN
,IRET
)
103 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
105 C SUBPROGRAM: BAOPENR BYTE-ADDRESSABLE OPEN
106 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
108 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR READ ONLY.
110 C PROGRAM HISTORY LOG:
113 C USAGE: CALL BAOPENR(LU,CFN,IRET)
115 C LU INTEGER UNIT TO OPEN
116 C CFN CHARACTER FILENAME TO OPEN
117 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
119 C IRET INTEGER RETURN CODE
122 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
124 C SUBPROGRAMS CALLED:
125 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
128 C LANGUAGE: FORTRAN 90
133 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
134 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
138 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
139 IRET
=BA_CIO
(BACIO_OPENR
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
140 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142 C-----------------------------------------------------------------------
143 SUBROUTINE BAOPENW
(LU
,CFN
,IRET
)
144 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
146 C SUBPROGRAM: BAOPENW BYTE-ADDRESSABLE OPEN
147 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
149 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY.
151 C PROGRAM HISTORY LOG:
154 C USAGE: CALL BAOPENW(LU,CFN,IRET)
156 C LU INTEGER UNIT TO OPEN
157 C CFN CHARACTER FILENAME TO OPEN
158 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
160 C IRET INTEGER RETURN CODE
163 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
165 C SUBPROGRAMS CALLED:
166 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
169 C LANGUAGE: FORTRAN 90
174 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
175 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
179 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
180 IRET
=BA_CIO
(BACIO_OPENW
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
181 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
183 C-----------------------------------------------------------------------
184 SUBROUTINE BAOPENWT
(LU
,CFN
,IRET
)
185 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
187 C SUBPROGRAM: BAOPENWT BYTE-ADDRESSABLE OPEN
188 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
190 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY WITH TRUNCATION.
192 C PROGRAM HISTORY LOG:
195 C USAGE: CALL BAOPENWT(LU,CFN,IRET)
197 C LU INTEGER UNIT TO OPEN
198 C CFN CHARACTER FILENAME TO OPEN
199 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
201 C IRET INTEGER RETURN CODE
204 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
206 C SUBPROGRAMS CALLED:
207 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
210 C LANGUAGE: FORTRAN 90
215 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
216 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
220 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
221 IRET
=BA_CIO
(BACIO_OPENWT
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
222 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
224 C-----------------------------------------------------------------------
225 SUBROUTINE BAOPENWA
(LU
,CFN
,IRET
)
226 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
228 C SUBPROGRAM: BAOPENWA BYTE-ADDRESSABLE OPEN
229 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
231 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY WITH APPEND.
233 C PROGRAM HISTORY LOG:
236 C USAGE: CALL BAOPENWA(LU,CFN,IRET)
238 C LU INTEGER UNIT TO OPEN
239 C CFN CHARACTER FILENAME TO OPEN
240 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
242 C IRET INTEGER RETURN CODE
245 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
247 C SUBPROGRAMS CALLED:
248 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
251 C LANGUAGE: FORTRAN 90
256 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
257 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
261 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
262 IRET
=BA_CIO
(BACIO_OPENWA
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
263 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
265 C-----------------------------------------------------------------------
266 SUBROUTINE BACLOSE
(LU
,IRET
)
267 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
269 C SUBPROGRAM: BACLOSE BYTE-ADDRESSABLE CLOSE
270 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
272 C ABSTRACT: CLOSE A BYTE-ADDRESSABLE FILE.
274 C PROGRAM HISTORY LOG:
277 C USAGE: CALL BACLOSE(LU,IRET)
279 C LU INTEGER UNIT TO CLOSE
281 C IRET INTEGER RETURN CODE
284 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
286 C SUBPROGRAMS CALLED:
287 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
289 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
292 C LANGUAGE: FORTRAN 90
296 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
297 IF(LU
.LT
.001.OR
.LU
.GT
.999) THEN
301 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
302 IRET
=BA_CIO
(BACIO_CLOSE
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
303 IF(IRET
.EQ
.0) FD
(LU
)=0
304 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
306 C-----------------------------------------------------------------------
307 SUBROUTINE BAREAD
(LU
,IB
,NB
,KA
,A
)
308 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
310 C SUBPROGRAM: BAREAD BYTE-ADDRESSABLE READ
311 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
313 C ABSTRACT: READ A GIVEN NUMBER OF BYTES FROM AN UNBLOCKED FILE,
314 C SKIPPING A GIVEN NUMBER OF BYTES.
315 C THE PHYSICAL I/O IS BLOCKED INTO FOUR 4096-BYTE BUFFERS
316 C IF THE BYTE-ADDRESSABLE OPTION 1 HAS BEEN SET TO 1 BY BASETO.
317 C THIS BUFFERED READING IS INCOMPATIBLE WITH NO-SEEK READING.
319 C PROGRAM HISTORY LOG:
322 C USAGE: CALL BAREAD(LU,IB,NB,KA,A)
324 C LU INTEGER UNIT TO READ
325 C IB INTEGER NUMBER OF BYTES TO SKIP
326 C (IF IB<0, THEN THE FILE IS ACCESSED WITH NO SEEKING)
327 C NB INTEGER NUMBER OF BYTES TO READ
329 C KA INTEGER NUMBER OF BYTES ACTUALLY READ
330 C A CHARACTER*1 (NB) DATA READ
333 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
335 C SUBPROGRAMS CALLED:
336 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
338 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
341 C LANGUAGE: FORTRAN 90
347 PARAMETER(NY
=4096,MY
=4)
348 INTEGER NS
(MY
),NN
(MY
)
352 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
357 IF(IB
.LT
.0.AND
.BAOPTS
(1).EQ
.1) THEN
365 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
367 IF(BAOPTS
(1).NE
.1) THEN
369 IRET
=BA_CIO
(BACIO_READ
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
371 IRET
=BA_CIO
(BACIO_READ
+BACIO_NOSEEK
,0,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
373 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
375 C GET DATA FROM PREVIOUS CALL IF POSSIBLE
386 IF(KA
.LT
.NB
.AND
.KY
.GE
.0.AND
.KY
.LT
.NN
(IY
)) THEN
387 K
=MIN
(NB
-KA
,NN
(IY
)-KY
)
388 A
(KA
+1:KA
+K
)=Y
(KY
+1:KY
+K
,IY
)
393 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
394 C SET POSITION AND READ BUFFER AND GET DATA
399 IRET
=BA_CIO
(BACIO_READ
,NS
(JY
),JB
,1,NY
,NN
(JY
),
400 & FD
(LUX
),CFN
,Y
(1,JY
))
403 A
(KA
+1:KA
+K
)=Y
(1:K
,JY
)
406 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
407 C CONTINUE TO READ BUFFER AND GET DATA
408 DOWHILE
(NN
(JY
).EQ
.NY
.AND
.KA
.LT
.NB
)
411 IRET
=BA_CIO
(BACIO_READ
+BACIO_NOSEEK
,NS
(JY
),JB
,1,NY
,NN
(JY
),
412 & FD
(LUX
),CFN
,Y
(1,JY
))
415 A
(KA
+1:KA
+K
)=Y
(1:K
,JY
)
421 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
423 C-----------------------------------------------------------------------
424 SUBROUTINE BAWRITE
(LU
,IB
,NB
,KA
,A
)
425 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
427 C SUBPROGRAM: BAWRITE BYTE-ADDRESSABLE WRITE
428 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
430 C ABSTRACT: WRITE A GIVEN NUMBER OF BYTES TO AN UNBLOCKED FILE,
431 C SKIPPING A GIVEN NUMBER OF BYTES.
433 C PROGRAM HISTORY LOG:
436 C USAGE: CALL BAWRITE(LU,IB,NB,KA,A)
438 C LU INTEGER UNIT TO WRITE
439 C IB INTEGER NUMBER OF BYTES TO SKIP
440 C (IF IB<0, THEN THE FILE IS ACCESSED WITH NO SEEKING)
441 C NB INTEGER NUMBER OF BYTES TO WRITE
442 C A CHARACTER*1 (NB) DATA TO WRITE
444 C KA INTEGER NUMBER OF BYTES ACTUALLY WRITTEN
447 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
449 C SUBPROGRAMS CALLED:
450 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
452 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
455 C LANGUAGE: FORTRAN 90
461 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
470 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
472 IRET
=BA_CIO
(BACIO_WRITE
,IB
,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
474 IRET
=BA_CIO
(BACIO_WRITE
+BACIO_NOSEEK
,0,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
476 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
478 C-----------------------------------------------------------------------
479 SUBROUTINE WRYTE
(LU
,NB
,A
)
480 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
482 C SUBPROGRAM: WRYTE WRITE DATA OUT BY BYTES
483 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
485 C ABSTRACT: WRITE A GIVEN NUMBER OF BYTES TO AN UNBLOCKED FILE.
487 C PROGRAM HISTORY LOG:
489 C 95-10-31 IREDELL WORKSTATION VERSION
490 C 1998-06-04 IREDELL BACIO VERSION
492 C USAGE: CALL WRYTE(LU,NB,A)
494 C LU INTEGER UNIT TO WHICH TO WRITE
495 C NB INTEGER NUMBER OF BYTES TO WRITE
496 C A CHARACTER*1 (NB) DATA TO WRITE
499 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
501 C SUBPROGRAMS CALLED:
502 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
504 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
507 C LANGUAGE: FORTRAN 90
513 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
520 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
521 IRET
=BA_CIO
(BACIO_WRITE
+BACIO_NOSEEK
,0,JB
,1,NB
,KA
,FD
(LU
),CFN
,A
)
522 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -