Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PEUL_ReadInputFile.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 user input for PEUL information (done on all processors).
26 !
27 ! Description: none.
28 !
29 ! Input: user input file.
30 !
31 ! Output: regions = PEUL information
32 !
33 ! Notes: none.
34 !
35 !******************************************************************************
36 !
37 ! $Id: PEUL_ReadInputFile.F90,v 1.3 2008/12/06 08:44:39 mtcampbe Exp $
38 !
39 ! Copyright: (c) 2002 by the University of Illinois
40 !
41 !******************************************************************************
42 
43 SUBROUTINE peul_readinputfile( regions )
44 
45  USE moddatatypes
46  USE moddatastruct, ONLY : t_region
47  USE modglobal, ONLY : t_global
48  USE moderror
49  USE modparameters
51 
54  IMPLICIT NONE
55 
56 ! ... parameters
57  TYPE(t_region), POINTER :: regions(:)
58 
59 ! ... loop variables
60  INTEGER :: iread, ireg
61 
62 ! ... local variables
63  CHARACTER(CHRLEN) :: rcsidentstring
64  CHARACTER(CHRLEN+4) :: fname
65  CHARACTER(256) :: line
66 
67  LOGICAL :: usedsomewhere, unusedsomewhere
68 
69  INTEGER :: errorflag, iptype, nptypes, nsecs, brbeg, brend, readstatus
70 
71  TYPE(t_global), POINTER :: global
72 
73 !******************************************************************************
74 
75  rcsidentstring = '$RCSfile: PEUL_ReadInputFile.F90,v $ $Revision: 1.3 $'
76 
77  global => regions(1)%global
78 
79  CALL registerfunction( global,'PEUL_ReadInputFile',&
80  'PEUL_ReadInputFile.F90' )
81 
82 ! begin -----------------------------------------------------------------------
83 
84 ! search for CONPART and CONPART_PTYPE sections
85 
86  fname = trim(global%inDir)//trim(global%casename)//'.inp'
87 
88  DO iread = 1,2
89 
90 ! - open file
91 
92  OPEN(if_input,file=fname,form='formatted',status='old',iostat=errorflag)
93  global%error = errorflag
94  IF (global%error /= 0) &
95  CALL errorstop( global,err_file_open,__line__,'File: '//trim(fname) )
96 
97 ! - read file looking for keywords
98 
99  SELECT CASE (iread)
100 
101  CASE (1) ! on first pass, find # of sections and Ptypes
102 
103  nsecs = 0 ! initialize counter for multiply referenced sections
104 
105  DO
106  READ(if_input,'(A256)',err=10,end=86) line
107 
108  SELECT CASE(trim(line))
109 
110  CASE ('# CONPART')
111  IF (nsecs == 1) THEN
112  nptypes = iptype
113  ELSE IF (nsecs > 1) THEN
114  IF (iptype /= nptypes) & ! nPtypes same in each sec?
115  CALL errorstop( global,err_peul_nptypes,__line__ )
116  END IF ! nSecs
117  nsecs = nsecs + 1
118  iptype = 0
119 
120  CASE ('# CONPART_PTYPE')
121  IF (nsecs == 0) &
122  CALL errorstop( global,err_peul_ptype,__line__ )
123  iptype = iptype + 1
124 
125  END SELECT ! line
126  END DO
127 
128 86 CONTINUE
129 
130  IF (nsecs == 1) THEN
131  nptypes = iptype
132  ELSE IF (nsecs > 1) THEN
133  IF (iptype /= nptypes) & ! nPtypes same in each sec?
134  CALL errorstop( global,err_peul_nptypes,__line__ )
135  END IF ! nSecs
136 
137  CASE (2) ! on second pass, search for real- and string-valued keys
138 
139  DO
140  READ(if_input,'(A256)',err=10,end=87) line
141 
142  SELECT CASE(trim(line))
143 
144  CASE ('# CONPART')
145  CALL peul_readconpartsection( regions,nptypes,brbeg,brend )
146  iptype = 0
147 
148  CASE ('# CONPART_PTYPE')
149  iptype = iptype + 1
150  CALL peul_readconpartptypesection( regions,brbeg,brend,iptype )
151 
152  END SELECT ! line
153  END DO
154 
155 87 CONTINUE
156 
157  END SELECT ! iRead
158 
159 ! close file ------------------------------------------------------------------
160 
161  CLOSE(if_input,iostat=errorflag)
162  global%error = errorflag
163  IF (global%error /= 0) &
164  CALL errorstop( global,err_file_close,__line__,'File: '//trim(fname) )
165 
166  IF (nsecs == 0) EXIT
167 
168  END DO ! iRead
169 
170 ! set global%peulUsed -------------------------------------------------------
171 
172  usedsomewhere = .false.
173  unusedsomewhere = .false.
174 
175  DO ireg = lbound(regions,1),ubound(regions,1)
176  readstatus = regions(ireg)%peulInput%readStatus
177  usedsomewhere = usedsomewhere .OR.(readstatus == 1)
178  unusedsomewhere = unusedsomewhere.OR.(readstatus /= 1) ! == 0 or -1
179  END DO ! iReg
180 
181  IF (usedsomewhere.AND.unusedsomewhere) THEN
182  CALL errorstop( global,err_mp_allornone,__line__ )
183  END IF ! usedSomewhere.AND.unusedSomewhere
184 
185  global%peulUsed = usedsomewhere
186 
187 ! finalization & error handling -----------------------------------------------
188 
189  CALL deregisterfunction( global )
190  goto 999
191 
192 10 CONTINUE
193  CALL errorstop( global,err_file_read,__line__,'File: '//trim(fname) )
194 
195 999 CONTINUE
196 
197 END SUBROUTINE peul_readinputfile
198 
199 !******************************************************************************
200 !
201 ! RCS Revision history:
202 !
203 ! $Log: PEUL_ReadInputFile.F90,v $
204 ! Revision 1.3 2008/12/06 08:44:39 mtcampbe
205 ! Updated license.
206 !
207 ! Revision 1.2 2008/11/19 22:17:51 mtcampbe
208 ! Added Illinois Open Source License/Copyright
209 !
210 ! Revision 1.1 2004/12/01 21:09:47 haselbac
211 ! Initial revision after changing case
212 !
213 ! Revision 1.7 2004/03/05 22:09:04 jferry
214 ! created global variables for peul, plag, and inrt use
215 !
216 ! Revision 1.6 2003/04/14 16:32:24 jferry
217 ! minor edits
218 !
219 ! Revision 1.5 2003/03/17 18:42:45 jblazek
220 ! Added inDir to path of the input file.
221 !
222 ! Revision 1.4 2003/03/11 16:04:57 jferry
223 ! Created data type for material properties
224 !
225 ! Revision 1.3 2003/02/26 23:38:30 jferry
226 ! eliminated end=999 convention to ensure that files get closed
227 !
228 ! Revision 1.2 2003/02/12 23:34:48 jferry
229 ! Replaced [io]stat=global%error with local errorFlag
230 !
231 ! Revision 1.1 2003/02/11 22:52:51 jferry
232 ! Initial import of Rocsmoke
233 !
234 !******************************************************************************
235 
236 
237 
238 
239 
240 
241 
CImg< T > & line(const unsigned int y0)
Get a line.
Definition: CImg.h:18421
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 brbeg
subroutine peul_readconpartsection(regions, nPtypes, brbeg, brend)
**********************************************************************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 peul_readinputfile(regions)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine peul_readconpartptypesection(regions, brbeg, brend, iPtype)