1 | include(dom.inc)
2 | PROGRAM Balance_flux
3 |
4 | ! ================================================================!
5 | ! !
6 | ! Balance_flux.F : Calculate flux at BC !
7 | ! !
8 | ! out : !
9 | ! !
10 | ! author : PEDOT T. (Sept 09) !
11 | ! !
12 | ! ================================================================!
13 |
14 | IMPLICIT NONE
15 |
16 | include 'dom_constants.h'
17 |
18 | CHARACTER*80 :: path,outpath
19 | CHARACTER*80 :: clpropfile,gdatfile,volafile
20 | CHARACTER*80 :: GFile, SrFile, QwFile
21 | CHARACTER*80 :: FMT
22 | DOM_INT :: i, j, l, k, iface,icell,nface,nfaces
23 | DOM_INT :: num_patch, num_patchmax
24 | DOM_INT :: ntcells,ntnodes,ntfaces,ntfacesmax,ndirs
25 |
26 | DOM_REAL :: Temp,SumSr,VolumeTot
27 | DOM_INT, ALLOCATABLE, DIMENSION(:,:) :: patch
28 | DOM_REAL, ALLOCATABLE, DIMENSION(:) :: QwTot,Sr,Surface,Volume
29 | DOM_REAL, ALLOCATABLE, DIMENSION(:,:) :: Surf,Qw
30 | ! ---------------------------------------------------------!
31 | ! Version 2.04 output files with data in the cell'Surf center !
32 | ! ---------------------------------------------------------!
33 |
34 | OPEN (FILE_CHCS , FILE='balance_flux.choices', FORM='FORMATTED')
35 | READ (FILE_CHCS,*) path ! Path for outfiles *.in
36 | READ (FILE_CHCS,*) outpath ! Path for outfiles *.out
37 | CLOSE(FILE_CHCS)
38 |
39 | !-------------------------------------------!
40 | ! Read all datas !
41 | !-------------------------------------------!
42 | gdatfile = trim(path)//'/Global.in'
43 | clpropfile = trim(path)//'/CLProperties.in'
44 | volafile = trim(path)//'/Volumesareas.in'
45 | SrFile = trim(outpath)//'/Sr.out'
46 | QwFile = trim(outpath)//'/Qw.out'
47 |
48 | print*,' Read all the Datas'
49 | OPEN(FILE_GDATA, FILE=gdatfile , FORM='UNFORMATTED')
50 | OPEN(FILE_CLPRO,FILE=clpropfile, FORM='UNFORMATTED')
51 | OPEN(FILE_VOLA, FILE=volafile, FORM='UNFORMATTED')
52 | OPEN(FILE_Sr,FILE=SrFile,FORM='UNFORMATTED')
53 | OPEN(FILE_Qw,FILE=QwFile,FORM='UNFORMATTED')
54 |
55 | READ(FILE_GDATA) ntcells,ntnodes,ntfaces,ntfacesmax,ndirs
56 | print*,' - Global.in'
57 | ! Search the number of patch
58 | ALLOCATE(patch(ntcells,ntfacesmax))
59 | num_patch =0
60 | num_patchmax = 0
61 |
62 | DO icell=1,ntcells
63 | READ(FILE_CLPRO) i,nfaces,(temp,patch(i,l),l=1,nfaces)
64 | ENDDO
65 |
66 | num_patchmax = maxval(patch)
67 | print*,' - CLProperties.in'
68 | rewind(FILE_CLPRO)
69 |
70 | ALLOCATE(QwTot(num_patchmax+1)) ! Last row is the sum of the array
71 | ALLOCATE(Surface(num_patchmax+1)) ! Last row is the sum of the array
72 | ALLOCATE(Surf(ntcells,ntfacesmax))
73 | ALLOCATE(Qw(ntcells,ntfacesmax))
74 | ALLOCATE(Sr(ntcells))
75 | ALLOCATE(Volume(ntcells))
76 | QwTot = 0
77 | Qw = 0
78 | Surface = 0
79 |
80 | do i=1,ntcells
81 | READ(FILE_VOLA) icell,nfaces,Volume(icell),(Surf(icell,nface) &
82 | & ,nface=1,nfaces)
83 | READ(FILE_Sr) icell,Sr(icell)
84 | do j=1,nfaces
85 | if (patch(i,j) .eq. 0) cycle ! If not a BC, skip these step
86 | READ(FILE_Qw) nface,icell,Qw(icell,nface)
87 | enddo
88 | enddo
89 | print*,' - Sr.out'
90 | print*,' - Qw.out'
91 |
92 | !-------------------------------------------!
93 | ! Summation of Qw over patchs !
94 | !-------------------------------------------!
95 | SumSr=0
96 | VolumeTot=0
97 | QwTot =0
98 | Surface=0
99 | print*,' Makes the summation over all patches'
100 | do icell=1,ntcells
101 | SumSr = SumSr + Sr(icell)*Volume(icell)
102 | VolumeTot = VolumeTot +Volume(icell)
103 | do nface=1,nfaces
104 | if (patch(icell,nface) .eq. 0) cycle ! If not a BC, skip these step
105 | num_patch = patch(icell,nface)
106 | QwTot(num_patch) = Qwtot(num_patch) + Qw(icell,nface)* &
107 | & Surf(icell,nface)
108 | Surface(num_patch) = Surface(num_patch) + Surf(icell,nface)
109 | enddo
110 | enddo
111 |
112 | FMT= "(A20,ES14.4)"
113 | do i=1,num_patchmax
114 | WRITE(*,*) " -------------"
115 | WRITE(*,*) " Patch number :",i
116 | WRITE(*,FMT) " *-> Surface = ", Surface(i)
117 | WRITE(*,FMT) " *-> QwTot*Surface = ", QwTot(i)
118 | Qwtot(num_patchmax+1) = QwTot(num_patchmax+1) +Qwtot(i)
119 | Surface(num_patchmax+1) = Surface(num_patchmax+1) +Surface(i)
120 | enddo
121 |
122 | WRITE(*,*) " "
123 | WRITE(*,*) " ---------------------------------------"
124 | WRITE(*,FMT) " *-> Sum of all Qw*S =", QwTot(num_patchmax+1)
125 | WRITE(*,*) " -------------"
126 | WRITE(*,FMT) " *-> SumSr = ", SumSr
127 | WRITE(*,*) " -------------"
128 | WRITE(*,FMT) " *-> Diff = ", abs(QwTot(num_patchmax+1)-SumSr)
129 | WRITE(*,*) " -------------"
130 |
131 | CLOSE(FILE_GDATA)
132 | CLOSE(FILE_VOLA)
133 | CLOSE(FILE_Sr)
134 | CLOSE(FILE_Qw)
135 | END PROGRAM Balance_flux
Balance_flux.F could be called by: