updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / external / bufr / cwbmg.c
bloba9c675b8ed18402f54b9fa3a44dd98c29376ab0b
1 /*$$$ SUBPROGRAM DOCUMENTATION BLOCK
3 C SUBPROGRAM: CWBMG
4 C PRGMMR: ATOR ORG: NP12 DATE: 2005-11-29
6 C ABSTRACT: THIS ROUTINE WRITES A SPECIFIED NUMBER OF BYTES TO THE
7 C SYSTEM FILE MOST RECENTLY OPENED FOR WRITING/OUTPUT VIA BUFR
8 C ARCHIVE LIBRARY ROUTINE COBFL.
10 C PROGRAM HISTORY LOG:
11 C 2005-11-29 J. ATOR -- ORIGINAL AUTHOR
13 C USAGE: CALL CWBMG( BMG, NMB, IRET )
14 C INPUT ARGUMENT LIST:
15 C BMG - CHARACTER*1: ARRAY CONTAINING BYTES TO BE WRITTEN
16 C NMB - INTEGER: NUMBER OF BYTES WITHIN BMG TO BE WRITTEN
18 C OUTPUT ARGUMENT LIST:
19 C IRET - INTEGER: RETURN CODE:
20 C 0 = normal return
21 C -1 = I/O error occurred while writing
23 C REMARKS:
24 C THIS ROUTINE CALLS: BORT
25 C THIS ROUTINE IS CALLED BY: None
26 C Normally called only by application
27 C programs.
29 C ATTRIBUTES:
30 C LANGUAGE: C
31 C MACHINE: PORTABLE TO ALL PLATFORMS
33 C$$$*/
35 #include "bufrlib.h"
37 void cwbmg( char *bmg, f77int *nmb, f77int *iret )
39 char errstr[129];
42 ** Make sure that a file is open for writing.
44 if ( pbf[1] == NULL ) {
45 sprintf( errstr, "BUFRLIB: CWBMG - NO FILE IS OPEN FOR WRITING" );
46 bort( errstr, ( f77int ) strlen( errstr ) );
49 ** Write the BUFR message to the file.
51 *iret = ( ( fwrite( bmg, 1, *nmb, pbf[1] ) == *nmb ) ? 0 : -1 );
53 return;