31 pb[nfile] = fopen(ufile,
"rb ");
44 pb[nfile] = fopen(ufile,
"wb ");
57 pb[nfile] = fopen(ufile,
"a+b");
116 int nbytrem, nintrem, nbytx, nintx, wkint[2], ii;
117 size_t nb =
sizeof(int), nbdi8 = 8/
sizeof(
int);
118 char wkchr[17] =
" ";
123 while (strncmp(wkchr,
"BUFR", 4) != 0) {
124 memmove(wkchr, &wkchr[1], 3);
125 if (fread(wkchr + 3, 1, 1,
pb[nfile]) != 1)
130 fgetpos(
pb[nfile], &nxtpos);
133 if (fread(wkchr+4, 1, 4,
pb[nfile]) != 4)
138 memcpy(wkint, wkchr, 8);
141 nintrem = nbytrem / nb;
147 if ( ( nbytx = nbytrem % nb ) > 0 ) {
151 if (nintrem + nintx > mxwrd) {
152 fsetpos(
pb[nfile], &nxtpos);
157 for ( ii = 0; ii < nbdi8; ii++ ) {
158 bufr[ii] = wkint[ii];
162 if (fread(&bufr[ii], nb, nintrem-1,
pb[nfile]) != nintrem-1) {
163 fsetpos(
pb[nfile],&nxtpos);
171 nbytrem = nb + nbytx;
172 if (fread(wkchr, 1, nbytrem,
pb[nfile]) != nbytrem) {
173 fsetpos(
pb[nfile], &nxtpos);
176 if (strncmp(&wkchr[nbytrem-4],
"7777", 4) != 0) {
177 fsetpos(
pb[nfile], &nxtpos);
181 memcpy(wkint, wkchr, nbytrem);
182 bufr[nintrem + 1] = wkint[0];
183 if ( nbytx > 0 ) bufr[nintrem + 2] = wkint[1];
200 size_t nb =
sizeof(int);
202 fwrite(bufr, nb, nwrd,
pb[nfile]);
int iupbs01_f(int *bufr, char *mnemonic)
Read a data value from Section 0 or Section 1 of a BUFR message.
Enable a number of NCEPLIBS-bufr subprograms to be called from within the C part of the library.
void closfb(int nfile)
Close a previously opened BUFR file.
int crdbufr(int nfile, int *bufr, int mxwrd)
Read the next message from a BUFR file that was previously opened for reading.
void openab(int nfile, char *ufile)
Open a new file for appending BUFR messages.
void cwrbufr(int nfile, int *bufr, int nwrd)
Write a BUFR message into a file that was previously opened for writing.
void openwb(int nfile, char *ufile)
Open a new file for writing BUFR messages.
void openrb(int nfile, char *ufile)
Open a new file for reading BUFR messages.
void backbufr(int nfile)
Backspace a BUFR file by one BUFR message.
void cewind(int nfile)
Rewind a BUFR file back to its beginning.
Declare variables for reading or writing BUFR messages via a C language interface.
fpos_t * lstpos
Byte positions of last successful reads from files corresponding to pb, for files that were opened fo...