NCEPLIBS-bufr  12.0.1
bufr_c2f_interface.F90
Go to the documentation of this file.
1 
6 
17 
18  use iso_c_binding
19 
20  implicit none
21 
22  private
23  public :: open_c, close_c, openbf_c, closbf_c
24  public :: exitbufr_c, bort_c
26  public :: ufbint_c, ufbrep_c, ufbseq_c
27  public :: mtinfo_c, bvers_c, status_c, ibfms_c
30  public :: delete_table_data_c
32  public :: igetntbi_c, igettdi_c, stntbi_c
36 
37  integer, allocatable, target, save :: isc_f(:), link_f(:), itp_f(:), jmpb_f(:), irf_f(:)
38  character(len=10), allocatable, target, save :: tag_f(:)
39  character(len=3), allocatable, target, save :: typ_f(:)
40 
41  contains
42 
53  function c_f_string(c_str) result(f_str)
54  character(kind=c_char,len=1), intent(in) :: c_str(*)
55  character(len=:), allocatable :: f_str
56  integer :: nchars
57 
58  nchars = 1
59  do while (c_str(nchars) /= c_null_char)
60  nchars = nchars + 1
61  end do
62  nchars = nchars - 1
63 
64  allocate(character(len=nchars) :: f_str)
65  f_str = transfer(c_str(1:nchars), f_str)
66  end function c_f_string
67 
75  subroutine copy_f_c_str(f_str, c_str, c_str_len)
76  character(len=*), target, intent(in) :: f_str
77  character(kind=c_char, len=1), intent(inout) :: c_str(*)
78  integer, intent(in) :: c_str_len
79  integer :: max_str_len
80 
81  if (c_str_len /= 0) then
82  max_str_len = c_str_len
83  c_str(1)(1:max_str_len) = f_str(1:max_str_len)
84  c_str(1)(max_str_len:max_str_len) = c_null_char
85  end if
86  end subroutine copy_f_c_str
87 
94  subroutine open_c(lunit, filepath) bind(C, name='open_f')
95  integer(c_int), value, intent(in) :: lunit
96  character(kind=c_char, len=1) :: filepath
97 
98  open(lunit, file=c_f_string(filepath))
99  end subroutine open_c
100 
106  subroutine close_c(lunit) bind(C, name='close_f')
107  integer(c_int), value, intent(in) :: lunit
108 
109  close(unit=lunit)
110  end subroutine close_c
111 
122  subroutine openbf_c(bufr_unit, cio, table_file_id) bind(C, name='openbf_f')
123  integer(c_int), value, intent(in) :: bufr_unit
124  character(kind=c_char, len=1), intent(in) :: cio(*)
125  integer(c_int), value, intent(in) :: table_file_id
126 
127  call openbf(bufr_unit, c_f_string(cio), table_file_id)
128  end subroutine openbf_c
129 
137  subroutine closbf_c(bufr_unit) bind(C, name='closbf_f')
138  integer(c_int), value, intent(in) :: bufr_unit
139 
140  call closbf(bufr_unit)
141  end subroutine closbf_c
142 
148  subroutine exitbufr_c() bind(C, name='exitbufr_f')
149  call exitbufr()
150  end subroutine exitbufr_c
151 
166  function ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len) result(ires) bind(C, name='ireadmg_f')
167  integer(c_int), value, intent(in) :: bufr_unit
168  character(kind=c_char, len=1), intent(out) :: c_subset(*)
169  integer(c_int), intent(out) :: iddate
170  integer(c_int), value, intent(in) :: subset_str_len
171  integer(c_int) :: ires
172  character(len=25) :: f_subset
173  integer :: ireadmg
174 
175  ires = ireadmg(bufr_unit, f_subset, iddate)
176 
177  if (ires == 0) then
178  call copy_f_c_str(f_subset, c_subset, int(subset_str_len))
179  end if
180  end function ireadmg_c
181 
192  function ireadsb_c(bufr_unit) result(ires) bind(C, name='ireadsb_f')
193  integer(c_int), value, intent(in) :: bufr_unit
194  integer(c_int) :: ires
195  integer :: ireadsb
196 
197  ires = ireadsb(bufr_unit)
198  end function ireadsb_c
199 
211  subroutine ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbint_f')
212  integer(c_int), value, intent(in) :: bufr_unit
213  type(c_ptr), intent(inout) :: c_data
214  integer(c_int), value, intent(in) :: dim_1, dim_2
215  integer(c_int), intent(out) :: iret
216  character(kind=c_char, len=1), intent(in) :: table_b_mnemonic(*)
217  real, pointer :: f_data
218 
219  call c_f_pointer(c_data, f_data)
220  call ufbint(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
221  end subroutine ufbint_c
222 
234  subroutine ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic) bind(C, name='ufbrep_f')
235  integer(c_int), value, intent(in) :: bufr_unit
236  type(c_ptr), intent(inout) :: c_data
237  integer(c_int), value, intent(in) :: dim_1, dim_2
238  integer(c_int), intent(out) :: iret
239  character(kind=c_char, len=1), intent(in) :: table_b_mnemonic(*)
240  real, pointer :: f_data
241 
242  call c_f_pointer(c_data, f_data)
243  call ufbrep(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_b_mnemonic))
244  end subroutine ufbrep_c
245 
255  subroutine mtinfo_c(path, file_unit_1, file_unit_2) bind(C, name='mtinfo_f')
256  character(kind=c_char, len=1), intent(in) :: path(*)
257  integer(c_int), value, intent(in) :: file_unit_1
258  integer(c_int), value, intent(in) :: file_unit_2
259 
260  call mtinfo(c_f_string(path), file_unit_1, file_unit_2)
261  end subroutine mtinfo_c
262 
273  subroutine status_c(file_unit, lun, il, im) bind(C, name='status_f')
274  integer(c_int), value, intent(in) :: file_unit
275  integer(c_int), intent(out) :: lun
276  integer(c_int), intent(out) :: il
277  integer(c_int), intent(out) :: im
278 
279  call status(file_unit, lun, il, im)
280  end subroutine status_c
281 
295  subroutine nemdefs_c(file_unit, mnemonic, unit_c, unit_str_len, desc_c, desc_str_len, iret) &
296  bind(c, name='nemdefs_f')
297  integer(c_int), value, intent(in) :: file_unit
298  character(kind=c_char,len=1), intent(in) :: mnemonic(*)
299  character(kind=c_char, len=1), intent(out) :: unit_c(*)
300  integer(c_int), value, intent(in) :: unit_str_len
301  character(kind=c_char, len=1), intent(out) :: desc_c(*)
302  integer(c_int), value, intent(in) :: desc_str_len
303  integer(c_int), intent(out) :: iret
304 
305  character(len=25) :: unit_f
306  character(len=55) :: desc_f
307 
308  ! Get the unit and description strings
309  call nemdefs ( file_unit, c_f_string(mnemonic), desc_f, unit_f, iret)
310 
311  if (iret == 0) then
312  ! Copy the unit Fortran string into the resulting C-style string.
313  call copy_f_c_str(unit_f, unit_c, min(len(unit_f), unit_str_len))
314  ! Copy the descriptor Fortran string into the resulting C-style string.
315  call copy_f_c_str(desc_f, desc_c, min(len(desc_f), desc_str_len))
316  end if
317  end subroutine nemdefs_c
318 
333  subroutine nemspecs_c(file_unit, mnemonic, mnemonic_idx, scale, reference, bits, iret) &
334  bind(c, name='nemspecs_f')
335  integer(c_int), value, intent(in) :: file_unit
336  character(kind=c_char,len=1), intent(in) :: mnemonic(*)
337  integer(c_int), value, intent(in) ::mnemonic_idx
338  integer(c_int), intent(out) :: scale
339  integer(c_int), intent(out) :: reference
340  integer(c_int), intent(out) :: bits
341  integer(c_int), intent(out) :: iret
342 
343  ! Get the scale, reference and bits
344  call nemspecs(file_unit, c_f_string(mnemonic), mnemonic_idx, scale, reference, bits, iret)
345  end subroutine nemspecs_c
346 
358  subroutine nemtab_c(lun, mnemonic, descriptor, table_type, table_idx) &
359  bind(c, name='nemtab_f')
360  integer(c_int), value, intent(in) :: lun
361  character(kind=c_char,len=1), intent(in) :: mnemonic(*)
362  integer(c_int), intent(out) :: descriptor
363  character(kind=c_char,len=1), intent(out) :: table_type(*)
364  integer(c_int), intent(out) :: table_idx
365 
366  character(len=1) :: table_type_f
367 
368  call nemtab(lun, c_f_string(mnemonic), descriptor, table_type_f, table_idx)
369 
370  table_type(1)(1:1) = table_type_f(1:1)
371  end subroutine nemtab_c
372 
386  subroutine nemtbb_c(lun, table_idx, unit_str, unit_str_len, scale, reference, bits) &
387  bind(c, name='nemtbb_f')
388  integer(c_int), intent(in), value :: lun
389  integer(c_int), intent(in), value :: table_idx
390  character(kind=c_char,len=1), intent(out) :: unit_str(*)
391  integer(c_int), intent(in), value :: unit_str_len
392  integer(c_int), intent(out) :: scale
393  integer(c_int), intent(out) :: reference
394  integer(c_int), intent(out) :: bits
395 
396  character(len=25) :: unit_str_f
397 
398  ! Get the scale, reference and bits
399  call nemtbb( lun, table_idx, unit_str_f, scale, reference, bits)
400  call copy_f_c_str(unit_str_f, unit_str, min(len(unit_str_f), unit_str_len))
401  end subroutine nemtbb_c
402 
409  subroutine get_isc_c(isc_ptr, isc_size) bind(C, name='get_isc_f')
410  use moda_tables
411  type(c_ptr), intent(inout) :: isc_ptr
412  integer(c_int), intent(out) :: isc_size
413 
414  allocate(isc_f(ntab))
415  isc_f(1:ntab) = isc(1:ntab)
416  isc_size = size(isc_f)
417  isc_ptr = c_loc(isc_f(1))
418  end subroutine get_isc_c
419 
426  subroutine get_link_c(link_ptr, link_size) bind(C, name='get_link_f')
427  use moda_tables
428  type(c_ptr), intent(inout) :: link_ptr
429  integer(c_int), intent(out) :: link_size
430 
431  allocate(link_f(ntab))
432  link_f(1:ntab) = link(1:ntab)
433  link_size = size(link_f)
434  link_ptr = c_loc(link_f(1))
435  end subroutine get_link_c
436 
443  subroutine get_itp_c(itp_ptr, itp_size) bind(C, name='get_itp_f')
444  use moda_tables
445  type(c_ptr), intent(inout) :: itp_ptr
446  integer(c_int), intent(out) :: itp_size
447 
448  allocate(itp_f(ntab))
449  itp_f(1:ntab) = itp(1:ntab)
450  itp_size = size(itp_f)
451  itp_ptr = c_loc(itp_f(1))
452  end subroutine get_itp_c
453 
461  subroutine get_typ_c(typ_ptr, typ_len, mem_size) bind(C, name='get_typ_f')
462  use moda_tables
463  type(c_ptr), intent(inout) :: typ_ptr
464  integer(c_int), intent(out) :: typ_len
465  integer(c_int), intent(out) :: mem_size
466 
467  allocate(typ_f(ntab))
468  typ_f(1:ntab) = typ(1:ntab)
469  typ_len = len(typ(1))
470  mem_size = size(typ_f)
471  typ_ptr = c_loc(typ_f(1))
472  end subroutine get_typ_c
473 
481  subroutine get_tag_c(tag_ptr, tag_len, mem_size) bind(C, name='get_tag_f')
482  use moda_tables
483  type(c_ptr), intent(inout) :: tag_ptr
484  integer(c_int), intent(out) :: tag_len
485  integer(c_int), intent(out) :: mem_size
486 
487  allocate(tag_f(ntab))
488  tag_f(1:ntab) = tag(1:ntab)
489  tag_len = len(tag(1))
490  mem_size = size(tag_f)
491  tag_ptr = c_loc(tag_f(1))
492  end subroutine get_tag_c
493 
500  subroutine get_jmpb_c(jmpb_ptr, jmpb_size) bind(C, name='get_jmpb_f')
501  use moda_tables
502  type(c_ptr), intent(inout) :: jmpb_ptr
503  integer(c_int), intent(out) :: jmpb_size
504 
505  allocate(jmpb_f(ntab))
506  jmpb_f(1:ntab) = jmpb(1:ntab)
507  jmpb_size = size(jmpb_f)
508  jmpb_ptr = c_loc(jmpb_f(1))
509  end subroutine get_jmpb_c
510 
517  subroutine get_irf_c(irf_ptr, irf_size) bind(C, name='get_irf_f')
518  use moda_tables
519  type(c_ptr), intent(inout) :: irf_ptr
520  integer(c_int), intent(out) :: irf_size
521 
522  allocate(irf_f(ntab))
523  irf_f(1:ntab) = irf(1:ntab)
524  irf_size = size(irf_f)
525  irf_ptr = c_loc(irf_f(1))
526  end subroutine get_irf_c
527 
534  subroutine get_inode_c(lun, start_node) bind(C, name='get_inode_f')
535  use moda_msgcwd
536  integer(c_int), value, intent(in) :: lun
537  integer(c_int), intent(out) :: start_node
538 
539  start_node = inode(lun)
540  end subroutine get_inode_c
541 
548  subroutine get_nval_c(lun, num_nodes) bind(C, name='get_nval_f')
549  use moda_usrint
550  integer(c_int), value, intent(in) :: lun
551  integer(c_int), intent(out) :: num_nodes
552 
553  num_nodes = nval(lun)
554  end subroutine get_nval_c
555 
563  subroutine get_val_c(lun, val_ptr, val_size) bind(C, name='get_val_f')
564  use moda_usrint
565  integer(c_int), value, intent(in) :: lun
566  type(c_ptr), intent(inout) :: val_ptr
567  integer(c_int), intent(out) :: val_size
568 
569  val_size = size(val(:, lun))
570  val_ptr = c_loc(val(1, lun))
571  end subroutine get_val_c
572 
580  subroutine get_inv_c(lun, inv_ptr, inv_size) bind(C, name='get_inv_f')
581  use moda_usrint
582  integer(c_int), value, intent(in) :: lun
583  type(c_ptr), intent(inout) :: inv_ptr
584  integer(c_int), intent(out) :: inv_size
585 
586  inv_size = size(inv(:, lun))
587  inv_ptr = c_loc(inv(1, lun))
588  end subroutine get_inv_c
589 
599  subroutine readlc_c(lunit, str_id, output_str, output_str_len) bind(C, name='readlc_f')
600  use moda_rlccmn
601  integer(c_int), value, intent(in) :: lunit
602  character(kind=c_char, len=1), intent(in) :: str_id(*)
603  character(kind=c_char, len=1), intent(out) :: output_str(*)
604  integer(c_int), intent(in), value :: output_str_len
605 
606  character(len=120) :: output_str_f
607  integer :: output_str_len_f
608 
609  call readlc(lunit, output_str_f, c_f_string(str_id))
610  output_str_len_f = len(trim(output_str_f)) + 1 ! add 1 for the null terminator
611  call copy_f_c_str(output_str_f, output_str, min(output_str_len_f, output_str_len))
612  end subroutine readlc_c
613 
617  subroutine delete_table_data_c() bind(C, name='delete_table_data_f')
618  if (allocated(isc_f)) deallocate(isc_f)
619  if (allocated(link_f)) deallocate(link_f)
620  if (allocated(itp_f)) deallocate(itp_f)
621  if (allocated(typ_f)) deallocate(typ_f)
622  if (allocated(tag_f)) deallocate(tag_f)
623  if (allocated(jmpb_f)) deallocate(jmpb_f)
624  if (allocated(irf_f)) deallocate(irf_f)
625  end subroutine delete_table_data_c
626 
639  function iupbs01_c(bufr, mnemonic) result(ires) bind(C, name='iupbs01_f')
640  integer(c_int), intent(in) :: bufr(*)
641  character(kind=c_char, len=1), intent(in) :: mnemonic(*)
642  integer(c_int) :: ires
643  integer :: iupbs01
644 
645  ires = iupbs01(bufr,c_f_string(mnemonic))
646  end function iupbs01_c
647 
658  function igetprm_c(cprmnm) result(ires) bind(C, name='igetprm_f')
659  character(kind=c_char, len=1), intent(in) :: cprmnm(*)
660  integer(c_int) :: ires
661  integer :: igetprm
662 
663  ires = igetprm(c_f_string(cprmnm))
664  end function igetprm_c
665 
676  function isetprm_c(cprmnm,ipval) result(ires) bind(C, name='isetprm_f')
677  character(kind=c_char, len=1), intent(in) :: cprmnm(*)
678  integer(c_int), value, intent(in) :: ipval
679  integer(c_int) :: ires
680  integer :: isetprm
681 
682  ires = isetprm(c_f_string(cprmnm),ipval)
683  end function isetprm_c
684 
693  subroutine maxout_c(max0) bind(C, name='maxout_f')
694  integer(c_int), value, intent(in) :: max0
695 
696  call maxout(max0)
697  end subroutine maxout_c
698 
708  function igetmxby_c() result(ires) bind(C, name='igetmxby_f')
709  integer(c_int) :: ires
710  integer :: igetmxby
711 
712  ires = igetmxby()
713  end function igetmxby_c
714 
725  subroutine cadn30_c(idn, adn, adn_str_len) bind(C, name='cadn30_f')
726  integer(c_int), intent(in), value :: idn, adn_str_len
727  character(kind=c_char, len=1), intent(out) :: adn(*)
728  character(len=8) :: adn_f
729 
730  call cadn30(idn, adn_f)
731  call copy_f_c_str(adn_f, adn, adn_str_len)
732  end subroutine cadn30_c
733 
744  function igetntbi_c(lun, table_type) result(ires) bind(C, name='igetntbi_f')
745  integer(c_int), value, intent(in) :: lun
746  character(kind=c_char,len=1), intent(in) :: table_type(*)
747  integer(c_int) :: ires
748  integer :: igetntbi
749  character(len=1) :: table_type_f
750 
751  table_type_f(1:1) = table_type(1)(1:1)
752 
753  ires = igetntbi(lun, table_type_f)
754  end function igetntbi_c
755 
765  subroutine elemdx_c(card,lun) bind(C, name='elemdx_f')
766  integer(c_int), value, intent(in) :: lun
767  character(kind=c_char, len=1), intent(in) :: card(*)
768  character(len=80) :: card_f
769  integer :: ii
770 
771  do ii = 1,80
772  card_f(ii:ii) = card(1)(ii:ii)
773  enddo
774  call elemdx(card_f, lun)
775  end subroutine elemdx_c
776 
789  subroutine numtbd_c(lun,idn,nemo,nemo_str_len,tab,iret) bind(C, name='numtbd_f')
790  integer(c_int), value, intent(in) :: lun, idn, nemo_str_len
791  character(kind=c_char,len=1), intent(out) :: nemo(*), tab(*)
792  integer(c_int), intent(out) :: iret
793 
794  character(len=9) :: nemo_f
795  character(len=1) :: tab_f
796 
797  call numtbd(lun, idn, nemo_f, tab_f, iret)
798 
799  call copy_f_c_str(nemo_f, nemo, nemo_str_len)
800  tab(1)(1:1) = tab_f(1:1)
801  end subroutine numtbd_c
802 
813  function ifxy_c(cfxy) result(ires) bind(C, name='ifxy_f')
814  character(kind=c_char, len=1), intent(in) :: cfxy(*)
815  integer(c_int) :: ires
816  integer :: ifxy
817 
818  ires = ifxy(c_f_string(cfxy))
819  end function ifxy_c
820 
837  subroutine uptdd_c(id, lun, ient, iret) bind(C, name='uptdd_f')
838  integer(c_int), intent(in), value :: id, lun, ient
839  integer(c_int), intent(out) :: iret
840 
841  call uptdd(id, lun, ient, iret)
842  end subroutine uptdd_c
843 
853  function imrkopr_c(nemo) result(ires) bind(C, name='imrkopr_f')
854  character(kind=c_char, len=1), intent(in) :: nemo(*)
855  integer(c_int) :: ires
856  integer :: imrkopr
857 
858  ires = imrkopr(c_f_string(nemo))
859  end function imrkopr_c
860 
870  function istdesc_c(idn) result(ires) bind(C, name='istdesc_f')
871  integer(c_int), intent(in), value :: idn
872  integer(c_int) :: ires
873  integer :: istdesc
874 
875  ires = istdesc(idn)
876  end function istdesc_c
877 
889  subroutine ufbseq_c(bufr_unit, c_data, dim_1, dim_2, iret, table_d_mnemonic) bind(C, name='ufbseq_f')
890  integer(c_int), value, intent(in) :: bufr_unit
891  type(c_ptr), intent(inout) :: c_data
892  integer(c_int), value, intent(in) :: dim_1, dim_2
893  integer(c_int), intent(out) :: iret
894  character(kind=c_char, len=1), intent(in) :: table_d_mnemonic(*)
895  real, pointer :: f_data
896 
897  call c_f_pointer(c_data, f_data)
898  call ufbseq(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_d_mnemonic))
899  end subroutine ufbseq_c
900 
915  function ireadns_c(bufr_unit, c_subset, iddate, subset_str_len) result(ires) bind(C, name='ireadns_f')
916  integer(c_int), value, intent(in) :: bufr_unit
917  character(kind=c_char, len=1), intent(out) :: c_subset(*)
918  integer(c_int), intent(out) :: iddate
919  integer(c_int), value, intent(in) :: subset_str_len
920  integer(c_int) :: ires
921  character(len=25) :: f_subset
922  integer :: ireadns
923 
924  ires = ireadns(bufr_unit, f_subset, iddate)
925 
926  if (ires == 0) then
927  call copy_f_c_str(f_subset, c_subset, subset_str_len)
928  end if
929  end function ireadns_c
930 
940  function ibfms_c(r8val) result(ires) bind(C, name='ibfms_f')
941  real(c_double), intent(in), value :: r8val
942  integer(c_int) :: ires
943  integer :: ibfms
944 
945  ires = ibfms(r8val)
946  end function ibfms_c
947 
957  subroutine strnum_c(str,num,iret) bind(C, name='strnum_f')
958  character(kind=c_char, len=1), intent(in) :: str(*)
959  integer(c_int), intent(out) :: num, iret
960 
961  call strnum(c_f_string(str), num, iret)
962  end subroutine strnum_c
963 
975  subroutine stntbi_c(n,lun,numb,nemo,celsq) bind(C, name='stntbi_f')
976  integer(c_int), intent(in), value :: n, lun
977  character(kind=c_char, len=1), intent(in) :: numb(*), nemo(*), celsq(*)
978  character(len=6) :: numb_f
979  character(len=8) :: nemo_f
980  character(len=55) :: celsq_f
981  integer :: ii
982 
983  do ii = 1,6
984  numb_f(ii:ii) = numb(1)(ii:ii)
985  enddo
986  do ii = 1,8
987  nemo_f(ii:ii) = nemo(1)(ii:ii)
988  enddo
989  do ii = 1,55
990  celsq_f(ii:ii) = celsq(1)(ii:ii)
991  enddo
992  call stntbi(n, lun, numb_f, nemo_f, celsq_f)
993  end subroutine stntbi_c
994 
1005  function igettdi_c(iflag) result(ires) bind(C, name='igettdi_f')
1006  integer(c_int), intent(in), value :: iflag
1007  integer(c_int) :: ires
1008  integer :: igettdi
1009 
1010  ires = igettdi(iflag)
1011  end function igettdi_c
1012 
1025  subroutine pktdd_c(id, lun, idn, iret) bind(C, name='pktdd_f')
1026  integer(c_int), intent(in), value :: id, lun, idn
1027  integer(c_int), intent(out) :: iret
1028 
1029  call pktdd(id, lun, idn, iret)
1030  end subroutine pktdd_c
1031 
1039  subroutine bort_c(errstr) bind(C, name='bort_f')
1040  character(kind=c_char, len=1), intent(in) :: errstr(*)
1041 
1042  call bort(c_f_string(errstr))
1043  end subroutine bort_c
1044 
1055  subroutine openmb_c(bufr_unit, c_subset, iddate) bind(C, name='openmb_f')
1056  integer(c_int), value, intent(in) :: bufr_unit, iddate
1057  character(kind=c_char, len=1), intent(in) :: c_subset(*)
1058 
1059  call openmb(bufr_unit, c_f_string(c_subset), iddate)
1060  end subroutine openmb_c
1061 
1070  subroutine bvers_c(cverstr, cverstr_len) bind(C, name='bvers_f')
1071  character(kind=c_char, len=1), intent(out) :: cverstr(*)
1072  integer(c_int), value, intent(in) :: cverstr_len
1073  character(len=10) :: f_cverstr
1074 
1075  call bvers(f_cverstr)
1076  call copy_f_c_str(f_cverstr, cverstr, cverstr_len)
1077  end subroutine bvers_c
1078 
1084  subroutine wrdlen_c() bind(C, name='wrdlen_f')
1085  call wrdlen()
1086  end subroutine wrdlen_c
1087 
1099  function iupb_c(mbay,nbyt,nbit) result(ires) bind(C, name='iupb_f')
1100  integer(c_int), intent(in) :: mbay(*)
1101  integer(c_int), intent(in), value :: nbyt, nbit
1102  integer(c_int) :: ires
1103  integer :: iupb
1104 
1105  ires = iupb(mbay,nbyt,nbit)
1106  end function iupb_c
1107 
1116  subroutine cmpmsg_c(cf) bind(C, name='cmpmsg_f')
1117  character(kind=c_char, len=1), intent(in) :: cf(*)
1118 
1119  call cmpmsg(c_f_string(cf))
1120  end subroutine cmpmsg_c
1121 
1122 end module bufr_c2f_interface
subroutine bort(STR)
Log one error message and abort application program.
Definition: bort.f:18
subroutine bvers(CVERSTR)
Get the version number of the NCEPLIBS-bufr software.
Definition: bvers.f:15
subroutine cadn30(IDN, ADN)
Convert an FXY value from its WMO bit-wise representation to its six-character representation.
Definition: cadn30.f:25
recursive subroutine closbf(LUNIT)
Close the connection between logical unit LUNIT and the NCEPLIBS-bufr software.
Definition: closbf.f:24
subroutine cmpmsg(CF)
Specify the use of compression when writing BUFR messages.
Definition: cmpmsg.f:39
subroutine elemdx(CARD, LUN)
This subroutine decodes the scale factor, reference value, bit width and units (i....
Definition: elemdx.f:20
recursive subroutine exitbufr
This subroutine frees all dynamically-allocated memory, closes all logical units that are open within...
Definition: exitbufr.f:34
integer function ibfms(R8VAL)
Test whether a real*8 data value is "missing".
Definition: ibfms.f:28
function ifxy(ADSC)
Convert an FXY value from its 6 character representation to its WMO bit-wise representation.
Definition: ifxy.f:34
recursive function igetmxby()
Get the maximum length of a BUFR message that can be written to an output file.
Definition: igetmxby.f:21
function igetntbi(LUN, CTB)
This function returns the next available index for storing an entry within a specified internal DX BU...
Definition: igetntbi.f:22
integer function igetprm(CPRMNM)
Get the current value of a parameter.
Definition: igetprm.f:67
function igettdi(IFLAG)
Get the next usable Table D index for the current master table, or reset the index.
Definition: igettdi.f:28
integer function imrkopr(NEMO)
Check whether a specified mnemonic is a Table C marker operator.
Definition: imrkopr.f:16
recursive function ireadmg(LUNIT, SUBSET, IDATE)
Calls NCEPLIBS-bufr subroutine readmg() and passes back its return code as the function value.
Definition: ireadmg.f:27
recursive function ireadns(LUNIT, SUBSET, IDATE)
Read the next data subset from a BUFR file that was previously opened for reading.
Definition: ireadns.f:32
recursive function ireadsb(LUNIT)
Calls NCEPLIBS-bufr subroutine readsb() and passes back its return code as the function value.
Definition: ireadsb.f:20
recursive function isetprm(CPRMNM, IPVAL)
Define a customized parameter value for dynamic allocation.
Definition: isetprm.f:76
function istdesc(IDN)
Check whether a descriptor is WMO-standard.
Definition: istdesc.f:23
recursive function iupb(MBAY, NBYT, NBIT)
Decode an integer value from an integer array.
Definition: iupb.f:21
recursive function iupbs01(MBAY, S01MNEM)
Read a data value from Section 0 or Section 1 of a BUFR message.
Definition: iupbs01.f:69
recursive subroutine maxout(MAXO)
This subroutine allows the user to define the maximum length of a BUFR message that can be written to...
Definition: maxout.f:27
recursive subroutine mtinfo(CMTDIR, LUNMT1, LUNMT2)
Specify the directory location and Fortran logical unit numbers to be used when reading master BUFR t...
Definition: mtinfo.f:39
Wrap Fortran NCEPLIBS-bufr subprograms and variables so they can be called from within C.
subroutine, public get_isc_c(isc_ptr, isc_size)
Get copy of the moda_tables ISC array.
subroutine, public open_c(lunit, filepath)
Open a Fortran file from a C program.
integer(c_int) function, public ifxy_c(cfxy)
Convert an FXY value from its 6 character representation to its WMO bit-wise representation.
subroutine, public get_nval_c(lun, num_nodes)
Get the number of values in the current subset.
subroutine, public stntbi_c(n, lun, numb, nemo, celsq)
Store a new entry within the internal BUFR Table B or D.
subroutine, public status_c(file_unit, lun, il, im)
Check whether a file is connected to the library.
integer(c_int) function, public ireadmg_c(bufr_unit, c_subset, iddate, subset_str_len)
Read the next message from a BUFR file.
integer(c_int) function, public igetprm_c(cprmnm)
Get the current value of a parameter.
subroutine, public closbf_c(bufr_unit)
Close a previously opened file and disconnect it from the library.
subroutine, public close_c(lunit)
Close a Fortran file from a C program.
integer(c_int) function, public ibfms_c(r8val)
Test whether a data value is "missing".
subroutine, public ufbint_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Read/write one or more data values from/to a data subset.
subroutine, public mtinfo_c(path, file_unit_1, file_unit_2)
Specify location of master BUFR tables on local file system.
integer(c_int) function, public igetntbi_c(lun, table_type)
Get the next index for storing an entry within an internal DX BUFR table.
subroutine, public ufbrep_c(bufr_unit, c_data, dim_1, dim_2, iret, table_b_mnemonic)
Read/write one or more data values from/to a data subset.
integer(c_int) function, public iupbs01_c(bufr, mnemonic)
Read a data value from Section 0 or Section 1 of a BUFR message.
subroutine, public nemspecs_c(file_unit, mnemonic, mnemonic_idx, scale, reference, bits, iret)
Get the scale factor, reference value and bit width associated with a specified occurrence of a Table...
subroutine, public exitbufr_c()
Reset the library.
integer(c_int) function, public igettdi_c(iflag)
Get the next usable Table D index for the current master table, or reset the index.
subroutine, public get_inv_c(lun, inv_ptr, inv_size)
Get pointer to the moda_usrint INV array.
subroutine, public get_tag_c(tag_ptr, tag_len, mem_size)
Get copy of the moda_tables TAG array.
subroutine, public cadn30_c(idn, adn, adn_str_len)
Convert an FXY value from its WMO bit-wise representation to its six-character representation.
subroutine, public openbf_c(bufr_unit, cio, table_file_id)
Connect a new file to the library, or initialize the library, or change verbosity associated with alr...
subroutine, public bort_c(errstr)
Log one error message and abort application program.
integer(c_int) function, public istdesc_c(idn)
Check whether a descriptor is WMO-standard.
subroutine, public nemdefs_c(file_unit, mnemonic, unit_c, unit_str_len, desc_c, desc_str_len, iret)
Get the element name and units associated with a Table B mnemonic.
subroutine, public get_typ_c(typ_ptr, typ_len, mem_size)
Get copy of the moda_tables TYP array.
integer(c_int) function, public ireadns_c(bufr_unit, c_subset, iddate, subset_str_len)
Read the next data subset from a BUFR file.
subroutine, public pktdd_c(id, lun, idn, iret)
Store information about a child mnemonic within the internal arrays.
subroutine, public elemdx_c(card, lun)
Decode the scale factor, reference value, bit width, and units from a Table B mnemonic definition.
subroutine, public uptdd_c(id, lun, ient, iret)
Get the WMO bit-wise representation of the FXY value corresponding to a child mnemonic of a Table D s...
integer(c_int) function, public imrkopr_c(nemo)
Check whether a specified mnemonic is a Table C marker operator.
subroutine, public maxout_c(max0)
Define a customized maximum length for output BUFR messages.
subroutine, public get_jmpb_c(jmpb_ptr, jmpb_size)
Get copy of the moda_tables JMPB array.
subroutine, public openmb_c(bufr_unit, c_subset, iddate)
Open a new message for output in a BUFR file that was previously opened for writing.
subroutine, public get_inode_c(lun, start_node)
Get the bufr node idx for the start node of the subset.
subroutine, public delete_table_data_c()
Deletes the copies of the moda_tables arrays.
subroutine, public numtbd_c(lun, idn, nemo, nemo_str_len, tab, iret)
Search for a Table B or Table D descriptor within the internal DX BUFR tables.
subroutine, public nemtab_c(lun, mnemonic, descriptor, table_type, table_idx)
Get information about a descriptor.
integer(c_int) function, public ireadsb_c(bufr_unit)
Read the next data subset from a BUFR message.
subroutine, public get_link_c(link_ptr, link_size)
Get copy of the moda_tables LINK array.
subroutine, public readlc_c(lunit, str_id, output_str, output_str_len)
Function used to get long strings from the BUFR file.
integer(c_int) function, public iupb_c(mbay, nbyt, nbit)
Decode an integer value from an integer array.
subroutine, public wrdlen_c()
Determine important information about the local machine.
integer(c_int) function, public isetprm_c(cprmnm, ipval)
Define a customized parameter value for dynamic allocation.
subroutine, public bvers_c(cverstr, cverstr_len)
Get the version number of the NCEPLIBS-bufr software.
subroutine, public get_itp_c(itp_ptr, itp_size)
Get copy of the moda_tables ITP array.
subroutine, public nemtbb_c(lun, table_idx, unit_str, unit_str_len, scale, reference, bits)
Get information about a Table B descriptor.
subroutine, public ufbseq_c(bufr_unit, c_data, dim_1, dim_2, iret, table_d_mnemonic)
Read/write an entire sequence of data values from/to a data subset.
integer(c_int) function, public igetmxby_c()
Get the maximum length of a BUFR message that can be written to an output file.
subroutine, public get_irf_c(irf_ptr, irf_size)
Get copy of the moda_tables IRF array.
subroutine, public get_val_c(lun, val_ptr, val_size)
Get pointer to the moda_usrint VAL array.
subroutine, public strnum_c(str, num, iret)
Decode an integer from a character string.
This module contains declarations for arrays used to store information about the current BUFR message...
integer, dimension(:), allocatable inode
Table A mnemonic for type of BUFR message.
This module contains array and variable declarations needed to store information about long character...
This module contains array and variable declarations used to store the internal jump/link table.
integer, dimension(:), allocatable irf
Reference values corresponding to tag and typ:
integer, dimension(:), allocatable isc
Scale factors corresponding to tag and typ:
character *3, dimension(:), allocatable typ
Type indicators corresponding to tag:
integer, dimension(:), allocatable jmpb
Jump backward indices corresponding to tag and typ:
character *10, dimension(:), allocatable tag
Mnemonics in the jump/link table.
integer ntab
Number of entries in the jump/link table.
integer, dimension(:), allocatable itp
Integer type values corresponding to typ:
integer, dimension(:), allocatable link
Link indices corresponding to tag, typ and jmpb:
This module contains declarations for arrays used to store data values and associated metadata for th...
integer, dimension(:), allocatable nval
Number of data values in BUFR data subset.
real *8, dimension(:,:), allocatable, target val
Data values.
integer, dimension(:,:), allocatable, target inv
Inventory pointer which links each data value to its corresponding node in the internal jump/link tab...
recursive 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 ...
Definition: nemdefs.f:32
recursive 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,...
Definition: nemspecs.f:47
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
Get information about a descriptor, based on the mnemonic.
Definition: nemtab.f:29
subroutine nemtbb(LUN, ITAB, UNIT, ISCL, IREF, IBIT)
Get information about a Table B descriptor.
Definition: nemtbb.f:22
subroutine numtbd(LUN, IDN, NEMO, TAB, IRET)
Search for a Table B or Table D descriptor within the internal DX BUFR tables.
Definition: numtbd.f:24
recursive subroutine openbf(LUNIT, IO, LUNDX)
Connects a new file to the NCEPLIBS-bufr software for input or output operations, or initializes the ...
Definition: openbf.f:124
recursive subroutine openmb(LUNIT, SUBSET, JDATE)
Open a new message for output in a BUFR file that was previously opened for writing.
Definition: openmb.f:42
subroutine pktdd(ID, LUN, IDN, IRET)
Store information about a child mnemonic within the internal arrays.
Definition: pktdd.f:26
recursive subroutine readlc(LUNIT, CHR, STR)
Read a long character string (greater than 8 bytes) from a data subset.
Definition: readlc.f:50
recursive subroutine status(LUNIT, LUN, IL, IM)
Check whether a specified Fortran logical unit number is currently connected to the NCEPLIBS-bufr sof...
Definition: status.f:36
subroutine stntbi(N, LUN, NUMB, NEMO, CELSQ)
Store a new entry within the internal BUFR Table B or D.
Definition: stntbi.f:20
recursive subroutine strnum(str, num, iret)
Decode an integer from a character string.
Definition: strnum.F90:24
recursive subroutine ufbint(LUNIN, USR, I1, I2, IRET, STR)
Read/write one or more data values from/to a data subset.
Definition: ufbint.f:121
recursive subroutine ufbrep(LUNIN, USR, I1, I2, IRET, STR)
Read/write one or more data values from/to a data subset.
Definition: ufbrep.f:116
recursive subroutine ufbseq(LUNIN, USR, I1, I2, IRET, STR)
This subroutine reads or writes an entire sequence of data values from or to the BUFR data subset tha...
Definition: ufbseq.f:128
subroutine uptdd(ID, LUN, IENT, IRET)
Returns the WMO bit-wise representation of the FXY value corresponding to a child mnemonic of a Table...
Definition: uptdd.f:28
subroutine wrdlen
Determine important information about the local machine.
Definition: wrdlen.F:25