TESTS Module

The numerical validation suite backing FORTVSH's accuracy claims (see the "Numerical Validation" appendix of the accompanying manuscript). Three families of checks:

  1. Cross-validation (TEST1_ANALYTIC/TEST1_VSH/TEST1_GW and their TEST2_* counterparts): the same closed-form quantity computed three independent ways -- a hand-derived analytic formula, a direct DOT product of VSH values, and the GWI/GWJ-coefficient expansion -- must agree to machine precision.
  2. Batch consistency (BATCH_*_CONS): every _ALL batch routine must agree pointwise with its single-mode counterpart, looped over the same range.
  3. Mathematical identities (SSH_ORTHO, PVSH_POL_TOR_ORTHO, VSH_POL_INVERSION): orthonormality, orthogonality, and the VSH_POL_UP/VSH_POL_DN rotation back to PVSH_POL/PVSH_RAD, each checked against its known exact value.

Every _CONS/_ORTHO/_INVERSION routine returns a STATUS (0 = pass, 1 = fail against its stated tolerance) and writes its full per-point data to OUTUNIT, driven from src/main.f90 -- the same data that feeds the manuscript's convergence figures via py/compute_validation.py.


Uses

  • module~~tests~~UsesGraph module~tests TESTS module~globals GLOBALS module~tests->module~globals module~kinds KINDS module~tests->module~kinds module~vsh VSH module~tests->module~vsh module~globals->module~kinds module~vsh->module~globals module~vsh->module~kinds

Used by

  • module~~tests~~UsedByGraph module~tests TESTS program~convergence_main CONVERGENCE_MAIN program~convergence_main->module~tests program~main MAIN program~main->module~tests

Functions

public function TEST1_ANALYTIC(NTH)

Hand-derived closed form for Test 1's target quantity (a specific product of VSH inner products), evaluated over a colatitude grid at for comparison against TEST1_VSH and TEST1_GW.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)

public function TEST1_GW(NTH)

Test 1's target quantity computed via the GWI-coefficient expansion in scalar spherical harmonics, rather than direct VSH DOT products -- must agree with TEST1_ANALYTIC and TEST1_VSH to machine precision. This is the check that specifically exercises GWI (see also TEST2_GW for the GWJ counterpart).

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)

public function TEST1_VSH(NTH)

Test 1's target quantity computed directly from DOT products of VSH_TOR/VSH_POL_DN/VSH_POL_UP values -- must agree with TEST1_ANALYTIC to machine precision.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)

public function TEST2_ANALYTIC(NTH)

Hand-derived closed form for Test 2's target quantity (a different product of VSH inner products than Test 1, with nonzero content), evaluated over a colatitude grid at a fixed for comparison against TEST2_VSH and TEST2_GW.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)

public function TEST2_GW(NTH)

Test 2's target quantity computed via the GWJ-coefficient expansion (combined with a GWI term) in scalar spherical harmonics -- must agree with TEST2_ANALYTIC and TEST2_VSH to machine precision. This is the check that specifically exercises GWJ.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)

public function TEST2_VSH(NTH)

Test 2's target quantity computed directly from DOT products of PVSH_POL/PVSH_TOR/PVSH_RAD values -- must agree with TEST2_ANALYTIC to machine precision.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: NTH

Number of colatitude samples over .

Return Value complex(kind=dp), DIMENSION(NTH)


Subroutines

public subroutine BATCH_ALM_CONS(LMAX, NX, OUTUNIT, STATUS)

Batch-consistency check: ASSOC_LEGENDRE_ALL vs. looped ASSOC_LEGENDRE calls, for , swept over NX points . Writes every (l,m,x) triple's batch value, single-mode value, and absolute difference to OUTUNIT; fails (STATUS=1) if any relative error exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NX

Number of points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some relative error

public subroutine BATCH_DALM_CONS(LMAX, NX, OUTUNIT, STATUS)

Batch-consistency check: DDX_ASSOC_LEGENDRE_ALL vs. looped DDX_ASSOC_LEGENDRE calls, for , swept over NX points . Same tolerance/output convention as BATCH_ALM_CONS.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NX

Number of points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some relative error

public subroutine BATCH_GRAD_SSH_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: GRAD_SSH_ALL vs. looped GRAD_SSH calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_L_SSH_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: L_SSH_ALL vs. looped L_SSH calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_PVSH_POL_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: PVSH_POL_ALL vs. looped PVSH_POL calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_PVSH_RAD_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: PVSH_RAD_ALL vs. looped PVSH_RAD calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_PVSH_TOR_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: PVSH_TOR_ALL vs. looped PVSH_TOR calls, for , swept over NTH colatitude points at fixed (both routines agree at too -- PVSH_TOR explicitly branches to return zero there rather than evaluating a 0/0 form). Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_SSH_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: SSH_ALL vs. looped SSH calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some

public subroutine BATCH_VSH_POL_DN_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: VSH_POL_DN_ALL vs. looped VSH_POL_DN calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_VSH_POL_UP_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: VSH_POL_UP_ALL vs. looped VSH_POL_UP calls, for , swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine BATCH_VSH_TOR_CONS(LMAX, NTH, OUTUNIT, STATUS)

Batch-consistency check: VSH_TOR_ALL vs. looped VSH_TOR calls, for (starts at ; VSH_TOR is identical to PVSH_TOR, already covered at by BATCH_PVSH_TOR_CONS), swept over NTH colatitude points at fixed . Fails (STATUS=1) if any component's absolute difference exceeds .

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some component difference

public subroutine PVSH_POL_TOR_ORTHO(LMAX, NTH, OUTUNIT, STATUS)

Verifies pointwise orthogonality of the poloidal and toroidal polar VSH members, for every -- an exact analytic identity (poloidal is a pure gradient, toroidal a pure gradient, and always), so any nonzero DOT value here is purely numerical error.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (some ( |{\rm DOT}|>10^{-12}

public subroutine SSH_ORTHO(LMAX, NQUAD, OUTUNIT, STATUS)

Verifies scalar spherical harmonic orthonormality, , for every . The integral is done analytically ( for matching , by construction 0 otherwise, so only same- pairs are checked); the integral (in ) uses a plain NQUAD-point midpoint rule via ASSOC_LEGENDRE_ALL, not SHGLQ -- sufficient here since only a scalar pass/fail diagonal check is needed, not a high-order transform.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NQUAD

Number of midpoint-rule quadrature points over

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L1 M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (any diagonal off from 1, or

public subroutine VSH_POL_INVERSION(LMAX, NTH, OUTUNIT, STATUS)

Verifies the orthogonal-rotation identity linking the standard and polar VSH bases can be inverted exactly: i.e. rotating VSH_POL_UP/VSH_POL_DN back by the same angle used to build them from PVSH_POL/PVSH_RAD recovers the originals exactly.

Read more…

Arguments

Type IntentOptional Attributes Name
integer(kind=i4), intent(in) :: LMAX

Maximum degree tested, .

integer(kind=i4), intent(in) :: NTH

Number of colatitude points swept over .

integer(kind=i4), intent(in) :: OUTUNIT

Fortran unit number to write results to (columns: `L M

integer(kind=i4), intent(out) :: STATUS

Output: 0 = pass, 1 = fail (either max difference