31 subroutine get_amns_data(reaction_type,reactants,grid,source,shot,run,backend,user,ds_version,ierr,error_description,debug)
41 type (grid_t
),
intent(out) :: grid
42 character*(answer_length),
intent(out) :: source
45 real (kind=r8) :: zn, za
46 character (len=*) :: backend, user, ds_version
48 character*128 :: error_description
50 integer :: iza, nz, nproc,
i, k, j, isearch,
ndim, ncoord
53 character(len=5):: treename
54 integer :: idx, shot, run
55 logical :: found, done, match
56 character (len=256) :: file
57 integer :: nreac, nprod, nlhs, nrhs, ireac
58 real (kind=r8) :: zn_cpo, za_cpo
67 do while(
associated(work))
69 if(work%shot.eq.shot.and.work%run.eq.run)
then
79 if(.not.
associated(first))
then
84 else if(.not.
associated(last%next))
then
89 if(work%shot.eq.0)
then
91 if(backend.eq.
'ascii')
then
92 write(file,
'(a,''_'',i6.6,''_'',i6.6,''.CPO'')')
'amns',shot,run
93 if(debug)
write(*,*)
'Reading data from ', trim(file),
' for ', shot, run
94 call open_read_file(1, trim(file))
95 call read_cpo(work%amns_cpo,
'amns')
99 if(backend.eq.
'mdsplus')
then
100 if(debug)
write(*,*)
'Using mdsplus backend'
101 call euitm_open_env(treename,shot,run,idx,trim(user),
'amns',ds_version)
102 elseif(backend.eq.
'hdf5')
then
103 if(debug)
write(*,*)
'Using hdf5 backend'
104 call euitm_open_hdf5(treename,shot,run,idx)
106 error_description =
'Backend not yet supported: ' // trim(backend)
107 write(*,*) error_description
111 call euitm_get(idx,
'amns',work%amns_cpo)
112 call euitm_close(idx)
114 error_description =
'The AMNS routines were compiled without UAL support. ' // &
115 'Use the ascii backend'
116 write(*,*) error_description
126 nproc=
SIZE(work%amns_cpo(1)%process)
129 do isearch = 1, nproc
131 if(reaction_type%string .ne. work%amns_cpo(1)%process(isearch)%proc_label(1)) cycle
134 if(
associated(work%amns_cpo(1)%process(isearch)%reactant))
then
135 nreac =
size(work%amns_cpo(1)%process(isearch)%reactant)
139 if(
associated(work%amns_cpo(1)%process(isearch)%product))
then
140 nprod =
size(work%amns_cpo(1)%process(isearch)%product)
149 if(
reactants%components(ireac)%lr .eq. 0)
then
150 if (nrhs .ne. 0)
then
151 error_description =
'Reactants should precede products'
152 write (*,*) error_description
157 else if(
reactants%components(ireac)%lr .eq. 1)
then
160 write(error_description,*)
'Unknown lr option ',
reactants%components(ireac)%lr, &
161 ' for component ', ireac
162 write(*,*) error_description
169 if (debug)
write(*,*)
'nreac/nprod', isearch, nreac, nprod, nlhs, nrhs
170 if(nreac .ne. nlhs) cycle
171 if(nprod .ne. nrhs) cycle
177 if(
associated(work%amns_cpo(1)%process(isearch)%reactant(ireac)%constituents))
then
178 if(
size(work%amns_cpo(1)%process(isearch)%reactant(ireac)%constituents) .eq. 1)
then
180 zn_cpo = work%amns_cpo(1)%process(isearch)%reactant(ireac)%constituents(1)%zn
187 error_description =
'Case with number of constituents != 1 not yet coded'
188 write(*,*) error_description
193 error_description =
'Must have at least one constituent'
194 write(*,*) error_description
198 if (debug)
write(*,*)
'zn', isearch, ireac, zn_cpo,
reactants%components(ireac)%zn
199 match = match .and. (nint(
reactants%components(ireac)%zn) .eq. nint(zn_cpo))
200 if (.not. match) cycle
203 if(work%amns_cpo(1)%process(isearch)%reactant(ireac)%relative .eq. -1)
then
205 if (debug)
write(*,*)
'za', isearch, ireac,
'za not relavant'
206 else if(work%amns_cpo(1)%process(isearch)%reactant(ireac)%relative .eq. 0)
then
208 if (debug)
write(*,*)
'za', isearch, ireac,
'absolute charge', work%amns_cpo(1)%process(isearch)%reactant(ireac)%za,
reactants%components(ireac)%za
209 match = match .and. (work%amns_cpo(1)%process(isearch)%reactant(ireac)%za .eq.
reactants%components(ireac)%za)
210 else if(work%amns_cpo(1)%process(isearch)%reactant(ireac)%relative .eq. 1 )
then
214 if (debug)
write(*,*)
'za', isearch, ireac,
'relative charge', work%amns_cpo(1)%process(isearch)%reactant(ireac)%za,
reactants%components(ireac)%za
216 write(error_description,*)
'Unrecognized value for relative ', work%amns_cpo(1)%process(isearch)%reactant(ireac)%relative
217 write(*,*) error_description
221 if (.not. match) cycle
224 write(*,*)
'am', isearch, ireac, work%amns_cpo(1)%process(isearch)%reactant(ireac)%amn,
reactants%components(ireac)%mi
226 if(nint(work%amns_cpo(1)%process(isearch)%reactant(ireac)%amn) .ne. 0 .and. nint(
reactants%components(ireac)%mi) .ne. 0)
then
227 match = match .and. (nint(work%amns_cpo(1)%process(isearch)%reactant(ireac)%amn) .eq. nint(
reactants%components(ireac)%mi))
229 if (.not. match) cycle
231 if (.not. match) cycle
236 if(
associated(work%amns_cpo(1)%process(isearch)%product(ireac)%constituents))
then
237 if(
size(work%amns_cpo(1)%process(isearch)%product(ireac)%constituents) .eq. 1)
then
239 zn_cpo = work%amns_cpo(1)%process(isearch)%product(ireac)%constituents(1)%zn
245 error_description =
'Case with number of constituents != 1 not yet coded'
246 write(*,*) error_description
251 error_description =
'Must have at least one constituent'
252 write(*,*) error_description
256 if (debug)
write(*,*)
'zn', isearch, ireac, zn_cpo,
reactants%components(ireac+nlhs)%zn
257 match = match .and. (nint(
reactants%components(ireac+nlhs)%zn) .eq. nint(zn_cpo))
260 if(work%amns_cpo(1)%process(isearch)%product(ireac)%relative .eq. -1)
then
262 if (debug)
write(*,*)
'za', isearch, ireac,
'za not relavant'
263 else if(work%amns_cpo(1)%process(isearch)%product(ireac)%relative .eq. 0)
then
265 if (debug)
write(*,*)
'za', isearch, ireac,
'absolute charge', work%amns_cpo(1)%process(isearch)%product(ireac)%za,
reactants%components(ireac+nlhs)%za
266 match = match .and. (work%amns_cpo(1)%process(isearch)%product(ireac)%za .eq. &
268 else if(work%amns_cpo(1)%process(isearch)%product(ireac)%relative .eq. 1 )
then
271 if (debug)
write(*,*)
'za', isearch, ireac,
'relative charge', work%amns_cpo(1)%process(isearch)%product(ireac)%za,
reactants%components(ireac+nlhs)%za
273 write(error_description,*)
'Unrecognized value for relative ', work%amns_cpo(1)%process(isearch)%reactant(ireac)%relative
274 write(*,*) error_description
278 if (.not. match) cycle
280 if(debug)
write(*,*)
'am', isearch, ireac, work%amns_cpo(1)%process(isearch)%product(ireac)%amn,
reactants%components(ireac+nlhs)%mi
281 if(nint(work%amns_cpo(1)%process(isearch)%product(ireac)%amn) .ne. 0 .and. nint(
reactants%components(ireac+nlhs)%mi) .ne. 0)
then
282 match = match .and. (nint(work%amns_cpo(1)%process(isearch)%product(ireac)%amn) .eq. nint(
reactants%components(ireac+nlhs)%mi))
284 if (.not. match) cycle
286 if (.not. match) cycle
292 write(error_description,*)
'GET_AMNS_DATA: Case ',trim(reaction_type%string),
' not yet implemented'
294 write(*,*) error_description
295 do isearch = 1, nproc
296 write(*,*)
'Process ', isearch,
' = ' , work%amns_cpo(1)%process(isearch)%proc_label(1)
303 ndim = work%amns_cpo(1)%tables(k)%ndim
304 ncoord=work%amns_cpo(1)%tables(k)%coord_index
305 if(iza .eq. -1) iza=1
306 if(
size(work%amns_cpo(1)%tables(k)%table) .eq. 1) iza=1
307 if(iza .gt.
size(work%amns_cpo(1)%tables(k)%table))
then
308 error_description =
'iza out of bounds'
309 write(*,*) error_description
316 if(.not.
associated(work%amns_cpo(1)%tables(k)%table(iza)%table_1d))
then
317 if (debug)
write(*,*)
'Special treatment for 1d functions requiring a 2d table'
318 if(
associated(work%amns_cpo(1)%tables(k)%table(iza)%table_2d))
then
328 call new_grid(grid, &
329 work%amns_cpo(1)%tables(k)%table(iza)%table_1d(:), &
330 work%amns_cpo(1)%tables_coord(ncoord)%coords(1)%coord(:))
332 call new_grid(grid, &
333 work%amns_cpo(1)%tables(k)%table(iza)%table_1d(:))
337 call new_grid(grid, &
338 work%amns_cpo(1)%tables(k)%table(iza)%table_2d(:,:), &
339 work%amns_cpo(1)%tables_coord(ncoord)%coords(1)%coord(:), &
340 work%amns_cpo(1)%tables_coord(ncoord)%coords(2)%coord(:))
342 call new_grid(grid, &
343 work%amns_cpo(1)%tables(k)%table(iza)%table_2d(:,:))
347 call new_grid(grid, &
348 work%amns_cpo(1)%tables(k)%table(iza)%table_3d(:,:,:), &
349 work%amns_cpo(1)%tables_coord(ncoord)%coords(1)%coord(:), &
350 work%amns_cpo(1)%tables_coord(ncoord)%coords(2)%coord(:), &
351 work%amns_cpo(1)%tables_coord(ncoord)%coords(3)%coord(:))
353 call new_grid(grid, &
354 work%amns_cpo(1)%tables(k)%table(iza)%table_3d(:,:,:))
358 call new_grid(grid, &
359 work%amns_cpo(1)%tables(k)%table(iza)%table_4d(:,:,:,:), &
360 work%amns_cpo(1)%tables_coord(ncoord)%coords(1)%coord(:), &
361 work%amns_cpo(1)%tables_coord(ncoord)%coords(2)%coord(:), &
362 work%amns_cpo(1)%tables_coord(ncoord)%coords(3)%coord(:), &
363 work%amns_cpo(1)%tables_coord(ncoord)%coords(4)%coord(:))
365 call new_grid(grid, &
366 work%amns_cpo(1)%tables(k)%table(iza)%table_4d(:,:,:,:))
370 write(*)
'0D and 5D can be implemented later'
374 grid%ndim=work%amns_cpo(1)%tables(k)%ndim
375 if(work%amns_cpo(1)%tables(k)%result_trans == 0)
then
377 elseif(work%amns_cpo(1)%tables(k)%result_trans == 1)
then
380 grid%interpol_function = work%amns_cpo(1)%tables(k)%result_trans
382 if(
associated(work%amns_cpo(1)%tables(k)%state_label))
then
383 if(
size(work%amns_cpo(1)%tables(k)%state_label).ge.iza)
then
384 grid%state_label=work%amns_cpo(1)%tables(k)%state_label(iza)
389 if(
associated(work%amns_cpo(1)%tables(k)%result_label))
then
390 grid%result_label=work%amns_cpo(1)%tables(k)%result_label(1)
394 if(
associated(work%amns_cpo(1)%tables(k)%result_unit))
then
395 grid%result_unit=work%amns_cpo(1)%tables(k)%result_unit(1)
401 if(work%amns_cpo(1)%tables_coord(ncoord)%coords(j)%transform == 0)
then
402 grid%axe(j)%is_lin= .true.
403 elseif(work%amns_cpo(1)%tables_coord(ncoord)%coords(j)%transform == 1)
then
404 grid%axe(j)%is_log= .true.
406 write(*,*)
'The coordinate transformation is unknown, the process', trim(reaction_type%string)
408 grid%axe(j)%lbound= lbound(grid%axe(j)%x, 1)
413 if(
associated(work%amns_cpo(1)%source))
then
414 if(
size(work%amns_cpo(1)%source).ge.1)
then
415 source=work%amns_cpo(1)%source(1)
417 source=
"Not specified in the AMNS CPO"
420 source=
"Not specified in the AMNS CPO"
430 use deallocate_structures
437 do while(
associated(work))
439 call deallocate_cpo(work%amns_cpo)
Type for linked list of amns cpos NOT interoperable with C.
subroutine end_amns_data
deallocate cpos
subroutine get_amns_data(reaction_type, reactants, grid, source, shot, run, backend, user, ds_version, ierr, error_description, debug)
transfer data from the CPO to the internal data structure
if error_status np ndarray[np.double_t, ndim=2] np ndarray[np.double_t, ndim=2] np ndarray[np.double_t, ndim=2] ndim
Module implementing various utility functions for the AMNS interface.
Type used for specifying reactions when using the AMNS interface ("interoperable" version) ...
if error_status answer number def version(self) if error_status &error_status if error_status Reactants reactants
Type for indicating the reactants when using the AMNS interface NOT interoperable with C...
f90_kind module from Silvio Gori's grid package
The derived types defined here are meant to be interoperable with C. The ones for this is not the cas...