forked from aarograh/EXACT-ISH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIO.f90
232 lines (203 loc) · 7.79 KB
/
IO.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
MODULE IO
USE sweeper
IMPLICIT NONE
PUBLIC :: processCmdLine
PUBLIC :: closeFiles
PUBLIC :: populateData
INTEGER,PARAMETER :: inpFileUnitNo=123
INTEGER,PARAMETER :: solFileUnitNo=124
INTEGER,PARAMETER :: outFileUnitNo=125
CONTAINS
!===============================================================================
SUBROUTINE processCmdLine()
! Local Variables
CHARACTER(LEN=16) :: arg_in
CALL GET_COMMAND_ARGUMENT(1,arg_in)
OPEN(FILE=TRIM(ADJUSTL(arg_in))//'.dump',UNIT=inpFileUnitNo)
OPEN(FILE=TRIM(ADJUSTL(arg_in))//'.sol',UNIT=solFileUnitNo)
OPEN(FILE=TRIM(ADJUSTL(arg_in))//'.out',UNIT=outFileUnitNo)
END SUBROUTINE processCmdLine
!===============================================================================
SUBROUTINE closeFiles()
CLOSE(UNIT=inpFileUnitNo)
CLOSE(UNIT=solFileUnitNo)
CLOSE(UNIT=outFileUnitNo)
END SUBROUTINE closeFiles
!===============================================================================
SUBROUTINE populateData(sweeper,psi)
CLASS(sweeperType),INTENT(INOUT) :: sweeper
DOUBLE PRECISION,POINTER,INTENT(INOUT) :: psi(:)
! Local variables
INTEGER :: i,ii,iii,n1,n2,n3,n4,n5
! Read number of groups and size of XS mesh
READ(123,*) n1,n2,n3
sweeper%ng=n3-n2+1
sweeper%igstt=n2
sweeper%igstp=n3
ALLOCATE(sweeper%myXSMesh(n1))
! Read XSMeshType data
sweeper%nxsreg = n1
DO i=1,n1
READ(123,*) sweeper%myXSMesh(i)%nreg
ALLOCATE(sweeper%myXSMesh(i)%ireg(sweeper%myXSMesh(i)%nreg))
READ(123,*) sweeper%myXSMesh(i)%ireg
ALLOCATE(sweeper%myXSMesh(i)%xsmactr(sweeper%ng))
READ(123,*) sweeper%myXSMesh(i)%xsmactr
READ(123,*) n2,n3
IF(n2 <= n3 .AND. (n3 - n2 < sweeper%ng)) THEN
ALLOCATE(sweeper%myXSMesh(i)%xsmacchi(sweeper%ng))
READ(123,*) sweeper%myXSMesh(i)%xsmacchi
ENDIF
ALLOCATE(sweeper%myXSMesh(i)%xsmacsc(sweeper%ng,0:0))
DO ii=1,sweeper%ng
READ(123,*) sweeper%myXSMesh(i)%xsmacsc(ii,0)%gmin
READ(123,*) sweeper%myXSMesh(i)%xsmacsc(ii,0)%gmax
ALLOCATE(sweeper%myXSMesh(i)%xsmacsc(ii,0)%from( &
sweeper%myXSMesh(i)%xsmacsc(ii,0)%gmin: &
sweeper%myXSMesh(i)%xsmacsc(ii,0)%gmax))
READ(123,*) sweeper%myXSMesh(i)%xsmacsc(ii,0)%from
ENDDO
ENDDO
! Read ModMeshType data
ALLOCATE(sweeper%myModMesh)
READ(123,*) sweeper%myModMesh%nmesh
ALLOCATE(sweeper%myModMesh%ifrstfsreg(sweeper%myModMesh%nmesh))
DO i=1,sweeper%myModMesh%nmesh
READ(123,*) sweeper%myModMesh%ifrstfsreg(i)
ENDDO
READ(123,*) n1,n2
ALLOCATE(sweeper%myModMesh%neigh(n1,n2))
READ(123,*) sweeper%myModMesh%neigh
! Read psi
READ(123,*) n1
ALLOCATE(psi(n1))
READ(123,*) psi
! Read ModMeshRayPtrArryType Data
READ(123,*) n1
ALLOCATE(sweeper%rtmesh(n1))
DO i=1,n1
READ(123,*) n2
ALLOCATE(sweeper%rtmesh(i)%rtdat)
ALLOCATE(sweeper%rtmesh(i)%rtdat%angles(n2))
DO ii=1,n2
READ(123,*) n3
ALLOCATE(sweeper%rtmesh(i)%rtdat%angles(ii)%rays(n3))
DO iii=1,n3
READ(123,*) sweeper%rtmesh(i)%rtdat%angles(ii)%rays(iii)%nseg
READ(123,*) n4
ALLOCATE(sweeper%rtmesh(i)%rtdat%angles(ii)%rays(iii)%ireg(n4))
READ(123,*) sweeper%rtmesh(i)%rtdat%angles(ii)%rays(iii)%ireg
READ(123,*) n4
ALLOCATE(sweeper%rtmesh(i)%rtdat%angles(ii)%rays(iii)%hseg(n4))
READ(123,*) sweeper%rtmesh(i)%rtdat%angles(ii)%rays(iii)%hseg
ENDDO
ENDDO
ENDDO
! Read CoreLongRays data
READ(123,*) n1
ALLOCATE(sweeper%longRayDat%nlongrays(n1))
ALLOCATE(sweeper%longRayDat%angles(n1))
DO i=1,n1
READ(123,*) sweeper%longRayDat%nlongrays(i)
ALLOCATE(sweeper%longRayDat%angles(i)%longrays( &
sweeper%longRayDat%nlongrays(i)))
DO ii=1,sweeper%longRayDat%nlongrays(i)
READ(123,*) sweeper%longRayDat%angles(i)%longrays(ii)%nmods
READ(123,*) sweeper%longRayDat%angles(i)%longrays(ii)%ifirstModMesh
READ(123,*) sweeper%longRayDat%angles(i)%longrays(ii)%iside
READ(123,*) sweeper%longRayDat%angles(i)%longrays(ii)%firstModRay
READ(123,*) sweeper%longRayDat%angles(i)%longrays(ii)%BCIndex
ENDDO
ENDDO
! Read ModularRayType data
ALLOCATE(sweeper%modRayDat)
READ(123,*) sweeper%modRayDat%iangstt,sweeper%modRayDat%iangstp
n1=sweeper%modRayDat%iangstp-sweeper%modRayDat%iangstt+1
ALLOCATE(sweeper%modRayDat%angles(n1))
DO i=1,n1
READ(123,*) sweeper%modRayDat%angles(i)%dlr
READ(123,*) n2
sweeper%modRayDat%angles(i)%nmodrays=n2
ALLOCATE(sweeper%modRayDat%angles(i)%rays(n2))
DO ii=1,n2
READ(123,*) sweeper%modRayDat%angles(i)%rays(ii)%nextray
READ(123,*) sweeper%modRayDat%angles(i)%rays(ii)%nextsurf
ENDDO
ENDDO
! Read Quadrature information
READ(123,*) sweeper%modRayDat%angquad%npol
READ(123,*) sweeper%modRayDat%angquad%nazi
READ(123,*) n1
ALLOCATE(sweeper%modRayDat%angquad%walpha(n1))
READ(123,*) sweeper%modRayDat%angquad%walpha
READ(123,*) n1
ALLOCATE(sweeper%modRayDat%angquad%wtheta(n1))
READ(123,*) sweeper%modRayDat%angquad%wtheta
READ(123,*) n1
ALLOCATE(sweeper%modRayDat%angquad%sinpolang(n1))
READ(123,*) sweeper%modRayDat%angquad%sinpolang
ALLOCATE(sweeper%modRayDat%angquad%rsinpolang(n1))
READ(123,*) sweeper%modRayDat%angquad%rsinpolang
! Read pz data
READ(123,*) sweeper%pz
! Read Exponential Tables data
ALLOCATE(sweeper%expTableDat)
READ(123,*) n1
READ(123,*) n2
ALLOCATE(sweeper%expTableDat%table2D(1:2,n1:n2))
READ(123,*) sweeper%expTableDat%table2D
READ(123,*) sweeper%expTableDat%rdx
! Read AngFluxBC data
READ(123,*) n1
ALLOCATE(sweeper%phiang(n1))
DO i=1,n1
READ(123,*) n2
ALLOCATE(sweeper%phiang(i)%angle(n2))
IF(i == 1) ALLOCATE(sweeper%phiang1g_out%angle(n2))
DO ii=1,n2
READ(123,*) n3
ALLOCATE(sweeper%phiang(i)%angle(ii)%face(n3))
IF(i == 1) ALLOCATE(sweeper%phiang1g_out%angle(ii)%face(n3))
DO iii=1,n3
READ(123,*) n4,n5
ALLOCATE(sweeper%phiang(i)%angle(ii)%face(iii)%angFlux(n4,0:n5-1))
READ(123,*) sweeper%phiang(i)%angle(ii)%face(iii)%angFlux
IF(i == 1) &
ALLOCATE(sweeper%phiang1g_out%angle(ii)%face(iii)%angFlux(n4,n5))
ENDDO
ENDDO
ENDDO
! Read in initial phis
READ(123,*) n1,n2
sweeper%nreg = n1
ALLOCATE(sweeper%phis(n1,n2))
READ(123,*) sweeper%phis
! Miscellaneous
READ(123,*) sweeper%maxsegray
READ(123,*) sweeper%myModMesh%nmesh,sweeper%imeshstt
ALLOCATE(sweeper%vol(sweeper%nreg))
READ(123,*) sweeper%vol
END SUBROUTINE populateData
!===============================================================================
SUBROUTINE validate(sweeper)
CLASS(sweeperType),INTENT(IN) :: sweeper
! Local Variables
INTEGER :: nreg,ngroups,ireg,ig
DOUBLE PRECISION :: compval,diff,maxdiff,rmsdiff
READ(124,*) nreg,ngroups
maxdiff = 0.0D0
rmsdiff = 0.0D0
DO ig=1,ngroups
DO ireg=1,nreg
READ(124,*) compval
diff = (sweeper%phis(ireg,ig) - compval)/compval
maxdiff = MAX(maxdiff,ABS(diff))
rmsdiff = rmsdiff + diff*diff
ENDDO !ireg
ENDDO !ig
rmsdiff = SQRT(rmsdiff)
WRITE(*,*)
WRITE(*,*) 'RMS Difference = ',rmsdiff
WRITE(*,*) 'Max Difference = ',maxdiff
END SUBROUTINE validate
END MODULE IO