3 C$$$ SUBPROGRAM DOCUMENTATION BLOCK
6 C PRGMMR: WOOLLEN ORG: NP20 DATE: 1994-01-06
8 C ABSTRACT: THIS SUBROUTINE FIGURES OUT SOME IMPORTANT INFORMATION
9 C ABOUT THE LOCAL MACHINE ON WHICH THE BUFR ARCHIVE LIBRARY SOFTWARE
10 C IS BEING RUN AND STORES THIS INTO COMMON BLOCK /HRDWRD/. SUCH
11 C INFORMATION INCLUDES DETERMINING THE NUMBER OF BITS AND THE NUMBER
12 C OF BYTES IN A MACHINE WORD AS WELL AS DETERMINING WHETHER THE
13 C MACHINE USES THE ASCII OR EBCDIC CHARACTER SET.
15 C NOTE: IT IS ONLY NECESSARY FOR THIS SUBROUTINE TO BE CALLED ONCE,
16 C AND THIS IS NORMALLY DONE DURING THE FIRST CALL TO BUFR ARCHIVE
17 C LIBRARY SUBROUTINE OPENBF. HOWEVER, THE SUBROUTINE DOES KEEP TRACK
18 C OF WHETHER IT HAS ALREADY BEEN CALLED; THUS, IF IT IS CALLED AGAIN
19 C LATER BY A DIFFERENT BUFR ARCHIVE LIBRARY SUBROUTINE, IT WILL JUST
20 C QUIETLY RETURN WITHOUT (RE)COMPUTING ALL OF THE INFORMATION WITHIN
21 C COMMON BLOCK /HRDWRD/.
23 C PROGRAM HISTORY LOG:
24 C 1994-01-06 J. WOOLLEN -- ORIGINAL AUTHOR
25 C 1998-07-08 J. WOOLLEN -- REPLACED CALL TO CRAY LIBRARY ROUTINE
26 C "ABORT" WITH CALL TO NEW INTERNAL BUFRLIB
28 C 2003-11-04 J. ATOR -- ADDED DOCUMENTATION
29 C 2003-11-04 S. BENDER -- ADDED REMARKS/BUFRLIB ROUTINE
31 C 2003-11-04 D. KEYSER -- UNIFIED/PORTABLE FOR WRF; ADDED HISTORY
32 C DOCUMENTATION; OUTPUTS MORE COMPLETE
33 C DIAGNOSTIC INFO WHEN ROUTINE TERMINATES
34 C ABNORMALLY OR FOR INFORMATIONAL PURPOSES;
35 C NBYTW INITIALIZED AS ZERO THE FIRST TIME
36 C THIS ROUTINE IS CALLED (BEFORE WAS
37 C UNDEFINED WHEN FIRST REFERENCED)
38 C 2004-08-18 J. ATOR -- ADDED SAVE FOR IFIRST FLAG AND IMMEDIATE
40 C 2007-01-19 J. ATOR -- BIG-ENDIAN VS. LITTLE-ENDIAN IS NOW
41 C DETERMINED AT COMPILE TIME AND CONFIGURED
42 C WITHIN BUFRLIB VIA CONDITIONAL COMPILATION
44 C 2009-03-23 J. ATOR -- CALL BVERS TO GET VERSION NUMBER
49 C THIS ROUTINE CALLS: BORT BVERS ERRWRT IUPM
50 C THIS ROUTINE IS CALLED BY: COBFL COPYBF DATEBF DATELEN
51 C DUMPBF IUPBS01 MESGBC MESGBF
53 C Normally not called by any application
57 C LANGUAGE: FORTRAN 77
58 C MACHINE: PORTABLE TO ALL PLATFORMS
62 COMMON /HRDWRD
/ NBYTW
,NBITW
,IORD
(8)
63 COMMON /CHARAC
/ IASCII
,IATOE
(0:255),IETOA
(0:255)
66 CHARACTER*128 BORT_STR
,ERRSTR
67 CHARACTER*8 CINT
,DINT
,CVSTR
68 CHARACTER*6 CNDIAN
,CLANG
69 EQUIVALENCE
(CINT
,INT
)
70 EQUIVALENCE
(DINT
,JNT
)
77 C-----------------------------------------------------------------------
78 C-----------------------------------------------------------------------
80 C HAS THIS SUBROUTINE ALREADY BEEN CALLED?
84 C NO, SO CHECK WHETHER DIAGNOSTIC INFORMATION SHOULD BE PRINTED
85 C AND THEN PROCEED THROUGH THE REST OF THE SUBROUTINE.
91 C YES, SO THERE IS NO NEED TO PROCEED ANY FURTHER.
96 C COUNT THE BITS IN A WORD - MAX 64 ALLOWED
97 C -----------------------------------------
104 c .... DK: Can the below ever happen since upper loop bounds is 65?
105 10 IF(I
.GE
.65) GOTO 900
106 IF(MOD
(I
,8).NE
.0) GOTO 901
108 C NBITW is no. of bits in a word, NBYTW is no. of bytes in a word
109 C ---------------------------------------------------------------
114 C INDEX THE BYTE STORAGE ORDER - HIGH BYTE TO LOW BYTE
115 C -----------------------------------------------------
124 INT
= ISHFT
(1,(NBYTW
-I
)*8)
126 IF(CINT
(J
:J
).NE
.DINT
(J
:J
)) GOTO 20
128 c .... DK: Can the below ever happen since upper loop bounds is NBYTW?
129 20 IF(J
.GT
.NBYTW
) GOTO 902
133 C SETUP AN ASCII/EBCDIC TRANSLATOR AND DETERMINE WHICH IS NATIVE
134 C --------------------------------------------------------------
140 ELSEIF
(IA
.EQ
.193) THEN
441 WRITE ( UNIT
=ERRSTR
, FMT
='(2A)' )
443 & WELCOME TO THE BUFR ARCHIVE LIBRARY', ' =============='
445 WRITE ( UNIT
=ERRSTR
, FMT
='(A,I2)' )
446 & ' MACHINE CHARACTERISTICS: NUMBER OF BYTES PER WORD =', NBYTW
448 WRITE ( UNIT
=ERRSTR
, FMT
='(A,I3)' )
449 & ' NUMBER OF BITS PER WORD =', NBITW
451 WRITE ( UNIT
=ERRSTR
, FMT
='(3A)' )
452 & ' BYTE ORDER IS ', CNDIAN
,
455 WRITE ( UNIT
=ERRSTR
, FMT
='(3A)' )
457 & ' IS THE NATIVE LANGUAGE'
459 WRITE ( UNIT
=ERRSTR
, FMT
='(3A)' )
460 & '====================== VERSION: ', CVSTR
,
461 & '=========================='
470 900 WRITE(BORT_STR
,'("BUFRLIB: WRDLEN - MACHINE WORD LENGTH IS
471 & LIMITED TO 64 BITS (THIS MACHINE APPARENTLY HAS",I4," BIT
474 901 WRITE(BORT_STR
,'("BUFRLIB: WRDLEN - MACHINE WORD LENGTH (",I4,"
475 & ) IS NOT A MULTIPLE OF 8 (THIS MACHINE HAS WORDS NOT ON WHOLE
476 & BYTE BOUNDARIES!)")') I
478 902 WRITE(BORT_STR
,'("BUFRLIB: WRDLEN - BYTE ORDER CHECKING MISTAKE
479 & , LOOP INDEX J (HERE =",I3,") IS .GT. NO. OF BYTES PER WORD
480 & ON THIS MACHINE (",I3,")")') J
,NBYTW
482 903 WRITE(BORT_STR
,'("BUFRLIB: WRDLEN - CAN''T DETERMINE MACHINE
483 & NATIVE LANGUAGE (CHAR. A UNPACKS TO INT.",I4," NEITHER ASCII
484 & (65) NOR EBCDIC (193)")') IA