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
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)
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.
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'
Returns the sec_ind_tot used to refer to a perturbation quantity.
Variables pertaining to the different grids used.
Numerical utilities related to giving output.
subroutine, public lvl_ud(inc)
Increases/decreases lvl of output.
integer function, public c(ij, sym, n, lim_n)
Convert 2-D coordinates (i,j) to the storage convention used in matrices.
integer, dimension(:,:), allocatable, public m
1-D array indices of metric indices
Numerical variables used by most other modules.
integer, parameter, public dp
double precision
integer, parameter, public max_name_ln
maximum length of filenames
complex(dp), parameter, public iu
complex unit
integer, parameter, public max_str_ln
maximum length of strings
integer, dimension(:,:), allocatable, public x_jobs_lims
data about X jobs: [ , , , ] for all jobs
integer, public x_job_nr
nr. of X job
Numerical utilities related to perturbation operations.
integer function, public calc_memory_x(ord, arr_size, n_mod, mem_size)
Calculate memory in MB necessary for X variables.
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...
logical function, public is_necessary_x(sym, sec_x_id, lim_sec_x)
Determines whether a variable needs to be considered:
logical function, public do_x()
Tests whether this perturbatino job should be done.
integer function, public trim_modes(mds_i, mds_o, id_lim_i, id_lim_o)
Limit input mode range to output mode range.
Variables pertaining to the perturbation quantities.
integer, public n_mod_x
size of m_X (pol. flux) or n_X (tor. flux)