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:: BACIO
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
94 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95 IF(LU.LT.001.OR.LU.GT.999) THEN
99 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100 IRET=BACIO(BACIO_OPENRW,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
101 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
103 C-----------------------------------------------------------------------
104 SUBROUTINE BAOPENR(LU,CFN,IRET)
105 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
107 C SUBPROGRAM: BAOPENR BYTE-ADDRESSABLE OPEN
108 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
110 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR READ ONLY.
112 C PROGRAM HISTORY LOG:
115 C USAGE: CALL BAOPENR(LU,CFN,IRET)
117 C LU INTEGER UNIT TO OPEN
118 C CFN CHARACTER FILENAME TO OPEN
119 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
121 C IRET INTEGER RETURN CODE
124 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
126 C SUBPROGRAMS CALLED:
127 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
130 C LANGUAGE: FORTRAN 90
136 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
137 IF(LU.LT.001.OR.LU.GT.999) THEN
141 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142 IRET=BACIO(BACIO_OPENR,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
143 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
145 C-----------------------------------------------------------------------
146 SUBROUTINE BAOPENW(LU,CFN,IRET)
147 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
149 C SUBPROGRAM: BAOPENW BYTE-ADDRESSABLE OPEN
150 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
152 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY.
154 C PROGRAM HISTORY LOG:
157 C USAGE: CALL BAOPENW(LU,CFN,IRET)
159 C LU INTEGER UNIT TO OPEN
160 C CFN CHARACTER FILENAME TO OPEN
161 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
163 C IRET INTEGER RETURN CODE
166 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
168 C SUBPROGRAMS CALLED:
169 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
172 C LANGUAGE: FORTRAN 90
178 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
179 IF(LU.LT.001.OR.LU.GT.999) THEN
183 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
184 IRET=BACIO(BACIO_OPENWT,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
185 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
187 C-----------------------------------------------------------------------
188 SUBROUTINE BAOPENWT(LU,CFN,IRET)
189 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
191 C SUBPROGRAM: BAOPENWT BYTE-ADDRESSABLE OPEN
192 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
194 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY WITH TRUNCATION.
196 C PROGRAM HISTORY LOG:
199 C USAGE: CALL BAOPENWT(LU,CFN,IRET)
201 C LU INTEGER UNIT TO OPEN
202 C CFN CHARACTER FILENAME TO OPEN
203 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
205 C IRET INTEGER RETURN CODE
208 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
210 C SUBPROGRAMS CALLED:
211 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
214 C LANGUAGE: FORTRAN 90
220 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
221 IF(LU.LT.001.OR.LU.GT.999) THEN
225 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
226 IRET=BACIO(BACIO_OPENWT,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
227 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
229 C-----------------------------------------------------------------------
230 SUBROUTINE BAOPENWA(LU,CFN,IRET)
231 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
233 C SUBPROGRAM: BAOPENWA BYTE-ADDRESSABLE OPEN
234 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
236 C ABSTRACT: OPEN A BYTE-ADDRESSABLE FILE FOR WRITE ONLY WITH APPEND.
238 C PROGRAM HISTORY LOG:
241 C USAGE: CALL BAOPENWA(LU,CFN,IRET)
243 C LU INTEGER UNIT TO OPEN
244 C CFN CHARACTER FILENAME TO OPEN
245 C (CONSISTING OF NONBLANK PRINTABLE CHARACTERS)
247 C IRET INTEGER RETURN CODE
250 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
252 C SUBPROGRAMS CALLED:
253 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
256 C LANGUAGE: FORTRAN 90
262 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
263 IF(LU.LT.001.OR.LU.GT.999) THEN
267 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
268 IRET=BACIO(BACIO_OPENWA,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
269 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
271 C-----------------------------------------------------------------------
272 SUBROUTINE BACLOSE(LU,IRET)
273 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
275 C SUBPROGRAM: BACLOSE BYTE-ADDRESSABLE CLOSE
276 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
278 C ABSTRACT: CLOSE A BYTE-ADDRESSABLE FILE.
280 C PROGRAM HISTORY LOG:
283 C USAGE: CALL BACLOSE(LU,IRET)
285 C LU INTEGER UNIT TO CLOSE
287 C IRET INTEGER RETURN CODE
290 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
292 C SUBPROGRAMS CALLED:
293 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
295 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
298 C LANGUAGE: FORTRAN 90
303 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
304 IF(LU.LT.001.OR.LU.GT.999) THEN
308 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
309 IRET=BACIO(BACIO_CLOSE,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
310 IF(IRET.EQ.0) FD(LU)=0
311 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
313 C-----------------------------------------------------------------------
314 SUBROUTINE BAREAD(LU,IB,NB,KA,A)
315 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
317 C SUBPROGRAM: BAREAD BYTE-ADDRESSABLE READ
318 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
320 C ABSTRACT: READ A GIVEN NUMBER OF BYTES FROM AN UNBLOCKED FILE,
321 C SKIPPING A GIVEN NUMBER OF BYTES.
322 C THE PHYSICAL I/O IS BLOCKED INTO FOUR 4096-BYTE BUFFERS
323 C IF THE BYTE-ADDRESSABLE OPTION 1 HAS BEEN SET TO 1 BY BASETO.
324 C THIS BUFFERED READING IS INCOMPATIBLE WITH NO-SEEK READING.
326 C PROGRAM HISTORY LOG:
329 C USAGE: CALL BAREAD(LU,IB,NB,KA,A)
331 C LU INTEGER UNIT TO READ
332 C IB INTEGER NUMBER OF BYTES TO SKIP
333 C (IF IB<0, THEN THE FILE IS ACCESSED WITH NO SEEKING)
334 C NB INTEGER NUMBER OF BYTES TO READ
336 C KA INTEGER NUMBER OF BYTES ACTUALLY READ
337 C A CHARACTER*1 (NB) DATA READ
340 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
342 C SUBPROGRAMS CALLED:
343 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
345 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
348 C LANGUAGE: FORTRAN 90
354 PARAMETER(NY=4096,MY=4)
355 INTEGER NS(MY),NN(MY)
361 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
366 IF(IB.LT.0.AND.BAOPTS(1).EQ.1) THEN
374 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
376 IF(BAOPTS(1).NE.1) THEN
379 IRET=BACIO(BACIO_READ,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
381 IRET=BACIO(BACIO_READ+BACIO_NOSEEK,ZERO,JB,SIZE,NB,KA,
384 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
386 C GET DATA FROM PREVIOUS CALL IF POSSIBLE
397 IF(KA.LT.NB.AND.KY.GE.0.AND.KY.LT.NN(IY)) THEN
398 K=MIN(NB-KA,NN(IY)-KY)
399 A(KA+1:KA+K)=Y(KY+1:KY+K,IY)
404 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
405 C SET POSITION AND READ BUFFER AND GET DATA
410 IRET=BACIO(BACIO_READ,NS(JY),JB,SIZE,NY,NN(JY),
411 & FD(LUX),CFN,Y(1,JY))
414 A(KA+1:KA+K)=Y(1:K,JY)
417 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
418 C CONTINUE TO READ BUFFER AND GET DATA
419 DOWHILE(NN(JY).EQ.NY.AND.KA.LT.NB)
422 IRET=BACIO(BACIO_READ+BACIO_NOSEEK,NS(JY),JB,SIZE,NY,NN(JY),
423 & FD(LUX),CFN,Y(1,JY))
426 A(KA+1:KA+K)=Y(1:K,JY)
432 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
434 C-----------------------------------------------------------------------
435 SUBROUTINE BAWRITE(LU,IB,NB,KA,A)
436 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
438 C SUBPROGRAM: BAWRITE BYTE-ADDRESSABLE WRITE
439 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
441 C ABSTRACT: WRITE A GIVEN NUMBER OF BYTES TO AN UNBLOCKED FILE,
442 C SKIPPING A GIVEN NUMBER OF BYTES.
444 C PROGRAM HISTORY LOG:
447 C USAGE: CALL BAWRITE(LU,IB,NB,KA,A)
449 C LU INTEGER UNIT TO WRITE
450 C IB INTEGER NUMBER OF BYTES TO SKIP
451 C (IF IB<0, THEN THE FILE IS ACCESSED WITH NO SEEKING)
452 C NB INTEGER NUMBER OF BYTES TO WRITE
453 C A CHARACTER*1 (NB) DATA TO WRITE
455 C KA INTEGER NUMBER OF BYTES ACTUALLY WRITTEN
458 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
460 C SUBPROGRAMS CALLED:
461 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
463 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
466 C LANGUAGE: FORTRAN 90
474 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
483 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
485 IRET=BACIO(BACIO_WRITE,IB,JB,SIZE,NB,KA,FD(LU),CFN,A)
487 IRET=BACIO(BACIO_WRITE+BACIO_NOSEEK,ZERO,JB,SIZE,NB,KA,
490 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
492 C-----------------------------------------------------------------------
493 SUBROUTINE WRYTE(LU,NB,A)
494 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
496 C SUBPROGRAM: WRYTE WRITE DATA OUT BY BYTES
497 C PRGMMR: IREDELL ORG: W/NMC23 DATE: 1998-06-04
499 C ABSTRACT: WRITE A GIVEN NUMBER OF BYTES TO AN UNBLOCKED FILE.
501 C PROGRAM HISTORY LOG:
503 C 95-10-31 IREDELL WORKSTATION VERSION
504 C 1998-06-04 IREDELL BACIO VERSION
506 C USAGE: CALL WRYTE(LU,NB,A)
508 C LU INTEGER UNIT TO WHICH TO WRITE
509 C NB INTEGER NUMBER OF BYTES TO WRITE
510 C A CHARACTER*1 (NB) DATA TO WRITE
513 C BACIO_MODULE BYTE-ADDRESSABLE I/O FORTRAN INTERFACE
515 C SUBPROGRAMS CALLED:
516 C BACIO BYTE-ADDRESSABLE I/O C PACKAGE
518 C REMARKS: A BAOPEN MUST HAVE ALREADY BEEN CALLED.
521 C LANGUAGE: FORTRAN 90
529 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
536 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
537 IRET=BACIO(BACIO_WRITE+BACIO_NOSEEK,ZERO,JB,SIZE,NB,KA,FD(LU),
539 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -