53 integer,
allocatable,
target,
save :: isc_f(:)
54 integer,
allocatable,
target,
save :: link_f(:)
55 integer,
allocatable,
target,
save :: itp_f(:)
56 integer,
allocatable,
target,
save :: jmpb_f(:)
57 character(len=10),
allocatable,
target,
save :: tag_f(:)
58 character(len=3),
allocatable,
target,
save :: typ_f(:)
72function c_f_string(c_str)
result(f_str)
73 character(kind=c_char,len=1),
intent(in) :: c_str(*)
74 character(len=:),
allocatable :: f_str
78 do while (c_str(nchars) /= c_null_char)
83 allocate(
character(len=nchars) :: f_str)
84 f_str = transfer(c_str(1:nchars), f_str)
85end function c_f_string
97subroutine copy_f_c_str(f_str, c_str, c_str_len)
98 character(len=*),
target,
intent(in) :: f_str
99 character(kind=c_char, len=1),
intent(inout) :: c_str(*)
100 integer,
intent(in) :: c_str_len
101 integer :: max_str_len
103 if (c_str_len /= 0)
then
104 max_str_len = c_str_len
105 c_str(1)(1:max_str_len) = f_str(1:max_str_len)
106 c_str(1)(max_str_len:max_str_len) = c_null_char
108end subroutine copy_f_c_str
121subroutine open_c(lunit, filepath) bind(C, name='open_f')
122 integer(c_int),
value,
intent(in) :: lunit
123 character(kind=c_char, len=1) :: filepath
125 open(lunit, file=c_f_string(filepath))
137subroutine close_c(lunit) bind(C, name='close_f')
138 integer(c_int),
value,
intent(in) :: lunit
153subroutine openbf_c(bufr_unit, cio, table_file_id) bind(C, name='openbf_f')
154 integer(c_int),
value,
intent(in) :: bufr_unit
155 character(kind=c_char, len=1),
intent(in) :: cio
156 integer(c_int),
value,
intent(in) :: table_file_id
158 call openbf(bufr_unit, c_f_string(cio), table_file_id)
169subroutine closbf_c(bufr_unit) bind(C, name='closbf_f')
170 integer(c_int),
value,
intent(in) :: bufr_unit
197function ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len)
result(ires) bind(C, name='ireadmg_f')
198 integer(c_int),
value,
intent(in) :: bufr_unit
199 character(kind=c_char, len=1),
intent(out) :: c_subset(*)
200 integer(c_int),
intent(out) :: iddate
201 integer(c_int),
value,
intent(in) :: subset_str_len
202 integer(c_int) :: ires
203 character(len=25) :: f_subset
206 ires =
ireadmg(bufr_unit, f_subset, iddate)
209 call copy_f_c_str(f_subset, c_subset, int(subset_str_len))
221function ireadsb_c(bufr_unit)
result(ires) bind(C, name='ireadsb_f')
222 integer(c_int),
value,
intent(in) :: bufr_unit
223 integer(c_int) :: ires
241subroutine ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbint_f')
242 integer(c_int),
value,
intent(in) :: bufr_unit
243 type(c_ptr),
intent(inout) :: c_data
244 integer(c_int),
value,
intent(in) :: dim_1, dim_2
245 integer(c_int),
intent(out) :: iret
246 character(kind=c_char, len=1),
intent(in) :: table_b_mnemonic
247 real,
pointer :: f_data
249 call c_f_pointer(c_data, f_data)
250 call ufbint(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
265subroutine ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbrep_f')
266 integer(c_int),
value,
intent(in) :: bufr_unit
267 type(c_ptr),
intent(inout) :: c_data
268 integer(c_int),
value,
intent(in) :: dim_1, dim_2
269 integer(c_int),
intent(out) :: iret
270 character(kind=c_char, len=1),
intent(in) :: table_b_mnemonic
271 real,
pointer :: f_data
273 call c_f_pointer(c_data, f_data)
274 call ufbrep(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
287subroutine mtinfo_c(path, file_unit_1, file_unit_2) bind(C, name='mtinfo_f')
288 character(kind=c_char, len=1),
intent(in) :: path
289 integer(c_int),
value,
intent(in) :: file_unit_1
290 integer(c_int),
value,
intent(in) :: file_unit_2
292 call mtinfo(c_f_string(path), file_unit_1, file_unit_2)
310subroutine status_c(file_unit, lun, il, im) bind(C, name='status_f')
311 integer(c_int),
value,
intent(in) :: file_unit
312 integer(c_int),
intent(out) :: lun
313 integer(c_int),
intent(out) :: il
314 integer(c_int),
intent(out) :: im
316 call status(file_unit, lun, il, im)
333subroutine nemdefs_c(file_unit, mnemonic, unit_c, unit_str_len, desc_c, desc_str_len, iret) &
334 bind(c, name=
'nemdefs_f')
335 integer(c_int),
value,
intent(in) :: file_unit
336 character(kind=c_char,len=1),
intent(in) :: mnemonic(*)
337 character(kind=c_char, len=1),
intent(out) :: unit_c(*)
338 integer(c_int),
value,
intent(in) :: unit_str_len
339 character(kind=c_char, len=1),
intent(out) :: desc_c(*)
340 integer(c_int),
value,
intent(in) :: desc_str_len
341 integer(c_int),
intent(out) :: iret
343 character(len=24) :: unit_f
344 character(len=55) :: desc_f
347 call nemdefs ( file_unit, c_f_string(mnemonic), desc_f, unit_f, iret)
351 call copy_f_c_str(unit_f, unit_c, min(len(unit_f) + 1, unit_str_len))
353 call copy_f_c_str(desc_f, desc_c, min(len(desc_f) + 1, desc_str_len))
371subroutine nemspecs_c(file_unit, mnemonic, mnemonic_idx, scale, reference, bits, iret) &
372 bind(c, name=
'nemspecs_f')
373 integer(c_int),
value,
intent(in) :: file_unit
374 character(kind=c_char,len=1),
intent(in) :: mnemonic(*)
375 integer(c_int),
value,
intent(in) ::mnemonic_idx
376 integer(c_int),
intent(out) :: scale
377 integer(c_int),
intent(out) :: reference
378 integer(c_int),
intent(out) :: bits
379 integer(c_int),
intent(out) :: iret
382 call nemspecs(file_unit, c_f_string(mnemonic), mnemonic_idx, scale, reference, bits, iret)
399subroutine nemtab_c(bufr_unit, mnemonic, descriptor, table_type, table_idx) &
400 bind(c, name=
'nemtab_f')
401 integer(c_int),
value,
intent(in) :: bufr_unit
402 character(kind=c_char,len=1),
intent(in) :: mnemonic(*)
403 integer(c_int),
intent(out) :: descriptor
404 character(kind=c_char,len=1),
intent(out) :: table_type(*)
405 integer(c_int),
intent(out) :: table_idx
407 character(len=1) :: table_type_f
409 call nemtab(bufr_unit, c_f_string(mnemonic), descriptor, table_type_f, table_idx)
411 table_type(1)(1:1) = table_type_f(1:1)
429subroutine nemtbb_c(bufr_unit, table_idx, unit_str, unit_str_len, scale, reference, bits) &
430 bind(c, name=
'nemtbb_f')
431 integer(c_int),
intent(in),
value :: bufr_unit
432 integer(c_int),
intent(in),
value :: table_idx
433 character(kind=c_char,len=1),
intent(out) :: unit_str(*)
434 integer(c_int),
intent(in),
value :: unit_str_len
435 integer(c_int),
intent(out) :: scale
436 integer(c_int),
intent(out) :: reference
437 integer(c_int),
intent(out) :: bits
439 character(len=24) :: unit_str_f
442 call nemtbb( bufr_unit, table_idx, unit_str_f, scale, reference, bits)
443 call copy_f_c_str(unit_str_f, unit_str, min(len(unit_str_f) + 1, unit_str_len))
456subroutine get_isc_c(isc_ptr, isc_size) bind(C, name='get_isc_f')
458 type(c_ptr),
intent(inout) :: isc_ptr
459 integer(c_int),
intent(out) :: isc_size
461 allocate(isc_f(
ntab))
463 isc_size =
size(isc_f)
464 isc_ptr = c_loc(isc_f(1))
476subroutine get_link_c(link_ptr, link_size) bind(C, name='get_link_f')
478 type(c_ptr),
intent(inout) :: link_ptr
479 integer(c_int),
intent(out) :: link_size
481 allocate(link_f(
ntab))
483 link_size =
size(link_f)
484 link_ptr = c_loc(link_f(1))
496subroutine get_itp_c(itp_ptr, itp_size) bind(C, name='get_itp_f')
498 type(c_ptr),
intent(inout) :: itp_ptr
499 integer(c_int),
intent(out) :: itp_size
501 allocate(itp_f(
ntab))
503 itp_size =
size(itp_f)
504 itp_ptr = c_loc(itp_f(1))
517subroutine get_typ_c(typ_ptr, typ_len, mem_size) bind(C, name='get_typ_f')
519 type(c_ptr),
intent(inout) :: typ_ptr
520 integer(c_int),
intent(out) :: typ_len
521 integer(c_int),
intent(out) :: mem_size
523 allocate(typ_f(
ntab))
525 typ_len = len(
typ(1))
526 mem_size =
size(typ_f)
527 typ_ptr = c_loc(typ_f(1))
540subroutine get_tag_c(tag_ptr, tag_len, mem_size) bind(C, name='get_tag_f')
542 type(c_ptr),
intent(inout) :: tag_ptr
543 integer(c_int),
intent(out) :: tag_len
544 integer(c_int),
intent(out) :: mem_size
546 allocate(tag_f(
ntab))
548 tag_len = len(
tag(1))
549 mem_size =
size(tag_f)
550 tag_ptr = c_loc(tag_f(1))
562subroutine get_jmpb_c(jmpb_ptr, jmpb_size) bind(C, name='get_jmpb_f')
564 type(c_ptr),
intent(inout) :: jmpb_ptr
565 integer(c_int),
intent(out) :: jmpb_size
567 allocate(jmpb_f(
ntab))
569 jmpb_size =
size(jmpb_f)
570 jmpb_ptr = c_loc(jmpb_f(1))
582subroutine get_inode_c(lun, start_node) bind(C, name='get_inode_f')
584 integer(c_int),
value,
intent(in) :: lun
585 integer(c_int),
intent(out) :: start_node
587 start_node = inode(lun)
599subroutine get_nval_c(lun, numNodes) bind(C, name='get_nval_f')
601 integer(c_int),
value,
intent(in) :: lun
602 integer(c_int),
intent(out) :: numnodes
617subroutine get_val_c(lun, val_ptr, val_size) bind(C, name='get_val_f')
619 integer(c_int),
value,
intent(in) :: lun
620 type(c_ptr),
intent(inout) :: val_ptr
621 integer(c_int),
intent(out) :: val_size
623 val_size =
size(val(:, lun))
624 val_ptr = c_loc(val(1, lun))
637subroutine get_inv_c(lun, inv_ptr, inv_size) bind(C, name='get_inv_f')
639 integer(c_int),
value,
intent(in) :: lun
640 type(c_ptr),
intent(inout) :: inv_ptr
641 integer(c_int),
intent(out) :: inv_size
643 inv_size =
size(inv(:, lun))
644 inv_ptr = c_loc(inv(1, lun))
654 if (
allocated(isc_f))
deallocate(isc_f)
655 if (
allocated(link_f))
deallocate(link_f)
656 if (
allocated(itp_f))
deallocate(itp_f)
657 if (
allocated(typ_f))
deallocate(typ_f)
658 if (
allocated(tag_f))
deallocate(tag_f)
659 if (
allocated(jmpb_f))
deallocate(jmpb_f)
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
subroutine exitbufr
This subroutine frees all dynamically-allocated memory, closes all logical units that are open within...
function ireadmg(LUNIT, SUBSET, IDATE)
This function calls BUFRLIB subroutine readmg() and passes back its return code as the function value...
function ireadsb(LUNIT)
This function calls BUFRLIB subroutine readsb() and passes back its return code as the function value...
subroutine mtinfo(CMTDIR, LUNMT1, LUNMT2)
This subroutine allows the specification of the directory location and Fortran logical unit numbers t...
This module contains functions which wrap Fortran BUFRLIB functions and variables so they can be used...
subroutine, public openbf_c(bufr_unit, cio, table_file_id)
Wraps BUFRLIB "openbf" subroutine.
subroutine, public status_c(file_unit, lun, il, im)
Get Raw BUFR data functions.
subroutine, public open_c(lunit, filepath)
Wraps fortran "open" statement so we can open a Fortran file from a C program.
subroutine, public get_isc_c(isc_ptr, isc_size)
Get copy of the moda_tables ISC array.
subroutine, public close_c(lunit)
Wraps fortran "close" statement so we can close a Fortran file from a C program.
subroutine, public delete_table_data_c()
Deletes the copies of the moda_tables arrays.
subroutine, public mtinfo_c(path, file_unit_1, file_unit_2)
Wraps BUFRLIB "mtinfo" function.
subroutine, public ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Wraps BUFRLIB "ufbint" function.
subroutine, public closbf_c(bufr_unit)
Wraps BUFRLIB "closbf" subroutine.
subroutine, public get_jmpb_c(jmpb_ptr, jmpb_size)
Get copy of the moda_tables JMPB array.
integer(c_int) function, public ireadsb_c(bufr_unit)
Wraps BUFRLIB "ireadsb" function.
subroutine, public nemspecs_c(file_unit, mnemonic, mnemonic_idx, scale, reference, bits, iret)
Gets Table B scale, reference, and bits values. Wraps BUFRLIB "nemspecs".
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".
subroutine, public get_itp_c(itp_ptr, itp_size)
Get copy of the moda_tables ITP array.
subroutine, public get_inv_c(lun, inv_ptr, inv_size)
Get pointer to the moda_usrint INV array.
subroutine, public get_nval_c(lun, numNodes)
Get the number of values in the current subset.
subroutine, public get_val_c(lun, val_ptr, val_size)
Get pointer to the moda_usrint VAL array.
subroutine, public ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Wraps BUFRLIB "ufbrep" function.
subroutine, public get_typ_c(typ_ptr, typ_len, mem_size)
Get copy of the moda_tables TYP array.
subroutine, public get_link_c(link_ptr, link_size)
Get copy of the moda_tables LINK array.
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".
integer(c_int) function, public ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len)
Wraps BUFRLIB "ireadmg" subroutine.
subroutine, public exitbufr_c()
Wraps BUFRLIB "exitbufr" subroutine. Closes all open file units used by BUFRLIB.
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,...
subroutine, public get_tag_c(tag_ptr, tag_len, mem_size)
Get copy of the moda_tables TAG array.
subroutine, public get_inode_c(lun, start_node)
Get the bufr node idx for the start node of the subset.
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable link
Link indices corresponding to tag, typ and jmpb:
integer, dimension(:), allocatable itp
Integer type values corresponding to typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
character *3, dimension(:), allocatable typ
Type indicators corresponding to tag:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
integer ntab
Number of entries in the jump/link table.
integer, dimension(:), allocatable jmpb
Jump backward indices corresponding to tag and typ:
subroutine nemdefs(LUNIT, NEMO, CELEM, CUNIT, IRET)
Given a Table B mnemonic defined in the DX BUFR Tables associated with a BUFR file (or in the master ...
subroutine nemspecs(LUNIT, NEMO, NNEMO, NSCL, NREF, NBTS, IRET)
Given a Table B mnemonic defined within a data subset, this subroutine returns the scale factor,...
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
This subroutine returns information about a descriptor from the internal DX BUFR tables,...
subroutine nemtbb(LUN, ITAB, UNIT, ISCL, IREF, IBIT)
This subroutine returns information about a Table B descriptor from the internal DX BUFR tables.
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
subroutine ufbint(LUNIN, USR, I1, I2, IRET, STR)
This subroutine reads or writes one or more data values from or to the BUFR data subset that is curre...
subroutine ufbrep(LUNIN, USR, I1, I2, IRET, STR)
This subroutine reads or writes one or more data values from or to the BUFR data subset that is curre...