Radial scheme

radial_scheme.f90

Description

This is an abstract type that defines the radial scheme used in MagIC

Quick access

Routines

costf1_complex(), costf1_complex_1d(), costf1_real_1d()

Needed modules

  • precision_mod: This module controls the precision used in MagIC

Types

  • type radial_scheme/unknown_type
    Type fields
    • % boundary_fac [real ]

    • % d2rmat (*,*) [real ,allocatable]

    • % d3rmat (*,*) [real ,allocatable]

    • % d4rmat (*,*) [real ,allocatable]

    • % ddddr (*,*) [real ,allocatable]

    • % dddr (*,*) [real ,allocatable]

    • % dddr_bot (*,*) [real ,allocatable]

    • % dddr_top (*,*) [real ,allocatable]

    • % dddrx (*) [real ,allocatable]

    • % ddr (*,*) [real ,allocatable]

    • % ddr_bot (*,*) [real ,allocatable]

    • % ddr_top (*,*) [real ,allocatable]

    • % ddrx (*) [real ,allocatable]

    • % dr (*,*) [real ,allocatable]

    • % dr_bot (*,*) [real ,allocatable]

    • % dr_top (*,*) [real ,allocatable]

    • % drmat (*,*) [real ,allocatable]

    • % drx (*) [real ,allocatable]

    • % n_max [integer ]

    • % nrmax [integer ]

    • % order [integer ]

    • % order_boundary [integer ]

    • % rmat (*,*) [real ,allocatable]

    • % rnorm [real ]

    • % version [character(len=72)]

Subroutines and functions

subroutine radial_scheme/costf1_complex(this, f, n_f_max, n_f_start, n_f_stop[, work_array])
Parameters
  • this [real ]

  • f (n_f_max,this%nrmax) [complex ,inout]

  • n_f_max [integer ,in,] :: number of columns in f,f2

  • n_f_start [integer ,in]

  • n_f_stop [integer ,in] :: columns to be transformed

  • work_array (n_f_max,this%nrmax) [complex ,inout,target]

subroutine radial_scheme/costf1_real_1d(this, f)
Parameters
  • this [real ]

  • f (this%nrmax) [real ,inout]

subroutine radial_scheme/costf1_complex_1d(this, f)
Parameters
  • this [real ]

  • f (this%nrmax) [complex ,inout]

chebyshev.f90

Quick access

Routines

initialize_mapping()

Needed modules

Types

  • type chebyshev/unknown_type
    Type fields
    • % alpha1 [real ]

    • % alpha2 [real ]

    • % chebt_oc [costf_odd_t ]

    • % l_map [logical ]

    • % r_cheb (*) [real ,allocatable]

    • % work_costf (*,*) [complex ,pointer]

Subroutines and functions

subroutine chebyshev/initialize(this, n_r_max, order, order_boundary)

Purpose of this subroutine is to calculate and store several values that will be needed for a fast cosine transform of the first kind. The actual transform is performed by the subroutine costf1.

Parameters
  • this [real ]

  • n_r_max [integer ,in]

  • order [integer ,in]

  • order_boundary [integer ,in]

subroutine chebyshev/initialize_mapping(this, n_r_max, ricb, rcmb, ratio1, ratio2, r)
Parameters
  • this [real ]

  • n_r_max [integer ,in]

  • ricb [real ,in]

  • rcmb [real ,in]

  • ratio1 [real ,inout]

  • ratio2 [real ,in]

  • r (n_r_max) [real ,out]

Call to

cheb_grid()

subroutine chebyshev/finalize(this)
Parameters

this [real ]

subroutine chebyshev/robin_bc(this, atop, btop, rhs_top, abot, bbot, rhs_bot, f)

This subroutine is used to determine the two boundary points of a field f subject to two Robin boundary conditions of the form:

atop*df/dr+btop*f = rhs_top;  abot*df/dr+bbot*f = rhs_bot

The method follows Canuto, SIAM, 1986 (p. 818)

Parameters
  • this [real ]

  • atop [real ,in]

  • btop [real ,in]

  • rhs_top [complex ,in]

  • abot [real ,in]

  • bbot [real ,in]

  • rhs_bot [complex ,in]

  • f (*) [complex ,inout]

subroutine chebyshev/get_der_mat(this, n_r_max)

Construct Chebychev polynomials and their first, second, and third derivative up to degree n_r at n_r points x in the interval \([a,b]\). Since the polynoms are only defined in \([-1,1]\) we have to use a map, mapping the points x to the points y in the interval \([-1,1]\). This map is executed by the subroutine cheb_grid and has to be done before calling this program.

Parameters
  • this [real ]

  • n_r_max [integer ,in]

subroutine chebyshev/costf1_complex(this, f, n_f_max, n_f_start, n_f_stop[, work_array])

Purpose of this subroutine is to perform a multiple cosine transforms for n+1 datapoints on the columns numbered n_f_start to n_f_stop in the array f(n_f_max,n+1) Depending whether the input f contains data or coeff arrays coeffs or data are returned in f.

Parameters
  • this [real ]

  • f (n_f_max,this%nrmax) [complex ,inout]

  • n_f_max [integer ,in,]

  • n_f_start [integer ,in]

  • n_f_stop [integer ,in]

  • work_array (n_f_max,this%nrmax) [complex ,inout,target]

subroutine chebyshev/costf1_complex_1d(this, f)
Parameters
  • this [real ]

  • f (this%nrmax) [complex ,inout]

subroutine chebyshev/costf1_real_1d(this, f)
Parameters
  • this [real ]

  • f (this%nrmax) [real ,inout]

finite_differences.f90

Description

This module is used to calculate the radial grid when finite differences are requested

Quick access

Routines

get_der_mat(), get_fd_coeffs(), get_fd_grid(), populate_fd_weights(), robin_bc()

Needed modules

Types

  • type finite_differences/unknown_type
    Type fields
    • % ddddr_bot (*,*) [real ,allocatable]

    • % ddddr_top (*,*) [real ,allocatable]

Subroutines and functions

subroutine finite_differences/initialize(this, n_r_max, order, order_boundary)

This subroutine allocates the arrays used when finite difference are used

Parameters
  • this [real ]

  • n_r_max [integer ,in]

  • order [integer ,in]

  • order_boundary [integer ,in]

subroutine finite_differences/finalize(this)

This subroutine deallocates the arrays used in FD

Parameters

this [real ]

subroutine finite_differences/get_fd_grid(this, n_r_max, ricb, rcmb, ratio1, ratio2, r)

This subroutine constructs the radial grid

Parameters
  • this [real ]

  • n_r_max [integer ,in] :: Number of grid points

  • ricb [real ,in] :: inner boundary

  • rcmb [real ,in] :: start with the outer boundary

  • ratio1 [real ,inout] :: Nboudary/Nbulk

  • ratio2 [real ,in] :: drMin/drMax

  • r (n_r_max) [real ,out] :: radius

Call to

logwrite(), abortrun()

subroutine finite_differences/get_fd_coeffs(this, r)
Parameters
  • this [real ]

  • r (*) [real ,in] :: Radius

Call to

populate_fd_weights()

subroutine finite_differences/robin_bc(this, atop, btop, rhs_top, abot, bbot, rhs_bot, f)

This routine is used to derive the values of f at both boundaries when f is subject to Robin boundary conditions on both sides:

Parameters
  • atop [real ,in] ::

    df/dr + btop * f = rhs_top; abot * df/dr + bbot * f = rhs_bot

    With finite differences, this yields two uncoupled equations that can be solved sequentially.

  • this [real ]

  • btop [real ,in]

  • rhs_top [complex ,in]

  • abot [real ,in]

  • bbot [real ,in]

  • rhs_bot [complex ,in]

  • f (*) [complex ,inout] :: Field f

subroutine finite_differences/get_der_mat(this, n_r_max)
Parameters
  • this [real ]

  • n_r_max [integer ,in]

subroutine finite_differences/populate_fd_weights(z, x, nd, m, c)

Generation of Finite Difference Formulas on Arbitrarily Spaced Grids, Bengt Fornberg, Mathematics of compuation, 51, 184, 1988, 699-706

Parameters
  • z [real ,in] :: grid points where approximations are to be accurate

  • x (nd + 1) [real ,in] :: hrid point locations

  • nd [integer ,in,optional/default=(len(x)-1)] :: dimension of x and c

  • m [integer ,in] :: highest deriative for which weights are sought

  • c (nd + 1,m + 1) [real ,out]

Called from

get_fd_coeffs()

Chebyshev polynomials and cosine transforms

chebyshev_polynoms.f90

Quick access

Routines

cheb_grid(), get_chebs_even()

Needed modules

Variables

Subroutines and functions

subroutine chebyshev_polynoms_mod/get_chebs_even(n_r, a, b, y, n_r_max, cheb, dcheb, d2cheb, dim1, dim2)

Construct even Chebyshev polynomials and their first, second and third derivative up to degree 2*(n_r/2) at (n_r/2) points x in the interval \([a,b]\). Since the polynoms are only defined in \([-1,1]\) we have to map the points x in [a,b] onto points y in the interval \([-1,1]\). For even Chebs we need only half the point of the map, these (n_r/2) points are in the interval \([1,0[\).

Parameters
  • n_r [integer ,in] :: only even chebs stored !

  • a [real ,in]

  • b [real ,in] :: interval boundaries \([a,b]\)

  • y (n_r_max) [real ,in] :: n_r grid points in interval \([a,b]\)

  • n_r_max [integer ,in,optional/default=len(y)] :: max number of radial points, dims of y

  • cheb (dim1,dim2) [real ,out] :: cheb(i,j) is Chebyshev pol.

  • dcheb (dim1,dim2) [real ,out] :: first derivative of cheb

  • d2cheb (dim1,dim2) [real ,out] :: second derivative o cheb

  • dim1 [integer ,in]

  • dim2 [integer ,in] :: dimensions of cheb,dcheb,……

Called from

radial()

subroutine chebyshev_polynoms_mod/cheb_grid(a, b, n, x, y, a1, a2, x0, lbd, l_map)

Given the interval \([a,b]\) the routine returns the n+1 points that should be used to support a Chebyshev expansion. These are the n+1 extrema y(i) of the Chebyshev polynomial of degree n in the interval \([-1,1]\). The respective points mapped into the interval of question \([a,b]\) are the x(i).

Note

x(i) and y(i) are stored in the reversed order: x(1)=b, x(n+1)=a, y(1)=1, y(n+1)=-1

Parameters
  • a [real ,in]

  • b [real ,in] :: interval boundaries

  • n [integer ,in] :: degree of Cheb polynomial to be represented by the grid points

  • x (*) [real ,out] :: grid points in interval \([a,b]\)

  • y (*) [real ,out] :: grid points in interval \([-1,1]\)

  • a1 [real ,in]

  • a2 [real ,in]

  • x0 [real ,in]

  • lbd [real ,in]

  • l_map [logical ,in] :: Chebyshev mapping

Called from

initialize_mapping(), radial()

cosine_transform_odd.f90

Description

This module contains the built-in type I discrete Cosine Transforms. This implementation is based on Numerical Recipes and FFTPACK. This only works for n_r_max-1 = 2**a 3**b 5**c, with a,b,c integers.

Quick access

Routines

costf1_real()

Needed modules

Types

  • type cosine_transform_odd/unknown_type
    Type fields
    • % d_costf_init (*) [real ,allocatable]

    • % i_costf_init (*) [integer ,allocatable]

Subroutines and functions

subroutine cosine_transform_odd/initialize(this, n, ni, nd)

Purpose of this subroutine is to calculate and store several values that will be needed for a fast cosine transform of the first kind. The actual transform is performed by the subroutine costf1.

Parameters
  • this [real ]

  • n [integer ,in]

  • ni [integer ,in]

  • nd [integer ,in]

Call to

abortrun(), factorise()

subroutine cosine_transform_odd/finalize(this)

Memory deallocation of help arrays for built-in type I DCT’s

Parameters

this [real ]

subroutine cosine_transform_odd/costf1_complex(this, f, n_f_max, n_f_start, n_f_stop, f2)

Purpose of this subroutine is to perform a multiple cosine transforms for n+1 datapoints on the columns numbered n_f_start to n_f_stop in the array f(n_f_max,n+1) Depending whether the input f contains data or coeff arrays coeffs or data are returned in f.

Parameters
  • this [real ]

  • f (n_f_max,*) [complex ,inout]

  • n_f_max [integer ,in,]

  • n_f_start [integer ,in]

  • n_f_stop [integer ,in]

  • f2 (n_f_max,*) [complex ,out]

Call to

fft_fac_complex()

subroutine cosine_transform_odd/costf1_complex_1d(this, f, f2)

Built-in type I DCT for one single complex vector field

Parameters
  • this [real ]

  • f (*) [complex ,inout]

  • f2 (*) [complex ,out]

subroutine cosine_transform_odd/costf1_real(this, f, n_f_max, n_f_start, n_f_stop, f2)

Built-in type I DCT for many real vector fields

Parameters
  • this [real ]

  • f (n_f_max,*) [real ,inout] :: data/coeff input

  • n_f_max [integer ,in,] :: number of columns in f,f2

  • n_f_start [integer ,in]

  • n_f_stop [integer ,in] :: columns to be transformed

  • f2 (n_f_max,*) [real ,out] :: work array of the same size as f

Call to

fft_fac_real()

subroutine cosine_transform_odd/costf1_real_1d(this, f, f2)

Built-in type I DCT for one single real vector field

Parameters
  • this [real ]

  • f (*) [real ,inout]

  • f2 (*) [real ,out]

cosine_transform_even.f90

Quick access

Routines

costf2()

Needed modules

Types

  • type cosine_transform_even/unknown_type
    Type fields
    • % d_costf_init (*) [real ,allocatable]

    • % i_costf_init (*) [integer ,allocatable]

Subroutines and functions

subroutine cosine_transform_even/initialize(this, n, ni, nd)

Purpose of this subroutine is to calculate several things needed for the Chebyshev transform. Prepares costf2 for even number of grid points.

Parameters
  • this [real ]

  • n [integer ,in]

  • ni [integer ,in]

  • nd [integer ,in]

Call to

abortrun(), factorise()

subroutine cosine_transform_even/finalize(this)
Parameters

this [real ]

subroutine cosine_transform_even/costf2(this, f, n_f_max, n_f_start, n_f_stop, f2)

Purpose of this subroutine is to perform a multiple cosine transforms for n+1 datapoints on the columns numbered n_f_start to n_f_stop in the array y(n_f_max,n+1) Depending whether the input y contains data or coeff arrays coeffs or data are returned in y.

Parameters
  • this [real ]

  • f (n_f_max,*) [complex ,inout] :: data/coeff input

  • n_f_max [integer ,in,] :: number of columns in y,y2

  • n_f_start [integer ,in]

  • n_f_stop [integer ,in] :: columns to be transformed

  • f2 (n_f_max,*) [complex ,out] :: work array of the same size as y

Call to

fft_fac_complex()

fft_fac.f90

Quick access

Routines

fft_fac_complex(), fft_fac_real()

Needed modules

Variables

Subroutines and functions

subroutine fft_fac_mod/fft_fac_real(a, b, c, d, trigs, nv, l1, l2, n, ifac, la)

Main part of Fourier / Chebyshev transform called in costf1, costf2

Parameters
  • a (*) [real ,in]

  • b (*) [real ,in]

  • c (*) [real ,out]

  • d (*) [real ,out]

  • trigs (2 * n) [real ,in]

  • nv [integer ,in]

  • l1 [integer ,in]

  • l2 [integer ,in]

  • n [integer ,in,optional/default=(len(trigs))/(2)]

  • ifac [integer ,in]

  • la [integer ,in]

Called from

costf1_real()

subroutine fft_fac_mod/fft_fac_complex(a, b, c, d, trigs, nv, l1, l2, n, ifac, la)

Main part of Fourier / Chebyshev transform called in costf1, costf2

Parameters
  • a (*) [complex ,in]

  • b (*) [complex ,in]

  • c (*) [complex ,out]

  • d (*) [complex ,out]

  • trigs (2 * n) [real ,in]

  • nv [integer ,in]

  • l1 [integer ,in]

  • l2 [integer ,in]

  • n [integer ,in,optional/default=(len(trigs))/(2)]

  • ifac [integer ,in]

  • la [integer ,in]

Called from

costf2()

Fourier transforms

fft.f90

Description

This module contains the native subroutines used to compute FFT’s. They are based on the FFT99 package from Temperton: http://www.cesm.ucar.edu/models/cesm1.2/cesm/cesmBbrowser/html_code/cam/fft99.F90.html I simply got rid of the ‘go to’ and Fortran legacy statements Those transforms only work for prime decomposition that involve factors of 2, 3, 5

Quick access

Variables

d_fft_init, i_fft_init, nd, ni

Routines

fft991(), fft99a(), fft99b(), fft_many(), fft_to_real(), finalize_fft(), ifft_many(), init_fft(), vpassm()

Needed modules

Variables

  • fft/d_fft_init (*) [real,private/allocatable]
  • fft/i_fft_init (100) [integer,private]
  • fft/nd [integer,private]
  • fft/ni [integer,private/parameter/optional/default=100]

Subroutines and functions

subroutine fft/init_fft(n)

Purpose of this subroutine is to calculate and store several values that will be needed for a fast Fourier transforms.

Parameters

n [integer ,in] :: Dimension of problem, number of grid points

Called from

horizontal()

Call to

abortrun(), factorise()

subroutine fft/finalize_fft()

Memory deallocation of FFT help arrays

Called from

finalize_horizontal_data()

subroutine fft/fft_to_real(f, ld_f, nrep)
Parameters
  • f (ld_f,nrep) [real ,inout]

  • ld_f [integer ,in,]

  • nrep [integer ,in,]

Call to

fft991()

subroutine fft/fft_many(g, f)

Fourier transform: f(nlat,nlon) -> fhat(nlat,nlon/2+1)

Parameters
Called from

native_spat_to_sph(), native_spat_to_sph_tor()

Call to

get_openmp_blocks(), fft991()

subroutine fft/ifft_many(f, g)

Inverse Fourier transform: fhat(nlat, nlon/2+1) -> f(nlat,nlon)

Parameters
Called from

native_qst_to_spat(), native_sphtor_to_spat(), native_sph_to_spat(), native_sph_to_grad_spat()

Call to

get_openmp_blocks(), fft991()

subroutine fft/fft991(a, work, trigs, ifax, inc, jump, n, lot, isign)

Multiple real/half-complex periodic Fast Fourier Transform

Procedure used to convert to half-length complex transform is given by Cooley, Lewis and Welch (j. sound vib., vol. 12 (1970), 315-337)

Definition of transforms:

isign=+1: x(j)=sum(k=0,...,n-1)(c(k)*exp(2*i*j*k*pi/n)) where c(k)=a(k)+i*b(k) and c(n-k)=a(k)-i*b(k)

isign=-1: a(k)=(1/n)*sum(j=0,...,n-1)(x(j)*cos(2*j*k*pi/n)) b(k)=-(1/n)*sum(j=0,...,n-1)(x(j)*sin(2*j*k*pi/n))

Parameters
  • a (*) [real ,inout] :: array containing input and output data

  • work (n+1)*lot) [real ,inout]

  • trigs (*) [real ,in] :: previously prepared list of trig function values

  • ifax (*) [integer ,inout] :: previously prepared list of factors of n/2

  • inc [integer ,in] :: increment within each data vector

  • jump [integer ,in] :: increment between the start of each data vector

  • n [integer ,in] :: length of the data vectors

  • lot [integer ,in] :: number of data vectors

  • isign [integer ,in] :: sign of the FFT

Called from

fft_to_real(), fft_many(), ifft_many()

Call to

fft99a(), vpassm(), fft99b()

subroutine fft/fft99a(a, work, trigs, inc, jump, n, lot)
Parameters
  • a (*) [real ,inout]

  • work (*) [real ,inout]

  • trigs (*) [real ,in]

  • inc [integer ,in]

  • jump [integer ,in]

  • n [integer ,in]

  • lot [integer ,in]

Called from

fft991()

subroutine fft/fft99b(work, a, trigs, inc, jump, n, lot)
Parameters
  • work (*) [real ,inout]

  • a (*) [real ,inout]

  • trigs (*) [real ,in]

  • inc [integer ,in]

  • jump [integer ,in]

  • n [integer ,in]

  • lot [integer ,in]

Called from

fft991()

subroutine fft/vpassm(a, b, c, d, trigs, inc1, inc2, inc3, inc4, lot, n, ifac, la)
Parameters
  • a (*) [real ,in]

  • b (*) [real ,in]

  • c (*) [real ,out]

  • d (*) [real ,out]

  • trigs (*) [real ,in]

  • inc1 [integer ,in]

  • inc2 [integer ,in]

  • inc3 [integer ,in]

  • inc4 [integer ,in]

  • lot [integer ,in]

  • n [integer ,in]

  • ifac [integer ,in]

  • la [integer ,in]

Called from

fft991()

Spherical harmonic transforms

plms.f90

Quick access

Routines

plm_theta()

Needed modules

Variables

Subroutines and functions

subroutine plms_theta/plm_theta(theta, max_degree, min_order, max_order, m0, plma, dtheta_plma, ndim_plma, norm)

This produces the \(P_{\ell}^m\) for all degrees \(\ell\) and orders \(m\) for a given colatitude. \(\theta\), as well as \(\sin \theta d P_{\ell}^m /d\theta\). The \(P_{\ell}^m\) are stored with a single lm index stored with m first.

Several normalisation are supported:

  • n=0 – surface normalised,

  • n=1 – Schmidt normalised,

  • n=2 – fully normalised.

Parameters
  • theta [real ,in] :: angle in radians

  • max_degree [integer ,in] :: required max degree of plm

  • min_order [integer ,in] :: required min order of plm

  • max_order [integer ,in] :: required max order of plm

  • m0 [integer ,in] :: basic wave number

  • plma (ndim_plma) [real ,out] :: associated Legendre polynomials at theta

  • dtheta_plma (ndim_plma) [real ,out] :: their theta derivative

  • ndim_plma [integer ,in] :: dimension of plma and dtheta_plma

  • norm [integer ,in] :: =0 fully normalised

Called from

horizontal(), initialize_magnetic_energy(), initialize_transforms()

Call to

abortrun()

shtransforms.f90

Description

This module is used when the native built-in SH transforms of MagIC are used. Those are much slower than SHTns, and are not recommanded for production runs!

Quick access

Variables

d_mc2m, dplm, lstart, lstop, plm, wdplm, wplm

Routines

finalize_transforms(), initialize_transforms(), native_axi_to_spat(), native_qst_to_spat(), native_spat_to_sh_axi(), native_spat_to_sph(), native_spat_to_sph_tor(), native_sph_to_grad_spat(), native_sph_to_spat(), native_sphtor_to_spat(), native_toraxi_to_spat()

Needed modules

Variables

  • shtransforms/d_mc2m (*) [real,allocatable/public]
  • shtransforms/dplm (*,*) [real,allocatable]
  • shtransforms/lstart (*) [integer,allocatable]
  • shtransforms/lstop (*) [integer,allocatable]
  • shtransforms/plm (*,*) [real,allocatable]

    Legendre polynomials \(P_{\ell m}\)

  • shtransforms/wdplm (*,*) [real,allocatable]
  • shtransforms/wplm (*,*) [real,allocatable]

Subroutines and functions

subroutine shtransforms/initialize_transforms()

This subroutine allocates the arrays needed when the native SH transforms are used. This also defines the Legendre polynomials and the Gauss weights.

Called from

initialize_sht()

Call to

gauleg(), plm_theta()

subroutine shtransforms/finalize_transforms()

This subroutine handles the memory deallocation of arrays used with the native SH transforms.

Called from

finalize_sht()

subroutine shtransforms/native_qst_to_spat(qlm, slm, tlm, brc, btc, bpc, lcut)

Vector spherical harmonic transform: take Q,S,T and transform them to a vector field

Parameters
Called from

torpol_to_spat(), torpol_to_curl_spat_ic(), torpol_to_spat_ic(), torpol_to_curl_spat()

Call to

get_openmp_blocks(), ifft_many()

subroutine shtransforms/native_sphtor_to_spat(slm, tlm, btc, bpc, lcut)

Use spheroidal and toroidal potentials to transform them to angular vector components btheta and bphi

Parameters
Called from

sphtor_to_spat(), torpol_to_dphspat()

Call to

get_openmp_blocks(), ifft_many()

subroutine shtransforms/native_axi_to_spat(slm, sc)
Parameters
Called from

axi_to_spat()

subroutine shtransforms/native_toraxi_to_spat(tlm, btc, bpc)

Use spheroidal and toroidal potentials to transform them to angular vector components btheta and bphi

Parameters
Called from

toraxi_to_spat()

subroutine shtransforms/native_sph_to_spat(slm, sc, lcut)

Spherical Harmonic Transform for a scalar input field

Parameters
Called from

scal_to_spat(), pol_to_curlr_spat()

Call to

get_openmp_blocks(), ifft_many()

subroutine shtransforms/native_sph_to_grad_spat(slm, gradtc, gradpc, lcut)

Transform s(l) into dsdt(theta) and dsdp(theta)

Parameters
Called from

scal_to_grad_spat(), pol_to_grad_spat()

Call to

get_openmp_blocks(), ifft_many()

subroutine shtransforms/native_spat_to_sph(scal, f1lm, lcut)

Legendre transform (n_r,n_theta,m) to (n_r,l,m)

Parameters
  • scal (*,*) [real ,inout]

  • f1lm (lm_max) [complex ,out]

  • lcut [integer ,in]

Called from

scal_to_sh(), spat_to_qst()

Call to

fft_many(), get_openmp_blocks()

subroutine shtransforms/native_spat_to_sph_tor(vt, vp, f1lm, f2lm, lcut)

Vector Legendre transform vt(n_r,n_theta,m), vp(n_r,n_theta,m) to Spheroidal(n_r,l,m) and Toroidal(n_r,l,m)

Parameters
  • vt (*,*) [real ,inout]

  • vp (*,*) [real ,inout]

  • f1lm (lm_max) [complex ,out]

  • f2lm (lm_max) [complex ,out]

  • lcut [integer ,in]

Called from

spat_to_qst(), spat_to_sphertor()

Call to

fft_many(), get_openmp_blocks()

subroutine shtransforms/native_spat_to_sh_axi(ft1, flm1, lmmax)

Legendre transform for an axisymmetric field

Parameters
  • ft1 (*) [real ,in] :: ASymm

  • flm1 (*) [real ,out]

  • lmmax [integer ,in] :: Number of modes to be processed

Called from

spat_to_sh_axi()

sht_native.f90

Quick access

Routines

axi_to_spat(), finalize_sht(), initialize_sht(), pol_to_curlr_spat(), pol_to_grad_spat(), scal_to_grad_spat(), scal_to_sh(), scal_to_spat(), spat_to_qst(), spat_to_sh_axi(), spat_to_sphertor(), sphtor_to_spat(), toraxi_to_spat(), torpol_to_curl_spat(), torpol_to_curl_spat_ic(), torpol_to_dphspat(), torpol_to_spat(), torpol_to_spat_ic()

Needed modules

Variables

Subroutines and functions

subroutine sht/initialize_sht()
Called from

magic

Call to

initialize_transforms()

subroutine sht/finalize_sht()
Called from

magic

Call to

finalize_transforms()

subroutine sht/scal_to_spat(slm, fieldc, lcut)

transform a spherical harmonic field into grid space

Parameters
  • slm (*) [complex ,in]

  • fieldc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

fields_average(), lm2pt(), transform_to_grid_space()

Call to

native_sph_to_spat()

subroutine sht/scal_to_grad_spat(slm, gradtc, gradpc, lcut)

transform a scalar spherical harmonic field into it’s gradient on the grid

Parameters
  • slm (*) [complex ,in]

  • gradtc (*,*) [real ,out]

  • gradpc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

transform_to_grid_rms(), transform_to_grid_space()

Call to

native_sph_to_grad_spat()

subroutine sht/pol_to_grad_spat(slm, gradtc, gradpc, lcut)
Parameters
  • slm (*) [complex ,in]

  • gradtc (*,*) [real ,out]

  • gradpc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

transform_to_grid_space()

Call to

native_sph_to_grad_spat()

subroutine sht/torpol_to_spat(wlm, dwlm, zlm, vrc, vtc, vpc, lcut)
Parameters
  • wlm (*) [complex ,in]

  • dwlm (*) [complex ,in]

  • zlm (*) [complex ,in]

  • vrc (*,*) [real ,out]

  • vtc (*,*) [real ,out]

  • vpc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

fields_average(), get_bpol(), get_b_surface(), transform_to_grid_space()

Call to

native_qst_to_spat()

subroutine sht/sphtor_to_spat(dwlm, zlm, vtc, vpc, lcut)
Parameters
  • dwlm (*) [complex ,in]

  • zlm (*) [complex ,in]

  • vtc (*,*) [real ,out]

  • vpc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

get_btor()

Call to

native_sphtor_to_spat()

subroutine sht/torpol_to_curl_spat_ic(r, r_icb, dblm, ddblm, jlm, djlm, cbr, cbt, cbp)

This is a QST transform that contains the transform for the inner core to compute the three components of the curl of B.

Parameters
  • r [real ,in]

  • r_icb [real ,in]

  • dblm (*) [complex ,in]

  • ddblm (*) [complex ,in]

  • jlm (*) [complex ,in]

  • djlm (*) [complex ,in]

  • cbr (*,*) [real ,out]

  • cbt (*,*) [real ,out]

  • cbp (*,*) [real ,out]

Called from

store_movie_frame_ic()

Call to

native_qst_to_spat()

subroutine sht/torpol_to_spat_ic(r, r_icb, wlm, dwlm, zlm, br, bt, bp)

This is a QST transform that contains the transform for the inner core.

Parameters
  • r [real ,in]

  • r_icb [real ,in]

  • wlm (*) [complex ,in]

  • dwlm (*) [complex ,in]

  • zlm (*) [complex ,in]

  • br (*,*) [real ,out]

  • bt (*,*) [real ,out]

  • bp (*,*) [real ,out]

Called from

graphout_ic(), store_movie_frame_ic()

Call to

native_qst_to_spat()

subroutine sht/torpol_to_dphspat(dwlm, zlm, dvtdp, dvpdp, lcut)

Computes horizontal phi derivative of a toroidal/poloidal field

Parameters
  • dwlm (*) [complex ,in]

  • zlm (*) [complex ,in]

  • dvtdp (*,*) [real ,out]

  • dvpdp (*,*) [real ,out]

  • lcut [integer ,in]

Called from

transform_to_grid_space()

Call to

native_sphtor_to_spat()

subroutine sht/pol_to_curlr_spat(qlm, cvrc, lcut)
Parameters
  • qlm (*) [complex ,in]

  • cvrc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

transform_to_grid_space()

Call to

native_sph_to_spat()

subroutine sht/torpol_to_curl_spat(or2, blm, ddblm, jlm, djlm, cvrc, cvtc, cvpc, lcut)

– Input variables

Parameters
  • or2 [real ,in]

  • blm (*) [complex ,in]

  • ddblm (*) [complex ,in]

  • jlm (*) [complex ,in]

  • djlm (*) [complex ,in]

  • cvrc (*,*) [real ,out]

  • cvtc (*,*) [real ,out]

  • cvpc (*,*) [real ,out]

  • lcut [integer ,in]

Called from

transform_to_grid_space()

Call to

native_qst_to_spat()

subroutine sht/scal_to_sh(f, flm, lcut)
Parameters
  • f (*,*) [real ,inout]

  • flm (*) [complex ,out]

  • lcut [integer ,in]

Called from

transform_to_lm_rms(), get_dtblm(), initv(), inits(), initxi(), transform_to_lm_space()

Call to

native_spat_to_sph()

subroutine sht/spat_to_qst(f, g, h, qlm, slm, tlm, lcut)
Parameters
  • f (*,*) [real ,inout]

  • g (*,*) [real ,inout]

  • h (*,*) [real ,inout]

  • qlm (*) [complex ,out]

  • slm (*) [complex ,out]

  • tlm (*) [complex ,out]

  • lcut [integer ,in]

Called from

transform_to_lm_rms(), transform_to_lm_space()

Call to

native_spat_to_sph(), native_spat_to_sph_tor()

subroutine sht/spat_to_sphertor(f, g, flm, glm, lcut)
Parameters
  • f (*,*) [real ,inout]

  • g (*,*) [real ,inout]

  • flm (*) [complex ,out]

  • glm (*) [complex ,out]

  • lcut [integer ,in]

Called from

transform_to_lm_rms(), get_dtblm(), get_br_v_bcs(), transform_to_lm_space()

Call to

native_spat_to_sph_tor()

subroutine sht/axi_to_spat(fl_ax, f)
Parameters
  • fl_ax (l_max+1) [complex ,in]

  • f (*) [real ,out]

Called from

outphase()

Call to

native_axi_to_spat()

subroutine sht/toraxi_to_spat(fl_ax, ft, fp)
Parameters
  • fl_ax (l_max+1) [complex ,in]

  • ft (*) [real ,out]

  • fp (*) [real ,out]

Called from

get_pas(), outomega(), get_dtb(), get_sl(), get_fl()

Call to

native_toraxi_to_spat()

subroutine sht/spat_to_sh_axi(f, flm)
Parameters
Called from

getto()

Call to

native_spat_to_sh_axi()

Linear algebra

matrices.f90

Quick access

Routines

mat_add()

Needed modules

  • precision_mod: This module controls the precision used in MagIC

Types

  • type real_matrices/unknown_type
    Type fields
    • % dat (*,*) [real ,allocatable]

    • % l_pivot [logical ]

    • % ncol [integer ]

    • % nrow [integer ]

    • % pivot (*) [integer ,allocatable]

Subroutines and functions

function real_matrices/mat_add(this, b)
Parameters
  • this [real ]

  • b [real ]

Return

mat_add [integer ]

Needed modules

Types

  • type dense_matrices/unknown_type

Subroutines and functions

subroutine dense_matrices/initialize(this, nx, ny, l_pivot[, nfull])

Memory allocation

Parameters
  • this [real ]

  • nx [integer ,in]

  • ny [integer ,in]

  • l_pivot [logical ,in]

Options

nfull [integer ,in,]

subroutine dense_matrices/finalize(this)

Memory deallocation

Parameters

this [real ]

subroutine dense_matrices/prepare(this, info)
Parameters
  • this [real ]

  • info [integer ,out]

Call to

prepare_mat()

subroutine dense_matrices/solve_real_single(this, rhs)
Parameters
  • this [real ]

  • rhs (*) [real ,inout]

subroutine dense_matrices/solve_complex_single(this, rhs)
Parameters
  • this [real ]

  • rhs (*) [complex ,inout]

subroutine dense_matrices/solve_real_multi(this, rhs, nrhs)
Parameters
  • this [real ]

  • rhs (*,*) [real ,inout]

  • nrhs [integer ,in]

subroutine dense_matrices/set_data(this, dat)
Parameters
  • this [real ]

  • dat (*,*) [real ,in]

Needed modules

Types

  • type band_matrices/unknown_type
    Type fields
    • % du2 (*) [real ,allocatable]

    • % kl [integer ]

    • % ku [integer ]

Subroutines and functions

subroutine band_matrices/initialize(this, nx, ny, l_pivot[, nfull])

Memory allocation

Parameters
  • this [real ]

  • nx [integer ,in]

  • ny [integer ,in]

  • l_pivot [logical ,in]

Options

nfull [integer ,in,]

subroutine band_matrices/finalize(this)

Memory deallocation

Parameters

this [real ]

subroutine band_matrices/prepare(this, info)
Parameters
  • this [real ]

  • info [integer ,out]

Call to

prepare_tridiag(), prepare_band()

subroutine band_matrices/solve_real_single(this, rhs)
Parameters
  • this [real ]

  • rhs (*) [real ,inout]

subroutine band_matrices/solve_complex_single(this, rhs)
Parameters
  • this [real ]

  • rhs (*) [complex ,inout]

subroutine band_matrices/solve_real_multi(this, rhs, nrhs)
Parameters
  • this [real ]

  • rhs (*,*) [real ,inout]

  • nrhs [integer ,in]

subroutine band_matrices/set_data(this, dat)
Parameters
  • this [real ]

  • dat (*,*) [real ,in]

algebra.f90

Quick access

Variables

solve_band, solve_bordered, solve_mat, solve_tridiag, zero_tolerance

Routines

gemm(), gemv(), prepare_band(), prepare_bordered(), prepare_mat(), prepare_tridiag(), solve_band_complex_rhs(), solve_band_real_rhs(), solve_band_real_rhs_multi(), solve_bordered_complex_rhs(), solve_bordered_real_rhs(), solve_bordered_real_rhs_multi(), solve_mat_complex_rhs(), solve_mat_real_rhs(), solve_mat_real_rhs_multi(), solve_tridiag_complex_rhs(), solve_tridiag_real_rhs(), solve_tridiag_real_rhs_multi()

Needed modules

Variables

  • algebra/solve_band [public]
  • algebra/solve_bordered [public]
  • algebra/solve_mat [public]
  • algebra/solve_tridiag [public]
  • algebra/zero_tolerance [real,private/parameter/optional/default=1.0e-15_cp]

Subroutines and functions

subroutine algebra/solve_mat_complex_rhs(a, ia, n, ip, bc1)

This routine does the backward substitution into a LU-decomposed real matrix a (to solve a * x = bc1) were bc1 is the right hand side vector. On return x is stored in bc1.

Parameters
  • a (ia,*) [real ,in] :: real n X n matrix

  • ia [integer ,in,] :: first dim of a

  • n [integer ,in] :: dimension of problem

  • ip (*) [integer ,in] :: pivot pointer of legth n

  • bc1 (*) [complex ,inout] :: on input RHS of problem

subroutine algebra/solve_mat_real_rhs_multi(a, ia, n, ip, bc, nrhss)

This routine does the backward substitution into a LU-decomposed real matrix a (to solve a * x = bc ) simultaneously for nRHSs real vectors bc. On return the results are stored in the bc.

Parameters
  • a (ia,n) [real ,in] :: real n X n matrix

  • ia [integer ,in,] :: leading dimension of a

  • n [integer ,in,] :: dimension of problem

  • ip (n) [integer ,in] :: pivot pointer of length n

  • bc (*,*) [real ,inout] :: on input RHS of problem

  • nrhss [integer ,in] :: number of right-hand sides

Called from

solve_bordered_real_rhs_multi()

subroutine algebra/solve_mat_real_rhs(a, ia, n, ip, b)

Backward substitution of vector b into lu-decomposed matrix a to solve a * x = b for a single real vector b

Parameters
  • a (ia,*) [real ,in] :: n*n real matrix

  • ia [integer ,in,] :: first dim of a

  • n [integer ,in] :: dim of problem

  • ip (*) [integer ,in] :: pivot information

  • b (*) [real ,inout] :: rhs-vector on input, solution on output

Called from

solve_bordered_real_rhs(), solve_bordered_complex_rhs()

subroutine algebra/prepare_mat(a, ia, n, ip, info)

LU decomposition the real matrix a(n,n) via gaussian elimination

Parameters
  • a (ia,*) [real ,inout] :: real nxn matrix on input, lu-decomposed matrix on output

  • ia [integer ,in,] :: first dimension of a (must be >= n)

  • n [integer ,in] :: 2nd dimension and rank of a

  • ip (*) [integer ,out] :: pivot pointer array

  • info [integer ,out] :: error message when /= 0

Called from

prepare_bordered(), inits(), initxi(), j_cond(), pt_cond(), ps_cond(), getbackground(), get_wpsmat(), get_ps0mat()

Call to

abortrun()

subroutine algebra/solve_band_real_rhs(abd, n, kl, ku, pivot, rhs)
Parameters
  • abd (2*kl+ku+1,n) [real ,in]

  • n [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivot (n) [integer ,in]

  • rhs (n) [real ,inout]

Called from

solve_bordered_real_rhs(), solve_bordered_complex_rhs()

subroutine algebra/solve_band_complex_rhs(abd, n, kl, ku, pivot, rhs)
Parameters
  • abd (2*kl+ku+1,n) [real ,in]

  • n [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivot (n) [integer ,in]

  • rhs (n) [complex ,inout]

subroutine algebra/solve_band_real_rhs_multi(abd, n, kl, ku, pivot, rhs, nrhss)
Parameters
  • abd (2*kl+ku+1,n) [real ,in]

  • n [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivot (n) [integer ,in]

  • rhs (*,*) [real ,inout]

  • nrhss [integer ,in]

Called from

solve_bordered_real_rhs_multi(), prepare_bordered()

subroutine algebra/prepare_band(abd, n, kl, ku, pivot, info)
Parameters
  • abd (2*kl+ku+1,n) [real ,inout]

  • n [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivot (n) [integer ,out]

  • info [integer ,out]

Called from

prepare_bordered()

subroutine algebra/solve_tridiag_real_rhs(dl, d, du, du2, n, pivot, rhs)
Parameters
  • dl (*) [real ,in] :: Lower

  • d (*) [real ,in] :: Diagonal

  • du (*) [real ,in] :: Upper

  • du2 (*) [real ,in] :: For pivot

  • n [integer ,in] :: dim of problem

  • pivot (*) [integer ,in] :: pivot information

  • rhs (*) [real ,inout]

subroutine algebra/solve_tridiag_complex_rhs(dl, d, du, du2, n, pivot, rhs)
Parameters
  • dl (*) [real ,in] :: Lower

  • d (*) [real ,in] :: Diagonal

  • du (*) [real ,in] :: Lower

  • du2 (*) [real ,in] :: Upper

  • n [integer ,in] :: dim of problem

  • pivot (*) [integer ,in] :: pivot information

  • rhs (*) [complex ,inout]

subroutine algebra/solve_tridiag_real_rhs_multi(dl, d, du, du2, n, pivot, rhs, nrhss)
Parameters
  • dl (*) [real ,in] :: Lower

  • d (*) [real ,in] :: Diagonal

  • du (*) [real ,in] :: Upper

  • du2 (*) [real ,in] :: For pivot

  • n [integer ,in] :: dim of problem

  • pivot (*) [integer ,in] :: pivot information

  • rhs (*,*) [real ,inout]

  • nrhss [integer ,in] :: Number of right-hand side

subroutine algebra/prepare_tridiag(dl, d, du, du2, n, pivot, info)
Parameters
  • dl (*) [real ,inout]

  • d (*) [real ,inout]

  • du (*) [real ,inout]

  • du2 (*) [real ,out]

  • n [integer ,in]

  • pivot (*) [integer ,out]

  • info [integer ,out]

subroutine algebra/solve_bordered_real_rhs(a1, a2, a3, a4, lena1, n_boundaries, kl, ku, pivota1, pivota4, rhs, lenrhs)

– Input variables

Parameters
  • a1 (2*kl+ku+1,lena1) [real ,in]

  • a2 (lena1,n_boundaries) [real ,in]

  • a3 (lena1) [real ,in]

  • a4 (n_boundaries,n_boundaries) [real ,in]

  • lena1 [integer ,in,]

  • n_boundaries [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivota1 (lena1) [integer ,in]

  • pivota4 (n_boundaries) [integer ,in]

  • rhs (lenrhs) [real ,inout]

  • lenrhs [integer ,in,optional/default=len(rhs)]

Call to

solve_band_real_rhs(), solve_mat_real_rhs(), gemv()

subroutine algebra/solve_bordered_complex_rhs(a1, a2, a3, a4, lena1, n_boundaries, kl, ku, pivota1, pivota4, rhs, lenrhs)

– Input variables

Parameters
  • a1 (2*kl+ku+1,lena1) [real ,in]

  • a2 (lena1,n_boundaries) [real ,in]

  • a3 (lena1) [real ,in]

  • a4 (n_boundaries,n_boundaries) [real ,in]

  • lena1 [integer ,in,]

  • n_boundaries [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivota1 (lena1) [integer ,in]

  • pivota4 (n_boundaries) [integer ,in]

  • rhs (lenrhs) [complex ,inout]

  • lenrhs [integer ,in,optional/default=len(rhs)]

Call to

solve_band_real_rhs(), solve_mat_real_rhs(), gemv()

subroutine algebra/solve_bordered_real_rhs_multi(a1, a2, a3, a4, lena1, n_boundaries, kl, ku, pivota1, pivota4, rhs, nrhss)

– Input variables

Parameters
  • a1 (2*kl+ku+1,lena1) [real ,in]

  • a2 (lena1,n_boundaries) [real ,in]

  • a3 (lena1) [real ,in]

  • a4 (n_boundaries,n_boundaries) [real ,in]

  • lena1 [integer ,in,]

  • n_boundaries [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivota1 (lena1) [integer ,in]

  • pivota4 (n_boundaries) [integer ,in]

  • rhs (*,*) [real ,inout]

  • nrhss [integer ,in]

Call to

solve_band_real_rhs_multi(), solve_mat_real_rhs_multi(), gemm()

subroutine algebra/prepare_bordered(a1, a2, a3, a4, lena1, n_boundaries, kl, ku, pivota1, pivota4, info)

– Input variables

Parameters
  • a1 (2*kl+ku+1,lena1) [real ,inout]

  • a2 (lena1,n_boundaries) [real ,inout]

  • a3 (lena1) [real ,inout]

  • a4 (n_boundaries,n_boundaries) [real ,inout]

  • lena1 [integer ,in,]

  • n_boundaries [integer ,in,]

  • kl [integer ,in]

  • ku [integer ,in]

  • pivota1 (lena1) [integer ,out]

  • pivota4 (n_boundaries) [integer ,out]

  • info [integer ,out]

Called from

prepare()

Call to

prepare_band(), solve_band_real_rhs_multi(), prepare_mat()

subroutine algebra/gemm(m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)

Computes a matrix-matrix product : C <- alpha*A*B+beta*C

– Input variables

Parameters
  • m [integer ,in]

  • n [integer ,in]

  • k [integer ,in]

  • alpha [real ,in]

  • a (lda,*) [real ,in]

  • lda [integer ,in,]

  • b (ldb,*) [real ,in]

  • ldb [integer ,in,]

  • beta [real ,in]

  • c (ldc,*) [real ,inout]

  • ldc [integer ,in,]

Called from

solve_bordered_real_rhs_multi()

subroutine algebra/gemv(m, n, alpha, a, lda, x, beta, y)

Computes a matrix-vector product: y <- alpha*A*x+beta

Parameters
  • m [integer ,in]

  • n [integer ,in]

  • alpha [real ,in]

  • a (lda,*) [real ,in]

  • lda [integer ,in,]

  • x (*) [real ,in]

  • beta [real ,in]

  • y (*) [real ,inout]

Called from

solve_bordered_real_rhs(), solve_bordered_complex_rhs()