Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_OpenRestartInfo.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: Open restart file.
26 !
27 ! Description: None.
28 !
29 ! Input:
30 ! global Pointer to global data
31 ! filePosition Position at which file to be opened (start or end)
32 !
33 ! Output:
34 ! fileExists Logical indicating whether file exists
35 !
36 ! Notes:
37 ! 1. The filePosition parameter is needed because the restart info file
38 ! is opened with two goals. The first is to open it with the goal of
39 ! getting the last output iteration or time. The second is to be able
40 ! to write to it by appending additional lines.
41 ! 2. The fileExists parameter is needed because on if the file exists
42 ! on restarting the code, it will need to be read to determine the
43 ! last output iteration or time.
44 !
45 ! ******************************************************************************
46 !
47 ! $Id: RFLU_OpenRestartInfo.F90,v 1.6 2008/12/06 08:44:12 mtcampbe Exp $
48 !
49 ! Copyright: (c) 2003-2004 by the University of Illinois
50 !
51 ! ******************************************************************************
52 
53 SUBROUTINE rflu_openrestartinfo(global,filePosition,fileExists)
54 
55  USE moddatatypes
56  USE modglobal, ONLY: t_global
57  USE modparameters
58  USE moderror
59  USE modmpi
60 
62 
63 ! *****************************************************************************
64 ! Declarations and definitions
65 ! *****************************************************************************
66 
67 ! =============================================================================
68 ! Arguments
69 ! =============================================================================
70 
71  INTEGER, INTENT(IN) :: fileposition
72  TYPE(t_global), POINTER :: global
73 
74  LOGICAL, INTENT(OUT) :: fileexists
75 
76 ! =============================================================================
77 ! Locals
78 ! =============================================================================
79 
80  CHARACTER(CHRLEN) :: ifilename,rcsidentstring
81  INTEGER :: errorflag
82 
83 ! *****************************************************************************
84 ! Start
85 ! *****************************************************************************
86 
87  rcsidentstring = '$RCSfile: RFLU_OpenRestartInfo.F90,v $ $Revision: 1.6 $'
88 
89  CALL registerfunction(global,'RFLU_OpenRestartInfo',&
90  'RFLU_OpenRestartInfo.F90')
91 
92  IF ( global%myProcid == masterproc .AND. &
93  global%verbLevel > verbose_low ) THEN
94  WRITE(stdout,'(A,1X,A)') solver_name, &
95  'Opening restart info file...'
96  END IF ! global%verbLevel
97 
98 ! =============================================================================
99 ! Open file
100 ! =============================================================================
101 
102  CALL buildfilenameplain(global,filedest_outdir,'.rin',ifilename)
103 
104  INQUIRE(file=ifilename,exist=fileexists)
105 
106  IF ( fileexists .EQV. .true. ) THEN
107  IF ( fileposition == file_position_start ) THEN
108  OPEN(if_restinfo,file=ifilename,form='FORMATTED',status='OLD', &
109  iostat=errorflag)
110  ELSE IF ( fileposition == file_position_end ) THEN
111  OPEN(if_restinfo,file=ifilename,form='FORMATTED',status='OLD', &
112  position='APPEND',iostat=errorflag)
113  ELSE
114  CALL errorstop(global,err_reached_default,__line__)
115  END IF ! filePosition
116  ELSE
117  OPEN(if_restinfo,file=ifilename,form='FORMATTED',status='NEW', &
118  iostat=errorflag)
119  END IF ! file
120 
121  global%error = errorflag
122  IF ( global%error /= 0 ) THEN
123  CALL errorstop(global,err_file_open,__line__,'File: '//trim(ifilename))
124  END IF ! global%error
125 
126 ! *****************************************************************************
127 ! End
128 ! *****************************************************************************
129 
130  IF ( global%myProcid == masterproc .AND. &
131  global%verbLevel > verbose_low ) THEN
132  WRITE(stdout,'(A,1X,A)') solver_name, &
133  'Opening restart info file done.'
134  END IF ! global%verbLevel
135 
136  CALL deregisterfunction(global)
137 
138 END SUBROUTINE rflu_openrestartinfo
139 
140 ! ******************************************************************************
141 !
142 ! RCS Revision history:
143 !
144 ! $Log: RFLU_OpenRestartInfo.F90,v $
145 ! Revision 1.6 2008/12/06 08:44:12 mtcampbe
146 ! Updated license.
147 !
148 ! Revision 1.5 2008/11/19 22:17:25 mtcampbe
149 ! Added Illinois Open Source License/Copyright
150 !
151 ! Revision 1.4 2006/04/07 15:19:16 haselbac
152 ! Removed tabs
153 !
154 ! Revision 1.3 2004/06/16 20:00:21 haselbac
155 ! Added use of ModBuildFileNames, cosmetics
156 !
157 ! Revision 1.2 2003/08/20 02:09:58 haselbac
158 ! Changed verbosity conditions to reduce solver output in GENx runs
159 !
160 ! Revision 1.1 2003/06/20 22:32:30 haselbac
161 ! Initial revision
162 !
163 ! ******************************************************************************
164 
165 
166 
167 
168 
169 
170 
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
subroutine buildfilenameplain(global, dest, ext, fileName)
subroutine rflu_openrestartinfo(global, filePosition, fileExists)
**********************************************************************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 errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine deregisterfunction(global)
Definition: ModError.F90:469