PB3D
[2.45]
Ideal linear high-n MHD stability in 3-D
|
Go to the documentation of this file.
9 #include <PB3D_macros.h>
11 #include <slepc/finclude/slepceps.h>
82 &overwrite,ind_insert)
result(ierr)
90 character(*),
parameter :: rout_name =
'insert_block_mat'
94 petscscalar,
intent(in) :: block(:,:)
95 mat,
intent(inout) :: mat
96 petscint,
intent(in) :: r_id
97 petscint,
intent(in) :: ind(2)
98 petscint,
intent(in) :: n_r
99 petscbool,
intent(in),
optional :: transp
100 petscbool,
intent(in),
optional :: overwrite
101 petscbool,
intent(in),
optional :: ind_insert
104 petscint,
pointer :: nm_x(:,:)
105 petscbool :: transp_loc
106 petscbool :: overwrite_loc
107 character(len=max_str_ln) :: err_msg
108 petscint :: operation
109 petscscalar,
allocatable :: block_loc(:,:)
110 petscbool :: ind_insert_loc
117 if (
present(transp)) transp_loc = transp
118 overwrite_loc = .false.
119 if (
present(overwrite)) overwrite_loc = overwrite
120 ind_insert_loc = .false.
121 if (
present(ind_insert)) ind_insert_loc = ind_insert
124 if (overwrite_loc)
then
125 operation = insert_values
127 operation = add_values
131 if (use_pol_flux_f)
then
140 if (.not.ind_insert_loc)
call sleep(
rank)
142 &
': at (k,m) = '//trim(
i2str(r_id))//
' + ('//&
143 &trim(
i2str(ind(1)))//
','//trim(
i2str(ind(2)))//
'):',&
150 if (minval(r_id+ind).ge.0 .and. maxval(r_id+ind).lt.n_r)
then
152 err_msg =
'Couldn''t add values to matrix'
155 allocate(block_loc(
size(block,1),
size(block,2)))
161 call matsetvaluesblocked(mat,1,r_id+ind(1),1,r_id+ind(2),&
162 &transpose(block_loc),operation,ierr)
169 call writo(
'Also at the transposed place:')
175 &transpose(conjg(block)),block_loc)
177 call matsetvaluesblocked(mat,1,r_id+ind(2),1,r_id+ind(1),&
178 &transpose(block_loc),operation,ierr)
183 deallocate(block_loc)
187 &
call writo(
'Due to out of range no local block is added',&
211 petscint,
intent(in) :: nm_x(:,:)
212 petscint,
intent(in) :: r_id
213 petscint,
intent(in) :: ind(2)
214 petscscalar,
intent(in) :: block(:,:)
215 petscscalar,
intent(inout) :: block_loc(:,:)
219 petscint :: k_loc, m_loc
224 k_loc = k + nm_x(r_id+1,k) - &
225 &nm_x(min(r_id+1+ind(1),
size(nm_x,1)),k)
226 m_loc = m + nm_x(r_id+1,m) - &
227 &nm_x(min(r_id+1+ind(2),
size(nm_x,1)),m)
228 if (k_loc.ge.1 .and. m_loc.ge.1 .and. &
230 block_loc(k_loc,m_loc) = block(k,m)
236 call writo(
'following local block is going to be added by &
237 &rank '//trim(
i2str(
rank))//
':',persistent=.true.)
238 call writo(
'Re =',persistent=.true.)
240 call writo(
'Im =',persistent=.true.)
242 if (overwrite_loc)
then
243 call writo(
'(with operation INSERT_VALUES)',&
246 call writo(
'(with operation ADD_VALUES)',&
integer, parameter, public dp
double precision
Numerical variables used by most other modules.
integer, parameter, public max_str_ln
maximum length of strings
elemental character(len=max_str_ln) function, public i2str(k)
Convert an integer to string.
subroutine, public print_ar_2(arr)
Print an array of dimension 2 on the screen.
Numerical utilities related to SLEPC (and PETSC) operations.
complex(dp), parameter, public iu
complex unit
logical, public debug_insert_block_mat
plot debug information for insert_block_mat()
Variables pertaining to the perturbation quantities.
subroutine, public writo(input_str, persistent, error, warning, alert)
Write output to file identified by output_i.
Numerical utilities related to giving output.
integer function, public insert_block_mat(mds, block, mat, r_id, ind, n_r, transp, overwrite, ind_insert)
Insert a block pertaining to 1 normal point into a matrix.
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)
logical, public use_pol_flux_f
whether poloidal flux is used in F coords.
Operations concerning giving output, on the screen as well as in output files.
integer, public rank
MPI rank.
subroutine setup_local_block(nm_X, r_id, ind, block, block_loc)
/private Set up local block, possibly translated for fast PB3D.