NCEPLIBS-bufr  11.5.0
 All Data Structures Files Functions Variables Pages
cobfl.c File Reference

Open a new system file for reading or writing BUFR messages via a C language interface. More...

#include "bufrlib.h"
#include "cobfl.h"

Go to the source code of this file.

Macros

#define IN_COBFL
 
#define MXFNLEN   100
 

Functions

void cobfl (char *bfl, char *io)
 This subroutine opens a new file for reading or writing BUFR messages via a C language interface. More...
 

Detailed Description

Open a new system file for reading or writing BUFR messages via a C language interface.

Definition in file cobfl.c.

Function Documentation

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 100 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:

  • 2005-11-29 J. Ator – Original author

Definition at line 79 of file cobfl.c.

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

Referenced by main().