-
Notifications
You must be signed in to change notification settings - Fork 13
/
readl.f
executable file
·141 lines (131 loc) · 3.42 KB
/
readl.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
! This file is part of stda.
!
! Copyright (C) 2013-2019 Stefan Grimme
!
! stda is free software: you can redistribute it and/or modify it under
! the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! stda is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public License
! along with stda. If not, see <https://www.gnu.org/licenses/>.
C *****************************************************************
SUBROUTINE READL(NL,A1,X,N)
IMPLICIT REAL*8 (A-H,O-Z)
CHARACTER*1 A1(*)
DIMENSION X(*)
I=0
IS=1
10 I=I+1
X(I)=XREAD(NL,A1,IS,IB,IE)
IF(IB.GT.0 .AND. IE.GT.0) THEN
IS=IE
GOTO 10
ENDIF
N=I-1
RETURN
END
C *****************************************************************
SUBROUTINE IREADL(NL,A1,IX,N)
IMPLICIT REAL*8 (A-H,O-Z)
CHARACTER*1 A1(*)
DIMENSION IX(*)
I=0
IS=1
10 I=I+1
IX(I)=IDINT(XREAD(NL,A1,IS,IB,IE))
IF(IB.GT.0 .AND. IE.GT.0) THEN
IS=IE
GOTO 10
ENDIF
N=I-1
RETURN
END
C *****************************************************************
FUNCTION XREAD(NL,A,ISTART,IEND,IEND2)
IMPLICIT REAL*8 (A-H,O-Z)
REAL*8 XREAD
CHARACTER*1 A(NL)
NINE=ICHAR('9')
IZERO=ICHAR('0')
MINUS=ICHAR('-')
IDOT=ICHAR('.')
ND=ICHAR('D')
NE=ICHAR('E')
IBL=ICHAR(' ')
IEND=0
IEND2=0
IDIG=0
C1=0
C2=0
ONE=1.D0
X = 1.D0
DO 10 J=ISTART,NL-1
N=ICHAR(A(J))
M=ICHAR(A(J+1))
IF(N.LE.NINE.AND.N.GE.IZERO .OR.N.EQ.IDOT)GOTO 20
IF(N.EQ.MINUS.AND.(M.LE.NINE.AND.M.GE.IZERO
1 .OR. M.EQ.IDOT)) GOTO 20
10 CONTINUE
XREAD=0.D0
RETURN
20 CONTINUE
IEND=J
DO 30 I=J,NL
N=ICHAR(A(I))
IF(N.LE.NINE.AND.N.GE.IZERO) THEN
IDIG=IDIG+1
IF (IDIG.GT.10) GOTO 60
C1=C1*10+N-IZERO
ELSEIF(N.EQ.MINUS.AND.I.EQ.J) THEN
ONE=-1.D0
ELSEIF(N.EQ.IDOT) THEN
GOTO 40
ELSE
GOTO 60
ENDIF
30 CONTINUE
40 CONTINUE
IDIG=0
DO 50 II=I+1,NL
N=ICHAR(A(II))
IF(N.LE.NINE.AND.N.GE.IZERO) THEN
IDIG=IDIG+1
IF (IDIG.GT.10) GOTO 60
C2=C2*10+N-IZERO
X = X /10
ELSEIF(N.EQ.MINUS.AND.II.EQ.I) THEN
X=-X
ELSE
GOTO 60
ENDIF
50 CONTINUE
C
C PUT THE PIECES TOGETHER
C
60 CONTINUE
XREAD= ONE * ( C1 + C2 * X)
DO 55 J=IEND,NL
N=ICHAR(A(J))
IEND2=J
IF(N.EQ.IBL)RETURN
55 IF(N.EQ.ND .OR. N.EQ.NE)GOTO 57
RETURN
57 C1=0.0D0
ONE=1.0D0
DO 31 I=J+1,NL
N=ICHAR(A(I))
IEND2=I
IF(N.EQ.IBL)GOTO 70
IF(N.LE.NINE.AND.N.GE.IZERO) C1=C1*10.0D0+N-IZERO
IF(N.EQ.MINUS)ONE=-1.0D0
31 CONTINUE
61 CONTINUE
70 XREAD=XREAD*10**(ONE*C1)
RETURN
END