NCEPLIBS-bacio  2.6.0
baciof.F90 File Reference

Contains subroutines to read/write binary files. More...

Go to the source code of this file.

Data Types

interface  bacio_module::baciol
 

Modules

module  bacio_module
 Contains subroutines to read/write binary files.
 

Functions/Subroutines

subroutine baclose (LU, IRET)
 Close a byte-addressable file. More...
 
subroutine baopen (LU, CFN, IRET)
 Open a byte-addressable file. More...
 
subroutine baopenr (LU, CFN, IRET)
 Open a byte-addressable file for read only. More...
 
subroutine baopenw (LU, CFN, IRET)
 Open a byte-addressable file for write only. More...
 
subroutine baopenwa (LU, CFN, IRET)
 Open a byte-addressable file for write only with append. More...
 
subroutine baopenwt (LU, CFN, IRET)
 Open a byte-addressable file for write only with truncation. More...
 
subroutine baread (LU, IB, NB, KA, A)
 This subroutine calls bareadl() to read a given number of bytes from an unblocked file, skipping a given number of bytes. More...
 
subroutine bareadl (LU, IB, NB, KA, A)
 This subrouytine is using updated baciol() I/O package to read a given number of bytes from an unblocked file, skipping a given number of bytes. More...
 
subroutine baseto (NOPT, VOPT)
 Set options for byte-addressable I/O. More...
 
subroutine bawrite (LU, IB, NB, KA, A)
 This program is calling bawritel() to write a given number of bytes to an unblocked file, skipping a given number of bytes. More...
 
subroutine bawritel (LU, IB, NB, KA, A)
 This subrouytine writes a given number of bytes to an unblocked file, skipping a given number of bytes. More...
 
subroutine wryte (LU, NB, A)
 This subroutine is calling wrytel() to write a given number of bytes to an unblocked file. More...
 
subroutine wrytel (LU, NB, A)
 Write a given number of bytes to an unblocked file. More...
 

Variables

integer, parameter bacio_module::bacio_close = 8
 Close file. More...
 
integer, parameter bacio_module::bacio_noseek = 64
 Start I/O from previous spot. More...
 
integer, parameter bacio_module::bacio_openr = 1
 Open file for read only. More...
 
integer, parameter bacio_module::bacio_openrw = 4
 Open file for read or write. More...
 
integer, parameter bacio_module::bacio_openw = 2
 Open file for write only. More...
 
integer, parameter bacio_module::bacio_openwa = 256
 Open for write only with append. More...
 
integer, parameter bacio_module::bacio_openwt = 128
 Open for write only with truncation. More...
 
integer, parameter bacio_module::bacio_read = 16
 Read from the file. More...
 
integer, parameter bacio_module::bacio_write = 32
 Write to the file. More...
 
integer, dimension(20), save bacio_module::baopts = 0
 Array of option settings. More...
 
integer, dimension(fddim), save bacio_module::fd = FDDIM*0
 Array IDs of currently open files. More...
 
integer, parameter bacio_module::fddim = 9999
 Maximum number of open files in bacio library. More...
 

Detailed Description

Contains subroutines to read/write binary files.

Author
Mark Iredell
Date
98-06-04

Definition in file baciof.F90.

Function/Subroutine Documentation

◆ baclose()

subroutine baclose ( integer, intent(in)  LU,
integer, intent(out)  IRET 
)

Close a byte-addressable file.

Parameters
luunit to close.
iretreturn code.
Author
Mark Iredell
Date
98-06-04

Definition at line 316 of file baciof.F90.

References bacio_module::bacio_close, bacio_module::fd, and bacio_module::fddim.

◆ baopen()

subroutine baopen ( integer, intent(in)  LU,
character, dimension(*), intent(in)  CFN,
integer, intent(out)  IRET 
)

Open a byte-addressable file.

Parameters
luunit to open.
cfnfilename to open (consisting of nonblank printable characters).
iretreturn code
Author
Mark Iredell
Date
98-06-04

Definition at line 108 of file baciof.F90.

References bacio_module::bacio_openrw, bacio_module::fd, and bacio_module::fddim.

◆ baopenr()

subroutine baopenr ( integer, intent(in)  LU,
character, dimension(*), intent(in)  CFN,
integer, intent(out)  IRET 
)

Open a byte-addressable file for read only.

Parameters
luunit to open.
cfnfilename to open (consisting of nonblank printable characters).
iretreturn code.
Author
Mark Iredell
Date
98-06-04

Definition at line 150 of file baciof.F90.

References bacio_module::bacio_openr, bacio_module::fd, and bacio_module::fddim.

◆ baopenw()

subroutine baopenw ( integer, intent(in)  LU,
character, dimension(*), intent(in)  CFN,
integer, intent(out)  IRET 
)

Open a byte-addressable file for write only.

Parameters
luunit to open.
cfnfilename to open (consisting of nonblank printable characters).
iretreturn code.
Author
Mark Iredell
Date
98-06-04

Definition at line 192 of file baciof.F90.

References bacio_module::bacio_openw, bacio_module::fd, and bacio_module::fddim.

◆ baopenwa()

subroutine baopenwa ( integer, intent(in)  LU,
character, dimension(*), intent(in)  CFN,
integer, intent(out)  IRET 
)

Open a byte-addressable file for write only with append.

Parameters
luunit to open.
cfnfilename to open (consisting of nonblank printable characters).
iretreturn code.
Author
Mark Iredell
Date
98-06-04

Definition at line 276 of file baciof.F90.

References bacio_module::bacio_openwa, bacio_module::fd, and bacio_module::fddim.

◆ baopenwt()

subroutine baopenwt ( integer, intent(in)  LU,
character, dimension(*), intent(in)  CFN,
integer, intent(out)  IRET 
)

Open a byte-addressable file for write only with truncation.

Parameters
luunit to open.
cfnfilename to open (consisting of nonblank printable characters).
iretreturn code.
Author
Mark Iredell
Date
98-06-04

Definition at line 234 of file baciof.F90.

References bacio_module::bacio_openwt, bacio_module::fd, and bacio_module::fddim.

◆ baread()

subroutine baread ( integer, intent(in)  LU,
integer, intent(in)  IB,
integer, intent(in)  NB,
integer, intent(out)  KA,
character, dimension(nb), intent(out)  A 
)

This subroutine calls bareadl() to read a given number of bytes from an unblocked file, skipping a given number of bytes.

The physical I/O is blocked into four 4096-byte buffers if the byte-addressable option 1 has been set to 1 by baseto. This buffered reading is incompatible with no-seek reading.

Note
The data in the I/O buffer is not cleared when the file is closed and reopened, or when any other operation on the file is done. So it may contian out-of-date data, if the data file has been changed after the buffers were filled. Use with caution.
Parameters
luunit to read.
ibnumber of bytes to skip. (If ib<0, then the file is accessed with no seeking)
nbnumber of bytes to read.
kanumber of bytes actually read.
aBuffer where data are copied to from file. Must be of sufficient size to hold data.
Note
A baopen() must have already been called.
Author
Mark Iredell
Date
98-06-04

Definition at line 358 of file baciof.F90.

References bareadl().

◆ bareadl()

subroutine bareadl ( integer, intent(in)  LU,
integer(kind=8), intent(in)  IB,
integer(kind=8), intent(in)  NB,
integer(kind=8), intent(out)  KA,
character, dimension(nb), intent(out)  A 
)

This subrouytine is using updated baciol() I/O package to read a given number of bytes from an unblocked file, skipping a given number of bytes.

The physical I/O is blocked into four 4096-byte buffers if the byte-addressable option 1 has been set to 1 by baseto. This buffered reading is incompatible with no-seek reading.

Note
The data in the I/O buffer is not cleared when the file is closed and reopened, or when any other operation on the file is done. So it may contian out-of-date data, if the data file has been changed after the buffers were filled. Use with caution.
Parameters
[in]luunit to read.
[in]ibnumber of bytes to skip (if ib<0, then the file is accessed with no seeking).
[in]nbnumber of bytes to read.
[out]kanumber of bytes actually read.
[out]aBuffer where data are copied to from file. Must be of sufficient size to hold data.
Note
A baopen() must have already been called.
Author
Mark Iredell
Date
98-06-04

Definition at line 401 of file baciof.F90.

References bacio_module::bacio_noseek, bacio_module::bacio_read, bacio_module::baopts, bacio_module::fd, and bacio_module::fddim.

Referenced by bafrindexl(), bafrreadl(), and baread().

◆ baseto()

subroutine baseto ( integer  NOPT,
integer  VOPT 
)

Set options for byte-addressable I/O.

(There is currently only one valid option.)

All options default to 0.

Option 1: Blocked reading option:

If the option value is 1, then the reading is blocked into four 4096-byte buffers. This may be efficient if the reads will be requested in much smaller chunks. otherwise, each call to baread initiates a physical read.

Parameters
noptoption number.
voptoption value.
Author
Mark Iredell
Date
98-06-04

Definition at line 79 of file baciof.F90.

References bacio_module::baopts.

◆ bawrite()

subroutine bawrite ( integer, intent(in)  LU,
integer, intent(in)  IB,
integer, intent(in)  NB,
integer, intent(out)  KA,
character, dimension(nb), intent(in)  A 
)

This program is calling bawritel() to write a given number of bytes to an unblocked file, skipping a given number of bytes.

Parameters
[in]luunit to write.
[in]ibnumber of bytes to skip. (If ib<0, then the file is accessed with no seeking.)
[in]nbnumber of bytes to write.
[out]kainteger number of bytes actually written.
[in]adata to write.
Note
A baopen() must have already been called.

Definition at line 506 of file baciof.F90.

References bawritel().

◆ bawritel()

subroutine bawritel ( integer, intent(in)  LU,
integer(kind = 8), intent(in)  IB,
integer(kind = 8), intent(in)  NB,
integer(kind = 8), intent(out)  KA,
character, dimension(nb), intent(in)  A 
)

This subrouytine writes a given number of bytes to an unblocked file, skipping a given number of bytes.

Parameters
[in]luunit to write.
[in]ibnumber of bytes to skip. (If ib < 0, then the file is accessed with no seeking).
[in]nbnumber of bytes to write.
[out]kanumber of bytes actually written.
[in]adata to write.
Author
Mark Iredell
Date
92-10-31

Definition at line 537 of file baciof.F90.

References bacio_module::bacio_noseek, bacio_module::bacio_write, bacio_module::fd, and bacio_module::fddim.

Referenced by bafrwritel(), and bawrite().

◆ wryte()

subroutine wryte ( integer, intent(in)  LU,
integer, intent(in)  NB,
character, dimension(nb), intent(in)  A 
)

This subroutine is calling wrytel() to write a given number of bytes to an unblocked file.

Parameters
[in]luunit to which to write.
[in]nbnumber of bytes to write.
[in]adata to write.
Note
A baopen must have already been called.
Author
Mark Iredell
Date
92-10-31

Definition at line 582 of file baciof.F90.

References wrytel().

◆ wrytel()

subroutine wrytel ( integer, intent(in)  LU,
integer(kind = 8), intent(in)  NB,
character, dimension(nb), intent(in)  A 
)

Write a given number of bytes to an unblocked file.

Note
A baopen must have already been called.
Parameters
[in]luunit to which to write.
[in]nbnumber of bytes to write.
[in]adata to write.
Author
Mark Iredell
Date
92-10-31

Definition at line 608 of file baciof.F90.

References bacio_module::bacio_noseek, bacio_module::bacio_write, bacio_module::fd, and bacio_module::fddim.

Referenced by wryte().