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, record_size, text_unit
77 LOGICAL :: named, opened
79 link(:, :) = cmplx(1.0_dp, 2.0_dp, dp)
80 CALL open_file(
'', unit_number=binary_unit, file_status=
'SCRATCH', file_access=
'STREAM', &
81 file_form=
'UNFORMATTED', file_action=
'READWRITE')
82 INQUIRE (unit=binary_unit, named=named, iostat=ios)
83 IF (ios /= 0) error stop
'Cannot inquire scratch link storage'
84 IF (named) error stop
'Link scratch storage must be anonymous'
85 CALL open_file(
'', unit_number=text_unit, file_status=
'SCRATCH', file_pad=
'NO', file_action=
'READWRITE')
86 IF (binary_unit == text_unit) error stop
'Scratch streams share a unit'
87 INQUIRE (iolength=record_size) link
88 WRITE (binary_unit, iostat=ios) link
89 IF (ios /= 0) error stop
'Cannot write first scratch link'
90 WRITE (binary_unit, iostat=ios) 2.0_dp*link
91 IF (ios /= 0) error stop
'Cannot write second scratch link'
92 READ (binary_unit, pos=record_size + 1, iostat=ios) restored
93 IF (ios /= 0) error stop
'Cannot read second scratch link'
94 IF (maxval(abs(restored - 2.0_dp*link)) > tolerance) error stop
'Incorrect second scratch link'
95 READ (binary_unit, pos=1, iostat=ios) restored
96 IF (ios /= 0) error stop
'Cannot read first scratch link'
97 IF (maxval(abs(restored - link)) > tolerance) error stop
'Incorrect first scratch link'
98 WRITE (text_unit,
'(A)', iostat=ios)
'links'
99 IF (ios /= 0) error stop
'Cannot write formatted scratch file'
101 READ (text_unit,
'(A)', iostat=ios) text
102 IF (ios /= 0) error stop
'Cannot read formatted scratch file'
103 IF (text /=
'links') error stop
'Incorrect formatted scratch contents'
104 CALL close_file(binary_unit)
105 CALL close_file(text_unit)
106 INQUIRE (unit=binary_unit, opened=opened, iostat=ios)
107 IF (ios /= 0) error stop
'Cannot inquire closed scratch stream'
108 IF (opened) error stop
'Scratch stream was not closed'
109 INQUIRE (unit=text_unit, opened=opened, iostat=ios)
110 IF (ios /= 0) error stop
'Cannot inquire closed formatted scratch file'
111 IF (opened) error stop
'Formatted scratch file was not closed'
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
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.