2D AMRCLAW
valout.f
Go to the documentation of this file.
1 c
2 c -----------------------------------------------------
3 c
4  subroutine valout (lst, lend, time, nvar, naux)
5 c
6  use amr_module
7  implicit double precision (a-h,o-z)
8  character*10 fname1, fname2, fname3, fname4, fname5
9 
17 
18  logical outaux
19  integer output_aux_num
20  integer clock_start, clock_finish, clock_rate
21  real(kind=8) cpu_start, cpu_finish
22 
23 c iadd(i,j,ivar) = loc + i - 1 + mitot*((ivar-1)*mjtot+j-1)
24 c iaddaux(i,j,ivar) = locaux + i - 1 + mitot*((ivar-1)*mjtot+j-1)
25  iadd(ivar,i,j) = loc + ivar - 1 + nvar*((j-1)*mitot+i-1)
26  iaddaux(iaux,i,j) = locaux + iaux-1 + naux*(i-1) +
27  . naux*mitot*(j-1)
28 c
29 
30  call system_clock(clock_start,clock_rate)
31  call cpu_time(cpu_start)
32 
33 c # how many aux components requested?
34  output_aux_num = 0
35  do i=1,naux
36  output_aux_num = output_aux_num + output_aux_components(i)
37  enddo
38 
39 c # Currently outputs all aux components if any are requested!
40  outaux = ((output_aux_num > 0) .and.
41  . ((.not. output_aux_onlyonce) .or. (time==t0)))
42 
43 c open(unit=77,file='fort.b',status='unknown',access='stream')
44 
45 
46 c ### Python graphics output
47 c
48 
49 c ### make the file names and open output files
50  fname1 = 'fort.qxxxx'
51  fname2 = 'fort.txxxx'
52  fname3 = 'fort.axxxx'
53  fname4 = 'fort.bxxxx'
54  matunit1 = 50
55  matunit2 = 60
56  matunit3 = 70
57  matunit4 = 71
58  nstp = matlabu
59  do 55 ipos = 10, 7, -1
60  idigit = mod(nstp,10)
61  fname1(ipos:ipos) = char(ichar('0') + idigit)
62  fname2(ipos:ipos) = char(ichar('0') + idigit)
63  fname3(ipos:ipos) = char(ichar('0') + idigit)
64  fname4(ipos:ipos) = char(ichar('0') + idigit)
65  nstp = nstp / 10
66  55 continue
67 
68  open(unit=matunit1,file=fname1,status='unknown',
69  . form='formatted')
70 
71  if (output_format == 3) then
72 c # binary output
73  open(unit=matunit4,file=fname4,status='unknown',
74  & access='stream')
75  endif
76 
77  level = lst
78  ngrids = 0
79 c65 if (level .gt. lfine) go to 90
80  65 if (level .gt. lend) go to 90
81  mptr = lstart(level)
82  70 if (mptr .eq. 0) go to 80
83  ngrids = ngrids + 1
84  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
85  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
86  loc = node(store1, mptr)
87  locaux = node(storeaux,mptr)
88  mitot = nx + 2*nghost
89  mjtot = ny + 2*nghost
90  if (ny.gt.1) then
91  write(matunit1,1001) mptr, level, nx, ny
92  else
93 c # output in 1d format if ny=1:
94  write(matunit1,1003) mptr, level, nx
95  endif
96  1001 format(i6,' grid_number',/,
97  & i6,' AMR_level',/,
98  & i6,' mx',/,
99  & i6,' my')
100  1003 format(i6,' grid_number',/,
101  & i6,' AMR_level',/,
102  & i6,' mx')
103 
104 
105  xlow = rnode(cornxlo,mptr)
106  ylow = rnode(cornylo,mptr)
107  if (ny.gt.1) then
108  write(matunit1,1002)
109  & xlow,ylow,hxposs(level),hyposs(level)
110  else
111  write(matunit1,1004)
112  & xlow,hxposs(level)
113  endif
114  1002 format(e26.16,' xlow', /,
115  & e26.16,' ylow', /,
116  & e26.16,' dx', /,
117  & e26.16,' dy',/)
118  1004 format(e26.16,' xlow', /,
119  & e26.16,' dx', /)
120 
121 
122  if (output_format == 1) then
123  do j = nghost+1, mjtot-nghost
124  do i = nghost+1, mitot-nghost
125  do ivar=1,nvar
126  if (abs(alloc(iadd(ivar,i,j))) < 1d-90) then
127  alloc(iadd(ivar,i,j)) = 0.d0
128  endif
129  enddo
130  write(matunit1,109)
131  & (alloc(iadd(ivar,i,j)), ivar=1,nvar)
132  enddo
133  write(matunit1,*) ' '
134  enddo
135  109 format(50e26.16)
136  endif
137 
138  if (output_format == 3) then
139 c # binary output
140  i1 = iadd(1,1,1)
141  i2 = iadd(nvar,mitot,mjtot)
142 c # NOTE: we are writing out ghost cell data also, unlike ascii
143  write(matunit4) alloc(i1:i2)
144  endif
145 
146  mptr = node(levelptr, mptr)
147  go to 70
148  80 level = level + 1
149  go to 65
150 
151  90 continue
152 
153 c -------------------
154 c # output aux arrays
155 c -------------------
156 
157  if (outaux) then
158 c # output aux array to fort.aXXXX
159 
160  level = lst
161  165 if (level .gt. lfine) go to 190
162  mptr = lstart(level)
163  170 if (mptr .eq. 0) go to 180
164  nx = node(ndihi,mptr) - node(ndilo,mptr) + 1
165  ny = node(ndjhi,mptr) - node(ndjlo,mptr) + 1
166  locaux = node(storeaux,mptr)
167  mitot = nx + 2*nghost
168  mjtot = ny + 2*nghost
169 
170 
171  if (output_format == 1) then
172  open(unit=matunit3,file=fname3,status='unknown',
173  . form='formatted')
174  if (ny.gt.1) then
175  write(matunit3,1001) mptr, level, nx, ny
176  else
177 c # output in 1d format if ny=1:
178  write(matunit3,1003) mptr, level, nx
179  endif
180  xlow = rnode(cornxlo,mptr)
181  ylow = rnode(cornylo,mptr)
182  if (ny.gt.1) then
183  write(matunit3,1002)
184  & xlow,ylow,hxposs(level),hyposs(level)
185  else
186  write(matunit3,1004)
187  & xlow,hxposs(level)
188  endif
189 
190  do j = nghost+1, mjtot-nghost
191  do i = nghost+1, mitot-nghost
192  do ivar=1,naux
193  if (abs(alloc(iaddaux(ivar,i,j))) .lt. 1d-90)
194  & alloc(iaddaux(ivar,i,j)) = 0.d0
195  enddo
196  write(matunit3,109) (alloc(iaddaux(ivar,i,j)),
197  & ivar=1,naux)
198  enddo
199  write(matunit3,*) ' '
200  enddo
201  endif
202 
203  if (output_format == 3) then
204 c # binary output
205  open(unit=matunit3,file=fname3,status='unknown',
206  & access='stream')
207  i1 = iaddaux(1,1,1)
208  i2 = iaddaux(naux,mitot,mjtot)
209 c # NOTE: we are writing out ghost cell data also, unlike ascii
210  write(matunit3) alloc(i1:i2)
211  endif
212 
213 
214  mptr = node(levelptr, mptr)
215  go to 170
216  180 level = level + 1
217  go to 165
218 
219  190 continue
220  close(unit=matunit3)
221  endif !# end outputting aux array
222 
223 
224 c --------------
225 c # fort.t file:
226 c --------------
227 
228  open(unit=matunit2,file=fname2,status='unknown',
229  . form='formatted')
230  if (ny.gt.1) then
231  ndim = 2
232  else
233 c # special case where 2d AMR is used for a 1d problem
234 c # and we want to use 1d plotting routines
235  ndim = 1
236  endif
237 
238 c # NOTE: we need to print out nghost too in order to strip
239 c # ghost cells from q when reading in pyclaw.io.binary
240  write(matunit2,1000) time,nvar,ngrids,naux,ndim,nghost
241  1000 format(e18.8,' time', /,
242  & i6,' meqn'/,
243  & i6,' ngrids'/,
244  & i6,' naux'/,
245  & i6,' ndim'/,
246  & i6,' nghost'/,/)
247 c
248 
249  write(6,601) matlabu,time
250  601 format('AMRCLAW: Frame ',i4,
251  & ' output files done at time t = ', d13.6,/)
252 
253  matlabu = matlabu + 1
254 
255  close(unit=matunit1)
256  close(unit=matunit2)
257  if (output_format == 3) then
258  close(unit=matunit4)
259  endif
260 
261  call system_clock(clock_finish,clock_rate)
262  call cpu_time(cpu_finish)
263  timevalout = timevalout + clock_finish - clock_start
264  timevaloutcpu = timevaloutcpu + cpu_finish - cpu_start
265 
266  return
267  end
real(kind=8) t0
Definition: amr_module.f90:272
logical output_aux_onlyonce
Definition: amr_module.f90:277
integer, parameter cornxlo
x-coordinate of the left border of this grid
Definition: amr_module.f90:143
real(kind=8), dimension(maxlv) hyposs
Definition: amr_module.f90:193
real(kind=8), dimension(maxlv) hxposs
Definition: amr_module.f90:193
integer, parameter ndihi
global i index of right border of this grid
Definition: amr_module.f90:111
subroutine valout(lst, lend, time, nvar, naux)
Definition: valout.f:5
integer, dimension(nsize, maxgr) node
Definition: amr_module.f90:198
real(kind=8), dimension(rsize, maxgr) rnode
Definition: amr_module.f90:193
integer pure function iadd(ivar, i, j)
Definition: intfil.f90:294
real(kind=8) timevaloutcpu
Definition: amr_module.f90:245
integer matlabu
Definition: amr_module.f90:283
integer, parameter ndilo
global i index of left border of this grid
Definition: amr_module.f90:108
integer, parameter ndjlo
global j index of lower border of this grid
Definition: amr_module.f90:114
integer, parameter store1
pointer to the address of memory storing the first copy of solution data on this grid, usually for storing new solution
Definition: amr_module.f90:101
integer, dimension(maxlv) lstart
Definition: amr_module.f90:198
integer output_format
Definition: amr_module.f90:274
integer, parameter ndjhi
global j index of upper border of this grid
Definition: amr_module.f90:117
integer, parameter cornylo
y-coordinate of the lower border of this grid
Definition: amr_module.f90:145
integer, parameter levelptr
node number (index) of next grid on the same level
Definition: amr_module.f90:35
integer, dimension(:), allocatable output_aux_components
Definition: amr_module.f90:276
integer nghost
Definition: amr_module.f90:232
The module contains the definition of a "node descriptor" as well as other global variables used duri...
Definition: amr_module.f90:21
integer timevalout
Definition: amr_module.f90:239
integer lfine
Definition: amr_module.f90:198
integer, parameter storeaux
pointer to the address of memory storing auxiliary data on this grid
Definition: amr_module.f90:120
real(kind=8), dimension(:), allocatable alloc
Definition: amr_module.f90:218