SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pb_numroc()

integer function pb_numroc ( integer  n,
integer  i,
integer  inb,
integer  nb,
integer  proc,
integer  srcproc,
integer  nprocs 
)

Definition at line 2547 of file pblastst.f.

2548*
2549* -- PBLAS test routine (version 2.0) --
2550* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
2551* and University of California, Berkeley.
2552* April 1, 1998
2553*
2554* .. Scalar Arguments ..
2555 INTEGER I, INB, N, NB, NPROCS, PROC, SRCPROC
2556* ..
2557*
2558* Purpose
2559* =======
2560*
2561* PB_NUMROC returns the local number of matrix rows/columns process
2562* PROC will get if we give out N rows/columns starting from global in-
2563* dex I.
2564*
2565* Arguments
2566* =========
2567*
2568* N (global input) INTEGER
2569* On entry, N specifies the number of rows/columns being dealt
2570* out. N must be at least zero.
2571*
2572* I (global input) INTEGER
2573* On entry, I specifies the global index of the matrix entry.
2574* I must be at least one.
2575*
2576* INB (global input) INTEGER
2577* On entry, INB specifies the size of the first block of the
2578* global matrix. INB must be at least one.
2579*
2580* NB (global input) INTEGER
2581* On entry, NB specifies the size of the blocks used to parti-
2582* tion the matrix. NB must be at least one.
2583*
2584* PROC (local input) INTEGER
2585* On entry, PROC specifies the coordinate of the process whose
2586* local portion is determined. PROC must be at least zero and
2587* strictly less than NPROCS.
2588*
2589* SRCPROC (global input) INTEGER
2590* On entry, SRCPROC specifies the coordinate of the process
2591* that possesses the first row or column of the matrix. When
2592* SRCPROC = -1, the data is not distributed but replicated,
2593* otherwise SRCPROC must be at least zero and strictly less
2594* than NPROCS.
2595*
2596* NPROCS (global input) INTEGER
2597* On entry, NPROCS specifies the total number of process rows
2598* or columns over which the matrix is distributed. NPROCS must
2599* be at least one.
2600*
2601* -- Written on April 1, 1998 by
2602* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
2603*
2604* =====================================================================
2605*
2606* .. Local Scalars ..
2607 INTEGER I1, ILOCBLK, INB1, MYDIST, N1, NBLOCKS,
2608 $ SRCPROC1
2609* ..
2610* .. Executable Statements ..
2611*
2612 IF( ( srcproc.EQ.-1 ).OR.( nprocs.EQ.1 ) ) THEN
2613 pb_numroc = n
2614 RETURN
2615 END IF
2616*
2617* Compute coordinate of process owning I and corresponding INB
2618*
2619 IF( i.LE.inb ) THEN
2620*
2621* I is in range of first block, i.e SRCPROC owns I.
2622*
2623 srcproc1 = srcproc
2624 inb1 = inb - i + 1
2625*
2626 ELSE
2627*
2628* I is not in first block of matrix, figure out who has it
2629*
2630 i1 = i - 1 - inb
2631 nblocks = i1 / nb + 1
2632 srcproc1 = srcproc + nblocks
2633 srcproc1 = srcproc1 - ( srcproc1 / nprocs ) * nprocs
2634 inb1 = nblocks*nb - i1
2635*
2636 END IF
2637*
2638* Now everything is just like I=1. Search now who has N-1, Is N-1
2639* in the first block ?
2640*
2641 IF( n.LE.inb1 ) THEN
2642 IF( proc.EQ.srcproc1 ) THEN
2643 pb_numroc = n
2644 ELSE
2645 pb_numroc = 0
2646 END IF
2647 RETURN
2648 END IF
2649*
2650 n1 = n - inb1
2651 nblocks = n1 / nb + 1
2652*
2653 IF( proc.EQ.srcproc1 ) THEN
2654 ilocblk = nblocks / nprocs
2655 IF( ilocblk.GT.0 ) THEN
2656 IF( ( nblocks - ilocblk * nprocs ).GT.0 ) THEN
2657 pb_numroc = inb1 + ilocblk * nb
2658 ELSE
2659 pb_numroc = n + nb * ( ilocblk - nblocks )
2660 END IF
2661 ELSE
2662 pb_numroc = inb1
2663 END IF
2664 ELSE
2665 mydist = proc - srcproc1
2666 IF( mydist.LT.0 )
2667 $ mydist = mydist + nprocs
2668 ilocblk = nblocks / nprocs
2669 IF( ilocblk.GT.0 ) THEN
2670 mydist = mydist - nblocks + ilocblk * nprocs
2671 IF( mydist.LT.0 ) THEN
2672 pb_numroc = ( ilocblk + 1 ) * nb
2673 ELSE IF( mydist.GT.0 ) THEN
2674 pb_numroc = ilocblk * nb
2675 ELSE
2676 pb_numroc = n1 + nb * ( ilocblk - nblocks + 1 )
2677 END IF
2678 ELSE
2679 mydist = mydist - nblocks
2680 IF( mydist.LT.0 ) THEN
2681 pb_numroc = nb
2682 ELSE IF( mydist.GT.0 ) THEN
2683 pb_numroc = 0
2684 ELSE
2685 pb_numroc = n1 + nb * ( 1 - nblocks )
2686 END IF
2687 END IF
2688 END IF
2689*
2690 RETURN
2691*
2692* End of PB_NUMROC
2693*
integer function pb_numroc(n, i, inb, nb, proc, srcproc, nprocs)
Definition pblastst.f:2548
Here is the call graph for this function:
Here is the caller graph for this function: