Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Source/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/Source/CharKeyWrd.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  kpos1 = 0
89  kpos2 = 0
90 
91  kposi = kpos0-1
92 
93 
94  IF(kposi.LT.0) kposi = 0
95  DO
96  kposi=kposi+1
97  IF(kposi+lvari-1.GT.200) THEN
98  kpos2 = -1
99  ! did not find any keyword
100  kpos2 = kpos0
101  kpos1 = kpos0
102  RETURN
103  ENDIF
104  IF(text(kposi:kposi+lvari-1).EQ.varna(1:lvari)) EXIT
105  ENDDO
106 
107  kpos1 = kposi
108  DO
109  kpos1=kpos1+1
110  IF(text(kpos1:kpos1).EQ.'=') EXIT
111  ENDDO
112 
113  DO
114  kpos1 = kpos1 + 1
115  IF(text(kpos1:kpos1).NE.' ') EXIT
116  ENDDO
117 
118  kpos2 = kpos1
119 
120  key = 0
121 
122  DO
123  kpos2 = kpos2 + 1
124  IF(kpos2.GE.120) EXIT
125 !!! if(text(kpos2:kpos2).ne.' ') key=1
126  IF(text(kpos2:kpos2).EQ.',') EXIT
127  IF(text(kpos2:kpos2).EQ.' '.AND.&
128  text(kpos2+1:kpos2+1).EQ.' ') EXIT
129  ENDDO
130 
131 
132 !!! kpos1=kpos1+1
133  kpos2=kpos2-1
134  DO k=1,10
135  IF(text(kpos1-1+k:kpos1-1+k).NE.' ') EXIT
136  END DO
137  kpos1 = kpos1 + k - 1
138  DO k=1,10
139  IF(text(kpos2+1-k:kpos2+1-k).NE.' '.AND. &
140  text(kpos2+1-k:kpos2+1-k).NE.',') EXIT
141  END DO
142 
143  kpos2=kpos2-k+1
144 
145  RETURN
146 
147  END SUBROUTINE locchr
148 
149  SUBROUTINE conchr(text,varna,lvari,kpos0,key)
150 
151 !!****f* Rocfrac/Source/CharKeyWrd.f90/conchr
152 !!
153 !! NAME
154 !! conchr
155 !!
156 !! FUNCTION
157 !!
158 !! To determine if a control deck keyword is specified
159 !!
160 !! INPUTS
161 !! text -- character string
162 !! varna -- variable name to search for
163 !! lvari -- length of the variable name
164 !! kpos0 -- initial position in 'text' so start looking for varna
165 !!
166 !! OUTPUT
167 !! key -- 0 = no, 1 = yes
168 !!
169 !!****
170 
171 
172  IMPLICIT NONE
173 ! In
174  INTEGER :: kpos0, lvari
175  CHARACTER(len=200) :: text
176  CHARACTER(len=26 ) :: varna
177 ! Out
178  INTEGER :: key ! 1=found, 0=not found
179 
180  INTEGER :: lll, kposi
181 
182  key = 0
183 
184  CALL dtext(text,lll)
185 
186  kposi = kpos0 - 1
187 
188  IF(kposi.LT.0) kposi = 0
189 
190  DO
191  kposi = kposi + 1
192 
193 ! Found keyword
194 !
195  IF(text(kposi:kposi+lvari-1).EQ.varna(1:lvari)) EXIT
196 !
197 ! Keyword not found
198 
199  IF(kposi+lvari-1.GT.lll) RETURN
200 
201  ENDDO
202 
203  key=1
204  RETURN
205  END SUBROUTINE conchr
206 
207  SUBROUTINE dtext(text,lll)
208 
209 !!****f* Rocfrac/Source/CharKeyWrd.f90/dtext
210 !!
211 !! NAME
212 !! dtext
213 !!
214 !! FUNCTION
215 !!
216 !! To determine the string length
217 !!
218 !! INPUTS
219 !! text -- character string
220 !!
221 !! OUTPUT
222 !! lll -- length of string
223 !!
224 !!****
225 
226  IMPLICIT NONE
227 ! In
228  CHARACTER(len=200) :: text
229 ! Out
230  INTEGER :: lll
231 
232  INTEGER :: mlen
233 
234  mlen = lll
235  IF(lll.LT.1) mlen = 200
236  mlen = 200
237  DO lll = mlen, 1, -1
238  IF(text(lll:lll).NE.' ') RETURN
239  END DO
240  lll=1
241  RETURN
242  END SUBROUTINE dtext
243 
244  SUBROUTINE dchar(char,key)
245 
246 !!****f* Rocfrac/Source/locchr.f90/dchar
247 !!
248 !! NAME
249 !! dtext
250 !!
251 !! FUNCTION
252 !!
253 !! Converts a character string to an integer
254 !!
255 !! INPUTS
256 !! char -- character string
257 !!
258 !! OUTPUT
259 !! key -- integer
260 !!
261 !!****
262 
263 
264  IMPLICIT NONE
265 
266  INTEGER :: key
267  CHARACTER(len=16) :: char
268 
269  INTEGER :: k
270 
271  key = 0
272  DO k = 1, 16
273  IF(char(k:k).NE.'0'.AND.char(k:k).NE.'1'.AND. &
274  char(k:k).NE.'2'.AND.char(k:k).NE.'3'.AND. &
275  char(k:k).NE.'4'.AND.char(k:k).NE.'5'.AND. &
276  char(k:k).NE.'6'.AND.char(k:k).NE.'7'.AND. &
277  char(k:k).NE.'8'.AND.char(k:k).NE.'9'.AND. &
278  char(k:k).NE.' ') RETURN
279  END DO
280  READ(char,'(I16)') key
281  RETURN
282 
283  END SUBROUTINE dchar
284 
285  SUBROUTINE rchar(char,key)
286 
287 !!****f* Rocfrac/Rocfrac/Source/CharKeyWrd.f90/rchar
288 !!
289 !! NAME
290 !! rchar
291 !!
292 !! FUNCTION
293 !!
294 !! Converts a character string to a real
295 !!
296 !! INPUTS
297 !! char -- character string
298 !!
299 !! OUTPUT
300 !! key -- real
301 !!
302 !!****
303 
304 
305  IMPLICIT NONE
306 
307  real*8 :: key
308  CHARACTER(len=16) :: char
309 
310  INTEGER :: k
311 
312  key = 0
313 !
314 ! Don't enforce that key includes a '.' real number,
315 ! allow for integer input.
316 
317 !!$ DO k = 1, 16
318 !!$ IF(char(k:k).NE.'0'.AND.char(k:k).NE.'1'.AND. &
319 !!$ char(k:k).NE.'2'.AND.char(k:k).NE.'3'.AND. &
320 !!$ char(k:k).NE.'4'.AND.char(k:k).NE.'5'.AND. &
321 !!$ char(k:k).NE.'6'.AND.char(k:k).NE.'7'.AND. &
322 !!$ char(k:k).NE.'8'.AND.char(k:k).NE.'9'.AND. &
323 !!$ char(k:k).NE.' '.AND.char(k:k).NE.'.') RETURN
324 !!$ END DO
325 
326  READ(char,*) key
327  RETURN
328 
329  END SUBROUTINE rchar
330 
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