NCEPLIBS-bufr 11.7.1
bufr_c_interface_mod Module Reference

This module contains functions which wrap Fortran BUFRLIB functions and variables so they can be used from within C and C++ based apps. More...

Functions/Subroutines

subroutine, public closbf_c (bufr_unit)
 Wraps BUFRLIB "closbf" subroutine. More...
 
subroutine, public close_c (lunit)
 Wraps fortran "close" statement so we can close a Fortran file from a C program. More...
 
subroutine, public delete_table_data_c ()
 Deletes the copies of the moda_tables arrays. More...
 
subroutine, public exitbufr_c ()
 Wraps BUFRLIB "exitbufr" subroutine. Closes all open file units used by BUFRLIB. More...
 
subroutine, public get_inode_c (lun, start_node)
 Get the bufr node idx for the start node of the subset. More...
 
subroutine, public get_inv_c (lun, inv_ptr, inv_size)
 Get pointer to the moda_usrint INV array. More...
 
subroutine, public get_isc_c (isc_ptr, isc_size)
 Get copy of the moda_tables ISC array. More...
 
subroutine, public get_itp_c (itp_ptr, itp_size)
 Get copy of the moda_tables ITP array. More...
 
subroutine, public get_jmpb_c (jmpb_ptr, jmpb_size)
 Get copy of the moda_tables JMPB array. More...
 
subroutine, public get_link_c (link_ptr, link_size)
 Get copy of the moda_tables LINK array. More...
 
subroutine, public get_nval_c (lun, numNodes)
 Get the number of values in the current subset. More...
 
subroutine, public get_tag_c (tag_ptr, tag_len, mem_size)
 Get copy of the moda_tables TAG array. More...
 
subroutine, public get_typ_c (typ_ptr, typ_len, mem_size)
 Get copy of the moda_tables TYP array. More...
 
subroutine, public get_val_c (lun, val_ptr, val_size)
 Get pointer to the moda_usrint VAL array. More...
 
integer(c_int) function, public ireadmg_c (bufr_unit, c_subset, iddate, subset_str_len)
 Wraps BUFRLIB "ireadmg" subroutine. More...
 
integer(c_int) function, public ireadsb_c (bufr_unit)
 Wraps BUFRLIB "ireadsb" function. More...
 
subroutine, public mtinfo_c (path, file_unit_1, file_unit_2)
 Wraps BUFRLIB "mtinfo" function. More...
 
subroutine, public nemdefs_c (file_unit, mnemonic, unit_c, unit_str_len, desc_c, desc_str_len, iret)
 Gets Table B Unit and Description strings for a mnemonic. Wraps BUFRLIB "nemdefs". More...
 
subroutine, public nemspecs_c (file_unit, mnemonic, mnemonic_idx, scale, reference, bits, iret)
 Gets Table B scale, reference, and bits values. Wraps BUFRLIB "nemspecs". More...
 
subroutine, public nemtab_c (bufr_unit, mnemonic, descriptor, table_type, table_idx)
 This subroutine returns information about a descriptor from the internal DX BUFR tables, based on the mnemonic associated with that descriptor. Wraps BUFRLIB "nemtab". More...
 
subroutine, public nemtbb_c (bufr_unit, table_idx, unit_str, unit_str_len, scale, reference, bits)
 Get information about a Table B descriptor. Wraps BUFRLIB "nemtbb". More...
 
subroutine, public open_c (lunit, filepath)
 Wraps fortran "open" statement so we can open a Fortran file from a C program. More...
 
subroutine, public openbf_c (bufr_unit, cio, table_file_id)
 Wraps BUFRLIB "openbf" subroutine. More...
 
subroutine, public status_c (file_unit, lun, il, im)
 Get Raw BUFR data functions. More...
 
subroutine, public ufbint_c (bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
 Wraps BUFRLIB "ufbint" function. More...
 
subroutine, public ufbrep_c (bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
 Wraps BUFRLIB "ufbrep" function. More...
 

Detailed Description

This module contains functions which wrap Fortran BUFRLIB functions and variables so they can be used from within C and C++ based apps.

The signatures of the public functions match their Fortran equivalents, as shown within the documentation for each of the individual functions.

Local copies of some Fortran variables are stored as allocatable objects, especially isc, link, jmpb, tag and typ. It's the application program's responsibility to call delete_table_data_f in order to properly delete these variables.

Author
Ronald Mclaren
Date
2020-07-29

Function/Subroutine Documentation

◆ closbf_c()

subroutine, public bufr_c_interface_mod::closbf_c ( integer(c_int), intent(in), value  bufr_unit)

Wraps BUFRLIB "closbf" subroutine.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number to close

Definition at line 169 of file bufr_interface.f90.

References closbf().

◆ close_c()

subroutine, public bufr_c_interface_mod::close_c ( integer(c_int), intent(in), value  lunit)

Wraps fortran "close" statement so we can close a Fortran file from a C program.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]lunit- c_int: the integer to use as the fortran file unit

Definition at line 137 of file bufr_interface.f90.

◆ delete_table_data_c()

subroutine, public bufr_c_interface_mod::delete_table_data_c

Deletes the copies of the moda_tables arrays.

Author
Ronald McLaren
Date
2022-03-23

Definition at line 653 of file bufr_interface.f90.

◆ exitbufr_c()

subroutine, public bufr_c_interface_mod::exitbufr_c

Wraps BUFRLIB "exitbufr" subroutine. Closes all open file units used by BUFRLIB.

Author
Ronald McLaren
Date
2020-07-29

Definition at line 182 of file bufr_interface.f90.

References exitbufr().

◆ get_inode_c()

subroutine, public bufr_c_interface_mod::get_inode_c ( integer(c_int), intent(in), value  lun,
integer(c_int), intent(out)  start_node 
)

Get the bufr node idx for the start node of the subset.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]lun- c_int: pointer for the file stream
[out]start_node- c_int: the start node of the subset

Definition at line 582 of file bufr_interface.f90.

◆ get_inv_c()

subroutine, public bufr_c_interface_mod::get_inv_c ( integer(c_int), intent(in), value  lun,
type(c_ptr), intent(inout)  inv_ptr,
integer(c_int), intent(out)  inv_size 
)

Get pointer to the moda_usrint INV array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]lun- c_int: pointer for the file stream
[out]inv_ptr- c_ptr: c style pointer to the INV array
[out]inv_size- c_int: length of the array

Definition at line 637 of file bufr_interface.f90.

◆ get_isc_c()

subroutine, public bufr_c_interface_mod::get_isc_c ( type(c_ptr), intent(inout)  isc_ptr,
integer(c_int), intent(out)  isc_size 
)

Get copy of the moda_tables ISC array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]isc_ptr- c_ptr: c style pointer to the ISC array
[out]isc_size- c_int: length of the array

Definition at line 456 of file bufr_interface.f90.

References moda_tables::isc, and moda_tables::ntab.

◆ get_itp_c()

subroutine, public bufr_c_interface_mod::get_itp_c ( type(c_ptr), intent(inout)  itp_ptr,
integer(c_int), intent(out)  itp_size 
)

Get copy of the moda_tables ITP array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]itp_ptr- c_ptr: c style pointer to the ITP array
[out]itp_size- c_int: size of the ITP array

Definition at line 496 of file bufr_interface.f90.

References moda_tables::itp, and moda_tables::ntab.

◆ get_jmpb_c()

subroutine, public bufr_c_interface_mod::get_jmpb_c ( type(c_ptr), intent(inout)  jmpb_ptr,
integer(c_int), intent(out)  jmpb_size 
)

Get copy of the moda_tables JMPB array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]jmpb_ptr- c_ptr: c style pointer to the JMPB array
[out]jmpb_size- c_int: length of the array

Definition at line 562 of file bufr_interface.f90.

References moda_tables::jmpb, and moda_tables::ntab.

◆ get_link_c()

subroutine, public bufr_c_interface_mod::get_link_c ( type(c_ptr), intent(inout)  link_ptr,
integer(c_int), intent(out)  link_size 
)

Get copy of the moda_tables LINK array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]link_ptr- c_ptr: c style pointer to the LINK array
[out]link_size- c_int: size of the LINK array

Definition at line 476 of file bufr_interface.f90.

References moda_tables::link, and moda_tables::ntab.

◆ get_nval_c()

subroutine, public bufr_c_interface_mod::get_nval_c ( integer(c_int), intent(in), value  lun,
integer(c_int), intent(out)  numNodes 
)

Get the number of values in the current subset.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]lun- c_int: pointer for the file stream
[out]numNodes- c_int: number of values in the subset

Definition at line 599 of file bufr_interface.f90.

◆ get_tag_c()

subroutine, public bufr_c_interface_mod::get_tag_c ( type(c_ptr), intent(inout)  tag_ptr,
integer(c_int), intent(out)  tag_len,
integer(c_int), intent(out)  mem_size 
)

Get copy of the moda_tables TAG array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]tag_ptr- c_ptr: c style pointer to the TAG array
[out]tag_len- c_int: length of the tag string
[out]mem_size- c_int: size of TAG array

Definition at line 540 of file bufr_interface.f90.

References moda_tables::ntab, and moda_tables::tag.

◆ get_typ_c()

subroutine, public bufr_c_interface_mod::get_typ_c ( type(c_ptr), intent(inout)  typ_ptr,
integer(c_int), intent(out)  typ_len,
integer(c_int), intent(out)  mem_size 
)

Get copy of the moda_tables TYP array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]typ_ptr- c_ptr: c style pointer to the TYP array
[out]typ_len- c_int: length of the TYP str
[out]mem_size- c_int: length of the TYP array

Definition at line 517 of file bufr_interface.f90.

References moda_tables::ntab, and moda_tables::typ.

◆ get_val_c()

subroutine, public bufr_c_interface_mod::get_val_c ( integer(c_int), intent(in), value  lun,
type(c_ptr), intent(inout)  val_ptr,
integer(c_int), intent(out)  val_size 
)

Get pointer to the moda_usrint VAL array.

Author
Ronald McLaren
Date
2022-03-23
Parameters
[out]lun- c_int: pointer for the file stream
[out]val_ptr- c_ptr: c style pointer to the VAL array
[out]val_size- c_int: length of the array

Definition at line 617 of file bufr_interface.f90.

◆ ireadmg_c()

integer(c_int) function, public bufr_c_interface_mod::ireadmg_c ( integer(c_int), intent(in), value  bufr_unit,
character(kind=c_char, len=1), dimension(*), intent(out)  c_subset,
integer(c_int), intent(out)  iddate,
integer(c_int), intent(in), value  subset_str_len 
)

Wraps BUFRLIB "ireadmg" subroutine.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number to read from
[out]c_subset- c_char: the subset string
[out]iddate- c_int: datetime of message
[in]subset_str_len- c_int: length of the subset string

Definition at line 197 of file bufr_interface.f90.

References ireadmg().

◆ ireadsb_c()

integer(c_int) function, public bufr_c_interface_mod::ireadsb_c ( integer(c_int), intent(in), value  bufr_unit)

Wraps BUFRLIB "ireadsb" function.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number to read from

Definition at line 221 of file bufr_interface.f90.

References ireadsb().

◆ mtinfo_c()

subroutine, public bufr_c_interface_mod::mtinfo_c ( character(kind=c_char, len=1), intent(in)  path,
integer(c_int), intent(in), value  file_unit_1,
integer(c_int), intent(in), value  file_unit_2 
)

Wraps BUFRLIB "mtinfo" function.

Author
Ronald McLaren
Date
2021-02-24
Parameters
[in]path- c_char: the path where the WMO tables are stored
[in]file_unit_1- c_int: number to use for first file unit
[in]file_unit_2- c_int: number to use for second file unit

Definition at line 287 of file bufr_interface.f90.

References mtinfo().

◆ nemdefs_c()

subroutine, public bufr_c_interface_mod::nemdefs_c ( integer(c_int), intent(in), value  file_unit,
character(kind=c_char,len=1), dimension(*), intent(in)  mnemonic,
character(kind=c_char, len=1), dimension(*), intent(out)  unit_c,
integer(c_int), intent(in), value  unit_str_len,
character(kind=c_char, len=1), dimension(*), intent(out)  desc_c,
integer(c_int), intent(in), value  desc_str_len,
integer(c_int), intent(out)  iret 
)

Gets Table B Unit and Description strings for a mnemonic. Wraps BUFRLIB "nemdefs".

Author
Ronald McLaren
Date
2022-08-08
Parameters
[in]file_unit- c_int: Fortran file unit for the open file
[in]mnemonic- c_char: mnemonic
[out]unit_c- c_char: unit str
[in]unit_str_len- c_int: unit str length
[out]desc_c- c_char: description string
[in]desc_str_len- c_int: description str length
[out]iret- c_int: return value. 0 indicates success -1 indicates failure.

Definition at line 333 of file bufr_interface.f90.

References nemdefs().

◆ nemspecs_c()

subroutine, public bufr_c_interface_mod::nemspecs_c ( integer(c_int), intent(in), value  file_unit,
character(kind=c_char,len=1), dimension(*), intent(in)  mnemonic,
integer(c_int), intent(in), value  mnemonic_idx,
integer(c_int), intent(out)  scale,
integer(c_int), intent(out)  reference,
integer(c_int), intent(out)  bits,
integer(c_int), intent(out)  iret 
)

Gets Table B scale, reference, and bits values. Wraps BUFRLIB "nemspecs".

Author
Ronald McLaren
Date
2022-08-08
Parameters
[in]file_unit- c_int: Fortran file unit for the open file
[in]mnemonic- c_char: mnemonic
[in]mnemonic_idx- c_int: indicates specific mnemonic element (if repeated)
[out]scale- c_int: scale of element
[out]reference- c_int: reference of element
[out]bits- c_int: number of bits representing the element
[out]iret- c_int: return value. 0 indicates success -1 indicates failure.

Definition at line 371 of file bufr_interface.f90.

References nemspecs().

◆ nemtab_c()

subroutine, public bufr_c_interface_mod::nemtab_c ( integer(c_int), intent(in), value  bufr_unit,
character(kind=c_char,len=1), dimension(*), intent(in)  mnemonic,
integer(c_int), intent(out)  descriptor,
character(kind=c_char,len=1), dimension(*), intent(out)  table_type,
integer(c_int), intent(out)  table_idx 
)

This subroutine returns information about a descriptor from the internal DX BUFR tables, based on the mnemonic associated with that descriptor. Wraps BUFRLIB "nemtab".

Author
Ronald McLaren
Date
2022-08-16
Parameters
[in]bufr_unit- c_int: the bufr file pointer
[in]mnemonic- c_char: mnemonic
[out]descriptor- c_int: the binary descriptor for the mnemonic
[out]tabletype - c_char: 'A', 'B', 'C', or 'D', depending on table type
[out]table_idx- c_int: the table index, or 0 if not found

Definition at line 399 of file bufr_interface.f90.

References nemtab().

◆ nemtbb_c()

subroutine, public bufr_c_interface_mod::nemtbb_c ( integer(c_int), intent(in), value  bufr_unit,
integer(c_int), intent(in), value  table_idx,
character(kind=c_char,len=1), dimension(*), intent(out)  unit_str,
integer(c_int), intent(in), value  unit_str_len,
integer(c_int), intent(out)  scale,
integer(c_int), intent(out)  reference,
integer(c_int), intent(out)  bits 
)

Get information about a Table B descriptor. Wraps BUFRLIB "nemtbb".

Author
Ronald McLaren
Date
2022-08-16
Parameters
[in]bufr_unit- c_int: the bufr file pointer
[in]table_idx- c_int: Table B index
[out]unit_str- c_char: unit str
[in]unit_str_len- c_int: unit str length
[out]scale- c_int: scale of element
[out]reference- c_int: reference of element
[out]bits- c_int: bits of element

Definition at line 429 of file bufr_interface.f90.

References nemtbb().

◆ open_c()

subroutine, public bufr_c_interface_mod::open_c ( integer(c_int), intent(in), value  lunit,
character(kind=c_char, len=1)  filepath 
)

Wraps fortran "open" statement so we can open a Fortran file from a C program.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]lunit- c_int: the integer to use as the fortran file unit
[in]filepath- c_char: path to the file we want to open.

Definition at line 121 of file bufr_interface.f90.

◆ openbf_c()

subroutine, public bufr_c_interface_mod::openbf_c ( integer(c_int), intent(in), value  bufr_unit,
character(kind=c_char, len=1), intent(in)  cio,
integer(c_int), intent(in), value  table_file_id 
)

Wraps BUFRLIB "openbf" subroutine.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number
[in]cio- c_char: cio string
[in]table_file_id- c_int: table_file unit number

Definition at line 153 of file bufr_interface.f90.

References openbf().

◆ status_c()

subroutine, public bufr_c_interface_mod::status_c ( integer(c_int), intent(in), value  file_unit,
integer(c_int), intent(out)  lun,
integer(c_int), intent(out)  il,
integer(c_int), intent(out)  im 
)

Get Raw BUFR data functions.

Author
Ronald McLaren
Date
2022-03-23

Wraps BUFRLIB "status" function.

Parameters
[in]file_unit- c_int: the fortran file unit number to read from
[out]lun- c_int: pointer for the file stream
[out]il- c_int: file status
[out]im- c_int: message status

Definition at line 310 of file bufr_interface.f90.

References status().

◆ ufbint_c()

subroutine, public bufr_c_interface_mod::ufbint_c ( integer(c_int), intent(in), value  bufr_unit,
type(c_ptr), intent(inout)  c_data,
integer(c_int), intent(in), value  dim_1,
integer(c_int), intent(in), value  dim_2,
integer(c_int), intent(out)  iret,
character(kind=c_char, len=1), intent(in)  table_b_mnemonic 
)

Wraps BUFRLIB "ufbint" function.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number to read from
[in,out]c_data- c_ptr: c style pointer to a pre-allocated buffer
[in]dim_1,dim_2- c_int: dimensionality of data to read or write
[out]iret- c_int: return value, length of data read
[in]table_b_mnemonic- c_char: string of mnemonics

Definition at line 241 of file bufr_interface.f90.

References ufbint().

◆ ufbrep_c()

subroutine, public bufr_c_interface_mod::ufbrep_c ( integer(c_int), intent(in), value  bufr_unit,
type(c_ptr), intent(inout)  c_data,
integer(c_int), intent(in), value  dim_1,
integer(c_int), intent(in), value  dim_2,
integer(c_int), intent(out)  iret,
character(kind=c_char, len=1), intent(in)  table_b_mnemonic 
)

Wraps BUFRLIB "ufbrep" function.

Author
Ronald McLaren
Date
2020-07-29
Parameters
[in]bufr_unit- c_int: the fortran file unit number to read from
[in,out]c_data- c_ptr: c style pointer to a pre-allocated buffer
[in]dim_1,dim_2- c_int: dimensionality of data to read or write
[out]iret- c_int: return value, length of data read
[in]table_b_mnemonic- c_char: string of mnemonics

Definition at line 265 of file bufr_interface.f90.

References ufbrep().