-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathm_paw_ij.F90
2866 lines (2603 loc) · 106 KB
/
m_paw_ij.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
!!****m* ABINIT/m_paw_ij
!! NAME
!! m_paw_ij
!!
!! FUNCTION
!! This module contains the definition of the paw_ij_type structured datatype,
!! as well as related functions and methods.
!! paw_ij_type variables contain various arrays given on (i,j) (partial waves) channels
!! for a given atom.
!!
!! COPYRIGHT
!! Copyright (C) 2013-2022 ABINIT group (MT, FJ)
!! This file is distributed under the terms of the
!! GNU General Public License, see ~abinit/COPYING
!! or http://www.gnu.org/copyleft/gpl.txt .
!!
!! NOTES
!! FOR DEVELOPPERS: in order to preserve the portability of libPAW library,
!! please consult ~abinit/src/??_libpaw/libpaw-coding-rules.txt
!!
!! SOURCE
#include "libpaw.h"
MODULE m_paw_ij
USE_DEFS
USE_MSG_HANDLING
USE_MPI_WRAPPERS
USE_MEMORY_PROFILING
use m_paral_atom, only : get_my_atmtab, free_my_atmtab, get_my_natom
use m_pawtab, only : pawtab_type
use m_paw_io, only : pawio_print_ij
implicit none
private
!!***
!----------------------------------------------------------------------
!!****t* m_paw_ij/paw_ij_type
!! NAME
!! paw_ij_type
!!
!! FUNCTION
!! For PAW, various arrays given on (i,j) (partial waves) channels
!!
!! SOURCE
type,public :: paw_ij_type
!Integer scalars
integer :: cplex_dij
! cplex_dij=1 if dij are real
! cplex_dij=2 if dij are complex (spin-orbit, non-collinear magnetism, magnetic field, ...)
integer :: has_dij=0
! 1 if dij is allocated
! 2 if dij is already computed
integer :: has_dij0=0
! 1 if dij0 is allocated
! 2 if dij0 is already computed
integer :: has_dijexxc=0
! 1 if dijexxc is associated and used, 0 otherwise
! 2 if dijexxc is already computed
integer :: has_dijfock=0
! 1 if dijfock is allocated
! 2 if dijfock is already computed
integer :: has_dijfr=0
! 1 if dijfr is allocated
! 2 if dijfr is already computed
integer :: has_dijhartree=0
! 1 if dijhartree is allocated
! 2 if dijhartree is already computed
integer :: has_dijhat=0
! 1 if dijhat is allocated
! 2 if dijhat is already computed
integer :: has_dijnd=0
! on site term due to nuclear dipole moment
! 1 if dijnd is associated and used, 0 otherwise
! 2 if dijnd is already computed
integer :: has_dijso=0
! 1 if dijso is associated and used, 0 otherwise
! 2 if dijso is already computed
integer :: has_dijU=0
! 1 if dijU is associated and used, 0 otherwise
! 2 if dijU is already computed
integer :: has_dijxc=0
! 1 if dijxc is associated and used, 0 otherwise
! 2 if dijxc is already computed
integer :: has_dijxc_hat=0
! 1 if dijxc_hat is associated and used, 0 otherwise
! 2 if dijxc_hat is already computed
integer :: has_dijxc_val=0
! 1 if dijxc_val is associated and used, 0 otherwise
! 2 if dijxc_val is already computed
integer :: has_exexch_pot=0
! 1 if PAW+(local exact exchange) potential is allocated
integer :: has_pawu_occ=0
! 1 if PAW+U occupations are allocated
integer :: itypat
! itypat=type of the atom
integer :: lmn_size
! Number of (l,m,n) elements for the paw basis
integer :: lmn2_size
! lmn2_size=lmn_size*(lmn_size+1)/2
! where lmn_size is the number of (l,m,n) elements for the paw basis
integer :: ndij
! Number of components of dij
! Usually ndij=nspden, except for nspinor==2 (where ndij=nspinor**2)
integer :: nspden
! Number of spin-density components (may be different from dtset%nspden if spin-orbit)
integer :: nsppol
! Number of independant spin-components
integer :: qphase
! qphase=2 if dij contain a exp(-i.q.r) phase (as in the q<>0 RF case), 1 if not
! (this may change the ij symmetry)
!Real (real(dp)) arrays
real(dp), allocatable :: dij(:,:)
! dij(cplex_dij*qphase*lmn2_size,ndij)
! Dij term (non-local operator)
! May be complex if cplex_dij=2 or qphase=2
! ==== Storage for the 1st dimension ====
! For each klmn=ij:
! When Dij is complex (cplex_dij=2):
! dij(2*ij-1,:) contains the real part
! dij(2*ij ,:) contains the imaginary part
! When a exp(-i.q.r) phase is included (qphase=2):
! dij(1:cplex_dij*lmn2_size,:)
! contains the real part of the phase, i.e. D_ij*cos(q.r)
! dij(cplex_dij*lmn2_size+1:2*cplex_dij*lmn2_size,:)
! contains the imaginary part of the phase, i.e. D_ij*sin(q.r)
! ==== Storage for the 2nd dimension ====
! dij(:,1) contains Dij^up-up
! dij(:,2) contains Dij^dn-dn
! dij(:,3) contains Dij^up-dn (only if nspinor=2)
! dij(:,4) contains Dij^dn-up (only if nspinor=2)
real(dp), allocatable :: dij0(:)
! dij0(lmn2_size)
! Atomic part of Dij (read from PAW dataset)
! Same storage as Dij (see above); always real, spin independent
real(dp), allocatable :: dijexxc(:,:)
! dijexxc(cplex_dij*lmn2_size,ndij)
! On-site matrix elements of the Fock operator (Local Exact exchange implementation)
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: dijfock(:,:)
! dijfock(cplex_dij*lmn2_size,ndij)
! Dij_fock term
! Contains all contributions to Dij from Fock exchange
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: dijfr(:,:)
! dijhat(cplex_dij*qphase*lmn2_size,ndij)
! For response function calculation only
! RF Frozen part of Dij (depends on q vector but not on 1st-order wave function)
! Same storage as Dij (see above)
real(dp), allocatable :: dijhartree(:)
! dijhartree(qphase*lmn2_size)
! Dij_hartree term; contains all contributions to Dij from hartree
! Warning: dimensioned only by qphase (exp(-iqr)), not cplex_dij
! Same storage as Dij (see above); spin independent
real(dp), allocatable :: dijhat(:,:)
! dijhat(cplex_dij*qphase*lmn2_size,ndij)
! Dij_hat term (non-local operator) i.e \sum_LM \int_FFT Q_{ij}^{LM} vtrial
! Same storage as Dij (see above)
! Same storage as Dij (see above)
real(dp), allocatable :: dijnd(:,:)
! dijnd(cplex_dij*lmn2_size,ndij)
! On-site matrix elements of -\frac{1}{c}\mu\cdot L/r^3
! Same storage as Dij (see above)
real(dp), allocatable :: dijso(:,:)
! dijso(cplex_dij*qphase*lmn2_size,ndij)
! On-site matrix elements of L.S i.e <phi_i|L.S|phi_j>
! Same storage as Dij (see above)
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: dijU(:,:)
! dijU(cplex_dij*qphase*lmn2_size,ndij)
! On-site matrix elements of the U part of the PAW Hamiltonian.
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: dijxc(:,:)
! dijxc(cplex_dij*qphase*lmn2_size,ndij)
! On-site matrix elements of vxc i.e
! <phi_i|vxc[n1+nc]|phi_j> - <tphi_i|vxc(tn1+nhat+tnc]|tphi_j>
! Same storage as Dij (see above)
real(dp), allocatable :: dijxc_hat(:,:)
! dijxc_hat(cplex_dij*lmn2_size,ndij)
! Dij_hat term i.e \sum_LM \int_FFT Q_{ij}^{LM} Vxc
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: dijxc_val(:,:)
! dijxc_val(cplex_dij*lmn2_size,ndij)
! Onsite matrix elements of valence-only vxc i.e
! <phi_i|vxc[n1]|phi_j> - <tphi_i|vxc(tn1+nhat]|tphi_j>
! Same storage as Dij (see above); not available for RF (i.e. qphase=2)
real(dp), allocatable :: noccmmp(:,:,:,:)
! noccmmp(cplex_dij,2*lpawu+1,2*lpawu+1,nocc_nspden)
! cplex_dij=1 if collinear
! cplex_dij=2 if spin orbit is used
! cplex_dij=2 is used if non-collinear (for coherence, it is not necessary in this case, however)
! gives occupation matrix for lda+u (computed in setnoccmmp)
! Stored as: noccmmp(:,:,1)= n^{up,up}_{m,mp}
! noccmmp(:,:,2)= n^{dn,dn}_{m,mp}
! noccmmp(:,:,3)= n^{up,dn}_{m,mp}
! noccmmp(:,:,4)= n^{dn,up}_{m,mp}
! noccmmp(m,mp,:) is computed from rhoij(klmn) with m=klmntomn(2)>mp=klmntomn(1)
real(dp), allocatable :: nocctot(:)
! nocctot(ndij)
! gives trace of occupation matrix for lda+u (computed in pawdenpot)
! for each value of ispden (1 or 2)
real(dp), allocatable :: vpawx(:,:,:)
! vpawx(1,2*lexexch+1,nspden)
! exact exchange potential
end type paw_ij_type
!public procedures.
public :: paw_ij_init ! Creation method
public :: paw_ij_free ! Free memory
public :: paw_ij_nullify
public :: paw_ij_copy ! Copy object
public :: paw_ij_print ! Printout of the object
public :: paw_ij_gather ! MPI gather
public :: paw_ij_redistribute ! MPI redistribute
public :: paw_ij_reset_flags ! Resent the internal flags.
!private procedures.
private :: paw_ij_isendreceive_getbuffer
private :: paw_ij_isendreceive_fillbuffer
!!***
CONTAINS
!===========================================================
!!***
!----------------------------------------------------------------------
!!****f* m_paw_ij/paw_ij_init
!! NAME
!! paw_ij_init
!!
!! FUNCTION
!! Initialize a Paw_ij data type.
!!
!! INPUTS
!! cplex=1 if no phase is applied (GS), 2 if a exp(-iqr) phase is applied (Response Function at q<>0)
!! natom=Number of atoms.
!! ntypat=Number of types of atoms in cell.
!! nspinor=number of spinor components
!! nsppol=Number of independent spin polarizations.
!! nspden=Number of spin-density components
!! pawspnorb=1 if spin-orbit coupling is activated
!! typat(natom)=Type of each atom
!! Pawtab(ntypat)<type(pawtab_type)>=PAW tabulated starting data
!!
!! OPTIONAL INPUTS
!! has_dij=1 to allocate Paw_ij%dij, 0 otherwise (default)
!! has_dij0=1 to allocate Paw_ij%dij0, 0 otherwise (default)
!! has_dijfr=1 to allocate Paw_ij%dijfr, 0 otherwise (default)
!! has_dijhat=1 to allocate Paw_ij%dijhat, 0 otherwise (default)
!! has_dijxc=1 to allocate Paw_ij%dijxc, 0 otherwise (default)
!! has_dijxc_hat=1 to allocate Paw_ij%dijxc_hat, 0 otherwise (default)
!! has_dijxc_val=1 to allocate Paw_ij%dijxc_val, 0 otherwise (default)
!! has_dijhartree=1 to allocate Paw_ij%dijhartree, 0 otherwise (default)
!! has_dijfock=1 to allocate Paw_ij%dijfock, 0 otherwise (default)
!! has_dijnd=1 to allocate Paw_ij%dijnd, used only if some nucdipmom /= 0; otherwise 0 (default)
!! has_dijso=1 to allocate Paw_ij%dijso, used only if pawspnorb>0. 0 otherwise (default)
!! has_dijU=1 to allocate Paw_ij%dijU, used only if Pawtab(itypat)%usepawu/=0. 0 otherwise (default).
!! has_dijexxc=to allocate Paw_ij%dijxx, 0 otherwise (default)
!! has_exexch_pot=1 to allocate potential used in PAW+(local exact exchange) formalism, 0 otherwise (default)
!! has_pawu_occ=1 to allocate occupations used in PAW+U formalism, 0 otherwise (default)
!! nucdipmom(3,natom)= (optional) array of nuclear dipole moments at atomic sites
!! mpi_atmtab(:)=indexes of the atoms treated by current proc
!! comm_atom=MPI communicator over atoms
!!
!! OUTPUT
!! Paw_ij(natom)<type(paw_ij_type)>=data structure containing PAW arrays given on (i,j) channels.
!! In output all the basic dimensions are defined and the arrays are allocated
!! according to the input variables.
!!
!! SOURCE
subroutine paw_ij_init(Paw_ij,cplex,nspinor,nsppol,nspden,pawspnorb,natom,ntypat,typat,Pawtab,&
& has_dij,has_dij0,has_dijfock,has_dijfr,has_dijhartree,has_dijhat,& ! Optional
& has_dijxc,has_dijxc_hat,has_dijxc_val,has_dijnd,has_dijso,has_dijU,has_dijexxc,& ! Optional
& has_exexch_pot,has_pawu_occ,nucdipmom,& ! Optional
& mpi_atmtab,comm_atom) ! optional arguments (parallelism)
!Arguments ------------------------------------
!scalars
integer,intent(in) :: cplex,nspinor,nspden,nsppol,natom,ntypat,pawspnorb
integer,optional,intent(in) :: has_dij,has_dij0,has_dijfr,has_dijhat,has_dijxc,has_dijxc_hat,has_dijxc_val
integer,optional,intent(in) :: has_dijnd,has_dijso,has_dijhartree,has_dijfock,has_dijU,has_dijexxc
integer,optional,intent(in) :: has_exexch_pot,has_pawu_occ
integer,optional,intent(in) :: comm_atom
!arrays
integer,intent(in) :: typat(natom)
integer,optional,target,intent(in) :: mpi_atmtab(:)
real(dp),optional,intent(in) :: nucdipmom(3,natom)
type(Paw_ij_type),intent(inout) :: Paw_ij(:)
type(Pawtab_type),intent(in) :: Pawtab(ntypat)
!Local variables-------------------------------
!scalars
integer :: cplex_dij,iat,iat_tot,itypat,lmn2_size,my_comm_atom,my_natom,ndij,qphase
logical :: my_atmtab_allocated,paral_atom,with_nucdipmom
!arrays
integer,pointer :: my_atmtab(:)
! *************************************************************************
!@Paw_ij_type
with_nucdipmom=.false.;if (present(nucdipmom)) with_nucdipmom=any(abs(nucdipmom)>tol8)
!Set up parallelism over atoms
my_natom=size(paw_ij);if (my_natom==0) return
paral_atom=(present(comm_atom).and.(my_natom/=natom))
nullify(my_atmtab);if (present(mpi_atmtab)) my_atmtab => mpi_atmtab
my_comm_atom=xpaw_mpi_comm_self;if (present(comm_atom)) my_comm_atom=comm_atom
call get_my_atmtab(my_comm_atom,my_atmtab,my_atmtab_allocated,paral_atom,natom,my_natom_ref=my_natom)
do iat=1,my_natom
iat_tot=iat;if (paral_atom) iat_tot=my_atmtab(iat)
itypat=typat(iat_tot)
cplex_dij=1;if ((nspinor==2).or.(with_nucdipmom)) cplex_dij=2
qphase=cplex
lmn2_size =Pawtab(itypat)%lmn2_size
Paw_ij(iat)%qphase =qphase
Paw_ij(iat)%cplex_dij =cplex_dij
Paw_ij(iat)%itypat =itypat
Paw_ij(iat)%nspden =nspden
Paw_ij(iat)%nsppol =nsppol
Paw_ij(iat)%lmn_size =Pawtab(itypat)%lmn_size
Paw_ij(iat)%lmn2_size =lmn2_size
Paw_ij(iat)%ndij =MAX(nspinor**2,nspden)
ndij=Paw_ij(iat)%ndij
! ==================================
! === Allocations (all optional) ===
! ==================================
! === Allocation for total Dij ===
Paw_ij(iat)%has_dij=0
if (PRESENT(has_dij)) then
if (has_dij/=0) then
Paw_ij(iat)%has_dij=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dij,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dij(:,:)=zero
end if
end if
! === Allocation for atomic Dij ===
Paw_ij(iat)%has_dij0=0
if (PRESENT(has_dij0)) then
if (has_dij0/=0) then
Paw_ij(iat)%has_dij0=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dij0,(lmn2_size))
Paw_ij(iat)%dij0(:)=zero
end if
end if
! === Allocation for Dij local exact exchange ===
Paw_ij(iat)%has_dijexxc=0
if (PRESENT(has_dijexxc)) then
if (has_dijexxc/=0.and.Pawtab(itypat)%useexexch/=0) then
Paw_ij(iat)%has_dijexxc=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijexxc,(cplex_dij*lmn2_size,ndij))
Paw_ij(iat)%dijexxc(:,:)=zero
end if
end if
! === Allocation for Dij_Fock ===
Paw_ij(iat)%has_dijfock=0
if (PRESENT(has_dijfock)) then
if (has_dijfock/=0) then
Paw_ij(iat)%has_dijfock=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijfock,(cplex_dij*lmn2_size,ndij))
Paw_ij(iat)%dijfock(:,:)=zero
end if
end if
! === Allocation for frozen part of 1st-order Dij ===
Paw_ij(iat)%has_dijfr=0
if (PRESENT(has_dijfr)) then
if (has_dijfr/=0) then
Paw_ij(iat)%has_dijfr=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijfr,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dijfr(:,:)=zero
end if
end if
! === Allocation for Dij_Hartree ===
Paw_ij(iat)%has_dijhartree=0
if (PRESENT(has_dijhartree)) then
if (has_dijhartree/=0) then
Paw_ij(iat)%has_dijhartree=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijhartree,(qphase*lmn2_size))
Paw_ij(iat)%dijhartree(:)=zero
end if
end if
! === Allocation for Dij_hat ===
Paw_ij(iat)%has_dijhat=0
if (PRESENT(has_dijhat)) then
if (has_dijhat/=0) then
Paw_ij(iat)%has_dijhat=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijhat,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dijhat(:,:)=zero
end if
end if
! === Allocation for Dij nuclear dipole moment ===
Paw_ij(iat)%has_dijnd=0
if (PRESENT(has_dijnd)) then
if (has_dijnd/=0.and.with_nucdipmom) then
Paw_ij(iat)%has_dijnd=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijnd,(cplex_dij*lmn2_size,ndij))
Paw_ij(iat)%dijnd(:,:)=zero
end if
end if
! === Allocation for Dij_SO ===
Paw_ij(iat)%has_dijso=0
if (PRESENT(has_dijso)) then
if (has_dijso/=0.and.pawspnorb>0) then
Paw_ij(iat)%has_dijso=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijso,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dijso(:,:)=zero
end if
end if
! === Allocation for Dij_U_val ===
Paw_ij(iat)%has_dijU=0
if (PRESENT(has_dijU)) then
if (has_dijU/=0) then
Paw_ij(iat)%has_dijU=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijU,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dijU(:,:)=zero
end if
end if
! === Allocation for total Dij_XC ===
Paw_ij(iat)%has_dijxc=0
if (PRESENT(has_dijxc)) then
if (has_dijxc/=0) then
Paw_ij(iat)%has_dijxc=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijxc,(cplex_dij*qphase*lmn2_size,ndij))
Paw_ij(iat)%dijxc(:,:)=zero
end if
end if
! === Allocation for total Dij_XC_hat ===
Paw_ij(iat)%has_dijxc_hat=0
if (PRESENT(has_dijxc_hat)) then
if (has_dijxc_hat/=0) then
Paw_ij(iat)%has_dijxc_hat=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijxc_hat,(cplex_dij*lmn2_size,ndij))
Paw_ij(iat)%dijxc_hat(:,:)=zero
end if
end if
! === Allocation for total Dij_XC_val ===
Paw_ij(iat)%has_dijxc_val=0
if (PRESENT(has_dijxc_val)) then
if (has_dijxc_val/=0) then
Paw_ij(iat)%has_dijxc_val=1
LIBPAW_ALLOCATE(Paw_ij(iat)%dijxc_val,(cplex_dij*lmn2_size,ndij))
Paw_ij(iat)%dijxc_val(:,:)=zero
end if
end if
! === Allocation for PAW+U occupations ===
Paw_ij(iat)%has_pawu_occ=0
if (PRESENT(has_pawu_occ)) then
if (has_pawu_occ/=0.and.Pawtab(itypat)%usepawu/=0) then
Paw_ij(iat)%has_pawu_occ=1
LIBPAW_ALLOCATE(Paw_ij(iat)%noccmmp,(cplex_dij,2*Pawtab(itypat)%lpawu+1,2*Pawtab(itypat)%lpawu+1,ndij))
LIBPAW_ALLOCATE(Paw_ij(iat)%nocctot,(ndij))
Paw_ij(iat)%noccmmp(:,:,:,:)=zero
Paw_ij(iat)%nocctot(:)=zero
end if
end if
! === Allocation for PAW+LEXX potential ===
Paw_ij(iat)%has_exexch_pot=0
if (PRESENT(has_exexch_pot)) then
if (has_exexch_pot/=0.and.Pawtab(itypat)%useexexch/=0) then
Paw_ij(iat)%has_exexch_pot=1
! TODO solve issue with first dimension
LIBPAW_ALLOCATE(Paw_ij(iat)%vpawx,(1,lmn2_size,nspden))
Paw_ij(iat)%vpawx(:,:,:)=zero
end if
end if
end do
!Destroy atom table used for parallelism
call free_my_atmtab(my_atmtab,my_atmtab_allocated)
end subroutine paw_ij_init
!!***
!----------------------------------------------------------------------
!!****f* m_paw_ij/paw_ij_free
!! NAME
!! paw_ij_free
!!
!! FUNCTION
!! Deallocate pointers and nullify flags in a paw_ij structure
!!
!! SIDE EFFECTS
!! paw_ij(:)<type(paw_ij_type)>=paw arrays given on (i,j) channels
!!
!! SOURCE
subroutine paw_ij_free(Paw_ij)
!Arguments ------------------------------------
!arrays
type(Paw_ij_type),intent(inout) :: Paw_ij(:)
!Local variables-------------------------------
integer :: iat,natom
! *************************************************************************
!@Paw_ij_type
natom=SIZE(Paw_ij);if (natom==0) return
do iat=1,natom
if (allocated(Paw_ij(iat)%dij )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dij)
end if
if (allocated(Paw_ij(iat)%dij0 )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dij0)
end if
if (allocated(Paw_ij(iat)%dijexxc )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijexxc)
end if
if (allocated(Paw_ij(iat)%dijfock )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijfock)
end if
if (allocated(Paw_ij(iat)%dijfr )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijfr)
end if
if (allocated(Paw_ij(iat)%dijhartree)) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijhartree)
end if
if (allocated(Paw_ij(iat)%dijhat )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijhat)
end if
if (allocated(Paw_ij(iat)%dijnd )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijnd)
end if
if (allocated(Paw_ij(iat)%dijU )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijU)
end if
if (allocated(Paw_ij(iat)%dijso )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijso)
end if
if (allocated(Paw_ij(iat)%dijxc )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijxc)
end if
if (allocated(Paw_ij(iat)%dijxc_hat )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijxc_hat)
end if
if (allocated(Paw_ij(iat)%dijxc_val )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%dijxc_val)
end if
if (allocated(Paw_ij(iat)%noccmmp )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%noccmmp)
end if
if (allocated(Paw_ij(iat)%nocctot )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%nocctot)
end if
if (allocated(Paw_ij(iat)%vpawx )) then
LIBPAW_DEALLOCATE(Paw_ij(iat)%vpawx)
end if
! === Reset all has_* flags ===
Paw_ij(iat)%has_dij =0
Paw_ij(iat)%has_dij0 =0
Paw_ij(iat)%has_dijexxc =0
Paw_ij(iat)%has_dijfock =0
Paw_ij(iat)%has_dijfr =0
Paw_ij(iat)%has_dijhartree=0
Paw_ij(iat)%has_dijhat =0
Paw_ij(iat)%has_dijnd =0
Paw_ij(iat)%has_dijso =0
Paw_ij(iat)%has_dijU =0
Paw_ij(iat)%has_dijxc =0
Paw_ij(iat)%has_dijxc_hat =0
Paw_ij(iat)%has_dijxc_val =0
Paw_ij(iat)%has_exexch_pot=0
Paw_ij(iat)%has_pawu_occ =0
end do
!call paw_ij_nullify(Paw_ij)
end subroutine paw_ij_free
!!***
!----------------------------------------------------------------------
!!****f* m_paw_ij/paw_ij_nullify
!! NAME
!! paw_ij_nullify
!!
!! FUNCTION
!! Reset all flags in a paw_ij structure
!!
!! SIDE EFFECTS
!! Paw_ij(:)<type(paw_ij_type)>=PAW arrays given on (i,j) channels.
!!
!! SOURCE
subroutine paw_ij_nullify(Paw_ij)
!Arguments ------------------------------------
!arrays
type(Paw_ij_type),intent(inout) :: Paw_ij(:)
!Local variables-------------------------------
integer :: iat,natom
! *************************************************************************
!@Paw_ij_type
! MGPAW: This one could be removed/renamed,
! variables can be initialized in the datatype declaration
! Do we need to expose this in the public API?
natom=SIZE(Paw_ij(:));if (natom==0) return
! Set all has_* flags to zero.
do iat=1,natom
! === Set all has_* flags to zero ===
Paw_ij(iat)%has_dij =0
Paw_ij(iat)%has_dij0 =0
Paw_ij(iat)%has_dijexxc =0
Paw_ij(iat)%has_dijfock =0
Paw_ij(iat)%has_dijfr =0
Paw_ij(iat)%has_dijhartree=0
Paw_ij(iat)%has_dijhat =0
Paw_ij(iat)%has_dijnd =0
Paw_ij(iat)%has_dijso =0
Paw_ij(iat)%has_dijU =0
Paw_ij(iat)%has_dijxc =0
Paw_ij(iat)%has_dijxc_hat =0
Paw_ij(iat)%has_dijxc_val =0
Paw_ij(iat)%has_exexch_pot=0
Paw_ij(iat)%has_pawu_occ =0
end do !iat
end subroutine paw_ij_nullify
!!***
!----------------------------------------------------------------------
!!****f* m_paw_ij/paw_ij_copy
!! NAME
!! paw_ij_copy
!!
!! FUNCTION
!! Copy one paw_ij datastructure into another
!! Can take into accound changes of dimensions
!! Can copy a shared paw_ij into distributed ones (when parallelism is activated)
!!
!! INPUTS
!! mpi_atmtab(:)=--optional-- indexes of the atoms treated by current proc
!! comm_atom=--optional-- MPI communicator over atoms
!! paw_ij_in(:)<type(paw_ij_type)>= input paw_ij datastructure
!!
!! SIDE EFFECTS
!! paw_ij_cpy(:)<type(paw_ij_type)>= output paw_ij datastructure
!!
!! NOTES
!! paw_ij_cpy must have been allocated in the calling function.
!!
!! SOURCE
subroutine paw_ij_copy(paw_ij_in,paw_ij_cpy, &
& mpi_atmtab,comm_atom) ! optional arguments (parallelism)
!Arguments ------------------------------------
!scalars
integer,optional,intent(in) :: comm_atom
!arrays
integer,optional,target,intent(in) :: mpi_atmtab(:)
type(paw_ij_type),intent(in) :: paw_ij_in(:)
type(paw_ij_type),intent(inout),target :: paw_ij_cpy(:)
!Local variables-------------------------------
!scalars
integer :: ij,ij1,my_comm_atom,my_paw_ij,npaw_ij_in,npaw_ij_max,npaw_ij_out,paral_case,sz1,sz2,sz3,sz4
logical :: my_atmtab_allocated,paral_atom
character(len=500) :: msg
!arrays
integer,pointer :: my_atmtab(:)
type(paw_ij_type),pointer :: paw_ij_out(:)
! *************************************************************************
!@Paw_ij_type
!Retrieve sizes
npaw_ij_in=size(paw_ij_in);npaw_ij_out=size(paw_ij_cpy)
!Set up parallelism over atoms
paral_atom=(present(comm_atom));if (paral_atom) paral_atom=(xpaw_mpi_comm_size(comm_atom)>1)
nullify(my_atmtab);if (present(mpi_atmtab)) my_atmtab => mpi_atmtab
my_comm_atom=xpaw_mpi_comm_self;if (present(comm_atom)) my_comm_atom=comm_atom
my_atmtab_allocated=.false.
!Determine in which case we are (parallelism, ...)
!No parallelism: a single copy operation
paral_case=0;npaw_ij_max=npaw_ij_in
paw_ij_out => paw_ij_cpy
if (paral_atom) then
if (npaw_ij_out<npaw_ij_in) then ! Parallelism: the copy operation is a scatter
call get_my_natom(my_comm_atom,my_paw_ij,npaw_ij_in)
if (my_paw_ij==npaw_ij_out) then
call get_my_atmtab(my_comm_atom,my_atmtab,my_atmtab_allocated,paral_atom,npaw_ij_in)
paral_case=1;npaw_ij_max=npaw_ij_out
paw_ij_out => paw_ij_cpy
else
msg=' npaw_ij_out should be equal to my_paw_ij !'
LIBPAW_BUG(msg)
end if
else ! Parallelism: the copy operation is a gather
call get_my_natom(my_comm_atom,my_paw_ij,npaw_ij_out)
if (my_paw_ij==npaw_ij_in) then
paral_case=2;npaw_ij_max=npaw_ij_in
else
msg=' npaw_ij_in should be equal to my_paw_ij !'
LIBPAW_BUG(msg)
end if
end if
end if
!First case: a simple copy or a scatter
if (npaw_ij_max>0.and.((paral_case==0).or.(paral_case==1))) then
call paw_ij_nullify(paw_ij_out)
! Loop on paw_ij components
do ij1=1,npaw_ij_max
ij=ij1; if (paral_case==1) ij=my_atmtab(ij1)
paw_ij_out(ij1)%qphase=paw_ij_in(ij)%qphase
paw_ij_out(ij1)%cplex_dij=paw_ij_in(ij)%cplex_dij
paw_ij_out(ij1)%has_dij=paw_ij_in(ij)%has_dij
paw_ij_out(ij1)%has_dij0=paw_ij_in(ij)%has_dij0
paw_ij_out(ij1)%has_dijexxc=paw_ij_in(ij)%has_dijexxc
paw_ij_out(ij1)%has_dijfock=paw_ij_in(ij)%has_dijfock
paw_ij_out(ij1)%has_dijfr=paw_ij_in(ij)%has_dijfr
paw_ij_out(ij1)%has_dijhartree=paw_ij_in(ij)%has_dijhartree
paw_ij_out(ij1)%has_dijhat=paw_ij_in(ij)%has_dijhat
paw_ij_out(ij1)%has_dijnd=paw_ij_in(ij)%has_dijnd
paw_ij_out(ij1)%has_dijso=paw_ij_in(ij)%has_dijso
paw_ij_out(ij1)%has_dijU=paw_ij_in(ij)%has_dijU
paw_ij_out(ij1)%has_dijxc=paw_ij_in(ij)%has_dijxc
paw_ij_out(ij1)%has_dijxc_hat=paw_ij_in(ij)%has_dijxc_hat
paw_ij_out(ij1)%has_dijxc_val=paw_ij_in(ij)%has_dijxc_val
paw_ij_out(ij1)%has_exexch_pot=paw_ij_in(ij)%has_exexch_pot
paw_ij_out(ij1)%has_pawu_occ=paw_ij_in(ij)%has_pawu_occ
paw_ij_out(ij1)%itypat=paw_ij_in(ij)%itypat
paw_ij_out(ij1)%lmn_size=paw_ij_in(ij)%lmn_size
paw_ij_out(ij1)%lmn2_size=paw_ij_in(ij)%lmn2_size
paw_ij_out(ij1)%ndij=paw_ij_in(ij)%ndij
paw_ij_out(ij1)%nspden=paw_ij_in(ij)%nspden
paw_ij_out(ij1)%nsppol=paw_ij_in(ij)%nsppol
if (paw_ij_in(ij)%has_dij>=1) then
sz1=size(paw_ij_in(ij)%dij,1);sz2=size(paw_ij_in(ij)%dij,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dij,(sz1,sz2))
if (paw_ij_in(ij)%has_dij==2) &
& paw_ij_out(ij1)%dij(:,:)=paw_ij_in(ij)%dij(:,:)
end if
if (paw_ij_in(ij)%has_dij0>=1) then
sz1=size(paw_ij_in(ij)%dij0,1)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dij0,(sz1))
if (paw_ij_in(ij)%has_dij0 ==2) &
& paw_ij_out(ij1)%dij0(:)=paw_ij_in(ij)%dij0(:)
end if
if (paw_ij_in(ij)%has_dijexxc>=1) then
sz1=size(paw_ij_in(ij)%dijexxc,1);sz2=size(paw_ij_in(ij)%dijexxc,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijexxc,(sz1,sz2))
if (paw_ij_in(ij)%has_dijexxc==2) &
& paw_ij_out(ij1)%dijexxc(:,:)=paw_ij_in(ij)%dijexxc(:,:)
end if
if (paw_ij_in(ij)%has_dijfock>=1) then
sz1=size(paw_ij_in(ij)%dijfock,1);sz2=size(paw_ij_in(ij)%dijfock,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijfock,(sz1,sz2))
if (paw_ij_in(ij)%has_dijfock==2) &
& paw_ij_out(ij1)%dijfock(:,:)=paw_ij_in(ij)%dijfock(:,:)
end if
if (paw_ij_in(ij)%has_dijfr>=1) then
sz1=size(paw_ij_in(ij)%dijfr,1);sz2=size(paw_ij_in(ij)%dijfr,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijfr,(sz1,sz2))
if (paw_ij_in(ij)%has_dijfr==2) &
& paw_ij_out(ij1)%dijfr(:,:)=paw_ij_in(ij)%dijfr(:,:)
end if
if (paw_ij_in(ij)%has_dijhartree>=1) then
sz1=size(paw_ij_in(ij)%dijhartree,1)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijhartree,(sz1))
if (paw_ij_in(ij)%has_dijhartree==2) &
& paw_ij_out(ij1)%dijhartree(:)=paw_ij_in(ij)%dijhartree(:)
end if
if (paw_ij_in(ij)%has_dijhat>=1) then
sz1=size(paw_ij_in(ij)%dijhat,1);sz2=size(paw_ij_in(ij)%dijhat,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijhat,(sz1,sz2))
if (paw_ij_in(ij)%has_dijhat==2) &
& paw_ij_out(ij1)%dijhat(:,:)=paw_ij_in(ij)%dijhat(:,:)
end if
if (paw_ij_in(ij)%has_dijnd>=1) then
sz1=size(paw_ij_in(ij)%dijnd,1);sz2=size(paw_ij_in(ij)%dijnd,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijnd,(sz1,sz2))
if (paw_ij_in(ij)%has_dijnd==2) &
& paw_ij_out(ij1)%dijnd(:,:)=paw_ij_in(ij)%dijnd(:,:)
end if
if (paw_ij_in(ij)%has_dijU>=1) then
sz1=size(paw_ij_in(ij)%dijU,1);sz2=size(paw_ij_in(ij)%dijU,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijU,(sz1,sz2))
if (paw_ij_in(ij)%has_dijU==2) &
& paw_ij_out(ij1)%dijU(:,:)=paw_ij_in(ij)%dijU(:,:)
end if
if (paw_ij_in(ij)%has_dijso>=1) then
sz1=size(paw_ij_in(ij)%dijso,1);sz2=size(paw_ij_in(ij)%dijso,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijso,(sz1,sz2))
if (paw_ij_in(ij)%has_dijso==2) &
& paw_ij_out(ij1)%dijso(:,:)=paw_ij_in(ij)%dijso(:,:)
end if
if (paw_ij_in(ij)%has_dijxc>=1) then
sz1=size(paw_ij_in(ij)%dijxc,1);sz2=size(paw_ij_in(ij)%dijxc,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijxc,(sz1,sz2))
if (paw_ij_in(ij)%has_dijxc==2) &
& paw_ij_out(ij1)%dijxc(:,:)=paw_ij_in(ij)%dijxc(:,:)
end if
if (paw_ij_in(ij)%has_dijxc_hat>=1) then
sz1=size(paw_ij_in(ij)%dijxc_hat,1);sz2=size(paw_ij_in(ij)%dijxc_hat,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijxc_hat,(sz1,sz2))
if (paw_ij_in(ij)%has_dijxc_hat==2) &
& paw_ij_out(ij1)%dijxc_hat(:,:)=paw_ij_in(ij)%dijxc_hat(:,:)
end if
if (paw_ij_in(ij)%has_dijxc_val>=1) then
sz1=size(paw_ij_in(ij)%dijxc_val,1);sz2=size(paw_ij_in(ij)%dijxc_val,2)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%dijxc_val,(sz1,sz2))
if (paw_ij_in(ij)%has_dijxc_val==2) &
& paw_ij_out(ij1)%dijxc_val(:,:)=paw_ij_in(ij)%dijxc_val(:,:)
end if
if (paw_ij_in(ij)%has_pawu_occ>=1) then
sz1=size(paw_ij_in(ij)%noccmmp,1);sz2=size(paw_ij_in(ij)%noccmmp,2)
sz3=size(paw_ij_in(ij)%noccmmp,3);sz4=size(paw_ij_in(ij)%noccmmp,4)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%noccmmp,(sz1,sz2,sz3,sz4))
sz1=size(paw_ij_in(ij)%nocctot,1)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%nocctot,(sz1))
if (paw_ij_in(ij)%has_pawu_occ==2) then
paw_ij_out(ij1)%noccmmp(:,:,:,:)=paw_ij_in(ij)%noccmmp(:,:,:,:)
paw_ij_out(ij1)%nocctot(:)=paw_ij_in(ij)%nocctot(:)
end if
end if
if (paw_ij_in(ij)%has_exexch_pot >= 1) then
sz1=size(paw_ij_in(ij)%vpawx,1);sz2=size(paw_ij_in(ij)%vpawx,2)
sz3=size(paw_ij_in(ij)%vpawx,3)
LIBPAW_ALLOCATE(paw_ij_out(ij1)%vpawx,(sz1,sz2,sz3))
if (paw_ij_in(ij)%has_exexch_pot==2) &
& paw_ij_out(ij1)%vpawx(:,:,:)=paw_ij_in(ij)%vpawx(:,:,:)
end if
end do
end if
!Second case: a gather
if (paral_case==2) then
call paw_ij_gather(paw_ij_in,paw_ij_cpy,-1,my_comm_atom)
end if
!Destroy atom table used for parallelism
call free_my_atmtab(my_atmtab,my_atmtab_allocated)
end subroutine paw_ij_copy
!!***
!----------------------------------------------------------------------
!!****f* m_paw_ij/paw_ij_print
!! NAME
!! paw_ij_print
!!
!! FUNCTION
!! Print out the content of a paw_ij datastructure (Dij only)
!!
!! INPUTS
!! [enunit]=governs the units to be used for the output of total Dij (0:Ha, 1:Ha+eV)
!! [ipert]=only for DFPT: index of the perturbation (0 for ground state)
!! [unit]=the unit number for output
!! [pawprtvol]=verbosity level
!! [pawspnorb]=1 if spin-orbit coupling is activated
!! [mode_paral]=either "COLL" or "PERS"
!! [mpi_atmtab(:)]=indexes of the atoms treated by current proc (can be computed here)
!! [comm_atom]=MPI communicator over atoms (needed if parallelism over atoms is activated)
!! [natom]=total number of atom (needed if parallelism over atoms is activated)
!! if Paw_ij is distributed, natom is different from size(Paw_ij).
!!
!! OUTPUT
!! (Only writing)
!!
!! NOTES
!!
!! SOURCE
subroutine paw_ij_print(Paw_ij,unit,pawprtvol,pawspnorb,mode_paral,enunit,ipert, &
& mpi_atmtab,comm_atom,natom)
!Arguments ------------------------------------
!scalars
integer,optional,intent(in) :: enunit,ipert
integer,optional,intent(in) :: comm_atom,natom
integer,optional,intent(in) :: pawprtvol,pawspnorb
integer,optional,intent(in) :: unit
character(len=4),optional,intent(in) :: mode_paral
!arrays
integer,optional,target,intent(in) :: mpi_atmtab(:)
type(Paw_ij_type),target,intent(in) :: Paw_ij(:)
!Local variables-------------------------------
character(len=7),parameter :: dspin(6)=(/"up ","down ","up-up ","dwn-dwn","up-dwn ","dwn-up "/)
!scalars
integer :: cplex_dij,iatom,iatom_tot,idij,idij_sym,lmn2_size,lmn_size,my_comm_atom,my_natom,nspden !klmn,
integer :: nsploop,nsppol,my_unt,ndij,qphase,tmp_cplex_dij,my_ipert,my_enunit,my_prtvol,size_paw_ij
logical :: my_atmtab_allocated,paral_atom
character(len=4) :: my_mode
character(len=2000) :: msg
!arrays
integer :: idum(0)
integer,pointer :: my_atmtab(:)
real(dp),allocatable,target :: dij(:),dijs(:),dijh(:,:)
real(dp),pointer :: dij2p(:),dij2p_(:)
! *************************************************************************
if (.False.) write(std_out,*)"pawspnorb:",pawspnorb
!@Paw_ij_type
size_paw_ij=SIZE(Paw_ij);if (size_paw_ij==0) return
my_unt =std_out ; if (PRESENT(unit )) my_unt =unit
my_prtvol=0 ; if (PRESENT(pawprtvol )) my_prtvol=pawprtvol
my_mode ='COLL' ; if (PRESENT(mode_paral)) my_mode =mode_paral
my_ipert =0 ; if (PRESENT(ipert)) my_ipert =ipert
my_enunit=0 ; if (PRESENT(enunit)) my_enunit=enunit
my_natom=size_paw_ij; if (PRESENT(natom)) my_natom=natom
!Set up parallelism over atoms