Bonjour
je veut mettre les subroutines de mon code dans un fichier.for que j'utilise apres comme module dans le code principal.je n' ai pas pu faire cette operation : lors de compilation du module avec gfortran -c mod.for il m'affiche plusieurs erreurs alors que ce code est executable. voila le code initial suivi de mon essai. merci vos aide et vos cooperation. merci bien.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
! ce programme tend a calculer les isothermes et les temp à differentes valeurs de i
 
        ! declaration de variables
 
        parameter (n=2000,m=100)
	real f(0:8,0:n,0:m)
	real feq(0:8,0:n,0:m),rho(0:n,0:m)
	real w(0:8), cx(0:8),cy(0:8)
	real u(0:n,0:m), v(0:n,0:m)
	real g(0:8,0:n,0:m), geq(0:8,0:n,0:m),th(0:n,0:m)
        real theta(0:n,0:m),theta_in(0:m)
        real t_in(0:m)
        real Y(0:m)
	integer i,j,k,kk
        character Saida*2910
 
        ! opening files
 
        Saida='results/chanflowartth960v2.dat'
	open(12,file=Saida)
        !Saida='results/chanflowartth400.dat'
	!open(13,file=Saida)
        !Saida='results/chanflowartth80.dat'
	!open(14,file=Saida)
        Saida='results/chanflowartth160.dat'
        open(15,file=Saida)
        !Saida='results/chanflowartstrli.dat'
	!open(6,file=Saida)
        Saida='results/chanflowartxvit400v2.dat'
	open(17,file=Saida)
        Saida='results/chanflowartxvit80.dat'
        open(18,file=saida)
        Saida='results/chanflowartxvit240.dat'
	open(19,file=Saida)
 
	!initialisations de variables
 
	cx(:)=(/0.0,1.0,0.0,-1.0,0.0,1.0,-1.0,-1.0,1.0/)
	cy(:)=(/0.0,0.0,1.0,0.0,-1.0,1.0,1.0,-1.0,-1.0/)
	w(:)=(/4./9.,1./9.,1./9.,1./9.,1./9.,1./36.,1./36.,1./36.,1./36./)
	uo=0.71
	!sumvelo=0.0
	rhof=5.00
	dx=1.0
	dy=dx
	dt=1.0
	tw=0.0
        t_in(m/2)=0.9
        th=0.7
        !H=0.02
 
 
 
	g=0.0
	!visco=10.E-7
	visco=0.089
	pr=1.0
	alpha=visco/pr
	!Re=uo*m/alpha
         Re=m*uo/visco
	print *, 'Re=', Re
	omega=1.0/(3.0*visco+0.5)
	omegat=1.0/(3.0*alpha+0.5)
	print *,omega
         mstep=5000
 
	do i=0,n
	do j=0,m
        rho(i,j)=rhof 
	u(i,j)=0.0
	v(i,j)=0.0
	end do
	end do
 
	! main loop
 
!/////////////////programme principale//////////////////////////
 
	do kk=1,mstep
        call collesion(u,v,f,feq,rho,omega,w,cx,cy,n,m)
        call streaming(f,n,m)
	call sfbound(f,n,m,uo)
        call rhouv(f,rho,u,v,cx,cy,n,m)
 
        ! collestion for scalar
	call col(u,v,g,geq,th,theta,omegat,w,cx,cy,n,m)
	! streaming for scalar
	!call streaming(g,n,m)!!!!!!!!!!!! n'existe pas
	call gbound(g,theta_in,Y,w,n,m)
        call tcalcu(g,th,theta,t_in,tw,n,m)
        !call result(u,v,rho,theta,Y,uo,n,m)
        END DO
	call result(u,v,rho,theta,Y,uo,n,m)! end of the main loop
 
	!call result(u,v,rho,theta,Y,uo,n,m)
	!do j=0,m
        !print *,theta(12*n/25,j) 
        !print *, u(n/5,j),u(n/25,j)
        !end do
        stop
	end
	! end of the main program
 
!/////////////////////les subroutines////////////////////////////
 
	!////////////collision////////////////
 
        subroutine collesion(u,v,f,feq,rho,omega,w,cx,cy,n,m)
	real f(0:8,0:n,0:m)
	real feq(0:8,0:n,0:m),rho(0:n,0:m)
	real w(0:8), cx(0:8),cy(0:8)
	real u(0:n,0:m), v(0:n,0:m)
	DO i=0,n
	DO j=0,m
	t1=(u(i,j)*u(i,j))+(v(i,j)*v(i,j))
	DO k=0,8
	t2=(u(i,j)*cx(k))+(v(i,j)*cy(k))
	feq(k,i,j)=rho(i,j)*w(k)*(1.0+3.0*t2+4.50*t2*t2-1.50*t1)
	f(k,i,j)=omega*feq(k,i,j)+(1.-omega)*f(k,i,j)
        !print*,f(k,i,j)
	END DO
	END DO
	END DO
 
 
        return
	end
 
        !///////////////////col////////////////
 
      subroutine col(u,v,g,geq,theta,th,omegat,w,cx,cy,n,m)
	real g(0:8,0:n,0:m),geq(0:8,0:n,0:m),theta(0:n,0:m)
        real th(0:n,0:m),t_in(m/2),tw
	real w(0:8),cx(0:8),cy(0:8)
	real u(0:n,0:m),v(0:n,0:m)
 
	do i=0,n
	do j=0,m
 
	do k=0,8
	geq(k,i,j)=theta(i,j)*w(k)*(1.0+3.0*(u(i,j)*cx(k)+v(i,j)*cy(k)))
	g(k,i,j)=omegat*geq(k,i,j)+(1.0-omegat)*g(k,i,j)
 
	end do
	end do
	end do
	!print*,theta
        return
	end
 
        !///////////////////propagation///////////////
 
	subroutine streaming(f,n,m)
	real f(0:8,0:n,0:m)
	! streaming
	DO j=0,m
	DO i=n,1,-1 !RIGHT TO LEFT
	f(1,i,j)=f(1,i-1,j)
 
	END DO
	DO i=0,n-1 !LEFT TO RIGHT
	f(3,i,j)=f(3,i+1,j)
	END DO
	END DO
	DO j=m,1,-1 !TOP TO BOTTOM
	DO i=0,n
	f(2,i,j)=f(2,i,j-1)
	END DO
	DO i=n,1,-1
	f(5,i,j)=f(5,i-1,j-1)
	END DO
	DO i=0,n-1
	f(6,i,j)=f(6,i+1,j-1)
	END DO
	END DO
	DO j=0,m-1 !BOTTOM TO TOP
	DO i=0,n
	f(4,i,j)=f(4,i,j+1)
	END DO
	DO i=0,n-1
	f(7,i,j)=f(7,i+1,j+1)
	END DO
	DO i=n,1,-1
	f(8,i,j)=f(8,i-1,j+1)
	END DO
	END DO
	return
	end
 
        !//////////////conditions aux limites////////////////
 
 
	 subroutine sfbound(f,n,m,uo)
 
	 real f(0:8,0:n,0:m)
 
	 do j=0,m
	!bounce back on west boundary!
	  rhow=(f(0,0,j)+f(2,0,j)+f(4,0,j)
     & +2.*(f(3,0,j)+f(6,0,j)+f(7,0,j)))/(1.-uo)
	  f(1,0,j)=f(3,0,j)+2.0*rhow*uo/3.0
	  f(5,0,j)=f(7,0,j)+rhow*uo/6.0
	  f(8,0,j)=f(6,0,j)+rhow*uo/6.0
 
	 end do
 
	!bounce back on south boundary!
	 do i=0,n
	   f(2,i,0)=f(4,i,0)
	   f(5,i,0)=f(7,i,0)
	   f(6,i,0)=f(8,i,0)
	 end do
 
	!bounce back, north boundary
	 do i=0,n
	   f(4,i,m)=f(2,i,m)
	   f(8,i,m)=f(6,i,m)
	   f(7,i,m)=f(5,i,m)
	 end do
 
	 ! accont for open boundary condition at the outlet
	  do j=0,m
	    f(1,n,j)=2.0*f(1,n-1,j)-f(1,n-2,j)
	    f(5,n,j)=2.0*f(5,n-1,j)-f(5,n-2,j)
	    f(8,n,j)=2.0*f(8,n-1,j)-f(8,n-2,j)
           end do 
 
	   return
	   end
 
       !/////////// cond aux limites sur g/////////////
 
	subroutine gbound(g,theta_in,Y,w,n,m)
	real g(0:8,0:n,0:m)
	real w(0:8),theta_in(0:m)
        real Y(0:m)
	! Boundary conditions
	! top boundary condition, theta=0.
	do j=0,m
	g(4,0,j)=-g(2,0,j)
	g(7,0,j)=-g(5,0,j)
	g(8,0,j)=-g(6,0,j)
        g(1,0,j)=-g(3,0,j)
	end do
	! east boundary condition, outlet cond ouverte.
	do j=0,m
 
	g(8,n,j)=2.0*g(8,n-1,j)-g(8,n-2,j)
	g(5,n,j)=2.0*g(5,n-1,j)-g(5,n-2,j)
	g(1,n,j)=2.0*g(1,n-1,j)-g(1,n-2,j)
 
	end do
	! inlet west boundary conditions, T=t_in et theta=theta_in dirichlet
	do j=0,m
 
        Y(j)=j/float(m)
        theta_in(j)=4.0*(Y(j)-(Y(j)*Y(j)))
 
	g(8,0,j)=theta_in(j)*(w(8)+w(6))-g(6,0,j)
	g(5,0,j)=theta_in(j)*(w(7)+w(5))-g(7,0,j)
	g(1,0,j)=theta_in(j)*(w(1)+w(3))-g(3,0,j)
        !print*,theta_in(j)
	end do
	!Bottom boundary conditions,Theta=0 
 
	do i=0,n
	g(1,i,0)=-g(3,i,0)
	g(2,i,0)=-g(4,i,0)
 
 
	g(5,i,0)=-g(7,i,0)
	g(6,i,0)=-g(8,i,0)
 
	end do
	return
	end
 
!/////////calcul de la temperature///////////
 
	subroutine tcalcu(g,th,theta,t_in,tw,n,m)
	real g(0:8,0:n,0:m),th(0:n,0:m),theta(0:n,0:m)
        real t_in(m/2),tw
 
        t_in(m/2)=0.9
        tw=0.0
        do i=0,n
	do j=0,m
 
	ssumt=0.0
	do k=0,8
	ssumt=ssumt+g(k,i,j)
	end do
	th(i,j)=ssumt
        theta(i,j)=(th(i,j)-tw)/(t_in(m/2)-tw)
	end do
	end do
        !do i=0,n
        !do j=0,m
 
	!theta(i,j)=(th(i,j)-tw)/(t_in(m/2)-tw)
        !end do
        !end do
 
        return
	end
 
!/////////////calcul de la densite et precisement la vitesse/////////////
 
	 subroutine rhouv(f,rho,u,v,cx,cy,n,m)
 
	 real f(0:8,0:n,0:m),rho(0:n,0:m)
	 real u(0:n,0:m),v(0:n,0:m)
	 real cx(0:8),cy(0:8)
 
	  do i=0,n
	  do j=0,m
	  ssum=0.0
	  do k=0,8
	  ssum=ssum+f(k,i,j)
	  end do
	  rho(i,j)=ssum
          !print*, ssum,rho(i,j)
	   end do
	   end do
 
	    do j=0,m
	    rho(0,j)=(f(0,0,j)+f(2,0,j)+f(4,0,j)
     & +2.0*(f(3,0,j)+f(6,0,j)+f(7,0,j)))/(1.0-uo)
	 end do
 
	      do i=0,n
	      do j=0,m
	      usum=0.0
	      vsum=0.0
 
        DO k=0,8
	usum1=usum+f(k,i,j)*cx(k)
	vsum1=vsum+f(k,i,j)*cy(k)
	END DO
 
	u(i,j)=usum1/rho(i,j)
	v(i,j)=vsum1/rho(i,j)
         !print*,u(i,j)
	END DO
	END DO
 
	      do j=1,m
	      v(n,j)=0.0
	      end do
              do i=1,n
	      u(i,0)=0.0
              u(i,m)=0.0
	      end do
 
 
	      return
	      end
 
!////////////////calcul de lignes de courant et de resultat/////////////////
 
	subroutine result(u,v,rho,theta,Y,uo,n,m)
	real u(0:n,0:m),v(0:n,0:m),theta(0:n,0:m)
	real rho(0:n,0:m),strf(0:n,0:m)
	real Y(0:m)
	! streamfunction calculations
	strf(0,0)=0.0
	do i=1,n
	rhoav=0.5*(rho(i-1,0)+rho(i,0))
        strf(i,0)=strf(i-1,0)-rhoav*0.5*(v(i-1,0)+v(i,0))
	do j=1,m
	rhom=0.5*(rho(i,j)+rho(i,j-1))
	strf(i,j)=strf(i,j-1)+rhom*0.5*(u(i,j-1)+u(i,j))
	end do
	end do
 
       ! enregistrement de resultat
 
        do j=0,m
        Y(j)=j/float(m)
 
        end do
 
	do j=0,m
 
	write(12,*)Y(j),theta(int(12.0*n/25.0),j)
        print*,Y(j),theta(int(12.0*n/25.0),j)
	end do
 
 
 
 
        !do j=0,m
 
        !write(13,*)Y(j),theta(int(n/5.0),j)
	!end do
 
 
 
 
        !do j=0,m
        !write(14,*)Y(j),theta(int(n/25.0),j)
	!end do
 
 
        do j=0,m
        write(15,*)Y(j),theta(int(2.0*n/25.0),j)
	end do
 
 
	!do j=0,m
        !do i=0,n
	!write(16,*)i,j,strf(i,j)
	!end do
        !end do
 
 
 
	do j=0,m
	write(17,*)Y(j),u(int(n/5.0),j)
 
 
        end do
 
 
 
	do j=0,m
	write(18,*)Y(j),u(int(n/25.0),j)
        end do
 
 
 
        do j=0,m
	write(19,*)Y(j),u(int(3.0*n/25.0),j)
        end do
 
 
 
 
 
 
 
	return
	end
ce je fait est
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
            Module modsubheaflow
 
 
!////////////collision////////////////
 
        subroutine collesion(u,v,f,feq,rho,omega,w,cx,cy,n,m)
	real f(0:8,0:n,0:m)
	real feq(0:8,0:n,0:m),rho(0:n,0:m)
	real w(0:8), cx(0:8),cy(0:8)
	real u(0:n,0:m), v(0:n,0:m)
	DO i=0,n
	DO j=0,m
	t1=(u(i,j)*u(i,j))+(v(i,j)*v(i,j))
	DO k=0,8
	t2=(u(i,j)*cx(k))+(v(i,j)*cy(k))
	feq(k,i,j)=rho(i,j)*w(k)*(1.0+3.0*t2+4.50*t2*t2-1.50*t1)
	f(k,i,j)=omega*feq(k,i,j)+(1.-omega)*f(k,i,j)
        !print*,f(k,i,j)
	END DO
	END DO
	END DO
 
 
        return
	end
 
        !///////////////////col////////////////
 
      subroutine col(u,v,g,geq,theta,th,omegat,w,cx,cy,n,m)
	real g(0:8,0:n,0:m),geq(0:8,0:n,0:m),theta(0:n,0:m)
        real th(0:n,0:m),t_in(m/2),tw
	real w(0:8),cx(0:8),cy(0:8)
	real u(0:n,0:m),v(0:n,0:m)
 
	do i=0,n
	do j=0,m
 
	do k=0,8
	geq(k,i,j)=theta(i,j)*w(k)*(1.0+3.0*(u(i,j)*cx(k)+v(i,j)*cy(k)))
	g(k,i,j)=omegat*geq(k,i,j)+(1.0-omegat)*g(k,i,j)
 
	end do
	end do
	end do
	!print*,theta
        return
	end
 
        !///////////////////propagation///////////////
 
	subroutine streaming(f,n,m)
	real f(0:8,0:n,0:m)
	! streaming
	DO j=0,m
	DO i=n,1,-1 !RIGHT TO LEFT
	f(1,i,j)=f(1,i-1,j)
 
	END DO
	DO i=0,n-1 !LEFT TO RIGHT
	f(3,i,j)=f(3,i+1,j)
	END DO
	END DO
	DO j=m,1,-1 !TOP TO BOTTOM
	DO i=0,n
	f(2,i,j)=f(2,i,j-1)
	END DO
	DO i=n,1,-1
	f(5,i,j)=f(5,i-1,j-1)
	END DO
	DO i=0,n-1
	f(6,i,j)=f(6,i+1,j-1)
	END DO
	END DO
	DO j=0,m-1 !BOTTOM TO TOP
	DO i=0,n
	f(4,i,j)=f(4,i,j+1)
	END DO
	DO i=0,n-1
	f(7,i,j)=f(7,i+1,j+1)
	END DO
	DO i=n,1,-1
	f(8,i,j)=f(8,i-1,j+1)
	END DO
	END DO
	return
	end
 
        !//////////////conditions aux limites////////////////
 
 
	 subroutine sfbound(f,n,m,uo)
 
	 real f(0:8,0:n,0:m)
 
	 do j=0,m
	!bounce back on west boundary!
	  rhow=(f(0,0,j)+f(2,0,j)+f(4,0,j)
     & +2.*(f(3,0,j)+f(6,0,j)+f(7,0,j)))/(1.-uo)
	  f(1,0,j)=f(3,0,j)+2.0*rhow*uo/3.0
	  f(5,0,j)=f(7,0,j)+rhow*uo/6.0
	  f(8,0,j)=f(6,0,j)+rhow*uo/6.0
 
	 end do
 
	!bounce back on south boundary!
	 do i=0,n
	   f(2,i,0)=f(4,i,0)
	   f(5,i,0)=f(7,i,0)
	   f(6,i,0)=f(8,i,0)
	 end do
 
	!bounce back, north boundary
	 do i=0,n
	   f(4,i,m)=f(2,i,m)
	   f(8,i,m)=f(6,i,m)
	   f(7,i,m)=f(5,i,m)
	 end do
 
	 ! accont for open boundary condition at the outlet
	  do j=0,m
	    f(1,n,j)=2.0*f(1,n-1,j)-f(1,n-2,j)
	    f(5,n,j)=2.0*f(5,n-1,j)-f(5,n-2,j)
	    f(8,n,j)=2.0*f(8,n-1,j)-f(8,n-2,j)
           end do 
 
	   return
	   end
 
       !/////////// cond aux limites sur g/////////////
 
	subroutine gbound(g,theta_in,Y,w,n,m)
	real g(0:8,0:n,0:m)
	real w(0:8),theta_in(0:m)
        real Y(0:m)
	! Boundary conditions
	! top boundary condition, theta=0.
	do j=0,m
	g(4,0,j)=-g(2,0,j)
	g(7,0,j)=-g(5,0,j)
	g(8,0,j)=-g(6,0,j)
        g(1,0,j)=-g(3,0,j)
	end do
	! east boundary condition, outlet cond ouverte.
	do j=0,m
 
	g(8,n,j)=2.0*g(8,n-1,j)-g(8,n-2,j)
	g(5,n,j)=2.0*g(5,n-1,j)-g(5,n-2,j)
	g(1,n,j)=2.0*g(1,n-1,j)-g(1,n-2,j)
 
	end do
	! inlet west boundary conditions, T=t_in et theta=theta_in dirichlet
	do j=0,m
 
        Y(j)=j/float(m)
        theta_in(j)=4.0*(Y(j)-(Y(j)*Y(j)))
 
	g(8,0,j)=theta_in(j)*(w(8)+w(6))-g(6,0,j)
	g(5,0,j)=theta_in(j)*(w(7)+w(5))-g(7,0,j)
	g(1,0,j)=theta_in(j)*(w(1)+w(3))-g(3,0,j)
        !print*,theta_in(j)
	end do
	!Bottom boundary conditions,Theta=0 
 
	do i=0,n
	g(1,i,0)=-g(3,i,0)
	g(2,i,0)=-g(4,i,0)
 
 
	g(5,i,0)=-g(7,i,0)
	g(6,i,0)=-g(8,i,0)
 
	end do
	return
	end
 
!/////////calcul de la temperature///////////
 
	subroutine tcalcu(g,th,theta,t_in,tw,n,m)
	real g(0:8,0:n,0:m),th(0:n,0:m),theta(0:n,0:m)
        real t_in(m/2),tw
 
        t_in(m/2)=0.9
        tw=0.0
        do i=0,n
	do j=0,m
 
	ssumt=0.0
	do k=0,8
	ssumt=ssumt+g(k,i,j)
	end do
	th(i,j)=ssumt
        theta(i,j)=(th(i,j)-tw)/(t_in(m/2)-tw)
	end do
	end do
        !do i=0,n
        !do j=0,m
 
	!theta(i,j)=(th(i,j)-tw)/(t_in(m/2)-tw)
        !end do
        !end do
 
        return
	end
 
!/////////////calcul de la densite et precisement la vitesse/////////////
 
	 subroutine rhouv(f,rho,u,v,cx,cy,n,m)
 
	 real f(0:8,0:n,0:m),rho(0:n,0:m)
	 real u(0:n,0:m),v(0:n,0:m)
	 real cx(0:8),cy(0:8)
 
	  do i=0,n
	  do j=0,m
	  ssum=0.0
	  do k=0,8
	  ssum=ssum+f(k,i,j)
	  end do
	  rho(i,j)=ssum
          !print*, ssum,rho(i,j)
	   end do
	   end do
 
	    do j=0,m
	    rho(0,j)=(f(0,0,j)+f(2,0,j)+f(4,0,j)
     & +2.0*(f(3,0,j)+f(6,0,j)+f(7,0,j)))/(1.0-uo)
	 end do
 
	      do i=0,n
	      do j=0,m
	      usum=0.0
	      vsum=0.0
 
        DO k=0,8
	usum1=usum+f(k,i,j)*cx(k)
	vsum1=vsum+f(k,i,j)*cy(k)
	END DO
 
	u(i,j)=usum1/rho(i,j)
	v(i,j)=vsum1/rho(i,j)
         !print*,u(i,j)
	END DO
	END DO
 
	      do j=1,m
	      v(n,j)=0.0
	      end do
              do i=1,n
	      u(i,0)=0.0
              u(i,m)=0.0
	      end do
 
 
	      return
	      end
 
!////////////////calcul de lignes de courant et de resultat/////////////////
 
	subroutine result(u,v,rho,theta,Y,uo,n,m)
	real u(0:n,0:m),v(0:n,0:m),theta(0:n,0:m)
	real rho(0:n,0:m),strf(0:n,0:m)
	real Y(0:m)
	! streamfunction calculations
	strf(0,0)=0.0
	do i=1,n
	rhoav=0.5*(rho(i-1,0)+rho(i,0))
        strf(i,0)=strf(i-1,0)-rhoav*0.5*(v(i-1,0)+v(i,0))
	do j=1,m
	rhom=0.5*(rho(i,j)+rho(i,j-1))
	strf(i,j)=strf(i,j-1)+rhom*0.5*(u(i,j-1)+u(i,j))
	end do
	end do
        return
        end
          end module modsubheaflow