9 integer,
parameter,
private :: kreal = kind(0.0d0)
22 integer :: tbcol, tbrow
24 real(kind=kreal),
pointer :: tbval(:,:)=>null()
32 interface assignment(=)
36 interface operator(==)
42 subroutine init_table( table, ndp, col, row, tbval )
43 type(
ttable ),
intent(inout) :: table
44 integer,
intent(in) :: ndp, col, row
45 real(kind=kreal),
intent(in) :: tbval(col,row)
47 real(kind=kreal) :: tbindexval(
maxnval)
48 if(
associated( table%tbval ) )
deallocate( table%tbval )
52 allocate( table%tbval( col, row ) )
55 table%tbval(i,j) = tbval(i,j)
61 tbindexval(1) = table%tbval(table%tbcol-i+1, 1)
65 if( any( tbindexval(1:table%tbindex(i))==table%tbval(table%tbcol-i+1, j) ) ) cycle
66 table%tbindex(i) = table%tbindex(i)+1
67 tbindexval(table%tbindex(i)) = table%tbval(table%tbcol-i+1, j)
76 if( j/= row) stop
"Error in table definition!"
81 type(
ttable ),
intent(inout) :: table
82 if(
associated( table%tbval ) )
deallocate( table%tbval )
87 integer,
intent(in) :: fname
89 write(fname,*) table%ndepends, table%tbcol, table%tbrow
91 write(fname,*) i,(table%tbval(j,i),j=1,table%tbcol)
97 type(
ttable),
intent(in) :: rhs
100 if( lhs%ndepends /= rhs%ndepends )
return
101 if( lhs%tbcol /= rhs%tbcol )
return
102 if( lhs%tbrow /= rhs%tbrow )
return
104 if( lhs%tbindex(i) /= rhs%tbindex(i) )
return
108 if( lhs%tbval(i,j) /= rhs%tbval(i,j) )
return
116 type(
ttable),
intent(in) :: rhs
118 lhs%ndepends = rhs%ndepends
119 lhs%tbcol = rhs%tbcol
120 lhs%tbrow = rhs%tbrow
121 lhs%tbindex(:) = rhs%tbindex(:)
122 if(
associated( lhs%tbval ) )
deallocate( lhs%tbval )
123 if( rhs%tbcol<=0 .or. rhs%tbrow<=0 )
return
124 allocate( lhs%tbval( lhs%tbcol, lhs%tbrow ) )
125 lhs%tbval(:,:) = rhs%tbval(:,:)
143 integer,
parameter,
private :: kreal = kind(0.0d0)
145 private :: gettablegrad, gettabledata
147 include
"dictionary.f90"
153 character(len=*),
intent(in) :: key
154 type(dict_struct),
pointer :: dict
155 logical,
intent(out) :: ierr
156 type(dict_data),
pointer :: dicval
158 dicval => dict_get_key( dict, key )
160 if( .not.
associated(dicval) )
then
169 character(len=*),
intent(in) :: key
170 type(dict_struct),
pointer :: dict
171 type(dict_data),
pointer :: dicval
173 dicval => dict_get_key( dict, key )
175 if( .not.
associated(dicval) )
return
183 character(len=*),
intent(in) :: key
184 real(kind=kreal),
intent(in) :: a(:)
185 type(dict_struct),
pointer :: dict
186 real(kind=kreal),
intent(out) :: outa
187 logical,
intent(out) :: ierr
189 type(dict_data),
pointer :: dicval
190 integer :: na, dd, crow, cindex
191 dicval => dict_get_key( dict, key )
193 if( .not.
associated(dicval) )
then
200 if(
size(a) > dicval%ndepends )
then
201 na =
size(a) - dicval%ndepends+1
204 call gettablegrad( a(na:), cindex, dicval, dd, crow, outa )
210 recursive subroutine gettablegrad( a, cindex, table, dd, crow, outa )
211 real(kind=kreal),
intent(in) :: a(:)
212 integer,
intent(inout) :: cindex
213 type(dict_data) :: table
214 integer,
intent(inout) :: dd, crow
215 real(kind=kreal),
intent(out) :: outa
217 integer :: i, ccol, ddd
218 real(kind=kreal) :: val1, val2, lambda
220 ddd = dd / table%tbindex(cindex)
221 ccol = table%tbcol-cindex+1
224 if( a(cindex)<table%tbval(2, crow) )
then
226 elseif( a(cindex)>=table%tbval(2, crow+dd-1) )
then
230 if( a(cindex)>=table%tbval(2, i) .and. a(cindex)<table%tbval(2, i+1) )
then
231 outa = (table%tbval(1, i+1)-table%tbval(1, i))/(table%tbval(2, i+1)-table%tbval(2, i))
237 if( a(cindex)<=table%tbval(ccol, crow) )
then
240 call gettablegrad( a, cindex, table, dd, crow, outa )
241 elseif( a(cindex)>=table%tbval(ccol, crow+dd-1) )
then
245 call gettablegrad( a, cindex, table, dd, crow, outa )
247 do i=crow, crow+dd-2, ddd
248 if( a(cindex)==table%tbval(ccol, i) )
then
252 call gettablegrad( a, cindex, table, dd, crow, outa )
254 elseif( a(cindex)==table%tbval(ccol, i+ddd) )
then
258 call gettablegrad( a, cindex, table, dd, crow, outa )
260 elseif( a(cindex)>table%tbval(ccol, i) .and. a(cindex)<table%tbval(ccol, i+ddd) )
then
264 call gettablegrad( a, cindex, table, dd, crow, val1 )
266 call gettablegrad( a, cindex, table, dd, crow, val2 )
267 lambda = (a(cindex-1)-table%tbval(ccol, i))/(table%tbval(ccol, crow)-table%tbval(ccol, i))
268 outa = (1.d0-lambda)*val1+ lambda* val2
280 character(len=*),
intent(in) :: key
281 type(dict_struct),
pointer :: dict
282 real(kind=kreal),
intent(out) :: outa(:)
283 logical,
intent(out) :: ierr
284 real(kind=kreal),
intent(in),
optional :: a(:)
286 type(dict_data),
pointer :: dicval
287 integer :: nval, na, dd, crow, cindex
289 dicval => dict_get_key( dict, key )
291 if( .not.
associated(dicval) )
then
296 nval = dicval%tbcol-dicval%ndepends
297 if( nval /=
size(outa) )
then
300 if( dicval%tbrow==1 )
then
301 outa(:) =dicval%tbval(1:nval, 1);
return
303 if( .not.
present(a) )
then
304 outa(:) =dicval%tbval(1:nval, 1);
return
310 if(
size(a) > dicval%ndepends )
then
311 na =
size(a) - dicval%ndepends+1
317 call gettabledata( a(na:), cindex, dicval, dd, crow, outa )
323 recursive subroutine gettabledata( a, cindex, table, dd, crow, outa )
324 real(kind=kreal),
intent(in) :: a(:)
325 integer,
intent(inout) :: cindex
326 type(dict_data) :: table
327 integer,
intent(inout) :: dd, crow
328 real(kind=kreal),
intent(out) :: outa(:)
330 integer :: i, ccol, ddd, nval
333 ddd = dd / table%tbindex(cindex)
334 ccol = table%tbcol-cindex+1
338 if( a(cindex)<table%tbval(ccol, crow) )
then
339 outa(:) = table%tbval(1:ccol-1, crow)
340 elseif( a(cindex)>=table%tbval(ccol, crow+dd-1) )
then
341 outa(:) = table%tbval(1:ccol-1, crow+dd-1)
344 if( a(cindex)>=table%tbval(ccol, i) .and. a(cindex)<table%tbval(ccol, i+1) )
then
345 lambda = (a(cindex)-table%tbval(ccol, i))/(table%tbval(ccol, i+1)-table%tbval(ccol, i))
346 outa(:) = (1.d0-lambda)*table%tbval(1:ccol-1, i)+ lambda* table%tbval(1:ccol-1, i+1)
352 if( a(cindex)<=table%tbval(ccol, crow) )
then
355 call gettabledata( a, cindex, table, dd, crow, outa )
356 elseif( a(cindex)>=table%tbval(ccol, crow+dd-1) )
then
360 call gettabledata( a, cindex, table, dd, crow, outa )
362 do i=crow, crow+dd-2, ddd
363 if( a(cindex)==table%tbval(ccol, i) )
then
367 call gettabledata( a, cindex, table, dd, crow, outa )
369 elseif( a(cindex)==table%tbval(ccol, i+ddd) )
then
373 call gettabledata( a, cindex, table, dd, crow, outa )
375 elseif( a(cindex)>table%tbval(ccol, i) .and. a(cindex)<table%tbval(ccol, i+ddd) )
then
379 call gettabledata( a, cindex, table, dd, crow, val1(1:nval) )
381 call gettabledata( a, cindex, table, dd, crow, val2(1:nval) )
382 lambda = (a(cindex-1)-table%tbval(ccol, i))/(table%tbval(ccol, crow)-table%tbval(ccol, i))
383 outa(:) = (1.d0-lambda)*val1(1:nval)+ lambda* val2(1:nval)
395 type(dict_struct),
pointer :: dict
396 integer,
intent(in) :: fname
398 type(linked_list),
pointer :: current
400 do i = 1,
size(dict%table)
401 if (
associated( dict%table(i)%list ) )
then
402 current => dict%table(i)%list
403 do while (
associated(current) )
404 if( trim(current%data%key) /=
'INIT' )
then
405 write( fname, * ) trim(current%data%key)
408 current => current%next