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 2778 of file pblastim.f.

2779*
2780* -- PBLAS test routine (version 2.0) --
2781* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
2782* and University of California, Berkeley.
2783* April 1, 1998
2784*
2785* .. Scalar Arguments ..
2786 INTEGER I, INB, N, NB, NPROCS, PROC, SRCPROC
2787* ..
2788*
2789* Purpose
2790* =======
2791*
2792* PB_NUMROC returns the local number of matrix rows/columns process
2793* PROC will get if we give out N rows/columns starting from global in-
2794* dex I.
2795*
2796* Arguments
2797* =========
2798*
2799* N (global input) INTEGER
2800* On entry, N specifies the number of rows/columns being dealt
2801* out. N must be at least zero.
2802*
2803* I (global input) INTEGER
2804* On entry, I specifies the global index of the matrix entry.
2805* I must be at least one.
2806*
2807* INB (global input) INTEGER
2808* On entry, INB specifies the size of the first block of the
2809* global matrix. INB must be at least one.
2810*
2811* NB (global input) INTEGER
2812* On entry, NB specifies the size of the blocks used to parti-
2813* tion the matrix. NB must be at least one.
2814*
2815* PROC (local input) INTEGER
2816* On entry, PROC specifies the coordinate of the process whose
2817* local portion is determined. PROC must be at least zero and
2818* strictly less than NPROCS.
2819*
2820* SRCPROC (global input) INTEGER
2821* On entry, SRCPROC specifies the coordinate of the process
2822* that possesses the first row or column of the matrix. When
2823* SRCPROC = -1, the data is not distributed but replicated,
2824* otherwise SRCPROC must be at least zero and strictly less
2825* than NPROCS.
2826*
2827* NPROCS (global input) INTEGER
2828* On entry, NPROCS specifies the total number of process rows
2829* or columns over which the matrix is distributed. NPROCS must
2830* be at least one.
2831*
2832* -- Written on April 1, 1998 by
2833* Antoine Petitet, University of Tennessee, Knoxville 37996, USA.
2834*
2835* =====================================================================
2836*
2837* .. Local Scalars ..
2838 INTEGER I1, ILOCBLK, INB1, MYDIST, N1, NBLOCKS,
2839 $ SRCPROC1
2840* ..
2841* .. Executable Statements ..
2842*
2843 IF( ( srcproc.EQ.-1 ).OR.( nprocs.EQ.1 ) ) THEN
2844 pb_numroc = n
2845 RETURN
2846 END IF
2847*
2848* Compute coordinate of process owning I and corresponding INB
2849*
2850 IF( i.LE.inb ) THEN
2851*
2852* I is in range of first block, i.e SRCPROC owns I.
2853*
2854 srcproc1 = srcproc
2855 inb1 = inb - i + 1
2856*
2857 ELSE
2858*
2859* I is not in first block of matrix, figure out who has it
2860*
2861 i1 = i - 1 - inb
2862 nblocks = i1 / nb + 1
2863 srcproc1 = srcproc + nblocks
2864 srcproc1 = srcproc1 - ( srcproc1 / nprocs ) * nprocs
2865 inb1 = nblocks*nb - i1
2866*
2867 END IF
2868*
2869* Now everything is just like I=1. Search now who has N-1, Is N-1
2870* in the first block ?
2871*
2872 IF( n.LE.inb1 ) THEN
2873 IF( proc.EQ.srcproc1 ) THEN
2874 pb_numroc = n
2875 ELSE
2876 pb_numroc = 0
2877 END IF
2878 RETURN
2879 END IF
2880*
2881 n1 = n - inb1
2882 nblocks = n1 / nb + 1
2883*
2884 IF( proc.EQ.srcproc1 ) THEN
2885 ilocblk = nblocks / nprocs
2886 IF( ilocblk.GT.0 ) THEN
2887 IF( ( nblocks - ilocblk * nprocs ).GT.0 ) THEN
2888 pb_numroc = inb1 + ilocblk * nb
2889 ELSE
2890 pb_numroc = n + nb * ( ilocblk - nblocks )
2891 END IF
2892 ELSE
2893 pb_numroc = inb1
2894 END IF
2895 ELSE
2896 mydist = proc - srcproc1
2897 IF( mydist.LT.0 )
2898 $ mydist = mydist + nprocs
2899 ilocblk = nblocks / nprocs
2900 IF( ilocblk.GT.0 ) THEN
2901 mydist = mydist - nblocks + ilocblk * nprocs
2902 IF( mydist.LT.0 ) THEN
2903 pb_numroc = ( ilocblk + 1 ) * nb
2904 ELSE IF( mydist.GT.0 ) THEN
2905 pb_numroc = ilocblk * nb
2906 ELSE
2907 pb_numroc = n1 + nb * ( ilocblk - nblocks + 1 )
2908 END IF
2909 ELSE
2910 mydist = mydist - nblocks
2911 IF( mydist.LT.0 ) THEN
2912 pb_numroc = nb
2913 ELSE IF( mydist.GT.0 ) THEN
2914 pb_numroc = 0
2915 ELSE
2916 pb_numroc = n1 + nb * ( 1 - nblocks )
2917 END IF
2918 END IF
2919 END IF
2920*
2921 RETURN
2922*
2923* End of PB_NUMROC
2924*
integer function pb_numroc(n, i, inb, nb, proc, srcproc, nprocs)
Definition pblastst.f:2548
Here is the call graph for this function: