1!{\src2tex{textfont=tt}}
2!!****f* ABINIT/xmpi_sum_master
3!! NAME
4!!  xmpi_sum_master
5!!
6!! FUNCTION
7!!  This module contains functions that calls MPI routine,
8!!  if we compile the code using the MPI  CPP flags.
9!!  xmpi_sum_master is the generic function.
10!!
11!! COPYRIGHT
12!!  Copyright (C) 2001-2016 ABINIT group (AR,XG,MB)
13!!  This file is distributed under the terms of the
14!!  GNU General Public License, see ~ABINIT/COPYING
15!!  or http://www.gnu.org/copyleft/gpl.txt .
16!!
17!! SOURCE
18
19!!***
20
21!!****f* ABINIT/xmpi_sum_master_int
22!! NAME
23!!  xmpi_sum_master_int
24!!
25!! FUNCTION
26!!  Reduces values on all processes to a single value.
27!!  Target: integer scalars.
28!!
29!! INPUTS
30!!  master= master MPI node
31!!  spaceComm= MPI communicator
32!!
33!! OUTPUT
34!!  ier= exit status, a non-zero value meaning there is an error
35!!
36!! SIDE EFFECTS
37!!  xval= buffer array
38!!
39!! SOURCE
40
41subroutine xmpi_sum_master_int(xval,master,spaceComm,ier)
42
43
44!This section has been created automatically by the script Abilint (TD).
45!Do not modify the following lines by hand.
46#undef ABI_FUNC
47#define ABI_FUNC 'xmpi_sum_master_int'
48!End of the abilint section
49
50 implicit none
51
52!Arguments-------------------------
53 integer,intent(inout) :: xval
54 integer ,intent(in) :: master
55 integer ,intent(in) :: spaceComm
56 integer ,intent(out)   :: ier
57
58!Local variables-------------------
59#if defined HAVE_MPI
60 integer :: xsum
61 integer :: nproc_space_comm
62#endif
63
64! *************************************************************************
65
66 ier=0
67#if defined HAVE_MPI
68 if (spaceComm /= MPI_COMM_NULL) then
69   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
70   if (nproc_space_comm /= 1) then
71!    Accumulate xval on all proc. in spaceComm
72     call MPI_REDUCE(xval,xsum,1,MPI_INTEGER,MPI_SUM,master,spaceComm,ier)
73     xval = xsum
74   end if
75 end if
76#endif
77end subroutine xmpi_sum_master_int
78!!***
79
80!!****f* ABINIT/xmpi_sum_master_int2d
81!! NAME
82!!  xmpi_sum_master_int2d
83!!
84!! FUNCTION
85!!  Reduces values on all processes to a single value.
86!!  Target: two-dimensional integer arrays.
87!!
88!! INPUTS
89!!  master= master MPI node
90!!  spaceComm= MPI communicator
91!!
92!! OUTPUT
93!!  ier= exit status, a non-zero value meaning there is an error
94!!
95!! SIDE EFFECTS
96!!  xval= buffer array
97!!
98!! SOURCE
99
100subroutine xmpi_sum_master_int2d(xval,master,spaceComm,ier)
101
102
103!This section has been created automatically by the script Abilint (TD).
104!Do not modify the following lines by hand.
105#undef ABI_FUNC
106#define ABI_FUNC 'xmpi_sum_master_int2d'
107!End of the abilint section
108
109 implicit none
110
111!Arguments ------------------------------------
112 integer, DEV_CONTARRD intent(inout) :: xval(:,:)
113 integer,intent(in) :: master,spaceComm
114 integer,intent(out) :: ier
115
116!Local variables-------------------------------
117#if defined HAVE_MPI
118 integer :: n1,n2
119 integer, allocatable :: xsum(:,:)
120 integer :: nproc_space_comm
121#endif
122
123! *************************************************************************
124
125 ier=0
126#if defined HAVE_MPI
127 if (spaceComm /= MPI_COMM_NULL) then
128   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
129   if (nproc_space_comm /= 1) then
130     n1 = size(xval,dim=1)
131     n2 = size(xval,dim=2)
132!    Accumulate xval on all proc. in spaceComm
133     ABI_STAT_ALLOCATE(xsum,(n1,n2), ier)
134     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
135     call MPI_reduce(xval,xsum,n1*n2,MPI_INTEGER,MPI_SUM,master,spaceComm,ier)
136     xval = xsum
137     ABI_DEALLOCATE(xsum)
138   end if
139 end if
140#endif
141
142end subroutine xmpi_sum_master_int2d
143!!***
144
145!!****f* ABINIT/xmpi_sum_master_dp1d
146!! NAME
147!!  xmpi_sum_master_dp1d
148!!
149!! FUNCTION
150!!  Reduces values on all processes to a single value.
151!!  Target: double precision one-dimensional arrays.
152!!
153!! INPUTS
154!!  master= master MPI node
155!!  spaceComm= MPI communicator
156!!
157!! OUTPUT
158!!  ier= exit status, a non-zero value meaning there is an error
159!!
160!! SIDE EFFECTS
161!!  xval= buffer array
162!!
163!! SOURCE
164
165subroutine xmpi_sum_master_dp1d(xval,master,spaceComm,ier)
166
167
168!This section has been created automatically by the script Abilint (TD).
169!Do not modify the following lines by hand.
170#undef ABI_FUNC
171#define ABI_FUNC 'xmpi_sum_master_dp1d'
172!End of the abilint section
173
174 implicit none
175
176!Arguments-------------------------
177 real(dp), DEV_CONTARRD intent(inout) :: xval(:)
178 integer ,intent(in) :: master
179 integer ,intent(in) :: spaceComm
180 integer ,intent(out) :: ier
181
182!Local variables-------------------
183#if defined HAVE_MPI
184 integer :: n1
185 real(dp) , allocatable :: xsum(:)
186 integer :: nproc_space_comm
187#endif
188
189! *************************************************************************
190
191 ier=0
192#if defined HAVE_MPI
193 if (spaceComm /= MPI_COMM_NULL) then
194   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
195   if (nproc_space_comm /= 1) then
196     n1 = size(xval,dim=1)
197!    Accumulate xval on all proc. in spaceComm
198     ABI_STAT_ALLOCATE(xsum,(n1), ier)
199     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
200     call MPI_REDUCE(xval,xsum,n1,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
201     xval (:) = xsum(:)
202     ABI_DEALLOCATE(xsum)
203   end if
204 end if
205#endif
206end subroutine xmpi_sum_master_dp1d
207!!***
208
209!!****f* ABINIT/xmpi_sum_master_dp2d
210!! NAME
211!!  xmpi_sum_master_dp2d
212!!
213!! FUNCTION
214!!  Reduces values on all processes to a single value.
215!!  Target: double precision two-dimensional arrays.
216!!
217!! INPUTS
218!!  master= master MPI node
219!!  spaceComm= MPI communicator
220!!
221!! OUTPUT
222!!  ier= exit status, a non-zero value meaning there is an error
223!!
224!! SIDE EFFECTS
225!!  xval= buffer array
226!!
227!! SOURCE
228
229subroutine xmpi_sum_master_dp2d(xval,master,spaceComm,ier)
230
231
232!This section has been created automatically by the script Abilint (TD).
233!Do not modify the following lines by hand.
234#undef ABI_FUNC
235#define ABI_FUNC 'xmpi_sum_master_dp2d'
236!End of the abilint section
237
238 implicit none
239
240!Arguments-------------------------
241 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:)
242 integer ,intent(in) :: master
243 integer ,intent(in) :: spaceComm
244 integer ,intent(out) :: ier
245
246!Local variables-------------------
247#if defined HAVE_MPI
248 integer :: n1,n2
249 real(dp) , allocatable :: xsum(:,:)
250 integer :: nproc_space_comm
251#endif
252
253! *************************************************************************
254
255 ier=0
256#if defined HAVE_MPI
257 if (spaceComm /= MPI_COMM_NULL) then
258   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
259   if (nproc_space_comm /= 1) then
260     n1 = size(xval,dim=1)
261     n2 = size(xval,dim=2)
262!    Accumulate xval on all proc. in spaceComm
263     ABI_STAT_ALLOCATE(xsum,(n1,n2), ier)
264     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
265     call MPI_REDUCE(xval,xsum,n1*n2,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
266     xval (:,:) = xsum(:,:)
267     ABI_DEALLOCATE(xsum)
268   end if
269 end if
270#endif
271end subroutine xmpi_sum_master_dp2d
272!!***
273
274!!****f* ABINIT/xmpi_sum_master_dp3d
275!! NAME
276!!  xmpi_sum_master_dp3d
277!!
278!! FUNCTION
279!!  Reduces values on all processes to a single value.
280!!  Target: double precision three-dimensional arrays.
281!!
282!! INPUTS
283!!  master= master MPI node
284!!  spaceComm= MPI communicator
285!!
286!! OUTPUT
287!!  ier= exit status, a non-zero value meaning there is an error
288!!
289!! SIDE EFFECTS
290!!  xval= buffer array
291!!
292!! SOURCE
293subroutine xmpi_sum_master_dp3d(xval,master,spaceComm,ier)
294
295
296!This section has been created automatically by the script Abilint (TD).
297!Do not modify the following lines by hand.
298#undef ABI_FUNC
299#define ABI_FUNC 'xmpi_sum_master_dp3d'
300!End of the abilint section
301
302 implicit none
303
304!Arguments-------------------------
305 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:,:)
306 integer ,intent(in) :: master
307 integer ,intent(in) :: spaceComm
308 integer ,intent(out) :: ier
309
310!Local variables-------------------
311#if defined HAVE_MPI
312 integer :: n1,n2,n3
313 real(dp) , allocatable :: xsum(:,:,:)
314 integer :: nproc_space_comm
315#endif
316
317! *************************************************************************
318
319 ier=0
320#if defined HAVE_MPI
321 if (spaceComm /= MPI_COMM_NULL) then
322   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
323   if (nproc_space_comm /= 1) then
324     n1 = size(xval,dim=1)
325     n2 = size(xval,dim=2)
326     n3 = size(xval,dim=3)
327!    Accumulate xval on all proc. in spaceComm
328     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3), ier)
329     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
330     call MPI_REDUCE(xval,xsum,n1*n2*n3,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
331     xval (:,:,:) = xsum(:,:,:)
332     ABI_DEALLOCATE(xsum)
333   end if
334 end if
335#endif
336
337end subroutine xmpi_sum_master_dp3d
338!!***
339
340!!****f* ABINIT/xmpi_sum_master_dp4d
341!! NAME
342!!  xmpi_sum_master_dp4d
343!!
344!! FUNCTION
345!!  Reduces values on all processes to a single value.
346!!  Target: double precision four-dimensional arrays.
347!!
348!! INPUTS
349!!  master= master MPI node
350!!  spaceComm= MPI communicator
351!!
352!! OUTPUT
353!!  ier= exit status, a non-zero value meaning there is an error
354!!
355!! SIDE EFFECTS
356!!  xval= buffer array
357!!
358!! SOURCE
359subroutine xmpi_sum_master_dp4d(xval,master,spaceComm,ier)
360
361
362!This section has been created automatically by the script Abilint (TD).
363!Do not modify the following lines by hand.
364#undef ABI_FUNC
365#define ABI_FUNC 'xmpi_sum_master_dp4d'
366!End of the abilint section
367
368 implicit none
369
370!Arguments-------------------------
371 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:,:,:)
372 integer ,intent(in) :: master
373 integer ,intent(in) :: spaceComm
374 integer ,intent(out) :: ier
375
376!Local variables-------------------
377#if defined HAVE_MPI
378 integer :: n1,n2,n3,n4
379 real(dp) , allocatable :: xsum(:,:,:,:)
380 integer :: nproc_space_comm
381#endif
382
383! *************************************************************************
384
385 ier=0
386#if defined HAVE_MPI
387 if (spaceComm /= MPI_COMM_NULL) then
388   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
389   if (nproc_space_comm /= 1) then
390     n1 = size(xval,dim=1)
391     n2 = size(xval,dim=2)
392     n3 = size(xval,dim=3)
393     n4 = size(xval,dim=4)
394!    Accumulate xval on all proc. in spaceComm
395     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4), ier)
396     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
397     call MPI_REDUCE(xval,xsum,n1*n2*n3*n4,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
398     xval (:,:,:,:) = xsum(:,:,:,:)
399     ABI_DEALLOCATE(xsum)
400   end if
401 end if
402#endif
403
404end subroutine xmpi_sum_master_dp4d
405!!***
406
407!!****f* ABINIT/xmpi_sum_master_dp5d
408!! NAME
409!!  xmpi_sum_master_dp5d
410!!
411!! FUNCTION
412!!  Reduces values on all processes to a single value.
413!!  Target: double precision five-dimensional arrays.
414!!
415!! INPUTS
416!!  master= master MPI node
417!!  spaceComm= MPI communicator
418!!
419!! OUTPUT
420!!  ier= exit status, a non-zero value meaning there is an error
421!!
422!! SIDE EFFECTS
423!!  xval= buffer array
424!!
425!! SOURCE
426subroutine xmpi_sum_master_dp5d(xval,master,spaceComm,ier)
427
428
429!This section has been created automatically by the script Abilint (TD).
430!Do not modify the following lines by hand.
431#undef ABI_FUNC
432#define ABI_FUNC 'xmpi_sum_master_dp5d'
433!End of the abilint section
434
435 implicit none
436
437!Arguments ------------------------------------
438 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:,:,:,:)
439 integer ,intent(in) :: master
440 integer ,intent(in) :: spaceComm
441 integer ,intent(out)   :: ier
442
443!Local variables-------------------------------
444#if defined HAVE_MPI
445 integer :: n1,n2,n3,n4,n5
446 real(dp), allocatable :: xsum(:,:,:,:,:)
447 integer :: nproc_space_comm
448#endif
449
450! *************************************************************************
451
452 ier=0
453#if defined HAVE_MPI
454 if (spaceComm /= MPI_COMM_NULL) then
455   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
456   if (nproc_space_comm /= 1) then
457     n1 = size(xval,dim=1)
458     n2 = size(xval,dim=2)
459     n3 = size(xval,dim=3)
460     n4 = size(xval,dim=4)
461     n5 = size(xval,dim=5)
462!    Accumulate xval on all proc. in spaceComm
463     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4,n5), ier)
464     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
465     call MPI_reduce(xval,xsum,n1*n2*n3*n4*n5,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
466     xval (:,:,:,:,:) = xsum(:,:,:,:,:)
467     ABI_DEALLOCATE(xsum)
468   end if
469 end if
470#endif
471
472end subroutine xmpi_sum_master_dp5d
473!!***
474
475!!****f* ABINIT/xmpi_sum_master_dp6d
476!! NAME
477!!  xmpi_sum_master_dp6d
478!!
479!! FUNCTION
480!!  Reduces values on all processes to a single value.
481!!  Target: double precision six-dimensional arrays.
482!!
483!! INPUTS
484!!  master= master MPI node
485!!  spaceComm= MPI communicator
486!!
487!! OUTPUT
488!!  ier= exit status, a non-zero value meaning there is an error
489!!
490!! SIDE EFFECTS
491!!  xval= buffer array
492!!
493!! SOURCE
494subroutine xmpi_sum_master_dp6d(xval,master,spaceComm,ier)
495
496
497!This section has been created automatically by the script Abilint (TD).
498!Do not modify the following lines by hand.
499#undef ABI_FUNC
500#define ABI_FUNC 'xmpi_sum_master_dp6d'
501!End of the abilint section
502
503 implicit none
504
505!Arguments ------------------------------------
506 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:,:,:,:,:)
507 integer ,intent(in) :: master
508 integer ,intent(in) :: spaceComm
509 integer ,intent(out) :: ier
510
511!Local variables-------------------------------
512#if defined HAVE_MPI
513 integer :: n1,n2,n3,n4,n5,n6
514 real(dp), allocatable :: xsum(:,:,:,:,:,:)
515 integer :: nproc_space_comm
516#endif
517
518! *************************************************************************
519
520 ier=0
521#if defined HAVE_MPI
522 if (spaceComm /= MPI_COMM_NULL) then
523   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
524   if (nproc_space_comm /= 1) then
525     n1 = size(xval,dim=1)
526     n2 = size(xval,dim=2)
527     n3 = size(xval,dim=3)
528     n4 = size(xval,dim=4)
529     n5 = size(xval,dim=5)
530     n6 = size(xval,dim=6)
531!    Accumulate xval on all proc. in spaceComm
532     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4,n5,n6), ier)
533     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
534     call MPI_reduce(xval,xsum,n1*n2*n3*n4*n5*n6,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
535     xval (:,:,:,:,:,:) = xsum(:,:,:,:,:,:)
536     ABI_DEALLOCATE(xsum)
537   end if
538 end if
539#endif
540
541end subroutine xmpi_sum_master_dp6d
542!!***
543
544!!****f* ABINIT/xmpi_sum_master_dp7d
545!! NAME
546!!  xmpi_sum_master_dp7d
547!!
548!! FUNCTION
549!!  Reduces values on all processes to a single value.
550!!  Target: double precision seven-dimensional arrays.
551!!
552!! INPUTS
553!!  master= master MPI node
554!!  spaceComm= MPI communicator
555!!
556!! OUTPUT
557!!  ier= exit status, a non-zero value meaning there is an error
558!!
559!! SIDE EFFECTS
560!!  xval= buffer array
561!!
562!! SOURCE
563subroutine xmpi_sum_master_dp7d(xval,master,spaceComm,ier)
564
565
566!This section has been created automatically by the script Abilint (TD).
567!Do not modify the following lines by hand.
568#undef ABI_FUNC
569#define ABI_FUNC 'xmpi_sum_master_dp7d'
570!End of the abilint section
571
572 implicit none
573
574!Arguments ------------------------------------
575 real(dp), DEV_CONTARRD intent(inout) :: xval(:,:,:,:,:,:,:)
576 integer ,intent(in) :: master
577 integer ,intent(in) :: spaceComm
578 integer ,intent(out) :: ier
579
580!Local variables-------------------------------
581#if defined HAVE_MPI
582 integer :: n1,n2,n3,n4,n5,n6,n7
583 real(dp), allocatable :: xsum(:,:,:,:,:,:,:)
584 integer :: nproc_space_comm
585#endif
586
587! *************************************************************************
588
589 ier=0
590#if defined HAVE_MPI
591 if (spaceComm /= MPI_COMM_NULL) then
592   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
593   if (nproc_space_comm /= 1) then
594     n1 = size(xval,dim=1)
595     n2 = size(xval,dim=2)
596     n3 = size(xval,dim=3)
597     n4 = size(xval,dim=4)
598     n5 = size(xval,dim=5)
599     n6 = size(xval,dim=6)
600     n7 = size(xval,dim=7)
601!    Accumulate xval on all proc. in spaceComm
602     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4,n5,n6,n7), ier)
603     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
604     call MPI_reduce(xval,xsum,n1*n2*n3*n4*n5*n6*n7,MPI_DOUBLE_PRECISION,MPI_SUM,master,spaceComm,ier)
605     xval (:,:,:,:,:,:,:) = xsum(:,:,:,:,:,:,:)
606     ABI_DEALLOCATE(xsum)
607   end if
608 end if
609#endif
610
611end subroutine xmpi_sum_master_dp7d
612!!***
613
614!!****f* ABINIT/xmpi_sum_master_int4d
615!! NAME
616!!  xmpi_sum_master_int4d
617!!
618!! FUNCTION
619!!  Reduces values on all processes to a single value.
620!!  Target: four-diemnsional integer arrays.
621!!
622!! INPUTS
623!!  master= master MPI node
624!!  spaceComm= MPI communicator
625!!
626!! OUTPUT
627!!  ier= exit status, a non-zero value meaning there is an error
628!!
629!! SIDE EFFECTS
630!!  xval= buffer array
631!!
632!! SOURCE
633
634subroutine xmpi_sum_master_int4d(xval,master,spaceComm,ier)
635
636
637!This section has been created automatically by the script Abilint (TD).
638!Do not modify the following lines by hand.
639#undef ABI_FUNC
640#define ABI_FUNC 'xmpi_sum_master_int4d'
641!End of the abilint section
642
643 implicit none
644
645!Arguments ------------------------------------
646 integer, DEV_CONTARRD intent(inout) :: xval(:,:,:,:)
647 integer,intent(in) :: master
648 integer,intent(in) :: spaceComm
649 integer,intent(out) :: ier
650
651!Local variables-------------------------------
652#if defined HAVE_MPI
653 integer :: n1,n2,n3,n4
654 integer, allocatable :: xsum(:,:,:,:)
655 integer :: nproc_space_comm
656#endif
657
658! *************************************************************************
659
660 ier=0
661#if defined HAVE_MPI
662 if (spaceComm /= MPI_COMM_NULL) then
663   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
664   if (nproc_space_comm /= 1) then
665     n1 = size(xval,dim=1)
666     n2 = size(xval,dim=2)
667     n3 = size(xval,dim=3)
668     n4 = size(xval,dim=4)
669!    Accumulate xval on all proc. in spaceComm
670     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4), ier)
671     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
672     call MPI_reduce(xval,xsum,n1*n2*n3*n4,MPI_INTEGER,MPI_SUM,master,spaceComm,ier)
673     xval (:,:,:,:) = xsum(:,:,:,:)
674     ABI_DEALLOCATE(xsum)
675   end if
676 end if
677#endif
678
679end subroutine xmpi_sum_master_int4d
680!!***
681
682!!****f* ABINIT/xmpi_sum_master_c1cplx
683!! NAME
684!!  xmpi_sum_master_c1cplx
685!!
686!! FUNCTION
687!!  Reduces values on all processes to a single value.
688!!  Target: one-dimensional complex arrays.
689!!
690!! INPUTS
691!!  master= master MPI node
692!!  spaceComm= MPI communicator
693!!
694!! OUTPUT
695!!  ier= exit status, a non-zero value meaning there is an error
696!!
697!! SIDE EFFECTS
698!!  xval= buffer array
699!!
700!! SOURCE
701
702subroutine xmpi_sum_master_c1cplx(xval,master,spaceComm,ier)
703
704
705!This section has been created automatically by the script Abilint (TD).
706!Do not modify the following lines by hand.
707#undef ABI_FUNC
708#define ABI_FUNC 'xmpi_sum_master_c1cplx'
709!End of the abilint section
710
711 implicit none
712
713!Arguments-------------------------
714 complex(spc), DEV_CONTARRD intent(inout) :: xval(:)
715 integer ,intent(in) :: master
716 integer ,intent(in) :: spaceComm
717 integer ,intent(out) :: ier
718
719!Local variables-------------------
720#if defined HAVE_MPI
721 integer :: n1,nproc_space_comm
722 complex(spc),allocatable :: xsum(:)
723#endif
724
725! *************************************************************************
726
727 ier=0
728#if defined HAVE_MPI
729 if (spaceComm /= MPI_COMM_NULL) then
730   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
731   if (nproc_space_comm /= 1) then
732     n1 = size(xval,dim=1)
733!    Collect xval from processors on master in spaceComm
734     ABI_STAT_ALLOCATE(xsum,(n1), ier)
735     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
736     call MPI_REDUCE(xval,xsum,n1,MPI_COMPLEX,MPI_SUM,master,spaceComm,ier)
737     xval = xsum
738     ABI_DEALLOCATE(xsum)
739   end if
740 end if
741#endif
742
743end subroutine xmpi_sum_master_c1cplx
744!!***
745
746!!****f* ABINIT/xmpi_sum_master_c2cplx
747!! NAME
748!!  xmpi_sum_master_c2cplx
749!!
750!! FUNCTION
751!!  Reduces values on all processes to a single value.
752!!  Target: two-dimensional complex arrays.
753!!
754!! INPUTS
755!!  master= master MPI node
756!!  spaceComm= MPI communicator
757!!
758!! OUTPUT
759!!  ier= exit status, a non-zero value meaning there is an error
760!!
761!! SIDE EFFECTS
762!!  xval= buffer array
763!!
764!! SOURCE
765
766subroutine xmpi_sum_master_c2cplx(xval,master,spaceComm,ier)
767
768
769!This section has been created automatically by the script Abilint (TD).
770!Do not modify the following lines by hand.
771#undef ABI_FUNC
772#define ABI_FUNC 'xmpi_sum_master_c2cplx'
773!End of the abilint section
774
775 implicit none
776
777!Arguments-------------------------
778 complex(spc), DEV_CONTARRD intent(inout) :: xval(:,:)
779 integer,intent(in) :: master
780 integer,intent(in) :: spaceComm
781 integer,intent(out) :: ier
782
783!Local variables-------------------
784#if defined HAVE_MPI
785 integer :: n1,n2
786 integer :: nproc_space_comm
787 complex(spc),allocatable :: xsum(:,:)
788#endif
789
790! *************************************************************************
791
792 ier=0
793#if defined HAVE_MPI
794 if (spaceComm /= MPI_COMM_NULL) then
795   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
796   if (nproc_space_comm /= 1) then
797     n1 = size(xval,dim=1)
798     n2 = size(xval,dim=2)
799!    Collect xval from processors on master in spaceComm
800     ABI_STAT_ALLOCATE(xsum,(n1,n2), ier)
801     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
802     call MPI_REDUCE(xval,xsum,n1*n2,MPI_COMPLEX,MPI_SUM,master,spaceComm,ier)
803     xval (:,:) = xsum(:,:)
804     ABI_DEALLOCATE(xsum)
805   end if
806 end if
807#endif
808
809end subroutine xmpi_sum_master_c2cplx
810!!***
811
812!!****f* ABINIT/xmpi_sum_master_c3cplx
813!! NAME
814!!  xmpi_sum_master_c3cplx
815!!
816!! FUNCTION
817!!  Reduces values on all processes to a single value.
818!!  Target: three-dimensional complex arrays.
819!!
820!! INPUTS
821!!  master= master MPI node
822!!  spaceComm= MPI communicator
823!!
824!! OUTPUT
825!!  ier= exit status, a non-zero value meaning there is an error
826!!
827!! SIDE EFFECTS
828!!  xval= buffer array
829!!
830!! SOURCE
831
832subroutine xmpi_sum_master_c3cplx(xval,master,spaceComm,ier)
833
834
835!This section has been created automatically by the script Abilint (TD).
836!Do not modify the following lines by hand.
837#undef ABI_FUNC
838#define ABI_FUNC 'xmpi_sum_master_c3cplx'
839!End of the abilint section
840
841 implicit none
842
843!Arguments-------------------------
844 complex(spc), DEV_CONTARRD intent(inout) :: xval(:,:,:)
845 integer,intent(in) :: master
846 integer,intent(in) :: spaceComm
847 integer,intent(out) :: ier
848
849!Local variables-------------------
850#if defined HAVE_MPI
851 integer :: n1,n2,n3
852 complex(spc), allocatable :: xsum(:,:,:)
853 integer :: nproc_space_comm
854#endif
855
856! *************************************************************************
857
858 ier=0
859#if defined HAVE_MPI
860 if (spaceComm /= MPI_COMM_NULL) then
861   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
862   if (nproc_space_comm /= 1) then
863     n1 = size(xval,dim=1)
864     n2 = size(xval,dim=2)
865     n3 = size(xval,dim=3)
866!    Collect xval from processors on master in spaceComm
867     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3), ier)
868     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
869     call MPI_REDUCE(xval,xsum,n1*n2*n3,MPI_COMPLEX,MPI_SUM,master,spaceComm,ier)
870     xval (:,:,:) = xsum(:,:,:)
871     ABI_DEALLOCATE(xsum)
872   end if
873 end if
874#endif
875
876end subroutine xmpi_sum_master_c3cplx
877!!***
878
879!!****f* ABINIT/xmpi_sum_master_c4cplx
880!! NAME
881!!  xmpi_sum_master_c4cplx
882!!
883!! FUNCTION
884!!  Reduces values on all processes to a single value.
885!!  Target: four-dimensional complex arrays.
886!!
887!! INPUTS
888!!  master= master MPI node
889!!  spaceComm= MPI communicator
890!!
891!! OUTPUT
892!!  ier= exit status, a non-zero value meaning there is an error
893!!
894!! SIDE EFFECTS
895!!  xval= buffer array
896!!
897!! SOURCE
898subroutine xmpi_sum_master_c4cplx(xval,master,spaceComm,ier)
899
900
901!This section has been created automatically by the script Abilint (TD).
902!Do not modify the following lines by hand.
903#undef ABI_FUNC
904#define ABI_FUNC 'xmpi_sum_master_c4cplx'
905!End of the abilint section
906
907 implicit none
908
909!Arguments-------------------------
910 complex(spc), DEV_CONTARRD intent(inout) :: xval(:,:,:,:)
911 integer,intent(in) :: master
912 integer,intent(in) :: spaceComm
913 integer,intent(out) :: ier
914
915!Local variables-------------------
916#if defined HAVE_MPI
917 integer :: n1,n2,n3,n4
918 integer :: nproc_space_comm
919 complex(spc), allocatable :: xsum(:,:,:,:)
920#endif
921
922! *************************************************************************
923
924 ier=0
925#if defined HAVE_MPI
926 if (spaceComm /= MPI_COMM_NULL) then
927   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
928   if (nproc_space_comm /= 1) then
929     n1 = size(xval,dim=1)
930     n2 = size(xval,dim=2)
931     n3 = size(xval,dim=3)
932     n4 = size(xval,dim=4)
933!    Collect xval from processors on master in spaceComm
934     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4), ier)
935     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
936     call MPI_REDUCE(xval,xsum,n1*n2*n3*n4,MPI_COMPLEX,MPI_SUM,master,spaceComm,ier)
937     xval (:,:,:,:) = xsum(:,:,:,:)
938     ABI_DEALLOCATE(xsum)
939   end if
940 end if
941#endif
942end subroutine xmpi_sum_master_c4cplx
943!!***
944
945!----------------------------------------------------------------------
946
947!!****f* ABINIT/xmpi_sum_master_c5cplx
948!! NAME
949!!  xmpi_sum_master_c5cplx
950!!
951!! FUNCTION
952!!  Reduces values on all processes to a single value.
953!!  Target: five-dimensional single precision complex arrays.
954!!
955!! INPUTS
956!!  master= master MPI node
957!!  spaceComm= MPI communicator
958!!
959!! OUTPUT
960!!  ier= exit status, a non-zero value meaning there is an error
961!!
962!! SIDE EFFECTS
963!!  xval= buffer array
964!!
965!! SOURCE
966
967subroutine xmpi_sum_master_c5cplx(xval,master,spaceComm,ier)
968
969!This section has been created automatically by the script Abilint (TD).
970!Do not modify the following lines by hand.
971#undef ABI_FUNC
972#define ABI_FUNC 'xmpi_sum_master_c5cplx'
973!End of the abilint section
974
975 implicit none
976
977!Arguments-------------------------
978 complex(spc), DEV_CONTARRD intent(inout) :: xval(:,:,:,:,:)
979 integer,intent(in) :: master
980 integer,intent(in) :: spaceComm
981 integer,intent(out) :: ier
982
983!Local variables-------------------
984#if defined HAVE_MPI
985 integer :: n1,n2,n3,n4,n5
986 complex(spc),allocatable :: xsum(:,:,:,:,:)
987 integer :: nproc_space_comm
988#endif
989
990! *************************************************************************
991
992 ier=0
993#if defined HAVE_MPI
994 if (spaceComm /= MPI_COMM_NULL) then
995   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
996   if (nproc_space_comm /= 1) then
997     n1 = size(xval,dim=1)
998     n2 = size(xval,dim=2)
999     n3 = size(xval,dim=3)
1000     n4 = size(xval,dim=4)
1001     n5 = size(xval,dim=5)
1002!    Collect xval from processors on master in spaceComm
1003     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4,n5), ier)
1004     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1005     call MPI_REDUCE(xval,xsum,n1*n2*n3*n4*n5,MPI_COMPLEX,MPI_SUM,master,spaceComm,ier)
1006     xval = xsum
1007     ABI_DEALLOCATE(xsum)
1008   end if
1009 end if
1010#endif
1011end subroutine xmpi_sum_master_c5cplx
1012!!***
1013
1014!!****f* ABINIT/xmpi_sum_master_c1dpc
1015!! NAME
1016!!  xmpi_sum_master_c1dpc
1017!!
1018!! FUNCTION
1019!!  Reduces values on all processes to a single value.
1020!!  Target: one-dimensional double complex arrays.
1021!!
1022!! INPUTS
1023!!  master= master MPI node
1024!!  spaceComm= MPI communicator
1025!!
1026!! OUTPUT
1027!!  ier= exit status, a non-zero value meaning there is an error
1028!!
1029!! SIDE EFFECTS
1030!!  xval= buffer array
1031!!
1032!! SOURCE
1033
1034subroutine xmpi_sum_master_c1dpc(xval,master,spaceComm,ier)
1035
1036
1037!This section has been created automatically by the script Abilint (TD).
1038!Do not modify the following lines by hand.
1039#undef ABI_FUNC
1040#define ABI_FUNC 'xmpi_sum_master_c1dpc'
1041!End of the abilint section
1042
1043 implicit none
1044
1045!Arguments-------------------------
1046 complex(dpc), DEV_CONTARRD intent(inout) :: xval(:)
1047 integer,intent(in) :: master
1048 integer,intent(in) :: spaceComm
1049 integer,intent(out) :: ier
1050
1051!Local variables-------------------
1052#if defined HAVE_MPI
1053 integer :: n1
1054 integer :: nproc_space_comm
1055 complex(dpc),allocatable :: xsum(:)
1056#endif
1057
1058! *************************************************************************
1059
1060 ier=0
1061#if defined HAVE_MPI
1062 if (spaceComm /= MPI_COMM_NULL) then
1063   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
1064   if (nproc_space_comm /= 1) then
1065     n1 = size(xval,dim=1)
1066!    Collect xval from processors on master in spaceComm
1067     ABI_STAT_ALLOCATE(xsum,(n1), ier)
1068     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1069     call MPI_REDUCE(xval,xsum,n1,MPI_DOUBLE_COMPLEX,MPI_SUM,master,spaceComm,ier)
1070     xval (:) = xsum(:)
1071     ABI_DEALLOCATE(xsum)
1072   end if
1073 end if
1074#endif
1075
1076end subroutine xmpi_sum_master_c1dpc
1077!!***
1078
1079!!****f* ABINIT/xmpi_sum_master_c2dpc
1080!! NAME
1081!!  xmpi_sum_master_c2dpc
1082!!
1083!! FUNCTION
1084!!  Reduces values on all processes to a single value.
1085!!  Target: two-dimensional double complex arrays.
1086!!
1087!! INPUTS
1088!!  master= master MPI node
1089!!  spaceComm= MPI communicator
1090!!
1091!! OUTPUT
1092!!  ier= exit status, a non-zero value meaning there is an error
1093!!
1094!! SIDE EFFECTS
1095!!  xval= buffer array
1096!!
1097!! SOURCE
1098subroutine xmpi_sum_master_c2dpc(xval,master,spaceComm,ier)
1099
1100
1101!This section has been created automatically by the script Abilint (TD).
1102!Do not modify the following lines by hand.
1103#undef ABI_FUNC
1104#define ABI_FUNC 'xmpi_sum_master_c2dpc'
1105!End of the abilint section
1106
1107 implicit none
1108
1109!Arguments-------------------------
1110 complex(dpc), DEV_CONTARRD intent(inout) :: xval(:,:)
1111 integer ,intent(in) :: master
1112 integer ,intent(in) :: spaceComm
1113 integer ,intent(out) :: ier
1114
1115!Local variables-------------------
1116#if defined HAVE_MPI
1117 integer :: n1,n2
1118 complex(dpc) , allocatable :: xsum(:,:)
1119 integer :: nproc_space_comm
1120#endif
1121
1122! *************************************************************************
1123
1124 ier=0
1125#if defined HAVE_MPI
1126 if (spaceComm /= MPI_COMM_NULL) then
1127   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
1128   if (nproc_space_comm /= 1) then
1129     n1 = size(xval,dim=1)
1130     n2 = size(xval,dim=2)
1131!    Collect xval from processors on master in spaceComm
1132     ABI_STAT_ALLOCATE(xsum,(n1,n2), ier)
1133     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1134     call MPI_REDUCE(xval,xsum,n1*n2,MPI_DOUBLE_COMPLEX,MPI_SUM,master,spaceComm,ier)
1135     xval (:,:) = xsum(:,:)
1136     ABI_DEALLOCATE(xsum)
1137   end if
1138 end if
1139#endif
1140
1141end subroutine xmpi_sum_master_c2dpc
1142!!***
1143
1144!!****f* ABINIT/xmpi_sum_master_c3dpc
1145!! NAME
1146!!  xmpi_sum_master_c3dpc
1147!!
1148!! FUNCTION
1149!!  Reduces values on all processes to a single value.
1150!!  Target: three-dimensional double complex arrays.
1151!!
1152!! INPUTS
1153!!  master= master MPI node
1154!!  spaceComm= MPI communicator
1155!!
1156!! OUTPUT
1157!!  ier= exit status, a non-zero value meaning there is an error
1158!!
1159!! SIDE EFFECTS
1160!!  xval= buffer array
1161!!
1162!! SOURCE
1163subroutine xmpi_sum_master_c3dpc(xval,master,spaceComm,ier)
1164
1165
1166!This section has been created automatically by the script Abilint (TD).
1167!Do not modify the following lines by hand.
1168#undef ABI_FUNC
1169#define ABI_FUNC 'xmpi_sum_master_c3dpc'
1170!End of the abilint section
1171
1172 implicit none
1173
1174!Arguments-------------------------
1175 complex(dpc), DEV_CONTARRD intent(inout) :: xval(:,:,:)
1176 integer,intent(in) :: master
1177 integer,intent(in) :: spaceComm
1178 integer,intent(out) :: ier
1179
1180!Local variables-------------------
1181#if defined HAVE_MPI
1182 integer :: n1,n2,n3
1183 complex(dpc) , allocatable :: xsum(:,:,:)
1184 integer :: nproc_space_comm
1185#endif
1186
1187! *************************************************************************
1188
1189 ier=0
1190#if defined HAVE_MPI
1191 if (spaceComm /= MPI_COMM_NULL) then
1192   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
1193   if (nproc_space_comm /= 1) then
1194     n1 = size(xval,dim=1)
1195     n2 = size(xval,dim=2)
1196     n3 = size(xval,dim=3)
1197!    Collect xval from processors on master in spaceComm
1198     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3), ier)
1199     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1200     call MPI_REDUCE(xval,xsum,n1*n2*n3,MPI_DOUBLE_COMPLEX,MPI_SUM,master,spaceComm,ier)
1201     xval (:,:,:) = xsum(:,:,:)
1202     ABI_DEALLOCATE(xsum)
1203   end if
1204 end if
1205#endif
1206end subroutine xmpi_sum_master_c3dpc
1207!!***
1208
1209!!****f* ABINIT/xmpi_sum_master_c4dpc
1210!! NAME
1211!!  xmpi_sum_master_c4dpc
1212!!
1213!! FUNCTION
1214!!  Reduces values on all processes to a single value.
1215!!  Target: four-dimensional double complex arrays.
1216!!
1217!! INPUTS
1218!!  master= master MPI node
1219!!  spaceComm= MPI communicator
1220!!
1221!! OUTPUT
1222!!  ier= exit status, a non-zero value meaning there is an error
1223!!
1224!! SIDE EFFECTS
1225!!  xval= buffer array
1226!!
1227!! SOURCE
1228subroutine xmpi_sum_master_c4dpc(xval,master,spaceComm,ier)
1229
1230
1231!This section has been created automatically by the script Abilint (TD).
1232!Do not modify the following lines by hand.
1233#undef ABI_FUNC
1234#define ABI_FUNC 'xmpi_sum_master_c4dpc'
1235!End of the abilint section
1236
1237 implicit none
1238
1239!Arguments-------------------------
1240 complex(dpc), DEV_CONTARRD intent(inout) :: xval(:,:,:,:)
1241 integer,intent(in) :: master
1242 integer,intent(in) :: spaceComm
1243 integer,intent(out) :: ier
1244
1245!Local variables-------------------
1246#if defined HAVE_MPI
1247 integer :: n1,n2,n3,n4
1248 complex(dpc) , allocatable :: xsum(:,:,:,:)
1249 integer :: nproc_space_comm
1250#endif
1251
1252! *************************************************************************
1253
1254 ier=0
1255#if defined HAVE_MPI
1256 if (spaceComm /= MPI_COMM_NULL) then
1257   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
1258   if (nproc_space_comm /= 1) then
1259     n1 = size(xval,dim=1)
1260     n2 = size(xval,dim=2)
1261     n3 = size(xval,dim=3)
1262     n4 = size(xval,dim=4)
1263!    Collect xval from processors on master in spaceComm
1264     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4), ier)
1265     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1266     call MPI_REDUCE(xval,xsum,n1*n2*n3*n4,MPI_DOUBLE_COMPLEX,MPI_SUM,master,spaceComm,ier)
1267     xval (:,:,:,:) = xsum(:,:,:,:)
1268     ABI_DEALLOCATE(xsum)
1269   end if
1270 end if
1271#endif
1272end subroutine xmpi_sum_master_c4dpc
1273!!***
1274
1275!!****f* ABINIT/xmpi_sum_master_c5dpc
1276!! NAME
1277!!  xmpi_sum_master_c5dpc
1278!!
1279!! FUNCTION
1280!!  Reduces values on all processes to a single value.
1281!!  Target: five-dimensional double complex arrays.
1282!!
1283!! INPUTS
1284!!  master= master MPI node
1285!!  spaceComm= MPI communicator
1286!!
1287!! OUTPUT
1288!!  ier= exit status, a non-zero value meaning there is an error
1289!!
1290!! SIDE EFFECTS
1291!!  xval= buffer array
1292!!
1293!! SOURCE
1294subroutine xmpi_sum_master_c5dpc(xval,master,spaceComm,ier)
1295
1296
1297!This section has been created automatically by the script Abilint (TD).
1298!Do not modify the following lines by hand.
1299#undef ABI_FUNC
1300#define ABI_FUNC 'xmpi_sum_master_c5dpc'
1301!End of the abilint section
1302
1303 implicit none
1304
1305!Arguments-------------------------
1306 complex(dpc), DEV_CONTARRD intent(inout) :: xval(:,:,:,:,:)
1307 integer,intent(in) :: master
1308 integer,intent(in) :: spaceComm
1309 integer,intent(out) :: ier
1310
1311!Local variables-------------------
1312#if defined HAVE_MPI
1313 integer :: n1,n2,n3,n4,n5
1314 complex(dpc),allocatable :: xsum(:,:,:,:,:)
1315 integer :: nproc_space_comm
1316#endif
1317
1318! *************************************************************************
1319
1320 ier=0
1321#if defined HAVE_MPI
1322 if (spaceComm /= MPI_COMM_NULL) then
1323   call MPI_COMM_SIZE(spaceComm,nproc_space_comm,ier)
1324   if (nproc_space_comm /= 1) then
1325     n1 = size(xval,dim=1)
1326     n2 = size(xval,dim=2)
1327     n3 = size(xval,dim=3)
1328     n4 = size(xval,dim=4)
1329     n5 = size(xval,dim=5)
1330!    Collect xval from processors on master in spaceComm
1331     ABI_STAT_ALLOCATE(xsum,(n1,n2,n3,n4,n5), ier)
1332     if (ier /= 0) call xmpi_abort(msg='error allocating xsum')
1333     call MPI_REDUCE(xval,xsum,n1*n2*n3*n4*n5,MPI_DOUBLE_COMPLEX,MPI_SUM,master,spaceComm,ier)
1334     xval (:,:,:,:,:) = xsum(:,:,:,:,:)
1335     ABI_DEALLOCATE(xsum)
1336   end if
1337 end if
1338#endif
1339end subroutine xmpi_sum_master_c5dpc
1340!!***
1341