Merge branch 'fixf'
[wrf-fire-matlab.git] / femwind / fortran / prolongation_test.f90
blobccf997e44d184ed26e780c23e7064a4ea4ca1c58
1 program prolongation_test
3 use module_coarsening
4 use module_utils ! to read and write matrices as text files from matlab
6 implicit none
8 integer:: &
9 ifds, ifde, kfds, kfde, jfds, jfde, & ! fire grid dimensions
10 ifms, ifme, kfms, kfme, jfms, jfme, & ! memory dimensions
11 ifps, ifpe, kfps, kfpe, jfps, jfpe, & ! fire patch bounds
12 ifts, ifte, kfts, kfte, jfts, jfte, & ! tile dimensions
13 ifcds, ifcde, kfcds,kfcde, jfcds,jfcde, & ! coarse grid domain
14 ifcms, ifcme, kfcms,kfcme, jfcms,jfcme, & ! coarse grid dimensions
15 ifcps, ifcpe, kfcps,kfcpe, jfcps,jfcpe, & ! coarse grid dimensions
16 ifcts, ifcte, kfcts,kfcte, jfcts,jfcte ! coarse grid tile
19 real, pointer, dimension(:,:,:):: u_m, uc_m, X_m, Y_m, Z_m, cl_z_m, hcz_m ! to read from files
20 real, pointer, dimension(:,:,:):: u, uc, X, Y, Z ! to pass on
21 integer, pointer:: cl_z(:)
22 integer:: n(3),nc(3),cr_x,cr_y, nwrap = 0
24 ! read matrices, X Y Z already in the ikj ordering
25 call read_array(X_m,'X')
26 call read_array(Y_m,'Y')
27 call read_array(Z_m,'Z')
28 call read_array(uc_m,'uc')
29 call read_array(cl_z_m,'cl_z')
30 call read_array(hcz_m,'hcz')
32 n = shape(X_m) ! fine mesh size
33 nc = shape(uc_m) ! coarse mesh size
35 call set_indices(nc,nwrap, & ! coarse mesh bounds
36 ifcds, ifcde, kfcds,kfcde, jfcds,jfcde, &
37 ifcms, ifcme, kfcms,kfcme, jfcms,jfcme, &
38 ifcts, ifcte, kfcts,kfcte, jfcts,jfcte)
40 ! allocate coarse input and copy
41 allocate(uc(ifcms:ifcme,kfcms:kfcme,jfcms:jfcme))
42 uc(ifcts:ifcte,kfcts:kfcte,jfcts:jfcte)=uc_m
44 ! set coarsening indices
45 if(nc(2).ne.size(cl_z_m))call crash('coarse index array size')
46 allocate(cl_z(kfcts:kfcte))
47 cl_z = cl_z_m(:,1,1);
48 cr_x = hcz_m(1,1,1)
49 cr_y = hcz_m(2,1,1)
51 call set_indices(n,nwrap, & ! coarse mesh bounds
52 ifds, ifde, kfds,kfde, jfds,jfde, & ! fire grid dimensions
53 ifms, ifme, kfms,kfme, jfms,jfme, &
54 ifts, ifte, kfts,kfte, jfts,jfte)
56 ! allocate fine input and copy to tile
57 allocate(X(ifms:ifme,kfms:kfme,jfms:jfme))
58 X(ifts:ifte,kfts:kfte,jfts:jfte)=X_m
59 allocate(Y(ifms:ifme,kfms:kfme,jfms:jfme))
60 Y(ifts:ifte,kfts:kfte,jfts:jfte)=Y_m
61 allocate(Z(ifms:ifme,kfms:kfme,jfms:jfme))
62 Z(ifts:ifte,kfts:kfte,jfts:jfte)=Z_m
64 ! allocate output
65 allocate(u(ifms:ifme,kfms:kfme,jfms:jfme))
67 u(ifts:ifte,kfts:kfte,jfts:jfte) = 0.
68 write(*,*)'calling prolongation'
69 call prolongation( &
70 ifds, ifde, kfds, kfde, jfds, jfde, & ! fire grid dimensions
71 ifms, ifme, kfms, kfme, jfms, jfme, & ! memory dimensions
72 ifps, ifpe, kfps, kfpe, jfps, jfpe, & ! fire patch bounds
73 ifts, ifte, kfts, kfte, jfts, jfte, & ! tile dimensions
74 ifcds, ifcde, kfcds,kfcde, jfcds,jfcde, & ! coarse grid domain
75 ifcms, ifcme, kfcms,kfcme, jfcms,jfcme, & ! coarse grid dimensions
76 ifcps, ifcpe, kfcps,kfcpe, jfcps,jfcpe, & ! coarse grid dimensions
77 ifcts, ifcte, kfcts,kfcte, jfcts,jfcte, & ! coarse grid tile
78 u,uc,cr_x,cr_y,cl_z,X,Y,Z)
80 ! copy output to tight and write to file
81 allocate(u_m(n(1),n(2),n(3)))
82 u_m = u(ifts:ifte,kfts:kfte,jfts:jfte)
83 call write_array(u_m,'u')
85 end program prolongation_test