Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / var / external / bufr / adn30.f
blobc7306f7b8dc50065e8f8a60823321ca704b0e5d3
1 FUNCTION ADN30(IDN,L30)
3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
5 C SUBPROGRAM: ADN30
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS FUNCTION CONVERTS A DESCRIPTOR FROM ITS BIT-WISE
9 C (INTEGER) REPRESENTATION TO ITS FIVE OR SIX CHARACTER ASCII
10 C REPRESENTATION.
12 C PROGRAM HISTORY LOG:
13 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
14 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
15 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
16 C ROUTINE "BORT"
17 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
18 C INTERDEPENDENCIES
19 C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED
20 C DOCUMENTATION (INCLUDING HISTORY); OUTPUTS
21 C MORE COMPLETE DIAGNOSTIC INFO WHEN ROUTINE
22 C TERMINATES ABNORMALLY
24 C USAGE: ADN30 (IDN, L30)
25 C INPUT ARGUMENT LIST:
26 C IDN - INTEGER: BIT-WISE REPRESENTATION OF DESCRIPTOR (FXY)
27 C VALUE
28 C L30 - INTEGER: LENGTH OF ADN30 (NUMBER OF CHARACTERS, 5 OR
29 C 6)
31 C OUTPUT ARGUMENT LIST:
32 C ADN30 - CHARACTER*(*): CHARACTER FORM OF DESCRIPTOR (FXY
33 C VALUE)
35 C REMARKS:
36 C THIS ROUTINE CALLS: BORT
37 C THIS ROUTINE IS CALLED BY: CADN30 DXINIT ISTDESC NEMTBD
38 C NUMTAB RDMTBB RDMTBD READS3
39 C SEQSDX SNTBDE UFBQCD UPDS3
40 C WRDXTB
41 C Normally not called by any application
42 C programs.
44 C ATTRIBUTES:
45 C LANGUAGE: FORTRAN 77
46 C MACHINE: PORTABLE TO ALL PLATFORMS
48 C$$$
50 COMMON /HRDWRD/ NBYTW,NBITW,IORD(8)
52 CHARACTER*(*) ADN30
53 CHARACTER*128 BORT_STR
55 C----------------------------------------------------------------------
56 C----------------------------------------------------------------------
58 IF(LEN(ADN30).LT.L30 ) GOTO 900
59 IF(IDN.LT.0 .OR. IDN.GT.65535) GOTO 901
60 IF(L30.EQ.5) THEN
61 WRITE(ADN30,'(I5)') IDN
62 ELSEIF(L30.EQ.6) THEN
63 IDF = ISHFT(IDN,-14)
64 IDX = ISHFT(ISHFT(IDN,NBITW-14),-(NBITW-6))
65 IDY = ISHFT(ISHFT(IDN,NBITW- 8),-(NBITW-8))
66 WRITE(ADN30,'(I1,I2,I3)') IDF,IDX,IDY
67 ELSE
68 GOTO 902
69 ENDIF
71 DO I=1,L30
72 IF(ADN30(I:I).EQ.' ') ADN30(I:I) = '0'
73 ENDDO
75 C EXITS
76 C -----
78 RETURN
79 900 CALL BORT('BUFRLIB: ADN30 - FUNCTION RETURN STRING TOO SHORT')
80 901 CALL BORT('BUFRLIB: ADN30 - INTEGER REPRESENTATION OF '//
81 . 'DESCRIPTOR OUT OF 16-BIT RANGE')
82 902 WRITE(BORT_STR,'("BUFRLIB: ADN30 - CHARACTER LENGTH (",I4,") '//
83 . 'MUST BE EITHER 5 OR 6")') L30
84 CALL BORT(BORT_STR)
85 END