SURFEX v8.1
General documentation of Surfex
sbyte_mf.F
Go to the documentation of this file.
1  SUBROUTINE sbyte_mf(KDEST,KSOURC,KOFSET,KBYTSZ)
2  USE parkind1, ONLY : jprb
3  USE yomhook , ONLY : lhook, dr_hook
4  USE lfi_precision
5 !*****
6 !*
7 !* FUNCTION: STORE A SINGLE BIT FIELD FROM KSOURC INTO KDEST
8 !*
9 !* INPUT : KSOURC = WORD CONTAINING BIT FIELD RIGHT JUSTIFIED
10 !* KDEST(1) = 1ST TARGET WORD
11 !* KOFSET = OFFSET IN BITS FOR START OF THE FIELD
12 !* KBYTSZ = LENGTH OF FIELD IN BITS ; .LE.WORD SIZE .....
13 !*
14 !* OUTPUT : KSOURC,KOFSET,KBYTSZ UNCHANGED
15 !* KDEST(1) AND EVENTUALLY KDEST(2) CONTAIN FIELD
16 !*
17 !* AUTHOR : M.MIQUEU 08/1981 (REWRITTEN FROM J.MARTELLET'S)
18 !*
19 !*****
20 !
21  IMPLICIT NONE
22 !
23  INTEGER (KIND=JPLIKM) :: KOFSET
24  INTEGER (KIND=JPLIKM) :: KBYTSZ
25  INTEGER (KIND=JPLIKB) :: KSOURC
26 !
27  INTEGER (KIND=JPLIKB) :: KDEST(*)
28 !
29  INTEGER (KIND=JPLIKM) :: INBPW, ISH1, ISH2, ISH3
30 !
31  REAL(KIND=JPRB) :: ZHOOK_HANDLE
32  IF (lhook) CALL dr_hook('SBYTE_MF',0,zhook_handle)
33  inbpw=64
34  ish1=kofset+kbytsz-inbpw
35 !
36  IF (ish1.LE.0) THEN
37 !
38 ! BYTE DOES NOT SPAN WORDS
39 !
40  kdest(1)=ishftc(ior(ishft(ishftc(kdest(1),kofset, &
41  & bit_size(kdest(1))),kbytsz), &
42  & ibits(ksourc,0,kbytsz)),-ish1, &
43  & bit_size(ior(ishft(ishftc(kdest(1),kofset, &
44  & bit_size(kdest(1))),kbytsz),ibits(ksourc,0,kbytsz))))
45 !
46  ELSE
47 !
48 ! BYTE SPANS 2 WORDS
49 !
50  kdest(1)=ior(ishftc(ishft(kdest(1),kofset-inbpw),inbpw-kofset, &
51  & bit_size(ishft(kdest(1),kofset-inbpw))), &
52  & ishft(ibits(ksourc,0,kbytsz),-ish1))
53 !
54  kdest(2)=ishftc(ior(ishft(kdest(2),ish1),ibits(ksourc,0,ish1)), &
55  & -ish1,bit_size(ior(ishft(kdest(2),ish1), &
56  & ibits(ksourc,0,ish1))))
57 !
58  ENDIF
59 !
60  IF (lhook) CALL dr_hook('SBYTE_MF',1,zhook_handle)
61  ENDSUBROUTINE sbyte_mf
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine sbyte_mf(KDEST, KSOURC, KOFSET, KBYTSZ)
Definition: sbyte_mf.F:2