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 icell=1,ntcells
219 |
220 | READ(FILE_C2C ) i,nfaces, &
221 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
222 | WRITE(FILE_C2C2,*) i,nfaces, &
223 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
224 |
225 | READ(FILE_CCELL) i,xc,yc,zc
226 | WRITE(FILE_CCELL2,*) i,xc,yc,zc
227 |
228 | READ(FILE_CFACE) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
229 | WRITE(FILE_CFACE2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
230 |
231 | READ(FILE_PROP) i,(celldata(l),l=1,8)
232 | WRITE(FILE_PROP2,*) i,(celldata(l),l=1,8)
233 |
234 | READ(FILE_NORM) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
235 | WRITE(FILE_NORM2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
236 |
237 | READ(FILE_VOLA) i,nfaces,VOL,(surf(l),l=1,nfaces)
238 | WRITE(FILE_VOLA2,*) i,nfaces,VOL,(surf(l),l=1,nfaces)
239 |
240 | READ(FILE_EMIS) i,nfaces,(epsil(l),l=1,nfaces)
241 | WRITE(FILE_EMI2,*) i,nfaces,(epsil(l),l=1,nfaces)
242 |
243 | READ(FILE_KSCA) i,kabs_gray,k_scat
244 | WRITE(FILE_KSCA2,*) i,kabs_gray,k_scat
245 |
246 | READ(FILE_C2FAC) i,nfaces,(iface(l),l=1,nfaces)
247 | WRITE(FILE_C2FAC2,*) i,nfaces,(iface(l),l=1,nfaces)
248 |
249 | READ(FILE_CELLS) i,cellnodes,(inode(l),l=1,cellnodes)
250 | WRITE(FILE_CELLS2,*) i,cellnodes,(inode(l),l=1,cellnodes)
251 |
252 | READ(FILE_CLPRO) i,nfaces,(tem(l),patch(l),l=1,nfaces)
253 | WRITE(FILE_CLPRO2,*) i,nfaces,(tem(l),patch(l),l=1,nfaces)
254 |
255 | ENDDO
256 |
257 | DO j=1,ndirs
258 |
259 | READ(FILE_QUADR) mu,eta,ksi,omega
260 | WRITE(FILE_QUADR2,*) mu,eta,ksi,omega
261 |
262 | READ(FILE_PROG) (prog(l),l=1,ntcells)
263 | WRITE(FILE_PROG2,*) (prog(l),l=1,ntcells)
264 |
265 | ENDDO
266 |
267 | DO k=1,ntnodes
268 |
269 | READ(FILE_NODES) i,a,b,c
270 | WRITE(FILE_NODES2,*) i,a,b,c
271 |
272 | ENDDO
273 |
274 | DO m=1,ntfaces
275 |
276 | READ(FILE_FACES) i,fnnodes,(inode(l),l=1,fnnodes)
277 | WRITE(FILE_FACES2,*) i,fnnodes,(inode(l),l=1,fnnodes)
278 |
279 | ENDDO
280 |
281 | READ(FILE_CLFAC) nbfaces
282 | WRITE(FILE_CLFAC2,*) nbfaces
283 |
284 | print*,'Conversion bin2ascii done!'
285 |
286 | ELSEIF (convtype.eq.2) THEN
287 |
288 | DO icell=1,ntcells
289 |
290 | READ(FILE_C2C2,*) i,nfaces, &
291 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
292 | WRITE(FILE_C2C) i,nfaces, &
293 | & (neighb(1,l),neighb(2,l),l=1,nfaces)
294 |
295 | READ(FILE_CCELL2,*) i,xc,yc,zc
296 | WRITE(FILE_CCELL) i,xc,yc,zc
297 |
298 | READ(FILE_CFACE2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
299 | WRITE(FILE_CFACE) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
300 |
301 | READ(FILE_PROP2,*) i,(celldata(l),l=1,8)
302 | WRITE(FILE_PROP) i,(celldata(l),l=1,8)
303 |
304 | READ(FILE_NORM2,*) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
305 | WRITE(FILE_NORM) i,nfaces,(x(l),y(l),z(l),l=1,nfaces)
306 |
307 | READ(FILE_VOLA2,*) i,nfaces,VOL,(surf(l),l=1,nfaces)
308 | WRITE(FILE_VOLA) i,nfaces,VOL,(surf(l),l=1,nfaces)
309 |
310 | READ(FILE_EMI2,*) i,nfaces,(epsil(l),l=1,nfaces)
311 | WRITE(FILE_EMIS) i,nfaces,(epsil(l),l=1,nfaces)
312 |
313 | READ(FILE_KSCA2,*) i,kabs_gray,k_scat
314 | WRITE(FILE_KSCA) i,kabs_gray,k_scat
315 |
316 | READ(FILE_C2FAC2,*) i,nfaces,(iface(l),l=1,nfaces)
317 | WRITE(FILE_C2FAC) i,nfaces,(iface(l),l=1,nfaces)
318 |
319 | READ(FILE_CELLS2,*) i,cellnodes,(inode(l),l=1,cellnodes)
320 | WRITE(FILE_CELLS) i,cellnodes,(inode(l),l=1,cellnodes)
321 |
322 | READ(FILE_CLPRO2,*) i,nfaces,(tem(l),patch(l),l=1,nfaces)
323 | WRITE(FILE_CLPRO) i,nfaces,(tem(l),patch(l),l=1,nfaces)
324 |
325 | ENDDO
326 |
327 | DO j=1,ndirs
328 |
329 | READ(FILE_QUADR2,*) mu,eta,ksi,omega
330 | WRITE(FILE_QUADR) mu,eta,ksi,omega
331 |
332 | READ(FILE_PROG2,*) (prog(l),l=1,ntcells)
333 | WRITE(FILE_PROG) (prog(l),l=1,ntcells)
334 |
335 | ENDDO
336 |
337 | DO k=1,ntnodes
338 |
339 | READ(FILE_NODES2,*) i,a,b,c
340 | WRITE(FILE_NODES) i,a,b,c
341 |
342 | ENDDO
343 |
344 | DO m=1,ntfaces
345 |
346 | READ(FILE_FACES2,*) i,fnnodes,(inode(l),l=1,fnnodes)
347 | WRITE(FILE_FACES) i,fnnodes,(inode(l),l=1,fnnodes)
348 |
349 | ENDDO
350 |
351 | READ(FILE_CLFAC2,*) nbfaces
352 | WRITE(FILE_CLFAC) nbfaces
353 |
354 | print*,'Conversion ascii2bin done!'
355 |
356 | ELSE
357 | print*, 'Error bad choice of convertion type'
358 | ENDIF
359 |
360 | ! ----------------!
361 | ! Close all files !
362 | ! ----------------!
363 |
364 | CLOSE(FILE_C2C)
365 | CLOSE(FILE_CCELL)
366 | CLOSE(FILE_CFACE)
367 | CLOSE(FILE_PROP)
368 | CLOSE(FILE_NORM)
369 | CLOSE(FILE_VOLA)
370 | CLOSE(FILE_EMIS)
371 | CLOSE(FILE_KSCA)
372 | CLOSE(FILE_QUADR)
373 | CLOSE(FILE_C2FAC)
374 | CLOSE(FILE_PROG)
375 | CLOSE(FILE_NODES)
376 | CLOSE(FILE_FACES)
377 | CLOSE(FILE_CELLS)
378 | CLOSE(FILE_CLPRO)
379 | CLOSE(FILE_CLFAC)
380 | CLOSE(FILE_C2C2)
381 | CLOSE(FILE_CCELL2)
382 | CLOSE(FILE_CFACE2)
383 | CLOSE(FILE_PROP2)
384 | CLOSE(FILE_NORM2)
385 | CLOSE(FILE_VOLA2)
386 | CLOSE(FILE_EMI2)
387 | CLOSE(FILE_KSCA2)
388 | CLOSE(FILE_QUADR2)
389 | CLOSE(FILE_C2FAC2)
390 | CLOSE(FILE_PROG2)
391 | CLOSE(FILE_NODES2)
392 | CLOSE(FILE_FACES2)
393 | CLOSE(FILE_CELLS2)
394 | CLOSE(FILE_CLPRO2)
395 | CLOSE(FILE_CLFAC2)
396 |
397 | END PROGRAM inconvert