Reads in a atomic rate table from file and puts it into a AtomicRates type
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=HID_T), | intent(in) | :: | fid | HDF5 file ID |
||
character(len=*), | intent(in) | :: | grp | HDF5 group to read from |
||
real(kind=Float64), | intent(in), | dimension(2) | :: | b_amu | Atomic masses of "beam" species (beam ion and thermal ion) |
|
real(kind=Float64), | intent(in) | :: | t_amu | Atomic mass of "target" species (thermal ion) |
||
type(AtomicRates), | intent(inout) | :: | rates | Atomic reaction rates |
subroutine read_atomic_rate(fid, grp, b_amu, t_amu, rates)
!+ Reads in a atomic rate table from file
!+ and puts it into a [[AtomicRates]] type
integer(HID_T), intent(in) :: fid
!+ HDF5 file ID
character(len=*), intent(in) :: grp
!+ HDF5 group to read from
real(Float64), dimension(2), intent(in) :: b_amu
!+ Atomic masses of "beam" species (beam ion and thermal ion)
real(Float64), intent(in) :: t_amu
!+ Atomic mass of "target" species (thermal ion)
type(AtomicRates), intent(inout) :: rates
!+ Atomic reaction rates
integer(HSIZE_T), dimension(2) :: dim2
integer(HSIZE_T), dimension(4) :: dim4
integer(HSIZE_T), dimension(5) :: dim5
logical :: path_valid
integer :: i, j, n, n_max, m_max, error
integer :: n_bt_amu, tt_ind, bt_ind, drank
real(Float64) :: emin,emax,tmin,tmax,rmin
real(Float64) :: bt_min, tt_min, tt_dum, bt_dum
real(Float64), dimension(2) :: bt_amu, tt_amu
real(Float64), dimension(:,:), allocatable :: dummy2
real(Float64), dimension(:,:,:,:), allocatable :: dummy4
real(Float64), dimension(:,:,:,:,:), allocatable :: dummy5
call h5ltpath_valid_f(fid, grp, .True., path_valid, error)
if(.not.path_valid) then
if(inputs%verbose.ge.0) then
write(*,'(a,a)') 'READ_ATOMIC_RATE: Unknown atomic interaction: ', trim(grp)
endif
stop
endif
call h5ltread_dataset_int_scalar_f(fid, grp//"/n_bt_amu", n_bt_amu, error)
allocate(dummy2(2, n_bt_amu))
dim2 = [2, n_bt_amu]
call h5ltread_dataset_double_f(fid, grp//"/bt_amu", dummy2, dim2, error)
call h5ltread_dataset_int_scalar_f(fid, grp//"/n_max", n_max, error)
call h5ltread_dataset_int_scalar_f(fid, grp//"/m_max", m_max, error)
call h5ltread_dataset_int_scalar_f(fid, grp//"/nenergy", rates%nenergy, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/emin", emin, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/emax", emax, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/dlogE", rates%dlogE, error)
call h5ltread_dataset_int_scalar_f(fid, grp//"/ntemp", rates%ntemp, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/tmin", tmin, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/tmax", tmax, error)
call h5ltread_dataset_double_scalar_f(fid, grp//"/dlogT", rates%dlogT, error)
rates%logemin = log10(emin)
rates%logemax = log10(emax)
rates%logtmin = log10(tmin)
rates%logtmax = log10(tmax)
bt_ind = 1
tt_ind = 1
bt_amu = [b_amu(1), t_amu]
tt_amu = [b_amu(2), t_amu]
bt_min = norm2(bt_amu - dummy2(:,1))
tt_min = norm2(tt_amu - dummy2(:,1))
do i=2, n_bt_amu
bt_dum = norm2(bt_amu - dummy2(:,i))
tt_dum = norm2(tt_amu - dummy2(:,i))
if(bt_dum.lt.bt_min) then
bt_min = bt_dum
bt_ind = i
endif
if(tt_dum.lt.tt_min) then
tt_min = tt_dum
tt_ind = i
endif
enddo
rates%ab(1) = dummy2(1,bt_ind)
rates%ab(2) = dummy2(1,tt_ind)
deallocate(dummy2)
allocate(rates%log_rate(&
rates%m_max, &
rates%n_max, &
rates%nenergy, &
rates%ntemp, 2))
rates%log_rate = 0.d0
!!Read CX
call h5ltpath_valid_f(fid, grp//"/cx", .True., path_valid, error)
if(path_valid) then
call h5ltget_dataset_ndims_f(fid, grp//"/cx", drank, error)
if(drank.eq.5) then
allocate(dummy5(n_max, m_max, &
rates%nenergy, &
rates%ntemp, n_bt_amu))
dim5 = [n_max, m_max, rates%nenergy, rates%ntemp,n_bt_amu]
call h5ltread_dataset_double_f(fid, grp//"/cx", dummy5, dim5, error)
do j=1,rates%ntemp
do i=1,rates%nenergy
rates%log_rate(:,:,i,j,1) = transpose(dummy5(1:nlevs,1:nlevs,i,j,bt_ind))
rates%log_rate(:,:,i,j,2) = transpose(dummy5(1:nlevs,1:nlevs,i,j,tt_ind))
enddo
enddo
deallocate(dummy5)
else
if(inputs%verbose.ge.0) then
write(*,'(a,a)') 'READ_ATOMIC_RATE: Unsupported atomic interaction: ', trim(grp)
endif
stop
endif
endif
rmin = minval(rates%log_rate, rates%log_rate.gt.0.d0)
where (rates%log_rate.le.0.d0)
rates%log_rate = 0.9*rmin
end where
rates%minlog_rate = log10(rmin)
rates%log_rate = log10(rates%log_rate)
end subroutine read_atomic_rate