SUBROUTINE save_avalanche_params(params)
TYPE(KORC_PARAMS), INTENT(IN) :: params
CHARACTER(MAX_STRING_LENGTH) :: filename
CHARACTER(MAX_STRING_LENGTH) :: gname
CHARACTER(MAX_STRING_LENGTH), DIMENSION(:), ALLOCATABLE :: attr_array
CHARACTER(MAX_STRING_LENGTH) :: dset
CHARACTER(MAX_STRING_LENGTH) :: attr
INTEGER(HID_T) :: h5file_id
INTEGER(HID_T) :: group_id
INTEGER :: h5error
REAL(rp) :: units
if (params%mpi_params%rank .EQ. 0) then
filename = TRIM(params%path_to_outputs) // "avalanche_parameters.h5"
call h5fcreate_f(TRIM(filename), H5F_ACC_TRUNC_F, h5file_id, h5error)
gname = "pdf_params"
call h5gcreate_f(h5file_id, TRIM(gname), group_id, h5error)
dset = TRIM(gname) // "/max_pitch_angle"
attr = "Maximum pitch angle in avalanche PDF (degrees)"
call save_to_hdf5(h5file_id,dset,aval_params%max_pitch_angle,attr)
dset = TRIM(gname) // "/min_pitch_angle"
attr = "Minimum pitch angle in avalanche PDF (degrees)"
call save_to_hdf5(h5file_id,dset,aval_params%min_pitch_angle,attr)
dset = TRIM(gname) // "/min_energy"
attr = "Minimum energy in avalanche PDF (eV)"
units = 1.0_rp/C_E
call save_to_hdf5(h5file_id,dset,units*aval_params%min_energy,attr)
dset = TRIM(gname) // "/max_energy"
attr = "Maximum energy in avalanche PDF (eV)"
units = 1.0_rp/C_E
call save_to_hdf5(h5file_id,dset,units*aval_params%max_energy,attr)
dset = TRIM(gname) // "/max_p"
attr = "Maximum momentum in avalanche PDF (me*c^2)"
call save_to_hdf5(h5file_id,dset,aval_params%max_p,attr)
dset = TRIM(gname) // "/min_p"
attr = "Maximum momentum in avalanche PDF (me*c^2)"
call save_to_hdf5(h5file_id,dset,aval_params%min_p,attr)
dset = TRIM(gname) // "/ne"
attr = "Background electron density (m^-3)"
call save_to_hdf5(h5file_id,dset,aval_params%ne,attr)
dset = TRIM(gname) // "/Zeff"
attr = "Effective atomic number of ions."
call save_to_hdf5(h5file_id,dset,aval_params%Zeff,attr)
dset = TRIM(gname) // "/Ec"
attr = "Critical electric field in (V/m)"
call save_to_hdf5(h5file_id,dset,aval_params%Ec,attr)
dset = TRIM(gname) // "/Epar"
attr = "Parallel electric field in (V/m)"
call save_to_hdf5(h5file_id,dset,aval_params%Epar,attr)
dset = TRIM(gname) // "/Te"
attr = "Background electron temperature (eV)"
units = 1.0_rp/C_E
call save_to_hdf5(h5file_id,dset,units*aval_params%Te,attr)
dset = TRIM(gname) // "/lambda_D"
attr = "Debye length (m)"
call save_to_hdf5(h5file_id,dset,aval_params%lD,attr)
dset = TRIM(gname) // "/bmin"
attr = "Maximum approach radius (m)"
call save_to_hdf5(h5file_id,dset,aval_params%bmin,attr)
dset = TRIM(gname) // "/Clog"
attr = "Coulomb logarithm"
call save_to_hdf5(h5file_id,dset,aval_params%CoulombLog,attr)
dset = TRIM(gname) // "/Tau"
attr = "Collision time (s)"
call save_to_hdf5(h5file_id,dset,aval_params%Tau,attr)
call h5gclose_f(group_id, h5error)
call h5fclose_f(h5file_id, h5error)
end if
END SUBROUTINE save_avalanche_params