Writes neut to a HDF5 file
subroutine write_neutrals
!+ Writes [[libfida:neut]] to a HDF5 file
integer(HID_T) :: fid, gid
integer :: error
integer :: i
character(charlim) :: filename
integer(HSIZE_T), dimension(4) :: dims4
dims4 = [nlevs, beam_grid%nx, beam_grid%ny, beam_grid%nz]
filename=trim(adjustl(inputs%result_dir))//"/"//trim(adjustl(inputs%runid))//"_neutrals.h5"
!Open HDF5 interface
call h5open_f(error)
!Create file overwriting any existing file
call h5fcreate_f(filename, H5F_ACC_TRUNC_F, fid, error)
!Write variables
call write_beam_grid(fid, error)
if(inputs%calc_nbi_dens.ge.1) then
call h5gcreate_f(fid, "/full", gid, error)
call write_neutral_population(gid, neut%full, error)
call h5gclose_f(gid, error)
call h5ltset_attribute_string_f(fid,"/full","description", &
"Full Energy Neutral Population", error)
call h5gcreate_f(fid, "/half", gid, error)
call write_neutral_population(gid, neut%half, error)
call h5gclose_f(gid, error)
call h5ltset_attribute_string_f(fid,"/half","description", &
"Half Energy Neutral Population", error)
call h5gcreate_f(fid, "/third", gid, error)
call write_neutral_population(gid, neut%third, error)
call h5gclose_f(gid, error)
call h5ltset_attribute_string_f(fid,"/third","description", &
"Third Energy Neutral Population", error)
endif
if(inputs%calc_dcx_dens.ge.1) then
call h5gcreate_f(fid, "/dcx", gid, error)
call write_neutral_population(gid, neut%dcx, error)
call h5gclose_f(gid, error)
call h5ltset_attribute_string_f(fid,"/dcx","description", &
"Direct Charge Exchange (DCX) Neutral Population", error)
endif
if(inputs%calc_halo_dens.ge.1) then
call h5gcreate_f(fid, "/halo", gid, error)
call write_neutral_population(gid, neut%halo, error)
call h5gclose_f(gid, error)
call h5ltset_attribute_string_f(fid,"/halo","description", &
"Thermal Halo Neutral Population", error)
endif
call h5ltset_attribute_string_f(fid, "/", "version", version, error)
call h5ltset_attribute_string_f(fid,"/","description", &
"Neutral Populations calculated by FIDASIM", error)
!Close file
call h5fclose_f(fid, error)
!Close HDF5 interface
call h5close_f(error)
if(inputs%verbose.ge.1) then
write(*,'(T4,a,a)') 'neutral populations written to: ',trim(filename)
endif
end subroutine write_neutrals