Routine to initialise
subroutine init_fields_local
use antenna, only: init_antenna
use theta_grid, only: init_theta_grid
use kt_grids, only: init_kt_grids
use gs2_layouts, only: init_gs2_layouts, g_lo
use mp, only: proc0, mp_abort
use file_utils, only: error_unit
implicit none
!Early exit if possible
if (initialised) return
!Exit if local fields not supported (e.g. compiled with pgi)
if(.not.fields_local_functional()) call mp_abort("field_option='local' not supported with this build")
!Make sure any dependencies are already initialised and
!initialise the field matrix object.
if (debug.and.proc0) write(6,*) "init_fields_local: gs2_layouts"
call init_gs2_layouts
if (debug.and.proc0) write(6,*) "init_fields_local: theta_grid"
call init_theta_grid
if (debug.and.proc0) write(6,*) "init_fields_local: kt_grids"
call init_kt_grids
if (debug.and.proc0) write(6,*) "init_fields_local: init_fields_matrixlocal"
if(field_local_tuneminnrow) then
call tuneMinNRow()
end if
call init_fields_matrixlocal(fieldmat, pc)
if (debug.and.proc0) write(6,*) "init_fields_local: antenna"
call init_antenna
!Print a warning message if x_lo isn't local
if((.not.(g_lo%x_local.and.g_lo%y_local)).and.field_local_allreduce_sub) then
if(proc0)write(error_unit(),'("Warning : In this run not all procs will hold the full field data (only proc0)")')
endif
!Set the initialised state
initialised = .true.
reinit = .false.
end subroutine init_fields_local