Reads neutral density from file and puts it in neut
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