NCEPLIBS-bufr  12.1.0
blocks.F90
Go to the documentation of this file.
1 
4 
36 subroutine blocks(mbay,mwrd)
37 
38  use modv_vars, only: iblock, nbytw, iordle
39 
40  implicit none
41 
42  integer, intent(inout) :: mbay(*), mwrd
43 
44  integer iint, jint, i
45 
46  character*1 cint(4),dint(4)
47 
48  equivalence(cint,iint)
49  equivalence(dint,jint)
50 
51  if(iblock==0) return
52 
53  ! make room in mbay for control words - one at each end of the record
54 
55  do i=mwrd,1,-1
56  mbay(i+1) = mbay(i)
57  enddo
58 
59  ! store the endianized control word in bytes in dint/jint
60 
61  iint=mwrd*4
62 
63  do i=1,nbytw
64  if(iblock==-1) then
65 #ifdef BIG_ENDIAN
66  dint(i)=cint(iordle(i))
67 #else
68  dint(i)=cint(i)
69 #endif
70  elseif(iblock==1) then
71 #ifdef LITTLE_ENDIAN
72  dint(i)=cint(iordle(i))
73 #else
74  dint(i)=cint(i)
75 #endif
76  endif
77  enddo
78 
79  ! increment mrwd and install the control words in their proper places
80 
81  mwrd = mwrd+2
82  mbay(1) = jint
83  mbay(mwrd) = jint
84 
85  return
86 end subroutine blocks
87 
129 recursive subroutine setblock(iblk)
130 
131  use modv_vars, only: im8b, iblock
132 
133  implicit none
134 
135  integer, intent(in) :: iblk
136 
137  integer my_iblk
138 
139  ! Check for I8 integers.
140 
141  if(im8b) then
142  im8b=.false.
143 
144  call x84(iblk,my_iblk,1)
145  call setblock(my_iblk)
146 
147  im8b=.true.
148  return
149  endif
150 
151  iblock=iblk
152 
153  return
154 end subroutine setblock
subroutine blocks(mbay, mwrd)
Encapsulate a BUFR message with IEEE Fortran control words as specified via the most recent call to s...
Definition: blocks.F90:37
recursive subroutine setblock(iblk)
Specify whether BUFR messages output by future calls to message-writing subroutines should be encapsu...
Definition: blocks.F90:130
subroutine x84(iin8, iout4, nval)
Encode one or more 8-byte integer values as 4-byte integer values.
Definition: x4884.F90:65