FIXME : Add documentation
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(nonlinear_terms_config_type), | intent(in), | optional | :: | nonlinear_terms_config_in |
subroutine init_nonlinear_terms(nonlinear_terms_config_in)
use theta_grid, only: init_theta_grid, ntgrid
use kt_grids, only: init_kt_grids, naky, ntheta0, nx, ny, akx, aky
use le_grids, only: init_le_grids, nlambda, negrid
use species, only: init_species, nspec
use gs2_layouts, only: init_dist_fn_layouts, yxf_lo, accelx_lo
use gs2_layouts, only: init_gs2_layouts
use gs2_transforms, only: init_transforms
use mp, only: nproc, iproc
use array_utils, only: zero_array
#ifdef SHMEM
use shm_mpi3, only : shm_alloc
#endif
implicit none
type(nonlinear_terms_config_type), intent(in), optional :: nonlinear_terms_config_in
logical, parameter :: debug=.false.
if (initialized) return
initialized = .true.
if (debug) write(6,*) "init_nonlinear_terms: init_gs2_layouts"
call init_gs2_layouts
if (debug) write(6,*) "init_nonlinear_terms: init_theta_grid"
call init_theta_grid
if (debug) write(6,*) "init_nonlinear_terms: init_kt_grids"
call init_kt_grids
if (debug) write(6,*) "init_nonlinear_terms: init_le_grids"
call init_le_grids
if (debug) write(6,*) "init_nonlinear_terms: init_species"
call init_species
if (debug) write(6,*) "init_nonlinear_terms: init_dist_fn_layouts"
call init_dist_fn_layouts (ntgrid, naky, ntheta0, nlambda, negrid, nspec, nproc, iproc)
call read_parameters(nonlinear_terms_config_in)
! Initialise maximum velocity values
max_vel_components = 0
if (nonlin) then
if (debug) write(6,*) "init_nonlinear_terms: init_transforms"
call init_transforms (ntgrid, naky, ntheta0, nlambda, negrid, nspec, nx, ny, accelerated)
if (debug) write(6,*) "init_nonlinear_terms: allocations"
if (alloc) then
if (accelerated) then
#ifndef SHMEM
allocate ( aba(2*ntgrid+1, 2, accelx_lo%llim_proc:accelx_lo%ulim_alloc))
allocate ( agb(2*ntgrid+1, 2, accelx_lo%llim_proc:accelx_lo%ulim_alloc))
allocate (abracket(2*ntgrid+1, 2, accelx_lo%llim_proc:accelx_lo%ulim_alloc))
#else
call shm_alloc(aba, [ 1, 2*ntgrid+1, 1, 2, accelx_lo%llim_proc, accelx_lo%ulim_alloc ])
call shm_alloc(agb, [ 1, 2*ntgrid+1, 1, 2, accelx_lo%llim_proc, accelx_lo%ulim_alloc ])
call shm_alloc(abracket, [ 1, 2*ntgrid+1, 1, 2, accelx_lo%llim_proc, accelx_lo%ulim_alloc ])
#endif
call zero_array(aba) ; call zero_array(agb) ; call zero_array(abracket)
else
#ifndef SHMEM
allocate ( ba(yxf_lo%ny,yxf_lo%llim_proc:yxf_lo%ulim_alloc))
allocate ( gb(yxf_lo%ny,yxf_lo%llim_proc:yxf_lo%ulim_alloc))
allocate (bracket(yxf_lo%ny,yxf_lo%llim_proc:yxf_lo%ulim_alloc))
#else
call shm_alloc(ba, [ 1,yxf_lo%ny,yxf_lo%llim_proc,yxf_lo%ulim_alloc ])
call shm_alloc(gb, [ 1,yxf_lo%ny,yxf_lo%llim_proc,yxf_lo%ulim_alloc ])
call shm_alloc(bracket, [ 1,yxf_lo%ny,yxf_lo%llim_proc,yxf_lo%ulim_alloc ])
#endif
call zero_array(ba) ; call zero_array(gb) ; call zero_array(bracket)
end if
alloc = .false.
end if
cfly = maxval(aky) * 0.5 / cfl
cflx = maxval(akx) * 0.5 / cfl
end if
end subroutine init_nonlinear_terms