read_neutrals Subroutine

public subroutine read_neutrals()

Reads neutral density from file and puts it in neut

Arguments

None

Calls

proc~~read_neutrals~~CallsGraph proc~read_neutrals read_neutrals h5close_f h5close_f proc~read_neutrals->h5close_f h5gopen_f h5gopen_f proc~read_neutrals->h5gopen_f proc~h5ltread_dataset_int_scalar_f h5ltread_dataset_int_scalar_f proc~read_neutrals->proc~h5ltread_dataset_int_scalar_f h5gclose_f h5gclose_f proc~read_neutrals->h5gclose_f h5open_f h5open_f proc~read_neutrals->h5open_f h5ltread_dataset_double_f h5ltread_dataset_double_f proc~read_neutrals->h5ltread_dataset_double_f h5fclose_f h5fclose_f proc~read_neutrals->h5fclose_f h5fopen_f h5fopen_f proc~read_neutrals->h5fopen_f h5ltread_dataset_int_f h5ltread_dataset_int_f proc~h5ltread_dataset_int_scalar_f->h5ltread_dataset_int_f

Called by

proc~~read_neutrals~~CalledByGraph proc~read_neutrals read_neutrals program~fidasim fidasim program~fidasim->proc~read_neutrals

Contents

Source Code


Source Code

subroutine read_neutrals
    !+ Reads neutral density from file and puts it in [[libfida:neut]]
    integer(HID_T) :: fid, gid
    integer(HSIZE_T), dimension(4) :: dims
    integer :: error,nx,ny,nz
    logical :: exis

    if(inputs%verbose.ge.1) then
        write(*,'(a)') '---- loading neutrals ----'
    endif

    inquire(file=inputs%neutrals_file,exist=exis)
    if(exis) then
        if(inputs%verbose.ge.1) then
            write(*,'(T2,"Neutrals file: ",a)') trim(inputs%neutrals_file)
            write(*,*) ''
        endif
    else
        if(inputs%verbose.ge.0) then
            write(*,'(a,a)') 'READ_NEUTRALS: Neutrals file does not exist: ',inputs%neutrals_file
        endif
        stop
    endif

    !Open HDF5 interface
    call h5open_f(error)

    !Create file overwriting any existing file
    call h5fopen_f(inputs%neutrals_file, H5F_ACC_RDONLY_F, fid, error)

    call h5gopen_f(fid, "/grid", gid, error)
    call h5ltread_dataset_int_scalar_f(gid,"nx", nx, error)
    call h5ltread_dataset_int_scalar_f(gid,"ny", ny, error)
    call h5ltread_dataset_int_scalar_f(gid,"nz", nz, error)
    call h5gclose_f(gid, error)

    if((nx.ne.beam_grid%nx).or. &
       (ny.ne.beam_grid%ny).or. &
       (nz.ne.beam_grid%nz)) then
        if(inputs%verbose.ge.0) then
            write(*,'(a)') 'READ_NEUTRALS: Neutrals file has incompatable grid dimensions'
        endif
        stop
    endif

    dims = [nlevs, nx, ny, nz]
    call h5ltread_dataset_double_f(fid,"/fdens", &
         neut%dens(:,nbif_type,:,:,:), dims, error)
    call h5ltread_dataset_double_f(fid,"/hdens", &
         neut%dens(:,nbih_type,:,:,:), dims, error)
    call h5ltread_dataset_double_f(fid,"/tdens", &
         neut%dens(:,nbit_type,:,:,:), dims, error)
    call h5ltread_dataset_double_f(fid,"/halodens", &
         neut%dens(:,halo_type,:,:,:), dims, error)

    !Close file
    call h5fclose_f(fid, error)

    !Close HDF5 interface
    call h5close_f(error)

end subroutine read_neutrals