NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
w3fi04.f
Go to the documentation of this file.
1C> @file
2C> @brief Find word size, endian, character set.
3C> @author Ralph Jones @date 1994-10-07
4
5C> Subroutine computes word size, the type of character
6C> set, ASCII or EBCDIC, and if the computer is big-endian, or
7C> little-endian.
8C>
9C> Program history log:
10C> - Relph Jones 1994-10-07
11C> - Stephen Gilbert 1998-07-08 Removed the Fortran SAVE Statement.
12C> The SAVE statement is not needed for this outine, and may have been
13C> causing errors using the f90 compiler under the 2.0 Programming Environment.
14C> - Boi Vuong 2002-10-15 Replaced Function ICHAR with mova2i
15C>
16C> @param[out] IENDN Integer for big-endian or little-endian
17C> - =0 big-endian
18C> - =1 little-endian
19C> - =2 cannot compute
20C> @param[out] ITYPEC Integer for type of character set
21C> - =0 ASCII character set
22C> - =1 EBCDIC character set
23C> - =2 not ASCII or EBCDIC
24C> @param[out] LW Integer for words size of computer in bytes
25C> - =4 for 32 bit computers
26C> - =8 for 64 bit computers
27C>
28C> @author Ralph Jones @date 1994-10-07
29 SUBROUTINE w3fi04(IENDN,ITYPEC,LW)
30C
31 INTEGER ITEST1
32 INTEGER ITEST2
33 INTEGER ITEST3
34 INTEGER IENDN
35 INTEGER ITYPEC
36 INTEGER LW
37C
38 CHARACTER * 8 CTEST1
39 CHARACTER * 8 CTEST2
40 CHARACTER * 1 CTEST3(8)
41 CHARACTER * 1 BLANK
42C
43 equivalence(ctest1,itest1),(ctest2,itest2)
44C
45 equivalence(itest3,ctest3(1))
46C
47 DATA ctest1/'12345678'/
48 DATA itest3/z'01020304'/
49 DATA blank /' '/
50C
51C SAVE
52C
53C TEST FOR TYPE OF CHARACTER SET
54C BLANK IS 32 (20 HEX) IN ASCII, 64 (40 HEX) IN EBCDEC
55C
56 IF (mova2i(blank).EQ.32) THEN
57 itypec = 0
58 ELSE IF (mova2i(blank).EQ.64) THEN
59C
60C COMPUTER IS PROBABLY AN IBM360, 370, OR 390 WITH
61C A 32 BIT WORD SIZE, AND BIG-ENDIAN.
62C
63 itypec = 1
64 ELSE
65 itypec = 2
66 END IF
67C
68C TEST FOR WORD SIZE, SET LW TO 4 FOR 32 BIT COMPUTER,
69C 8 FOR FOR 64 BIT COMPUTERS
70C
71 itest2 = itest1
72 IF (ctest1 .EQ. ctest2) THEN
73C
74C COMPUTER MAY BE A CRAY, OR COULD BE DEC VAX ALPHA
75C OR SGI WITH R4000, R4400, R8800 AFTER THEY CHANGE
76C FORTRAN COMPILERS FOR 64 BIT INTEGER.
77C
78 lw = 8
79 ELSE
80 lw = 4
81 ENDIF
82C
83C USING ITEST3 WITH Z'01020304' EQUIVALNCED TO CTEST3
84C ON A 32 BIT BIG-ENDIAN COMPUTER 03 IS IN THE 3RD
85C BYTE OF A 4 BYTE WORD. ON A 32 BIT LITTLE-ENDIAN
86C COMPUTER IT IS IN 2ND BYTE.
87C ON A 64 BIT COMPUTER Z'01020304' IS RIGHT ADJUSTED IN
88C A 64 BIT WORD, 03 IS IN THE 7TH BYTE. ON A LITTLE-
89C ENDIAN 64 BIT COMPUTER IT IS IN THE 2ND BYTE.
90C
91 IF (lw.EQ.4) THEN
92 IF (mova2i(ctest3(3)).EQ.3) THEN
93 iendn = 0
94 ELSE IF (mova2i(ctest3(3)).EQ.2) THEN
95 iendn = 1
96 ELSE
97 iendn = 2
98 END IF
99 ELSE IF (lw.EQ.8) THEN
100 IF (mova2i(ctest3(7)).EQ.3) THEN
101 iendn = 0
102 ELSE IF (mova2i(ctest3(2)).EQ.3) THEN
103 iendn = 1
104 ELSE
105 iendn = 2
106 END IF
107 ELSE
108 iendn = 2
109 END IF
110C
111 RETURN
112 END
integer function mova2i(a)
This Function copies a bit string from a Character*1 variable to an integer variable.
Definition mova2i.f:25
subroutine w3fi04(iendn, itypec, lw)
Subroutine computes word size, the type of character set, ASCII or EBCDIC, and if the computer is big...
Definition w3fi04.f:30