@brief Subroutine that loads the fields data from the HDF5 input file.
@param[in] params Core KORC simulation parameters. @param[in,out] F An instance of the KORC derived type FIELDS. In this variable we keep the loaded data. @param filename String containing the name of the HDF5 file. @param gname String containing the group name of a parameter in the HDF5 file. @param subgname String containing the subgroup name of a parameter in the HDF5 file. @param dset Name of data set to read from file. @param h5file_id HDF5 file identifier. @param group_id HDF5 group identifier. @param subgroup_id HDF5 subgroup identifier. @param h5error HDF5 error status.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(KORC_PARAMS), | intent(in) | :: | params | |||
type(FIELDS), | intent(inout) | :: | F |
subroutine load_field_data_from_hdf5(params,F)
TYPE(KORC_PARAMS), INTENT(IN) :: params
TYPE(FIELDS), INTENT(INOUT) :: F
CHARACTER(MAX_STRING_LENGTH) :: filename
CHARACTER(MAX_STRING_LENGTH) :: gname
CHARACTER(MAX_STRING_LENGTH) :: subgname
CHARACTER(MAX_STRING_LENGTH) :: dset
INTEGER(HID_T) :: h5file_id
INTEGER(HID_T) :: group_id
INTEGER(HID_T) :: subgroup_id
INTEGER :: h5error
LOGICAL :: Efield
filename = TRIM(params%magnetic_field_filename)
call h5fopen_f(filename, H5F_ACC_RDONLY_F, h5file_id, h5error)
if (h5error .EQ. -1) then
write(6,'("KORC ERROR: Something went wrong in: load_field_data_from_hdf5 --> h5fopen_f")')
end if
if (((.NOT.F%Bflux).AND.(.NOT.F%axisymmetric_fields)).OR. &
F%Dim2x1t) then
dset = "/PHI"
call load_array_from_hdf5(h5file_id,dset,F%X%PHI)
end if
if (params%SC_E) then
dset = "/OSR"
call load_array_from_hdf5(h5file_id,dset,F%X%R)
dset = "/OSZ"
call load_array_from_hdf5(h5file_id,dset,F%X%Z)
else
dset = "/R"
call load_array_from_hdf5(h5file_id,dset,F%X%R)
dset = "/Z"
call load_array_from_hdf5(h5file_id,dset,F%X%Z)
end if
dset = '/Bo'
call load_from_hdf5(h5file_id,dset,F%Bo)
if (F%Efield) then
dset = '/Eo'
gname = 'Eo'
call h5lexists_f(h5file_id,TRIM(gname),Efield,h5error)
if (Efield) then
call load_from_hdf5(h5file_id,dset,F%Eo)
else
F%Eo = 0.0_rp
end if
else
F%Eo = 0.0_rp
end if
dset = '/Ro'
call load_from_hdf5(h5file_id,dset,F%Ro)
dset = '/Zo'
call load_from_hdf5(h5file_id,dset,F%Zo)
if ((F%Bflux.OR.F%axisymmetric_fields).AND.(.NOT.F%Dim2x1t)) then
if (params%SC_E) then
dset = "/OSFLAG"
call load_array_from_hdf5(h5file_id,dset,F%FLAG2D)
else
dset = "/FLAG"
call load_array_from_hdf5(h5file_id,dset,F%FLAG2D)
end if
else
dset = "/FLAG"
call load_array_from_hdf5(h5file_id,dset,F%FLAG3D)
end if
if (F%Bflux) then
if (params%SC_E) then
dset = "/OSPSIP"
gname = 'OSPSIP'
call h5lexists_f(h5file_id,TRIM(gname),Efield,h5error)
if (Efield) then
call load_array_from_hdf5(h5file_id,dset,F%PSIp)
else
F%PSIp = 0.0_rp
end if
else
dset = "/PSIp"
gname = 'PSIp'
call h5lexists_f(h5file_id,TRIM(gname),Efield,h5error)
if (Efield) then
call load_array_from_hdf5(h5file_id,dset,F%PSIp)
else
F%PSIp = 0.0_rp
end if
! F%PSIp=2*C_PI*(F%PSIp-minval(F%PSIp))
end if
end if
if (F%Bflux3D) then
dset = "/PSIp"
gname = 'PSIp'
call h5lexists_f(h5file_id,TRIM(gname),Efield,h5error)
if (Efield) then
call load_array_from_hdf5(h5file_id,dset,F%PSIp3D)
else
F%PSIp3D = 0.0_rp
end if
! F%PSIp3D=2*C_PI*(F%PSIp3D-minval(F%PSIp3D))
end if
if (F%Bfield) then
if (F%axisymmetric_fields) then
dset = "/BR"
call load_array_from_hdf5(h5file_id,dset,F%B_2D%R)
dset = "/BPHI"
call load_array_from_hdf5(h5file_id,dset,F%B_2D%PHI)
dset = "/BZ"
call load_array_from_hdf5(h5file_id,dset,F%B_2D%Z)
else
dset = "/BR"
call load_array_from_hdf5(h5file_id,dset,F%B_3D%R)
dset = "/BPHI"
call load_array_from_hdf5(h5file_id,dset,F%B_3D%PHI)
dset = "/BZ"
call load_array_from_hdf5(h5file_id,dset,F%B_3D%Z)
end if
end if
if (F%dBfield.and.F%dBfield_in_file) then
if (F%axisymmetric_fields) then
dset = "/dBRdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_2D%R)
dset = "/dBPHIdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_2D%PHI)
dset = "/dBZdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_2D%Z)
dset = "/dBRdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_2D%R)
dset = "/dBPHIdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_2D%PHI)
dset = "/dBZdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_2D%Z)
dset = "/dBRdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_2D%R)
dset = "/dBPHIdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_2D%PHI)
dset = "/dBZdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_2D%Z)
else
dset = "/dBRdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_3D%R)
dset = "/dBPHIdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_3D%PHI)
dset = "/dBZdR"
call load_array_from_hdf5(h5file_id,dset,F%dBdR_3D%Z)
dset = "/dBRdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_3D%R)
dset = "/dBPHIdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_3D%PHI)
dset = "/dBZdPHI"
call load_array_from_hdf5(h5file_id,dset,F%dBdPHI_3D%Z)
dset = "/dBRdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_3D%R)
dset = "/dBPHIdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_3D%PHI)
dset = "/dBZdZ"
call load_array_from_hdf5(h5file_id,dset,F%dBdZ_3D%Z)
end if
end if
if (F%Efield.AND.F%Efield_in_file) then
if (F%axisymmetric_fields.and.(.not.F%ReInterp_2x1t)) then
dset = "/ER"
call load_array_from_hdf5(h5file_id,dset,F%E_2D%R)
dset = "/EPHI"
call load_array_from_hdf5(h5file_id,dset,F%E_2D%PHI)
dset = "/EZ"
call load_array_from_hdf5(h5file_id,dset,F%E_2D%Z)
else
dset = "/ER"
call load_array_from_hdf5(h5file_id,dset,F%E_3D%R)
dset = "/EPHI"
call load_array_from_hdf5(h5file_id,dset,F%E_3D%PHI)
dset = "/EZ"
call load_array_from_hdf5(h5file_id,dset,F%E_3D%Z)
end if
end if
call h5fclose_f(h5file_id, h5error)
if (h5error .EQ. -1) then
write(6,'("KORC ERROR: Something went wrong in: load_field_data_from_hdf5 --> h5fclose_f")')
end if
end subroutine load_field_data_from_hdf5