Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLO_ReadStat.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 !******************************************************************************
24 !
25 ! Purpose: read in time averaged statistics of the mixture.
26 !
27 ! Description: the following solution formats are supported:
28 ! - RocfloMP ASCII
29 ! - RocfloMP binary
30 !
31 ! Input: regions = dimensions of all regions
32 !
33 ! Output: region%levels%mixt%tav = time avg mixture variables (current grid level)
34 ! region%levels%turb%tav = time avg TURB variables (current grid level)
35 ! global%integrTime = integrated averaging time
36 !
37 ! Notes: time averaged solution is read in only for the current grid level;
38 ! it is also read in for all dummy cells
39 !
40 !******************************************************************************
41 !
42 ! $Id: RFLO_ReadStat.F90,v 1.3 2008/12/06 08:44:07 mtcampbe Exp $
43 !
44 ! Copyright: (c) 2001 by the University of Illinois
45 !
46 !******************************************************************************
47 
48 SUBROUTINE rflo_readstat( regions )
49 
50  USE moddatatypes
51  USE moddatastruct, ONLY : t_region
52  USE modglobal, ONLY : t_global
55  USE moderror
56  USE modmpi
57  USE modparameters
58  IMPLICIT NONE
59 
60 #include "Indexing.h"
61 
62 ! ... parameters
63  TYPE(t_region), POINTER :: regions(:)
64 
65 ! ... loop variables
66  INTEGER :: ireg, i, j, k, l, n, ind
67 
68 ! ... local variables
69  CHARACTER(2*CHRLEN+17) :: fname
70  CHARACTER(CHRLEN) :: msg
71 
72 #ifdef MPI
73  INTEGER :: status(mpi_status_size)
74 #endif
75  INTEGER :: ilev, iregfile, ipc, jpc, kpc, ndumcells, ndim, ioff, ijoff, ijk
76  INTEGER :: idcbeg, jdcbeg, kdcbeg, idcend, jdcend, kdcend, ijkbeg, ijkend
77  INTEGER :: mixtvarid(2,regions(1)%global%mixtnstat)
78  INTEGER :: turbvarid(2,regions(1)%global%turbnstat)
79  INTEGER :: ntavgvar, maxnstat, allnstat, errorflag
80  INTEGER, ALLOCATABLE :: ivar(:,:), jvar(:,:)
81 
82  REAL(RFREAL), POINTER :: mixttav(:,:), turbtav(:,:)
83  REAL(RFREAL), ALLOCATABLE :: rvar(:,:), tavfile(:,:)
84 
85  TYPE(t_global), POINTER :: global
86 
87 !******************************************************************************
88 
89  global => regions(1)%global
90 
91  CALL registerfunction( global,'RFLO_ReadStat',&
92  'RFLO_ReadStat.F90' )
93 
94 ! allocate temporary data arrays --------------------------------------------
95 
96  ALLOCATE( ivar(5,1),stat=errorflag )
97  ALLOCATE( rvar(2,1),stat=errorflag )
98  maxnstat = global%mixtNStat
99 #ifdef TURB
100  IF (global%turbNStat>0) maxnstat = max( global%mixtNStat,global%turbNStat )
101 #endif
102  ALLOCATE( jvar(maxnstat+1,1),stat=errorflag )
103  global%error = errorflag
104  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
105 
106 ! open statistics file (only master proc.) ----------------------------------
107 
108  IF (global%myProcid == masterproc) THEN
109 
110  IF (global%solutFormat == format_ascii) THEN
111  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.stata_', &
112  global%timeStamp
113  OPEN(if_stat,file=fname,form='formatted',status='old',iostat=errorflag)
114  ELSE IF (global%solutFormat == format_binary) THEN
115  WRITE(fname,'(A,1PE11.5)') trim(global%inDir)//trim(global%casename)//'.statb_', &
116  global%timeStamp
117  OPEN(if_stat,file=fname,form='unformatted',status='old',iostat=errorflag)
118  ELSE
119  CALL errorstop( global,err_unknown_format,__line__ )
120  ENDIF
121 
122  global%error = errorflag
123  IF (global%error /= 0) &
124  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
125 
126  ENDIF ! MASTERPROC
127 
128 ! read & broadcast current and integrated time in file, and stats ID ---------------
129 
130  IF (global%myProcid == masterproc) THEN
131  CALL rflo_readdatafilereal( global,if_stat,global%solutFormat,2,1,rvar )
132  ENDIF
133 
134 #ifdef MPI
135  CALL mpi_bcast( rvar,2,mpi_rfreal,masterproc,global%mpiComm,global%mpierr )
136  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
137 #endif
138 
139  IF (global%flowType==flow_unsteady .AND. global%currentTime>0._rfreal) THEN
140  IF (global%currentTime /= rvar(1,1)) THEN
141  WRITE(msg,1000) rvar(1,1),global%currentTime
142  CALL errorstop( global,err_time_solution,__line__,msg//' File: '//trim(fname) )
143  ENDIF
144  ELSE
145  global%currentTime = rvar(1,1)
146  ENDIF
147  global%integrTime = rvar(2,1)
148 
149  IF (global%myProcid == masterproc) THEN
150 
151 ! - mixture statistics NSTATS and ID
152 
153  IF (global%mixtNStat > 0) THEN
154  CALL rflo_readdatafileint( global,if_stat,global%solutFormat, &
155  global%mixtNStat+1,1,jvar )
156  ntavgvar = jvar(1,1)
157  IF (ntavgvar /= global%mixtNStat) THEN
158  CALL errorstop( global,err_stats_restart,__line__ )
159  ENDIF
160 
161  mixtvarid(1,:) = jvar(2:global%mixtNStat+1,1)
162  mixtvarid(2,:) = mod(mixtvarid(1,:),10)
163  mixtvarid(1,:) = (mixtvarid(1,:)-mixtvarid(2,:))/10
164 
165  DO ind=1,2
166  DO l=1,global%mixtNStat
167  IF (mixtvarid(ind,l) /= global%mixtStatId(ind,l)) &
168  CALL errorstop( global,err_stats_restart,__line__ )
169  ENDDO
170  ENDDO
171  ENDIF
172 
173 ! - turbulence statistics NSTATS and ID
174 
175 #ifdef TURB
176  IF (global%turbNStat > 0) THEN
177  CALL rflo_readdatafileint( global,if_stat,global%solutFormat, &
178  global%turbNStat+1,1,jvar )
179  ntavgvar = jvar(1,1)
180  IF (ntavgvar /= global%turbNStat) THEN
181  CALL errorstop( global,err_stats_restart,__line__ )
182  ENDIF
183 
184  turbvarid(1,:) = jvar(2:global%turbNStat+1,1)
185  turbvarid(2,:) = mod(turbvarid(1,:),10)
186  turbvarid(1,:) = (turbvarid(1,:)-turbvarid(2,:))/10
187 
188  DO ind=1,2
189  DO l=1,global%turbNStat
190  IF (turbvarid(ind,l) /= global%turbStatId(ind,l)) &
191  CALL errorstop( global,err_stats_restart,__line__ )
192  ENDDO
193  ENDDO
194  ENDIF
195 #endif
196  ENDIF
197 
198 ! read statistics data from all regions ------------------------------------------
199 
200  allnstat = global%mixtNStat+global%turbNStat
201 
202  DO ireg=1,global%nRegions
203 
204 ! - get dimensions and pointers
205 
206  ilev = regions(ireg)%currLevel
207  CALL rflo_getdimensdummy( regions(ireg),ilev,idcbeg,idcend, &
208  jdcbeg,jdcend,kdcbeg,kdcend )
209  CALL rflo_getcelloffset( regions(ireg),ilev,ioff,ijoff )
210  ijkbeg = indijk(idcbeg,jdcbeg,kdcbeg,ioff,ijoff)
211  ijkend = indijk(idcend,jdcend,kdcend,ioff,ijoff)
212  ndim = ijkend - ijkbeg + 1
213 
214 ! - read region number and dimensions (only master)
215 
216  IF (global%myProcid == masterproc) THEN
217  CALL rflo_readdatafileint( global,if_stat,global%solutFormat,5,1,ivar )
218  iregfile = ivar(1,1)
219  ipc = ivar(2,1)
220  jpc = ivar(3,1)
221  kpc = ivar(4,1)
222  ndumcells = ivar(5,1)
223 
224  IF (iregfile /= ireg) &
225  CALL errorstop( global,err_region_number,__line__,'File: '//trim(fname) )
226  IF ((ipc /= regions(ireg)%levels(ilev)%grid%ipc) .OR. &
227  (jpc /= regions(ireg)%levels(ilev)%grid%jpc) .OR. &
228  (kpc /= regions(ireg)%levels(ilev)%grid%kpc)) THEN
229  WRITE(msg,1005) ireg,ipc,jpc,kpc
230  CALL errorstop( global,err_grid_dimensions,__line__,msg )
231  ENDIF
232  IF (ndumcells /= regions(ireg)%nDumCells) THEN
233  WRITE(msg,1010) ireg,ndumcells,regions(ireg)%nDumCells
234  CALL errorstop( global,err_grid_dumcells,__line__,msg )
235  ENDIF
236 
237 ! - master reads & sends data, others receive them
238 
239  ALLOCATE( tavfile(allnstat,ndim),stat=errorflag )
240  global%error = errorflag
241  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
242 
243  CALL rflo_readdatafilereal( global,if_stat,global%solutFormat, &
244  allnstat,ndim,tavfile )
245 #ifdef MPI
246  IF (regions(ireg)%procid /= masterproc) THEN
247  CALL mpi_send( tavfile,allnstat*ndim,mpi_rfreal, &
248  regions(ireg)%procid,ireg, &
249  global%mpiComm,global%mpierr )
250  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
251  ENDIF
252 #endif
253  ELSE ! not the master
254 
255  IF (regions(ireg)%procid == global%myProcid) THEN
256  ALLOCATE( tavfile(allnstat,ndim),stat=errorflag )
257  global%error = errorflag
258  IF (global%error /= 0) CALL errorstop( global,err_allocate,__line__ )
259 #ifdef MPI
260  CALL mpi_recv( tavfile,allnstat*ndim,mpi_rfreal,masterproc, &
261  ireg,global%mpiComm,status,global%mpierr )
262  IF (global%mpierr /=0 ) CALL errorstop( global,err_mpi_trouble,__line__ )
263 #endif
264  ENDIF
265 
266  ENDIF ! global%myProcid
267 
268 ! - copy statistics into data structure
269 
270  IF (regions(ireg)%procid == global%myProcid) THEN
271  IF (global%mixtNStat > 0) mixttav => regions(ireg)%levels(ilev)%mixt%tav
272  n = 0
273  DO k=kdcbeg,kdcend
274  DO j=jdcbeg,jdcend
275  DO i=idcbeg,idcend
276  n = n + 1
277  ijk = indijk(i,j,k,ioff,ijoff)
278  DO l=1,global%mixtNStat
279  mixttav(l,ijk) = tavfile(l,n)
280  ENDDO
281  ENDDO
282  ENDDO
283  ENDDO
284 #ifdef TURB
285  IF (global%turbNStat > 0) THEN
286  IF ((regions(ireg)%mixtInput%flowModel == flow_navst) .AND. &
287  (regions(ireg)%mixtInput%turbModel /= turb_model_none)) THEN
288  turbtav => regions(ireg)%levels(ilev)%turb%tav
289  n = 0
290  DO k=kdcbeg,kdcend
291  DO j=jdcbeg,jdcend
292  DO i=idcbeg,idcend
293  n = n + 1
294  ijk = indijk(i,j,k,ioff,ijoff)
295  DO l=1,global%turbNStat
296  turbtav(l,ijk) = tavfile(l+global%mixtNStat,n)
297  ENDDO
298  ENDDO
299  ENDDO
300  ENDDO
301  ENDIF
302  ENDIF
303 #endif
304  ENDIF
305 
306  IF (ALLOCATED(tavfile)) THEN
307  DEALLOCATE( tavfile,stat=errorflag )
308  global%error = errorflag
309  IF (global%error /= 0) CALL errorstop( global,err_deallocate,__line__ )
310  ENDIF
311 
312  ENDDO ! iReg
313 
314 ! finalize -----------------------------------------------------------------
315 
316  IF (global%myProcid == masterproc) THEN
317  CLOSE(if_stat,iostat=errorflag)
318  global%error = errorflag
319  IF (global%error /= 0) &
320  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
321  ENDIF
322 
323  CALL deregisterfunction( global )
324 
325 1000 FORMAT('Time in file is= ',1pe12.5,' but it should be= ',e12.5,'.')
326 1005 FORMAT('Region ',i5,', ipc= ',i6,', jpc= ',i6,', kpc= ',i6,'.')
327 1010 FORMAT('Region ',i5,', # dummy cells=',i2,' but should be= ',i1)
328 
329 END SUBROUTINE rflo_readstat
330 
331 !******************************************************************************
332 !
333 ! RCS Revision history:
334 !
335 ! $Log: RFLO_ReadStat.F90,v $
336 ! Revision 1.3 2008/12/06 08:44:07 mtcampbe
337 ! Updated license.
338 !
339 ! Revision 1.2 2008/11/19 22:17:21 mtcampbe
340 ! Added Illinois Open Source License/Copyright
341 !
342 ! Revision 1.1 2004/11/29 21:25:17 wasistho
343 ! lower to upper case
344 !
345 ! Revision 1.14 2004/11/09 10:51:48 wasistho
346 ! provide maximum size for jvar
347 !
348 ! Revision 1.13 2003/11/20 16:40:34 mdbrandy
349 ! Backing out RocfluidMP changes from 11-17-03
350 !
351 ! Revision 1.10 2003/08/11 20:12:51 wasistho
352 ! put safety in reading turbulence statistics
353 !
354 ! Revision 1.9 2003/05/15 02:57:01 jblazek
355 ! Inlined index function.
356 !
357 ! Revision 1.8 2002/11/04 18:41:57 wasistho
358 ! Modified statistics restart
359 !
360 ! Revision 1.7 2002/11/02 01:47:23 wasistho
361 ! Added TURB statistics
362 !
363 ! Revision 1.6 2002/10/23 18:43:24 jblazek
364 ! Changed temporary pointer arrays into allocatable arrays
365 ! in grid and solution I/O routines.
366 !
367 ! Revision 1.5 2002/10/12 03:20:50 jblazek
368 ! Replaced [io]stat=global%error with local errorFlag for Rocflo.
369 !
370 ! Revision 1.4 2002/09/20 22:22:35 jblazek
371 ! Finalized integration into GenX.
372 !
373 ! Revision 1.3 2002/09/05 17:40:19 jblazek
374 ! Variable global moved into regions().
375 !
376 ! Revision 1.2 2002/07/22 15:44:08 wasistho
377 ! Cleaned-up conforming Coding Rule
378 !
379 ! Revision 1.1 2002/06/14 20:53:05 wasistho
380 ! add time avg statistics
381 !
382 !******************************************************************************
383 
384 
385 
386 
387 
388 
389 
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE idcend
j indices k indices k
Definition: Indexing.h:6
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine rflo_readdatafileint(global, fileId, form, nDim1, nDim2, ivar)
subroutine rflo_readstat(regions)
subroutine rflo_getdimensdummy(region, iLev, idcbeg, idcend, jdcbeg, jdcend, kdcbeg, kdcend)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE kdcbeg
blockLoc i
Definition: read.cpp:79
subroutine rflo_getcelloffset(region, iLev, iCellOffset, ijCellOffset)
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE idcbeg
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE form
const NT & n
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jdcend
j indices j
Definition: Indexing.h:6
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **Arising OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE **********************************************************************INTERFACE SUBROUTINE jdcbeg
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflo_readdatafilereal(global, fileId, form, nDim1, nDim2, var)