19 REAL(kind=
dp),
PARAMETER :: pi = 3.1415926535897932384626433832795_dp, tolerance = 1.e-12_dp
21 COMPLEX(KIND=dp) :: m(1, 1), reverse(1, 1), phase
22 REAL(kind=
dp) :: metric, gap
31 a%cell(i, i) = 20.0_dp
32 a%inverse(i, i) = 0.05_dp
34 ALLOCATE (a%atoms(1), a%bands(1), a%energies(2), a%coefficients(1, 1))
36 a%energies(:) = [-1.0_dp, 1.0_dp]
37 a%coefficients(:, :) = 1.0_dp
40 ALLOCATE (a%atoms(1)%shells(1))
41 associate(s => a%atoms(1)%shells(1))
45 ALLOCATE (s%exponent(1), s%radii(1), s%contraction(1, 1))
46 s%exponent(1) = 1.0_dp
48 s%contraction(1, 1) = (2.0_dp/pi)**0.75_dp
50 CALL check_snapshot(a, tolerance, tolerance, metric, gap)
51 IF (metric > tolerance .OR. abs(gap - 2.0_dp) > tolerance) error stop
'Incorrect snapshot metric or gap'
54 b%atoms(1)%center(1) = 0.7_dp
55 b%atoms(1)%shells(1)%center(1) = 0.7_dp
56 phase = exp(cmplx(0.0_dp, 0.3_dp, dp))
57 b%coefficients(:, :) = phase
58 CALL snapshot_overlap(a, b, a%k, b%k, m)
59 IF (abs(m(1, 1) - phase*exp(-0.7_dp**2/2.0_dp)) > tolerance) error stop
'Moving Gaussian overlap failed'
60 CALL snapshot_overlap(b, a, b%k, a%k, reverse)
61 IF (abs(m(1, 1) - conjg(reverse(1, 1))) > tolerance) error stop
'Directed overlap adjoint failed'
62 b%atoms(1)%center(:) = 0.0_dp
63 b%atoms(1)%shells(1)%center(:) = 0.0_dp
64 CALL check_snapshot_seam(a, b, [1], tolerance)
65 CALL snapshot_overlap(a, b, a%k, b%k, m)
66 IF (abs(m(1, 1) - phase) > tolerance) error stop
'Endpoint gauge sewing failed'
74 CHARACTER(LEN=5) :: text
75 COMPLEX(KIND=dp) :: link(2, 2), restored(2, 2)
76 INTEGER :: binary_unit, ios, second_position, &
78 LOGICAL :: named, opened
80 link(:, :) = cmplx(1.0_dp, 2.0_dp, dp)
81 CALL open_file(unit_number=binary_unit, file_status=
'SCRATCH', file_access=
'STREAM', &
82 file_form=
'UNFORMATTED', file_action=
'READWRITE')
83 INQUIRE (unit=binary_unit, named=named, iostat=ios)
84 IF (ios /= 0) error stop
'Cannot inquire scratch link storage'
85 IF (named) error stop
'Link scratch storage must be anonymous'
86 CALL open_file(unit_number=text_unit, file_status=
'SCRATCH', file_pad=
'NO', file_action=
'READWRITE')
87 IF (binary_unit == text_unit) error stop
'Scratch streams share a unit'
88 WRITE (binary_unit, iostat=ios) link
89 IF (ios /= 0) error stop
'Cannot write first scratch link'
90 INQUIRE (unit=binary_unit, pos=second_position, iostat=ios)
91 IF (ios /= 0) error stop
'Cannot inquire second scratch link position'
92 WRITE (binary_unit, iostat=ios) 2.0_dp*link
93 IF (ios /= 0) error stop
'Cannot write second scratch link'
94 READ (binary_unit, pos=second_position, iostat=ios) restored
95 IF (ios /= 0) error stop
'Cannot read second scratch link'
96 IF (maxval(abs(restored - 2.0_dp*link)) > tolerance) error stop
'Incorrect second scratch link'
97 READ (binary_unit, pos=1, iostat=ios) restored
98 IF (ios /= 0) error stop
'Cannot read first scratch link'
99 IF (maxval(abs(restored - link)) > tolerance) error stop
'Incorrect first scratch link'
100 WRITE (text_unit,
'(A)', iostat=ios)
'links'
101 IF (ios /= 0) error stop
'Cannot write formatted scratch file'
103 READ (text_unit,
'(A)', iostat=ios) text
104 IF (ios /= 0) error stop
'Cannot read formatted scratch file'
105 IF (text /=
'links') error stop
'Incorrect formatted scratch contents'
106 CALL close_file(binary_unit)
107 CALL close_file(text_unit)
108 INQUIRE (unit=binary_unit, opened=opened, iostat=ios)
109 IF (ios /= 0) error stop
'Cannot inquire closed scratch stream'
110 IF (opened) error stop
'Scratch stream was not closed'
111 INQUIRE (unit=text_unit, opened=opened, iostat=ios)
112 IF (ios /= 0) error stop
'Cannot inquire closed formatted scratch file'
113 IF (opened) error stop
'Formatted scratch file was not closed'
Utility routines to open and close files.
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
Defines the basic variable types.
integer, parameter, public dp
Provides Cartesian and spherical orbital pointers and indices.
subroutine, public init_orbital_pointers(maxl)
Initialize or update the orbital pointers.
Reader and physical moving-basis links for version-1 topology snapshots.
subroutine, public check_snapshot_seam(a, b, permutation, tolerance)
Check explicitly prescribed atom permutation, periodic translations and basis at a seam.
subroutine, public snapshot_overlap(a, b, ka, kb, overlap)
Apply screened Gaussian cross-geometry operator by atom blocks, without a dense AO matrix.
subroutine, public check_snapshot(a, metric_tol, gap_tol, metric_error, gap)
Check AO-metric normalization and separation at every selected/excluded boundary.
program topology_snapshot_unittest
subroutine test_scratch_links()
Exercise anonymous link storage without named files or shared-unit collisions.