NCEPLIBS-bufr
12.1.0
|
Open or close a file to the library. More...
Go to the source code of this file.
Functions/Subroutines | |
recursive subroutine | closbf (lunit) |
Close the connection between logical unit lunit and the NCEPLIBS-bufr software. More... | |
recursive subroutine | fortran_close (lunit, iret) |
Close a Fortran file on the local system. More... | |
recursive subroutine | fortran_open (filename, lunit, format, position, iret) |
Open a Fortran file on the local system. More... | |
recursive subroutine | openbf (lunit, io, lundx) |
Connect a new file to the NCEPLIBS-bufr software for input or output operations, or initialize the library without connecting to a file, or change the verbosity of the library for an already-connected BUFR file. More... | |
subroutine | posapx (lunxx) |
Position an output BUFR file for appending. More... | |
subroutine | rewnbf (lunit, isr) |
Store or restore parameters associated with a BUFR file. More... | |
recursive subroutine | status (lunit, lun, il, im) |
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr software. More... | |
recursive subroutine | ufbcnt (lunit, kmsg, ksub) |
Get the current location of the file pointer within a BUFR file, in terms of a message number counting from the beginning of the file, and a data subset number counting from the beginning of that message. More... | |
recursive subroutine | ufbtab (lunin, tab, i1, i2, iret, str) |
Read through every data subset in a BUFR file and return one or more specified data values from each subset. More... | |
subroutine | wtstat (lunit, lun, il, im) |
Update file status in library internals. More... | |
recursive subroutine closbf | ( | integer, intent(in) | lunit | ) |
Close the connection between logical unit lunit and the NCEPLIBS-bufr software.
lunit | - Fortran logical unit number for BUFR file |
Definition at line 337 of file openclosebf.F90.
References closmg(), errwrt(), moda_nulbfr::null, status(), wtstat(), and x84().
Referenced by apxdx(), bufr_c2f_interface::closbf_c(), copybf(), datebf(), dumpbf(), exitbufr(), gettab(), mesgbc(), mesgbf(), split_by_subset(), ufbinx(), ufbmem(), ufbmex(), and ufbtab().
recursive subroutine fortran_close | ( | integer, intent(in) | lunit, |
integer, intent(out) | iret | ||
) |
Close a Fortran file on the local system.
lunit | - Fortran logical unit number for Fortran file |
iret | - return code from the Fortran close statement |
Definition at line 48 of file openclosebf.F90.
recursive subroutine fortran_open | ( | character*(*), intent(in) | filename, |
integer, intent(in) | lunit, | ||
character*(*), intent(in) | format, | ||
character*(*), intent(in) | position, | ||
integer, intent(out) | iret | ||
) |
Open a Fortran file on the local system.
filename | - name of the file to be opened |
lunit | - Fortran logical unit number for Fortran file |
format | - format of the Fortran file |
position | - to rewind or continue with open file |
iret | - return code from the Fortran open statement |
Definition at line 15 of file openclosebf.F90.
recursive subroutine openbf | ( | integer, intent(in) | lunit, |
character*(*), intent(in) | io, | ||
integer, intent(in) | lundx | ||
) |
Connect a new file to the NCEPLIBS-bufr software for input or output operations, or initialize the library without connecting to a file, or change the verbosity of the library for an already-connected BUFR file.
The logical unit numbers lunit and lundx must already be associated with actual filenames on the local system, typically via a Fortran "OPEN" statement. Multiple logical units can be connected to the NCEPLIBS-bufr software at any one time.
The argument io is a character string describing how the file connected to lunit will be used, e.g. 'IN' is used to access an existing file of BUFR messages for input (i.e. reading/decoding BUFR), and 'OUT' is used to access a new file for output (i.e. writing/encoding BUFR). An option 'APX' is also available which behaves like 'OUT', except that output is then appended to an existing BUFR file rather than creating a new one from scratch, and there are also some additional options 'NUL' and 'NODX' which can likewise be used instead of 'OUT' for some very special cases as needed. There's also an option 'SEC3' which can be used in place of 'IN' for certain cases when the user is attempting to read BUFR messages whose content and descriptor layout are unknown in advance. However, all of these additional options are basically just variations of 'IN' or 'OUT', again depending on whether the intent is to read or write BUFR messages from the file connected to lunit. The only exceptions are when io = 'FIRST' or 'QUIET'. When io = 'FIRST', the subroutine simply checks whether it has already been called from within the application program and, if not, goes ahead and initializes the library without actually connecting any files in lunit or lundx.
Alternatively, when io = 'QUIET', the subroutine simply sets or resets the internal print verbosity switch to the value of input argument lundx, overriding its previous value and/or its internal default value of 0.
The third and final call argument lundx identifies the logical unit which contains the definition of the DX BUFR tables to be associated with unit lunit. Except when io = 'SEC3', every BUFR file that is linked to the NCEPLIBS-bufr software must have a DX BUFR tables file associated with it, and these tables may be defined within a separate ASCII text file (see Description and Format of DX BUFR Tables for more info.) or, in the case of an existing BUFR file, may be embedded within the first few BUFR messages of the file itself, and in which case the user can denote this to the subroutine by setting lundx to the same value as lunit.
lunit | - Fortran logical unit number for BUFR file (unless io is set to 'FIRST' or 'QUIET', in which case this is a dummy argument) |
io | - flag indicating how lunit is to be used by the software:
|
lundx | - Fortran logical unit number containing DX BUFR table information, except as noted below:
|
Definition at line 168 of file openclosebf.F90.
References arallocf(), bfrini(), bort(), errwrt(), moda_msgcwd::idate, moda_msgcwd::inode, moda_sc3bfr::isc3, moda_stcode::iscodes, moda_lushr::lus, moda_msgcwd::msub, moda_msgcwd::nmsg, moda_msgcwd::nsub, moda_nulbfr::null, posapx(), readdx(), status(), writdx(), wtstat(), and x84().
Referenced by apxdx(), binv(), cmpbqm(), copybf(), datebf(), dumpbf(), fdebufr_c(), gettab(), mesgbc(), mesgbf(), bufr_c2f_interface::openbf_c(), pkvs01(), rdmgsb(), readbp(), readmp(), sinv(), split_by_subset(), ufbinx(), ufbmem(), ufbmex(), and ufbtab().
subroutine posapx | ( | integer, intent(in) | lunxx | ) |
Position an output BUFR file for appending.
Read to the end of the file pointed to by abs(lunxx) and position it for appending. The file must have already been opened for output operations. If lunxx < 0, then the file is not backspaced before being positioned for append.
lunxx | - Absolute value is Fortran logical unit number for BUFR file |
Definition at line 630 of file openclosebf.F90.
References bort(), moda_mgwa::mgwa, rdbfdx(), rdmsgw(), and status().
Referenced by openbf().
subroutine rewnbf | ( | integer, intent(in) | lunit, |
integer, intent(in) | isr | ||
) |
Store or restore parameters associated with a BUFR file.
Depending on the value of isr, either:
This allows information to be extracted from a particular subset in a BUFR file which is in the midst of being read from or written to by an application program. Note that, for any given BUFR file, a call to this subroutine with isr = 0 must precede a call to this same subroutine with isr = 1. An application program might first call this subroutine with isr = 0, then call either subroutine rdmgsb() or ufbinx() to get information from a subset, then call this routine again with isr = 1 to restore the pointers in the BUFR file to their original location. For example, this subroutine is called internally by subroutine ufbtab() whenever the BUFR file it is acting upon is already open for input or output.
lunit | - Fortran logical unit number for BUFR file. |
isr | - Switch:
|
Definition at line 693 of file openclosebf.F90.
References bort(), moda_bitbuf::ibit, moda_bufrsr::jbay, moda_bufrsr::jbit, moda_bufrsr::jbyt, moda_bufrsr::jill, moda_bufrsr::jimm, moda_bufrsr::jmsg, moda_bufrsr::jsr, moda_bufrsr::jsub, moda_bufrsr::junn, moda_bitbuf::mbay, moda_bitbuf::mbyt, moda_msgcwd::nmsg, moda_msgcwd::nsub, readmg(), readsb(), status(), and wtstat().
recursive subroutine status | ( | integer, intent(in) | lunit, |
integer, intent(out) | lun, | ||
integer, intent(out) | il, | ||
integer, intent(out) | im | ||
) |
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr software.
If the unit number is already connected, then the subroutine returns information about the associated file. Otherwise, it returns the next available file ID that could be used to connect the associated file to the software via a subsequent call to subroutine wtstat().
lunit | - Fortran logical unit number for BUFR file |
lun | - File ID associated with lunit
|
il | - File status:
|
im | - Message status, indicating whether there is already a message open within internal arrays for lunit:
|
Definition at line 405 of file openclosebf.F90.
References bort(), errwrt(), moda_stbfr::iolun, moda_stbfr::iomsg, x48(), and x84().
Referenced by closbf(), closmg(), copybf(), copymg(), copysb(), cpdxmm(), cpymem(), datebf(), drfini(), dumpbf(), dxdump(), getabdb(), getcfmng(), gettab(), gettagpr(), gettagre(), getvalnb(), ifbget(), igetsc(), invmrg(), iupvs01(), lcmgdf(), mesgbc(), minimg(), msgwrt(), nemdefs(), nemspecs(), nmsub(), openbf(), openmb(), openmg(), posapx(), rdmemm(), rdmems(), rdmgsb(), rdmsgw(), readdx(), readerme(), readlc(), readmg(), readns(), readsb(), rewnbf(), rtrcpt(), setvalnb(), bufr_c2f_interface::status_c(), stndrd(), ufbcnt(), ufbcpy(), ufbcup(), ufbdmp(), ufbevn(), ufbget(), ufbin3(), ufbint(), ufbinx(), ufbmem(), ufbmms(), ufbovr(), ufbpos(), ufbqcd(), ufbqcp(), ufbrep(), ufbrms(), ufbseq(), ufbstp(), ufbtab(), ufbtam(), ufdump(), upftbv(), wrcmps(), wrdxtb(), writlc(), writsa(), and writsb().
recursive subroutine ufbcnt | ( | integer, intent(in) | lunit, |
integer, intent(out) | kmsg, | ||
integer, intent(out) | ksub | ||
) |
Get the current location of the file pointer within a BUFR file, in terms of a message number counting from the beginning of the file, and a data subset number counting from the beginning of that message.
lunit | - Fortran logical unit number for BUFR file |
kmsg | - Ordinal number of current message, counting from the beginning of the BUFR file, but not counting any messages which contain DX BUFR tables information |
ksub | - Ordinal number of current data subset within (kmsg)th message, counting from the beginning of the message |
Definition at line 585 of file openclosebf.F90.
References bort(), moda_msgcwd::nmsg, moda_msgcwd::nsub, status(), x48(), and x84().
recursive subroutine ufbtab | ( | integer, intent(in) | lunin, |
real*8, dimension(i1,i2), intent(out) | tab, | ||
integer, intent(in) | i1, | ||
integer, intent(in) | i2, | ||
integer, intent(out) | iret, | ||
character*(*), intent(in) | str | ||
) |
Read through every data subset in a BUFR file and return one or more specified data values from each subset.
This provides a useful way to scan the ranges of one or more specified data values across all of the data subsets within an entire BUFR file. It is similar to subroutine ufbtam(), except that ufbtam() works on data subsets within internal arrays.
It is the user's responsibility to ensure that tab is dimensioned sufficiently large enough to accommodate the number of data values that are to be read from the BUFR file. Specifically, each row of tab will contain the data values read from a different data subset, so the value i2 must be at least as large as the total number of data subsets in the BUFR file.
If logical unit abs(lunin) has already been opened via a previous call to subroutine openbf(), then this subroutine will save the current file position, rewind the file to the beginning, read through the entire file, and then restore it to its previous file position. Otherwise, if logical unit abs(lunin) has not already been opened via a previous call to subroutine openbf(), then this subroutine will open it via an internal call to subroutine openbf(), read through the entire file, and then close it via an internal call to subroutine closbf().
lunin | - Absolute value is Fortran logical unit number for BUFR file |
tab | - Data values |
i1 | - First dimension of tab as allocated within the calling program |
i2 | - Second dimension of tab as allocated within the calling program |
iret | - Number of data subsets in BUFR file |
str | - String of blank-separated Table B mnemonics, in one-to-one correspondence with the number of data values that will be read from each data subset within the first dimension of tab (see DX BUFR Tables for further information about Table B mnemonics) |
Definition at line 856 of file openclosebf.F90.
References bort(), closbf(), errwrt(), moda_bitbuf::ibit, moda_tables::ibt, moda_usrint::inv, ireadmg(), ireadsb(), moda_tables::itp, moda_bitbuf::mbay, moda_bitbuf::mbyt, moda_unptyp::msgunp, moda_msgcwd::msub, moda_msgcwd::nmsg, nmsub(), moda_msgcwd::nsub, moda_usrint::nval, openbf(), parstr(), rewnbf(), status(), string(), up8(), upb(), upb8(), upc(), ups(), usrtpl(), x48(), and x84().
Referenced by sinv().
subroutine wtstat | ( | integer, intent(in) | lunit, |
integer, intent(in) | lun, | ||
integer, intent(in) | il, | ||
integer, intent(in) | im | ||
) |
Update file status in library internals.
This subroutine can be used to connect or disconnect a specified Fortran logical unit number to/from the NCEPLIBS-bufr software, and it can also be used to set or reset the internal message status associated with that logical unit number.
lunit | - Fortran logical unit number for BUFR file |
lun | - File ID associated with lunit |
il | - File status update option:
|
im | - Message status update option, indicating whether a message is currently open within the internal arrays for lunit:
|
Definition at line 508 of file openclosebf.F90.
References bort(), moda_stbfr::iolun, and moda_stbfr::iomsg.
Referenced by closbf(), closmg(), openbf(), openmb(), openmg(), rdmemm(), readerme(), readmg(), and rewnbf().