BraWl
Loading...
Searching...
No Matches
display.f90
Go to the documentation of this file.
1
8module display
9
10 use kinds
11 use shared_data
12 use constants
14
15 implicit none
16
17 private
18
20
21 contains
22
36 subroutine pretty_print_exchange(setup, units)
37 integer :: i,j,k
38 character(len=*), optional :: units
39 character(len=10) :: aunits
40 type(run_params), intent(in) :: setup
41
42 ! Can do mRy or meV, but default is meV
43 if (present(units)) then
44 aunits = units
45 else
46 aunits = 'meV'
47 end if
48
49 ! Case mRy
50 if (trim(aunits) .eq. 'mRy') then
51 write(*,"(x,'V_ij to be used in calculation (mRy):',/)")
52 do i=1, setup%interaction_range
53 write(*,'(a, I2, a, a)') ' Interchange interaction on shell: ', i, new_line('a')
54 write(*, '(A)', advance='no') ' '
55 do j=1, setup%n_species
56 write(*, '(A, A)', advance='no') ' ', setup%species_names(j)
57 end do
58 write(*, '(A)', advance='yes') ''
59 do j=1, setup%n_species
60 write(*, '(A, A)', advance='no') ' ', setup%species_names(j)
61 do k=1, setup%n_species
62 write(*, '(A, F8.3, A)', advance='no') ' ', 1000*v_ex(k,j,i), ' '
63 if (k .eq. setup%n_species) write(*,'(a)') ''
64 end do
65 if (j .eq. setup%n_species) write(*,'(a)') ''
66 end do
67 end do
68 write(*,'(a)') ''
69 ! Case meV
70 else if (trim(aunits) .eq. 'meV') then
71 write(*,"(x,'V_ij to be used in calculation (meV):',/)")
72 do i=1, setup%interaction_range
73 write(*,'(a, I2, a, a)') ' Interchange interaction on shell: ', i, new_line('a')
74 write(*, '(A)', advance='no') ' '
75 do j=1, setup%n_species
76 write(*, '(A, A)', advance='no') ' ', setup%species_names(j)
77 end do
78 write(*, '(A)', advance='yes') ''
79 do j=1, setup%n_species
80 write(*, '(A, A)', advance='no') ' ', setup%species_names(j)
81 do k=1, setup%n_species
82 write(*, '(A, F8.3, A)', advance='no') ' ', 1000*ry_to_ev*v_ex(k,j,i), ' '
83 if (k .eq. setup%n_species) write(*,'(a)') ''
84 end do
85 if (j .eq. setup%n_species) write(*,'(a)') ''
86 end do
87 end do
88 write(*,'(a)') ''
89 end if
90
91 end subroutine pretty_print_exchange
92
97 ! bcc lattice types, as well as simple cubic.
108 subroutine display_grid(grid, show_borders, title)
109
110 integer(kind=array_int), intent(in), dimension(:,:,:,:) :: grid
111 logical, intent(in), optional :: show_borders
112 character(len=*), optional :: title
113 logical :: borders
114 integer, dimension(4) :: sizes
115 integer :: ix, iy, iz
116 character(len=1) :: c
117 character(len=4), parameter :: clrstr = char(27)//'[2j'
118
119 borders = .true.
120
121 if (present(show_borders)) borders = show_borders
122
123 write(*,'(a)') clrstr
124
125 sizes = shape(grid)
126 if (present(title)) then
127 write(*, '(a)') title
128 end if
129
130 do iz = sizes(4), 1, -1
131
132 write(*, '(a, I2)') 'Layer for z = ', iz
133
134 if (borders) write(*, '(a)') repeat('=', sizes(2)+2)
135
136 do iy = sizes(3), 1, -1
137 if (borders) write(*, '(a)', advance='no') '|'
138 do ix = 1, sizes(2)
139 if (grid(1,ix,iy,iz) .ne. 0) then
140 write(c, '(I1)') grid(1,ix, iy, iz)
141 else
142 c = ' '
143 end if
144 write(*, '(a)', advance='no') c
145 end do
146 if (borders) write(*, '(a)', advance='no') '|'
147 write(*, '(a)') ''
148 end do
149 if (borders) write(*, '(a)') repeat('=', sizes(2)+2)
150 end do
151
152 end subroutine display_grid
153
168 subroutine print_centered_message(message, fill_char, newline)
169 implicit none
170 character(len=*), intent(in) :: message, fill_char
171 logical, optional :: newline
172 character(len=72) :: output_str
173 logical :: anewline
174 integer :: num_fill_chars
175
176 if (present(newline)) then
177 anewline = newline
178 else
179 anewline = .false.
180 end if
181
182 ! Calculate the number of fill characters needed on each side
183 num_fill_chars = (72 - len_trim(message) - 2) / 2
184
185 ! Construct the formatted string with fill characters on both sides
186 output_str = repeat(fill_char, num_fill_chars) // " " // message // " " // repeat(fill_char, num_fill_chars)
187
188 ! If there's an odd number of fill characters, we need to add one more to the right side
189 if (mod(72 - len_trim(message) - 2, 2) /= 0) then
190 output_str = output_str // fill_char
191 end if
192
193 ! Write formatted output
194 if (anewline) then
195 write(6, '(A,/)') output_str
196 else
197 write(6, '(A)') output_str
198 end if
199
200end subroutine print_centered_message
201
202end module display
real(real64), parameter, public ry_to_ev
Definition constants.f90:49
subroutine, public pretty_print_exchange(setup, units)
Subroutine to print atom-atom effective pair interactions to the screen in a human-readable format.
Definition display.f90:37
subroutine, public print_centered_message(message, fill_char, newline)
Centered printing routine
Definition display.f90:169
subroutine, public display_grid(grid, show_borders, title)
Subroutine to print the current state of the grid to the screen, layer by layer.
Definition display.f90:109
real(real64), dimension(:,:,:), allocatable v_ex
Derived type for parameters specifying general simulation parameters which are common to all sampling...