32 integer,
allocatable,
target,
save :: isc_f(:)
33 integer,
allocatable,
target,
save :: link_f(:)
34 integer,
allocatable,
target,
save :: itp_f(:)
35 integer,
allocatable,
target,
save :: jmpb_f(:)
36 character(len=10),
allocatable,
target,
save :: tag_f(:)
37 character(len=3),
allocatable,
target,
save :: typ_f(:)
51 function c_f_string(c_str) result(f_str)
52 character(kind=c_char,len=1),
intent(in) :: c_str(*)
53 character(len=:),
allocatable :: f_str
57 do while (c_str(nchars) /= c_null_char)
62 allocate(
character(len=nchars) :: f_str)
63 f_str = transfer(c_str(1:nchars), f_str)
64 end function c_f_string
76 subroutine copy_f_c_str(f_str, c_str, c_str_len)
77 character(len=*),
target,
intent(in) :: f_str
78 character(kind=c_char, len=1),
intent(inout) :: c_str(*)
79 integer,
intent(in) :: c_str_len
80 integer :: max_str_len
82 if (c_str_len /= 0)
then
83 max_str_len = c_str_len
84 c_str(1)(1:max_str_len) = f_str(1:max_str_len)
85 c_str(1)(max_str_len:max_str_len) = c_null_char
87 end subroutine copy_f_c_str
100 subroutine open_c(lunit, filepath) bind(C, name='open_f')
101 integer(c_int), value,
intent(in) :: lunit
102 character(kind=c_char, len=1) :: filepath
104 open(lunit, file=c_f_string(filepath))
116 subroutine close_c(lunit) bind(C, name='close_f')
117 integer(c_int), value,
intent(in) :: lunit
132 subroutine openbf_c(bufr_unit, cio, table_file_id) bind(C, name='openbf_f')
133 integer(c_int), value,
intent(in) :: bufr_unit
134 character(kind=c_char, len=1),
intent(in) :: cio
135 integer(c_int), value,
intent(in) :: table_file_id
137 call
openbf(bufr_unit, c_f_string(cio), table_file_id)
148 subroutine closbf_c(bufr_unit) bind(C, name='closbf_f')
149 integer(c_int), value,
intent(in) :: bufr_unit
176 function ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len) result(ires) bind(C, name='ireadmg_f')
177 integer(c_int), value,
intent(in) :: bufr_unit
178 character(kind=c_char, len=1),
intent(inout) :: c_subset(*)
179 integer(c_int),
intent(out) :: iddate
180 integer(c_int), value,
intent(in) :: subset_str_len
181 integer(c_int) :: ires
182 character(len=25) :: f_subset
185 ires =
ireadmg(bufr_unit, f_subset, iddate)
188 call copy_f_c_str(f_subset, c_subset, int(subset_str_len))
200 function ireadsb_c(bufr_unit) result(ires) bind(C, name='ireadsb_f')
201 integer(c_int), value,
intent(in) :: bufr_unit
202 integer(c_int) :: ires
220 subroutine ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbint_f')
221 integer(c_int), value,
intent(in) :: bufr_unit
222 type(c_ptr
),
intent(inout) :: c_data
223 integer(c_int), value,
intent(in) :: dim_1, dim_2
224 integer(c_int),
intent(out) :: iret
225 character(kind=c_char, len=1),
intent(in) :: table_b_mnemonic
226 real,
pointer :: f_data
228 call c_f_pointer(c_data, f_data)
229 call
ufbint(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
244 subroutine ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbrep_f')
245 integer(c_int), value,
intent(in) :: bufr_unit
246 type(c_ptr
),
intent(inout) :: c_data
247 integer(c_int), value,
intent(in) :: dim_1, dim_2
248 integer(c_int),
intent(out) :: iret
249 character(kind=c_char, len=1),
intent(in) :: table_b_mnemonic
250 real,
pointer :: f_data
252 call c_f_pointer(c_data, f_data)
253 call
ufbrep(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
266 subroutine mtinfo_c(path, file_unit_1, file_unit_2) bind(C, name='mtinfo_f')
267 character(kind=c_char, len=1),
intent(in) :: path
268 integer(c_int), value,
intent(in) :: file_unit_1
269 integer(c_int), value,
intent(in) :: file_unit_2
271 call
mtinfo(c_f_string(path), file_unit_1, file_unit_2)
289 subroutine status_c(file_unit, lun, il, im) bind(C, name='status_f')
290 integer(c_int), value,
intent(in) :: file_unit
291 integer(c_int),
intent(out) :: lun
292 integer(c_int),
intent(out) :: il
293 integer(c_int),
intent(out) :: im
295 call
status(file_unit, lun, il, im)
296 end subroutine status_c
307 subroutine get_isc_c(isc_ptr, isc_size) bind(C, name='get_isc_f')
309 type(c_ptr
),
intent(inout) :: isc_ptr
310 integer(c_int),
intent(out) :: isc_size
312 allocate(isc_f(ntab))
313 isc_f(1:ntab) = isc(1:ntab)
314 isc_size =
size(isc_f)
315 isc_ptr = c_loc(isc_f(1))
316 end subroutine get_isc_c
327 subroutine get_link_c(link_ptr, link_size) bind(C, name='get_link_f')
329 type(c_ptr
),
intent(inout) :: link_ptr
330 integer(c_int),
intent(out) :: link_size
332 allocate(link_f(ntab))
333 link_f(1:ntab) = link(1:ntab)
334 link_size =
size(link_f)
335 link_ptr = c_loc(link_f(1))
347 subroutine get_itp_c(itp_ptr, itp_size) bind(C, name='get_itp_f')
349 type(c_ptr
),
intent(inout) :: itp_ptr
350 integer(c_int),
intent(out) :: itp_size
352 allocate(itp_f(ntab))
353 itp_f(1:ntab) = itp(1:ntab)
354 itp_size =
size(itp_f)
355 itp_ptr = c_loc(itp_f(1))
368 subroutine get_typ_c(typ_ptr, typ_len, mem_size) bind(C, name='get_typ_f')
370 type(c_ptr
),
intent(inout) :: typ_ptr
371 integer(c_int),
intent(out) :: typ_len
372 integer(c_int),
intent(out) :: mem_size
374 allocate(typ_f(ntab))
375 typ_f(1:ntab) = typ(1:ntab)
376 typ_len = len(typ(1))
377 mem_size =
size(typ_f)
378 typ_ptr = c_loc(typ_f(1))
391 subroutine get_tag_c(tag_ptr, tag_len, mem_size) bind(C, name='get_tag_f')
393 type(c_ptr
),
intent(inout) :: tag_ptr
394 integer(c_int),
intent(out) :: tag_len
395 integer(c_int),
intent(out) :: mem_size
397 allocate(tag_f(ntab))
398 tag_f(1:ntab) = tag(1:ntab)
399 tag_len = len(tag(1))
400 mem_size =
size(tag_f)
401 tag_ptr = c_loc(tag_f(1))
413 subroutine get_jmpb_c(jmpb_ptr, jmpb_size) bind(C, name='get_jmpb_f')
415 type(c_ptr
),
intent(inout) :: jmpb_ptr
416 integer(c_int),
intent(out) :: jmpb_size
418 allocate(jmpb_f(ntab))
419 jmpb_f(1:ntab) = jmpb(1:ntab)
420 jmpb_size =
size(jmpb_f)
421 jmpb_ptr = c_loc(jmpb_f(1))
433 subroutine get_inode_c(lun, start_node) bind(C, name='get_inode_f')
435 integer(c_int), value,
intent(in) :: lun
436 integer(c_int),
intent(out) :: start_node
438 start_node = inode(lun)
450 subroutine get_nval_c(lun, numNodes) bind(C, name='get_nval_f')
452 integer(c_int), value,
intent(in) :: lun
453 integer(c_int),
intent(out) :: numnodes
468 subroutine get_val_c(lun, val_ptr, val_size) bind(C, name='get_val_f')
470 integer(c_int), value,
intent(in) :: lun
471 type(c_ptr
),
intent(inout) :: val_ptr
472 integer(c_int),
intent(out) :: val_size
474 val_size =
size(val(:, lun))
475 val_ptr = c_loc(val(1, lun))
488 subroutine get_inv_c(lun, inv_ptr, inv_size) bind(C, name='get_inv_f')
490 integer(c_int), value,
intent(in) :: lun
491 type(c_ptr
),
intent(inout) :: inv_ptr
492 integer(c_int),
intent(out) :: inv_size
494 inv_size =
size(inv(:, lun))
495 inv_ptr = c_loc(inv(1, lun))
505 if (
allocated(isc_f))
deallocate(isc_f)
506 if (
allocated(link_f))
deallocate(link_f)
507 if (
allocated(itp_f))
deallocate(itp_f)
508 if (
allocated(typ_f))
deallocate(typ_f)
509 if (
allocated(tag_f))
deallocate(tag_f)
510 if (
allocated(jmpb_f))
deallocate(jmpb_f)
subroutine, public exitbufr_c()
Wraps BUFRLIB "exitbufr" subroutine. Closes all open file units used by BUFRLIB.
function ireadmg(LUNIT, SUBSET, IDATE)
This function calls BUFRLIB subroutine readmg() and passes back its return code as the function value...
subroutine get_val_c(lun, val_ptr, val_size)
Get pointer to the moda_usrint VAL array.
subroutine, public open_c(lunit, filepath)
Wraps fortran "open" statement so we can open a Fortran file from a C program.
function ireadsb(LUNIT)
This function calls BUFRLIB subroutine readsb() and passes back its return code as the function value...
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...
subroutine, public openbf_c(bufr_unit, cio, table_file_id)
Wraps BUFRLIB "openbf" subroutine.
subroutine, public ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Wraps BUFRLIB "ufbint" function.
subroutine mtinfo(CMTDIR, LUNMT1, LUNMT2)
This subroutine allows the specification of the directory location and Fortran logical unit numbers t...
subroutine closbf(LUNIT)
This subroutine closes the connection between logical unit LUNIT and the BUFRLIB software.
subroutine 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 ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Wraps BUFRLIB "ufbrep" function.
This module contains array and variable declarations used to store the internal jump/link table...
subroutine status(LUNIT, LUN, IL, IM)
This subroutine checks whether a specified Fortran logical unit number is currently connected to the ...
subroutine openbf(LUNIT, IO, LUNDX)
This subroutine connects a new file to the BUFRLIB software for input or output operations.
subroutine get_link_c(link_ptr, link_size)
Get copy of the moda_tables LINK array.
subroutine get_itp_c(itp_ptr, itp_size)
Get copy of the moda_tables ITP array.
subroutine get_inode_c(lun, start_node)
Get the bufr node idx for the start node of the subset.
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, public closbf_c(bufr_unit)
Wraps BUFRLIB "closbf" subroutine.
subroutine exitbufr
This subroutine frees all dynamically-allocated memory, closes all logical units that are open within...
subroutine 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 get_nval_c(lun, numNodes)
Get the number of values in the current subset.
This module contains functions which wrap certain Fortran BUFRLIB functions so they can be called fro...
subroutine get_typ_c(typ_ptr, typ_len, mem_size)
Get copy of the moda_tables TYP array.
subroutine get_tag_c(tag_ptr, tag_len, mem_size)
Get copy of the moda_tables TAG array.
integer(c_int) function, public ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len)
Wraps BUFRLIB "ireadmg" subroutine.
subroutine get_inv_c(lun, inv_ptr, inv_size)
Get pointer to the moda_usrint INV array.
subroutine, public close_c(lunit)
Wraps fortran "close" statement so we can close a Fortran file from a C program.