1 | include(dom.inc)
2 |
3 | PROGRAM inconvert
4 |
5 | ! ==================================================================!
6 | ! !
7 | ! convertion.F : Convert PRISSMA's input files !
8 | ! from bin to ascii and from ascii to bin !
9 | ! !
10 | ! author : D. POITOU (april 2008) !
11 | ! !
12 | ! ==================================================================!
13 |
14 | IMPLICIT NONE
15 |
16 | include 'dom_constants.h'
17 |
18 | DOM_INT, PARAMETER :: FILE_NODES2 = 200
19 | DOM_INT, PARAMETER :: FILE_CELLS2 = 201
20 | DOM_INT, PARAMETER :: FILE_FACES2 = 202
21 | DOM_INT, PARAMETER :: FILE_C2C2 = 203
22 | DOM_INT, PARAMETER :: FILE_CCELL2 = 204
23 | DOM_INT, PARAMETER :: FILE_CFACE2 = 205
24 | DOM_INT, PARAMETER :: FILE_NORM2 = 207
25 | DOM_INT, PARAMETER :: FILE_VOLA2 = 208
26 | DOM_INT, PARAMETER :: FILE_EMI2 = 209
27 | DOM_INT, PARAMETER :: FILE_KSCA2 = 210
28 | DOM_INT, PARAMETER :: FILE_QUADR2 = 212
29 | DOM_INT, PARAMETER :: FILE_CLPRO2 = 213
30 | DOM_INT, PARAMETER :: FILE_CLFAC2 = 214
31 | DOM_INT, PARAMETER :: FILE_PROG2 = 215
32 | DOM_INT, PARAMETER :: FILE_C2FAC2 = 224
33 | DOM_INT, PARAMETER :: FILE_GDATA2 = 228
34 | DOM_INT, PARAMETER :: FILE_PROP2 = 229
35 |
36 | CHARACTER*80 :: path1,path2
37 | CHARACTER*80 :: gdatafile,gdatafile2
38 | CHARACTER*80 :: c2cfile,c2cfile2
39 | CHARACTER*80 :: ccellfile,ccellfile2
40 | CHARACTER*80 :: cfacefile,cfacefile2
41 | CHARACTER*80 :: propfile,propfile2
42 | CHARACTER*80 :: normfile,normfile2
43 | CHARACTER*80 :: volafile,volafile2
44 | CHARACTER*80 :: emisfile,emisfile2
45 | CHARACTER*80 :: kscafile,kscafile2
46 | CHARACTER*80 :: extrnfile,extrnfile2
47 | CHARACTER*80 :: quadrfile,quadrfile2
48 | CHARACTER*80 :: c2facfile,c2facfile2
49 | CHARACTER*80 :: progfile,progfile2
50 | CHARACTER*80 :: nodesfile,nodesfile2
51 | CHARACTER*80 :: facesfile,facesfile2
52 | CHARACTER*80 :: cellsfile,cellsfile2
53 | CHARACTER*80 :: clprofile,clprofile2
54 | CHARACTER*80 :: clfacfile,clfacfile2
55 |
56 |
57 | DOM_INT :: ntcells, ntnodes, ntfaces,ntfacesmax,ndirs
58 | DOM_INT :: icell,i,j,k,l,m,convtype,nfaces,cellnodes
59 | DOM_INT :: fnnodes,nbfaces,datas
60 |
61 | DOM_REAL :: Th,Ph,Kh
62 | DOM_REAL :: xc,yc,zc,a,b,c
63 | DOM_REAL, DIMENSION(8) :: celldata
64 | DOM_REAL :: VOL,k_scat,kabs_gray
65 | DOM_REAL :: mu,eta,ksi,omega
66 | DOM_INT, DIMENSION(10) :: inode
67 |
68 | DOM_INT, ALLOCATABLE, DIMENSION(:,:) :: neighb
69 | DOM_REAL, ALLOCATABLE, DIMENSION(:) :: x,y,z,surf,epsil,tem
70 | DOM_INT, ALLOCATABLE, DIMENSION(:) :: iface,patch,prog
71 |
72 | ! ------------------!
73 | ! Read choices file !
74 | ! ------------------!
75 |
76 | OPEN (FILE_CHCS , FILE='inconvert.choices', FORM='FORMATTED')
77 | READ (FILE_CHCS,*) path1 ! Path for infiles *.in
78 | READ (FILE_CHCS,*) path2 ! Path for acsii infiles *.txt
79 | READ (FILE_CHCS,*) convtype ! Choice for the convertion type
80 | CLOSE(FILE_CHCS)
81 |
82 | ! ---------------!
83 | ! Set file names !
84 | ! ---------------!
85 |
86 | gdatafile = path1(1:len_trim(path1))//'/Global.in'
87 | gdatafile2 = path2(1:len_trim(path2))//'/Global.txt'
88 | c2cfile = path1(1:len_trim(path1))//'/Cell2cells.in'
89 | c2cfile2 = path2(1:len_trim(path2))//'/Cell2cells.txt'
90 | ccellfile = path1(1:len_trim(path1))//'/Centercells.in'
91 | ccellfile2 = path2(1:len_trim(path2))//'/Centercells.txt'
92 | cfacefile = path1(1:len_trim(path1))//'/Centerfaces.in'
93 | cfacefile2 = path2(1:len_trim(path2))//'/Centerfaces.txt'
94 | propfile = path1(1:len_trim(path1))//'/Properties.in'
95 | propfile2 = path2(1:len_trim(path2))//'/Properties.txt'
96 | normfile = path1(1:len_trim(path1))//'/Normals.in'
97 | normfile2 = path2(1:len_trim(path2))//'/Normals.txt'
98 | volafile = path1(1:len_trim(path1))//'/Volumesareas.in'
99 | volafile2 = path2(1:len_trim(path2))//'/Volumesareas.txt'
100 | emisfile = path1(1:len_trim(path1))//'/Emissivities.in'
101 | emisfile2 = path2(1:len_trim(path2))//'/Emissivities.txt'
102 | kscafile = path1(1:len_trim(path1))//'/K_Extinction.in'
103 | kscafile2 = path2(1:len_trim(path2))//'/K_Extinction.txt'
104 | extrnfile = path1(1:len_trim(path1))//'/Externaldata.in'
105 | extrnfile2 = path2(1:len_trim(path2))//'/Externaldata.txt'
106 | quadrfile = path1(1:len_trim(path1))//'/Quadrature.in'
107 | quadrfile2 = path2(1:len_trim(path2))//'/Quadrature.txt'
108 | c2facfile = path1(1:len_trim(path1))//'/Cell2faces.in'
109 | c2facfile2 = path2(1:len_trim(path2))//'/Cell2faces.txt'
110 | progfile = path1(1:len_trim(path1))//'/Progress.in'
111 | progfile2 = path2(1:len_trim(path2))//'/Progress.txt'
112 | nodesfile = path1(1:len_trim(path1))//'/Nodelist.in'
113 | nodesfile2 = path2(1:len_trim(path2))//'/Nodelist.txt'
114 | facesfile = path1(1:len_trim(path1))//'/Facelist.in'
115 | facesfile2 = path2(1:len_trim(path2))//'/Facelist.txt'
116 | cellsfile = path1(1:len_trim(path1))//'/Cellnodes.in'
117 | cellsfile2 = path2(1:len_trim(path2))//'/Cellnodes.txt'
118 | clprofile = path1(1:len_trim(path1))//'/CLProperties.in'
119 | clprofile2 = path2(1:len_trim(path2))//'/CLProperties.txt'
120 | clfacfile = path1(1:len_trim(path1))//'/CLFaces.in'
121 | clfacfile2 = path2(1:len_trim(path2))//'/CLFaces.txt'
122 |
123 | ! ------------------------------------!
124 | ! Open binary/ascii Global data files !
125 | ! ------------------------------------!
126 |
127 | OPEN(FILE_GDATA, FILE=gdatafile , FORM='UNFORMATTED')
128 | OPEN(FILE_GDAT2, FILE=gdatafile2, FORM='FORMATTED')
129 |
130 | ! ------------------------!
131 | ! Open binary input files !
132 | ! ------------------------!
133 |
134 | OPEN(FILE_C2C, FILE=c2cfile, FORM='unformatted')
135 | OPEN(FILE_CCELL, FILE=ccellfile, FORM='unformatted')
136 | OPEN(FILE_CFACE, FILE=cfacefile, FORM='unformatted')
137 | OPEN(FILE_PROP, FILE=propfile, FORM='unformatted')
138 | OPEN(FILE_NORM, FILE=normfile, FORM='unformatted')
139 | OPEN(FILE_VOLA, FILE=volafile, FORM='unformatted')
140 | OPEN(FILE_EMIS, FILE=emisfile, FORM='unformatted')
141 | OPEN(FILE_KSCA, FILE=kscafile, FORM='unformatted')
142 | OPEN(FILE_QUADR, FILE=quadrfile, FORM='unformatted')
143 | OPEN(FILE_C2FAC, FILE=c2facfile, FORM='unformatted')
144 | OPEN(FILE_PROG, FILE=progfile, FORM='unformatted')
145 | OPEN(FILE_NODES, FILE=nodesfile, FORM='unformatted')
146 | OPEN(FILE_FACES, FILE=facesfile, FORM='unformatted')
147 | OPEN(FILE_CELLS, FILE=cellsfile, FORM='unformatted')
148 | OPEN(FILE_CLPRO, FILE=clprofile, FORM='unformatted')
149 | OPEN(FILE_CLFAC, FILE=clfacfile, FORM='unformatted')
150 |
151 | ! ------------------------!
152 | ! Open ascii input files !
153 | ! ------------------------!
154 |
155 | OPEN(FILE_C2C2, FILE=c2cfile2, FORM='formatted')
156 | OPEN(FILE_CCELL2, FILE=ccellfile2, FORM='formatted')
157 | OPEN(FILE_CFACE2, FILE=cfacefile2, FORM='formatted')
158 | OPEN(FILE_PROP2, FILE=propfile2, FORM='formatted')
159 | OPEN(FILE_NORM2, FILE=normfile2, FORM='formatted')
160 | OPEN(FILE_VOLA2, FILE=volafile2, FORM='formatted')
161 | OPEN(FILE_EMI2, FILE=emisfile2, FORM='formatted')
162 | OPEN(FILE_KSCA2, FILE=kscafile2, FORM='formatted')
163 | OPEN(FILE_QUADR2, FILE=quadrfile2, FORM='formatted')
164 | OPEN(FILE_C2FAC2, FILE=c2facfile2, FORM='formatted')
165 | OPEN(FILE_PROG2, FILE=progfile2, FORM='formatted')
166 | OPEN(FILE_NODES2, FILE=nodesfile2, FORM='formatted')
167 | OPEN(FILE_FACES2, FILE=facesfile2, FORM='formatted')
168 | OPEN(FILE_CELLS2, FILE=cellsfile2, FORM='formatted')
169 | OPEN(FILE_CLPRO2, FILE=clprofile2, FORM='formatted')
170 | OPEN(FILE_CLFAC2, FILE=clfacfile2, FORM='formatted')
171 |
172 |
173 | ! ----------------------!
174 | ! Transform Global data !
175 | ! ----------------------!
176 |
177 | IF (convtype.eq.1) THEN
178 |
179 | READ(FILE_GDATA) ntcells, ntnodes, ntfaces,ntfacesmax, &
180 | & ndirs
181 | WRITE(FILE_GDAT2,*) ntcells, ntnodes, ntfaces,ntfacesmax, &
182 | & ndirs
183 |
184 | ELSEIF (convtype.eq.2) THEN
185 |
186 | READ(FILE_GDAT2,*) ntcells, ntnodes, ntfaces,ntfacesmax, &
187 | & ndirs
188 | WRITE(FILE_GDATA) ntcells, ntnodes, ntfaces,ntfacesmax, &
189 | & ndirs
190 |
191 |
192 | ENDIF
193 |
194 | CLOSE(FILE_GDATA)
195 | CLOSE(FILE_GDAT2)
196 |
197 | ! -----------------!
198 | ! Allocate vectors !
199 | ! -----------------!
200 |
201 | ALLOCATE(neighb(2,ntfacesmax))
202 | ALLOCATE(x(ntfacesmax))
203 | ALLOCATE(y(ntfacesmax))
204 | ALLOCATE(z(ntfacesmax))
205 | ALLOCATE(surf(ntfacesmax))
206 | ALLOCATE(epsil(ntfacesmax))
207 | ALLOCATE(iface(ntfacesmax))
208 | ALLOCATE(tem(ntfacesmax))
209 | ALLOCATE(patch(ntfacesmax))
210 | ALLOCATE(prog(ntcells))
211 |
212 | ! ----------------------!
213 | ! Transform output data !
214 | ! ----------------------!
215 |
216 | IF (convtype.eq.1) THEN
217 |
218 | DO j=1,ntnodes
219 | READ(FILE_PROP) i,(celldata(l),l=1,8)
220 | WRITE(FILE_PROP2,*) i,(celldata(l),l=1,8)
221 |
222 | READ(FILE_KSCA) i,kabs_gray,k_scat
223 | WRITE(FILE_KSCA2,*) i,kabs_gray,k_scat
224 |
225 | ENDDO
226 |
227 | DO icell=1,ntcells
228 |
229 | READ(FILE_C2C ) i,nfaces, &
230 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
231 | WRITE(FILE_C2C2,*) i,nfaces, &
232 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
233 |
234 | READ(FILE_CCELL) i,xc,yc,zc
235 | WRITE(FILE_CCELL2,*) i,xc,yc,zc
236 |
237 | READ(FILE_CFACE) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
238 | WRITE(FILE_CFACE2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
239 |
240 | READ(FILE_NORM) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
241 | WRITE(FILE_NORM2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
242 |
243 | READ(FILE_VOLA) i,nfaces,VOL,(surf(l),l=1,nfaces)
244 | WRITE(FILE_VOLA2,*) i,nfaces,VOL,(surf(l),l=1,nfaces)
245 |
246 | READ(FILE_EMIS) i,nfaces,(epsil(l),l=1,nfaces)
247 | WRITE(FILE_EMI2,*) i,nfaces,(epsil(l),l=1,nfaces)
248 |
249 | READ(FILE_C2FAC) i,nfaces,(iface(l),l=1,nfaces)
250 | WRITE(FILE_C2FAC2,*) i,nfaces,(iface(l),l=1,nfaces)
251 |
252 | READ(FILE_CELLS) i,cellnodes,(inode(l),l=1,cellnodes)
253 | WRITE(FILE_CELLS2,*) i,cellnodes,(inode(l),l=1,cellnodes)
254 |
255 | READ(FILE_CLPRO) i,nfaces,(tem(l),patch(l),l=1,nfaces)
256 | WRITE(FILE_CLPRO2,*) i,nfaces,(tem(l),patch(l),l=1,nfaces)
257 |
258 | ENDDO
259 |
260 | DO j=1,ndirs
261 |
262 | READ(FILE_QUADR) mu,eta,ksi,omega
263 | WRITE(FILE_QUADR2,*) mu,eta,ksi,omega
264 |
265 | READ(FILE_PROG) (prog(l),l=1,ntcells)
266 | WRITE(FILE_PROG2,*) (prog(l),l=1,ntcells)
267 |
268 | ENDDO
269 |
270 | DO k=1,ntnodes
271 |
272 | READ(FILE_NODES) i,a,b,c
273 | WRITE(FILE_NODES2,*) i,a,b,c
274 |
275 | ENDDO
276 |
277 | DO m=1,ntfaces
278 |
279 | READ(FILE_FACES) i,fnnodes,(inode(l),l=1,fnnodes)
280 | WRITE(FILE_FACES2,*) i,fnnodes,(inode(l),l=1,fnnodes)
281 |
282 | ENDDO
283 |
284 | READ(FILE_CLFAC) nbfaces
285 | WRITE(FILE_CLFAC2,*) nbfaces
286 |
287 | print*,'Conversion bin2ascii done!'
288 |
289 | ELSEIF (convtype.eq.2) THEN
290 |
291 | DO j=1,ntnodes
292 | READ(FILE_PROP2,*) i,(celldata(l),l=1,8)
293 | WRITE(FILE_PROP) i,(celldata(l),l=1,8)
294 |
295 | READ(FILE_KSCA2,*) i,kabs_gray,k_scat
296 | WRITE(FILE_KSCA) i,kabs_gray,k_scat
297 |
298 | ENDDO
299 |
300 |
301 | DO icell=1,ntcells
302 |
303 | READ(FILE_C2C2,*) i,nfaces, &
304 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
305 | WRITE(FILE_C2C) i,nfaces, &
306 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
307 |
308 | READ(FILE_CCELL2,*) i,xc,yc,zc
309 | WRITE(FILE_CCELL) i,xc,yc,zc
310 |
311 | READ(FILE_CFACE2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
312 | WRITE(FILE_CFACE) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
313 |
314 | READ(FILE_NORM2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
315 | WRITE(FILE_NORM) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
316 |
317 | READ(FILE_VOLA2,*) i,nfaces,VOL,(surf(l),l=1,nfaces)
318 | WRITE(FILE_VOLA) i,nfaces,VOL,(surf(l),l=1,nfaces)
319 |
320 | READ(FILE_EMI2,*) i,nfaces,(epsil(l),l=1,nfaces)
321 | WRITE(FILE_EMIS) i,nfaces,(epsil(l),l=1,nfaces)
322 |
323 | READ(FILE_C2FAC2,*) i,nfaces,(iface(l),l=1,nfaces)
324 | WRITE(FILE_C2FAC) i,nfaces,(iface(l),l=1,nfaces)
325 |
326 | READ(FILE_CELLS2,*) i,cellnodes,(inode(l),l=1,cellnodes)
327 | WRITE(FILE_CELLS) i,cellnodes,(inode(l),l=1,cellnodes)
328 |
329 | READ(FILE_CLPRO2,*) i,nfaces,(tem(l),patch(l),l=1,nfaces)
330 | WRITE(FILE_CLPRO) i,nfaces,(tem(l),patch(l),l=1,nfaces)
331 |
332 | ENDDO
333 |
334 | DO j=1,ndirs
335 |
336 | READ(FILE_QUADR2,*) mu,eta,ksi,omega
337 | WRITE(FILE_QUADR) mu,eta,ksi,omega
338 |
339 | READ(FILE_PROG2,*) (prog(l),l=1,ntcells)
340 | WRITE(FILE_PROG) (prog(l),l=1,ntcells)
341 |
342 | ENDDO
343 |
344 | DO k=1,ntnodes
345 |
346 | READ(FILE_NODES2,*) i,a,b,c
347 | WRITE(FILE_NODES) i,a,b,c
348 |
349 | ENDDO
350 |
351 | DO m=1,ntfaces
352 |
353 | READ(FILE_FACES2,*) i,fnnodes,(inode(l),l=1,fnnodes)
354 | WRITE(FILE_FACES) i,fnnodes,(inode(l),l=1,fnnodes)
355 |
356 | ENDDO
357 |
358 | READ(FILE_CLFAC2,*) nbfaces
359 | WRITE(FILE_CLFAC) nbfaces
360 |
361 | print*,'Conversion ascii2bin done!'
362 |
363 | ELSE
364 | print*, 'Error bad choice of convertion type'
365 | ENDIF
366 |
367 | ! ----------------!
368 | ! Close all files !
369 | ! ----------------!
370 |
371 | CLOSE(FILE_C2C)
372 | CLOSE(FILE_CCELL)
373 | CLOSE(FILE_CFACE)
374 | CLOSE(FILE_PROP)
375 | CLOSE(FILE_NORM)
376 | CLOSE(FILE_VOLA)
377 | CLOSE(FILE_EMIS)
378 | CLOSE(FILE_KSCA)
379 | CLOSE(FILE_QUADR)
380 | CLOSE(FILE_C2FAC)
381 | CLOSE(FILE_PROG)
382 | CLOSE(FILE_NODES)
383 | CLOSE(FILE_FACES)
384 | CLOSE(FILE_CELLS)
385 | CLOSE(FILE_CLPRO)
386 | CLOSE(FILE_CLFAC)
387 | CLOSE(FILE_C2C2)
388 | CLOSE(FILE_CCELL2)
389 | CLOSE(FILE_CFACE2)
390 | CLOSE(FILE_PROP2)
391 | CLOSE(FILE_NORM2)
392 | CLOSE(FILE_VOLA2)
393 | CLOSE(FILE_EMI2)
394 | CLOSE(FILE_KSCA2)
395 | CLOSE(FILE_QUADR2)
396 | CLOSE(FILE_C2FAC2)
397 | CLOSE(FILE_PROG2)
398 | CLOSE(FILE_NODES2)
399 | CLOSE(FILE_FACES2)
400 | CLOSE(FILE_CELLS2)
401 | CLOSE(FILE_CLPRO2)
402 | CLOSE(FILE_CLFAC2)
403 |
404 | END PROGRAM inconvert