-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathqexsd.f90
1461 lines (1434 loc) · 61.4 KB
/
qexsd.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
! Copyright (C) 2003-2015 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!----------------------------------------------------------------------------
MODULE qexsd_module
!----------------------------------------------------------------------------
!
! This module contains some common subroutines used to read and write
! in XML format the data produced by Quantum ESPRESSO package.
!
! Written by Giovanni Borghi, A. Ferretti, ... (2015).
!
! Based on the qexml.f90 routine:
! Written by Andrea Ferretti (2006).
! Initial work by Carlo Sbraccia (xml_io_base.f90)
! Modified by Simone Ziraldo (2013).
!
USE kinds, ONLY : DP
USE input_parameters, ONLY : input_xml_schema_file, title
USE mp_world, ONLY : nproc
USE mp_images, ONLY : nimage,nproc_image
USE mp_pools, ONLY : npool
USE mp_bands, ONLY : ntask_groups, nproc_bgrp, nbgrp
USE global_version, ONLY: version_number, svn_revision
!
USE iotk_base, ONLY : iotk_indent, iotk_maxindent
USE constants, ONLY : e2
USE iotk_module
USE qes_module
!
IMPLICIT NONE
!
PRIVATE
SAVE
!
! definitions for the fmt
!
CHARACTER(5), PARAMETER :: fmt_name = "QEXSD"
CHARACTER(5), PARAMETER :: fmt_version = "0.1.0"
!
! some default for kinds
!
!INTEGER, PARAMETER :: DP = selected_real_kind( 14, 200 )
!
! internal data to be set
!
CHARACTER(256) :: datadir_in, datadir_out
INTEGER :: iunit, ounit
!
! vars to manage back compatibility
!
CHARACTER(10) :: qexsd_current_version = " "
CHARACTER(10) :: qexsd_default_version = trim( fmt_version )
LOGICAL :: qexsd_current_version_init = .FALSE.
!
LOGICAL :: qexsd_use_large_indent = .FALSE.
!
CHARACTER(iotk_attlenx) :: attr
!
TYPE (input_type) :: qexsd_input_obj
TYPE (general_info_type) :: general_info
TYPE (parallel_info_type) :: parallel_info
TYPE (berryPhaseOutput_type) :: qexsd_bp_obj
TYPE (dipoleOutput_type ) :: qexsd_dipol_obj
TYPE ( step_type),ALLOCATABLE :: steps(:)
TYPE ( status_type ) :: exit_status
TYPE ( closed_type ) :: qexsd_closed_element
INTEGER :: step_counter
!
! end of declarations
!
PUBLIC :: qexsd_current_version, qexsd_default_version
PUBLIC :: qexsd_current_version_init
!
PUBLIC :: qexsd_input_obj
!
PUBLIC :: qexsd_init_schema, qexsd_openschema, qexsd_closeschema
!
PUBLIC :: qexsd_init_convergence_info, qexsd_init_algorithmic_info, &
qexsd_init_atomic_species, qexsd_init_atomic_structure, &
qexsd_init_symmetries, qexsd_init_basis_set, qexsd_init_dft, &
qexsd_init_magnetization, qexsd_init_band_structure, &
qexsd_init_total_energy, qexsd_init_forces, qexsd_init_stress, &
qexsd_init_dipole_info, qexsd_init_outputElectricField
!
PUBLIC :: qexsd_step_addstep, qexsd_set_status
!
PUBLIC :: qexsd_init_berryPhaseOutput, qexsd_bp_obj, qexsd_dipol_obj
CONTAINS
!
!-------------------------------------------
! ... basic (public) subroutines
!-------------------------------------------
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_schema( unit_in, unit_out )
!------------------------------------------------------------------------
!
! just init module data
!
IMPLICIT NONE
INTEGER, INTENT(in) :: unit_in
INTEGER, OPTIONAL, INTENT(in) :: unit_out
!
iunit = unit_in
ounit = unit_in
IF ( present( unit_out ) ) ounit = unit_out
!
! increase the xml indentation for better reading
IF ( qexsd_use_large_indent ) THEN
iotk_indent = 8
iotk_maxindent = 64
ENDIF
!
END SUBROUTINE qexsd_init_schema
!
!
!------------------------------------------------------------------------
FUNCTION check_file_exst( filename )
!------------------------------------------------------------------------
!
IMPLICIT NONE
!
LOGICAL :: check_file_exst
CHARACTER(len=*) :: filename
!
LOGICAL :: lexists
!
INQUIRE( FILE = trim( filename ), EXIST = lexists )
!
check_file_exst = lexists
RETURN
!
END FUNCTION check_file_exst
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_openschema( filename )
!------------------------------------------------------------------------
!
IMPLICIT NONE
!
CHARACTER(iotk_attlenx) :: attr
CHARACTER(len=*), INTENT(IN) :: filename
CHARACTER(len=16) :: subname = 'qexsd_openschema'
INTEGER :: ierr, len_steps, i_step
!
! we need a qes-version number here
CALL iotk_write_attr(attr,"xmlns:qes","http://www.quantum-espresso.org/ns/qes/qes-1.0",FIRST=.true.)
!
! we need a schema location number (put a string in fortran-input)?
CALL iotk_write_attr(attr,"xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance",newline=.true.)
!
CALL iotk_write_attr(attr,"xsi:schemaLocation","http://www.quantum-espresso.org/ns/qes/qes-1.0 espresso.xsd",&
newline=.true.)
!
CALL iotk_open_write(ounit,FILE=filename , root="qes:espresso",attr=attr,binary=.false., &
skip_head=.true.,IERR=ierr)
!
IF (ierr /= 0) call errore(subname, 'opening xml output file', ierr)
! the input file is mandatory to have a validating schema
! here an error should be issued, instead
!
CALL qexsd_init_general_info(general_info)
CALL qes_write_general_info(ounit,general_info)
CALL qes_reset_general_info(general_info)
!
CALL qexsd_init_parallel_info(parallel_info)
CALL qes_write_parallel_info(ounit,parallel_info)
CALL qes_reset_parallel_info(parallel_info)
IF ( check_file_exst(input_xml_schema_file) ) THEN
CALL qexsd_cp_line_by_line(ounit,input_xml_schema_file, spec_tag="input")
ELSE IF ( TRIM(qexsd_input_obj%tagname) == "input") THEN
CALL qes_write_input(ounit,qexsd_input_obj)
END IF
!
!CALL qes_reset_input(qexsd_input_obj)
IF (ALLOCATED(steps) ) THEN
len_steps= step_counter
DO i_step = 1, len_steps
CALL qes_write_step(ounit, steps(i_step) )
END DO
END IF
!
END SUBROUTINE qexsd_openschema
!
!
!---------------------------------------------------------------------------------------
SUBROUTINE qexsd_init_general_info(obj)
!---------------------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE( general_info_type ) :: obj
CHARACTER(LEN=*),PARAMETER :: TAGNAME="general_info"
TYPE( creator_type ) :: creator_obj
TYPE( created_type ) :: created_obj
TYPE( xml_format_type) :: xml_fmt_obj
CHARACTER(LEN=256) :: version
CHARACTER(9) :: cdate, ctime
CHARACTER(60) :: timestamp
!
version=TRIM(version_number)
IF (svn_revision .NE. "unknown") version=TRIM(version)//&
" (svn rev. " // TRIM (svn_revision) // ")"
CALL qes_init_creator(creator_obj, "creator", "PWSCF", version, "XML file generated by PWSCF")
!
CALL date_and_tim(cdate, ctime)
timestamp = 'This run was terminated on: ' // ctime // ' ' // cdate(1:2) // &
' '//cdate(3:5) // ' '// cdate (6:9)
CALL qes_init_created (created_obj, "created", cdate, ctime, timestamp )
!
CALL qes_init_xml_format(xml_fmt_obj, "xml_format", fmt_name, fmt_version, fmt_name//"_"//fmt_version)
!
CALL qes_init_general_info( obj, TAGNAME, xml_fmt_obj, creator = creator_obj, created = created_obj,&
job=title)
!
CALL qes_reset_creator(creator_obj)
CALL qes_reset_created(created_obj)
CALL qes_reset_xml_format(xml_fmt_obj)
END SUBROUTINE qexsd_init_general_info
!
!---------------------------------------------------------------------------------------------
SUBROUTINE qexsd_init_parallel_info(obj)
!---------------------------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE ( parallel_info_type ) :: obj
!
INTEGER :: nthreads=1
#ifdef __OMP
INTEGER,EXTERNAL :: omp_get_max
!
nthreads = omp_get_max()
#endif
CALL qes_init_parallel_info(obj, "parallel_info", nproc, nthreads, ntask_groups, &
nbgrp, npool, nproc_bgrp)
END SUBROUTINE qexsd_init_parallel_info
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_closeschema()
!------------------------------------------------------------------------
USE mytime, ONLY: nclock, clock_label
IMPLICIT NONE
REAL(DP),EXTERNAL :: get_clock
!
CHARACTER(len=17) :: subname = 'qexsd_closeschema'
INTEGER :: ierr
!
IF (TRIM(exit_status%tagname) == "status") THEN
CALL qes_write_status(ounit, exit_status)
CALL qexsd_set_closed()
CALL iotk_write_begin(ounit, "cputime", attr="",new_line=.FALSE.)
!
WRITE(ounit, '(I0)', advance = 'no' ) nint(get_clock('PWSCF'))
CALL iotk_write_end(ounit, "cputime",indentation=.FALSE.)
CALL qes_write_closed(ounit, qexsd_closed_element)
END IF
CALL iotk_close_write(ounit, IERR=ierr)
!
CALL errore(subname, 'closing xml input file', ierr)
!
END SUBROUTINE qexsd_closeschema
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_cp_line_by_line(iun_out,filename,spec_tag)
!------------------------------------------------------------------------
implicit none
!
integer, intent(in) :: iun_out
character(*), intent(in) :: filename
character(*), optional, intent(in) :: spec_tag
!
integer :: iun, ierr
character(256) :: str
logical :: icopy, exists
call iotk_free_unit(iun)
!
INQUIRE(FILE=trim(filename), EXIST=exists)
!
IF(.not.exists) THEN
CALL errore('qexsd_cp_line_by_line', 'input xml file "' // &
& TRIM(filename) // '" not found', 1)
ENDIF
!
open(iun,FILE=trim(filename),status="old", IOSTAT=ierr)
!
icopy=.false.
copy_loop: do
!
read(iun,"(a256)",iostat=ierr) str
if (ierr<0) exit copy_loop
if (present(spec_tag)) then
!
if (index(str,"<"//trim(adjustl(spec_tag))//">")/=0) then
!
icopy=.true.
!
endif
!
else
!
icopy=.true.
!
endif
!
! filtering
!
if ( index(str,"<Root>")/=0 .or. index(str,"<Root>")/=0 .or. &
index(str,"<?")/=0 .or. .not.icopy) cycle copy_loop
!
write(iun_out,"(a)") trim(str)
!
if (present(spec_tag)) then
if (index(str,"</input>")/=0) icopy=.false.
endif
!
enddo copy_loop
!
close(iun)
!
END SUBROUTINE qexsd_cp_line_by_line
!
!
!-------------------------------------------
! ... write subroutines
!-------------------------------------------
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_convergence_info(obj, n_scf_steps, scf_error, &
opt_conv_ispresent, n_opt_steps, grad_norm )
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(convergence_info_type) :: obj
INTEGER, INTENT(IN) :: n_scf_steps
REAL(DP), INTENT(IN) :: scf_error
LOGICAL, INTENT(IN) :: opt_conv_ispresent
INTEGER, OPTIONAL, INTENT(in) :: n_opt_steps
REAL(DP),OPTIONAL, INTENT(IN) :: grad_norm
!
CHARACTER(27) :: subname="qexsd_init_convergence_info"
TYPE(scf_conv_type) :: scf_conv
TYPE(opt_conv_type) :: opt_conv
!
call qes_init_scf_conv(scf_conv, "scf_conv", n_scf_steps, scf_error)
!
IF ( opt_conv_ispresent ) THEN
!
IF ( .NOT. PRESENT(n_opt_steps) ) CALL errore(subname,"n_opt_steps not present",10)
IF ( .NOT. PRESENT(grad_norm) ) CALL errore(subname,"grad_norm not present",10)
!
call qes_init_opt_conv(opt_conv, "opt_conv", n_opt_steps, grad_norm)
ENDIF
!
call qes_init_convergence_info(obj, "convergence_info", scf_conv, opt_conv_ispresent, opt_conv)
!
call qes_reset_scf_conv(scf_conv)
call qes_reset_opt_conv(opt_conv)
!
END SUBROUTINE qexsd_init_convergence_info
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_algorithmic_info(obj, real_space_q, uspp, paw )
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(algorithmic_info_type) :: obj
LOGICAL, INTENT(IN) :: real_space_q, uspp, paw
!
CALL qes_init_algorithmic_info(obj, "algorithmic_info", real_space_q, uspp, paw)
!
END SUBROUTINE qexsd_init_algorithmic_info
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_atomic_species(obj, nsp, atm, psfile, amass, starting_magnetization,&
angle1,angle2)
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(atomic_species_type) :: obj
INTEGER, INTENT(IN) :: nsp
CHARACTER(len=*), INTENT(IN) :: atm(:)
CHARACTER(len=*), INTENT(IN) :: psfile(:)
REAL(DP), OPTIONAL, INTENT(IN) :: amass(:)
REAL(DP), OPTIONAL, INTENT(IN) :: starting_magnetization(:)
REAL(DP), OPTIONAL, INTENT(IN) :: angle1(:),angle2(:)
!
TYPE(species_type), ALLOCATABLE :: species(:)
REAL(DP) :: amass_ = 0.0d0
REAL(DP) :: start_mag_ = 0.0d0
REAL(DP) :: spin_teta = 0.0d0
REAL(DP) :: spin_phi = 0.0d0
INTEGER :: i
ALLOCATE(species(nsp))
!
DO i = 1, nsp
!
IF ( PRESENT(amass) ) amass_=amass(i)
IF ( PRESENT(starting_magnetization) ) start_mag_=starting_magnetization(i)
IF ( PRESENT( angle1 ) ) spin_teta =angle1(i)
IF ( PRESENT( angle2 ) ) spin_phi = angle2(i)
!
CALL qes_init_species( species(i), "species", TRIM(atm(i)),PRESENT(amass),amass_, &
TRIM(psfile(i)), PRESENT(starting_magnetization), start_mag_,&
PRESENT(angle1),spin_teta,PRESENT(angle2),spin_phi)
ENDDO
!
CALL qes_init_atomic_species(obj, "atomic_species", nsp, SIZE(species), species)
!
DO i = 1, nsp
CALL qes_reset_species(species(i))
ENDDO
DEALLOCATE(species)
!
END SUBROUTINE qexsd_init_atomic_species
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_atomic_structure(obj, nsp, atm, ityp, nat, tau, tau_units, &
alat, a1, a2, a3, ibrav)
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(atomic_structure_type) :: obj
INTEGER, INTENT(IN) :: nsp, nat
INTEGER, INTENT(in) :: ityp(:)
CHARACTER(LEN=*), INTENT(in) :: atm(:)
REAL(DP), INTENT(IN) :: tau(3,*)
CHARACTER(LEN=*), INTENT(IN) :: tau_units
REAL(DP), INTENT(IN) :: alat
REAL(DP), INTENT(IN) :: a1(:), a2(:), a3(:)
INTEGER, INTENT(IN) :: ibrav
!
INTEGER :: ia
TYPE(atom_type), ALLOCATABLE :: atom(:)
TYPE(cell_type) :: cell
TYPE(atomic_positions_type) :: atomic_pos
TYPE(wyckoff_positions_type) :: wyckoff_pos
REAL(DP) :: new_alat
LOGICAL :: ibrav_ispresent
!
! atomic positions
!
IF ( ibrav .gt. 0 ) THEN
ibrav_ispresent = .TRUE.
ELSE
ibrav_ispresent = .FALSE.
END IF
!
ALLOCATE(atom(nat))
DO ia = 1, nat
CALL qes_init_atom( atom(ia), "atom", name=trim(atm(ityp(ia))), &
position="", position_ispresent=.FALSE., atom=tau(1:3,ia), index_ispresent = .TRUE.,&
index = ia )
ENDDO
!
CALL qes_init_atomic_positions(atomic_pos, "atomic_positions", SIZE(atom), atom)
!
DO ia = 1, nat
CALL qes_reset_atom( atom(ia) )
ENDDO
DEALLOCATE(atom)
!
! cell
!
CALL qes_init_cell(cell, "cell", a1, a2, a3)
!
! global init
!
CALL qes_init_atomic_structure(obj, "atomic_structure", nat=nat, &
alat=alat, alat_ispresent=.TRUE., atomic_positions_ispresent=.TRUE., &
atomic_positions=atomic_pos, wyckoff_positions_ispresent=.FALSE., &
wyckoff_positions=wyckoff_pos, cell=cell ,&
bravais_index_ispresent = ibrav_ispresent, bravais_index=ibrav)
!
! cleanup
!
CALL qes_reset_atomic_positions(atomic_pos)
CALL qes_reset_cell(cell)
!
END SUBROUTINE qexsd_init_atomic_structure
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_symmetries(obj, nsym, nrot, space_group, s, ft, sname, t_rev, nat, irt, &
class_names, verbosity, noncolin)
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(symmetries_type) :: obj
INTEGER, INTENT(IN) :: nsym, nrot, nat
INTEGER, INTENT(IN) :: space_group
INTEGER, INTENT(IN) :: s(:,:,:), irt(:,:)
REAL(DP), INTENT(IN) :: ft(:,:)
INTEGER, INTENT(IN) :: t_rev(:)
CHARACTER(LEN=*), INTENT(IN) :: sname(:), verbosity
CHARACTER(LEN=15),INTENT(IN) :: class_names(:)
LOGICAL,INTENT(IN) :: noncolin
!
TYPE(symmetry_type), ALLOCATABLE :: symm(:)
TYPE(equivalent_atoms_type) :: equiv_atm
TYPE(info_type) :: info
TYPE(matrix_type) :: matrix
CHARACTER(LEN=15) :: classname
CHARACTER(LEN=256) :: la_info
LOGICAL :: class_ispresent = .FALSE., time_reversal_ispresent = .FALSE.
INTEGER :: i
ALLOCATE(symm(nrot))
!
IF ( TRIM(verbosity) .EQ. 'high' .OR. TRIM(verbosity) .EQ. 'medium') class_ispresent= .TRUE.
IF ( noncolin ) time_reversal_ispresent = .TRUE.
DO i = 1, nrot
!
classname = class_names(i)
IF ( i .LE. nsym ) THEN
la_info = "crystal_symmetry"
ELSE
la_info = "lattice_symmetry"
END IF
CALL qes_init_info(info, "info", name=sname(i), name_ispresent=.TRUE., &
class=classname, class_ispresent = class_ispresent, &
time_reversal=(t_rev(i)==1), time_reversal_ispresent = time_reversal_ispresent, &
INFO= TRIM(la_info) )
!
CALL qes_init_matrix(matrix, "rotation", ndim1_mat=3, ndim2_mat=3, mat=real(s(:,:,i),DP))
!
IF ( i .LE. nsym ) THEN
CALL qes_init_equivalent_atoms(equiv_atm, "equivalent_atoms", nat=nat, ndim_index_list=nat, &
index_list=irt(i,1:nat) )
!
CALL qes_init_symmetry(symm(i),"symmetry", info=info, rotation=matrix, &
fractional_translation_ispresent=.TRUE., fractional_translation=ft(:,i), &
equivalent_atoms_ispresent=.TRUE., equivalent_atoms=equiv_atm)
ELSE
CALL qes_init_symmetry ( symm(i), "symmetry", INFO = info, ROTATION = matrix, &
FRACTIONAL_TRANSLATION_ISPRESENT = .FALSE., FRACTIONAL_TRANSLATION=ft(:,i), &
EQUIVALENT_ATOMS_ISPRESENT = .FALSE., EQUIVALENT_ATOMS=equiv_atm)
END IF
!
CALL qes_reset_info(info)
CALL qes_reset_matrix(matrix)
IF ( i .LT. nsym ) THEN
CALL qes_reset_equivalent_atoms( equiv_atm )
ELSE IF ( i .EQ. nrot ) THEN
CALL qes_reset_equivalent_atoms( equiv_atm )
END IF
!
ENDDO
!
CALL qes_init_symmetries(obj,"symmetries",NSYM = nsym, NROT=nrot, SPACE_GROUP = space_group, &
NDIM_SYMMETRY=SIZE(symm), SYMMETRY=symm )
!
DO i = 1, nsym
CALL qes_reset_symmetry(symm(i))
ENDDO
DEALLOCATE(symm)
!
END SUBROUTINE qexsd_init_symmetries
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_basis_set(obj, gamma_only, ecutwfc, ecutrho, &
nr1, nr2, nr3, nr1s, nr2s, nr3s, &
fft_box_ispresent, nr1b, nr2b, nr3b, &
ngm, ngms, npwx, b1, b2, b3 )
!------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(basis_set_type) :: obj
LOGICAL, INTENT(IN) :: gamma_only
INTEGER, INTENT(IN) :: nr1, nr2, nr3
INTEGER, INTENT(IN) :: nr1s, nr2s, nr3s
LOGICAL, INTENT(IN) :: fft_box_ispresent
INTEGER, INTENT(IN) :: nr1b, nr2b, nr3b
INTEGER, INTENT(IN) :: ngm, ngms, npwx
REAL(DP), INTENT(IN) :: ecutwfc, ecutrho
REAL(DP), INTENT(IN) :: b1(3), b2(3), b3(3)
!
TYPE(basisSetItem_type) :: fft_grid
TYPE(basisSetItem_type) :: fft_smooth
TYPE(basisSetItem_type) :: fft_box
TYPE(reciprocal_lattice_type) :: recipr_latt
CALL qes_init_basisSetItem(fft_grid, "fft_grid", nr1, nr2, nr3, "")
CALL qes_init_basisSetItem(fft_smooth, "fft_smooth", nr1s, nr2s, nr3s, "")
CALL qes_init_basisSetItem(fft_box, "fft_box", nr1b, nr2b, nr3b, "" )
CALL qes_init_reciprocal_lattice(recipr_latt, "reciprocal_lattice", b1, b2, b3)
CALL qes_init_basis_set(obj, "basis_set", GAMMA_ONLY_ISPRESENT=.TRUE., GAMMA_ONLY=gamma_only, &
ECUTWFC=ecutwfc, ECUTRHO_ISPRESENT=.TRUE., ECUTRHO=ecutrho, FFT_GRID=fft_grid, &
FFT_SMOOTH_ISPRESENT=.TRUE., FFT_SMOOTH=fft_smooth, &
FFT_BOX_ISPRESENT=fft_box_ispresent, FFT_BOX=fft_box, NGM=ngm, &
NGMS_ISPRESENT=.TRUE., NGMS=ngms, NPWX=npwx, RECIPROCAL_LATTICE=recipr_latt )
!
CALL qes_reset_basisSetItem(fft_grid)
CALL qes_reset_basisSetItem(fft_smooth)
CALL qes_reset_basisSetItem(fft_box)
CALL qes_reset_reciprocal_lattice(recipr_latt)
!
END SUBROUTINE qexsd_init_basis_set
!
!
!------------------------------------------------------------------------
SUBROUTINE qexsd_init_dft(obj, functional, root_is_output, dft_is_hybrid, nqx1, nqx2, nqx3, ecutfock, &
exx_fraction, screening_parameter, exxdiv_treatment, x_gamma_extrapolation, ecutvcut, &
dft_is_lda_plus_U, lda_plus_U_kind, llmax, noncolin, nspin, nsp, ldim, nat, species, ityp, &
Hubbard_U, Hubbard_J0, Hubbard_alpha, Hubbard_beta, Hubbard_J, starting_ns, Hubbard_ns, &
Hubbard_ns_nc, U_projection_type, dft_is_vdW, vdw_corr, nonlocal_term, london_s6, london_c6, &
london_rcut, xdm_a1, xdm_a2 ,ts_vdw_econv_thr, ts_vdw_isolated, is_hubbard, psd)
!------------------------------------------------------------------------
USE parameters, ONLY: lqmax
USE input_parameters, ONLY: nspinx
IMPLICIT NONE
!
TYPE(dft_type) :: obj
CHARACTER(len=*), INTENT(IN) :: functional, nonlocal_term
LOGICAL, INTENT(IN) :: dft_is_hybrid
LOGICAL, INTENT(IN) :: root_is_output
INTEGER, INTENT(IN) :: nqx1, nqx2, nqx3
REAL(DP), INTENT(IN) :: ecutfock
REAL(DP), INTENT(IN) :: exx_fraction
REAL(DP), INTENT(IN) :: screening_parameter
CHARACTER(len=*), INTENT(IN) :: exxdiv_treatment
LOGICAL, INTENT(IN) :: x_gamma_extrapolation
REAL(DP), INTENT(IN) :: ecutvcut
!
LOGICAL, INTENT(IN) :: dft_is_lda_plus_U, noncolin
INTEGER, INTENT(IN) :: lda_plus_U_kind
INTEGER, INTENT(IN) :: llmax, nspin, nsp, ldim, nat
CHARACTER(len=*), INTENT(IN) :: species(nsp)
INTEGER, INTENT(IN) :: ityp(nat)
REAL(DP), INTENT(IN) :: Hubbard_U(nsp)
REAL(DP), INTENT(IN) :: Hubbard_J0(nsp)
REAL(DP), INTENT(IN) :: Hubbard_alpha(nsp)
REAL(DP), INTENT(IN) :: Hubbard_beta(nsp)
REAL(DP), INTENT(IN) :: Hubbard_J(3,nsp)
REAL(DP), INTENT(IN) :: starting_ns(lqmax,nspinx,nsp)
REAL(DP), INTENT(IN) :: Hubbard_ns(ldim,ldim,nspin,nat)
COMPLEX(DP), INTENT(IN) :: Hubbard_ns_nc(ldim,ldim,nspin,nat)
CHARACTER(len=*), INTENT(IN) :: U_projection_type
LOGICAL,INTENT(IN) :: is_hubbard(nsp)
CHARACTER(LEN=2),INTENT(IN) :: psd(nsp)
!
LOGICAL, INTENT(IN) :: dft_is_vdW, ts_vdw_isolated
CHARACTER(len=*), INTENT(IN) :: vdw_corr
REAL(DP), INTENT(IN) :: london_s6
REAL(DP), INTENT(IN) :: london_rcut
REAL(DP), INTENT(IN) :: xdm_a1
REAL(DP), INTENT(IN) :: xdm_a2
REAL(DP), INTENT(IN) :: london_c6(nsp), ts_vdw_econv_thr
!
INTEGER :: i, is, isp, ind,hubb_l,hubb_n
TYPE(hybrid_type) :: hybrid
TYPE(qpoint_grid_type) :: qpoint_grid
TYPE(dftU_type) :: dftU
TYPE(vdW_type) :: vdW
TYPE(HubbardCommon_type), ALLOCATABLE :: Hubbard_U_(:)
TYPE(HubbardCommon_type), ALLOCATABLE :: Hubbard_J0_(:)
TYPE(HubbardCommon_type), ALLOCATABLE :: Hubbard_alpha_(:)
TYPE(HubbardCommon_type), ALLOCATABLE :: Hubbard_beta_(:)
TYPE(HubbardJ_type), ALLOCATABLE :: Hubbard_J_(:)
TYPE(starting_ns_type), ALLOCATABLE :: starting_ns_(:)
TYPE(Hubbard_ns_type), ALLOCATABLE :: Hubbard_ns_(:)
TYPE(HubbardCommon_type), ALLOCATABLE :: london_c6_obj(:)
REAL(DP), ALLOCATABLE :: Hubb_occ_aux(:,:)
INTEGER :: m1, m2
LOGICAL :: Hubbard_U_ispresent
LOGICAL :: Hubbard_J0_ispresent
LOGICAL :: Hubbard_alpha_ispresent
LOGICAL :: Hubbard_beta_ispresent
LOGICAL :: Hubbard_J_ispresent
LOGICAL :: starting_ns_ispresent
LOGICAL :: Hubbard_ns_ispresent
LOGICAL :: london_c6_ispresent, london_s6_ispresent, london_rvdw_ispresent, ts_vdw_econv_thr_ispresent, &
london_rcut_ispresent, ts_vdw_isolated_ispresent, xdm_a1_ispresent, xdm_a2_ispresent, &
empirical_vdw = .FALSE.
INTEGER :: ndim_london_c6
CHARACTER(10), ALLOCATABLE :: label(:)
CHARACTER :: hubbard_shell
INTEGER,EXTERNAL :: set_hubbard_l,set_hubbard_n
!
!
IF ( dft_is_hybrid ) THEN
!
CALL qes_init_qpoint_grid(qpoint_grid, "qpoint_grid", nqx1, nqx2, nqx3, "")
!
CALL qes_init_hybrid(hybrid, "hybrid", qpoint_grid, ecutfock, exx_fraction, &
screening_parameter, exxdiv_treatment, x_gamma_extrapolation, ecutvcut)
!
CALL qes_reset_qpoint_grid(qpoint_grid)
!
ENDIF
!
IF ( dft_is_lda_plus_U ) THEN
!
ALLOCATE(label(nsp))
DO i = 1, nsp
IF (is_hubbard(i)) THEN
hubb_l=set_hubbard_l(psd(i))
hubb_n=set_hubbard_n(psd(i))
SELECT CASE ( hubb_l )
CASE ( 0)
hubbard_shell='s'
CASE ( 1 )
hubbard_shell='p'
CASE( 2 )
hubbard_shell='d'
CASE( 3 )
hubbard_shell='f'
END SELECT
WRITE (label(i),'(I0,A)') hubb_n,hubbard_shell
ELSE
label(i)="no Hubbard"
END IF
END DO
!
Hubbard_U_ispresent = (SIZE(Hubbard_U)>0)
Hubbard_J0_ispresent = (SIZE(Hubbard_J0)>0)
Hubbard_alpha_ispresent = (SIZE(Hubbard_alpha)>0)
Hubbard_beta_ispresent = (SIZE(Hubbard_beta)>0)
Hubbard_J_ispresent = (SIZE(Hubbard_J)>0)
Hubbard_ns_ispresent = (SIZE(Hubbard_ns)>0)
starting_ns_ispresent = (SIZE(starting_ns)>0)
!
ALLOCATE( Hubbard_U_(nsp) )
ALLOCATE( Hubbard_J0_(nsp) )
ALLOCATE( Hubbard_alpha_(nsp) )
ALLOCATE( Hubbard_beta_(nsp) )
ALLOCATE( Hubbard_J_(nsp) )
!
IF (noncolin ) THEN
ALLOCATE (starting_ns_(nsp))
ALLOCATE (Hubbard_ns_(nat))
ELSE
ALLOCATE( starting_ns_(min(nspin,nspinx)*nsp) )
ALLOCATE( Hubbard_ns_(nspin*nat) )
END IF
!
DO i = 1, nsp
CALL qes_init_HubbardCommon(Hubbard_U_(i),"Hubbard_U",TRIM(species(i)),TRIM(label(i)),Hubbard_U(i))
CALL qes_init_HubbardCommon(Hubbard_J0_(i),"Hubbard_J0",TRIM(species(i)),TRIM(label(i)),Hubbard_J0(i))
CALL qes_init_HubbardCommon(Hubbard_alpha_(i),"Hubbard_alpha",TRIM(species(i)),TRIM(label(i)),&
Hubbard_alpha(i))
CALL qes_init_HubbardCommon(Hubbard_beta_(i),"Hubbard_beta",TRIM(species(i)),TRIM(label(i)),&
Hubbard_beta(i))
CALL qes_init_HubbardJ(Hubbard_J_(i),"Hubbard_J",TRIM(species(i)),TRIM(label(i)),Hubbard_J(1:3,i))
ENDDO
!
ind = 0
IF (starting_ns_ispresent) THEN
IF (noncolin) THEN
DO i = 1, nsp
ind = ind + 1
CALL qes_init_starting_ns(starting_ns_(ind), "starting_ns", TRIM (species(i)),TRIM (label(i)),&
1,2*llmax, starting_ns(1:2*llmax, 1, i))
END DO
ELSE
DO is = 1, MIN(nspin,nspinx)
DO i = 1, nsp
ind = ind+1
CALL qes_init_starting_ns(starting_ns_(ind),"starting_ns",TRIM(species(i)),TRIM(label(i)), &
is, llmax, starting_ns(1:llmax,is,i) )
ENDDO
ENDDO
END IF
END IF
!
ind = 0
IF (noncolin) THEN
ALLOCATE (Hubb_occ_aux(2*ldim,2*ldim))
DO i = 1, nat
Hubb_occ_aux = 0.d0
DO m1 =1, ldim
DO m2 = 1, ldim
Hubb_occ_aux( m1, m2) = SQRT(DCONJG(Hubbard_ns_nc(m1,m2,1,i))*Hubbard_ns_nc(m1,m2,1,i))
Hubb_occ_aux( m1,ldim+m2) = SQRT(DCONJG(Hubbard_ns_nc(m1,m2,2,i))*Hubbard_ns_nc(m1,m2,2,i))
Hubb_occ_aux(ldim+m1, m2) = SQRT(DCONJG(Hubbard_ns_nc(m1,m2,3,i))*Hubbard_ns_nc(m1,m2,3,i))
Hubb_occ_aux(ldim+m1,ldim+m2) = SQRT(DCONJG(Hubbard_ns_nc(m1,m2,4,i))*Hubbard_ns_nc(m1,m2,4,i))
END DO
END DO
CALL qes_init_Hubbard_ns(Hubbard_ns_(i),"Hubbard_ns_mod", TRIM(species(ityp(i))),TRIM(label(ityp(i))), &
1, i, 2*ldim, 2*ldim, Hubb_occ_aux(:,:))
END DO
DEALLOCATE ( Hubb_occ_aux)
ELSE
DO i = 1, nat
DO is = 1, nspin
ind = ind+1
CALL qes_init_Hubbard_ns(Hubbard_ns_(ind),"Hubbard_ns", TRIM(species(ityp(i))),TRIM(label(ityp(i))), &
is, i, ldim, ldim, Hubbard_ns(:,:,is,i) )
ENDDO
ENDDO
END IF
!
! main init
CALL qes_init_dftU(dftU, "dftU", .TRUE., lda_plus_u_kind, &
Hubbard_U_ispresent, SIZE(Hubbard_U_), Hubbard_U_, &
Hubbard_J0_ispresent, SIZE(Hubbard_J0_), Hubbard_J0_, &
Hubbard_alpha_ispresent, SIZE(Hubbard_alpha_), Hubbard_alpha_, &
Hubbard_beta_ispresent, SIZE(Hubbard_beta_), Hubbard_beta_, &
Hubbard_J_ispresent, SIZE(Hubbard_J_), Hubbard_J_, &
starting_ns_ispresent, SIZE(starting_ns_), starting_ns_, &
Hubbard_ns_ispresent, SIZE(Hubbard_ns_), Hubbard_ns_, &
.TRUE., U_projection_type)
!
DO i = 1, nsp
CALL qes_reset_HubbardCommon(Hubbard_U_(i))
CALL qes_reset_HubbardCommon(Hubbard_J0_(i))
CALL qes_reset_HubbardCommon(Hubbard_alpha_(i))
CALL qes_reset_HubbardCommon(Hubbard_beta_(i))
CALL qes_reset_HubbardJ(Hubbard_J_(i))
ENDDO
!
DEALLOCATE(Hubbard_U_)
DEALLOCATE(Hubbard_J0_)
DEALLOCATE(Hubbard_alpha_)
DEALLOCATE(Hubbard_beta_)
DEALLOCATE(Hubbard_J_)
!
DO i = 1, SIZE(starting_ns_)
CALL qes_reset_starting_ns(starting_ns_(i))
ENDDO
DEALLOCATE(starting_ns_)
!
DO i = 1, SIZE(Hubbard_ns_)
CALL qes_reset_Hubbard_ns(Hubbard_ns_(i))
ENDDO
DEALLOCATE(Hubbard_ns_)
!
DEALLOCATE(label)
!
ENDIF
!
SELECT CASE ( TRIM (vdw_corr ))
CASE ( 'grimme-d2', 'Grimme-D2', 'DFT-D', 'dft-d')
empirical_vdw = .TRUE.
london_s6_ispresent = .TRUE.
london_rcut_ispresent = .TRUE.
xdm_a1_ispresent = .TRUE.
xdm_a2_ispresent = .TRUE.
IF ( ANY(london_c6 .GT. 0.d0 )) THEN
london_c6_ispresent = .TRUE.
ndim_london_c6 = 0
DO isp = 1, nsp
IF ( london_c6(isp) .GT. 0.d0 ) THEN
ndim_london_c6 = ndim_london_c6 + 1
END IF
END DO
ALLOCATE (london_c6_obj(ndim_london_c6))
ndim_london_c6 = 0
DO isp = 1, nsp
IF ( london_c6(isp) .GT. 0.d0) THEN
ndim_london_c6 = ndim_london_c6 + 1
CALL qes_init_hubbardcommon(london_c6_obj(ndim_london_c6), "london_c6", TRIM(species(isp)),"",&
london_c6(isp))
END IF
END DO
ELSE
london_c6_ispresent = .FALSE.
ALLOCATE ( london_c6_obj(1))
END IF
ts_vdw_econv_thr_ispresent = .FALSE.
ts_vdw_isolated_ispresent = .FALSE.
CASE ( 'TS', 'ts', 'ts-vdw', 'ts-vdW', 'tkatchenko-scheffler')
empirical_vdw = .TRUE.
london_s6_ispresent = .FALSE.
london_c6_ispresent = .FALSE.
ALLOCATE ( london_c6_obj(1))
london_rcut_ispresent = .FALSE.
xdm_a1_ispresent = .FALSE.
xdm_a2_ispresent = .FALSE.
ts_vdw_econv_thr_ispresent = .TRUE.
ts_vdw_isolated_ispresent = .TRUE.
CASE default
empirical_vdw = .FALSE.
ts_vdw_econv_thr_ispresent = .FALSE.
ts_vdw_isolated_ispresent = .FALSE.
london_s6_ispresent = .FALSE.
london_c6_ispresent = .FALSE.
ALLOCATE (london_c6_obj(1))
london_rcut_ispresent = .FALSE.
xdm_a1_ispresent = .FALSE.
xdm_a2_ispresent = .FALSE.
london_c6_ispresent = .FALSE.
END SELECT
IF ( dft_is_vdW .OR. empirical_vdw ) THEN
!
CALL qes_init_vdW(vdW, "vdW", TRIM(vdw_corr), root_is_output, TRIM(nonlocal_term), london_s6_ispresent, london_s6, &
ts_vdw_econv_thr_ispresent, ts_vdw_econv_thr, ts_vdw_isolated_ispresent, ts_vdw_isolated,&
london_rcut_ispresent, london_rcut, xdm_a1_ispresent, xdm_a1, xdm_a2_ispresent, xdm_a2, &
london_c6_ispresent, ndim_london_c6, london_c6_obj )
!
IF (london_c6_ispresent ) THEN
DO isp=1, ndim_london_c6
CALL qes_reset_hubbardcommon(london_c6_obj(isp))
END DO
END IF
DEALLOCATE ( london_c6_obj)
ENDIF
CALL qes_init_dft(obj, "dft", functional, dft_is_hybrid, hybrid, &
dft_is_lda_plus_U, dftU, (dft_is_vdW .OR. empirical_vdw) , vdW)
!
IF (dft_is_hybrid) CALL qes_reset_hybrid(hybrid)
IF (dft_is_lda_plus_U) CALL qes_reset_dftU(dftU)
IF (dft_is_vdW .OR. empirical_vdw ) CALL qes_reset_vdW(vdW)
!
END SUBROUTINE qexsd_init_dft
!
!
!---------------------------------------------------------------------------------------
SUBROUTINE qexsd_init_magnetization(obj, lsda, noncolin, spinorbit, total_mag, total_mag_nc, &
absolute_mag, do_magnetization)
!------------------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(magnetization_type) :: obj
LOGICAL, INTENT(IN) :: lsda, noncolin, spinorbit
REAL(DP), INTENT(IN) :: total_mag, absolute_mag
REAL(DP), INTENT(IN) :: total_mag_nc(3)
LOGICAL, INTENT(IN) :: do_magnetization
!
CALL qes_init_magnetization(obj, "magnetization", lsda, noncolin, spinorbit, total_mag, absolute_mag, &
do_magnetization)
!
END SUBROUTINE qexsd_init_magnetization
!
!
!---------------------------------------------------------------------------------------
SUBROUTINE qexsd_init_band_structure(obj, lsda, noncolin, lspinorb, nbnd, nelec, n_wfc_at, occupations_are_fixed, &
fermi_energy, two_fermi_energies, ef_updw, et, wg, nks, xk, ngk, wk, &
starting_kpoints, occupation_kind, smearing, wf_collected)
!----------------------------------------------------------------------------------------
IMPLICIT NONE
!
TYPE(band_structure_type) :: obj
CHARACTER(LEN=*), PARAMETER :: TAGNAME="band_structure"
LOGICAL,INTENT(IN) :: lsda, noncolin, lspinorb, occupations_are_fixed
INTEGER,INTENT(IN) :: nbnd, nks, n_wfc_at
REAL(DP),INTENT(IN) :: nelec, fermi_energy
REAL(DP),DIMENSION(:,:),INTENT(IN) :: et, wg, xk
REAL(DP),DIMENSION(:),INTENT(IN) :: wk
INTEGER,DIMENSION(:),INTENT(IN) :: ngk
REAL(DP),DIMENSION(2),INTENT(IN) :: ef_updw
LOGICAL,INTENT(IN) :: two_fermi_energies
TYPE(k_points_IBZ_type),INTENT(IN) :: starting_kpoints
TYPE(occupations_type), INTENT(IN) :: occupation_kind
TYPE(smearing_type),OPTIONAL,INTENT(IN) :: smearing
LOGICAL,INTENT(IN) :: wf_collected
!
LOGICAL :: nbnd_up_ispresent, nbnd_dw_ispresent, &
fermi_energy_ispresent, HOL_ispresent, &
n_wfc_at_ispresent = .TRUE.
INTEGER :: nbnd_up,nbnd_dw
INTEGER :: ndim_ks_energies, nbnd_tot, ik
TYPE(k_point_type) :: kp_obj
TYPE(ks_energies_type),ALLOCATABLE :: ks_objs(:)
TYPE (k_points_IBZ_type) :: starting_k_points_
TYPE ( occupations_type) :: occupations_kind_
REAL(DP),DIMENSION(:),ALLOCATABLE :: eigenvalues, occupations
TYPE (smearing_type) :: smearing_
!
!
ndim_ks_energies=nks
nbnd_tot=nbnd
!
IF ( lsda ) THEN
ndim_ks_energies=ndim_ks_energies/2
nbnd_up=nbnd
nbnd_dw=nbnd
nbnd_tot=nbnd_up+nbnd_dw
nbnd_up_ispresent=.true.
nbnd_dw_ispresent=.true.
ELSE
nbnd_up=0
nbnd_dw=0
nbnd_up_ispresent=.false.
nbnd_dw_ispresent=.false.
END IF
IF (fermi_energy.GT.-1.D6 .AND. ( .NOT. two_fermi_energies ) ) THEN
IF ( occupations_are_fixed ) THEN
fermi_energy_ispresent = .FALSE.
HOL_ispresent = .TRUE.
ELSE
fermi_energy_ispresent = .TRUE.
HOL_ispresent = .FALSE.
END IF