-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEMC2.f95
303 lines (271 loc) · 6.59 KB
/
EMC2.f95
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
!--- START PROGRAM FORTRAN : EMC---
PROGRAM EMC
!---Build the required variables---
REAL,ALLOCATABLE,DIMENSION(:)::NUMBER_TOTAL
CHARACTER(LEN=10),DIMENSION(5)::READINFOPLOT
INTEGER ::FF=0 ,MM ,FLAG4,FLAG5
INTEGER ::CONTER1=0,CONTER2=0,CR1=1,CR2=1
REAL(kind=3)::NUMBERBAND,NUMBERINFOBAND
CHARACTER(LEN=129)::CH1,CH2
REAL,ALLOCATABLE,DIMENSION(:)::SIZE_PLUS,SIZE_MINEZ
REAL,ALLOCATABLE,DIMENSION(:)::SIZE_LINE_PLUS,SIZE_LINE_MINEZ
REAL::MAX_MINEZ,MIN_PLUS,R_MIN_PLUS,R_MAX_MINEZ
REAL::R_NUMBER_TOTALS,KLS
REAL ::MAX,MAX2
INTEGER ::CONTER_TOTAL
INTEGER ::COLUMN_MINEZ_MAX,COLUMN_PLUS_MIN
INTEGER ::START_PLUS_MIN, START_MINEZ_MAX
INTEGER ::MMM
INTEGER ::COOL
REAL,ALLOCATABLE,DIMENSION(:)::CHART_FINAL_PLUS
REAL,ALLOCATABLE,DIMENSION(:)::CHART_FINAL_MINEZ
REAL,ALLOCATABLE,DIMENSION(:)::CHART_CHANGE_ENERGY
!--- Select file path for processing. ---
!--- This is the output file of the device. ---
!--- The file format is .txt ---
!--- This file contains millions of data. ---
Open(Unit=1,File="_SRC_",Action="Read",Status="Old")
READ(1,*) READINFOPLOT
CH1 = READINFOPLOT(3)
CH2 = READINFOPLOT(5)
READ(CH1,*) NUMBERBAND
READ(CH2,*) NUMBERINFOBAND
ALLOCATE (NUMBER_TOTAL(NUMBERBAND*NUMBERINFOBAND+3*NUMBERINFOBAND))
ALLOCATE (CHART_FINAL_PLUS(NUMBERINFOBAND))
ALLOCATE (CHART_FINAL_MINEZ(NUMBERINFOBAND))
READ(1,*) NUMBER_TOTAL
!--- Determine the zero border point and check the crossing. ---
DO LINE=4 , NUMBERBAND + 3
KL = LINE ! 4
IF (NUMBER_TOTAL(KL)<0)THEN
FLAG2=1
ELSE
FLAG2=0
END IF
DO I=1 , NUMBERINFOBAND
IF (NUMBER_TOTAL(KL)<0)THEN
FLAG3=1
ELSE
FLAG3=0
END IF
IF (FLAG2==FLAG3)THEN
CONTINUE
ELSE
FF = 1
GOTO 2001
END IF
KL = KL + NUMBERBAND + 3
END DO
END DO
!--- CODE SYSTEM 1. ---
2001 IF (FF==1)THEN
DO I = 4 , NUMBERBAND + 3
CONTER2=0
M = I
KLS = NUMBER_TOTAL(M)
IF (KLS<0)THEN
FLAG4=0
ELSE
FLAG4=1
END IF
DO J=1 , NUMBERINFOBAND
KLS = NUMBER_TOTAL(M)
IF(KLS<0)THEN
FLAG5=1
ELSE
FLAG5=0
END IF
IF (FLAG4==FLAG5 .AND. CONTER2==0)THEN
CONTER1= CONTER1 + 1
CONTER2= 1
END IF
M = M + NUMBERBAND + 3
END DO
END DO
CONTER_TOTAL = CONTER1
ALLOCATE (CHART_CHANGE_ENERGY(CONTER1*(NUMBERINFOBAND+1)))
CONTER1 = 0
KL=1
DO I = 4 , NUMBERBAND + 3
CONTER2=0
M = I
KLS = NUMBER_TOTAL(M)
IF (KLS<0)THEN
FLAG4=0
ELSE
FLAG4=1
END IF
DO J=1 , NUMBERINFOBAND
KLS = NUMBER_TOTAL(M)
IF(KLS<0)THEN
FLAG5=1
ELSE
FLAG5=0
END IF
IF (FLAG4==FLAG5 .AND. CONTER2==0)THEN
CHART_CHANGE_ENERGY(KL)=I
KL = KL + NUMBERINFOBAND + 1
CONTER2= 1
END IF
M = M + NUMBERBAND + 3
END DO
END DO
CONTER1=0
M=1
MMM=1
DO I = 1 , CONTER_TOTAL
KLS =CHART_CHANGE_ENERGY(M)
KL = KLS
DO J=1 , NUMBERINFOBAND
CHART_CHANGE_ENERGY(MMM+1)=NUMBER_TOTAL(KL)
MMM=MMM+1
KL = KL + NUMBERBAND + 3
END DO
M = M + NUMBERINFOBAND + 1
MMM = M
END DO
! ---MAXIMUM CHART_CHANGE_ENERGY ---
M = 2
MAX = CHART_CHANGE_ENERGY(2)
DO J = 1 , CONTER_TOTAL
DO I = 1 , NUMBERINFOBAND
MAX2=CHART_CHANGE_ENERGY(M)
IF (MAX<MAX2)THEN
MAX = MAX2
CONTER1=J
END IF
M = M +1
END DO
M = M + 1
END DO
! ---EXPORT Capacity bar---
COOL = (CONTER1-1)*(NUMBERINFOBAND+1)+1
Open(Unit=3,File="D:\NAVARE_ZARFIAT.TXT",Action="WRITE",Status="NEW")
DO I=1 , NUMBERINFOBAND
WRITE(3,*)CHART_CHANGE_ENERGY(COOL)
WRITE(3,*)
COOL = COOL + 1
END DO
Open(Unit=4,File="D:\NAVARE_DIGAR.TXT",Action="WRITE",Status="NEW")
M = 2
MAX = CHART_CHANGE_ENERGY(2)
DO J = 1 , CONTER_TOTAL
DO I = 1 , NUMBERINFOBAND
MAX2=CHART_CHANGE_ENERGY(M)
WRITE(4,*)MAX2
M = M +1
END DO
M = M + 1
END DO
!--- CODE SYSTEM 0. ---
ELSE IF(FF==0)THEN
DO I=4 , NUMBERBAND + 3
IF (NUMBER_TOTAL(I)<0)THEN
CONTER1 = CONTER1 + 1
ELSE
CONTER2 = CONTER2 + 1
END IF
END DO
ALLOCATE (SIZE_PLUS(CONTER2 * NUMBERINFOBAND))
ALLOCATE (SIZE_MINEZ(CONTER1 * NUMBERINFOBAND))
ALLOCATE (SIZE_LINE_PLUS(CONTER2))
ALLOCATE (SIZE_LINE_MINEZ(CONTER1))
DO I=4 , NUMBERBAND + 3
IF (NUMBER_TOTAL(I)<0)THEN
SIZE_LINE_MINEZ(CR1)=I
CR1 = CR1 + 1
ELSE
SIZE_LINE_PLUS(CR2)=I
CR2 = CR2 + 1
END IF
END DO
MM = 1
IJ=1
DO J=1 , SIZE(SIZE_LINE_MINEZ)
KL = SIZE_LINE_MINEZ(MM)
DO I=1 , NUMBERINFOBAND
SIZE_MINEZ(IJ)=NUMBER_TOTAL(KL)
KL = KL + NUMBERBAND + 3
IJ=IJ+1
END DO
MM = MM + 1
END DO
MM = 1
IJ=1
DO J=1 , SIZE(SIZE_LINE_PLUS)
KL = SIZE_LINE_PLUS(MM)
DO I=1 , NUMBERINFOBAND
SIZE_PLUS(IJ)=NUMBER_TOTAL(KL)
KL = KL + NUMBERBAND + 3
IJ=IJ+1
END DO
MM = MM + 1
END DO
MAX_MINEZ = SIZE_MINEZ(1)
DO I=1 ,SIZE(SIZE_MINEZ)
R_MAX_MINEZ = SIZE_MINEZ(I)
IF ((R_MAX_MINEZ > MAX_MINEZ) .OR. (R_MAX_MINEZ == MAX_MINEZ))THEN
MAX_MINEZ = R_MAX_MINEZ
! ---ROW_MINEZ=I---
END IF
END DO
MIN_PLUS = SIZE_PLUS(1)
DO I=1 ,SIZE(SIZE_PLUS)
R_MIN_PLUS = SIZE_PLUS(I)
IF (R_MIN_PLUS < MIN_PLUS .OR. R_MIN_PLUS == MIN_PLUS)THEN
MIN_PLUS = R_MIN_PLUS
! ---ROW_PLUS = I---
END IF
END DO
! ---FOR BAND MINEZ---
M=4
DO I=1 , NUMBERINFOBAND
DO J=1 , NUMBERBAND
R_NUMBER_TOTAL = NUMBER_TOTAL(M)
IF (MAX_MINEZ== R_NUMBER_TOTAL)THEN
C_I1 = I
END IF
M = M + 1
END DO
M = M + 3
END DO
DO I=1 , SIZE(NUMBER_TOTAL)
R_NUMBER_TOTAL = NUMBER_TOTAL(I)
IF (MAX_MINEZ== R_NUMBER_TOTAL)THEN
C_I2 = I
END IF
END DO
COLUMN_MINEZ_MAX = C_I2 - ((C_I1-1)*(NUMBERBAND+3))
! ---FOR BAND PLUS---
M=4
DO I=1 , NUMBERINFOBAND
DO J=1 , NUMBERBAND
R_NUMBER_TOTAL = NUMBER_TOTAL(M)
IF (MIN_PLUS== R_NUMBER_TOTAL)THEN
C_I1 = I
END IF
M = M + 1
END DO
M = M + 3
END DO
DO I=1 , SIZE(NUMBER_TOTAL)
R_NUMBER_TOTAL = NUMBER_TOTAL(I)
IF (MIN_PLUS== R_NUMBER_TOTAL)THEN
C_I2 = I
END IF
END DO
COLUMN_PLUS_MIN = C_I2 - ((C_I1-1)*(NUMBERBAND+3))
! ---START_PLUS_MIN, START_MINEZ_MAX ---
START_PLUS_MIN = COLUMN_PLUS_MIN
DO I=1, NUMBERINFOBAND
CHART_FINAL_PLUS(I)=NUMBER_TOTAL(START_PLUS_MIN)
START_PLUS_MIN = START_PLUS_MIN + NUMBERBAND + 3
END DO
START_MINEZ_MAX = COLUMN_MINEZ_MAX
DO I=1, NUMBERINFOBAND
CHART_FINAL_MINEZ(I)=NUMBER_TOTAL(START_MINEZ_MAX)
START_MINEZ_MAX = START_MINEZ_MAX + NUMBERBAND + 3
END DO
END IF
!****************************************************************************************
END PROGRAM EMC