ALLOCATE_2D_FIELDS_ARRAYS Subroutine

public subroutine ALLOCATE_2D_FIELDS_ARRAYS(params, F, bfield, bflux, dbfield, efield)

Arguments

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

Core KORC simulation parameters.

type(FIELDS), intent(inout) :: F

An instance of the KORC derived type FIELDS. In this variable we keep the loaded data.

logical, intent(in) :: bfield
logical, intent(in) :: bflux

Logical variable that specifies if the variables that keep the poloidal magnetic flux data is allocated (bflux=T) or not (bflux=F).

logical, intent(in) :: dbfield

Logical variable that specifies if the variables that keep the magnetic field data is allocated (bfield=T) or not (bfield=F).

logical, intent(in) :: efield

Logical variable that specifies if the variables that keep the electric field data is allocated (efield=T) or not (efield=F).


Contents


Source Code

  subroutine ALLOCATE_2D_FIELDS_ARRAYS(params,F,bfield,bflux,dbfield,efield)
    !! @note Subroutine that allocates the variables keeping the axisymmetric
    !! fields data. @endnote
    TYPE (KORC_PARAMS), INTENT(IN) 	:: params
    !! Core KORC simulation parameters.
    TYPE(FIELDS), INTENT(INOUT)    :: F
    !! An instance of the KORC derived type FIELDS. In this variable we keep
    !! the loaded data.
    LOGICAL, INTENT(IN)            :: bfield
    LOGICAL, INTENT(IN)            :: dbfield
    !! Logical variable that specifies if the variables that keep the magnetic
    !! field data is allocated (bfield=T) or not (bfield=F).
    LOGICAL, INTENT(IN)            :: bflux
    !! Logical variable that specifies if the variables that keep the poloidal
    !! magnetic flux data is allocated (bflux=T) or not (bflux=F).
    LOGICAL, INTENT(IN)            :: efield
    !! Logical variable that specifies if the variables that keep the electric
    !! field data is allocated (efield=T) or not (efield=F).

    if (bfield.and.(.not.ALLOCATED(F%B_2D%R))) then
       call ALLOCATE_V_FIELD_2D(F%B_2D,F%dims)

       if(params%orbit_model(3:5).EQ.'pre') then
          call ALLOCATE_V_FIELD_2D(F%curlb_2D,F%dims)
          call ALLOCATE_V_FIELD_2D(F%gradB_2D,F%dims)
       end if

    end if

    if (bflux.and.(.not.ALLOCATED(F%PSIp))) then
       ALLOCATE(F%PSIp(F%dims(1),F%dims(3)))
    end if

    if (dbfield.and.(.not.ALLOCATED(F%dBdR_2D%R))) then
       call ALLOCATE_V_FIELD_2D(F%dBdR_2D,F%dims)
       call ALLOCATE_V_FIELD_2D(F%dBdPHI_2D,F%dims)
       call ALLOCATE_V_FIELD_2D(F%dBdZ_2D,F%dims)
    end if
    
    if (efield.and.(.not.ALLOCATED(F%E_2D%R))) then
       call ALLOCATE_V_FIELD_2D(F%E_2D,F%dims)

    end if

    if (.NOT.ALLOCATED(F%FLAG2D)) ALLOCATE(F%FLAG2D(F%dims(1),F%dims(3)))

    if (.NOT.ALLOCATED(F%X%R)) ALLOCATE(F%X%R(F%dims(1)))
    if (.NOT.ALLOCATED(F%X%Z)) ALLOCATE(F%X%Z(F%dims(3)))
  end subroutine ALLOCATE_2D_FIELDS_ARRAYS