Subroutine that loads pre-computed plasma profiles' data from an input HDF5 file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(in) | :: | params | Core KORC simulation parameters. |
||
type(PROFILES), | intent(inout) | :: | P | An instance of KORC's derived type PROFILES containing all the information about the plasma profiles used in the simulation. See korc_types and korc_profiles. |
subroutine load_profiles_data_from_hdf5(params,P)
!! @note Subroutine that loads pre-computed plasma profiles' data
!! from an input HDF5 file. @endnote
TYPE(KORC_PARAMS), INTENT(IN) :: params
!! Core KORC simulation parameters.
TYPE(PROFILES), INTENT(INOUT) :: P
!! An instance of KORC's derived type PROFILES containing all the
!! information about the plasma profiles used in the
!! simulation. See [[korc_types]] and [[korc_profiles]].
CHARACTER(MAX_STRING_LENGTH) :: filename
!!String containing the name of the input HDF5 file.
CHARACTER(MAX_STRING_LENGTH) :: gname
!! String containing the group name of a parameter in the HDF5 file.
CHARACTER(MAX_STRING_LENGTH) :: subgname
!! String containing the subgroup name of a parameter in the HDF5 file.
CHARACTER(MAX_STRING_LENGTH) :: dset
!!Name of data set to read from file.
INTEGER(HID_T) :: h5file_id
!! HDF5 file identifier.
INTEGER(HID_T) :: group_id
!! HDF5 group identifier.
INTEGER(HID_T) :: subgroup_id
!!HDF5 subgroup identifier.
REAL(rp) :: rdatum
!!
INTEGER :: h5error
!! HDF5 error status.
filename = TRIM(P%filename)
call h5fopen_f(filename, H5F_ACC_RDONLY_F, h5file_id, h5error)
if (h5error .EQ. -1) then
write(output_unit_write,'("KORC ERROR: Something went wrong in: load_profiles_data_from_hdf5 --> h5fopen_f")')
end if
dset = "/NR"
call load_from_hdf5(h5file_id,dset,rdatum)
P%dims(1) = INT(rdatum)
if (P%axisymmetric) then
P%dims(2) = 0
else
dset = "/NPHI"
call load_from_hdf5(h5file_id,dset,rdatum)
P%dims(2) = INT(rdatum)
end if
dset = "/NZ"
call load_from_hdf5(h5file_id,dset,rdatum)
P%dims(3) = INT(rdatum)
if (P%axisymmetric) then
call ALLOCATE_2D_PROFILES_ARRAYS(params,P)
else
call ALLOCATE_3D_PROFILES_ARRAYS(P)
end if
dset = "/R"
call load_array_from_hdf5(h5file_id,dset,P%X%R)
if (.NOT.P%axisymmetric) then
dset = "/PHI"
call load_array_from_hdf5(h5file_id,dset,P%X%PHI)
end if
dset = "/Z"
call load_array_from_hdf5(h5file_id,dset,P%X%Z)
dset = "/FLAG"
if (P%axisymmetric) then
call load_array_from_hdf5(h5file_id,dset,P%FLAG2D)
else
call load_array_from_hdf5(h5file_id,dset,P%FLAG3D)
end if
dset = "/ne"
if (P%axisymmetric) then
call load_array_from_hdf5(h5file_id,dset,P%ne_2D)
else
call load_array_from_hdf5(h5file_id,dset,P%ne_3D)
end if
dset = "/Te"
if (P%axisymmetric) then
call load_array_from_hdf5(h5file_id,dset,P%Te_2D)
P%Te_2D = P%Te_2D*C_E
else
call load_array_from_hdf5(h5file_id,dset,P%Te_3D)
P%Te_3D = P%Te_3D*C_E
end if
!write(output_unit_write,'("Te: ",E17.10)') P%Te_2D(1,1)
dset = "/Zeff"
if (P%axisymmetric) then
call load_array_from_hdf5(h5file_id,dset,P%Zeff_2D)
else
call load_array_from_hdf5(h5file_id,dset,P%Zeff_3D)
end if
if (params%profile_model(10:10).eq.'H') then
dset = "/RHON"
call load_array_from_hdf5(h5file_id,dset,P%RHON)
dset = "/nRE"
call load_array_from_hdf5(h5file_id,dset,P%nRE_2D)
dset = "/nAr0"
call load_array_from_hdf5(h5file_id,dset,P%nAr0_2D)
dset = "/nAr1"
call load_array_from_hdf5(h5file_id,dset,P%nAr1_2D)
dset = "/nAr2"
call load_array_from_hdf5(h5file_id,dset,P%nAr2_2D)
dset = "/nAr3"
call load_array_from_hdf5(h5file_id,dset,P%nAr3_2D)
dset = "/nD"
call load_array_from_hdf5(h5file_id,dset,P%nD_2D)
dset = "/nD1"
call load_array_from_hdf5(h5file_id,dset,P%nD1_2D)
end if
call h5fclose_f(h5file_id, h5error)
if (h5error .EQ. -1) then
write(output_unit_write,'("KORC ERROR: Something went wrong in: load_profiles_data_from_hdf5 --> h5fclose_f")')
end if
end subroutine load_profiles_data_from_hdf5