2 use module_fr_sfire_core
5 integer :: ims,ime,jms,jme,icl,jcl,i,j,num_tests,flag
6 real,dimension(3,3)::tff,lff,lfn,tign,real_tff,real_lff
7 real,dimension(3,3)::tff0,lff0,lfn0,tign0,real_tff0,real_lff0
8 real,dimension(3,3)::tff1,lff1,lfn1,tign1,real_tff1,real_lff1
9 real,dimension(3,3)::tff2,lff2,lfn2,tign2,real_tff2,real_lff2
10 real,dimension(3,3)::tff3,lff3,lfn3,tign3,real_tff3,real_lff3
11 real,dimension(3,3)::tff8,lff8,lfn8,tign8
12 real,dimension(3,5)::tff9,lff9,lfn9,tign9
13 real, dimension(5,5)::d
14 real,dimension(2,2)::result
16 real::lfn00,lfn01,lfn10,lfn11,tign00,tign01,tign10,tign11,fuel_time_cell
17 real:: result1,Result2,Result3,Result4,Result5,result6
18 real:: res,res1,res2,res3,res4!
33 ! tign -- everywhere where lfn>=0, tign=3;
34 ! everywhere where lfn<0, tign=Z+3;
35 data lfn/0.5, -0.5, -1.5, &
39 data tign/3.0, 2.5, 1.5, &
43 data real_tff/3.0, 2.5, 2.0, &
47 data real_lff/0.0, -0.5, -1.0, &
51 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
54 test_err=maxval(abs(real_tff-tff))
55 if (test_err>error) then
56 print*,'Test #1 is not working, error ',test_err
57 print*,'is greater than 0.0001'
59 num_tests=num_tests+1;
63 ! tign -- everywhere where lfn>=0, tign=3;
64 ! everywhere where lfn<0, tign=Z+3;
65 data lfn1/2.0, 1.0, 0.0, &
69 data tign1/3.0, 3.0, 3.0, &
73 data real_tff1/3.0, 3.0, 3.0, &
77 data real_lff1/1.0, 0.5, 0.0, &
81 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
85 test_err=maxval(abs(real_tff1-tff1))
87 if (test_err>error) then
88 print*,'Test #2 is not working, error ',test_err
89 print*,'is greater than 0.0001'
91 num_tests=num_tests+1;
97 ! tign -- everywhere where lfn>=0, tign=3;
98 ! everywhere where lfn<0, tign=Z+3;
99 data lfn2/1.0, 0.0, -1.0, &
103 data tign2/3.0, 3.0, 2.0, &
107 data real_tff2/3.0, 2.5, 2.0, &
111 data real_lff2/0.0, -0.5, -1.0, &
117 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
118 tign2,lfn2,tff2,lff2)
121 test_err=maxval(abs(real_tff2-tff2))
122 if (test_err>error) then
123 print*,'Test #3 is not working, error ',test_err
124 print*,'is greater than 0.0001'
126 num_tests=num_tests+1;
131 !lfn - plane Z=5-X-Y;
132 ! tign -- everywhere where lfn>=0, tign=3;
133 ! everywhere where lfn<0, tign=Z+3;
134 data lfn3/3.0, 2.0, 1.0, &
138 data tign3/3.0, 3.0, 3.0, &
142 data real_tff3/3.0, 3.0, 3.0, &
146 data real_lff3/2.0, 1.5, 1.0, &
152 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
153 tign3,lfn3,tff3,lff3)
155 test_err=maxval(abs(real_tff3-tff3))
156 if (test_err>error) then
157 print*,'Test #4 is not working, error ',test_err
158 print*,'is greater than 0.0001'
160 num_tests=num_tests+1;
163 !!!Tests for fuel_left calculation!!!
164 !!!Test #5, result in Matlab u=(-2;0;1) f =0.91691!
175 fuel_time_cell= 8.235294 ;
177 call fuel_left_cell_3( &
179 lfn00,lfn01,lfn10,lfn11, &
180 tign00,tign01,tign10,tign11,&
181 time_now, fuel_time_cell)
186 if (test_err>error) then
187 print*,'Test #5 is not working, error ',test_err
188 print*,'is greater than 0.0001'
190 num_tests=num_tests+1;
195 !Test#6, result in Matlab u=(1;0;1) f =0.1660
206 fuel_time_cell= 8.235294 ;
208 call fuel_left_cell_3( &
210 lfn00,lfn01,lfn10,lfn11, &
211 tign00,tign01,tign10,tign11,&
212 time_now, fuel_time_cell)
217 if (test_err>error) then
218 print*,'Test #6 is not working, error ',test_err
219 print*,'is greater than 0.0001'
221 num_tests=num_tests+1;
224 !Test7, result in Matlab u=-(2;0;4) f =0.4538
235 fuel_time_cell= 8.235294 ;
237 call fuel_left_cell_3( &
239 lfn00,lfn01,lfn10,lfn11, &
240 tign00,tign01,tign10,tign11,&
241 time_now, fuel_time_cell)
245 if (test_err>error) then
246 print*,'Test #7 is not working, error ',test_err
247 print*,'is greater than 0.0001'
249 num_tests=num_tests+1;
253 !Test#8, result in Matlab u=(-4;-4;6) f =0.5336
264 fuel_time_cell= 8.235294 ;
266 call fuel_left_cell_3( &
268 lfn00,lfn01,lfn10,lfn11, &
269 tign00,tign01,tign10,tign11,&
270 time_now, fuel_time_cell)
274 if (test_err>error) then
275 print*,'Test #8 is not working, error ',test_err
276 print*,'is greater than 0.0001'
278 num_tests=num_tests+1;
281 !Test9, result in Matlab u=(-2;-2;1) f =0.9692
292 fuel_time_cell= 8.235294 ;
294 call fuel_left_cell_3( &
296 lfn00,lfn01,lfn10,lfn11, &
297 tign00,tign01,tign10,tign11,&
298 time_now, fuel_time_cell)
302 if (test_err>error) then
303 print*,'Test #9 is not working, error ',test_err
304 print*,'is greater than 0.0001'
306 num_tests=num_tests+1;
311 print*,"Main Test (#10), we calculate the fuel_left of the center cell"
312 print*,"(we have 9 cells initially)"
313 print*,"The initial values are"
314 print*,"lfn is described by the plane z=y-2; tign is described by the plane z=y"
319 data lfn8/-1., 0., 1., &
323 data tign8/1.0, 2., 2., &
330 print*,"time_now",time_now
331 write(*,101)'tign',tign8
332 write(*,101)'lfn',lfn8
333 print*,"icl,jcl should be equal 2 here"
334 write(*,*)'icl,jcl',icl,jcl
335 print*,"calling tign_lfn_interpolation, that calculates"
336 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
337 tign8,lfn8,tff8,lff8)
339 print*,"as result tff,lff are"
340 write(*,101)'tff',tff8
341 write(*,101)'lff',lff8
346 write(*,*)'tign and tff, here you can check whether they were &
352 write(*,*)'lfn and lff, here you can check whether they were calculated properly'
357 fuel_time_cell= 8.235294 ;
358 print*,"Calculation of fuel_frac over 4 subcells"
360 do i=1,2 ! Loop over 4 subcells
363 print*,"meaning of tff and lff in the subcell",i,j
364 write(*,*)'lff',lff8(i,j),lff8(i,j+1),lff8(i+1,j),lff8(i+1,j+1)
365 write(*,*)'tff',tff8(i,j),tff8(i,j+1),tff8(i+1,j),tff8(i+1,j+1)
366 call fuel_left_cell_3( &
367 result(i,j),fire_area, &
368 lff8(i,j),lff8(i,j+1),lff8(i+1,j),lff8(i+1,j+1), &
369 tff8(i,j),tff8(i,j+1),tff8(i+1,j),tff8(i+1,j+1),&
370 time_now, fuel_time_cell)
371 write(*,*)'result after step i and j',result(i,j),i,j
375 if (res1-result(1,1)>error.or.res2-result(1,2)>error.or.res3-result(2,1)>error.or.res4-result(2,2)>error) then
376 print*,'Test #10 is not working, one of errors '
377 print*,'For cell (1,1)',res1-result(1,1)
378 print*,'For cell (1,2)',res2-result(1,2)
379 print*,'For cell (2,1)',res3-result(2,1)
380 print*,'For cell (2,2)',res4-result(2,2)
381 print*,'is greater than 0.0001',error
383 num_tests=num_tests+1;
390 write(*,*)'MAIN TEST #2 (#11)'
391 print*,"Check for consistency, for 3 inner cells with the same results"
402 data lfn9/-1., -1.,-1., &
408 data tign9/1.0, 1., 1., &
415 write(*,*)"icl,jcl",icl,jcl
416 call tign_lfn_interpolation(time_now,icl,jcl,ims,ime,jms,jme, &
417 tign9,lfn9,tff9,lff9)
419 fuel_time_cell= 8.235294 ;
420 write(*,*)"Calculation of fuel_frac over 4 subcells"
426 call fuel_left_cell_3( &
427 result(i,j),fire_area, &
428 lff9(i,j),lff9(i,j+1),lff9(i+1,j),lff9(i+1,j+1), &
429 tff9(i,j),tff9(i,j+1),tff9(i+1,j),tff9(i+1,j+1),&
430 time_now, fuel_time_cell)
431 write(*,*)'result after step i and j',result(i,j),i,j
436 if (res1-result(1,1)>error.or.res2-result(1,2)>error.or.res3-result(2,1)>error.or.res4-result(2,2)>error) then
437 print*,'Test #10 is not working, one of errors '
438 print*,'For cell (1,1)',res1-result(1,1)
439 print*,'For cell (1,2)',res2-result(1,2)
440 print*,'For cell (2,1)',res3-result(2,1)
441 print*,'For cell (2,2)',res4-result(2,2)
442 print*,'is greater than 0.0001',error
448 num_tests=num_tests+1;
450 print*,"If the results for each correspondent subcell are equal in all cells"
451 print*,"then the code is consistent"
453 print*,num_tests,'of 11 tests worked succesfully'