NCEPLIBS-bufr  12.0.0
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 
593  subroutine delete_table_data_c() bind(C, name='delete_table_data_f')
594  if (allocated(isc_f)) deallocate(isc_f)
595  if (allocated(link_f)) deallocate(link_f)
596  if (allocated(itp_f)) deallocate(itp_f)
597  if (allocated(typ_f)) deallocate(typ_f)
598  if (allocated(tag_f)) deallocate(tag_f)
599  if (allocated(jmpb_f)) deallocate(jmpb_f)
600  if (allocated(irf_f)) deallocate(irf_f)
601  end subroutine delete_table_data_c
602 
615  function iupbs01_c(bufr, mnemonic) result(ires) bind(C, name='iupbs01_f')
616  integer(c_int), intent(in) :: bufr(*)
617  character(kind=c_char, len=1), intent(in) :: mnemonic(*)
618  integer(c_int) :: ires
619  integer :: iupbs01
620 
621  ires = iupbs01(bufr,c_f_string(mnemonic))
622  end function iupbs01_c
623 
634  function igetprm_c(cprmnm) result(ires) bind(C, name='igetprm_f')
635  character(kind=c_char, len=1), intent(in) :: cprmnm(*)
636  integer(c_int) :: ires
637  integer :: igetprm
638 
639  ires = igetprm(c_f_string(cprmnm))
640  end function igetprm_c
641 
652  function isetprm_c(cprmnm,ipval) result(ires) bind(C, name='isetprm_f')
653  character(kind=c_char, len=1), intent(in) :: cprmnm(*)
654  integer(c_int), value, intent(in) :: ipval
655  integer(c_int) :: ires
656  integer :: isetprm
657 
658  ires = isetprm(c_f_string(cprmnm),ipval)
659  end function isetprm_c
660 
669  subroutine maxout_c(max0) bind(C, name='maxout_f')
670  integer(c_int), value, intent(in) :: max0
671 
672  call maxout(max0)
673  end subroutine maxout_c
674 
684  function igetmxby_c() result(ires) bind(C, name='igetmxby_f')
685  integer(c_int) :: ires
686  integer :: igetmxby
687 
688  ires = igetmxby()
689  end function igetmxby_c
690 
701  subroutine cadn30_c(idn, adn, adn_str_len) bind(C, name='cadn30_f')
702  integer(c_int), intent(in), value :: idn, adn_str_len
703  character(kind=c_char, len=1), intent(out) :: adn(*)
704  character(len=8) :: adn_f
705 
706  call cadn30(idn, adn_f)
707  call copy_f_c_str(adn_f, adn, adn_str_len)
708  end subroutine cadn30_c
709 
720  function igetntbi_c(lun, table_type) result(ires) bind(C, name='igetntbi_f')
721  integer(c_int), value, intent(in) :: lun
722  character(kind=c_char,len=1), intent(in) :: table_type(*)
723  integer(c_int) :: ires
724  integer :: igetntbi
725  character(len=1) :: table_type_f
726 
727  table_type_f(1:1) = table_type(1)(1:1)
728 
729  ires = igetntbi(lun, table_type_f)
730  end function igetntbi_c
731 
741  subroutine elemdx_c(card,lun) bind(C, name='elemdx_f')
742  integer(c_int), value, intent(in) :: lun
743  character(kind=c_char, len=1), intent(in) :: card(*)
744  character(len=80) :: card_f
745  integer :: ii
746 
747  do ii = 1,80
748  card_f(ii:ii) = card(1)(ii:ii)
749  enddo
750  call elemdx(card_f, lun)
751  end subroutine elemdx_c
752 
765  subroutine numtbd_c(lun,idn,nemo,nemo_str_len,tab,iret) bind(C, name='numtbd_f')
766  integer(c_int), value, intent(in) :: lun, idn, nemo_str_len
767  character(kind=c_char,len=1), intent(out) :: nemo(*), tab(*)
768  integer(c_int), intent(out) :: iret
769 
770  character(len=9) :: nemo_f
771  character(len=1) :: tab_f
772 
773  call numtbd(lun, idn, nemo_f, tab_f, iret)
774 
775  call copy_f_c_str(nemo_f, nemo, nemo_str_len)
776  tab(1)(1:1) = tab_f(1:1)
777  end subroutine numtbd_c
778 
789  function ifxy_c(cfxy) result(ires) bind(C, name='ifxy_f')
790  character(kind=c_char, len=1), intent(in) :: cfxy(*)
791  integer(c_int) :: ires
792  integer :: ifxy
793 
794  ires = ifxy(c_f_string(cfxy))
795  end function ifxy_c
796 
813  subroutine uptdd_c(id, lun, ient, iret) bind(C, name='uptdd_f')
814  integer(c_int), intent(in), value :: id, lun, ient
815  integer(c_int), intent(out) :: iret
816 
817  call uptdd(id, lun, ient, iret)
818  end subroutine uptdd_c
819 
829  function imrkopr_c(nemo) result(ires) bind(C, name='imrkopr_f')
830  character(kind=c_char, len=1), intent(in) :: nemo(*)
831  integer(c_int) :: ires
832  integer :: imrkopr
833 
834  ires = imrkopr(c_f_string(nemo))
835  end function imrkopr_c
836 
846  function istdesc_c(idn) result(ires) bind(C, name='istdesc_f')
847  integer(c_int), intent(in), value :: idn
848  integer(c_int) :: ires
849  integer :: istdesc
850 
851  ires = istdesc(idn)
852  end function istdesc_c
853 
865  subroutine ufbseq_c(bufr_unit, c_data, dim_1, dim_2, iret, table_d_mnemonic) bind(C, name='ufbseq_f')
866  integer(c_int), value, intent(in) :: bufr_unit
867  type(c_ptr), intent(inout) :: c_data
868  integer(c_int), value, intent(in) :: dim_1, dim_2
869  integer(c_int), intent(out) :: iret
870  character(kind=c_char, len=1), intent(in) :: table_d_mnemonic(*)
871  real, pointer :: f_data
872 
873  call c_f_pointer(c_data, f_data)
874  call ufbseq(bufr_unit, f_data, dim_1, dim_2, iret, c_f_string(table_d_mnemonic))
875  end subroutine ufbseq_c
876 
891  function ireadns_c(bufr_unit, c_subset, iddate, subset_str_len) result(ires) bind(C, name='ireadns_f')
892  integer(c_int), value, intent(in) :: bufr_unit
893  character(kind=c_char, len=1), intent(out) :: c_subset(*)
894  integer(c_int), intent(out) :: iddate
895  integer(c_int), value, intent(in) :: subset_str_len
896  integer(c_int) :: ires
897  character(len=25) :: f_subset
898  integer :: ireadns
899 
900  ires = ireadns(bufr_unit, f_subset, iddate)
901 
902  if (ires == 0) then
903  call copy_f_c_str(f_subset, c_subset, subset_str_len)
904  end if
905  end function ireadns_c
906 
916  function ibfms_c(r8val) result(ires) bind(C, name='ibfms_f')
917  real(c_double), intent(in), value :: r8val
918  integer(c_int) :: ires
919  integer :: ibfms
920 
921  ires = ibfms(r8val)
922  end function ibfms_c
923 
933  subroutine strnum_c(str,num,iret) bind(C, name='strnum_f')
934  character(kind=c_char, len=1), intent(in) :: str(*)
935  integer(c_int), intent(out) :: num, iret
936 
937  call strnum(c_f_string(str), num, iret)
938  end subroutine strnum_c
939 
951  subroutine stntbi_c(n,lun,numb,nemo,celsq) bind(C, name='stntbi_f')
952  integer(c_int), intent(in), value :: n, lun
953  character(kind=c_char, len=1), intent(in) :: numb(*), nemo(*), celsq(*)
954  character(len=6) :: numb_f
955  character(len=8) :: nemo_f
956  character(len=55) :: celsq_f
957  integer :: ii
958 
959  do ii = 1,6
960  numb_f(ii:ii) = numb(1)(ii:ii)
961  enddo
962  do ii = 1,8
963  nemo_f(ii:ii) = nemo(1)(ii:ii)
964  enddo
965  do ii = 1,55
966  celsq_f(ii:ii) = celsq(1)(ii:ii)
967  enddo
968  call stntbi(n, lun, numb_f, nemo_f, celsq_f)
969  end subroutine stntbi_c
970 
981  function igettdi_c(iflag) result(ires) bind(C, name='igettdi_f')
982  integer(c_int), intent(in), value :: iflag
983  integer(c_int) :: ires
984  integer :: igettdi
985 
986  ires = igettdi(iflag)
987  end function igettdi_c
988 
1001  subroutine pktdd_c(id, lun, idn, iret) bind(C, name='pktdd_f')
1002  integer(c_int), intent(in), value :: id, lun, idn
1003  integer(c_int), intent(out) :: iret
1004 
1005  call pktdd(id, lun, idn, iret)
1006  end subroutine pktdd_c
1007 
1015  subroutine bort_c(errstr) bind(C, name='bort_f')
1016  character(kind=c_char, len=1), intent(in) :: errstr(*)
1017 
1018  call bort(c_f_string(errstr))
1019  end subroutine bort_c
1020 
1031  subroutine openmb_c(bufr_unit, c_subset, iddate) bind(C, name='openmb_f')
1032  integer(c_int), value, intent(in) :: bufr_unit, iddate
1033  character(kind=c_char, len=1), intent(in) :: c_subset(*)
1034 
1035  call openmb(bufr_unit, c_f_string(c_subset), iddate)
1036  end subroutine openmb_c
1037 
1046  subroutine bvers_c(cverstr, cverstr_len) bind(C, name='bvers_f')
1047  character(kind=c_char, len=1), intent(out) :: cverstr(*)
1048  integer(c_int), value, intent(in) :: cverstr_len
1049  character(len=10) :: f_cverstr
1050 
1051  call bvers(f_cverstr)
1052  call copy_f_c_str(f_cverstr, cverstr, cverstr_len)
1053  end subroutine bvers_c
1054 
1060  subroutine wrdlen_c() bind(C, name='wrdlen_f')
1061  call wrdlen()
1062  end subroutine wrdlen_c
1063 
1075  function iupb_c(mbay,nbyt,nbit) result(ires) bind(C, name='iupb_f')
1076  integer(c_int), intent(in) :: mbay(*)
1077  integer(c_int), intent(in), value :: nbyt, nbit
1078  integer(c_int) :: ires
1079  integer :: iupb
1080 
1081  ires = iupb(mbay,nbyt,nbit)
1082  end function iupb_c
1083 
1092  subroutine cmpmsg_c(cf) bind(C, name='cmpmsg_f')
1093  character(kind=c_char, len=1), intent(in) :: cf(*)
1094 
1095  call cmpmsg(c_f_string(cf))
1096  end subroutine cmpmsg_c
1097 
1098 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.
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 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 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