NCEPLIBS-bufr  12.0.0
elemdx.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Decode the scale factor, reference value,
3 C> bit width, and units from a Table B mnemonic definition.
4 C> @author Woollen @date 1994-01-06
5 
6 C> This subroutine decodes the scale factor, reference value,
7 C> bit width and units (i.e., the "elements") from a Table B mnemonic
8 C> definition card that was previously read from a user-supplied DX BUFR
9 C> table file in character format by subroutine rdusdx().
10 C> These decoded values are then added to the
11 C> already-existing entry for that mnemonic within the internal BUFR
12 C> Table B array TABB(*,LUN) in module @ref moda_tababd.
13 C>
14 C> @param[in] CARD - character*80: mnemonic definition card that was read
15 C> from a user-supplied DX BUFR table.
16 C> @param[in] LUN - integer: I/O stream index into internal memory arrays.
17 C>
18 C> @author Woollen @date 1994-01-06
19  SUBROUTINE elemdx(CARD,LUN)
20 
21  USE moda_tababd
22 
23  CHARACTER*128 BORT_STR1,BORT_STR2
24  CHARACTER*80 CARD
25  CHARACTER*24 UNIT
26  CHARACTER*11 REFR,REFR_ORIG
27  CHARACTER*8 NEMO
28  CHARACTER*4 SCAL,SCAL_ORIG
29  CHARACTER*3 BITW,BITW_ORIG
30  CHARACTER*1 SIGN,TAB
31 
32 C-----------------------------------------------------------------------
33 C-----------------------------------------------------------------------
34 
35 C CAPTURE THE VARIOUS ELEMENTS CHARACTERISTICS
36 C --------------------------------------------
37 
38  nemo = card( 3:10)
39  scal = card(14:17)
40  refr = card(21:31)
41  bitw = card(35:37)
42  unit = card(41:64)
43 c .... Make sure the units are all capitalized
44  CALL capit(unit)
45 
46 C FIND THE ELEMENT TAG IN TABLE B
47 C -------------------------------
48 
49 C Note that an entry for this mnemonic should already exist within
50 C the internal BUFR Table B array TABB(*,LUN). We now need to
51 C retrieve the positional index for that entry within TABB(*,LUN)
52 C so that we can access the entry and then add the scale factor,
53 C reference value, bit width, and units to it.
54 
55  CALL nemtab(lun,nemo,idsn,tab,iele)
56  IF(tab.NE.'B') GOTO 900
57 
58 C LEFT JUSTIFY AND STORE CHARACTERISTICS
59 C --------------------------------------
60 
61  unit = adjustl(unit)
62  IF(unit.EQ.' ') GOTO 904
63  tabb(iele,lun)(71:94) = unit
64 
65  scal_orig=scal
66  CALL jstnum(scal,sign,iret)
67  IF(iret.NE.0) GOTO 901
68  tabb(iele,lun)(95:95) = sign
69  tabb(iele,lun)(96:98) = scal(1:3)
70 
71  refr_orig=refr
72  CALL jstnum(refr,sign,iret)
73  IF(iret.NE.0) GOTO 902
74  tabb(iele,lun)( 99: 99) = sign
75  tabb(iele,lun)(100:109) = refr(1:10)
76 
77  bitw_orig=bitw
78  CALL jstnum(bitw,sign,iret)
79  IF(iret.NE.0 ) GOTO 903
80  IF(sign.EQ.'-') GOTO 903
81  tabb(iele,lun)(110:112) = bitw
82 
83 C EXITS
84 C -----
85 
86  RETURN
87 900 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
88  WRITE(bort_str2,'(18X,"MNEMONIC ",A," IS NOT A TABLE B ENTRY '//
89  . '(UNDEFINED, TAB=",A,")")') nemo,tab
90  CALL bort2(bort_str1,bort_str2)
91 901 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
92  WRITE(bort_str2,'(18X,"PARSED SCALE VALUE (=",A,") IS NOT '//
93  . 'NUMERIC")') scal_orig
94  CALL bort2(bort_str1,bort_str2)
95 902 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
96  WRITE(bort_str2,'(18X,"PARSED REFERENCE VALUE (=",A,") IS NOT '//
97  . 'NUMERIC")') refr_orig
98  CALL bort2(bort_str1,bort_str2)
99 903 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
100  WRITE(bort_str2,'(18X,"PARSED BIT WIDTH VALUE (=",A,") IS NOT '//
101  . 'NUMERIC")') bitw_orig
102  CALL bort2(bort_str1,bort_str2)
103 904 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
104  WRITE(bort_str2,'(18X,"UNITS FIELD IS EMPTY")')
105  CALL bort2(bort_str1,bort_str2)
106  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
subroutine capit(STR)
This subroutine capitalizes all of the alphabetic characters in a string.
Definition: capit.f:13
subroutine elemdx(CARD, LUN)
This subroutine decodes the scale factor, reference value, bit width and units (i....
Definition: elemdx.f:20
subroutine jstnum(STR, SIGN, IRET)
This subroutine left-justifies a character string containing an encoded integer, by removing all lead...
Definition: jstnum.f:24
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
character *128, dimension(:,:), allocatable tabb
Table B entries for each internal I/O stream.
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
Get information about a descriptor, based on the mnemonic.
Definition: nemtab.f:29