ITM AMNS: User Interface  \$Id: Doxyfile 502 2015-10-15 12:23:45Z dpc $
amns_module.F90
Go to the documentation of this file.
1 
10 
12 
13  use euitm_schemas
14 
15  implicit none
16 
27  interface itm_amns_rx
28 
30 
31  end interface
32 
33  integer, save :: version_no
34  character (len=256), save :: USER
35  character (len=32), save :: ds_version='4.10b', backend='mdsplus', dataversion_tag=DATAVERSION_TAG, &
36  local_dataversion_tag=''
37  type (type_amns), save, pointer :: amns00(:)
38 
39 contains
40 
41  ! ================================================================================================================ !
47  subroutine itm_amns_setup(handle, version, error_status)
48  use itm_types
49  use amns_types
50  use euitm_schemas ! IGNORE
51  use euitm_routines ! IGNORE
52  use read_structures ! IGNORE
53  implicit none
54  optional version, error_status
55  type(amns_handle_type), intent(out) :: handle
56  type(amns_version_type), intent(in) :: version
57  type(amns_error_type), intent(out) :: error_status
58 
59  type(amns_version_type) :: default_version
60 
61 #ifdef UAL
62  integer :: euitm_open_env, euitm_open_hdf5, euitm_create_env, euitm_create_hdf5
63  integer :: euitm_status
64 #endif
65  integer :: idx
66  integer :: shot, run
67  character (len=256) :: file
68  character(len=5) :: treename = 'euitm'
69  character(len=4) :: amnspath = 'amns'
70 
71  character(len=32) :: amns_debug_env
72  logical :: amns_debug
73 
74  if(present(error_status)) then
75  error_status%flag=.false.
76  error_status%string="No error"
77  end if
78 
79  call getenv('ITM_AMNS_DEBUG', amns_debug_env)
80  amns_debug = amns_debug_env.eq."yes" .or. amns_debug_env.eq."YES" .or. amns_debug_env.eq."Yes"
81  if (amns_debug) handle%debug = .true.
82  amns_debug = amns_debug_env.eq."no" .or. amns_debug_env.eq."NO" .or. amns_debug_env.eq."No"
83  if (amns_debug) handle%debug = .false.
84 
85  if(handle%debug) write(*,*) 'ITM_AMNS_SETUP start'
86 
87  call getenv('DATAVERSION_TAG', local_dataversion_tag)
88  if(local_dataversion_tag .ne. dataversion_tag) then
89  write(*,*) 'The AMNS library was compiled for datastructure version ', trim(dataversion_tag)
90  write(*,*) 'It is being used in an environment with datastructure version ', trim(local_dataversion_tag)
91  write(*,*) 'This is likely to be a major problem --- aborting!'
92  if(present(error_status)) then
93  error_status%flag=.true.
94  error_status%string="AMNS library mismatch"
95  return
96  else
97  stop 'AMNS library mismatch'
98  end if
99  endif
100 
101  default_version%string='DEFAULT'
102  call getenv('USER', user)
103  default_version%user = user
104  call getenv('DATAVERSION', ds_version)
105  write(*,*) 'Using DATAVERSION ', trim(ds_version)
106 
107  if(present(version)) then
108  if(handle%debug) write(*,*) 'ITM_AMNS_SETUP: requested database = ',trim(version%string), version%number
109  handle%version=version
110  version_no = version%number
111  if(version%user .eq. '') then
112  handle%version%USER = user
113  write(*,*) 'Reset USER to ', trim(user)
114  endif
115  else
116  handle%version=default_version
117  version_no = -1
118  endif
119  if(handle%version%backend .eq. '') then
120  handle%version%backend = backend
121  endif
122 
123 ! get the index information from 0/1
124  shot=0
125  run=1
126  if(handle%version%backend.eq.'ascii') then
127  write(file,'(a,''_'',i6.6,''_'',i6.6,''.CPO'')') 'amns',shot,run
128  write(*,*) 'Reading data from ', trim(file), ' for ', shot, run
129  call open_read_file(1, trim(file))
130  call read_cpo(amns00, 'amns')
131  call close_read_file
132 #ifdef UAL
133  elseif(handle%version%backend.eq.'hdf5') then
134  euitm_status = euitm_open_hdf5(treename, shot, run, idx)
135  write(*,*) 'EUITM_STATUS, IDX = ', euitm_status, idx
136  call euitm_get(idx, amnspath, amns00)
137  call euitm_close(idx)
138  elseif(handle%version%backend.eq.'mdsplus') then
139  euitm_status = euitm_open_env(treename, shot, run, idx, &
140  trim(handle%version%USER), 'amns', trim(ds_version))
141  write(*,*) 'EUITM_STATUS, IDX = ', euitm_status, idx
142  if(euitm_status.ne.0) then
143  handle%version%USER = 'public'
144  euitm_status = euitm_open_env(treename, shot, run, idx, &
145  trim(handle%version%USER), 'amns', trim(ds_version))
146  write(*,*) 'EUITM_STATUS, IDX = ', euitm_status, idx
147  if(euitm_status.ne.0) then
148  write(*,*) 'Could not find any AMNS data, even under "public"'
149  if(present(error_status)) then
150  error_status%flag=.true.
151  error_status%string='Could not find any AMNS data, even under "public"'
152  return
153  else
154  stop 'Could not find any AMNS data, even under "public"'
155  end if
156  endif
157  endif
158  call euitm_get(idx, amnspath, amns00)
159  call euitm_close(idx)
160 #else
161  else
162  write(*,*) 'The version of the AMNS routines without the UAL was compiled'
163  write(*,*) 'Use the ascii backend'
164  if(present(error_status)) then
165  error_status%flag=.true.
166  error_status%string='Error - UAL called in a non-UAL version of the code'
167  return
168  else
169  stop 'Error - UAL called in a non-UAL version of the code'
170  end if
171 #endif
172  endif
173  if(.not.associated(amns00(1)%version_ind)) then
174  write(*,*) 'No version information in INDEX shot'
175  if(present(error_status)) then
176  error_status%flag=.true.
177  error_status%string="No version information in INDEX shot"
178  return
179  else
180  stop "No version information in INDEX shot"
181  end if
182  endif
183  if(version_no.le.0) then
184  version_no=size(amns00(1)%version_ind)
185  if(handle%debug) write(*,*) 'Found global version # ', version_no
186  else
187  if(version_no.gt.size(amns00(1)%version_ind)) then
188  write(*,*) 'Requested version out of range ', version_no, ' > ', size(amns00(1)%version_ind)
189  if(present(error_status)) then
190  error_status%flag=.true.
191  error_status%string="Requested version out of range"
192  return
193  else
194  stop 'Requested version out of range'
195  end if
196  endif
197  endif
198  handle%version%string = trim(handle%version%USER) // ': ' // trim(handle%version%backend)
199  handle%version%number = version_no
200 
201  if(present(error_status)) then
202  if(handle%debug) write(*,*) 'ITM_AMNS_SETUP: requested error_status response'
203  endif
204  handle%initialized=.true.
205  if(handle%debug) write(*,*) 'ITM_AMNS_SETUP end'
206 
207  end subroutine itm_amns_setup
208 
209  ! ================================================================================================================ !
217  subroutine itm_amns_setup_table(handle, reaction_type, reactants, handle_rx, error_status)
218  use itm_types
219  use amns_types
220  use amns_utility
222  ! do not remove the comment!!!
223  use euitm_schemas ! IGNORE
224  use euitm_routines ! IGNORE
225 
226  implicit none
227  optional error_status
228  type(amns_handle_type), intent(in) :: handle
229  type(amns_reaction_type), intent(in) :: reaction_type
230  type(amns_reactants_type), intent(in) :: reactants
231  type(amns_handle_rx_type), intent(out) :: handle_rx
232  type(amns_error_type), intent(out) :: error_status
233 
234  integer :: no_of_reactants, i, is
235  integer :: izn, izm, shot, run, ierr
236  character*128 :: data_file, error_description
237  integer :: iversion, nrelease, irelease
238 
239  if(present(error_status)) then
240  error_status%flag=.false.
241  error_status%string="No error"
242  end if
243 
244  handle_rx%debug= handle%debug
245  handle_rx%reaction_type= reaction_type%string
246  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SETUP_TABLE start'
247  izn=0
248  izm=0
249  if(allocated(reactants%components)) then
250  no_of_reactants=size(reactants%components)
251  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SETUP_TABLE: number of reactants = ',no_of_reactants
252  do i=1,no_of_reactants
253 ! only reactants, not products
254  if(reactants%components(i)%lr .eq. 0 .and. &
255  (reactants%components(i)%int_specifier .ge. 0 .or. reactants%components(i)%int_specifier .eq. itm_int_invalid)) then
256  if(nint(reactants%components(i)%ZN) .gt. izn) then
257  izn=nint(reactants%components(i)%ZN)
258  if(reaction_type%isotope_resolved .ne. 0) izm=nint(reactants%components(i)%MI)
259  else if(nint(reactants%components(i)%ZN) .eq. izn .and. reaction_type%isotope_resolved .ne. 0) then
260  izm=max(izm,nint(reactants%components(i)%MI))
261  endif
262  endif
263  if(handle_rx%debug) &
264  write(*,'(a,i3,3(1x,f6.2),i2)') 'ITM_AMNS_SETUP_TABLE: reactant# ZN, ZA, MI, LR = ', &
265  i,reactants%components(i)%ZN, &
266  reactants%components(i)%ZA, &
267  reactants%components(i)%MI, &
268  reactants%components(i)%lr
269  enddo
270  handle_rx%no_of_reactants=no_of_reactants
271  allocate(handle_rx%components(no_of_reactants))
272  handle_rx%components=reactants%components
273  else
274  no_of_reactants=0
275  handle_rx%no_of_reactants=0
276  endif
277  if(allocated(reactants%string)) then
278  allocate(handle_rx%string(size(reactants%string)))
279  handle_rx%string=reactants%string
280  endif
281  if(present(error_status)) then
282  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SETUP_TABLE: requested error_status response'
283  endif
284 ! find local version number for shot
285  shot=izn+1000*izm
286  if(shot.eq.0) then
287  if(present(error_status)) then
288  error_status%flag=.true.
289  return
290  else
291  write(*,*) 'Could not calculate the AMNS shot number'
292  if(present(error_status)) then
293  error_status%flag=.true.
294  error_status%string="Could not calculate the AMNS shot number"
295  return
296  else
297  stop 'Could not calculate the AMNS shot number'
298  end if
299  endif
300  endif
301  run=0
302  iversion=handle%version%number
303  if(associated(amns00(1)%version_ind(iversion)%data_release)) then
304  nrelease=size(amns00(1)%version_ind(iversion)%data_release)
305  do irelease=1, nrelease ! loop over data in a version
306  if(amns00(1)%version_ind(iversion)%data_release(irelease)%shot .eq. shot) then
307  run=amns00(1)%version_ind(iversion)%data_release(irelease)%run
308  exit
309  endif
310  enddo
311  endif
312  if(run.eq.0) then
313  if(present(error_status)) then
314  error_status%flag=.true.
315  write(error_status%string,*) 'No data found for ', shot, ' in version ', iversion
316  return
317  else
318  write(*,*) 'No data found for ', shot, ' in version ', iversion
319  stop 'No data found'
320  endif
321  else
322  if(handle_rx%debug) write(*,*) 'Found local version ', run, ' for case = ', shot
323  handle_rx%version%number = run
324  ! now handle the various reaction possibilities
325 
326  call get_amns_data(reaction_type, reactants, &
327  handle_rx%grid, handle_rx%source, shot, run, handle%version%backend, handle%version%user, ds_version, ierr, error_description, handle_rx%debug)
328  if(ierr.eq.0) then
329  handle_rx%filled=.true.
330  else
331  if(present(error_status)) then
332  error_status%flag=.true.
333  error_status%string="'get_amns_data' returned an error - " // error_description
334  return
335  else
336  stop "'get_amns_data' returned an error"
337  end if
338  endif
339  handle_rx%initialized=.true.
340  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SETUP_TABLE end'
341  endif
342  end subroutine itm_amns_setup_table
343 
344  ! ================================================================================================================ !
349  subroutine itm_amns_finish(handle, error_status)
350  use itm_types
351  use amns_types
352  use amns_utility
354  use deallocate_structures ! IGNORE
355  implicit none
356  optional error_status
357  type(amns_handle_type), intent(inout) :: handle
358  type(amns_error_type), intent(out) :: error_status
359 
360  if(present(error_status)) then
361  error_status%flag=.false.
362  error_status%string="No error"
363  end if
364 
365  if(handle%debug) write(*,*) 'ITM_AMNS_FINISH start'
366  if(handle%initialized) then
367  handle%initialized=.false.
368  else
369  if(handle%debug) write(*,*) 'ITM_AMNS_FINISH: Attempt to FINISH an uninitialized case'
370  endif
371  if(present(error_status)) then
372  if(handle%debug) write(*,*) 'ITM_AMNS_SETUP_TABLE: requested error_status response'
373  endif
374  call end_amns_data
375  call deallocate_cpo(amns00)
376  if(handle%debug) write(*,*) 'ITM_AMNS_FINISH end'
377 
378  end subroutine itm_amns_finish
379 
380  ! ================================================================================================================ !
385  subroutine itm_amns_finish_table(handle_rx, error_status)
386  use itm_types
387  use amns_types
388  implicit none
389  optional error_status
390  type(amns_handle_rx_type), intent(inout) :: handle_rx
391  type(amns_error_type), intent(out) :: error_status
392 
393  if(present(error_status)) then
394  error_status%flag=.false.
395  error_status%string="No error"
396  end if
397 
398  if(handle_rx%debug) write(*,*) 'ITM_AMNS_FINISH_TABLE start'
399  if(handle_rx%initialized) then
400  handle_rx%initialized=.false.
401  if(allocated(handle_rx%components)) then
402  deallocate(handle_rx%components)
403  endif
404  handle_rx%no_of_reactants=0
405  if(allocated(handle_rx%string)) then
406  deallocate(handle_rx%string)
407  endif
408  call delete(handle_rx%grid)
409  else
410  if(handle_rx%debug) write(*,*) 'ITM_AMNS_FINISH_TABLE: Attempt to FINISH an uninitialized table'
411  endif
412  if(present(error_status)) then
413  if(handle_rx%debug) write(*,*) 'ITM_AMNS_FINISH_TABLE: requested error_status response'
414  endif
415  if(handle_rx%debug) write(*,*) 'ITM_AMNS_FINISH_TABLE end'
416 
417  end subroutine itm_amns_finish_table
418 
419  ! ================================================================================================================ !
428  subroutine itm_amns_query(handle,query,answer,error_status)
429  use itm_types
430  use amns_types
431  implicit none
432  optional error_status
433  type(amns_handle_type), intent(in) :: handle
434  type(amns_query_type), intent(in) :: query
435  type(amns_answer_type), intent(out) :: answer
436  type(amns_error_type), intent(out) :: error_status
437 
438  if(present(error_status)) then
439  error_status%flag=.false.
440  error_status%string="No error"
441  end if
442 
443  if(handle%debug) write(*,*) 'ITM_AMNS_QUERY start'
444  if(handle%debug) write(*,*) 'ITM_AMNS_QUERY: query = ',trim(query%string)
445 ! The choices are documented in the doxygen block above
446  select case (query%string)
447  case ("version") ! \property version: information about the version
448  answer%string=handle%version%string
449  answer%number=handle%version%number
450  case default
451  answer%string='Not implemented yet'
452  end select
453  if(present(error_status)) then
454  if(handle%debug) write(*,*) 'ITM_AMNS_QUERY: requested error_status response'
455  endif
456  if(handle%debug) write(*,*) 'ITM_AMNS_QUERY end'
457 
458  end subroutine itm_amns_query
459 
460  ! ================================================================================================================ !
480  subroutine itm_amns_query_table(handle_rx,query,answer,error_status)
481  use itm_types
482  use amns_types
483  use amns_utility
484  implicit none
485  optional error_status
486  type(amns_handle_rx_type), intent(in) :: handle_rx
487  type(amns_query_type), intent(in) :: query
488  type(amns_answer_type), intent(out) :: answer
489  type(amns_error_type), intent(out) :: error_status
490  integer ir
491 
492  if(present(error_status)) then
493  error_status%flag=.false.
494  error_status%string="No error"
495  end if
496 
497  if(handle_rx%debug) write(*,*) 'ITM_AMNS_QUERY_TABLE start'
498  if(handle_rx%debug) write(*,*) 'ITM_AMNS_QUERY_TABLE: query = ',trim(query%string)
499 ! The choices are documented in the doxygen block above
500  select case (query%string)
501  case ("source")
502  answer%string=handle_rx%source
503  case ("no_of_reactants")
504  answer%string=string(handle_rx%no_of_reactants)
505  answer%number=handle_rx%no_of_reactants
506  case ("index")
507  answer%string=string(handle_rx%index)
508  answer%number=handle_rx%index
509  case ("filled")
510  if(handle_rx%filled) then
511  answer%string= 'Filled'
512  else
513  answer%string= 'Empty'
514  endif
515  case ("reaction_type")
516  answer%string= handle_rx%reaction_type
517  case ("reactants")
518  answer%string=""
519  do ir=1,handle_rx%no_of_reactants
520  answer%string= trim(answer%string) // " " // &
521  trim(string(nint(handle_rx%components(ir)%ZN))) // "/" // &
522  trim(string(nint(handle_rx%components(ir)%ZA))) // "/" // &
523  trim(string(nint(handle_rx%components(ir)%MI))) // "/" // &
524  trim(string(handle_rx%components(ir)%LR))
525  enddo
526  answer%string= adjustl(answer%string)
527  case ("version")
528  answer%string=""
529  answer%number=handle_rx%version%number
530  case ("state_label")
531  answer%string=handle_rx%grid%state_label
532  answer%number=-1
533  case ("result_unit")
534  answer%string=handle_rx%grid%result_unit
535  answer%number=-1
536  case ("result_label")
537  answer%string=handle_rx%grid%result_label
538  answer%number=-1
539  case ("ndim")
540  answer%string=string(handle_rx%grid%ndim)
541  answer%number=handle_rx%grid%ndim
542  case ("interp_fun")
543  answer%string=string(handle_rx%grid%interpol_function)
544  answer%number=handle_rx%grid%ndim
545  case default
546  answer%string='Not implemented yet'
547  end select
548  if(present(error_status)) then
549  if(handle_rx%debug) write(*,*) 'ITM_AMNS_QUERY_TABLE: requested error_status response'
550  endif
551  if(handle_rx%debug) write(*,*) 'ITM_AMNS_QUERY_TABLE end'
552 
553  end subroutine itm_amns_query_table
554 
555  ! ================================================================================================================ !
567  subroutine itm_amns_set(handle,set,error_status)
568  use itm_types
569  use amns_types
570  implicit none
571  optional error_status
572  type(amns_handle_type), intent(inout) :: handle
573  type(amns_set_type), intent(in) :: set
574  type(amns_error_type), intent(out) :: error_status
575 
576  if(present(error_status)) then
577  error_status%flag=.false.
578  error_status%string="No error"
579  end if
580 
581  if(handle%debug) write(*,*) 'ITM_AMNS_SET start'
582  if(handle%debug) write(*,*) 'ITM_AMNS_SET: set = ',trim(set%string)
583  if(present(error_status)) then
584  if(handle%debug) write(*,*) 'ITM_AMNS_SET_TABLE: requested error_status response'
585  endif
586 ! The choices are documented in the doxygen block above
587  select case(set%string)
588  case ("debug")
589  handle%debug=.true.
590  case ("nodebug")
591  handle%debug=.false.
592  case ("backend=mdsplus")
593  handle%version%backend='mdsplus'
594  case ("backend=hdf5")
595  handle%version%backend='hdf5'
596  case ("backend=ascii")
597  handle%version%backend='ascii'
598  case default
599  write(*,*) "ITM_AMNS_SET: not yet implemented ", trim(set%string)
600  end select
601  if(handle%debug) write(*,*) 'ITM_AMNS_SET end'
602 
603  end subroutine itm_amns_set
604 
605  ! ================================================================================================================ !
616  subroutine itm_amns_set_table(handle_rx,set,error_status)
617  use itm_types
618  use amns_types
619  implicit none
620  optional error_status
621  type(amns_handle_rx_type), intent(inout) :: handle_rx
622  type(amns_set_type), intent(in) :: set
623  type(amns_error_type), intent(out) :: error_status
624 
625  if(present(error_status)) then
626  error_status%flag=.false.
627  error_status%string="No error"
628  end if
629 
630  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SET_TABLE start'
631  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SET_TABLE: set = ',trim(set%string)
632 ! The choices are documented in the doxygen block above
633  select case (set%string)
634  case ("warn")
635  if(handle_rx%filled) then
636  call set_option(handle_rx%grid,.true.)
637  else
638  write(*,*) 'ITM_AMNS_SET_TABLE: Attempt to set WARN using an unfilled table'
639  endif
640  case ("nowarn")
641  if(handle_rx%filled) then
642  call set_option(handle_rx%grid,.false.)
643  else
644  write(*,*) 'ITM_AMNS_SET_TABLE: Attempt to set NOWARN using an unfilled table'
645  endif
646  case ("debug")
647  handle_rx%debug=.true.
648  case ("nodebug")
649  handle_rx%debug=.false.
650  case default
651  write(*,*) 'ITM_AMNS_SET_TABLE: not implemeted yet '
652  end select
653  if(present(error_status)) then
654  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SET_TABLE: requested error_status response'
655  endif
656  if(handle_rx%debug) write(*,*) 'ITM_AMNS_SET_TABLE end'
657 
658  end subroutine itm_amns_set_table
659 
660  ! ================================================================================================================ !
668  subroutine itm_amns_rx_0(handle_rx,out,arg1,arg2,arg3,error_status)
669  use itm_types
670  use amns_types
671  use data_suport
672 ! use ieee_arithmetic ! IGNORE
673  implicit none
674  optional arg2,arg3,error_status
675  type(amns_handle_rx_type), intent(inout) :: handle_rx
676  real (kind=R8), intent(out) :: out
677  real (kind=R8), intent(in) :: arg1,arg2,arg3
678  type(amns_error_type), intent(out) :: error_status
679 
680  type(data_error_t) :: data_error
681  real (kind=R8) :: out_d(1),arg1_d(1),arg2_d(1),arg3_d(1)
682 
683 ! LOGICAL :: SG
684 
685  if(present(error_status)) then
686  error_status%flag=.false.
687  error_status%string="No error"
688  end if
689 
690  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_0 start'
691 
692 ! CALL IEEE_GET_UNDERFLOW_MODE (SG)
693 ! CALL IEEE_SET_UNDERFLOW_MODE (.TRUE.)
694 
695  if(present(arg3)) then
696  if(present(arg2)) then
697  if(handle_rx%filled) then
698  arg1_d(1)=arg1
699  arg2_d(1)=arg2
700  arg3_d(1)=arg3
701  call interpol( &
702  reshape(arg1_d,(/size(arg1_d)/)), &
703  reshape(arg2_d,(/size(arg2_d)/)), &
704  reshape(arg3_d,(/size(arg3_d)/)), &
705  fd1=out_d, grid=handle_rx%grid, &
706  data_error=data_error)
707  if(present(error_status)) then
708  error_status%flag = data_error%ierr .ne. 0
709  error_status%string = data_error%cerr
710  else
711  if(data_error%ierr.ne.0) then
712  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
713  stop 'error in interpol'
714  endif
715  endif
716  out=out_d(1)
717  else
718  write(*,*) 'ITM_AMNS_RX_0: Attempt to INTERPOLATE using an unfilled table'
719  endif
720  else
721  write(*,*) 'ITM_AMNS_RX_0: arg3 present but not arg2!'
722  endif
723  else
724  if(present(arg2)) then
725  if(handle_rx%filled) then
726  arg1_d(1)=arg1
727  arg2_d(1)=arg2
728  call interpol( &
729  reshape(arg1_d,(/size(arg1_d)/)), &
730  reshape(arg2_d,(/size(arg2_d)/)), &
731  fd1=out_d, grid=handle_rx%grid, &
732  data_error=data_error)
733  if(present(error_status)) then
734  error_status%flag = data_error%ierr .ne. 0
735  error_status%string = data_error%cerr
736  else
737  if(data_error%ierr.ne.0) then
738  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
739  stop 'error in interpol'
740  endif
741  endif
742  out=out_d(1)
743  else
744  write(*,*) 'ITM_AMNS_RX_0: Attempt to INTERPOLATE using an unfilled table'
745  endif
746  else
747  if(handle_rx%filled) then
748  arg1_d(1)=arg1
749  call interpol( &
750  reshape(arg1_d,(/size(arg1_d)/)), &
751  fd1=out_d, grid=handle_rx%grid, &
752  data_error=data_error)
753  if(present(error_status)) then
754  error_status%flag = data_error%ierr .ne. 0
755  error_status%string = data_error%cerr
756  else
757  if(data_error%ierr.ne.0) then
758  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
759  stop 'error in interpol'
760  endif
761  endif
762  out=out_d(1)
763  else
764  write(*,*) 'ITM_AMNS_RX_0: Attempt to INTERPOLATE using an unfilled table'
765  endif
766  endif
767  endif
768 ! CALL IEEE_SET_UNDERFLOW_MODE (SG)
769  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_0 end'
770 
771  end subroutine itm_amns_rx_0
772 
773  ! ================================================================================================================ !
781  subroutine itm_amns_rx_1(handle_rx,out,arg1,arg2,arg3,error_status)
782  use itm_types
783  use amns_types
784  use data_suport
785 ! use ieee_arithmetic ! IGNORE
786  implicit none
787  optional arg2,arg3,error_status
788  type(amns_handle_rx_type), intent(inout) :: handle_rx
789  real (kind=R8), intent(out) :: out(:)
790  real (kind=R8), intent(in) :: arg1(:),arg2(:),arg3(:)
791  type(amns_error_type), intent(out) :: error_status
792 
793  type(data_error_t) :: data_error
794 
795 ! LOGICAL :: SG
796 
797  if(present(error_status)) then
798  error_status%flag=.false.
799  error_status%string="No error"
800  end if
801 
802  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1 start'
803 
804 ! CALL IEEE_GET_UNDERFLOW_MODE (SG)
805 ! CALL IEEE_SET_UNDERFLOW_MODE (.TRUE.)
806 
807  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1: bounds(out) = ',lbound(out),ubound(out)
808  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1: bounds(arg1) = ',lbound(arg1),ubound(arg1)
809  if(present(arg3)) then
810  if(present(arg2)) then
811  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1: bounds(arg2) = ',lbound(arg2),ubound(arg2)
812  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1: bounds(arg3) = ',lbound(arg3),ubound(arg3)
813  if(handle_rx%filled) then
814  call interpol( &
815  reshape(arg1,(/size(arg1)/)), &
816  reshape(arg2,(/size(arg2)/)), &
817  reshape(arg3,(/size(arg3)/)), &
818  fd1=out, grid=handle_rx%grid, &
819  data_error=data_error)
820  if(present(error_status)) then
821  error_status%flag = data_error%ierr .ne. 0
822  error_status%string = data_error%cerr
823  else
824  if(data_error%ierr.ne.0) then
825  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
826  stop 'error in interpol'
827  endif
828  endif
829  else
830  write(*,*) 'ITM_AMNS_RX_1: Attempt to INTERPOLATE using an unfilled table'
831  endif
832  else
833  write(*,*) 'ITM_AMNS_RX_1: arg3 present but not arg2!'
834  endif
835  else
836  if(present(arg2)) then
837  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1: bounds(arg2) = ',lbound(arg2),ubound(arg2)
838  if(handle_rx%filled) then
839  call interpol( &
840  reshape(arg1,(/size(arg1)/)), &
841  reshape(arg2,(/size(arg2)/)), &
842  fd1=out, grid=handle_rx%grid, &
843  data_error=data_error)
844  if(present(error_status)) then
845  error_status%flag = data_error%ierr .ne. 0
846  error_status%string = data_error%cerr
847  else
848  if(data_error%ierr.ne.0) then
849  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
850  stop 'error in interpol'
851  endif
852  endif
853  else
854  write(*,*) 'ITM_AMNS_RX_1: Attempt to INTERPOLATE using an unfilled table'
855  endif
856  else
857  if(handle_rx%filled) then
858  call interpol( &
859  reshape(arg1,(/size(arg1)/)), &
860  fd1=out, grid=handle_rx%grid, &
861  data_error=data_error)
862  if(present(error_status)) then
863  error_status%flag = data_error%ierr .ne. 0
864  error_status%string = data_error%cerr
865  else
866  if(data_error%ierr.ne.0) then
867  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
868  stop 'error in interpol'
869  endif
870  endif
871  else
872  write(*,*) 'ITM_AMNS_RX_1: Attempt to INTERPOLATE using an unfilled table'
873  endif
874  endif
875  endif
876 ! CALL IEEE_SET_UNDERFLOW_MODE (SG)
877  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_1 end'
878 
879  end subroutine itm_amns_rx_1
880 
881  ! ================================================================================================================ !
889  subroutine itm_amns_rx_2(handle_rx,out,arg1,arg2,arg3,error_status)
890  use itm_types
891  use amns_types
892  use data_suport
893 ! use ieee_arithmetic ! IGNORE
894  implicit none
895  optional arg2,arg3,error_status
896  type(amns_handle_rx_type), intent(inout) :: handle_rx
897  real (kind=R8), intent(out) :: out(:,:)
898  real (kind=R8), intent(in) :: arg1(:,:),arg2(:,:),arg3(:,:)
899  type(amns_error_type), intent(out) :: error_status
900 
901  real (kind=R8) :: tmp_out(size(out))
902 
903  type(data_error_t) :: data_error
904 
905 ! LOGICAL :: SG
906 
907  if(present(error_status)) then
908  error_status%flag=.false.
909  error_status%string="No error"
910  end if
911 
912  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2 start'
913 
914 ! CALL IEEE_GET_UNDERFLOW_MODE (SG)
915 ! CALL IEEE_SET_UNDERFLOW_MODE (.TRUE.)
916 
917  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2: bounds(out) = ',lbound(out),ubound(out)
918  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2: bounds(arg1) = ',lbound(arg1),ubound(arg1)
919  if(present(arg3)) then
920  if(present(arg2)) then
921  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2: bounds(arg2) = ',lbound(arg2),ubound(arg2)
922  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2: bounds(arg3) = ',lbound(arg3),ubound(arg3)
923  if(handle_rx%filled) then
924  call interpol( &
925  reshape(arg1,(/size(arg1)/)), &
926  reshape(arg2,(/size(arg2)/)), &
927  reshape(arg3,(/size(arg3)/)), &
928  fd1=tmp_out, grid=handle_rx%grid, &
929  data_error=data_error)
930  if(present(error_status)) then
931  error_status%flag = data_error%ierr .ne. 0
932  error_status%string = data_error%cerr
933  else
934  if(data_error%ierr.ne.0) then
935  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
936  stop 'error in interpol'
937  endif
938  endif
939  out=reshape(tmp_out,shape(out))
940  else
941  write(*,*) 'ITM_AMNS_RX_2: Attempt to INTERPOLATE using an unfilled table'
942  endif
943  else
944  write(*,*) 'ITM_AMNS_RX_2: arg3 present but not arg2!'
945  endif
946  else
947  if(present(arg2)) then
948  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2: bounds(arg2) = ',lbound(arg2),ubound(arg2)
949  if(handle_rx%filled) then
950  call interpol( &
951  reshape(arg1,(/size(arg1)/)), &
952  reshape(arg2,(/size(arg2)/)), &
953  fd1=tmp_out, grid=handle_rx%grid, &
954  data_error=data_error)
955  if(present(error_status)) then
956  error_status%flag = data_error%ierr .ne. 0
957  error_status%string = data_error%cerr
958  else
959  if(data_error%ierr.ne.0) then
960  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
961  stop 'error in interpol'
962  endif
963  endif
964  out=reshape(tmp_out,shape(out))
965  else
966  write(*,*) 'ITM_AMNS_RX_2: Attempt to INTERPOLATE using an unfilled table'
967  endif
968  else
969  if(handle_rx%filled) then
970  call interpol( &
971  reshape(arg1,(/size(arg1)/)), &
972  fd1=tmp_out, grid=handle_rx%grid, &
973  data_error=data_error)
974  if(present(error_status)) then
975  error_status%flag = data_error%ierr .ne. 0
976  error_status%string = data_error%cerr
977  else
978  if(data_error%ierr.ne.0) then
979  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
980  stop 'error in interpol'
981  endif
982  endif
983  out=reshape(tmp_out,shape(out))
984  else
985  write(*,*) 'ITM_AMNS_RX_2: Attempt to INTERPOLATE using an unfilled table'
986  endif
987  endif
988  endif
989 ! CALL IEEE_SET_UNDERFLOW_MODE (SG)
990  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_2 end'
991 
992  end subroutine itm_amns_rx_2
993 
994  ! ================================================================================================================ !
1002  subroutine itm_amns_rx_3(handle_rx,out,arg1,arg2,arg3,error_status)
1003  use itm_types
1004  use amns_types
1005  use data_suport
1006 ! use ieee_arithmetic ! IGNORE
1007  implicit none
1008  optional arg2,arg3,error_status
1009  type(amns_handle_rx_type), intent(inout) :: handle_rx
1010  real (kind=R8), intent(out) :: out(:,:,:)
1011  real (kind=R8), intent(in) :: arg1(:,:,:),arg2(:,:,:),arg3(:,:,:)
1012  type(amns_error_type), intent(out) :: error_status
1013 
1014  real (kind=R8) :: tmp_out(size(out))
1015 
1016  type(data_error_t) :: data_error
1017 
1018 ! LOGICAL :: SG
1019 
1020  if(present(error_status)) then
1021  error_status%flag=.false.
1022  error_status%string="No error"
1023  end if
1024 
1025  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3 start'
1026 
1027 ! CALL IEEE_GET_UNDERFLOW_MODE (SG)
1028 ! CALL IEEE_SET_UNDERFLOW_MODE (.TRUE.)
1029 
1030  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3: bounds(out) = ',lbound(out),ubound(out)
1031  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3: bounds(arg1) = ',lbound(arg1),ubound(arg1)
1032  if(present(arg3)) then
1033  if(present(arg2)) then
1034  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3: bounds(arg2) = ',lbound(arg2),ubound(arg2)
1035  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3: bounds(arg3) = ',lbound(arg3),ubound(arg3)
1036  if(handle_rx%filled) then
1037  call interpol( &
1038  reshape(arg1,(/size(arg1)/)), &
1039  reshape(arg2,(/size(arg2)/)), &
1040  reshape(arg3,(/size(arg3)/)), &
1041  fd1=tmp_out, grid=handle_rx%grid, &
1042  data_error=data_error)
1043  if(present(error_status)) then
1044  error_status%flag = data_error%ierr .ne. 0
1045  error_status%string = data_error%cerr
1046  else
1047  if(data_error%ierr.ne.0) then
1048  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
1049  stop 'error in interpol'
1050  endif
1051  endif
1052  out=reshape(tmp_out,shape(out))
1053  else
1054  write(*,*) 'ITM_AMNS_RX_3: Attempt to INTERPOLATE using an unfilled table'
1055  endif
1056  else
1057  write(*,*) 'ITM_AMNS_RX_3: arg3 present but not arg2!'
1058  endif
1059  else
1060  if(present(arg2)) then
1061  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3: bounds(arg2) = ',lbound(arg2),ubound(arg2)
1062  if(handle_rx%filled) then
1063  call interpol( &
1064  reshape(arg1,(/size(arg1)/)), &
1065  reshape(arg2,(/size(arg2)/)), &
1066  fd1=tmp_out, grid=handle_rx%grid, &
1067  data_error=data_error)
1068  if(present(error_status)) then
1069  error_status%flag = data_error%ierr .ne. 0
1070  error_status%string = data_error%cerr
1071  else
1072  if(data_error%ierr.ne.0) then
1073  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
1074  stop 'error in interpol'
1075  endif
1076  endif
1077  out=reshape(tmp_out,shape(out))
1078  else
1079  write(*,*) 'ITM_AMNS_RX_3: Attempt to INTERPOLATE using an unfilled table'
1080  endif
1081  else
1082  if(handle_rx%filled) then
1083  call interpol( &
1084  reshape(arg1,(/size(arg1)/)), &
1085  fd1=tmp_out, grid=handle_rx%grid, &
1086  data_error=data_error)
1087  if(present(error_status)) then
1088  error_status%flag = data_error%ierr .ne. 0
1089  error_status%string = data_error%cerr
1090  else
1091  if(data_error%ierr.ne.0) then
1092  write(*,*) 'interpol returned an error: ', data_error%ierr, trim(data_error%cerr)
1093  stop 'error in interpol'
1094  endif
1095  endif
1096  out=reshape(tmp_out,shape(out))
1097  else
1098  write(*,*) 'ITM_AMNS_RX_3: Attempt to INTERPOLATE using an unfilled table'
1099  endif
1100  endif
1101  endif
1102 ! CALL IEEE_SET_UNDERFLOW_MODE (SG)
1103  if(handle_rx%debug) write(*,*) 'ITM_AMNS_RX_3 end'
1104 
1105  end subroutine itm_amns_rx_3
1106 end module amns_module
1107 
subroutine, public interpol(w, x, y, z, fd1, fd2, fd3, fd4, grid, data_error)
interpolate in the grid
subroutine itm_amns_rx_2(handle_rx, out, arg1, arg2, arg3, error_status)
get the rates associated with the input (2d) args for a particular reaction
subroutine itm_amns_query_table(handle_rx, query, answer, error_status)
query routine for a particular reaction
Type for specifying the AMNS version ("interoperable" version)
subroutine end_amns_data
deallocate cpos
if error_status & query
Definition: amns.pyx:11
for i
Definition: amns.pyx:365
if error_status & answer
Definition: amns.pyx:11
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
type for the AMNS handle (opaque for user codes) NOT interoperable with C.
Definition: amns_types.F90:87
Type for answers from queries in the AMNS package ("interoperable" version)
Type for error returns from the AMNS interface ("interoperable" version)
subroutine itm_amns_rx_0(handle_rx, out, arg1, arg2, arg3, error_status)
get the rates associated with the input (0d) args for a particular reaction
subroutine itm_amns_setup(handle, version, error_status)
initialization call for the AMNS package
Definition: amns_module.F90:47
subroutine itm_amns_finish(handle, error_status)
finalization call for the AMNS package
Module implementing various utility functions for the AMNS interface.
subroutine itm_amns_rx_3(handle_rx, out, arg1, arg2, arg3, error_status)
get the rates associated with the input (3d) args for a particular reaction
subroutine itm_amns_rx_1(handle_rx, out, arg1, arg2, arg3, error_status)
get the rates associated with the input (1d) args for a particular reaction
subroutine itm_amns_setup_table(handle, reaction_type, reactants, handle_rx, error_status)
initialization call for a particular reaction
Type used for specifying reactions when using the AMNS interface ("interoperable" version) ...
Type for the AMNS RX handle (opaque for user codes) NOT interoperable with C.
Definition: amns_types.F90:98
subroutine itm_amns_set(handle, set, error_status)
set a parameter for the AMNS package
subroutine, public delete(grid)
deallocate a grid
subroutine itm_amns_set_table(handle_rx, set, error_status)
set a parameter for a particular reaction
Type for querying parameters in the AMNS package ("interoperable" version)
Type for setting parameters in the AMNS package ("interoperable" version)
subroutine itm_amns_finish_table(handle_rx, error_status)
finalization call for a particular reaction
if error_status answer number def version(self) if error_status &error_status if error_status Reactants reactants
Definition: amns.pyx:59
if error_status & error_status
Definition: amns.pyx:11
Type for indicating the reactants when using the AMNS interface NOT interoperable with C...
Definition: amns_types.F90:75
get the rates associated with the input args for a particular reaction (generic interface for 1d...
Definition: amns_module.F90:27
subroutine itm_amns_query(handle, query, answer, error_status)
query routine for the AMNS package
The derived types defined here are meant to be interoperable with C. The ones for this is not the cas...
Definition: amns_types.F90:17
subroutine, public set_option(grid, warning)
set the "with_warning" flag in grid to the value of "warning"