PB3D
[2.45]
Ideal linear high-n MHD stability in 3-D
|
Go to the documentation of this file.
5 #include <PB3D_macros.h>
24 module procedure sec_ind_loc2tot_1
26 module procedure sec_ind_loc2tot_2
31 function sec_ind_loc2tot_1(id,lim_sec_X)
result(res)
33 integer,
intent(in) :: id
34 integer,
intent(in),
optional :: lim_sec_x(2)
38 integer :: lim_sec_x_loc(2)
42 if (
present(lim_sec_x)) lim_sec_x_loc = lim_sec_x
45 res = lim_sec_x_loc(1)-1+id
46 end function sec_ind_loc2tot_1
48 function sec_ind_loc2tot_2(id,jd,lim_sec_X)
result(res)
50 integer,
intent(in) :: id
51 integer,
intent(in) :: jd
52 integer,
intent(in),
optional :: lim_sec_x(2,2)
56 integer :: lim_sec_x_loc(2,2)
59 lim_sec_x_loc(:,1) = [1,
n_mod_x]
60 lim_sec_x_loc(:,2) = [1,
n_mod_x]
61 if (
present(lim_sec_x)) lim_sec_x_loc = lim_sec_x
64 res = [lim_sec_x_loc(1,1)-1+id,lim_sec_x_loc(1,2)-1+jd]
65 end function sec_ind_loc2tot_2
127 subroutine get_sec_x_range(sec_X_range_loc,sec_X_range_tot,m,sym,lim_sec_X)
132 integer,
intent(inout) :: sec_x_range_loc(2)
133 integer,
intent(inout) :: sec_x_range_tot(2)
134 integer,
intent(in) :: m
135 logical,
intent(in) :: sym
136 integer,
intent(in),
optional :: lim_sec_x(2,2)
139 integer :: k_range_loc(2)
144 if (
present(lim_sec_x))
then
145 n_mod = lim_sec_x(2,1)-lim_sec_x(1,1)+1
151 k_range_loc = [n_mod+1,0]
154 find_start:
do k = 1,n_mod
160 find_stop:
do k = n_mod,k_range_loc(1),-1
169 sec_x_range_loc(k) =
c([k_range_loc(k),m],sym,
n_mod_x,lim_sec_x)
178 logical function do_x()
196 logical function is_necessary_x(sym,sec_X_id,lim_sec_X)
result(res)
198 logical,
intent(in) :: sym
199 integer,
intent(in) :: sec_x_id(2)
200 integer,
intent(in),
optional :: lim_sec_x(2,2)
203 integer :: lim_sec_x_loc(2,2)
211 lim_sec_x_loc(:,1) = [1,
n_mod_x]
212 lim_sec_x_loc(:,2) = [1,
n_mod_x]
213 if (
present(lim_sec_x)) lim_sec_x_loc = lim_sec_x
216 if (lim_sec_x_loc(1,1)+sec_x_id(1).lt.&
217 &lim_sec_x_loc(1,2)+sec_x_id(2)) res = .false.
235 integer function calc_memory_x(ord,arr_size,n_mod,mem_size)
result(ierr)
238 character(*),
parameter :: rout_name =
'calc_memory_X'
241 integer,
intent(in) :: ord
242 integer,
intent(in) :: arr_size
243 integer,
intent(in) :: n_mod
244 real(
dp),
intent(inout) :: mem_size
247 integer(C_SIZE_T) :: dp_size
248 character(len=max_str_ln) :: err_msg
256 dp_size = 2*sizeof(1._dp)
262 mem_size = 4*arr_size
263 mem_size = mem_size*n_mod**ord
264 mem_size = mem_size*dp_size
268 mem_size = mem_size*(2*n_mod**ord+4*n_mod*(n_mod+1)/2)
269 mem_size = mem_size*dp_size
272 err_msg =
'Orders > 2 are not implemented'
277 mem_size = mem_size*1.e-6_dp
280 mem_size = mem_size*1.5_dp
283 if (mem_size.lt.0)
then
285 chckerr(
'Overflow occured')
292 integer function trim_modes(mds_i,mds_o,id_lim_i,id_lim_o)
result(ierr)
295 character(*),
parameter :: rout_name =
'trim_modes'
300 integer,
intent(inout) :: id_lim_i(2)
301 integer,
intent(inout) :: id_lim_o(2)
305 character(len=max_str_ln) :: err_msg
312 id_lim_o = [1,
size(mds_o%sec,1)]
314 do m = 1,
size(mds_i%sec,1)
315 if (mds_i%sec(m,1).eq.mds_o%sec(id_lim_o(1),1))
then
320 do m =
size(mds_i%sec,1),1,-1
321 if (mds_i%sec(m,1).eq.mds_o%sec(id_lim_o(2),1))
then
328 if (any(id_lim_o.le.0))
then
330 err_msg =
'Cannot find limits of input modes'
integer function, public c(ij, sym, n, lim_n)
Convert 2-D coordinates (i,j) to the storage convention used in matrices.
integer, parameter, public max_name_ln
maximum length of filenames
subroutine, public get_sec_x_range(sec_X_range_loc, sec_X_range_tot, m, sym, lim_sec_X)
Gets one of the the local ranges of contiguous tensorial perturbation variables to be printed or read...
integer, parameter, public dp
double precision
Numerical variables used by most other modules.
integer, parameter, public max_str_ln
maximum length of strings
Returns the sec_ind_tot used to refer to a perturbation quantity.
logical function, public is_necessary_x(sym, sec_X_id, lim_sec_X)
Determines whether a variable needs to be considered:
complex(dp), parameter, public iu
complex unit
integer, public x_job_nr
nr. of X job
Variables pertaining to the perturbation quantities.
logical function, public do_x()
Tests whether this perturbatino job should be done.
Numerical utilities related to perturbation operations.
Numerical utilities related to giving output.
Variables pertaining to the different grids used.
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
integer, public n_mod_x
size of m_X (pol. flux) or n_X (tor. flux)
integer function, public calc_memory_x(ord, arr_size, n_mod, mem_size)
Calculate memory in MB necessary for X variables.
integer function, public trim_modes(mds_i, mds_o, id_lim_i, id_lim_o)
Limit input mode range to output mode range.
integer, dimension(:,:), allocatable, public x_jobs_lims
data about X jobs: [ , , , ] for all jobs