Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModReadWriteGridSpeeds.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: Suite of routines to read and write grid speed files.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModReadWriteGridSpeeds.F90,v 1.3 2008/12/06 08:44:23 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2004 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modparameters
42  USE moddatatypes
43  USE moderror
44  USE modglobal, ONLY: t_global
45  USE modbndpatch, ONLY: t_patch
46  USE moddatastruct, ONLY: t_region
47  USE modgrid, ONLY: t_grid
48  USE modmpi
49 
50  IMPLICIT NONE
51 
52  PRIVATE
53  PUBLIC :: rflu_readgridspeedswrapper, &
55 
56 ! ******************************************************************************
57 ! Declarations and definitions
58 ! ******************************************************************************
59 
60  CHARACTER(CHRLEN) :: RCSIdentString = &
61  '$RCSfile: RFLU_ModReadWriteGridSpeeds.F90,v $ $Revision: 1.3 $'
62 
63 ! ******************************************************************************
64 ! Routines
65 ! ******************************************************************************
66 
67  CONTAINS
68 
69 
70 
71 
72 
73 
74 
75 
76 ! ******************************************************************************
77 !
78 ! Purpose: Read grid speeds in ASCII ROCFLU format.
79 !
80 ! Description: None.
81 !
82 ! Input:
83 ! pRegion Pointer to region
84 !
85 ! Output: None.
86 !
87 ! Notes: None.
88 !
89 ! ******************************************************************************
90 
91  SUBROUTINE rflu_readgridspeedsascii(pRegion)
92 
95 
96  IMPLICIT NONE
97 
98 ! ******************************************************************************
99 ! Declarations and definitions
100 ! ******************************************************************************
101 
102 ! ==============================================================================
103 ! Arguments
104 ! ==============================================================================
105 
106  TYPE(t_region), POINTER :: pregion
107 
108 ! ==============================================================================
109 ! Local variables
110 ! ==============================================================================
111 
112  CHARACTER(CHRLEN) :: ifilename,sectionstring,timestring1,timestring2
113  INTEGER :: errorflag,ifile,ifg,ifl,ipatch,loopcounter,nfaces,p,r
114  REAL(RFREAL) :: currenttime
115  TYPE(t_grid), POINTER :: pgrid
116  TYPE(t_patch), POINTER :: ppatch
117  TYPE(t_global), POINTER :: global
118 
119 ! ******************************************************************************
120 ! Start
121 ! ******************************************************************************
122 
123  global => pregion%global
124 
125  CALL registerfunction(global,'RFLU_ReadGridSpeedsASCII',&
126  'RFLU_ModReadWriteGridSpeeds.F90')
127 
128  IF ( global%myProcid == masterproc .AND. &
129  global%verbLevel >= verbose_high ) THEN
130  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII grid speeds file...'
131  END IF ! global%verbLevel
132 
133  ifile = if_grid
134 
135  IF ( global%flowType == flow_unsteady .AND. &
136  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
137  CALL buildfilenameunsteady(global,filedest_indir,'.gspa', &
138  pregion%iRegionGlobal,global%currentTime, &
139  ifilename)
140 
141  IF ( global%myProcid == masterproc .AND. &
142  global%verbLevel >= verbose_high ) THEN
143  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
144  pregion%iRegionGlobal
145  WRITE(stdout,'(A,3X,A,1X,1PE11.5)') solver_name,'Current time:', &
146  global%currentTime
147  END IF ! global%verbLevel
148  ELSE
149  CALL buildfilenamebasic(global,filedest_indir,'.gspa', &
150  pregion%iRegionGlobal,ifilename)
151 
152  IF ( global%myProcid == masterproc .AND. &
153  global%verbLevel >= verbose_high ) THEN
154  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
155  pregion%iRegionGlobal
156  END IF ! global%verbLevel
157  END IF ! global
158 
159  OPEN(ifile,file=ifilename,form="FORMATTED",status="OLD",iostat=errorflag)
160  global%error = errorflag
161  IF ( global%error /= err_none ) THEN
162  CALL errorstop(global,err_file_open,__line__,ifilename)
163  END IF ! global%error
164 
165 ! ==============================================================================
166 ! Read header stuff
167 ! ==============================================================================
168 
169  IF ( global%myProcid == masterproc .AND. &
170  global%verbLevel >= verbose_high) THEN
171  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
172  END IF ! global%verbLevel
173 
174  READ(ifile,'(A)') sectionstring
175  IF ( trim(sectionstring) /= '# ROCFLU grid speeds file' ) THEN
176  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
177  END IF ! TRIM
178 
179 ! -----------------------------------------------------------------------------
180 ! Precision and range
181 ! -----------------------------------------------------------------------------
182 
183  READ(ifile,'(A)') sectionstring
184  IF ( trim(sectionstring) /= '# Precision and range' ) THEN
185  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
186  END IF ! TRIM
187 
188  READ(ifile,'(2(I8))') p,r
189  IF ( p < precision(1.0_rfreal) .OR. r < range(1.0_rfreal) ) THEN
190  CALL errorstop(global,err_prec_range,__line__)
191  END IF ! p
192 
193 ! -----------------------------------------------------------------------------
194 ! Initial residual and physical time
195 ! -----------------------------------------------------------------------------
196 
197  READ(ifile,'(A)') sectionstring
198  IF ( trim(sectionstring) /= '# Physical time' ) THEN
199  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
200  END IF ! TRIM
201 
202  READ(ifile,'(E23.16)') currenttime
203 
204  IF ( global%flowType == flow_unsteady .AND. &
205  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
206  IF ( global%currentTime < 0.0_rfreal ) THEN
207  global%currentTime = currenttime
208  ELSE
209  WRITE(timestring1,'(1PE11.5)') global%currentTime
210  WRITE(timestring2,'(1PE11.5)') currenttime
211  IF ( trim(timestring1) /= trim(timestring2) ) THEN
212  CALL errorstop(global,err_time_solution,__line__,trim(ifilename))
213  END IF ! global%currentTime
214  END IF ! global%currentTime
215  END IF ! global%flowType
216 
217 ! ==============================================================================
218 ! Dimensions
219 ! ==============================================================================
220 
221  READ(ifile,'(A)') sectionstring
222  IF ( trim(sectionstring) /= '# Dimensions' ) THEN
223  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
224  END IF ! TRIM
225 
226  pgrid => pregion%grid
227 
228  READ(ifile,'(I8)') nfaces
229 
230 ! ==============================================================================
231 ! Check dimensions (against those read from dimensions file)
232 ! ==============================================================================
233 
234  IF ( nfaces /= pgrid%nFaces ) THEN
235  CALL errorstop(global,err_dimens_invalid,__line__)
236  END IF ! nFaces
237 
238 ! ==============================================================================
239 ! Rest of file
240 ! ==============================================================================
241 
242  loopcounter = 0
243 
244  DO ! set up infinite loop
245  loopcounter = loopcounter + 1
246 
247  READ(ifile,'(A)') sectionstring
248 
249  SELECT CASE ( trim(sectionstring) )
250 
251 ! ------------------------------------------------------------------------------
252 ! Grid speeds
253 ! ------------------------------------------------------------------------------
254 
255  CASE ( '# Grid speeds' )
256  IF ( global%myProcid == masterproc .AND. &
257  global%verbLevel >= verbose_high) THEN
258  WRITE(stdout,'(A,3X,A)') solver_name,'Grid speeds...'
259  END IF ! global%verbLevel
260 
261  IF ( pgrid%nFaces > 0 ) THEN
262  READ(ifile,'(5(E23.16))') (pgrid%gs(ifg),ifg=1,pgrid%nFaces)
263  END IF ! pGrid%nFaces
264 
265  DO ipatch = 1,pgrid%nPatches
266  ppatch => pregion%patches(ipatch)
267 
268  IF ( ppatch%nBFaces > 0 ) THEN
269  READ(ifile,'(5(E23.16))') (ppatch%gs(ifl),ifl=1,ppatch%nBFaces)
270  END IF ! pPatch%nFaces
271  END DO ! iPatch
272 
273 ! ------------------------------------------------------------------------------
274 ! End marker
275 ! ------------------------------------------------------------------------------
276 
277  CASE ( '# End' )
278  IF ( global%myProcid == masterproc .AND. &
279  global%verbLevel >= verbose_high) THEN
280  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
281  END IF ! global%verbLevel
282 
283  EXIT
284 
285 ! ------------------------------------------------------------------------------
286 ! Invalid section string
287 ! ------------------------------------------------------------------------------
288 
289  CASE default
290  IF ( global%verbLevel >= verbose_high) THEN
291  WRITE(stdout,'(3X,A)') sectionstring
292  END IF ! global%verbLevel
293 
294  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
295 
296  END SELECT ! TRIM
297 
298 ! ==============================================================================
299 ! Guard against infinite loop - might be unnecessary because of read errors?
300 ! ==============================================================================
301 
302  IF ( loopcounter >= limit_infinite_loop ) THEN
303  CALL errorstop(global,err_infinite_loop,__line__)
304  END IF ! loopCounter
305 
306  END DO ! <empty>
307 
308 ! ******************************************************************************
309 ! Close file
310 ! ******************************************************************************
311 
312  CLOSE(ifile,iostat=errorflag)
313  global%error = errorflag
314  IF ( global%error /= err_none ) THEN
315  CALL errorstop(global,err_file_close,__line__,ifilename)
316  END IF ! global%error
317 
318 ! ******************************************************************************
319 ! End
320 ! ******************************************************************************
321 
322  IF ( global%myProcid == masterproc .AND. &
323  global%verbLevel >= verbose_high ) THEN
324  WRITE(stdout,'(A,1X,A)') solver_name,'Reading ASCII grid speeds file done.'
325  END IF ! global%verbLevel
326 
327  CALL deregisterfunction(global)
328 
329  END SUBROUTINE rflu_readgridspeedsascii
330 
331 
332 
333 
334 
335 
336 
337 ! ******************************************************************************
338 !
339 ! Purpose: Read grid speeds in binary ROCFLU format.
340 !
341 ! Description: None.
342 !
343 ! Input:
344 ! pRegion Pointer to region
345 !
346 ! Output: None.
347 !
348 ! Notes: None.
349 !
350 ! ******************************************************************************
351 
352  SUBROUTINE rflu_readgridspeedsbinary(pRegion)
353 
356 
357  IMPLICIT NONE
358 
359 ! ******************************************************************************
360 ! Declarations and definitions
361 ! ******************************************************************************
362 
363 ! ==============================================================================
364 ! Arguments
365 ! ==============================================================================
366 
367  TYPE(t_region), POINTER :: pregion
368 
369 ! ==============================================================================
370 ! Local variables
371 ! ==============================================================================
372 
373  CHARACTER(CHRLEN) :: ifilename,sectionstring,timestring1,timestring2
374  INTEGER :: errorflag,ifile,ifg,ifl,ipatch,loopcounter,nfaces,p,r
375  REAL(RFREAL) :: currenttime
376  TYPE(t_grid), POINTER :: pgrid
377  TYPE(t_patch), POINTER :: ppatch
378  TYPE(t_global), POINTER :: global
379 
380 ! ******************************************************************************
381 ! Start
382 ! ******************************************************************************
383 
384  global => pregion%global
385 
386  CALL registerfunction(global,'RFLU_ReadGridSpeedsBinary',&
387  'RFLU_ModReadWriteGridSpeeds.F90')
388 
389  IF ( global%myProcid == masterproc .AND. &
390  global%verbLevel >= verbose_high ) THEN
391  WRITE(stdout,'(A,1X,A)') solver_name,'Reading binary grid speeds file...'
392  END IF ! global%verbLevel
393 
394  ifile = if_grid
395 
396  IF ( global%flowType == flow_unsteady .AND. &
397  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
398  CALL buildfilenameunsteady(global,filedest_indir,'.gsp', &
399  pregion%iRegionGlobal,global%currentTime, &
400  ifilename)
401 
402  IF ( global%myProcid == masterproc .AND. &
403  global%verbLevel >= verbose_high ) THEN
404  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
405  pregion%iRegionGlobal
406  WRITE(stdout,'(A,3X,A,1X,1PE11.5)') solver_name,'Current time:', &
407  global%currentTime
408  END IF ! global%verbLevel
409  ELSE
410  CALL buildfilenamebasic(global,filedest_indir,'.gsp', &
411  pregion%iRegionGlobal,ifilename)
412 
413  IF ( global%myProcid == masterproc .AND. &
414  global%verbLevel >= verbose_high ) THEN
415  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
416  pregion%iRegionGlobal
417  END IF ! global%verbLevel
418  END IF ! global
419 
420  OPEN(ifile,file=ifilename,form="UNFORMATTED",status="OLD",iostat=errorflag)
421  global%error = errorflag
422  IF ( global%error /= err_none ) THEN
423  CALL errorstop(global,err_file_open,__line__,ifilename)
424  END IF ! global%error
425 
426 ! ==============================================================================
427 ! Read header stuff
428 ! ==============================================================================
429 
430  IF ( global%myProcid == masterproc .AND. &
431  global%verbLevel >= verbose_high) THEN
432  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
433  END IF ! global%verbLevel
434 
435  READ(ifile) sectionstring
436  IF ( trim(sectionstring) /= '# ROCFLU grid speeds file' ) THEN
437  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
438  END IF ! TRIM
439 
440 ! -----------------------------------------------------------------------------
441 ! Precision and range
442 ! -----------------------------------------------------------------------------
443 
444  READ(ifile) sectionstring
445  IF ( trim(sectionstring) /= '# Precision and range' ) THEN
446  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
447  END IF ! TRIM
448 
449  READ(ifile) p,r
450  IF ( p < precision(1.0_rfreal) .OR. r < range(1.0_rfreal) ) THEN
451  CALL errorstop(global,err_prec_range,__line__)
452  END IF ! p
453 
454 ! -----------------------------------------------------------------------------
455 ! Initial residual and physical time
456 ! -----------------------------------------------------------------------------
457 
458  READ(ifile) sectionstring
459  IF ( trim(sectionstring) /= '# Physical time' ) THEN
460  CALL errorstop(global,err_invalid_marker,__line__,ifilename)
461  END IF ! TRIM
462 
463  READ(ifile) currenttime
464 
465  IF ( global%flowType == flow_unsteady .AND. &
466  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
467  IF ( global%currentTime < 0.0_rfreal ) THEN
468  global%currentTime = currenttime
469  ELSE
470  WRITE(timestring1,'(1PE11.5)') global%currentTime
471  WRITE(timestring2,'(1PE11.5)') currenttime
472  IF ( trim(timestring1) /= trim(timestring2) ) THEN
473  CALL errorstop(global,err_time_solution,__line__,trim(ifilename))
474  END IF ! global%currentTime
475  END IF ! global%currentTime
476  END IF ! global%flowType
477 
478 ! ==============================================================================
479 ! Dimensions
480 ! ==============================================================================
481 
482  READ(ifile) sectionstring
483  IF ( trim(sectionstring) /= '# Dimensions' ) THEN
484  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
485  END IF ! TRIM
486 
487  pgrid => pregion%grid
488 
489  READ(ifile) nfaces
490 
491 ! ==============================================================================
492 ! Check dimensions (against those read from dimensions file)
493 ! ==============================================================================
494 
495  IF ( nfaces /= pgrid%nFaces ) THEN
496  CALL errorstop(global,err_dimens_invalid,__line__)
497  END IF ! nVertTot
498 
499 ! ==============================================================================
500 ! Rest of file
501 ! ==============================================================================
502 
503  loopcounter = 0
504 
505  DO ! set up infinite loop
506  loopcounter = loopcounter + 1
507 
508  READ(ifile) sectionstring
509 
510  SELECT CASE ( trim(sectionstring) )
511 
512 ! ------------------------------------------------------------------------------
513 ! Grid speeds
514 ! ------------------------------------------------------------------------------
515 
516  CASE ( '# Grid speeds' )
517  IF ( global%myProcid == masterproc .AND. &
518  global%verbLevel >= verbose_high) THEN
519  WRITE(stdout,'(A,3X,A)') solver_name,'Grid speeds...'
520  END IF ! global%verbLevel
521 
522  IF ( pgrid%nFaces > 0 ) THEN
523  READ(ifile) (pgrid%gs(ifg),ifg=1,pgrid%nFaces)
524  END IF ! pGrid%nFaces
525 
526  DO ipatch = 1,pgrid%nPatches
527  ppatch => pregion%patches(ipatch)
528 
529  IF ( ppatch%nBFaces > 0 ) THEN
530  READ(ifile) (ppatch%gs(ifl),ifl=1,ppatch%nBFaces)
531  END IF ! pPatch%nBFaces
532  END DO ! iPatch
533 
534 ! ------------------------------------------------------------------------------
535 ! End marker
536 ! ------------------------------------------------------------------------------
537 
538  CASE ( '# End' )
539  IF ( global%myProcid == masterproc .AND. &
540  global%verbLevel >= verbose_high) THEN
541  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
542  END IF ! global%verbLevel
543 
544  EXIT
545 
546 ! ------------------------------------------------------------------------------
547 ! Invalid section string
548 ! ------------------------------------------------------------------------------
549 
550  CASE default
551  IF ( global%verbLevel >= verbose_high) THEN
552  WRITE(stdout,'(3X,A)') sectionstring
553  END IF ! global%verbLevel
554 
555  CALL errorstop(global,err_invalid_marker,__line__,sectionstring)
556 
557  END SELECT ! TRIM
558 
559 ! ==============================================================================
560 ! Guard against infinite loop - might be unnecessary because of read errors?
561 ! ==============================================================================
562 
563  IF ( loopcounter >= limit_infinite_loop ) THEN
564  CALL errorstop(global,err_infinite_loop,__line__)
565  END IF ! loopCounter
566 
567  END DO ! <empty>
568 
569 ! ******************************************************************************
570 ! Close file
571 ! ******************************************************************************
572 
573  CLOSE(ifile,iostat=errorflag)
574  global%error = errorflag
575  IF ( global%error /= err_none ) THEN
576  CALL errorstop(global,err_file_close,__line__,ifilename)
577  END IF ! global%error
578 
579 ! ******************************************************************************
580 ! End
581 ! ******************************************************************************
582 
583  IF ( global%myProcid == masterproc .AND. &
584  global%verbLevel >= verbose_high ) THEN
585  WRITE(stdout,'(A,1X,A)') solver_name,'Reading binary grid speeds file done.'
586  END IF ! global%verbLevel
587 
588  CALL deregisterfunction(global)
589 
590  END SUBROUTINE rflu_readgridspeedsbinary
591 
592 
593 
594 
595 
596 
597 
598 ! ******************************************************************************
599 !
600 ! Purpose: Wrapper for reading of grid speeds files.
601 !
602 ! Description: None.
603 !
604 ! Input:
605 ! pRegion Pointer to region
606 !
607 ! Output: None.
608 !
609 ! Notes: None.
610 !
611 ! ******************************************************************************
612 
613  SUBROUTINE rflu_readgridspeedswrapper(pRegion)
614 
615 #ifdef GENX
618 #endif
619 
620  IMPLICIT NONE
621 
622 ! ******************************************************************************
623 ! Declarations and definitions
624 ! ******************************************************************************
625 
626 ! ==============================================================================
627 ! Arguments
628 ! ==============================================================================
629 
630  TYPE(t_region), POINTER :: pregion
631 
632 ! ==============================================================================
633 ! Local variables
634 ! ==============================================================================
635 
636  TYPE(t_global), POINTER :: global
637 
638 ! ******************************************************************************
639 ! Start
640 ! ******************************************************************************
641 
642  global => pregion%global
643 
644  CALL registerfunction(global,'RFLU_ReadGridSpeedsWrapper',&
645  'RFLU_ModReadWriteGridSpeeds.F90')
646 
647 ! ******************************************************************************
648 ! Read grid speed files
649 ! ******************************************************************************
650 
651 #ifndef GENX
652  IF ( global%gridFormat == format_ascii ) THEN
653  CALL rflu_readgridspeedsascii(pregion)
654  ELSE IF ( global%gridFormat == format_binary ) THEN
655  CALL rflu_readgridspeedsbinary(pregion)
656  ELSE
657  CALL errorstop(global,err_reached_default,__line__)
658  END IF ! global%gridFormat
659 #else
660  CALL rflu_genx_getdatagspeedssurf(pregion)
661  CALL rflu_genx_getdatagspeedsvol(pregion)
662 #endif
663 
664 ! ******************************************************************************
665 ! End
666 ! ******************************************************************************
667 
668  CALL deregisterfunction(global)
669 
670  END SUBROUTINE rflu_readgridspeedswrapper
671 
672 
673 
674 
675 
676 
677 ! ******************************************************************************
678 !
679 ! Purpose: Write grid speeds in ASCII ROCFLU format.
680 !
681 ! Description: None.
682 !
683 ! Input:
684 ! pRegion Pointer to region
685 !
686 ! Output: None.
687 !
688 ! Notes: None.
689 !
690 ! ******************************************************************************
691 
692  SUBROUTINE rflu_writegridspeedsascii(pRegion)
693 
696 
697  IMPLICIT NONE
698 
699 ! ******************************************************************************
700 ! Declarations and definitions
701 ! ******************************************************************************
702 
703 ! ==============================================================================
704 ! Arguments
705 ! ==============================================================================
706 
707  TYPE(t_region), POINTER :: pregion
708 
709 ! ==============================================================================
710 ! Local variables
711 ! ==============================================================================
712 
713  CHARACTER(CHRLEN) :: ifilename,sectionstring
714  INTEGER :: errorflag,ifile,ifg,ifl,ipatch
715  TYPE(t_grid), POINTER :: pgrid
716  TYPE(t_patch), POINTER :: ppatch
717  TYPE(t_global), POINTER :: global
718 
719 ! ******************************************************************************
720 ! Start
721 ! ******************************************************************************
722 
723  global => pregion%global
724 
725  CALL registerfunction(global,'RFLU_WriteGridSpeedsASCII',&
726  'RFLU_ModReadWriteGridSpeeds.F90')
727 
728  IF ( global%myProcid == masterproc .AND. &
729  global%verbLevel >= verbose_low ) THEN
730  WRITE(stdout,'(A,1X,A)') solver_name
731  WRITE(stdout,'(A,1X,A)') solver_name,'Writing ASCII grid speeds file...'
732  END IF ! global%verbLevel
733 
734  ifile = if_grid
735 
736  IF ( global%flowType == flow_unsteady .AND. &
737  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
738  CALL buildfilenameunsteady(global,filedest_outdir,'.gspa', &
739  pregion%iRegionGlobal,global%currentTime, &
740  ifilename)
741 
742  IF ( global%myProcid == masterproc .AND. &
743  global%verbLevel >= verbose_high ) THEN
744  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
745  pregion%iRegionGlobal
746  WRITE(stdout,'(A,3X,A,1X,1PE11.5)') solver_name,'Current time:', &
747  global%currentTime
748  END IF ! global%verbLevel
749  ELSE
750  CALL buildfilenamebasic(global,filedest_outdir,'.gspa', &
751  pregion%iRegionGlobal,ifilename)
752 
753  IF ( global%myProcid == masterproc .AND. &
754  global%verbLevel >= verbose_high ) THEN
755  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
756  pregion%iRegionGlobal
757  END IF ! global%verbLevel
758  END IF ! global
759 
760  OPEN(ifile,file=ifilename,form="FORMATTED",status="UNKNOWN", &
761  iostat=errorflag)
762  global%error = errorflag
763  IF ( global%error /= err_none ) THEN
764  CALL errorstop(global,err_file_open,__line__,ifilename)
765  END IF ! global%error
766 
767 ! ==============================================================================
768 ! Header and general information
769 ! ==============================================================================
770 
771  IF ( global%myProcid == masterproc .AND. &
772  global%verbLevel >= verbose_med) THEN
773  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
774  END IF ! global%verbLevel
775 
776  sectionstring = '# ROCFLU grid speeds file'
777  WRITE(ifile,'(A)') trim(sectionstring)
778 
779  sectionstring = '# Precision and range'
780  WRITE(ifile,'(A)') trim(sectionstring)
781  WRITE(ifile,'(2(I8))') precision(1.0_rfreal),range(1.0_rfreal)
782 
783  sectionstring = '# Physical time'
784  WRITE(ifile,'(A)') trim(sectionstring)
785  WRITE(ifile,'(E23.16)') global%currentTime
786 
787 ! ==============================================================================
788 ! Dimensions
789 ! ==============================================================================
790 
791  pgrid => pregion%grid
792 
793  sectionstring = '# Dimensions'
794  WRITE(ifile,'(A)') trim(sectionstring)
795  WRITE(ifile,'(I8)') pgrid%nFaces
796 
797 ! ==============================================================================
798 ! Grid speeds
799 ! ==============================================================================
800 
801  IF ( pregion%mixtInput%moveGrid .EQV. .true. ) THEN
802  IF ( global%myProcid == masterproc .AND. &
803  global%verbLevel >= verbose_med) THEN
804  WRITE(stdout,'(A,3X,A)') solver_name,'Grid speeds...'
805  END IF ! global%verbLevel
806 
807  sectionstring = '# Grid speeds'
808  WRITE(ifile,'(A)') trim(sectionstring)
809 
810  IF ( pgrid%nFaces > 0 ) THEN
811  WRITE(ifile,'(5(E23.16))') (pgrid%gs(ifg),ifg=1,pgrid%nFaces)
812  END IF ! pGrid%nFaces
813 
814  DO ipatch = 1,pgrid%nPatches
815  ppatch => pregion%patches(ipatch)
816 
817  IF ( ppatch%nBFaces > 0 ) THEN
818  WRITE(ifile,'(5(E23.16))') (ppatch%gs(ifl),ifl=1,ppatch%nBFaces)
819  END IF ! pPatch%nBFaces
820  END DO ! iPatch
821  END IF ! pRegion%mixtInput%moveGrid
822 
823 ! ==============================================================================
824 ! End marker
825 ! ==============================================================================
826 
827  IF ( global%myProcid == masterproc .AND. &
828  global%verbLevel >= verbose_med) THEN
829  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
830  END IF ! global%verbLevel
831 
832  sectionstring = '# End'
833  WRITE(ifile,'(A)') trim(sectionstring)
834 
835 ! ==============================================================================
836 ! Close file
837 ! ==============================================================================
838 
839  CLOSE(ifile,iostat=errorflag)
840  global%error = errorflag
841  IF ( global%myProcid == masterproc .AND. &
842  global%error /= err_none ) THEN
843  CALL errorstop(global,err_file_close,__line__,ifilename)
844  END IF ! global%error
845 
846 ! ******************************************************************************
847 ! End
848 ! ******************************************************************************
849 
850  IF ( global%myProcid == masterproc .AND. &
851  global%verbLevel >= verbose_med ) THEN
852  WRITE(stdout,'(A,1X,A)') solver_name, &
853  'Writing ASCII grid speeds file done.'
854  WRITE(stdout,'(A,1X,A)') solver_name
855  END IF ! global%verbLevel
856 
857  CALL deregisterfunction(global)
858 
859  END SUBROUTINE rflu_writegridspeedsascii
860 
861 
862 
863 
864 
865 
866 ! ******************************************************************************
867 !
868 ! Purpose: Write grid speeds in binary ROCFLU format.
869 !
870 ! Description: None.
871 !
872 ! Input:
873 ! pRegion Pointer to region
874 !
875 ! Output: None.
876 !
877 ! Notes: None.
878 !
879 ! ******************************************************************************
880 
881  SUBROUTINE rflu_writegridspeedsbinary(pRegion)
882 
885 
886  IMPLICIT NONE
887 
888 ! ******************************************************************************
889 ! Declarations and definitions
890 ! ******************************************************************************
891 
892 ! ==============================================================================
893 ! Arguments
894 ! ==============================================================================
895 
896  TYPE(t_region), POINTER :: pregion
897 
898 ! ==============================================================================
899 ! Local variables
900 ! ==============================================================================
901 
902  CHARACTER(CHRLEN) :: ifilename,sectionstring
903  INTEGER :: errorflag,ifile,ifg,ifl,ipatch
904  TYPE(t_grid), POINTER :: pgrid
905  TYPE(t_patch), POINTER :: ppatch
906  TYPE(t_global), POINTER :: global
907 
908 ! ******************************************************************************
909 ! Start
910 ! ******************************************************************************
911 
912  global => pregion%global
913 
914  CALL registerfunction(global,'RFLU_WriteGridSpeedsBinary',&
915  'RFLU_ModReadWriteGridSpeeds.F90')
916 
917  IF ( global%myProcid == masterproc .AND. &
918  global%verbLevel >= verbose_low ) THEN
919  WRITE(stdout,'(A,1X,A)') solver_name
920  WRITE(stdout,'(A,1X,A)') solver_name,'Writing binary grid speeds file...'
921  END IF ! global%verbLevel
922 
923  ifile = if_grid
924 
925  IF ( global%flowType == flow_unsteady .AND. &
926  (pregion%mixtInput%moveGrid .EQV. .true.) ) THEN
927  CALL buildfilenameunsteady(global,filedest_outdir,'.gsp', &
928  pregion%iRegionGlobal,global%currentTime, &
929  ifilename)
930 
931  IF ( global%myProcid == masterproc .AND. &
932  global%verbLevel >= verbose_high ) THEN
933  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
934  pregion%iRegionGlobal
935  WRITE(stdout,'(A,3X,A,1X,1PE11.5)') solver_name,'Current time:', &
936  global%currentTime
937  END IF ! global%verbLevel
938  ELSE
939  CALL buildfilenamebasic(global,filedest_outdir,'.gsp', &
940  pregion%iRegionGlobal,ifilename)
941 
942  IF ( global%myProcid == masterproc .AND. &
943  global%verbLevel >= verbose_high ) THEN
944  WRITE(stdout,'(A,3X,A,1X,I5.5)') solver_name,'Global region:', &
945  pregion%iRegionGlobal
946  END IF ! global%verbLevel
947  END IF ! global
948 
949  OPEN(ifile,file=ifilename,form="UNFORMATTED",status="UNKNOWN", &
950  iostat=errorflag)
951  global%error = errorflag
952  IF ( global%error /= err_none ) THEN
953  CALL errorstop(global,err_file_open,__line__,ifilename)
954  END IF ! global%error
955 
956 ! ==============================================================================
957 ! Header and general information
958 ! ==============================================================================
959 
960  IF ( global%myProcid == masterproc .AND. &
961  global%verbLevel >= verbose_med) THEN
962  WRITE(stdout,'(A,3X,A)') solver_name,'Header information...'
963  END IF ! global%verbLevel
964 
965  sectionstring = '# ROCFLU grid speeds file'
966  WRITE(ifile) sectionstring
967 
968  sectionstring = '# Precision and range'
969  WRITE(ifile) sectionstring
970  WRITE(ifile) precision(1.0_rfreal),range(1.0_rfreal)
971 
972  sectionstring = '# Physical time'
973  WRITE(ifile) sectionstring
974  WRITE(ifile) global%currentTime
975 
976 ! ==============================================================================
977 ! Dimensions
978 ! ==============================================================================
979 
980  pgrid => pregion%grid
981 
982  sectionstring = '# Dimensions'
983  WRITE(ifile) sectionstring
984  WRITE(ifile) pgrid%nFaces
985 
986 ! ==============================================================================
987 ! Grid speeds
988 ! ==============================================================================
989 
990  IF ( pregion%mixtInput%moveGrid .EQV. .true. ) THEN
991  IF ( global%myProcid == masterproc .AND. &
992  global%verbLevel >= verbose_med) THEN
993  WRITE(stdout,'(A,3X,A)') solver_name,'Grid speeds...'
994  END IF ! global%verbLevel
995 
996  sectionstring = '# Grid speeds'
997  WRITE(ifile) sectionstring
998 
999  IF ( pgrid%nFaces > 0 ) THEN
1000  WRITE(ifile) (pgrid%gs(ifg),ifg=1,pgrid%nFaces)
1001  END IF ! pGrid%nFaces
1002 
1003  DO ipatch = 1,pgrid%nPatches
1004  ppatch => pregion%patches(ipatch)
1005 
1006  IF ( ppatch%nBFaces > 0 ) THEN
1007  WRITE(ifile) (ppatch%gs(ifl),ifl=1,ppatch%nBFaces)
1008  END IF ! pPatch%nBFaces
1009  END DO ! iPatch
1010  END IF ! pRegion%mixtInput%moveGrid
1011 
1012 ! ==============================================================================
1013 ! End marker
1014 ! ==============================================================================
1015 
1016  IF ( global%myProcid == masterproc .AND. &
1017  global%verbLevel >= verbose_med) THEN
1018  WRITE(stdout,'(A,3X,A)') solver_name,'End marker...'
1019  END IF ! global%verbLevel
1020 
1021  sectionstring = '# End'
1022  WRITE(ifile) sectionstring
1023 
1024 ! ==============================================================================
1025 ! Close file
1026 ! ==============================================================================
1027 
1028  CLOSE(ifile,iostat=errorflag)
1029  global%error = errorflag
1030  IF ( global%myProcid == masterproc .AND. &
1031  global%error /= err_none ) THEN
1032  CALL errorstop(global,err_file_close,__line__,ifilename)
1033  END IF ! global%error
1034 
1035 ! ******************************************************************************
1036 ! End
1037 ! ******************************************************************************
1038 
1039  IF ( global%myProcid == masterproc .AND. &
1040  global%verbLevel >= verbose_med ) THEN
1041  WRITE(stdout,'(A,1X,A)') solver_name, &
1042  'Writing binary grid speeds file done.'
1043  WRITE(stdout,'(A,1X,A)') solver_name
1044  END IF ! global%verbLevel
1045 
1046  CALL deregisterfunction(global)
1047 
1048  END SUBROUTINE rflu_writegridspeedsbinary
1049 
1050 
1051 
1052 
1053 
1054 
1055 ! ******************************************************************************
1056 !
1057 ! Purpose: Wrapper for writing of grid speeds files in ROCFLU format.
1058 !
1059 ! Description: None.
1060 !
1061 ! Input:
1062 ! pRegion Pointer to region
1063 !
1064 ! Output: None.
1065 !
1066 ! Notes: None.
1067 !
1068 ! ******************************************************************************
1069 
1070  SUBROUTINE rflu_writegridspeedswrapper(pRegion)
1071 
1072 #ifdef GENX
1076 #endif
1077 
1078  IMPLICIT NONE
1079 
1080 ! ******************************************************************************
1081 ! Declarations and definitions
1082 ! ******************************************************************************
1083 
1084 ! ==============================================================================
1085 ! Arguments
1086 ! ==============================================================================
1087 
1088  TYPE(t_region), POINTER :: pregion
1089 
1090 ! ==============================================================================
1091 ! Local variables
1092 ! ==============================================================================
1093 
1094  TYPE(t_global), POINTER :: global
1095 
1096 ! ******************************************************************************
1097 ! Start
1098 ! ******************************************************************************
1099 
1100  global => pregion%global
1101 
1102  CALL registerfunction(global,'RFLU_WriteGridSpeedsWrapper',&
1103  'RFLU_ModReadWriteGridSpeeds.F90')
1104 
1105 ! ******************************************************************************
1106 ! Read grid speed file
1107 ! ******************************************************************************
1108 
1109 #ifdef GENX
1110  IF ( rflu_genx_decidewritefile(global) .EQV. .false. ) THEN
1111 #endif
1112  IF ( global%gridFormat == format_ascii ) THEN
1113  CALL rflu_writegridspeedsascii(pregion)
1114  ELSE IF ( global%gridFormat == format_binary ) THEN
1115  CALL rflu_writegridspeedsbinary(pregion)
1116  ELSE
1117  CALL errorstop(global,err_reached_default,__line__)
1118  END IF ! global%gridFormat
1119 #ifdef GENX
1120  ELSE
1121  CALL rflu_genx_putdatagspeedssurf(pregion)
1122  CALL rflu_genx_putdatagspeedsvol(pregion)
1123  END IF ! RFLU_GENX_DecideReadFile
1124 #endif
1125 
1126 ! ******************************************************************************
1127 ! End
1128 ! ******************************************************************************
1129 
1130  CALL deregisterfunction(global)
1131 
1132  END SUBROUTINE rflu_writegridspeedswrapper
1133 
1134 
1135 
1136 
1137 
1138 ! ******************************************************************************
1139 ! End
1140 ! ******************************************************************************
1141 
1142 END MODULE rflu_modreadwritegridspeeds
1143 
1144 
1145 ! ******************************************************************************
1146 !
1147 ! RCS Revision history:
1148 !
1149 ! $Log: RFLU_ModReadWriteGridSpeeds.F90,v $
1150 ! Revision 1.3 2008/12/06 08:44:23 mtcampbe
1151 ! Updated license.
1152 !
1153 ! Revision 1.2 2008/11/19 22:17:34 mtcampbe
1154 ! Added Illinois Open Source License/Copyright
1155 !
1156 ! Revision 1.1 2004/10/19 19:27:10 haselbac
1157 ! Initial revision
1158 !
1159 ! ******************************************************************************
1160 
1161 
1162 
1163 
1164 
1165 
1166 
1167 
1168 
1169 
1170 
1171 
unsigned char r() const
Definition: Color.h:68
subroutine buildfilenamebasic(global, dest, ext, id, fileName)
subroutine, public rflu_writegridspeedswrapper(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine, public rflu_readgridspeedswrapper(pRegion)
subroutine, public rflu_genx_getdatagspeedssurf(pRegion)
IndexType nfaces() const
Definition: Mesh.H:641
subroutine, public rflu_genx_putdatagspeedssurf(pRegion)
subroutine, public rflu_genx_getdatagspeedsvol(pRegion)
**********************************************************************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, public rflu_genx_putdatagspeedsvol(pRegion)
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469
LOGICAL function, public rflu_genx_decidewritefile(global)
subroutine buildfilenameunsteady(global, dest, ext, id, tm, fileName)