forked from wannier-developers/wannier90
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwannier90_readwrite.F90
2599 lines (2251 loc) · 119 KB
/
wannier90_readwrite.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!-*- mode: F90 -*-!
!------------------------------------------------------------!
! This file is distributed as part of the Wannier90 code and !
! under the terms of the GNU General Public License. See the !
! file `LICENSE' in the root directory of the Wannier90 !
! distribution, or http://www.gnu.org/copyleft/gpl.txt !
! !
! The webpage of the Wannier90 code is www.wannier.org !
! !
! The Wannier90 code is hosted on GitHub: !
! !
! https://github.com/wannier-developers/wannier90 !
!------------------------------------------------------------!
! !
! w90_wannier90_readwrite: input/output routines !
! specific to wannier90.x !
! !
!------------------------------------------------------------!
module w90_wannier90_readwrite
!! Read/write routines specific to wannier90.x data types
use w90_constants, only: dp
use w90_types
use w90_error
use w90_readwrite
use w90_wannier90_types
implicit none
private
public :: w90_wannier90_readwrite_memory_estimate
public :: w90_wannier90_readwrite_read
public :: w90_wannier90_readwrite_read_special
public :: w90_wannier90_readwrite_w90_dealloc
public :: w90_wannier90_readwrite_write
public :: w90_wannier90_readwrite_write_chkpt
contains
!================================================!
subroutine w90_wannier90_readwrite_read_special(settings, atom_data, kmesh_input, kmesh_info, &
kpt_latt, wann_control, proj, proj_input, &
select_proj, w90_system, w90_calculation, &
real_lattice, bohr, mp_grid, num_bands, &
exclude_bands, num_kpts, num_proj, num_wann, &
gamma_only, lhasproj, use_bloch_phases, distk, &
stdout, error, comm)
!================================================!
!
!! Read parameters and calculate derived values
!!
!! Note on parallelization: this function should be called
!! from the root node only!
!!
!
!================================================
use w90_constants, only: w90_physical_constants_type
use w90_utility, only: utility_recip_lattice, utility_inverse_mat
implicit none
! arguments
type(atom_data_type), intent(inout) :: atom_data
type(kmesh_info_type), intent(inout) :: kmesh_info
type(kmesh_input_type), intent(inout) :: kmesh_input
type(proj_type), allocatable, intent(inout) :: proj(:), proj_input(:)
type(select_projection_type), intent(inout) :: select_proj
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
type(w90_system_type), intent(inout) :: w90_system
type(wann_control_type), intent(inout) :: wann_control
type(w90_calculation_type), intent(inout) :: w90_calculation !check if really needed??
integer, allocatable, intent(inout) :: exclude_bands(:)
integer, allocatable, intent(inout) :: distk(:)
integer, intent(inout) :: mp_grid(3)
integer, intent(inout) :: num_bands
integer, intent(inout) :: num_kpts
integer, intent(inout) :: num_proj
integer, intent(inout) :: num_wann
integer, intent(in) :: stdout
real(kind=dp), allocatable, intent(inout) :: kpt_latt(:, :)
real(kind=dp), intent(in) :: bohr
real(kind=dp), intent(inout) :: real_lattice(3, 3)
logical, intent(inout) :: lhasproj
logical, intent(inout) :: use_bloch_phases
logical, intent(inout) :: gamma_only
! local variables
logical :: disentanglement
real(kind=dp) :: inv_lattice(3, 3)
integer :: ip
integer :: num_exclude_bands, total_bands
call w90_readwrite_read_lattice(settings, real_lattice, bohr, error, comm)
if (allocated(error)) return
call w90_readwrite_read_atoms(settings, atom_data, real_lattice, bohr, error, comm)
if (allocated(error)) return
call w90_readwrite_read_num_wann(settings, num_wann, error, comm)
if (allocated(error)) return
call w90_readwrite_read_exclude_bands(settings, exclude_bands, num_exclude_bands, error, comm)
if (allocated(error)) return
total_bands = 0
call w90_readwrite_read_total_bands(settings, total_bands, error, comm)
if (allocated(error)) return
if (total_bands > 0) then
num_bands = total_bands - num_exclude_bands
else
call w90_readwrite_read_num_bands(settings, .false., num_bands, num_wann, error, comm)
if (allocated(error)) return
endif
disentanglement = (num_bands > num_wann)
call w90_readwrite_read_mp_grid(settings, .false., mp_grid, num_kpts, error, comm)
if (allocated(error)) return
call w90_readwrite_read_distk(settings, distk, num_kpts, error, comm)
if (allocated(error)) return
call w90_readwrite_read_kmesh_data(settings, kmesh_input, error, comm)
if (allocated(error)) return
call w90_readwrite_read_kpoints(settings, .false., kpt_latt, num_kpts, bohr, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_explicit_kpts(settings, w90_calculation, kmesh_info, &
num_kpts, bohr, error, comm)
if (allocated(error)) return
call w90_readwrite_read_system(settings, w90_system, error, comm)
if (allocated(error)) return
num_proj = num_wann !default, no projections specified
call utility_inverse_mat(real_lattice, inv_lattice)
call w90_wannier90_readwrite_read_projections(settings, proj, proj_input, use_bloch_phases, &
lhasproj, wann_control%guiding_centres%enable, &
select_proj, num_proj, atom_data, inv_lattice, &
num_wann, gamma_only, w90_system%spinors, bohr, &
stdout, error, comm)
if (allocated(error)) return
if (allocated(proj)) then
allocate (wann_control%guiding_centres%centres(3, num_proj))
do ip = 1, num_proj
wann_control%guiding_centres%centres(:, ip) = proj(ip)%site(:)
enddo
endif
end subroutine w90_wannier90_readwrite_read_special
!================================================!
subroutine w90_wannier90_readwrite_read(settings, band_plot, dis_control, dis_spheres, &
dis_manifold, fermi_energy_list, fermi_surface_data, &
output_file, wvfn_read, wann_control, real_space_ham, &
kpoint_path, w90_system, tran, print_output, wann_plot, &
ws_region, real_lattice, w90_calculation, bohr, &
symmetrize_eps, num_bands, num_kpts, num_wann, &
optimisation, calc_only_A, cp_pp, gamma_only, &
lsitesymmetry, use_bloch_phases, seedname, stdout, &
error, comm)
!================================================!
!
!! Read parameters and calculate derived values
!!
!! Note on parallelization: this function should be called
!! from the root node only!
!!
!
!================================================
use w90_constants, only: w90_physical_constants_type
use w90_utility, only: utility_recip_lattice, utility_inverse_mat
implicit none
! arguments
type(band_plot_type), intent(inout) :: band_plot
type(dis_control_type), intent(inout) :: dis_control
type(dis_manifold_type), intent(inout) :: dis_manifold
type(dis_spheres_type), intent(inout) :: dis_spheres
type(fermi_surface_plot_type), intent(inout) :: fermi_surface_data
type(kpoint_path_type), intent(inout) :: kpoint_path
type(output_file_type), intent(inout) :: output_file
type(print_output_type), intent(inout) :: print_output
type(real_space_ham_type), intent(inout) :: real_space_ham
type(settings_type), intent(inout) :: settings
type(transport_type), intent(inout) :: tran
type(w90_calculation_type), intent(inout) :: w90_calculation
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
type(w90_system_type), intent(inout) :: w90_system
type(wann_control_type), intent(inout) :: wann_control
type(wannier_plot_type), intent(inout) :: wann_plot
type(ws_region_type), intent(inout) :: ws_region
type(wvfn_read_type), intent(inout) :: wvfn_read
integer, intent(inout) :: num_bands
integer, intent(inout) :: num_kpts
integer, intent(inout) :: num_wann
integer, intent(inout) :: optimisation
integer, intent(in) :: stdout
real(kind=dp), allocatable, intent(inout) :: fermi_energy_list(:)
real(kind=dp), intent(in) :: bohr
real(kind=dp), intent(inout) :: real_lattice(3, 3)
real(kind=dp), intent(inout) :: symmetrize_eps
character(len=*), intent(in) :: seedname
!Projections
! RS: symmetry-adapted Wannier functions
logical, intent(inout) :: lsitesymmetry
logical, intent(out) :: use_bloch_phases, cp_pp, calc_only_A
logical, intent(inout) :: gamma_only
! local variables
logical :: has_kpath
logical :: has_explicit_kpath
integer :: num_exclude_bands
logical :: found_fermi_energy
logical :: disentanglement
character(len=20) :: energy_unit ! is this not used???
!! Units for energy
disentanglement = .false.
call w90_wannier90_readwrite_read_sym(settings, symmetrize_eps, lsitesymmetry, error, comm)
if (allocated(error)) return
call w90_readwrite_read_verbosity(settings, print_output, output_file%svd_omega, error, comm)
if (allocated(error)) return
call w90_readwrite_read_algorithm_control(settings, optimisation, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_w90_calcs(settings, w90_calculation, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_transport(settings, w90_calculation%transport, tran, &
w90_calculation%restart, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_dist_cutoff(settings, real_space_ham, error, comm)
if (allocated(error)) return
if (.not. (w90_calculation%transport .and. tran%read_ht)) then
call w90_readwrite_read_units(settings, print_output%lenconfac, print_output%length_unit, &
energy_unit, bohr, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_wannierise(settings, wann_control, num_wann, &
stdout, error, comm)
if (allocated(error)) return
call w90_readwrite_read_gamma_only(settings, gamma_only, num_kpts, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_post_proc(settings, cp_pp, calc_only_A, &
w90_calculation%postproc_setup, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_restart(settings, w90_calculation, seedname, error, comm)
if (allocated(error)) return
call w90_readwrite_read_kpath(settings, kpoint_path, has_kpath, w90_calculation%bands_plot, &
error, comm)
if (allocated(error)) return
if (.not. has_kpath) then
call w90_readwrite_read_explicit_kpath(settings, kpoint_path, has_explicit_kpath, w90_calculation%bands_plot, &
bohr, error, comm)
if (allocated(error)) return
endif
call w90_wannier90_readwrite_read_plot_info(settings, wvfn_read, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_band_plot(settings, band_plot, num_wann, has_kpath, &
has_explicit_kpath, w90_calculation%bands_plot, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_wann_plot(settings, wann_plot, num_wann, &
w90_calculation%wannier_plot, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_fermi_surface(settings, fermi_surface_data, &
w90_calculation%fermi_surface_plot, error, &
comm)
if (allocated(error)) return
call w90_readwrite_read_fermi_energy(settings, found_fermi_energy, fermi_energy_list, error, &
comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_outfiles(settings, output_file, num_kpts, &
w90_system%num_valence_bands, disentanglement, &
gamma_only, error, comm)
if (allocated(error)) return
endif
call w90_wannier90_readwrite_read_one_dim(settings, w90_calculation, band_plot, real_space_ham, &
tran%read_ht, error, comm)
if (allocated(error)) return
call w90_readwrite_read_ws_data(settings, ws_region, error, comm) !ws_search etc
if (allocated(error)) return
if (.not. (w90_calculation%transport .and. tran%read_ht)) then
call w90_readwrite_read_dis_manifold(settings, dis_manifold, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_disentangle(settings, dis_control, dis_spheres, num_bands, &
num_wann, bohr, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_hamil(settings, real_space_ham, error, comm)
if (allocated(error)) return
call w90_wannier90_readwrite_read_bloch_phase(settings, use_bloch_phases, disentanglement, &
error, comm)
if (allocated(error)) return
if (wann_control%constrain%constrain) then
call w90_wannier90_readwrite_read_constrained_centres(settings, &
wann_control, real_lattice, &
num_wann, print_output%iprint, &
stdout, error, comm)
if (allocated(error)) return
endif
endif
end subroutine w90_wannier90_readwrite_read
!================================================!
subroutine w90_wannier90_readwrite_read_sym(settings, symmetrize_eps, lsitesymmetry, error, comm)
!================================================!
! Site symmetry
!================================================!
use w90_error, only: w90_error_type
implicit none
logical, intent(inout) :: lsitesymmetry
real(kind=dp), intent(inout) :: symmetrize_eps
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found
! default value is lsitesymmetry=.false.
call w90_readwrite_get_keyword(settings, 'site_symmetry', found, error, comm, &
l_value=lsitesymmetry)
if (allocated(error)) return
! default value is symmetrize_eps=0.001
call w90_readwrite_get_keyword(settings, 'symmetrize_eps', found, error, comm, &
r_value=symmetrize_eps)
if (allocated(error)) return
end subroutine w90_wannier90_readwrite_read_sym
!================================================!
subroutine w90_wannier90_readwrite_read_w90_calcs(settings, w90_calculation, error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
type(settings_type), intent(inout) :: settings
type(w90_calculation_type), intent(inout) :: w90_calculation
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found
call w90_readwrite_get_keyword(settings, 'transport', found, error, comm, &
l_value=w90_calculation%transport)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'wannier_plot', found, error, comm, &
l_value=w90_calculation%wannier_plot)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'bands_plot', found, error, comm, &
l_value=w90_calculation%bands_plot)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'fermi_surface_plot', found, error, comm, &
l_value=w90_calculation%fermi_surface_plot)
if (allocated(error)) return
end subroutine w90_wannier90_readwrite_read_w90_calcs
!================================================!
subroutine w90_wannier90_readwrite_read_transport(settings, transport, tran, restart, error, comm)
!================================================!
! Transport
!================================================!
use w90_error, only: w90_error_type
implicit none
character(len=*), intent(inout) :: restart
logical, intent(in) :: transport
type(settings_type), intent(inout) :: settings
type(transport_type), intent(inout) :: tran
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found
call w90_readwrite_get_keyword(settings, 'tran_read_ht', found, error, comm, &
l_value=tran%read_ht)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_easy_fix', found, error, comm, &
l_value=tran%easy_fix)
if (allocated(error)) return
if (transport .and. tran%read_ht) restart = ' '
call w90_readwrite_get_keyword(settings, 'transport_mode', found, error, comm, &
c_value=tran%mode)
if (allocated(error)) return
! if ( .not.tran_read_ht .and. (index(transport_mode,'lcr').ne.0) ) then
! call set_error_input(error, 'Error: transport_mode.eq.lcr not compatible with tran_read_ht.eq.false', comm)
! return
! endif
call w90_readwrite_get_keyword(settings, 'tran_win_min', found, error, comm, &
r_value=tran%win_min)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_win_max', found, error, comm, &
r_value=tran%win_max)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_energy_step', found, error, comm, &
r_value=tran%energy_step)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_bb', found, error, comm, i_value=tran%num_bb)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_ll', found, error, comm, i_value=tran%num_ll)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_rr', found, error, comm, i_value=tran%num_rr)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_cc', found, error, comm, i_value=tran%num_cc)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_lc', found, error, comm, i_value=tran%num_lc)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_cr', found, error, comm, i_value=tran%num_cr)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_bandc', found, error, comm, &
i_value=tran%num_bandc)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_write_ht', found, error, comm, &
l_value=tran%write_ht)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_use_same_lead', found, error, comm, &
l_value=tran%use_same_lead)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_cell_ll', found, error, comm, &
i_value=tran%num_cell_ll)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_num_cell_rr', found, error, comm, &
i_value=tran%num_cell_rr)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'tran_group_threshold', found, error, comm, &
r_value=tran%group_threshold)
if (allocated(error)) return
! checks
if (transport) then
if ((index(tran%mode, 'bulk') .eq. 0) .and. (index(tran%mode, 'lcr') .eq. 0)) then
call set_error_input(error, 'Error: transport_mode not recognised', comm)
return
endif
if (tran%num_bb < 0) then
call set_error_input(error, 'Error: tran_num_bb < 0', comm)
return
endif
if (tran%num_ll < 0) then
call set_error_input(error, 'Error: tran_num_ll < 0', comm)
return
endif
if (tran%num_rr < 0) then
call set_error_input(error, 'Error: tran_num_rr < 0', comm)
return
endif
if (tran%num_cc < 0) then
call set_error_input(error, 'Error: tran_num_cc < 0', comm)
return
endif
if (tran%num_lc < 0) then
call set_error_input(error, 'Error: tran_num_lc < 0', comm)
return
endif
if (tran%num_cr < 0) then
call set_error_input(error, 'Error: tran_num_cr < 0', comm)
return
endif
if (tran%num_bandc < 0) then
call set_error_input(error, 'Error: tran_num_bandc < 0', comm)
return
endif
if (tran%num_cell_ll < 0) then
call set_error_input(error, 'Error: tran_num_cell_ll < 0', comm)
return
endif
if (tran%num_cell_rr < 0) then
call set_error_input(error, 'Error: tran_num_cell_rr < 0', comm)
return
endif
if (tran%group_threshold < 0.0_dp) then
call set_error_input(error, 'Error: tran_group_threshold < 0', comm)
return
endif
endif
end subroutine w90_wannier90_readwrite_read_transport
!================================================!
subroutine w90_wannier90_readwrite_read_dist_cutoff(settings, real_space_ham, error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
type(real_space_ham_type), intent(inout) :: real_space_ham
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found
call w90_readwrite_get_keyword(settings, 'dist_cutoff_mode', found, error, comm, &
c_value=real_space_ham%dist_cutoff_mode)
if (allocated(error)) return
if ((index(real_space_ham%dist_cutoff_mode, 'three_dim') .eq. 0) &
.and. (index(real_space_ham%dist_cutoff_mode, 'two_dim') .eq. 0) &
.and. (index(real_space_ham%dist_cutoff_mode, 'one_dim') .eq. 0)) then
call set_error_input(error, 'Error: dist_cutoff_mode not recognised', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'dist_cutoff', found, error, comm, &
r_value=real_space_ham%dist_cutoff)
if (allocated(error)) return
real_space_ham%dist_cutoff_hc = real_space_ham%dist_cutoff
call w90_readwrite_get_keyword(settings, 'dist_cutoff_hc', found, error, comm, &
r_value=real_space_ham%dist_cutoff_hc)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'hr_cutoff', found, error, comm, &
r_value=real_space_ham%hr_cutoff)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'bands_plot_dim', found, error, comm, &
i_value=real_space_ham%system_dim)
if (allocated(error)) return
end subroutine w90_wannier90_readwrite_read_dist_cutoff
!================================================!
subroutine w90_wannier90_readwrite_read_wannierise(settings, wann_control, num_wann, &
stdout, error, comm)
!================================================!
! Wannierise
!================================================!
use w90_error, only: w90_error_type
implicit none
! arguments
integer, intent(in) :: num_wann
integer, intent(in) :: stdout
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
type(wann_control_type), intent(inout) :: wann_control
! local variables
integer :: ierr
logical :: found
call w90_readwrite_get_keyword(settings, 'num_dump_cycles', found, error, comm, &
i_value=wann_control%num_dump_cycles)
if (allocated(error)) return
if (wann_control%num_dump_cycles < 0) then
call set_error_input(error, 'Error: num_dump_cycles must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'num_print_cycles', found, error, comm, &
i_value=wann_control%num_print_cycles)
if (allocated(error)) return
if (wann_control%num_print_cycles < 0) then
call set_error_input(error, 'Error: num_print_cycles must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'num_iter', found, error, comm, &
i_value=wann_control%num_iter)
if (allocated(error)) return
if (wann_control%num_iter < 0) then
call set_error_input(error, 'Error: num_iter must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'num_cg_steps', found, error, comm, &
i_value=wann_control%num_cg_steps)
if (allocated(error)) return
if (wann_control%num_cg_steps < 0) then
call set_error_input(error, 'Error: num_cg_steps must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'conv_tol', found, error, comm, &
r_value=wann_control%conv_tol)
if (allocated(error)) return
if (wann_control%conv_tol < 0.0_dp) then
call set_error_input(error, 'Error: conv_tol must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'conv_noise_amp', found, error, comm, &
r_value=wann_control%conv_noise_amp)
if (allocated(error)) return
! note that the default here is not to check convergence
wann_control%conv_window = -1
if (wann_control%conv_noise_amp > 0.0_dp) wann_control%conv_window = 5
call w90_readwrite_get_keyword(settings, 'conv_window', found, error, comm, &
i_value=wann_control%conv_window)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'conv_noise_num', found, error, comm, &
i_value=wann_control%conv_noise_num)
if (allocated(error)) return
if (wann_control%conv_noise_num < 0) then
call set_error_input(error, 'Error: conv_noise_num must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'guiding_centres', found, error, comm, &
l_value=wann_control%guiding_centres%enable)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'use_ss_functional', found, error, comm, &
l_value=wann_control%use_ss_functional)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'num_guide_cycles', found, error, comm, &
i_value=wann_control%guiding_centres%num_guide_cycles)
if (allocated(error)) return
if (wann_control%guiding_centres%num_guide_cycles < 0) then
call set_error_input(error, 'Error: num_guide_cycles must be >= 0', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'num_no_guide_iter', found, error, comm, &
i_value=wann_control%guiding_centres%num_no_guide_iter)
if (allocated(error)) return
if (wann_control%guiding_centres%num_no_guide_iter < 0) then
call set_error_input(error, 'Error: num_no_guide_iter must be >= 0', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'fixed_step', found, error, comm, &
r_value=wann_control%fixed_step)
if (allocated(error)) return
if (found .and. (wann_control%fixed_step < 0.0_dp)) then
call set_error_input(error, 'Error: fixed_step must be > 0', comm)
return
endif
if (wann_control%fixed_step > 0.0_dp) wann_control%lfixstep = .true.
call w90_readwrite_get_keyword(settings, 'trial_step', found, error, comm, &
r_value=wann_control%trial_step)
if (allocated(error)) return
if (found .and. wann_control%lfixstep) then
call set_error_input(error, 'Error: cannot specify both fixed_step and trial_step', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'precond', found, error, comm, &
l_value=wann_control%precond)
if (allocated(error)) return
wann_control%constrain%slwf_num = num_wann
call w90_readwrite_get_keyword(settings, 'slwf_num', found, error, comm, &
i_value=wann_control%constrain%slwf_num)
if (allocated(error)) return
if (found) then
if (wann_control%constrain%slwf_num .gt. num_wann .or. &
wann_control%constrain%slwf_num .lt. 1) then
call set_error_input(error, 'Error: slwf_num must be an integer between 1 and num_wann', comm)
return
end if
if (wann_control%constrain%slwf_num .lt. num_wann) &
wann_control%constrain%selective_loc = .true.
end if
call w90_readwrite_get_keyword(settings, 'slwf_constrain', found, error, comm, &
l_value=wann_control%constrain%constrain)
if (allocated(error)) return
if (found .and. wann_control%constrain%constrain) then
if (wann_control%constrain%selective_loc) then
allocate (wann_control%constrain%centres(num_wann, 3), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating ccentres_cart in w90_readwrite_get_centre_constraints', comm)
return
endif
else
write (stdout, *) ' No selective localisation requested. Ignoring constraints on centres'
wann_control%constrain%constrain = .false.
end if
end if
call w90_readwrite_get_keyword(settings, 'slwf_lambda', found, error, comm, &
r_value=wann_control%constrain%lambda)
if (allocated(error)) return
if (found) then
if (wann_control%constrain%lambda < 0.0_dp) then
call set_error_input(error, 'Error: slwf_lambda must be positive.', comm)
return
endif
endif
end subroutine w90_wannier90_readwrite_read_wannierise
!================================================!
subroutine w90_wannier90_readwrite_read_disentangle(settings, dis_control, dis_spheres, &
num_bands, num_wann, bohr, error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
integer, intent(in) :: num_bands, num_wann
real(kind=dp), intent(in) :: bohr
type(dis_control_type), intent(inout) :: dis_control
type(dis_spheres_type), intent(inout) :: dis_spheres
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
integer :: nkp, ierr
logical :: found
call w90_readwrite_get_keyword(settings, 'dis_num_iter', found, error, comm, &
i_value=dis_control%num_iter)
if (allocated(error)) return
if (dis_control%num_iter < 0) then
call set_error_input(error, 'Error: dis_num_iter must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'dis_mix_ratio', found, error, comm, &
r_value=dis_control%mix_ratio)
if (allocated(error)) return
if (dis_control%mix_ratio <= 0.0_dp .or. dis_control%mix_ratio > 1.0_dp) then
call set_error_input(error, 'Error: dis_mix_ratio must be greater than 0.0 but not greater than 1.0', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'dis_conv_tol', found, error, comm, &
r_value=dis_control%conv_tol)
if (allocated(error)) return
if (dis_control%conv_tol < 0.0_dp) then
call set_error_input(error, 'Error: dis_conv_tol must be positive', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'dis_conv_window', found, error, comm, &
i_value=dis_control%conv_window)
if (allocated(error)) return
if (dis_control%conv_window < 0) then
call set_error_input(error, 'Error: dis_conv_window must be positive', comm)
return
endif
! GS-start
call w90_readwrite_get_keyword(settings, 'dis_spheres_first_wann', found, error, comm, &
i_value=dis_spheres%first_wann)
if (allocated(error)) return
if (dis_spheres%first_wann < 1) then
call set_error_input(error, 'Error: dis_spheres_first_wann must be greater than 0', comm)
return
endif
if (dis_spheres%first_wann > num_bands - num_wann + 1) then
call set_error_input(error, 'Error: dis_spheres_first_wann is larger than num_bands-num_wann+1', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'dis_spheres_num', found, error, comm, &
i_value=dis_spheres%num)
if (allocated(error)) return
if (dis_spheres%num < 0) then
call set_error_input(error, 'Error: dis_spheres_num cannot be negative', comm)
return
endif
if (dis_spheres%num > 0) then
allocate (dis_spheres%spheres(4, dis_spheres%num), stat=ierr)
if (ierr /= 0) then
call set_error_alloc(error, 'Error allocating dis_spheres in w90_wannier90_readwrite_read', comm)
return
endif
call w90_readwrite_get_keyword_block(settings, 'dis_spheres', found, dis_spheres%num, 4, &
bohr, error, comm, r_value=dis_spheres%spheres)
if (allocated(error)) return
if (.not. found) then
call set_error_input(error, 'Error: Did not find dis_spheres in the input file', comm)
return
endif
do nkp = 1, dis_spheres%num
if (dis_spheres%spheres(4, nkp) < 1.0e-15_dp) then
call set_error_input(error, 'Error: radius for dis_spheres must be > 0', comm)
return
endif
enddo
endif
! GS-end
end subroutine w90_wannier90_readwrite_read_disentangle
!================================================!
subroutine w90_wannier90_readwrite_read_post_proc(settings, cp_pp, pp_only_A, postproc_setup, &
error, comm)
!================================================!
! check for input option to activate 'post processing' mode (i.e. writing nnkp data)
! the main() routine separately looks for '-pp' command line argument
use w90_error, only: w90_error_type
implicit none
logical, intent(inout) :: cp_pp, pp_only_A, postproc_setup
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found
call w90_readwrite_get_keyword(settings, 'postproc_setup', found, error, comm, &
l_value=postproc_setup)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'cp_pp', found, error, comm, l_value=cp_pp)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'calc_only_A', found, error, comm, l_value=pp_only_A)
if (allocated(error)) return
end subroutine w90_wannier90_readwrite_read_post_proc
!================================================!
subroutine w90_wannier90_readwrite_read_restart(settings, w90_calculation, seedname, error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
character(len=*), intent(in) :: seedname
type(settings_type), intent(inout) :: settings
type(w90_calculation_type), intent(inout) :: w90_calculation
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found, chk_found
call w90_readwrite_get_keyword(settings, 'restart', found, error, comm, &
c_value=w90_calculation%restart)
if (allocated(error)) return
if (found) then
if ((w90_calculation%restart .ne. 'default') .and. (w90_calculation%restart .ne. 'wannierise') &
.and. (w90_calculation%restart .ne. 'plot') .and. (w90_calculation%restart .ne. 'transport')) then
call set_error_input(error, 'Error in input file: value of restart not recognised', comm)
return
else
inquire (file=trim(seedname)//'.chk', exist=chk_found)
if (.not. chk_found) then
call set_error_file(error, 'Error: restart requested but '//trim(seedname)//'.chk file not found', comm)
return
endif
endif
endif
!post processing takes priority (user is not warned of this)
if (w90_calculation%postproc_setup) w90_calculation%restart = ' '
end subroutine w90_wannier90_readwrite_read_restart
!================================================!
subroutine w90_wannier90_readwrite_read_outfiles(settings, output_file, num_kpts, &
num_valence_bands, disentanglement, gamma_only, &
error, comm)
!================================================!
use w90_error, only: w90_error_type
implicit none
integer, intent(in) :: num_kpts
integer, intent(in) :: num_valence_bands
logical, intent(in) :: disentanglement, gamma_only
type(output_file_type), intent(inout) :: output_file
type(settings_type), intent(inout) :: settings
type(w90_comm_type), intent(in) :: comm
type(w90_error_type), allocatable, intent(out) :: error
logical :: found, hr_plot
call w90_readwrite_get_keyword(settings, 'write_xyz', found, error, comm, &
l_value=output_file%write_xyz)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_r2mn', found, error, comm, &
l_value=output_file%write_r2mn)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_proj', found, error, comm, &
l_value=output_file%write_proj)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_hr_diag', found, error, comm, &
l_value=output_file%write_hr_diag)
if (allocated(error)) return
hr_plot = .false.
call w90_readwrite_get_keyword(settings, 'hr_plot', found, error, comm, l_value=hr_plot)
if (allocated(error)) return
if (found) then
call set_error_input(error, 'Input parameter hr_plot is no longer used. Please use write_hr instead.', comm)
return
endif
call w90_readwrite_get_keyword(settings, 'write_hr', found, error, comm, &
l_value=output_file%write_hr)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_rmn', found, error, comm, &
l_value=output_file%write_rmn)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_tb', found, error, comm, &
l_value=output_file%write_tb)
if (allocated(error)) return
!%%%%%%%%%%%%%%%%
! Other Stuff
!%%%%%%%%%%%%%%%%
! aam: vdW
call w90_readwrite_get_keyword(settings, 'write_vdw_data', found, error, comm, &
l_value=output_file%write_vdw_data)
if (allocated(error)) return
if (output_file%write_vdw_data) then
if ((.not. gamma_only) .or. (num_kpts .ne. 1)) then
call set_error_input(error, 'Error: write_vdw_data may only be used with a single k-point at Gamma', comm)
return
endif
if (disentanglement .and. num_valence_bands <= 0) then
call set_error_input(error, 'If writing vdw data and disentangling then num_valence_bands must be defined', comm)
return
endif
endif
call w90_readwrite_get_keyword(settings, 'write_u_matrices', found, error, comm, &
l_value=output_file%write_u_matrices)
if (allocated(error)) return
call w90_readwrite_get_keyword(settings, 'write_bvec', found, error, comm, &
l_value=output_file%write_bvec)
if (allocated(error)) return
end subroutine w90_wannier90_readwrite_read_outfiles