-
Notifications
You must be signed in to change notification settings - Fork 3
/
readE.f90
457 lines (419 loc) · 18.1 KB
/
readE.f90
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
SUBROUTINE READE(CFLENAME,XTF,AEFF,NAMBIENT,WAVE,DPHYS,NAT0,NX,NY,NZ, &
CXE_INC,CXE_SCA,CXP)
USE DDPRECISION,ONLY: WP
IMPLICIT NONE
! arguments
CHARACTER*60 :: CFLENAME
INTEGER NAT0,NX,NY,NZ
REAL(WP) :: AEFF,DPHYS,NAMBIENT,WAVE
REAL(WP) :: &
XTF(3)
COMPLEX(WP) :: &
CXE_INC(3), &
CXE_SCA(3), &
CXP(3)
! local variables
LOGICAL :: INIT
CHARACTER*60 :: CFLENAME_OLD
INTEGER :: IDVOUT,IX1,IY1,IZ1, &
J,J1,J1X,J1Y,J1Z,J2,J2X,J2Y,J2Z,J3X,J3Y,J3Z,J4X,J4Y,J4Z, &
J5X,J5Y,J5Z,J6X,J6Y,J6Z,J7X,J7Y,J7Z,J8X,J8Y,J8Z,JX,JY,JZ, &
NAT3,NXY,NXYZ
INTEGER*2, &
ALLOCATABLE :: &
ICOMP(:)
REAL(WP) :: E2,EINC2,PI,SUMERR2,TINY,W1,W2,W3,W4,W5,W6,W7,W8,WX,WY,WZ, &
XMAX,XMIN,YMAX,YMIN,ZMAX,ZMIN
REAL(WP) :: X0(3)
COMPLEX(WP) :: CXERR
COMPLEX(WP), &
ALLOCATABLE :: &
CXADIA(:), &
CXPOL(:), &
CXEINC(:), &
CXESCA(:)
!=======================================================================
! subroutine READE
! given
! CFLENAME = name of file with precomputed E and P
! XTF(3) = (x_TF,y_TF,z_TF) = coordinates in Target Frame (phys. units)
! returns
! AEFF = effective radius of target (phys. units)
! NAMBIENT = (real) refractive index of ambient medium
! WAVE = wavelength in vacuo of incident wave (phys. units)
! DPHYS = interdipole separation (phys. units)
! NAT0 = number of dipoles in physical target
! NX,NY,NZ = dimensions/d of computational volume
! CXE_INC(1-3)= (complex) incident E field at location (x_TF,y_TF,z_TF)
! CXE_SCA(1-3)= (complex) scattered E field at location (x_TF,y_TF,z_TF)
! CXP(1-3) = (complex) polarization/d^3 at location (x_TF,y_TF,z_TF)
!
! B.T. Draine, Princeton Univ. Observatory, 2011.08.30
! history
! 11.08.29 (BTD) completed working version
! 11.08.31 (BTD) * added NAMBIENT to argument list
! * added NAMBIENT to READ statement
! * changed FORM='UNFORMATTED' to ACCESS='STREAM'
! end history
! Copyright (C) 2011
! B.T. Draine and P.J. Flatau
! This code is covered by the GNU General Public License.
!=======================================================================
DATA CFLENAME_OLD/'null'/
SAVE NXYZ
SAVE CFLENAME_OLD,NXY,PI,X0,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX
SAVE CXEINC,CXESCA,CXPOL
IDVOUT=0
!*** diagnostic
! write(idvout,*)'readE ckpt 0, x_TF(1-3)=',xtf
!***
IF(CFLENAME/=CFLENAME_OLD)THEN
PI=4._WP*ATAN(1._WP)
WRITE(IDVOUT,FMT='(A,A)')'>READE read file = ',CFLENAME
CFLENAME_OLD=CFLENAME
OPEN(UNIT=17,FILE=CFLENAME,ACCESS='STREAM')
READ(17)NXYZ,NAT0,NAT3,NX,NY,NZ,X0,AEFF,NAMBIENT,WAVE
DPHYS=AEFF*(4._WP*PI/(3._WP*NAT0))**(1._WP/3._WP)
NXY=NX*NY
XMIN=(X0(1)+1.-0.501)*DPHYS
XMAX=(X0(1)+NX+0.501)*DPHYS
YMIN=(X0(2)+1.-0.501)*DPHYS
YMAX=(X0(2)+NY+0.501)*DPHYS
ZMIN=(X0(3)+1.-0.501)*DPHYS
ZMAX=(X0(3)+NZ+0.501)*DPHYS
!*** diagnostic
! write(idvout,*)'readE ckpt 1'
! write(idvout,*)' nat0=',nat0
! write(idvout,*)' nxyz=',nxyz
! write(idvout,*)' nat3=',nat3
! write(idvout,*)' nx=',nx
! write(idvout,*)' ny=',ny
! write(idvout,*)' nz=',nz
! write(idvout,*)' x0=',x0
! write(idvout,*)' aeff=',aeff
! write(idvout,*)' wave=',wave
! write(idvout,*)'nambient=',nambient
!***
ALLOCATE(CXPOL(1:3*NXYZ))
ALLOCATE(CXEINC(1:3*NXYZ))
ALLOCATE(CXESCA(1:3*NXYZ))
!*** diagnostic
! write(idvout,*)'readE ckpt 2'
!***
READ(17)CXPOL,CXEINC,CXESCA
!*** diagnostic
! write(idvout,*)'readE ckpt 3'
!***
ALLOCATE(CXADIA(1:3*NXYZ))
ALLOCATE(ICOMP(1:3*NXYZ))
!*** diagnostic
! write(idvout,*)'readE ckpt 4'
!***
READ(17)CXADIA,ICOMP
!*** diagnostic
! write(idvout,*)'readE ckpt 5'
!***
CLOSE(17)
!*** diagnostic
! write(idvout,*)'readE ckpt 6: check CXPOL for NaN...'
! j2=0
! do j1=1,nat3
! if(.not.(abs(cxpol(j1))>=0.d0))then
! write(idvout,*)'j1=',j1,' cxpol(j1)=',cxpol(j1)
! j2=j2+1
! endif
! enddo
! write(idvout,*)'... CXPOL checked for NaN'
! write(idvout,*)' j2=',j2,' instances'
!***
!*** diagnostic
! write(idvout,*)'readE ckpt 7: check CXEINC for NaN...'
! j2=0
! do j1=1,nat3
! if(.not.(abs(cxeinc(j1))>=0.d0))then
! write(idvout,*)'j1=',j1,' cxeinc(j1)=',cxeinc(j1)
! j2=j2+1
! endif
! enddo
! write(idvout,*)'... CXEINC checked for NaN'
! write(idvout,*)' j2=',j2,' instances'
!***
!*** diagnostic
! write(idvout,*)'readE ckpt 8: check CXESCA for NaN...'
! j2=0
! do j1=1,nat3
! if(.not.(abs(cxesca(j1))>=0.d0))then
! write(idvout,*)'j1=',j1,' cxesca(j1)=',cxesca(j1)
! j2=j2+1
! endif
! enddo
! write(idvout,*)'... CXESCA checked for NaN'
! write(idvout,*)' j2=',j2,' instances'
!***
! check solution
EINC2=0.
DO J=0,2
EINC2=EINC2+CXEINC(1+J*NXYZ)*CONJG(CXEINC(1+J*NXYZ))
ENDDO
!*** diagnostic
! write(0,*)'readE ckpt 9 : EINC2=',EINC2
!***
SUMERR2=0.
J1=0
DO J=1,NAT3
IF(ICOMP(J)>0)THEN
CXERR=CXPOL(J)*CXADIA(J)-(CXEINC(J)+CXESCA(J))
SUMERR2=SUMERR2+CXERR*CONJG(CXERR)
J1=J1+1
!*** diagnostic
! IF(J1<=3)THEN
! WRITE(IDVOUT,*)'readE ckpt 10'
! WRITE(IDVOUT,*)'------------------------ j1 =',j1, &
! ' ---------------'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')CXEINC(J),CXEINC(J+NXYZ), &
! CXEINC(J+2*NXYZ),' = E_inc'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')CXESCA(J),CXESCA(J+NXYZ), &
! CXESCA(J+2*NXYZ),' = E_sca'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')(CXEINC(J)+CXESCA(J)), &
! (CXEINC(J+NXYZ)+CXESCA(J+NXYZ)), &
! (CXEINC(J+2*NXYZ)+CXESCA(J+2*NXYZ)), &
! ' = E'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')(CXADIA(J)*CXPOL(J)), &
! (CXADIA(J+NXYZ)*CXPOL(J+NXYZ)), &
! (CXADIA(J+2*NXYZ)*CXPOL(J+2*NXYZ)), &
! ' = A*P'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')CXPOL(J),CXPOL(J+NXYZ), &
! CXPOL(J+2*NXYZ),' = P'
! WRITE(IDVOUT,FMT='(1P6E11.3,A)')CXADIA(J),CXADIA(J+NXYZ), &
! CXADIA(J+2*NXYZ),' = A'
! ENDIF
!***
ENDIF
ENDDO
SUMERR2=SUMERR2/(REAL(NAT0)*EINC2)
WRITE(IDVOUT,FMT='(A,1PE11.4,A)')'>READE', &
SUMERR2,' = normalized error |P/alpha-E|^2/|E_inc|^2'
WRITE(IDVOUT,FMT='(A,1PE11.4,A)')'>READE',AEFF, &
' = AEFF (vol. equiv. radius, phys. units)'
WRITE(IDVOUT,FMT='(A,I11,A)')'>READE',NAT0, &
' = NAT0 (number of physical dipoles in target)'
WRITE(IDVOUT,FMT='(A,1PE11.4,A)')'>READE', &
DPHYS,' = d = interdipole separation (phys. units)'
WRITE(IDVOUT,FMT='(A,1PE11.4,A)')'>READE', &
WAVE,' = wavelength in vacuo (phys. units)'
WRITE(IDVOUT,FMT='(A,1PE11.4,A)')'>READE', &
WAVE/NAMBIENT,' = wavelength in ambient medium (phys. units)'
! write out the lattice site locations
! write(9,fmt='(1pe11.3,a)')dphys,' = dphys'
! do j=1,nx
! w1=(x0(1)+j)*dphys
! write(9,fmt='(i3,1pe11.3)')j,w1
! enddo
!***
ENDIF
!==============================================================================
! check that XTF(1-3) is within computational volume
!*** diagnostic
! write(idvout,*)'readE ckpt 11'
!***
IF(XTF(1).LT.XMIN)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: x_TF=', &
XTF(1),' < x_min=',XMIN,' STOP'
STOP
ENDIF
IF(XTF(1).GT.XMAX)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: x_TF=', &
XTF(1),' > x_max=',XMAX,' STOP'
STOP
ENDIF
IF(XTF(2).LT.YMIN)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: y_TF=', &
XTF(2),' < y_min=',YMIN,' STOP'
STOP
ENDIF
IF(XTF(2).GT.YMAX)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: y_TF=', &
XTF(2),' > y_max=',YMAX,' STOP'
STOP
ENDIF
IF(XTF(3).LT.ZMIN)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: z_TF=', &
XTF(3),' < z_min=',ZMIN,' STOP'
STOP
ENDIF
IF(XTF(3).GT.ZMAX)THEN
WRITE(IDVOUT,'(A,F8.4,A,F8.4,A)')'Fatal error in readE: z_TF=', &
XTF(3),' > z_max=',ZMAX,' STOP'
STOP
ENDIF
!*** diagnostic
! write(idvout,*)'readE ckpt 12'
!***
! XTF is assumed to be in physical units
! XTF/DPHYS is in dipole units
! I + X0 = XTF/DPHYS
! I = XTF/DPHYS - X0
IX1=INT(XTF(1)/DPHYS-X0(1))
IY1=INT(XTF(2)/DPHYS-X0(2))
IZ1=INT(XTF(3)/DPHYS-X0(3))
I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8i8)')'j1x-j8x=',j1x,j2x,j3x,j4x,j5x,j6x,j7x,j8x
! write(idvout,fmt='(a,8i8)')'j1y-j8y=',j1y,j2y,j3y,j4y,j5y,j6y,j7y,j8y
! write(idvout,fmt='(a,8i8)')'j1z-j8z=',j1z,j2z,j3z,j4z,j5z,j6z,j7z,j8z
! write(idvout,fmt='(a,8f8.4)')' w1-w8=',w1,w2,w3,w4,w5,w6,w7,w8
! write(idvout,*)' sum(w1-w8)=',(w1+w2+w3+w4+w5+w6+w7+w8)
! write(idvout,*)' nxyz=',nxyz
!
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1x=',j1x,' cxeinc(j1x)=',cxeinc(j1x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2x=',j2x,' cxeinc(j2x)=',cxeinc(j2x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3x=',j3x,' cxeinc(j3x)=',cxeinc(j3x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4x=',j4x,' cxeinc(j4x)=',cxeinc(j4x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5x=',j5x,' cxeinc(j5x)=',cxeinc(j5x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6x=',j6x,' cxeinc(j6x)=',cxeinc(j6x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j7x=',j7x,' cxeinc(j7x)=',cxeinc(j7x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j8x=',j8x,' cxeinc(j8x)=',cxeinc(j8x)
! write(idvout,*)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1y=',j1y,' cxeinc(j1y)=',cxeinc(j1y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2y=',j2y,' cxeinc(j2y)=',cxeinc(j2y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3y=',j3y,' cxeinc(j3y)=',cxeinc(j3y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4y=',j4y,' cxeinc(j4y)=',cxeinc(j4y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5y=',j5y,' cxeinc(j5y)=',cxeinc(j5y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6y=',j6y,' cxeinc(j6y)=',cxeinc(j6y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j7y=',j7y,' cxeinc(j7y)=',cxeinc(j7y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j8y=',j8y,' cxeinc(j8y)=',cxeinc(j8y)
! write(idvout,*)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1z=',j1z,' cxeinc(j1z)=',cxeinc(j1z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2z=',j2z,' cxeinc(j2z)=',cxeinc(j2z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3z=',j3z,' cxeinc(j3z)=',cxeinc(j3z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4z=',j4z,' cxeinc(j4z)=',cxeinc(j4z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5z=',j5z,' cxeinc(j5z)=',cxeinc(j5z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6z=',j6z,' cxeinc(j6z)=',cxeinc(j6z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j7z=',j7z,' cxeinc(j7z)=',cxeinc(j7z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j8z=',j8z,' cxeinc(j8z)=',cxeinc(j8z)
! write(idvout,*)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1x=',j1x,' cxesca(j1x)=',cxesca(j1x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2x=',j2x,' cxesca(j2x)=',cxesca(j2x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3x=',j3x,' cxesca(j3x)=',cxesca(j3x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4x=',j4x,' cxesca(j4x)=',cxesca(j4x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5x=',j5x,' cxesca(j5x)=',cxesca(j5x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6x=',j6x,' cxesca(j6x)=',cxesca(j6x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j7x=',j7x,' cxesca(j7x)=',cxesca(j7x)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j8x=',j8x,' cxesca(j8x)=',cxesca(j8x)
! write(idvout,*)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1y=',j1y,' cxesca(j1y)=',cxesca(j1y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2y=',j2y,' cxesca(j2y)=',cxesca(j2y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3y=',j3y,' cxesca(j3y)=',cxesca(j3y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4y=',j4y,' cxesca(j4y)=',cxesca(j4y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5y=',j5y,' cxesca(j5y)=',cxesca(j5y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6y=',j6y,' cxesca(j6y)=',cxesca(j6y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j7y=',j7y,' cxesca(j7y)=',cxesca(j7y)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j8y=',j8y,' cxesca(j8y)=',cxesca(j8y)
! write(idvout,*)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j1z=',j1z,' cxesca(j1z)=',cxesca(j1z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j2z=',j2z,' cxesca(j2z)=',cxesca(j2z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j3z=',j3z,' cxesca(j3z)=',cxesca(j3z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j4z=',j4z,' cxesca(j4z)=',cxesca(j4z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j5z=',j5z,' cxesca(j5z)=',cxesca(j5z)
! write(idvout,fmt='(a,i7,a,2f8.4)')' j6z=',j6z,' cxesca(j6z)=',cxesca(j6z)
! write(idvout,fmt='(a,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XPOL(J5X)+W6*CXPOL(J6X)+W7*CXPOL(J7X)+W8*CXPOL(J8X)
CXP(2)=W1*CXPOL(J1Y)+W2*CXPOL(J2Y)+W3*CXPOL(J3Y)+W4*CXPOL(J4Y)+ &
W5*CXPOL(J5Y)+W6*CXPOL(J6Y)+W7*CXPOL(J7Y)+W8*CXPOL(J8Y)
CXP(3)=W1*CXPOL(J1Z)+W2*CXPOL(J2Z)+W3*CXPOL(J3Z)+W4*CXPOL(J4Z)+ &
W5*CXPOL(J5Z)+W6*CXPOL(J6Z)+W7*CXPOL(J7Z)+W8*CXPOL(J8Z)
!*** diagnostic
! write(idvout,*)'readE ckpt 17'
! write(idvout,*)' cxe_inc(1)=',cxe_inc(1)
! write(idvout,*)' cxe_inc(2)=',cxe_inc(2)
! write(idvout,*)' cxe_inc(3)=',cxe_inc(3)
! w1=cxe_inc(1)*conjg(cxe_inc(1))+cxe_inc(2)*conjg(cxe_inc(2))+ &
! cxe_inc(3)*conjg(cxe_inc(3))
! write(idvout,*)' |cxe_inc|=',w1
! write(idvout,*)' cxe_sca(1)=',cxe_sca(1)
! write(idvout,*)' cxe_sca(2)=',cxe_sca(2)
! write(idvout,*)' cxe_sca(3)=',cxe_sca(3)
! write(idvout,*)' cxp(1)=',cxp(1)
! write(idvout,*)' cxp(2)=',cxp(2)
! write(idvout,*)' cxp(3)=',cxp(3)
!***
!*** diagnostic
! e2=(cxe_inc(1)+cxe_sca(1))*conjg(cxe_inc(1)+cxe_sca(1))+ &
! (cxe_inc(2)+cxe_sca(2))*conjg(cxe_inc(2)+cxe_sca(2))+ &
! (cxe_inc(3)+cxe_sca(3))*conjg(cxe_inc(3)+cxe_sca(3))
! write(10,fmt='(f7.4,3i3,8f7.3,f7.4)')xtf(1),ix1,iy1,iz1, &
! w1,w2,w3,w4,w5,w6,w7,w8,e2
!***
RETURN
END SUBROUTINE READE