read_atomic_rate Subroutine

public subroutine read_atomic_rate(fid, grp, rates)

Reads in a atomic rate table from file and puts it into a AtomicRates type

Arguments

TypeIntentOptionalAttributesName
integer(kind=HID_T), intent(in) :: fid

HDF5 file ID

character(len=*), intent(in) :: grp

HDF5 group to read from

type(AtomicRates), intent(inout) :: rates

Atomic reaction rates


Calls

proc~~read_atomic_rate~~CallsGraph proc~read_atomic_rate read_atomic_rate h5ltpath_valid_f h5ltpath_valid_f proc~read_atomic_rate->h5ltpath_valid_f proc~h5ltread_dataset_double_scalar_f h5ltread_dataset_double_scalar_f proc~read_atomic_rate->proc~h5ltread_dataset_double_scalar_f proc~h5ltread_dataset_int_scalar_f h5ltread_dataset_int_scalar_f proc~read_atomic_rate->proc~h5ltread_dataset_int_scalar_f h5ltget_dataset_ndims_f h5ltget_dataset_ndims_f proc~read_atomic_rate->h5ltget_dataset_ndims_f h5ltread_dataset_double_f h5ltread_dataset_double_f proc~read_atomic_rate->h5ltread_dataset_double_f proc~h5ltread_dataset_double_scalar_f->h5ltread_dataset_double_f h5ltread_dataset_int_f h5ltread_dataset_int_f proc~h5ltread_dataset_int_scalar_f->h5ltread_dataset_int_f

Called by

proc~~read_atomic_rate~~CalledByGraph proc~read_atomic_rate read_atomic_rate proc~read_tables read_tables proc~read_tables->proc~read_atomic_rate program~fidasim fidasim program~fidasim->proc~read_tables

Contents

Source Code


Source Code

subroutine read_atomic_rate(fid, grp, 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
    type(AtomicRates), intent(inout)        :: rates
        !+ Atomic reaction rates

    integer(HSIZE_T), dimension(2) :: dim2
    integer(HSIZE_T), dimension(3) :: dim3
    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 :: drank
    real(Float64) :: emin,emax,tmin,tmax,rmin
    real(Float64), dimension(:,:), allocatable :: dummy2
    real(Float64), dimension(:,:,:), allocatable :: dummy3
    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_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)


    allocate(rates%log_rate(&
                    rates%m_max, &
                    rates%n_max, &
                    rates%nenergy, &
                    rates%ntemp))
    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.4) then
            allocate(dummy4(n_max, m_max, &
                           rates%nenergy, &
                           rates%ntemp))
            dim4 = [n_max, m_max, rates%nenergy, rates%ntemp]
            call h5ltread_dataset_double_f(fid, grp//"/cx", dummy4, dim4, error)

            do j=1,rates%ntemp
                do i=1,rates%nenergy
                        rates%log_rate(:,:,i,j) = transpose(dummy4(1:nlevs,1:nlevs,i,j))
                        rates%log_rate(:,:,i,j) = transpose(dummy4(1:nlevs,1:nlevs,i,j))
                enddo
            enddo
            deallocate(dummy4)
        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