korc_finalize.f90 Source File


This file depends on

sourcefile~~korc_finalize.f90~~EfferentGraph sourcefile~korc_finalize.f90 korc_finalize.f90 sourcefile~korc_profiles.f90 korc_profiles.f90 sourcefile~korc_finalize.f90->sourcefile~korc_profiles.f90 sourcefile~korc_fields.f90 korc_fields.f90 sourcefile~korc_finalize.f90->sourcefile~korc_fields.f90 sourcefile~korc_hpc.f90 korc_hpc.f90 sourcefile~korc_finalize.f90->sourcefile~korc_hpc.f90 sourcefile~korc_types.f90 korc_types.f90 sourcefile~korc_finalize.f90->sourcefile~korc_types.f90 sourcefile~korc_profiles.f90->sourcefile~korc_hpc.f90 sourcefile~korc_profiles.f90->sourcefile~korc_types.f90 sourcefile~korc_hdf5.f90 korc_HDF5.f90 sourcefile~korc_profiles.f90->sourcefile~korc_hdf5.f90 sourcefile~korc_coords.f90 korc_coords.f90 sourcefile~korc_profiles.f90->sourcefile~korc_coords.f90 sourcefile~korc_interp.f90 korc_interp.f90 sourcefile~korc_profiles.f90->sourcefile~korc_interp.f90 sourcefile~korc_input.f90 korc_input.f90 sourcefile~korc_profiles.f90->sourcefile~korc_input.f90 sourcefile~korc_fields.f90->sourcefile~korc_hpc.f90 sourcefile~korc_fields.f90->sourcefile~korc_types.f90 sourcefile~korc_fields.f90->sourcefile~korc_hdf5.f90 sourcefile~korc_fields.f90->sourcefile~korc_coords.f90 sourcefile~korc_fields.f90->sourcefile~korc_interp.f90 sourcefile~korc_fields.f90->sourcefile~korc_input.f90 sourcefile~korc_hpc.f90->sourcefile~korc_types.f90 sourcefile~korc_hdf5.f90->sourcefile~korc_hpc.f90 sourcefile~korc_hdf5.f90->sourcefile~korc_types.f90 sourcefile~korc_constants.f90 korc_constants.f90 sourcefile~korc_hdf5.f90->sourcefile~korc_constants.f90 sourcefile~korc_coords.f90->sourcefile~korc_types.f90 sourcefile~korc_coords.f90->sourcefile~korc_constants.f90 sourcefile~korc_interp.f90->sourcefile~korc_hpc.f90 sourcefile~korc_interp.f90->sourcefile~korc_types.f90 sourcefile~korc_interp.f90->sourcefile~korc_coords.f90 sourcefile~korc_rnd_numbers.f90 korc_rnd_numbers.f90 sourcefile~korc_interp.f90->sourcefile~korc_rnd_numbers.f90 sourcefile~korc_fio_interface.f90 korc_fio_interface.f90 sourcefile~korc_interp.f90->sourcefile~korc_fio_interface.f90 sourcefile~korc_input.f90->sourcefile~korc_hpc.f90 sourcefile~korc_input.f90->sourcefile~korc_types.f90 sourcefile~korc_rnd_numbers.f90->sourcefile~korc_types.f90 sourcefile~korc_random.f90 korc_random.f90 sourcefile~korc_rnd_numbers.f90->sourcefile~korc_random.f90 sourcefile~korc_constants.f90->sourcefile~korc_types.f90 sourcefile~korc_fio_interface.f90->sourcefile~korc_types.f90 sourcefile~korc_fio_interface.f90->sourcefile~korc_hdf5.f90 sourcefile~korc_fio_interface.f90->sourcefile~korc_input.f90 sourcefile~korc_random.f90->sourcefile~korc_types.f90

Files dependent on this one

sourcefile~~korc_finalize.f90~~AfferentGraph sourcefile~korc_finalize.f90 korc_finalize.f90 sourcefile~main.f90 main.f90 sourcefile~main.f90->sourcefile~korc_finalize.f90

Contents

Source Code


Source Code

module korc_finalize
  !! @note Module containing subroutines to terminate parallel
  !! communications and free memory.
  use korc_types
  use korc_fields
  use korc_profiles
  use korc_hpc

  IMPLICIT NONE

  PUBLIC :: finalize_communications,&
       deallocate_variables

CONTAINS

  
  subroutine finalize_communications(params)
    !! @note Interface to function that finalizes MPI communications.
    !! See [[korc_hpc]].
    TYPE(KORC_PARAMS), INTENT(IN) :: params
    !! Core KORC simulation parameters.  

    call finalize_mpi(params)
  end subroutine finalize_communications


  subroutine deallocate_variables(params,F,P,spp)
    !! @note Subroutine to free allocatable simulation variables.    
    TYPE(KORC_PARAMS), INTENT(INOUT) 			:: params
    !! Core KORC simulation parameters.
    TYPE(FIELDS), INTENT(INOUT) 			:: F
    !! An instance of KORC's derived type FIELDS containing all the
    !! information about the fields used in the simulation. See
    !! [[korc_types]] and [[korc_fields]].
    TYPE(PROFILES), INTENT(INOUT)              :: P
    TYPE(SPECIES), DIMENSION(:), ALLOCATABLE, INTENT(INOUT) :: spp
    !! An instance of KORC's derived type SPECIES containing all the
    !! information of different electron species. See [[korc_types]].
    INTEGER 						:: ii
    !! Iterator of the spp array
    
    DEALLOCATE(params%outputs_list)

    do ii=1_idef,params%num_species
       DEALLOCATE(spp(ii)%vars%X)
       DEALLOCATE(spp(ii)%vars%V)
       DEALLOCATE(spp(ii)%vars%Rgc)
       DEALLOCATE(spp(ii)%vars%Y)
       DEALLOCATE(spp(ii)%vars%E)
       DEALLOCATE(spp(ii)%vars%B)
       DEALLOCATE(spp(ii)%vars%PSI_P)
       DEALLOCATE(spp(ii)%vars%ne)
       DEALLOCATE(spp(ii)%vars%ni)
       if (ALLOCATED(spp(ii)%vars%nimp)) DEALLOCATE(spp(ii)%vars%nimp)
       DEALLOCATE(spp(ii)%vars%Te)
       DEALLOCATE(spp(ii)%vars%Zeff)
       DEALLOCATE(spp(ii)%vars%g)
       DEALLOCATE(spp(ii)%vars%eta)
       DEALLOCATE(spp(ii)%vars%mu)
       DEALLOCATE(spp(ii)%vars%Prad)
       DEALLOCATE(spp(ii)%vars%flagCon)
       DEALLOCATE(spp(ii)%vars%flagCol)
       DEALLOCATE(spp(ii)%vars%flagRE)
       DEALLOCATE(spp(ii)%vars%initLCFS)
       DEALLOCATE(spp(ii)%vars%wt)

       if (params%orbit_model(1:2).eq.'GC') then
          DEALLOCATE(spp(ii)%vars%Y0)
          DEALLOCATE(spp(ii)%vars%V0)
          DEALLOCATE(spp(ii)%vars%k1)
          DEALLOCATE(spp(ii)%vars%k2)
          DEALLOCATE(spp(ii)%vars%k3)
          DEALLOCATE(spp(ii)%vars%k4)
          DEALLOCATE(spp(ii)%vars%RHS)
       end if
       
    end do

    DEALLOCATE(spp)

    call DEALLOCATE_FIELDS_ARRAYS(F)
    call DEALLOCATE_PROFILES_ARRAYS(P)
  end subroutine deallocate_variables

end module korc_finalize