NCEPLIBS-bufr  11.6.0
 All Data Structures Files Functions Variables Pages
elemdx.f
Go to the documentation of this file.
1 C> @file
2 C> @author WOOLLEN @date 1994-01-06
3 
4 C> THIS SUBROUTINE DECODES THE SCALE FACTOR, REFERENCE VALUE,
5 C> BIT WIDTH AND UNITS (I.E., THE "ELEMENTS") FROM A TABLE B MNEMONIC
6 C> DEFINITION CARD THAT WAS PREVIOUSLY READ FROM A USER-SUPPLIED BUFR
7 C> DICTIONARY TABLE FILE IN CHARACTER FORMAT BY BUFR ARCHIVE LIBRARY
8 C> SUBROUTINE RDUSDX. THESE DECODED VALUES ARE THEN ADDED TO THE
9 C> ALREADY-EXISTING ENTRY FOR THAT MNEMONIC WITHIN THE INTERNAL BUFR
10 C> TABLE B ARRAY TABB(*,LUN) IN MODULE TABABD.
11 C>
12 C> PROGRAM HISTORY LOG:
13 C> 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
14 C> 1995-06-28 J. WOOLLEN -- INCREASED THE SIZE OF INTERNAL BUFR TABLE
15 C> ARRAYS IN ORDER TO HANDLE BIGGER FILES
16 C> 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
17 C> "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
18 C> ROUTINE "BORT"
19 C> 1999-11-18 J. WOOLLEN -- THE NUMBER OF BUFR FILES WHICH CAN BE
20 C> OPENED AT ONE TIME INCREASED FROM 10 TO 32
21 C> (NECESSARY IN ORDER TO PROCESS MULTIPLE
22 C> BUFR FILES UNDER THE MPI)
23 C> 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
24 C> 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
25 C> INTERDEPENDENCIES
26 C> 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
27 C> DOCUMENTATION; OUTPUTS MORE COMPLETE
28 C> DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
29 C> ABNORMALLY; CHANGED CALL FROM BORT TO BORT2
30 C> 2007-01-19 J. ATOR -- ADDED EXTRA ARGUMENT FOR CALL TO JSTCHR
31 C> 2014-12-10 J. ATOR -- USE MODULES INSTEAD OF COMMON BLOCKS
32 C> - 2021-09-30 J. Ator -- Replace jstchr with Fortran intrinsic
33 C> adjustl
34 C>
35 C> USAGE: CALL ELEMDX (CARD, LUN)
36 C> INPUT ARGUMENT LIST:
37 C> CARD - CHARACTER*80: MNEMONIC DEFINITION CARD THAT WAS READ
38 C> FROM A USER-SUPPLIED BUFR DICTIONARY TABLE
39 C> LUN - INTEGER: I/O STREAM INDEX INTO INTERNAL MEMORY ARRAYS
40 C>
41 C> REMARKS:
42 C> THIS ROUTINE CALLS: BORT2 CAPIT JSTNUM NEMTAB
43 C> THIS ROUTINE IS CALLED BY: RDUSDX STSEQ
44 C> Normally not called by any application
45 C> programs.
46 C>
47  SUBROUTINE elemdx(CARD,LUN)
48 
49  USE moda_tababd
50 
51  CHARACTER*128 bort_str1,bort_str2
52  CHARACTER*80 card
53  CHARACTER*24 unit
54  CHARACTER*11 refr,refr_orig
55  CHARACTER*8 nemo
56  CHARACTER*4 scal,scal_orig
57  CHARACTER*3 bitw,bitw_orig
58  CHARACTER*1 sign,tab
59 
60 C-----------------------------------------------------------------------
61 C-----------------------------------------------------------------------
62 
63 C CAPTURE THE VARIOUS ELEMENTS CHARACTERISTICS
64 C --------------------------------------------
65 
66  nemo = card( 3:10)
67  scal = card(14:17)
68  refr = card(21:31)
69  bitw = card(35:37)
70  unit = card(41:64)
71 c .... Make sure the units are all capitalized
72  CALL capit(unit)
73 
74 C FIND THE ELEMENT TAG IN TABLE B
75 C -------------------------------
76 
77 C Note that an entry for this mnemonic should already exist within
78 C the internal BUFR Table B array TABB(*,LUN). We now need to
79 C retrieve the positional index for that entry within TABB(*,LUN)
80 C so that we can access the entry and then add the scale factor,
81 C reference value, bit width, and units to it.
82 
83  CALL nemtab(lun,nemo,idsn,tab,iele)
84  IF(tab.NE.'B') goto 900
85 
86 C LEFT JUSTIFY AND STORE CHARACTERISTICS
87 C --------------------------------------
88 
89  unit = adjustl(unit)
90  IF(unit.EQ.' ') goto 904
91  tabb(iele,lun)(71:94) = unit
92 
93  scal_orig=scal
94  CALL jstnum(scal,sign,iret)
95  IF(iret.NE.0) goto 901
96  tabb(iele,lun)(95:95) = sign
97  tabb(iele,lun)(96:98) = scal
98 
99  refr_orig=refr
100  CALL jstnum(refr,sign,iret)
101  IF(iret.NE.0) goto 902
102  tabb(iele,lun)( 99: 99) = sign
103  tabb(iele,lun)(100:109) = refr
104 
105  bitw_orig=bitw
106  CALL jstnum(bitw,sign,iret)
107  IF(iret.NE.0 ) goto 903
108  IF(sign.EQ.'-') goto 903
109  tabb(iele,lun)(110:112) = bitw
110 
111 C EXITS
112 C -----
113 
114  RETURN
115 900 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
116  WRITE(bort_str2,'(18X,"MNEMONIC ",A," IS NOT A TABLE B ENTRY '//
117  . '(UNDEFINED, TAB=",A,")")') nemo,tab
118  CALL bort2(bort_str1,bort_str2)
119 901 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
120  WRITE(bort_str2,'(18X,"PARSED SCALE VALUE (=",A,") IS NOT '//
121  . 'NUMERIC")') scal_orig
122  CALL bort2(bort_str1,bort_str2)
123 902 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
124  WRITE(bort_str2,'(18X,"PARSED REFERENCE VALUE (=",A,") IS NOT '//
125  . 'NUMERIC")') refr_orig
126  CALL bort2(bort_str1,bort_str2)
127 903 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
128  WRITE(bort_str2,'(18X,"PARSED BIT WIDTH VALUE (=",A,") IS NOT '//
129  . 'NUMERIC")') bitw_orig
130  CALL bort2(bort_str1,bort_str2)
131 904 WRITE(bort_str1,'("BUFRLIB: ELEMDX - CARD READ IN IS: ",A)') card
132  WRITE(bort_str2,'(18X,"UNITS FIELD IS EMPTY")')
133  CALL bort2(bort_str1,bort_str2)
134  END
subroutine jstnum(STR, SIGN, IRET)
This subroutine left-justifies a character string containing an encoded integer, by removing all lead...
Definition: jstnum.f:33
subroutine bort2(STR1, STR2)
This subroutine calls subroutine errwrt() to log two error messages, then calls subroutine bort_exit(...
Definition: bort2.f:22
This module contains array and variable declarations used to store DX BUFR tables internally for mult...
Definition: moda_tababd.F:10
subroutine nemtab(LUN, NEMO, IDN, TAB, IRET)
This subroutine returns information about a descriptor from the internal DX BUFR tables, based on the mnemonic associated with that descriptor.
Definition: nemtab.f:44
subroutine elemdx(CARD, LUN)
THIS SUBROUTINE DECODES THE SCALE FACTOR, REFERENCE VALUE, BIT WIDTH AND UNITS (I.E., THE "ELEMENTS") FROM A TABLE B MNEMONIC DEFINITION CARD THAT WAS PREVIOUSLY READ FROM A USER-SUPPLIED BUFR DICTIONARY TABLE FILE IN CHARACTER FORMAT BY BUFR ARCHIVE LIBRARY SUBROUTINE RDUSDX.
Definition: elemdx.f:47
subroutine capit(STR)
This subroutine capitalizes all of the alphabetic characters in a string.
Definition: capit.f:18