load_profiles_data_from_hdf5 Subroutine

private subroutine load_profiles_data_from_hdf5(params, P)

Arguments

Type IntentOptional AttributesName
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.


Contents


Source Code

  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(6,'("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(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(6,'("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

    call h5fclose_f(h5file_id, h5error)
    if (h5error .EQ. -1) then
       write(6,'("KORC ERROR: Something went wrong in: load_profiles_data_from_hdf5 --> h5fclose_f")')
    end if
  end subroutine load_profiles_data_from_hdf5