FLASH-X
Doxygen Generated Documentation From Interface Source Code
nameValueLL_set.F90
Go to the documentation of this file.
1!! NOTICE
2!! Copyright 2022 UChicago Argonne, LLC and contributors
3!!
4!! Licensed under the Apache License, Version 2.0 (the "License");
5!! you may not use this file except in compliance with the License.
6!!
7!! Unless required by applicable law or agreed to in writing, software
8!! distributed under the License is distributed on an "AS IS" BASIS,
9!! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10!! See the License for the specific language governing permissions and
11!! limitations under the License.
12!!
29
30subroutine nameValueLL_setReal (context, name, value, current_val)
31
32 use nameValueLL_data !, ONLY: context_type, &
33 ! & nameValueLL_find, nameValueLL_check, nameValueLL_addReal, &
34 ! & name_invalid, name_real, name_int, name_str, name_log, &
35 ! & real_list_type, int_list_type, str_list_type, log_list_type, TYPE_VAR
37 use Logfile_interface, ONLY : Logfile_stamp
38
39#include "constants.h"
40implicit none
41
42
43 type (context_type),intent(inout) :: context
44 character(len=*), intent(in) :: name
45 real, intent(in) :: value
46 logical, intent(in) :: current_val
47 type (real_list_type),pointer :: node
48 logical :: valid
49 character(len=MAX_STRING_LENGTH) :: buf
50 character(len=300) :: logStr
51 character(len=80) :: initValueStr, valueStr
52
53
54 call nameValueLL_find(context, name, node)
55
56 if (associated(node)) then
57 if (.NOT. node%isConstant) then
58 call nameValueLL_check(node,value,valid)
59 if (.not. valid) then
60 call nameValueLL_logRulesReal(name,node%numValues,node%minValues,node%maxValues)
61 write (buf,'(F8.3)') value
62 call Driver_abort("nameValue_set: Trying to set '"// trim(name) //"' to invalid value "// trim(buf))
63 endif
64 if (current_val) then
65 node%value = value
66 else
67 node%initValue = value
68 endif
69 else if (current_val .AND. (node%value.EQ.value)) then
70 return ! Same value as existing value marked as constant - RETURN
71 else if (.NOT. current_val) then
72 if(node%initValue.NE.value) then
73 write(initValueStr, '(es20.13)') node%initValue
74 write(valueStr, '(es20.13)') value
75 write(logStr, "(a,a,a,a)") &
76 'current=', trim(adjustl(initValueStr)), &
77 ', new(checkpoint)=', trim(adjustl(valueStr))
78 call Logfile_stamp(logStr, &
79 '[nameValueLL_set] Different previous value for '//trim(name))
80 node%initValue = value
81 end if
82 else
83 write(*,*) "set : Can not change parameter with constant attribute:", name
84 call Driver_abort('ERROR: unable to change constant parameter')
85 endif
86 else
87 ! name is not found - add it to list
88 call nameValueLL_addReal(context, name, value, TYPE_VAR)
89 endif
90
91 return
92end subroutine nameValueLL_setReal
93
94
95
96
97
98subroutine nameValueLL_setInt (context, name, value, current_val)
99
100 use nameValueLL_data !, ONLY: context_type, &
101 ! & nameValueLL_find, nameValueLL_check, nameValueLL_addInt, &
102 ! & name_invalid, name_real, name_int, name_str, name_log, &
103 ! & real_list_type, int_list_type, str_list_type, log_list_type, TYPE_VAR
105 use Logfile_interface, ONLY : Logfile_stamp
106
107#include "constants.h"
108
109implicit none
110
111 type (context_type), intent(inout) :: context
112 character(len=*), intent(in) :: name
113 integer, intent(in) :: value
114 logical, intent(in) :: current_val
115 type (int_list_type),pointer :: node
116 logical :: valid
117 character(len=MAX_STRING_LENGTH) :: buf
118 character(len=300) :: logStr
119 character(len=80) :: initValueStr, valueStr
120
121 call nameValueLL_find(context, name, node)
122
123 if (associated(node)) then
124 if (.NOT. node%isConstant) then
125 call nameValueLL_check(node,value,valid)
126 if (.not. valid) then
127 call nameValueLL_logRulesInt(name,node%numValues,node%minValues,node%maxValues)
128 write (buf,'(I12)') value
129 call Driver_abort("Trying to set '"// trim(name) // "' to invalid value " // trim(buf))
130 endif
131 if (current_val) then
132 node%value = value
133 else
134 node%initValue = value
135 endif
136 else if (current_val .AND. (node%value.EQ.value)) then
137 return ! Same value as existing value marked as constant - RETURN
138 else if (.NOT. current_val) then
139 if(node%initValue.NE.value) then
140 write(initValueStr, '(i12)') node%initValue
141 write(valueStr, '(i12)') value
142 write(logStr, "(a,a,a,a)") &
143 'current=', trim(adjustl(initValueStr)), &
144 ', new(checkpoint)=', trim(adjustl(valueStr))
145 call Logfile_stamp(logStr, &
146 '[nameValueLL_set] Different previous value for '//trim(name))
147 node%initValue = value
148 end if
149 else
150 write(*,*) "set : Can not change name with constant attribute:", name
151 call Driver_abort('ERROR: unable to change constant name')
152 end if
153 else
154 ! could not find name so we are adding it to list
155 call nameValueLL_addInt(context, name, value, TYPE_VAR)
156 endif
157
158 return
159
160end subroutine nameValueLL_setInt
161
162
163
164
165subroutine nameValueLL_setStr (context, name, value, current_val)
166
167 use nameValueLL_data !, ONLY: context_type, &
168 ! & nameValueLL_find, nameValueLL_check, nameValueLL_addStr, &
169 ! & name_invalid, name_real, name_int, name_str, name_log, &
170 ! & real_list_type, int_list_type, str_list_type, log_list_type, TYPE_VAR
172 use Logfile_interface, ONLY : Logfile_stamp
173
174#include "constants.h"
175
176implicit none
177
178 type (context_type), intent(inout) :: context
179 character(len=*),intent(in) :: name, value
180 logical, intent(in) :: current_val
181 type (str_list_type),pointer :: node
182 logical :: valid
183 character(len=300) :: logStr
184
185 call nameValueLL_find(context, name, node)
186
187 if (associated(node)) then
188 if (.NOT. node%isConstant) then
189 call nameValueLL_check(node,value,valid)
190 if (.not. valid) then
191 call nameValueLL_logRulesStr(name,node%numValues,node%validValues)
192 call Driver_abort("nameValue_set: Trying to set '"// trim(name) // "' to invalid value '"// trim(value) //"'")
193 endif
194 if (current_val) then
195 node%value = value
196 else
197 node%initValue = value
198 endif
199 else if (current_val .AND. (node%value.EQ.value)) then
200 return ! Same value as existing value marked as constant - RETURN
201 else if (.NOT. current_val) then
202 if(node%initValue.NE.value) then
203 write(logStr, "(a,a,a,a)") &
204 'current=', trim(adjustl(node%initValue)), &
205 ', new(checkpoint)=', trim(adjustl(value))
206 call Logfile_stamp(logStr, &
207 '[nameValueLL_set] Different previous value for '//trim(name))
208 node%initValue = value
209 end if
210 else
211 write(*,*) "set : Can not change name with constant attribute:", name
212 call Driver_abort('ERROR: unable to change constant name')
213 end if
214 else
215 ! could not find name so we are adding it to list
216 call nameValueLL_addStr(context, name, value, TYPE_VAR)
217 endif
218
219 return
220
221end subroutine nameValueLL_setStr
222
223
224
225
226
227
228subroutine nameValueLL_setLog (context, name, value, current_val)
229
230 use nameValueLL_data !, ONLY: context_type, &
231 ! & nameValueLL_find, nameValueLL_check, nameValueLL_addLog, &
232 ! & name_invalid, name_real, name_int, name_str, name_log, &
233 ! & real_list_type, int_list_type, str_list_type, log_list_type, TYPE_VAR
235 use Logfile_interface, ONLY : Logfile_stamp
236
237#include "constants.h"
238
239implicit none
240 type (context_type), intent(inout) :: context
241 character(len=*),intent(in) :: name
242 logical,intent(in) :: value
243 logical, intent(in) :: current_val
244 type (log_list_type),pointer :: node
245 character(len=300) :: logStr
246 character(len=80) :: initValueStr, valueStr
247
248 call nameValueLL_find(context, name, node)
249
250 if (associated(node)) then
251 if (.NOT. node%isConstant) then
252 if (current_val) then
253 node%value = value
254 else
255 node%initValue = value
256 endif
257 else if (current_val .AND. (node%value.EQV.value)) then
258 return ! Same value as existing value marked as constant - RETURN
259 else if (.NOT. current_val) then
260 if(node%initValue.NEQV.value) then
261 write(initValueStr, '(l12)') node%initValue
262 write(valueStr, '(l12)') value
263 write(logStr, "(a,a,a,a)") &
264 'current=', trim(adjustl(initValueStr)), &
265 ', new(checkpoint)=', trim(adjustl(valueStr))
266 call Logfile_stamp(logStr, &
267 '[nameValueLL_set] Different previous value for '//trim(name))
268 node%initValue = value
269 end if
270 else
271 write(*,*) "set: Can not change name with constant attribute:", name
272 call Driver_abort('ERROR: unable to change constant name')
273 end if
274 else
275 ! could not find name so we are adding it to list
276 call nameValueLL_addLog(context, name, value, TYPE_VAR)
277 endif
278
279 return
280
281end subroutine nameValueLL_setLog
282
283
subroutine nameValueLL_logRulesReal(name, numValues, minValues, maxValues)
subroutine nameValueLL_logRulesInt(name, numValues, minValues, maxValues)
subroutine nameValueLL_logRulesStr(name, numValues, validValues)
subroutine nameValueLL_setInt(context, name, value, current_val)
subroutine nameValueLL_setReal(context, name, value, current_val)
subroutine nameValueLL_setStr(context, name, value, current_val)
subroutine nameValueLL_setLog(context, name, value, current_val)
subroutine nameValueLL_addReal(context, name, value, state)
integer, parameter TYPE_VAR
subroutine nameValueLL_addLog(context, name, value, state)
subroutine nameValueLL_addStr(context, name, value, state)
subroutine nameValueLL_addInt(context, name, value, state)