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