Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TURB_rFLU_ReadSolutionASCII.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 file for turbulence quantities in ASCII ROCFLU format.
26 !
27 ! Description: None.
28 !
29 ! Input: pRegion = Pointer to region
30 !
31 ! Output: None.
32 !
33 ! Notes: None.
34 !
35 ! ******************************************************************************
36 !
37 ! $Id: TURB_rFLU_ReadSolutionASCII.F90,v 1.6 2009/08/26 12:28:53 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2004 by the University of Illinois
40 !
41 ! ******************************************************************************
42 
43 SUBROUTINE turb_rflu_readsolutionascii( region ) ! PUBLIC
44 
45  USE moddatatypes
46  USE modglobal, ONLY : t_global
47  USE moddatastruct, ONLY: t_region
48  USE modgrid, ONLY : t_grid
49  USE moderror
50  USE modmpi
51  USE modparameters
52 
55 
57 
58  IMPLICIT NONE
59 
60 ! ... arguments
61  TYPE(t_region), POINTER :: region
62 
63 ! ... loop variables
64  INTEGER :: ivars, j
65 
66 ! ... local variables
67  CHARACTER(CHRLEN) :: errorstring,ifilename,sectionstring,rcsidentstring, &
68  timestring1,timestring2
69  TYPE(t_grid), POINTER :: grid
70  TYPE(t_global), POINTER :: global
71 
72  INTEGER :: errorflag,ifile,loopcounter,ncellstot,ncellsexpected,nvars, &
73  nvarsexpected,precactual,precexpected,rangeactual,rangeexpected
74  REAL(RFREAL) :: currenttime
75  REAL(RFREAL), DIMENSION(:,:), POINTER :: tv, tcv, vort
76  REAL(RFREAL), DIMENSION(:), POINTER :: lens
77 
78 ! ******************************************************************************
79 ! Start, open file
80 ! ******************************************************************************
81 
82  rcsidentstring = '$RCSfile: TURB_rFLU_ReadSolutionASCII.F90,v $ $Revision: 1.6 $'
83 
84  global => region%global
85  CALL registerfunction(global,'TURB_RFLU_ReadSolutionASCII',&
86  'TURB_rFLU_ReadSolutionASCII.F90')
87 
88 #ifdef GENX
89  goto 999 ! Genx doesn't need to read turbulence solution file
90 #endif
91 
92  IF ( global%myProcid == masterproc .AND. &
93  global%verbLevel > verbose_none ) THEN
94  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII turbulence file...'
95  END IF ! global%verbLevel
96 
97  IF ( global%flowType == flow_unsteady ) THEN
98  currenttime = global%currentTime
99 
100  CALL buildfilenameunsteady(global,filedest_indir,'.turba', &
101  region%iRegionGlobal,currenttime,ifilename)
102 
103  IF ( global%myProcid == masterproc .AND. &
104  global%verbLevel > verbose_none ) THEN
105  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
106  region%iRegionGlobal
107  WRITE(stdout,'(A,3X,A,1X,1PE11.5)') solver_name,'Current time:', &
108  currenttime
109  END IF ! global%verbLevel
110  ELSE
111  CALL buildfilenamesteady(global,filedest_indir,'.turba', &
112  region%iRegionGlobal,global%currentIter,ifilename)
113 
114  IF ( global%myProcid == masterproc .AND. &
115  global%verbLevel > verbose_none ) THEN
116  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
117  region%iRegionGlobal
118  WRITE(stdout,'(A,3X,A,1X,I6.6)') solver_name,'Current iteration '// &
119  'number:',global%currentIter
120  END IF ! global%verbLevel
121  ENDIF ! global%flowType
122 
123  ifile = if_solut
124  OPEN(ifile,file=ifilename,form="FORMATTED",status="OLD", &
125  iostat=errorflag)
126  global%error = errorflag
127  IF ( global%error /= err_none ) THEN
128  CALL errorstop(global,err_file_open,__line__,ifilename)
129  END IF ! global%error
130 
131 ! ==============================================================================
132 ! Header and general information
133 ! ==============================================================================
134 
135  IF ( global%myProcid == masterproc .AND. &
136  global%verbLevel > verbose_low ) THEN
137  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
138  END IF ! global%verbLevel
139 
140  READ(ifile,'(A)') sectionstring
141  IF ( trim(sectionstring) /= '# ROCTURB solution file' ) THEN
142  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
143  END IF ! TRIM
144 
145 ! -----------------------------------------------------------------------------
146 ! Precision and range
147 ! -----------------------------------------------------------------------------
148 
149  READ(ifile,'(A)') sectionstring
150  IF ( trim(sectionstring) /= '# Precision and range' ) THEN
151  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
152  END IF ! TRIM
153 
154  precexpected = precision(1.0_rfreal)
155  rangeexpected = range(1.0_rfreal)
156 
157  READ(ifile,'(2(I8))') precactual,rangeactual
158  IF ( precactual < precexpected .OR. rangeactual < rangeexpected ) THEN
159  CALL errorstop(global,err_prec_range,__line__)
160  END IF ! precActual
161 
162 ! -----------------------------------------------------------------------------
163 ! Initial residual (for RaNS), physical time, and energy subgrid quantities
164 ! -----------------------------------------------------------------------------
165 
166  READ(ifile,'(A)') sectionstring
167  IF ( trim(sectionstring) /= '# Initial residual' ) THEN
168  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
169  END IF ! TRIM
170 
171  READ(ifile,'(E23.16)') global%resInit
172 
173  READ(ifile,'(A)') sectionstring
174  IF ( trim(sectionstring) /= '# Physical time' ) THEN
175  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
176  END IF ! TRIM
177 
178  READ(ifile,'(E23.16)') currenttime
179 
180  IF ( global%flowType == flow_unsteady ) THEN
181  IF ( global%currentTime < 0.0_rfreal ) THEN
182  global%currentTime = currenttime
183  ELSE
184  WRITE(timestring1,'(1PE11.5)') global%currentTime
185  WRITE(timestring2,'(1PE11.5)') currenttime
186  IF ( trim(timestring1) /= trim(timestring2) ) THEN
187  CALL errorstop(global,err_time_solution,__line__,trim(ifilename))
188  END IF ! global%currentTime
189  END IF ! global%currentTime
190  END IF ! global%flowType
191 
192  READ(ifile,'(A)') sectionstring
193  IF ( trim(sectionstring) /= '# Esg1Sum' ) THEN
194  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
195  END IF ! TRIM
196 
197  READ(ifile,'(E23.16)') global%esg1Sum
198 
199  READ(ifile,'(A)') sectionstring
200  IF ( trim(sectionstring) /= '# Esg4Sum' ) THEN
201  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
202  END IF ! TRIM
203 
204  READ(ifile,'(E23.16)') global%esg4Sum
205 
206 ! ==============================================================================
207 ! Dimensions
208 ! ==============================================================================
209 
210  grid => region%grid
211 
212  nvarsexpected = region%turbInput%nOutField
213  ncellsexpected = grid%nCellsTot
214 
215  READ(ifile,'(A)') sectionstring
216  IF ( trim(sectionstring) /= '# Dimensions' ) THEN
217  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
218  END IF ! TRIM
219 
220  READ(ifile,'(2(I8))') ncellstot,nvars
221  IF ( ncellstot /= ncellsexpected ) THEN
222  WRITE(errorstring,'(A,1X,I6,1X,A,1X,I6))') 'Specified:',ncellstot, &
223  'but expected:',ncellsexpected
224  CALL errorstop(global,err_invalid_ncells,__line__,errorstring)
225  END IF ! nCellsExpected
226 
227  IF ( nvars /= nvarsexpected ) THEN
228  WRITE(errorstring,'(A,1X,I6,1X,A,1X,I6))') 'Specified:',nvars, &
229  'but expected:',nvarsexpected
230  CALL errorstop(global,err_invalid_nvars,__line__)
231  END IF ! nVarsExpected
232 
233 ! ==============================================================================
234 ! Rest of file
235 ! ==============================================================================
236 
237  ivars = 0
238  loopcounter = 0
239 
240  DO ! set up infinite loop
241  loopcounter = loopcounter + 1
242 
243  READ(ifile,'(A)') sectionstring
244 
245  SELECT CASE ( trim(sectionstring) )
246 
247 ! ------------------------------------------------------------------------------
248 ! Eddy viscosity
249 ! ------------------------------------------------------------------------------
250 
251  CASE ( '# Eddy viscosity' )
252  IF ( global%myProcid == masterproc .AND. &
253  global%verbLevel > verbose_low ) THEN
254  WRITE(stdout,'(A,3X,A)') solver_name,'Eddy viscosity...'
255  END IF ! global%verbLevel
256 
257  IF (region%turbInput%modelClass == model_les) THEN
258  tv => region%mixt%tv
259 
260  ivars = ivars + 1
261  READ(ifile,'(5(E23.16))') (tv(tv_mixt_muet,j),j=1,grid%nCellsTot)
262 
263  IF (ASSOCIATED( region%turb%postv ) .eqv. .true.) THEN
264  region%turb%postv(1,:) = tv(tv_mixt_muet,:)
265  ENDIF
266  ELSEIF (region%turbInput%modelClass == model_rans) THEN
267  tcv => region%turb%cv
268 
269  ivars = ivars + 1
270  READ(ifile,'(5(E23.16))') (tcv(cv_sa_nutil,j),j=1,grid%nCellsTot)
271 
272  IF (ASSOCIATED( region%turb%postv ).eqv. .true.) THEN
273  region%turb%postv(1,:) = tcv(cv_sa_nutil,:)
274  ENDIF
275  ENDIF
276 
277 ! ------------------------------------------------------------------------------
278 ! Total vorticity
279 ! ------------------------------------------------------------------------------
280 
281  CASE ( '# Total vorticity' )
282  IF ( global%myProcid == masterproc .AND. &
283  global%verbLevel > verbose_low ) THEN
284  WRITE(stdout,'(A,3X,A)') solver_name,'Total vorticity...'
285  END IF ! global%verbLevel
286 
287  vort => region%turb%vort
288 
289  ivars = ivars + 1
290  READ(ifile,'(5(E23.16))') (vort(xcoord,j),j=1,grid%nCellsTot)
291 
292 ! ------------------------------------------------------------------------------
293 ! RaNS or DES length scale
294 ! ------------------------------------------------------------------------------
295 
296  CASE ( '# RANS length scale' )
297  IF ( global%myProcid == masterproc .AND. &
298  global%verbLevel > verbose_low ) THEN
299  WRITE(stdout,'(A,3X,A)') solver_name,'RaNS length scale...'
300  END IF ! global%verbLevel
301 
302  lens => region%turb%lens
303 
304  ivars = ivars + 1
305  READ(ifile,'(5(E23.16))') (lens(j),j=1,grid%nCellsTot)
306 
307  IF (ASSOCIATED( region%turb%postv ) .eqv. .true.) THEN
308  region%turb%postv(2,:) = lens(:)
309  ENDIF
310 
311 ! ------------------------------------------------------------------------------
312 ! End marker
313 ! ------------------------------------------------------------------------------
314 
315  CASE ( '# End' )
316  IF ( global%myProcid == masterproc .AND. &
317  global%verbLevel > verbose_low ) THEN
318  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
319  END IF ! global%verbLevel
320 
321  EXIT
322 
323 ! ------------------------------------------------------------------------------
324 ! Invalid section string
325 ! ------------------------------------------------------------------------------
326 
327  CASE default
328  IF ( global%verbLevel > verbose_low ) THEN
329  WRITE(stdout,'(A,3X,A)') solver_name,sectionstring
330  END IF ! verbosityLevel
331 
332  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
333 
334  END SELECT ! TRIM
335 
336 ! ------------------------------------------------------------------------------
337 ! Guard against infinite loop - might be unnecessary because of read errors?
338 ! ------------------------------------------------------------------------------
339 
340  IF ( loopcounter >= limit_infinite_loop ) THEN
341  CALL errorstop(global,err_infinite_loop,__line__)
342  END IF ! loopCounter
343 
344  END DO ! <empty>
345 
346 ! ==============================================================================
347 ! Check and information about number of variables read
348 ! ==============================================================================
349 
350  IF ( ivars /= nvars ) THEN
351  CALL errorstop(global,err_invalid_nvars,__line__)
352  END IF ! iVar
353 
354 ! ==============================================================================
355 ! Close file
356 ! ==============================================================================
357 
358  CLOSE(ifile,iostat=errorflag)
359  global%error = errorflag
360  IF ( global%error /= err_none ) THEN
361  CALL errorstop(global,err_file_close,__line__,ifilename)
362  END IF ! global%error
363 
364  IF ( global%myProcid == masterproc .AND. &
365  global%verbLevel > verbose_none ) THEN
366  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII turbulence file done.'
367  END IF ! global%verbLevel
368 
369 ! finalize --------------------------------------------------------------------
370 
371 999 CONTINUE
372 
373  CALL deregisterfunction(global)
374 
375 ! ******************************************************************************
376 ! End
377 ! ******************************************************************************
378 
379 END SUBROUTINE turb_rflu_readsolutionascii
380 
381 
382 ! ******************************************************************************
383 !
384 ! RCS Revision history:
385 !
386 ! $Log: TURB_rFLU_ReadSolutionASCII.F90,v $
387 ! Revision 1.6 2009/08/26 12:28:53 mtcampbe
388 ! Ported to Hera. Fixed logical expression syntax errors. Replaced all
389 ! IF (logical_variable) with IF (logical_variable .eqv. .true.) as
390 ! consistent with the specification. Also changed: IF( ASSOCIATED(expr) )
391 ! to IF ( ASSOCIATED(expr) .eqv. .true. ). Intel compilers produce code
392 ! which silently fails for some mal-formed expressions, so these changes
393 ! are a net which should ensure that they are evaluated as intended.
394 !
395 ! Revision 1.5 2008/12/06 08:44:45 mtcampbe
396 ! Updated license.
397 !
398 ! Revision 1.4 2008/11/19 22:17:56 mtcampbe
399 ! Added Illinois Open Source License/Copyright
400 !
401 ! Revision 1.3 2006/01/12 09:44:09 wasistho
402 ! copy to postv
403 !
404 ! Revision 1.2 2004/06/16 20:01:30 haselbac
405 ! Added use of ModBuildFileNames, cosmetics
406 !
407 ! Revision 1.1 2004/03/27 02:19:15 wasistho
408 ! added routines specific for Rocflu
409 !
410 ! ******************************************************************************
411 
412 
413 
414 
415 
416 
417 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
**********************************************************************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
subroutine turb_rflu_readsolutionascii(region)
j indices j
Definition: Indexing.h:6
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine grid(bp)
Definition: setup_py.f90:257
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine buildfilenamesteady(global, dest, ext, id, it, fileName)
subroutine buildfilenameunsteady(global, dest, ext, id, tm, fileName)