load_field_data_from_hdf5 Subroutine

public subroutine load_field_data_from_hdf5(params, F)

@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.

Arguments

Type IntentOptional AttributesName
type(KORC_PARAMS), intent(in) :: params
type(FIELDS), intent(inout) :: F

Calls

proc~~load_field_data_from_hdf5~~CallsGraph proc~load_field_data_from_hdf5 load_field_data_from_hdf5 interface~load_array_from_hdf5 load_array_from_hdf5 proc~load_field_data_from_hdf5->interface~load_array_from_hdf5 h5fclose_f h5fclose_f proc~load_field_data_from_hdf5->h5fclose_f h5fopen_f h5fopen_f proc~load_field_data_from_hdf5->h5fopen_f interface~load_from_hdf5 load_from_hdf5 proc~load_field_data_from_hdf5->interface~load_from_hdf5 proc~rload_1d_array_from_hdf5 rload_1d_array_from_hdf5 interface~load_array_from_hdf5->proc~rload_1d_array_from_hdf5 proc~rload_2d_array_from_hdf5 rload_2d_array_from_hdf5 interface~load_array_from_hdf5->proc~rload_2d_array_from_hdf5 proc~rload_3d_array_from_hdf5 rload_3d_array_from_hdf5 interface~load_array_from_hdf5->proc~rload_3d_array_from_hdf5 proc~iload_from_hdf5 iload_from_hdf5 interface~load_from_hdf5->proc~iload_from_hdf5 proc~rload_from_hdf5 rload_from_hdf5 interface~load_from_hdf5->proc~rload_from_hdf5 proc~korc_abort korc_abort proc~iload_from_hdf5->proc~korc_abort h5dclose_f h5dclose_f proc~iload_from_hdf5->h5dclose_f h5dread_f h5dread_f proc~iload_from_hdf5->h5dread_f proc~rload_from_hdf5->proc~korc_abort proc~rload_from_hdf5->h5dclose_f proc~rload_from_hdf5->h5dread_f proc~rload_1d_array_from_hdf5->proc~korc_abort proc~rload_1d_array_from_hdf5->h5dclose_f proc~rload_1d_array_from_hdf5->h5dread_f proc~rload_2d_array_from_hdf5->proc~korc_abort proc~rload_2d_array_from_hdf5->h5dclose_f proc~rload_2d_array_from_hdf5->h5dread_f proc~rload_3d_array_from_hdf5->proc~korc_abort proc~rload_3d_array_from_hdf5->h5dclose_f proc~rload_3d_array_from_hdf5->h5dread_f mpi_abort mpi_abort proc~korc_abort->mpi_abort

Called by

proc~~load_field_data_from_hdf5~~CalledByGraph proc~load_field_data_from_hdf5 load_field_data_from_hdf5 proc~initialize_fields initialize_fields proc~initialize_fields->proc~load_field_data_from_hdf5 program~main main program~main->proc~initialize_fields

Contents


Source Code

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

    if (params%field_model(10:13).eq.'MARS') then

       dset = '/PSIP0'
       call load_from_hdf5(h5file_id,dset,F%PSIP_min)

       dset = '/PSIPlim'
       call load_from_hdf5(h5file_id,dset,F%PSIp_lim)

       dset = '/AMP'
       call load_from_hdf5(h5file_id,dset,F%AMP)

       F%AMP=F%AMP*F%MARS_AMP_Scale
       
    end if

    if (params%field_model(10:14).eq.'AORSA') then

       dset = '/PSIP0'
       call load_from_hdf5(h5file_id,dset,F%PSIP_min)

       dset = '/PSIPlim'
       call load_from_hdf5(h5file_id,dset,F%PSIp_lim)

       F%AMP=F%AORSA_AMP_Scale
       
    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)

          if (F%useLCFS) then
             dset = "/LCFS"
             call load_array_from_hdf5(h5file_id,dset,F%LCFS2D)
          else
             F%LCFS2D = 0._rp
          end if
             
       end if

       
    else
       dset = "/FLAG"
       call load_array_from_hdf5(h5file_id,dset,F%FLAG3D)

       if (F%useLCFS) then
          dset = "/LCFS"       
          call load_array_from_hdf5(h5file_id,dset,F%LCFS3D)
       else
          F%LCFS3D = 0._rp
       end if
    end if
    
    if (F%Bflux) then

       !write(6,*) 'SC_E: ',params%SC_E
       !write(6,*) size(F%PSIp) 
       !flush(6)
       
       if (.not.params%SC_E) 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%PSIp)
          else
             F%PSIp = 0.0_rp
          end if

          !          F%PSIp=2*C_PI*(F%PSIp-minval(F%PSIp))

       else

       !write(6,*) 'SC_E: ',params%SC_E
       !flush(6)
          
          dset = "/OSPSIp"
          gname = 'OSPSIp'
       
          call h5lexists_f(h5file_id,TRIM(gname),Efield,h5error)

          write(6,*) params%SC_E
          flush(6)
          
          if (Efield) then
             call load_array_from_hdf5(h5file_id,dset,F%PSIp)
          else
             F%PSIp = 0.0_rp
          end if

       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%B1field) then      

       if (params%field_model(10:13).eq.'MARS') then
       
          dset = "/ReBR"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2D%R)

          dset = "/ReBPHI"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2D%PHI)

          dset = "/ReBZ"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2D%Z)

          dset = "/ImBR"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2D%R)

          dset = "/ImBPHI"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2D%PHI)

          dset = "/ImBZ"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2D%Z)

       else if (params%field_model(10:14).eq.'AORSA') then

          dset = "/ReBX"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2DX%X)

          dset = "/ReBY"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2DX%Y)

          dset = "/ReBZ"
          call load_array_from_hdf5(h5file_id,dset,F%B1Re_2DX%Z)

          dset = "/ImBX"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2DX%X)

          dset = "/ImBY"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2DX%Y)

          dset = "/ImBZ"
          call load_array_from_hdf5(h5file_id,dset,F%B1Im_2DX%Z)

       endif

    end if

    if (F%E1field) then      
       
       dset = "/ReEX"
       call load_array_from_hdf5(h5file_id,dset,F%E1Re_2DX%X)

       dset = "/ReEY"
       call load_array_from_hdf5(h5file_id,dset,F%E1Re_2DX%Y)

       dset = "/ReEZ"
       call load_array_from_hdf5(h5file_id,dset,F%E1Re_2DX%Z)

       dset = "/ImEX"
       call load_array_from_hdf5(h5file_id,dset,F%E1Im_2DX%X)

       dset = "/ImEY"
       call load_array_from_hdf5(h5file_id,dset,F%E1Im_2DX%Y)

       dset = "/ImEZ"
       call load_array_from_hdf5(h5file_id,dset,F%E1Im_2DX%Z)

    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)

          !write(6,*) 'BR(25,1,:)',F%B_3D%R(25,1,:)

          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(output_unit_write,'("KORC ERROR: Something went wrong in: load_field_data_from_hdf5 --> h5fclose_f")')
    end if
  end subroutine load_field_data_from_hdf5