Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SourceIMP/utilities/RocfracPrep/CharKeyWrd.f90
Go to the documentation of this file.
1 !*********************************************************************
2 !* Illinois Open Source License *
3 !* *
4 !* University of Illinois/NCSA *
5 !* Open Source License *
6 !* *
7 !* Copyright@2008, University of Illinois. All rights reserved. *
8 !* *
9 !* Developed by: *
10 !* *
11 !* Center for Simulation of Advanced Rockets *
12 !* *
13 !* University of Illinois *
14 !* *
15 !* www.csar.uiuc.edu *
16 !* *
17 !* Permission is hereby granted, free of charge, to any person *
18 !* obtaining a copy of this software and associated documentation *
19 !* files (the "Software"), to deal with the Software without *
20 !* restriction, including without limitation the rights to use, *
21 !* copy, modify, merge, publish, distribute, sublicense, and/or *
22 !* sell copies of the Software, and to permit persons to whom the *
23 !* Software is furnished to do so, subject to the following *
24 !* conditions: *
25 !* *
26 !* *
27 !* @ Redistributions of source code must retain the above copyright *
28 !* notice, this list of conditions and the following disclaimers. *
29 !* *
30 !* @ Redistributions in binary form must reproduce the above *
31 !* copyright notice, this list of conditions and the following *
32 !* disclaimers in the documentation and/or other materials *
33 !* provided with the distribution. *
34 !* *
35 !* @ Neither the names of the Center for Simulation of Advanced *
36 !* Rockets, the University of Illinois, nor the names of its *
37 !* contributors may be used to endorse or promote products derived *
38 !* from this Software without specific prior written permission. *
39 !* *
40 !* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41 !* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42 !* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43 !* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44 !* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45 !* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46 !* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47 !* USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48 !*********************************************************************
49 !* Please acknowledge The University of Illinois Center for *
50 !* Simulation of Advanced Rockets in works and publications *
51 !* resulting from this software or its derivatives. *
52 !*********************************************************************
53  SUBROUTINE locchr(text,varna,lvari,kpos0,kpos1,kpos2)
54 
55 !!****f* Rocfrac/Rocfrac/Source/locchr.f90/locchr
56 !!
57 !! NAME
58 !! locchr
59 !!
60 !! FUNCTION
61 !!
62 !! Locates the keyword value after a keyword
63 !!
64 !! INPUTS
65 !! text -- character string
66 !! varna -- variable name to search for
67 !! lvari -- length of the variable name
68 !! kpos0 -- initial position in 'text' so start looking for varna
69 !!
70 !! OUTPUT
71 !! kpos1 -- Start of keyword value in string
72 !! kpos2 -- End of keywork value in string
73 !!
74 !!****
75 
76  IMPLICIT NONE
77 
78  CHARACTER(len=200) :: text
79  CHARACTER(len=26) :: varna
80 
81  INTEGER :: kpos0,kpos1,kpos2
82 ! length of the input variable
83  integer :: lvari
84 
85  INTEGER :: kposi
86  INTEGER :: key,k
87 
88  kposi = kpos0-1
89  IF(kposi.LT.0) kposi = 0
90  DO
91  kposi=kposi+1
92  IF(kposi+lvari-1.GT.200) THEN
93  kpos2 = -1
94  RETURN
95  ENDIF
96  IF(text(kposi:kposi+lvari-1).EQ.varna(1:lvari)) EXIT
97  ENDDO
98 
99  kpos1 = kposi
100  DO
101  kpos1=kpos1+1
102  IF(text(kpos1:kpos1).EQ.'=') EXIT
103  ENDDO
104 
105  DO
106  kpos1 = kpos1 + 1
107  IF(text(kpos1:kpos1).NE.' ') EXIT
108  ENDDO
109  kpos2 = kpos1
110 
111  key = 0
112 
113  DO
114  kpos2 = kpos2 + 1
115  IF(kpos2.GE.120) EXIT
116 !!! if(text(kpos2:kpos2).ne.' ') key=1
117  IF(text(kpos2:kpos2).EQ.',') EXIT
118  IF(text(kpos2:kpos2).EQ.' '.AND.&
119  text(kpos2+1:kpos2+1).EQ.' ') EXIT
120  ENDDO
121 !!! kpos1=kpos1+1
122  kpos2=kpos2-1
123  DO k=1,10
124  IF(text(kpos1-1+k:kpos1-1+k).NE.' ') EXIT
125  END DO
126  kpos1 = kpos1 + k - 1
127  DO k=1,10
128  IF(text(kpos2+1-k:kpos2+1-k).NE.' '.AND. &
129  text(kpos2+1-k:kpos2+1-k).NE.',') EXIT
130  END DO
131 
132  kpos2=kpos2-k+1
133  RETURN
134 
135  END SUBROUTINE locchr
136 
137  SUBROUTINE conchr(text,varna,lvari,kpos0,key)
138 
139 !!****f* Rocfrac/Rocfrac/Source/locchr.f90/conchr
140 !!
141 !! NAME
142 !! conchr
143 !!
144 !! FUNCTION
145 !!
146 !! To determine if a control deck keyword is specified
147 !!
148 !! INPUTS
149 !! text -- character string
150 !! varna -- variable name to search for
151 !! lvari -- length of the variable name
152 !! kpos0 -- initial position in 'text' so start looking for varna
153 !!
154 !! OUTPUT
155 !! key -- 0 = no, 1 = yes
156 !!
157 !!****
158 
159 
160  IMPLICIT NONE
161 ! In
162  INTEGER :: kpos0, lvari
163  CHARACTER(len=200) :: text
164  CHARACTER(len=26 ) :: varna
165 ! Out
166  INTEGER :: key ! 1=found, 0=not found
167 
168  INTEGER :: lll, kposi
169 
170  key = 0
171 
172  CALL dtext(text,lll)
173 
174  kposi = kpos0 - 1
175 
176  IF(kposi.LT.0) kposi = 0
177 
178  DO
179  kposi = kposi + 1
180 
181 ! Found keyword
182 !
183  IF(text(kposi:kposi+lvari-1).EQ.varna(1:lvari)) EXIT
184 !
185 ! Keyword not found
186 
187  IF(kposi+lvari-1.GT.lll) RETURN
188 
189  ENDDO
190 
191  key=1
192  RETURN
193  END SUBROUTINE conchr
194 
195  SUBROUTINE dtext(text,lll)
196 
197 !!****f* Rocfrac/Rocfrac/Source/locchr.f90/dtext
198 !!
199 !! NAME
200 !! dtext
201 !!
202 !! FUNCTION
203 !!
204 !! To determine the string length
205 !!
206 !! INPUTS
207 !! text -- character string
208 !!
209 !! OUTPUT
210 !! lll -- length of string
211 !!
212 !!****
213 
214  IMPLICIT NONE
215 ! In
216  CHARACTER(len=200) :: text
217 ! Out
218  INTEGER :: lll
219 
220  INTEGER :: mlen
221 
222  mlen = lll
223  IF(lll.LT.1) mlen = 200
224  mlen = 200
225  DO lll = mlen, 1, -1
226  IF(text(lll:lll).NE.' ') RETURN
227  END DO
228  lll=1
229  RETURN
230  END SUBROUTINE dtext
231 
232  SUBROUTINE dchar(char,key)
233 
234 !!****f* Rocfrac/Rocfrac/Source/locchr.f90/dtext
235 !!
236 !! NAME
237 !! dtext
238 !!
239 !! FUNCTION
240 !!
241 !! Converts a character string to an integer
242 !!
243 !! INPUTS
244 !! char -- character string
245 !!
246 !! OUTPUT
247 !! key -- integer
248 !!
249 !!****
250 
251 
252  IMPLICIT NONE
253 
254  INTEGER :: key
255  CHARACTER(len=16) :: char
256 
257  INTEGER :: k
258 
259  key = 0
260  DO k = 1, 16
261  IF(char(k:k).NE.'0'.AND.char(k:k).NE.'1'.AND. &
262  char(k:k).NE.'2'.AND.char(k:k).NE.'3'.AND. &
263  char(k:k).NE.'4'.AND.char(k:k).NE.'5'.AND. &
264  char(k:k).NE.'6'.AND.char(k:k).NE.'7'.AND. &
265  char(k:k).NE.'8'.AND.char(k:k).NE.'9'.AND. &
266  char(k:k).NE.' ') RETURN
267  END DO
268  READ(char,'(I16)') key
269  RETURN
270 
271  END SUBROUTINE dchar
272 
273  SUBROUTINE rchar(char,key)
274 
275 !!****f* Rocfrac/Rocfrac/Source/locchr.f90/rchar
276 !!
277 !! NAME
278 !! rchar
279 !!
280 !! FUNCTION
281 !!
282 !! Converts a character string to a real
283 !!
284 !! INPUTS
285 !! char -- character string
286 !!
287 !! OUTPUT
288 !! key -- real
289 !!
290 !!****
291 
292 
293  IMPLICIT NONE
294 
295  real*8 :: key
296  CHARACTER(len=16) :: char
297 
298  INTEGER :: k
299 
300  key = 0
301 !
302 ! Don't enforce that key includes a '.' real number,
303 ! allow for integer input.
304 
305 !!$ DO k = 1, 16
306 !!$ IF(char(k:k).NE.'0'.AND.char(k:k).NE.'1'.AND. &
307 !!$ char(k:k).NE.'2'.AND.char(k:k).NE.'3'.AND. &
308 !!$ char(k:k).NE.'4'.AND.char(k:k).NE.'5'.AND. &
309 !!$ char(k:k).NE.'6'.AND.char(k:k).NE.'7'.AND. &
310 !!$ char(k:k).NE.'8'.AND.char(k:k).NE.'9'.AND. &
311 !!$ char(k:k).NE.' '.AND.char(k:k).NE.'.') RETURN
312 !!$ END DO
313 
314  READ(char,*) key
315  RETURN
316 
317  END SUBROUTINE rchar
318 
j indices k indices k
Definition: Indexing.h:6
subroutine conchr(text, varna, lvari, kpos0, key)
subroutine dtext(text, lll)
subroutine rchar(char, key)
subroutine locchr(text, varna, lvari, kpos0, kpos1, kpos2)
subroutine dchar(char, key)
static T_Key key
Definition: vinci_lass.c:76