1 | include(dom.inc)
2 |
3 | PROGRAM outconvert
4 |
5 | ! ==================================================================!
6 | ! !
7 | ! convertion.F : Convert PRISSMA's solution files !
8 | ! from bin to ascii and from ascii to bin !
9 | ! !
10 | ! author : D. POITOU (march 2008) !
11 | ! !
12 | ! ==================================================================!
13 |
14 | IMPLICIT NONE
15 |
16 | include 'dom_constants.h'
17 |
18 | CHARACTER*80 :: path1, path2, path3
19 | CHARACTER*80 :: gdatafile,gdatafile2,epfile,epfile2
20 | CHARACTER*80 :: gfile,srfile,hfile,qwfile,qrfile
21 | CHARACTER*80 :: gfile2,srfile2,hfile2,qwfile2,qrfile2
22 |
23 | DOM_INT :: ntcells, ntnodes, ntfaces,ntfacesmax
24 | DOM_INT :: icell,iface,l,i,j,nfaces,convtype
25 | DOM_REAL :: Sr,G,H,Qw
26 | DOM_REAL :: Q_r(3)
27 |
28 | DOM_REAL, ALLOCATABLE, DIMENSION(:) :: epsil
29 |
30 | ! ------------------!
31 | ! Read choices file !
32 | ! ------------------!
33 |
34 | OPEN (FILE_CHCS , FILE='outconvert.choices', FORM='FORMATTED')
35 | READ (FILE_CHCS,*) path1 ! Path for infiles *.in
36 | READ (FILE_CHCS,*) path2 ! Path for bin outfiles *.out
37 | READ (FILE_CHCS,*) path3 ! Path for acsii outfiles *.txt
38 | READ (FILE_CHCS,*) convtype ! Choice for the convertion type
39 | CLOSE(FILE_CHCS)
40 |
41 | ! ---------------!
42 | ! Set file names !
43 | ! ---------------!
44 |
45 | gdatafile = path1(1:len_trim(path1))//'/Global.in'
46 | gdatafile2 = path3(1:len_trim(path3))//'/Global.txt'
47 | epfile = path1(1:len_trim(path1))//'/Emissivities.in'
48 | epfile2 = path3(1:len_trim(path3))//'/Emissivities.txt'
49 |
50 | gfile = path2(1:len_trim(path2))//'/G.out'
51 | srfile = path2(1:len_trim(path2))//'/Sr.out'
52 | hfile = path2(1:len_trim(path2))//'/H.out'
53 | qwfile = path2(1:len_trim(path2))//'/Qw.out'
54 | qrfile = path2(1:len_trim(path2))//'/Qr.out'
55 |
56 | gfile2 = path3(1:len_trim(path3))//'/G.txt'
57 | srfile2 = path3(1:len_trim(path3))//'/Sr.txt'
58 | hfile2 = path3(1:len_trim(path3))//'/H.txt'
59 | qwfile2 = path3(1:len_trim(path3))//'/Qw.txt'
60 | qrfile2 = path3(1:len_trim(path3))//'/Qr.txt'
61 |
62 | ! -----------------------------------!
63 | ! Open biary/ascii Global data files !
64 | ! -----------------------------------!
65 |
66 | OPEN(FILE_GDATA, FILE=gdatafile , FORM='UNFORMATTED')
67 | OPEN(FILE_EMIS , FILE=epfile , FORM='UNFORMATTED')
68 | OPEN(FILE_GDAT2, FILE=gdatafile2, FORM='FORMATTED')
69 | OPEN(FILE_EMIS2, FILE=epfile2 , FORM='FORMATTED')
70 |
71 | ! ------------------------!
72 | ! Open biary output files !
73 | ! ------------------------!
74 |
75 | OPEN(FILE_G ,FILE=gfile ,FORM='unformatted')
76 | OPEN(FILE_Sr,FILE=srfile,FORM='unformatted')
77 | OPEN(FILE_H ,FILE=hfile ,FORM='unformatted')
78 | OPEN(FILE_Qw,FILE=qwfile,FORM='unformatted')
79 | OPEN(FILE_Qr,FILE=qrfile,FORM='unformatted')
80 |
81 | ! ------------------------!
82 | ! Open ascii output files !
83 | ! ------------------------!
84 |
85 | OPEN(FILE_G2 ,FILE=gfile2 ,FORM='formatted')
86 | OPEN(FILE_Sr2,FILE=srfile2,FORM='formatted')
87 | OPEN(FILE_H2 ,FILE=hfile2 ,FORM='formatted')
88 | OPEN(FILE_Qw2,FILE=qwfile2,FORM='formatted')
89 | OPEN(FILE_Qr2,FILE=qrfile2,FORM='formatted')
90 |
91 | ! ----------------------!
92 | ! Transform Global data !
93 | ! ----------------------!
94 |
95 | IF (convtype.eq.1) THEN
96 |
97 | READ(FILE_GDATA) ntcells, ntnodes, ntfaces,ntfacesmax
98 | WRITE(FILE_GDAT2,*) ntcells, ntnodes, ntfaces,ntfacesmax
99 |
100 | ELSEIF (convtype.eq.2) THEN
101 |
102 | READ(FILE_GDAT2,*) ntcells, ntnodes, ntfaces,ntfacesmax
103 |
104 | ENDIF
105 |
106 | CLOSE(FILE_GDATA)
107 | CLOSE(FILE_GDAT2)
108 |
109 | ! -----------------!
110 | ! Allocate vectors !
111 | ! -----------------!
112 |
113 | ALLOCATE(epsil(ntfacesmax))
114 |
115 | ! ----------------------!
116 | ! Transform output data !
117 | ! ----------------------!
118 | epsil = -1.
119 |
120 | IF (convtype.eq.1) THEN
121 |
122 | DO i=1,ntnodes
123 | READ(FILE_G ) icell,G
124 | READ(FILE_Sr ) icell,Sr
125 | READ(FILE_Qr ) icell,(Q_r(l),l=1,3)
126 |
127 | WRITE(FILE_G2,* ) icell,G
128 | WRITE(FILE_Sr2,* ) icell,Sr
129 | WRITE(FILE_Qr2,* ) icell,(Q_r(l),l=1,3)
130 |
131 | ENDDO
132 |
133 | DO i=1,ntcells
134 |
135 | READ(FILE_EMIS) icell,nfaces,(epsil(j),j=1,nfaces)
136 |
137 | WRITE(FILE_EMIS2,*) icell,nfaces,(epsil(j),j=1,nfaces)
138 |
139 | DO j=1,nfaces
140 |
141 | IF (epsil(j).ne.-1.) THEN
142 |
143 | READ(FILE_H ) iface,icell,H
144 | READ(FILE_Qw) iface,icell,Qw
145 |
146 | WRITE(FILE_H2,* ) iface,icell,H
147 | WRITE(FILE_Qw2,*) iface,icell,Qw
148 |
149 | ENDIF
150 |
151 | ENDDO
152 |
153 | ENDDO
154 |
155 | ELSEIF (convtype.eq.2) THEN
156 |
157 | DO i=1,ntcells
158 |
159 | READ(FILE_G2,* ) icell,G
160 | READ(FILE_Sr2,* ) icell,Sr
161 | READ(FILE_Qr2,* ) icell,(Q_r(l),l=1,3)
162 |
163 | WRITE(FILE_G ) icell,G
164 | WRITE(FILE_Sr) icell,Sr
165 | WRITE(FILE_Qr) icell,(Q_r(l),l=1,3)
166 |
167 | ENDDO
168 |
169 | DO i=1,ntcells
170 |
171 | READ(FILE_EMIS2,*) icell,nfaces,(epsil(j),j=1,nfaces)
172 |
173 | DO j=1,nfaces
174 |
175 | IF (epsil(j).ne.-1.) THEN
176 |
177 | READ(FILE_H2,* ) iface,icell,H
178 | READ(FILE_Qw2,*) iface,icell,Qw
179 |
180 | WRITE(FILE_H ) iface,icell,H
181 | WRITE(FILE_Qw ) iface,icell,Qw
182 |
183 | ENDIF
184 |
185 | ENDDO
186 |
187 | ENDDO
188 |
189 | ELSE
190 | print*, 'Error bad choice of convertion type'
191 | ENDIF
192 |
193 | ! ----------------!
194 | ! Close all files !
195 | ! ----------------!
196 |
197 | CLOSE(FILE_EMIS)
198 | CLOSE(FILE_EMIS2)
199 | CLOSE(FILE_G)
200 | CLOSE(FILE_G2)
201 | CLOSE(FILE_Sr)
202 | CLOSE(FILE_Sr2)
203 | CLOSE(FILE_Qr)
204 | CLOSE(FILE_Qr2)
205 | CLOSE(FILE_Qw)
206 | CLOSE(FILE_Qw2)
207 |
208 | IF(convtype.eq.1) THEN
209 | print*,'Conversion bin2ascii done!'
210 | ELSEIF(convtype.eq.2) THEN
211 | print*,'Conversion ascii2bin done!'
212 | ENDIF
213 |
214 | END PROGRAM outconvert
outconvert.F could be called by: