NCEPLIBS-bufr  11.7.0
 All Data Structures Files Functions Variables Pages
cobfl.h File Reference

Define signatures and declare variables for reading or writing BUFR messages via a C language interface. More...

Go to the source code of this file.

Functions

void ccbfl (void)
 This subroutine closes all system files that were opened via previous calls to subroutine cobfl(). More...
 
void cobfl (char *, char *)
 This subroutine opens a new file for reading or writing BUFR messages via a C language interface. More...
 
void crbmg (char *, f77int *, f77int *, f77int *)
 This subroutine reads the next BUFR message from the system file that was opened via the most recent call to subroutine cobfl() with io = 'r'. More...
 
void cwbmg (char *, f77int *, f77int *)
 This subroutine writes a BUFR message to the system file that was opened via the most recent call to subroutine cobfl() with io = 'w'. More...
 
f77int rbytes (char *, f77int *, f77int, f77int)
 This function reads a specified number of bytes from the system file that was opened via the most recent call to subroutine cobfl() with io = 'r'. More...
 

Variables

FILE * pbf [2]
 File pointers. More...
 

Detailed Description

Define signatures and declare variables for reading or writing BUFR messages via a C language interface.

These signatures and variables are used by the C language interface which encompasses subroutines cobfl(), crbmg(), cwbmg(), ccbfl() and rbytes().

Author
J. Ator
Date
2005-11-29

Definition in file cobfl.h.

Function Documentation

void ccbfl ( void  )

This subroutine closes all system files that were opened via previous calls to subroutine cobfl().

Author
J. Ator
Date
2005-11-29

Program history log:

Date Programmer Comments
2005-11-29 J. Ator Original author

Definition at line 20 of file ccbfl.c.

References pbf.

Referenced by main().

void cobfl ( char *  bfl,
char *  io 
)

This subroutine opens a new file for reading or writing BUFR messages via a C language interface.

Author
J. Ator
Date
2005-11-29
Parameters
[in]bfl– char*: System file to be opened. Inclusion of directory prefixes or other local filesystem notation is allowed, up to 200 total characters.
[in]io– char: Flag indicating how bfl is to be opened:
  • 'r' = input (for reading BUFR messages)
  • 'w' = output (for writing BUFR messages)

This subroutine is designed to be easily callable from application program written in either C or Fortran. It is functionally equivalent to subroutine openbf(); however, there are some important differences:

  • When using openbf(), the underlying file must already be associated with a Fortran logical unit number on the local system, typicially via a prior Fortran "OPEN" statement. This is not required when using this subroutine.
  • When using this subroutine, it is only possible to have at most one input (io = 'r') file and one output (io = 'w') file open at a time. If a successive call to this subroutine is made in either case where a file of that type is already open, then the subroutine will automatically close the previous file of that type before opening the new one.
  • When opening a file for input/reading using openbf(), the user can make subsequent calls to any of the BUFRLIB message-reading subroutines to read individual BUFR messages from that file into internal arrays, followed by subsequent calls to any of the BUFRLIB subset-reading subroutines) to read individual data subsets from each such message. However, when opening a file for input/reading using this subroutine, the user must instead make subsequent calls to crbmg() to read individual BUFR messages from that file, and each such message will be returned directly to the user within an allocated memory array. The user may then, if desired, make subsequent calls to readerme() to store each such message into the same internal arrays, followed by subsequent calls to any of the BUFRLIB subset-reading subroutines to read individual data subsets from each such message.
  • When opening a file for output/writing using openbf(), the user can make subsequent successive calls to writsb() to pack each completed data subset into the BUFR message that is currently open within the internal arrays, for eventual output to that file. However, when opening a file for output/writing using this subroutine, the user can instead, if desired, make subsequent successive calls to writsa() to pack each completed data subset into the BUFR message that is currently open within the internal arrays. The use of writsa() will cause each completed BUFR message to be returned directly to the user within an allocated memory array, which in turn can then be written directly to the file via a subsequent call to cwbmg().

Any errors encountered when using this subroutine are automatically logged to standard output, or to an alternate location previously specified via a call to subroutine errwrt().

Program history log:

Date Programmer Comments
2005-11-29 J. Ator Original author
2021-10-20 J. Ator Increase MXFNLEN to 200 characters

Definition at line 82 of file cobfl.c.

References bort(), pbf, and wrdlen().

Referenced by main().

void crbmg ( char *  bmg,
f77int *  mxmb,
f77int *  nmb,
f77int *  iret 
)

This subroutine reads the next BUFR message from the system file that was opened via the most recent call to subroutine cobfl() with io = 'r'.

Author
J. Ator
Date
2005-11-29
Parameters
[in]mxmb– f77int*: Dimensioned size (in bytes) of bmg; used by the subroutine to ensure that it doesn't overflow the bmg array
[out]bmg– char*: BUFR message
[out]nmb– f77int*: Size (in bytes) of BUFR message in bmg
[out]iret– f77int*: return code
  • 0 = normal return
  • 1 = overflow of bmg array
  • 2 = "7777" indicator not found in expected location
  • -1 = end-of-file encountered while reading
  • -2 = I/O error encountered while reading

This subroutine is designed to be easily callable from application program written in either C or Fortran.

The file from which messages are to be read must have already been opened for reading via a previous call to subroutine cobfl() with io = 'r'.

Any messages read that were encoded according to BUFR edition 0 or BUFR edition 1 are automatically converted to BUFR edition 2 before being returned by this subroutine.

Program history log:

Date Programmer Comments
2005-11-29 J. Ator Original author

Definition at line 48 of file crbmg.c.

References bort(), gets1loc(), ichkstr(), ipkm(), iupbs01(), iupm(), pbf, and rbytes().

Referenced by fdebufr().

void cwbmg ( char *  bmg,
f77int *  nmb,
f77int *  iret 
)

This subroutine writes a BUFR message to the system file that was opened via the most recent call to subroutine cobfl() with io = 'w'.

Author
J. Ator
Date
2005-11-29
Parameters
[in]bmg– char*: BUFR message to be written
[in]nmb– f77int*: Size (in bytes) of BUFR message in bmg
[out]iret– f77int*: return code
  • 0 = normal return
  • -1 = I/O error encountered while writing

This subroutine is designed to be easily callable from application program written in either C or Fortran.

The file to which the message is to be written must have already been opened for writing via a previous call to subroutine cobfl() with io = 'w'.

Program history log:

Date Programmer Comments
2005-11-29 J. Ator Original author

Definition at line 35 of file cwbmg.c.

References bort(), and pbf.

f77int rbytes ( char *  bmg,
f77int *  mxmb,
f77int  isloc,
f77int  newbytes 
)

This function reads a specified number of bytes from the system file that was opened via the most recent call to subroutine cobfl() with io = 'r'.

Author
J. Ator
Date
2005-11-29
Parameters
[in]mxmb– f77int*: Dimensioned size (in bytes) of bmg; used by the function to ensure that it doesn't overflow the bmg array
[in]isloc– f77int: Starting byte within bmg into which to read the next newbytes bytes
[in]newbytes– f77int: Number of bytes to read from system file most recently opened for input/reading via subroutine cobfl()
[out]bmg– char*: Array containing the newbytes bytes that were read, beginning at byte number isloc
Returns
rbytes – f77int: return code
  • 0 = normal return
  • 1 = overflow of bmg array
  • -1 = end-of-file encountered while reading
  • -2 = I/O error encountered while reading

Program history log:

Date Programmer Comments
2005-11-29 J. Ator Original author

Definition at line 40 of file rbytes.c.

References pbf.

Referenced by crbmg().

Variable Documentation

pbf

File pointers.

Referenced by ccbfl(), cobfl(), crbmg(), cwbmg(), and rbytes().