diff --git a/Changelog b/Changelog index 58a673db..d6b3a3c2 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,8 @@ Changelog. A lot less detailed than usual, at least for past history. +2007/12/21: Merged in debug infrastructure, internal and html docs. + 2007/11/14: Fix INTENT(IN) on X vector in preconditioner routines. 2007/10/15: Repackaged the sorting routines in a submodule of their diff --git a/base/comm/psb_dgather.f90 b/base/comm/psb_dgather.f90 index 37574474..4e3d2fbf 100644 --- a/base/comm/psb_dgather.f90 +++ b/base/comm/psb_dgather.f90 @@ -38,7 +38,7 @@ ! the distributed pieces. ! locx - real,dimension(:,:). The local piece of the distributed ! matrix to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! iroot - integer. The process that has to own the ! global matrix. If -1 all @@ -209,7 +209,7 @@ end subroutine psb_dgatherm ! distributed pieces. ! locx - real,dimension(:). The local piece of the ditributed ! vector to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! root - integer. The process that has to own the ! global matrix. If -1 all diff --git a/base/comm/psb_dhalo.f90 b/base/comm/psb_dhalo.f90 index 792d5707..1171d5fd 100644 --- a/base/comm/psb_dhalo.f90 +++ b/base/comm/psb_dhalo.f90 @@ -36,7 +36,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! alpha - real(optional). Scale factor. ! jx - integer(optional). The starting column of the global matrix. @@ -252,7 +252,7 @@ end subroutine psb_dhalom ! ! Arguments: ! x - real,dimension(:). The local part of the dense vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! alpha - real(optional). Scale factor. ! work - real(optional). Work area. diff --git a/base/comm/psb_dovrl.f90 b/base/comm/psb_dovrl.f90 index c1b8997d..b9bd9e97 100644 --- a/base/comm/psb_dovrl.f90 +++ b/base/comm/psb_dovrl.f90 @@ -36,7 +36,7 @@ ! ! Arguments: ! x(:,:) - real The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! jx - integer(optional). The starting column of the global matrix ! ik - integer(optional). The number of columns to gather. @@ -254,7 +254,7 @@ end subroutine psb_dovrlm ! ! Arguments: ! x(:) - real The local part of the dense vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! work - real(optional). A work area. ! update - integer(optional). Type of update: diff --git a/base/comm/psb_dscatter.F90 b/base/comm/psb_dscatter.F90 index 3fc5aec1..2bf33d55 100644 --- a/base/comm/psb_dscatter.F90 +++ b/base/comm/psb_dscatter.F90 @@ -37,10 +37,9 @@ ! Arguments: ! globx - real,dimension(:,:). The global matrix to scatter. ! locx - real,dimension(:,:). The local piece of the ditributed matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. -! iroot - integer(optional). The process that owns the global matrix. -! If -1 all +! iroot - integer(optional). The process that owns the global matrix. If -1 all ! the processes have a copy. Default -1. ! subroutine psb_dscatterm(globx, locx, desc_a, info, iroot) @@ -267,7 +266,7 @@ end subroutine psb_dscatterm ! Arguments: ! globx - real,dimension(:). The global vector to scatter. ! locx - real,dimension(:). The local piece of the ditributed vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer(optional). The process that owns the global vector. If -1 all ! the processes have a copy. diff --git a/base/comm/psb_igather.f90 b/base/comm/psb_igather.f90 index b3d330c1..4ead3fcb 100644 --- a/base/comm/psb_igather.f90 +++ b/base/comm/psb_igather.f90 @@ -38,7 +38,7 @@ ! the distributed pieces. ! locx - integer,dimension(:,:). The local piece of the distributed ! matrix to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer. The process that has to own the ! global matrix. If -1 all @@ -209,7 +209,7 @@ end subroutine psb_igatherm ! distributed pieces. ! locx - integer,dimension(:). The local piece of the ditributed ! vector to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer. The process that has to own the ! global matrix. If -1 all diff --git a/base/comm/psb_ihalo.f90 b/base/comm/psb_ihalo.f90 index f53b65ac..f2bdcaa2 100644 --- a/base/comm/psb_ihalo.f90 +++ b/base/comm/psb_ihalo.f90 @@ -37,7 +37,7 @@ ! ! Arguments: ! x - integer,dimension(:,:). The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! alpha - real(optional). Scale factor. ! jx - integer(optional). The starting column of the global matrix. @@ -254,7 +254,7 @@ end subroutine psb_ihalom ! ! Arguments: ! x - integer,dimension(:). The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! alpha - real(optional). Scale factor. ! jx - integer(optional). The starting column of the global matrix. diff --git a/base/comm/psb_iscatter.F90 b/base/comm/psb_iscatter.F90 index c3fa71f1..5c171dcf 100644 --- a/base/comm/psb_iscatter.F90 +++ b/base/comm/psb_iscatter.F90 @@ -37,7 +37,7 @@ ! Arguments: ! globx - integer,dimension(:,:). The global matrix to scatter. ! locx - integer,dimension(:,:). The local piece of the ditributed matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer(optional). The process that owns the global matrix. If -1 all ! the processes have a copy. @@ -264,7 +264,7 @@ end subroutine psb_iscatterm ! Arguments: ! globx - integer,dimension(:). The global vector to scatter. ! locx - integer,dimension(:). The local piece of the ditributed vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer(optional). The process that owns the global vector. If -1 all ! the processes have a copy. diff --git a/base/comm/psb_zgather.f90 b/base/comm/psb_zgather.f90 index dca3fbd1..507e6d65 100644 --- a/base/comm/psb_zgather.f90 +++ b/base/comm/psb_zgather.f90 @@ -38,7 +38,7 @@ ! the distributed pieces. ! locx - cplx,dimension(:,:). The local piece of the distributed ! matrix to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer. The process that has to own the ! global matrix. If -1 all @@ -211,7 +211,7 @@ end subroutine psb_zgatherm ! the distributed pieces. ! locx - cplx,dimension(:). The local piece of the distributed ! vector to be gathered. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer. The process that has to own the ! global matrix. If -1 all diff --git a/base/comm/psb_zhalo.f90 b/base/comm/psb_zhalo.f90 index 3a2cdf5b..048dd751 100644 --- a/base/comm/psb_zhalo.f90 +++ b/base/comm/psb_zhalo.f90 @@ -36,7 +36,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! alpha - complex(optional). Scale factor. ! jx - integer(optional). The starting column of the global matrix. @@ -251,7 +251,7 @@ end subroutine psb_zhalom ! ! Arguments: ! x - real,dimension(:). The local part of the dense vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! alpha - complex(optional). Scale factor. ! jx - integer(optional). The starting column of the global matrix. diff --git a/base/comm/psb_zovrl.f90 b/base/comm/psb_zovrl.f90 index 0b241b32..d13cf9a2 100644 --- a/base/comm/psb_zovrl.f90 +++ b/base/comm/psb_zovrl.f90 @@ -36,7 +36,7 @@ ! ! Arguments: ! x(:,:) - complex The local part of the dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! jx - integer(optional). The starting column of the global matrix ! ik - integer(optional). The number of columns to gather. @@ -253,7 +253,7 @@ end subroutine psb_zovrlm ! ! Arguments: ! x(:) - complex The local part of the dense vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! work - real(optional). A work area. ! update - integer(optional). Type of update: diff --git a/base/comm/psb_zscatter.F90 b/base/comm/psb_zscatter.F90 index 29613eb3..bbfb758e 100644 --- a/base/comm/psb_zscatter.F90 +++ b/base/comm/psb_zscatter.F90 @@ -37,7 +37,7 @@ ! Arguments: ! globx - complex,dimension(:,:). The global matrix to scatter. ! locx - complex,dimension(:,:). The local piece of the distributed matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code. ! iroot - integer(optional). The process that owns the global matrix. ! If -1 all the processes have a copy. @@ -269,7 +269,7 @@ end subroutine psb_zscatterm ! Arguments: ! globx - complex,dimension(:). The global vector to scatter. ! locx - complex,dimension(:). The local piece of the ditributed vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! iroot - integer(optional). The process that owns the global vector. If -1 all ! the processes have a copy. diff --git a/base/internals/psi_compute_size.f90 b/base/internals/psi_compute_size.f90 index 2fefc9ae..6e269d03 100644 --- a/base/internals/psi_compute_size.f90 +++ b/base/internals/psi_compute_size.f90 @@ -52,11 +52,13 @@ subroutine psi_compute_size(desc_data, index_in, dl_lda, info) integer, allocatable :: counter_recv(:), counter_dl(:) ! ...parameters - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name name='psi_compute_size' call psb_get_erraction(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() info = 0 ictxt = desc_data(psb_ctxt_) @@ -113,8 +115,8 @@ subroutine psi_compute_size(desc_data, index_in, dl_lda, info) ! computing max global value of dl_lda call psb_amx(ictxt, dl_lda) - if (debug) then - write(0,*) 'psi_compute_size: ',dl_lda + if (debug_level>=psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': ',dl_lda endif call psb_erractionrestore(err_act) diff --git a/base/internals/psi_crea_bnd_elem.f90 b/base/internals/psi_crea_bnd_elem.f90 index 3b9a5c00..1e896936 100644 --- a/base/internals/psi_crea_bnd_elem.f90 +++ b/base/internals/psi_crea_bnd_elem.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! bndel(:) - integer, allocatable Array containing the output list -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psi_crea_bnd_elem(bndel,desc_a,info) diff --git a/base/internals/psi_crea_index.f90 b/base/internals/psi_crea_index.f90 index a0b664ea..0b76835d 100644 --- a/base/internals/psi_crea_index.f90 +++ b/base/internals/psi_crea_index.f90 @@ -71,12 +71,14 @@ subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info ! ...parameters... integer, allocatable :: dep_list(:,:), length_dl(:) integer,parameter :: root=psb_root_,no_comm=-1 - logical,parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name info = 0 name='psi_crea_index' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt,me,np) @@ -99,7 +101,8 @@ subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info ! ...extract dependence list (ordered list of identifer process ! which every process must communcate with... - if (debug) write(*,*) 'crea_halo: calling extract_dep_list' + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': calling extract_dep_list' mode = 1 call psi_extract_dep_list(desc_a%matrix_data,index_in,& @@ -109,10 +112,12 @@ subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info goto 9999 end if - if (debug) write(0,*) 'crea_index: from extract_dep_list',& + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': from extract_dep_list',& & me,length_dl(0),index_in(1), ':',dep_list(:length_dl(me),me) ! ...now process root contains dependence list of all processes... - if (debug) write(0,*) 'crea_index: root sorting dep list' + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': root sorting dep list' call psi_dl_check(dep_list,max(1,dl_lda),np,length_dl) @@ -123,12 +128,14 @@ subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info goto 9999 end if - if(debug) write(0,*)'in psi_crea_index calling psi_desc_index',& + if(debug_level >= psb_debug_inner_)& + & write(debug_unit,*) me,' ',trim(name),': calling psi_desc_index',& & size(index_out) ! Do the actual format conversion. call psi_desc_index(desc_a,index_in,dep_list(1:,me),& & length_dl(me),nsnd,nrcv, index_out,glob_idx,info) - if(debug) write(0,*)'out of psi_desc_index',& + if(debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': out of psi_desc_index',& & size(index_out) nxch = length_dl(me) if(info /= 0) then @@ -137,6 +144,9 @@ subroutine psi_crea_index(desc_a,index_in,index_out,glob_idx,nxch,nsnd,nrcv,info end if deallocate(dep_list,length_dl) + if(debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': done' + call psb_erractionrestore(err_act) return diff --git a/base/internals/psi_crea_ovr_elem.f90 b/base/internals/psi_crea_ovr_elem.f90 index 3cce6ecd..d084c005 100644 --- a/base/internals/psi_crea_ovr_elem.f90 +++ b/base/internals/psi_crea_ovr_elem.f90 @@ -38,7 +38,7 @@ ! ! Arguments: ! ovr_elem(:) - integer, allocatable Array containing the output list -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psi_crea_ovr_elem(desc_overlap,ovr_elem,info) @@ -84,6 +84,8 @@ subroutine psi_crea_ovr_elem(desc_overlap,ovr_elem,info) if (usetree) then + ! + ! This is now here just for historical reasons. ! ! While running through the column indices exchanged with other procs ! we have to record them in overlap_elem. We do this by maintaining @@ -148,7 +150,7 @@ subroutine psi_crea_ovr_elem(desc_overlap,ovr_elem,info) else if (.not.usetree) then - + ! Simple alternative. insize = size(desc_overlap) insize = max(1,(insize+1)/2) allocate(telem(insize,2),stat=info) diff --git a/base/internals/psi_desc_index.F90 b/base/internals/psi_desc_index.F90 index 526e1c0f..3fdbe38b 100644 --- a/base/internals/psi_desc_index.F90 +++ b/base/internals/psi_desc_index.F90 @@ -131,12 +131,15 @@ subroutine psi_desc_index(desc,index_in,dep_list,& integer :: ihinsz,ntot,k,err_act,nidx,& & idxr, idxs, iszs, iszr, nesd, nerv, icomm - logical,parameter :: debug=.false., usempi=.true. - character(len=20) :: name + logical,parameter :: usempi=.true. + integer :: debug_level, debug_unit + character(len=20) :: name info = 0 name='psi_desc_index' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc) icomm = psb_cd_get_mpic(desc) @@ -147,8 +150,8 @@ subroutine psi_desc_index(desc,index_in,dep_list,& goto 9999 endif - if (debug) then - write(0,*) me,'start desc_index' + if (debug_level >= psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': start' call psb_barrier(ictxt) endif @@ -203,8 +206,8 @@ subroutine psi_desc_index(desc,index_in,dep_list,& if ((iszs /= idxs).or.(iszr /= idxr)) then write(0,*) 'strange results?', iszs,idxs,iszr,idxr end if - if (debug) then - write(0,*) me,'computed sizes ',iszr,iszs + if (debug_level >= psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': computed sizes ',iszr,iszs call psb_barrier(ictxt) endif @@ -223,8 +226,8 @@ subroutine psi_desc_index(desc,index_in,dep_list,& goto 9999 end if - if (debug) then - write(0,*) me,'computed allocated workspace ',iszr,iszs + if (debug_level >= psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': computed allocated workspace ',iszr,iszs call psb_barrier(ictxt) endif allocate(sndbuf(iszs),rcvbuf(iszr),stat=info) @@ -264,8 +267,8 @@ subroutine psi_desc_index(desc,index_in,dep_list,& i = i + nerv + 1 end do - if (debug) then - write(0,*) me,' prepared send buffer ' + if (debug_level >= psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': prepared send buffer ' call psb_barrier(ictxt) endif ! @@ -317,8 +320,8 @@ subroutine psi_desc_index(desc,index_in,dep_list,& goto 9999 end if - if (debug) then - write(0,*) me,'end desc_index' + if (debug_level >= psb_debug_inner_) then + write(debug_unit,*) me,' ',trim(name),': done' call psb_barrier(ictxt) endif diff --git a/base/internals/psi_dswapdata.F90 b/base/internals/psi_dswapdata.F90 index b44da06d..9588c180 100644 --- a/base/internals/psi_dswapdata.F90 +++ b/base/internals/psi_dswapdata.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswapdata.F90 +! File: psi_dswapdata.F90 ! -! Subroutine: psi_Xswapdatam +! Subroutine: psi_dswapdatam ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -68,7 +68,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -504,9 +504,8 @@ end subroutine psi_dswapdatam !!$ !!$ ! -! File: psi_Xswapdata.F90 ! -! Subroutine: psi_Xswapdatav +! Subroutine: psi_dswapdatav ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -543,7 +542,7 @@ end subroutine psi_dswapdatam ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/internals/psi_dswaptran.F90 b/base/internals/psi_dswaptran.F90 index df6b7b10..9c471119 100644 --- a/base/internals/psi_dswaptran.F90 +++ b/base/internals/psi_dswaptran.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswaptran.F90 +! File: psi_dswaptran.F90 ! -! Subroutine: psi_Xswaptranm +! Subroutine: psi_dswaptranm ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -72,7 +72,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -498,9 +498,8 @@ end subroutine psi_dswaptranm !!$ !!$ ! -! File: psi_Xswaptran.F90 ! -! Subroutine: psi_Xswaptranv +! Subroutine: psi_dswaptranv ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -541,7 +540,7 @@ end subroutine psi_dswaptranm ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/internals/psi_extrct_dl.F90 b/base/internals/psi_extrct_dl.F90 index 3bef2b4b..9b6babac 100644 --- a/base/internals/psi_extrct_dl.F90 +++ b/base/internals/psi_extrct_dl.F90 @@ -141,11 +141,13 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& ! .....local scalars... integer i,me,nprow,pointer_dep_list,proc,j,err_act integer ictxt, err, icomm - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character name*20 name='psi_extrct_dl' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() info = 0 ictxt = desc_data(psb_ctxt_) @@ -156,11 +158,13 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& length_dl(i) = 0 enddo i=1 - if (debug) write(0,*) 'extract: info ',info,desc_data(psb_dec_type_) + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) me,' ',trim(name),': start ',info,desc_data(psb_dec_type_) pointer_dep_list=1 if (psb_is_bld_dec(desc_data(psb_dec_type_))) then do while (desc_str(i) /= -1) - if (debug) write(0,*) me,' extract: looping ',i,& + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) me,' ',trim(name),' : looping ',i,& & desc_str(i),desc_str(i+1),desc_str(i+2) ! ...with different decomposition type we have different @@ -169,7 +173,8 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& ! ..if number of element to be exchanged !=0 proc=desc_str(i) if ((proc < 0).or.(proc.ge.nprow)) then - if (debug) write(0,*) 'extract error ',i,desc_str(i) + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) me,' ',trim(name),': error ',i,desc_str(i) info = 9999 int_err(1) = i int_err(2) = desc_str(i) @@ -203,7 +208,8 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& enddo else if (psb_is_upd_dec(desc_data(psb_dec_type_))) then do while (desc_str(i) /= -1) - if (debug) write(0,*) 'extract: looping ',i,desc_str(i) + if (debug_level >= psb_debug_inner_) & + & write(debug_unit,*) me,' ',trim(name),': looping ',i,desc_str(i) ! ...with different decomposition type we have different ! structure of indices lists............................ @@ -240,7 +246,6 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& i=i+desc_str(i+1)+2 enddo else - write(0,*) 'invalid dec_type',desc_data(psb_dec_type_) info = 2020 goto 9999 endif @@ -249,7 +254,8 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& ! ... check for errors... 998 continue - if (debug) write(0,*) 'extract: info ',info + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) me,' ',trim(name),': info ',info err = info if (err /= 0) goto 9999 @@ -257,11 +263,18 @@ subroutine psi_extract_dep_list(desc_data,desc_str,dep_list,& call psb_sum(ictxt,length_dl(0:np)) call psb_get_mpicomm(ictxt,icomm ) allocate(itmp(dl_lda),stat=info) - if (info /= 0) goto 9999 + if (info /= 0) then + info=4000 + goto 9999 + endif itmp(1:dl_lda) = dep_list(1:dl_lda,me) call mpi_allgather(itmp,dl_lda,mpi_integer,& & dep_list,dl_lda,mpi_integer,icomm,info) - deallocate(itmp) + deallocate(itmp,stat=info) + if (info /= 0) then + info=4000 + goto 9999 + endif call psb_erractionrestore(err_act) return diff --git a/base/internals/psi_fnd_owner.f90 b/base/internals/psi_fnd_owner.f90 index 19609e3f..aaef8612 100644 --- a/base/internals/psi_fnd_owner.f90 +++ b/base/internals/psi_fnd_owner.f90 @@ -40,7 +40,7 @@ ! idx(:) - integer Required indices on the calling process ! iprc(:) - integer, allocatable Output: process identifiers for the corresponding ! indices -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psi_fnd_owner(nv,idx,iprc,desc,info) @@ -64,7 +64,6 @@ subroutine psi_fnd_owner(nv,idx,iprc,desc,info) integer :: i,n_row,n_col, err_act,ih,icomm,hsize integer :: ictxt,np,me - logical, parameter :: debug=.false., debugwrt=.false. character(len=20) :: name info = 0 @@ -92,20 +91,13 @@ subroutine psi_fnd_owner(nv,idx,iprc,desc,info) endif if (.not.(psb_is_ok_desc(desc))) then - write(0,*) 'Invalid input descriptor in psi_fnd_owner' + call psb_errpush(4010,name,a_err='invalid desc') + goto 9999 end if ! ! The basic idea is very simple. ! First we figure out the total number of requests. - ! Second we build the aggregate list of requests (with psb_amx) - ! Third, we figure out locally whether we own the indices (whoever is - ! asking for them) and build our part of the reply (we shift process - ! indices so that they're 1-based) - ! Fourth, we do a psb_amx on the replies so that we have everybody's answers - ! Fifth, we extract the answers for our local query, and shift back the - ! process indices to 0-based. - Allocate(hidx(np+1),hsz(np),stat=info) if (info /= 0) then call psb_errpush(4010,name,a_err='Allocate') @@ -124,12 +116,16 @@ subroutine psi_fnd_owner(nv,idx,iprc,desc,info) call psb_errpush(4010,name,a_err='Allocate') goto 9999 end if + ! Second we build the aggregate list of requests (with psb_amx) helem(:) = 0 ih = hidx(me+1) do i=1, hsz(me+1) helem(ih+i-1) = idx(i) end do call psb_amx(ictxt,helem,info) + ! Third, we figure out locally whether we own the indices (whoever is + ! asking for them) and build our part of the reply (we shift process + ! indices so that they're 1-based) call psi_idx_cnv(hsize,helem,desc,info,owned=.true.) if (info /= 0) then call psb_errpush(4010,name,a_err='psi_idx_cnv') @@ -144,8 +140,11 @@ subroutine psi_fnd_owner(nv,idx,iprc,desc,info) end if end do + ! Fourth, we do a psb_amx on the replies so that we have everybody's answers call psb_amx(ictxt,hproc,info) + ! Fifth, we extract the answers for our local query, and shift back the + ! process indices to 0-based. if (nv > 0) then call psb_realloc(nv,iprc,info) ih = hidx(me+1) diff --git a/base/internals/psi_idx_cnv.f90 b/base/internals/psi_idx_cnv.f90 index db028acc..bbcf1ac2 100644 --- a/base/internals/psi_idx_cnv.f90 +++ b/base/internals/psi_idx_cnv.f90 @@ -38,7 +38,7 @@ ! Arguments: ! nv - integer Number of indices required ! idxin(:) - integer Required indices, overwritten on output. -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask(:) - logical, optional Only do the conversion for specific indices. ! owned - logical,optional Restrict to local indices, no halo @@ -61,7 +61,6 @@ subroutine psi_idx_cnv1(nv,idxin,desc,info,mask,owned) integer :: np, me integer :: nrow,ncol, err_act integer, allocatable :: idxout(:) - logical, parameter :: debug=.false. integer, parameter :: relocsz=200 character(len=20) :: name logical, pointer :: mask_(:) @@ -183,7 +182,6 @@ end subroutine psi_idx_cnv1 !!$ !!$ ! -! File: psi_idx_cnv.f90 ! ! Subroutine: psi_idx_cnv2 ! Converts a bunch of indices from global to local numbering. @@ -193,7 +191,7 @@ end subroutine psi_idx_cnv1 ! nv - integer Number of indices required ! idxin(:) - integer Required indices ! idxout(:) - integer Output values, negative for invalid input. -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask(:) - logical, optional Only do the conversion for specific indices. ! owned - logical,optional Restrict to local indices, no halo @@ -215,7 +213,6 @@ subroutine psi_idx_cnv2(nv,idxin,idxout,desc,info,mask,owned) integer :: i,ictxt,mglob, nglob integer :: np, me integer :: nrow,ncol, ip, err_act,lip - logical, parameter :: debug=.false. integer, parameter :: relocsz=200 character(len=20) :: name logical, pointer :: mask_(:) @@ -405,7 +402,6 @@ end subroutine psi_idx_cnv2 !!$ !!$ ! -! File: psi_idx_cnv.f90 ! ! Subroutine: psi_idx_cnvs ! Converts an index from global to local numbering. @@ -414,7 +410,7 @@ end subroutine psi_idx_cnv2 ! Arguments: ! idxin - integer Required index ! idxout - integer Output value, negative for invalid input. -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask - logical, optional Only do the conversion if true. ! owned - logical,optional Restrict to local indices, no halo diff --git a/base/internals/psi_idx_ins_cnv.f90 b/base/internals/psi_idx_ins_cnv.f90 index 7205ea81..561b298c 100644 --- a/base/internals/psi_idx_ins_cnv.f90 +++ b/base/internals/psi_idx_ins_cnv.f90 @@ -43,7 +43,7 @@ ! nv - integer Number of indices required ! idxin(:) - integer Required indices, overwritten on output ! output is negative for masked entries -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask(:) - logical, optional Only do the conversion for specific indices. ! @@ -64,7 +64,6 @@ subroutine psi_idx_ins_cnv1(nv,idxin,desc,info,mask) integer :: np, me integer :: nrow,ncol, err_act integer, allocatable :: idxout(:) - logical, parameter :: debug=.false. integer, parameter :: relocsz=200 character(len=20) :: name logical, pointer :: mask_(:) @@ -179,7 +178,6 @@ end subroutine psi_idx_ins_cnv1 !!$ !!$ ! -! File: psi_idx_ins_cnv.f90 ! ! Subroutine: psi_idx_ins_cnv2 ! Converts a bunch of indices from global to local numbering. @@ -193,7 +191,7 @@ end subroutine psi_idx_ins_cnv1 ! nv - integer Number of indices required ! idxin(:) - integer Required indices ! idxout(:) - integer Output values (negative for masked entries) -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask(:) - logical, optional Only do the conversion for specific indices. ! @@ -214,7 +212,6 @@ subroutine psi_idx_ins_cnv2(nv,idxin,idxout,desc,info,mask) integer :: i,ictxt,k,mglob, nglob integer :: np, me, isize integer :: pnt_halo,nrow,ncol, nh, ip, err_act,lip,nxt - logical, parameter :: debug=.false. integer, parameter :: relocsz=200 character(len=20) :: name,ch_err logical, pointer :: mask_(:) @@ -293,7 +290,6 @@ subroutine psi_idx_ins_cnv2(nv,idxin,idxout,desc,info,mask) if (ncol > isize) then nh = ncol + max(nv,relocsz) call psb_realloc(nh,desc%loc_to_glob,info,pad=-1) - if (debug) write(0,*) 'done realloc ',nh if (info /= 0) then info=1 ch_err='psb_realloc' @@ -346,9 +342,6 @@ subroutine psi_idx_ins_cnv2(nv,idxin,idxout,desc,info,mask) if (ncol > isize) then nh = ncol + max(nv,relocsz) call psb_realloc(nh,desc%loc_to_glob,info,pad=-1) - if (me==0) then - if (debug) write(0,*) 'done realloc ',nh - end if if (info /= 0) then info=3 ch_err='psb_realloc' @@ -437,7 +430,6 @@ end subroutine psi_idx_ins_cnv2 !!$ !!$ ! -! File: psi_idx_ins_cnv.f90 ! ! Subroutine: psi_idx_ins_cnvs ! Converts an index from global to local numbering. @@ -450,7 +442,7 @@ end subroutine psi_idx_ins_cnv2 ! Arguments: ! idxin - integer Required index s ! idxout - integer Output value (negative for masked entries) -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! mask - logical, optional Only do the conversion for specific indices. ! diff --git a/base/internals/psi_iswapdata.F90 b/base/internals/psi_iswapdata.F90 index a96ff545..1de81c42 100644 --- a/base/internals/psi_iswapdata.F90 +++ b/base/internals/psi_iswapdata.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswapdata.F90 +! File: psi_iswapdata.F90 ! -! Subroutine: psi_Xswapdatam +! Subroutine: psi_iswapdatam ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -68,7 +68,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -503,9 +503,8 @@ end subroutine psi_iswapdatam !!$ !!$ ! -! File: psi_Xswapdata.F90 ! -! Subroutine: psi_Xswapdatav +! Subroutine: psi_iswapdatav ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -542,7 +541,7 @@ end subroutine psi_iswapdatam ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/internals/psi_iswaptran.F90 b/base/internals/psi_iswaptran.F90 index 54d1e6d2..46e31ab0 100644 --- a/base/internals/psi_iswaptran.F90 +++ b/base/internals/psi_iswaptran.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswaptran.F90 +! File: psi_iswaptran.F90 ! -! Subroutine: psi_Xswaptranm +! Subroutine: psi_iswaptranm ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -72,7 +72,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -497,9 +497,8 @@ end subroutine psi_iswaptranm !!$ !!$ ! -! File: psi_Xswaptran.F90 ! -! Subroutine: psi_Xswaptranv +! Subroutine: psi_iswaptranv ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -540,7 +539,7 @@ end subroutine psi_iswaptranm ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/internals/psi_ldsc_pre_halo.f90 b/base/internals/psi_ldsc_pre_halo.f90 index f5e7940e..799a5bb5 100644 --- a/base/internals/psi_ldsc_pre_halo.f90 +++ b/base/internals/psi_ldsc_pre_halo.f90 @@ -43,7 +43,7 @@ ! ! ! Arguments: -! desc - type(). The communication descriptor. +! desc - type(psb_desc_type). The communication descriptor. ! ext_hv - logical Should we work on the halo_index. ! info - integer. return code. ! @@ -66,7 +66,6 @@ subroutine psi_ldsc_pre_halo(desc,ext_hv,info) integer :: i,j,np,me,lhalo,nhalo,& & n_col, err_act, key, ih, nh, idx, nk,icomm integer :: ictxt,n_row - logical, parameter :: debug=.false., debugwrt=.false. character(len=20) :: name,ch_err info = 0 diff --git a/base/internals/psi_sort_dl.f90 b/base/internals/psi_sort_dl.f90 index 7f787cdf..b3739e7f 100644 --- a/base/internals/psi_sort_dl.f90 +++ b/base/internals/psi_sort_dl.f90 @@ -41,20 +41,23 @@ subroutine psi_sort_dl(dep_list,l_dep_list,np,info) integer :: np,dep_list(:,:), l_dep_list(:) integer :: idg, iupd, idgp, iedges, iidx, iich,ndgmx, isz, err_act integer :: i, info - integer, allocatable :: work(:) - logical, parameter :: debug=.false. - character(len=20) :: name + integer, allocatable :: work(:) + integer :: debug_level, debug_unit + character(len=20) :: name name='psi_sort_dl' if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() info = 0 ndgmx = 0 do i=1,np ndgmx = ndgmx + l_dep_list(i) - if (debug) write(0,*) i,l_dep_list(i) + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) name,': ',i,l_dep_list(i) enddo idg = 1 iupd = idg+np @@ -63,7 +66,8 @@ subroutine psi_sort_dl(dep_list,l_dep_list,np,info) iidx = iedges + 2*ndgmx iich = iidx + ndgmx isz = iich + ndgmx - if (debug)write(0,*) 'psi_sort_dl: ndgmx ',ndgmx,isz + if (debug_level >= psb_debug_inner_)& + & write(debug_unit,*) name,': ndgmx ',ndgmx,isz allocate(work(isz)) ! call srtlist(dep_list, dl_lda, l_dep_list, np, info) diff --git a/base/internals/psi_zswapdata.F90 b/base/internals/psi_zswapdata.F90 index 88c9825e..ff997826 100644 --- a/base/internals/psi_zswapdata.F90 +++ b/base/internals/psi_zswapdata.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswapdata.F90 +! File: psi_zswapdata.F90 ! -! Subroutine: psi_Xswapdatam +! Subroutine: psi_zswapdatam ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -68,7 +68,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -503,9 +503,8 @@ end subroutine psi_zswapdatam !!$ !!$ ! -! File: psi_Xswapdata.F90 ! -! Subroutine: psi_Xswapdatav +! Subroutine: psi_zswapdatav ! Does the data exchange among processes. Essentially this is doing ! a variable all-to-all data exchange (ALLTOALLV in MPI parlance), but ! it is capable of pruning empty exchanges, which are very likely in out @@ -542,7 +541,7 @@ end subroutine psi_zswapdatam ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/internals/psi_zswaptran.F90 b/base/internals/psi_zswaptran.F90 index dc1305a0..7293b1ee 100644 --- a/base/internals/psi_zswaptran.F90 +++ b/base/internals/psi_zswaptran.F90 @@ -29,9 +29,9 @@ !!$ !!$ ! -! File: psi_Xswaptran.F90 +! File: psi_zswaptran.F90 ! -! Subroutine: psi_Xswaptranm +! Subroutine: psi_zswaptranm ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -72,7 +72,7 @@ ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:,:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. @@ -498,9 +498,8 @@ end subroutine psi_zswaptranm !!$ !!$ ! -! File: psi_Xswaptran.F90 ! -! Subroutine: psi_Xswaptranv +! Subroutine: psi_zswaptranv ! Does the data exchange among processes. This is similar to Xswapdata, but ! the list is read "in reverse", i.e. indices that are normally SENT are used ! for the RECEIVE part and vice-versa. This is the basic data exchange operation @@ -541,7 +540,7 @@ end subroutine psi_zswaptranm ! n - integer Number of columns in Y ! beta - X Choose overwrite or sum. ! y(:) - X The data area -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! work(:) - X Buffer space. If not sufficient, will do ! our own internal allocation. ! info - integer. return code. diff --git a/base/modules/psb_desc_type.f90 b/base/modules/psb_desc_type.f90 index b6d8f492..bf5a37d8 100644 --- a/base/modules/psb_desc_type.f90 +++ b/base/modules/psb_desc_type.f90 @@ -29,12 +29,10 @@ !!$ !!$ ! -! Module to define desc_a, -! structure for coomunications. ! -! Typedef: psb_desc_type +! package: psb_descriptor_type ! Defines a communication descriptor - +! module psb_descriptor_type use psb_const_mod @@ -98,7 +96,23 @@ module psb_descriptor_type ! - ! DESC data structure. + ! type: psb_desc_type + ! + ! Communication Descriptor data structure. + !| type psb_desc_type + !| integer, allocatable :: matrix_data(:) + !| integer, allocatable :: halo_index(:), ext_index(:) + !| integer, allocatable :: bnd_elem(:) + !| integer, allocatable :: ovrlap_index(:) + !| integer, allocatable :: ovrlap_elem(:) + !| integer, allocatable :: loc_to_glob(:) + !| integer, allocatable :: glob_to_loc (:) + !| integer, allocatable :: hashv(:), glb_lc(:,:), ptree(:) + !| integer, allocatable :: lprm(:) + !| integer, allocatable :: idx_space(:) + !| end type psb_desc_type + ! + ! ! This is the most important data structure: it holds all the data ! necessary to organize data exchange. The pattern of communication ! among processes depends not only on the allocation of portions of @@ -174,22 +188,22 @@ module psb_descriptor_type ! risk a deadlock. NOTE: This is the format when the state is PSB_ASB_. ! See below for BLD. The end-of-list is marked with a -1. ! - ! notation stored in explanation - ! --------------- --------------------------- ----------------------------------- - ! process_id index_v(p+proc_id_) identifier of process with which - ! data is exchanged. - ! n_elements_recv index_v(p+n_elem_recv_) number of elements to receive. - ! elements_recv index_v(p+elem_recv_+i) indexes of local elements to - ! receive. these are stored in the - ! array from location p+elem_recv_ to - ! location p+elem_recv_+ - ! index_v(p+n_elem_recv_)-1. - ! n_elements_send index_v(p+n_elem_send_) number of elements to send. - ! elements_send index_v(p+elem_send_+i) indexes of local elements to - ! send. these are stored in the - ! array from location p+elem_send_ to - ! location p+elem_send_+ - ! index_v(p+n_elem_send_)-1. + !| notation stored in explanation + !| --------------- --------------------------- ----------------------------------- + !| process_id index_v(p+proc_id_) identifier of process with which + !| data is exchanged. + !| n_elements_recv index_v(p+n_elem_recv_) number of elements to receive. + !| elements_recv index_v(p+elem_recv_+i) indexes of local elements to + !| receive. these are stored in the + !| array from location p+elem_recv_ to + !| location p+elem_recv_+ + !| index_v(p+n_elem_recv_)-1. + !| n_elements_send index_v(p+n_elem_send_) number of elements to send. + !| elements_send index_v(p+elem_send_+i) indexes of local elements to + !| send. these are stored in the + !| array from location p+elem_send_ to + !| location p+elem_send_+ + !| index_v(p+n_elem_send_)-1. ! ! This organization is valid for both halo and overlap indices; overlap entries ! need to be updated to ensure that a variable at a given global index @@ -234,9 +248,7 @@ module psb_descriptor_type ! ! 10. ovrlap_elem contains a list of overlap indices together with their degree ! of overlap, i.e. the number of processes "owning" them. - ! - ! - ! Yes, it is complex, but it does the following: + ! It is complex, but it does the following: ! 1. Allows a purely local matrix/stencil buildup phase, requiring only ! one synch point at the end (CDASB) ! 2. Takes shortcuts when the problem size is not too large (the default threshold @@ -248,7 +260,6 @@ module psb_descriptor_type ! ! ! - type psb_desc_type integer, allocatable :: matrix_data(:) integer, allocatable :: halo_index(:), ext_index(:) @@ -278,7 +289,6 @@ contains Type(psb_desc_type), intent(in) :: desc Integer :: psb_cd_sizeof !locals - logical, parameter :: debug=.false. integer :: val integer, external :: SizeofPairSearchTree diff --git a/base/modules/psb_error_mod.F90 b/base/modules/psb_error_mod.F90 index 142e0a61..6783e502 100644 --- a/base/modules/psb_error_mod.F90 +++ b/base/modules/psb_error_mod.F90 @@ -31,13 +31,19 @@ module psb_error_mod integer, parameter, public :: psb_act_ret_=0, psb_act_abort_=1, psb_no_err_=0 + integer, parameter, public :: psb_debug_ext_=1, psb_debug_outer_=2 + integer, parameter, public :: psb_debug_comp_=3, psb_debug_inner_=4 + integer, parameter, public :: psb_debug_serial_=8, psb_debug_serial_comp_=9 ! ! Error handling ! public psb_errpush, psb_error, psb_get_errstatus,& & psb_get_errverbosity, psb_set_errverbosity,psb_errcomm, & & psb_erractionsave, psb_erractionrestore, & - & psb_get_erraction, psb_set_erraction + & psb_get_erraction, psb_set_erraction, & + & psb_get_debug_level, psb_set_debug_level,& + & psb_get_debug_unit, psb_set_debug_unit,& + & psb_get_serial_debug_level, psb_set_serial_debug_level interface psb_error module procedure psb_serror @@ -49,29 +55,37 @@ module psb_error_mod type psb_errstack_node - integer :: err_code=0 ! the error code - character(len=20) :: routine='' ! the name of the routine generating the error - integer,dimension(5) :: i_err_data=0 ! array of integer data to complete the error msg + ! the error code + integer :: err_code=0 + ! the name of the routine generating the error + character(len=20) :: routine='' + ! array of integer data to complete the error msg + integer,dimension(5) :: i_err_data=0 ! real(kind(1.d0))(dim=10) :: r_err_data=0.d0 ! array of real data to complete the error msg ! complex(dim=10) :: c_err_data=0.c0 ! array of complex data to complete the error msg - character(len=40) :: a_err_data='' ! array of character data to complete the error msg - type(psb_errstack_node), pointer :: next ! pointer to the next element in the stack + ! array of character data to complete the error msg + character(len=40) :: a_err_data='' + ! pointer to the next element in the stack + type(psb_errstack_node), pointer :: next end type psb_errstack_node type psb_errstack - type(psb_errstack_node), pointer :: top => null() ! pointer to the top element of the stack - integer :: n_elems=0 ! number of entries in the stack + ! pointer to the top element of the stack + type(psb_errstack_node), pointer :: top => null() + ! number of entries in the stack + integer :: n_elems=0 end type psb_errstack - type(psb_errstack),save :: error_stack ! the PSBLAS-2.0 error stack - integer,save :: error_status=0 ! the error status (maybe not here) - integer,save :: verbosity_level=1 ! the verbosity level (maybe not here) - integer,save :: err_action=1 + type(psb_errstack), save :: error_stack ! the PSBLAS-2.0 error stack + integer, save :: error_status=0 ! the error status (maybe not here) + integer, save :: verbosity_level=1 ! the verbosity level (maybe not here) + integer, save :: err_action=1 + integer, save :: debug_level=0, debug_unit=0, serial_debug_level=0 contains @@ -105,6 +119,49 @@ contains end subroutine psb_erractionrestore + function psb_get_debug_level() + integer :: psb_get_debug_level + psb_get_debug_level = debug_level + end function psb_get_debug_level + + subroutine psb_set_debug_level(level) + integer, intent(in) :: level + if (level >= 0) then + debug_level = level + else + debug_level = 0 + end if + end subroutine psb_set_debug_level + + function psb_get_debug_unit() + integer :: psb_get_debug_unit + psb_get_debug_unit = debug_unit + end function psb_get_debug_unit + + subroutine psb_set_debug_unit(unit) + integer, intent(in) :: unit + if (unit >= 0) then + debug_unit = unit + else + debug_unit = 0 + end if + end subroutine psb_set_debug_unit + + function psb_get_serial_debug_level() + integer :: psb_get_serial_debug_level + psb_get_serial_debug_level = serial_debug_level + end function psb_get_serial_debug_level + + subroutine psb_set_serial_debug_level(level) + integer, intent(in) :: level + if (level >= 0) then + serial_debug_level = level + else + serial_debug_level = 0 + end if + end subroutine psb_set_serial_debug_level + + ! checks wether an error has occurred on one of the porecesses in the execution pool subroutine psb_errcomm(ictxt, err) integer, intent(in) :: ictxt @@ -452,10 +509,16 @@ contains write (0,'("local index is: ",i0," and global index is:",i0)')i_e_d(1:2) case(3110) write (0,'("Before you call this routine, you must assembly sparse matrix")') + case(3111) + write (0,'("Before you call this routine, you must initialize the preconditioner")') + case(3112) + write (0,'("Before you call this routine, you must build the preconditioner")') case(3111:3999) write(0,'("miscellaneus error. code: ",i0)')err_c case(4000) write(0,'("Allocation/deallocation error")') + case(4001) + write(0,'("Internal error: ",a)')a_e_d case(4010) write (0,'("Error from call to subroutine ",a)')a_e_d case(4011) diff --git a/base/modules/psb_penv_mod.F90 b/base/modules/psb_penv_mod.F90 index ce391c32..a4221f42 100644 --- a/base/modules/psb_penv_mod.F90 +++ b/base/modules/psb_penv_mod.F90 @@ -72,7 +72,7 @@ module psb_penv_mod module procedure psb_ibcasts, psb_ibcastv, psb_ibcastm,& & psb_dbcasts, psb_dbcastv, psb_dbcastm,& & psb_zbcasts, psb_zbcastv, psb_zbcastm,& - & psb_hbcasts, psb_lbcasts, psb_lbcastv, psb_hbcastv1 + & psb_hbcasts, psb_lbcasts, psb_lbcastv end interface @@ -546,39 +546,6 @@ contains end subroutine psb_hbcasts - subroutine psb_hbcastv1(ictxt,dat,root,length) -#ifdef MPI_H - include 'mpif.h' -#endif -#ifdef MPI_MOD - use mpi -#endif - integer, intent(in) :: ictxt - character(len=1), intent(inout) :: dat(:) - integer, intent(in), optional :: root,length - - integer :: iam, np, root_,icomm,length_,info - -#if !defined(SERIAL_MPI) - if (present(root)) then - root_ = root - else - root_ = psb_root_ - endif - if (present(length)) then - length_ = length - else - length_ = size(dat) - endif - - call psb_info(ictxt,iam,np) - call psb_get_mpicomm(ictxt,icomm) - - call mpi_bcast(dat,length_,MPI_CHARACTER,root_,icomm,info) -#endif - - end subroutine psb_hbcastv1 - subroutine psb_lbcasts(ictxt,dat,root) #ifdef MPI_H include 'mpif.h' diff --git a/base/modules/psb_spmat_type.f90 b/base/modules/psb_spmat_type.f90 index 0b50c224..8888b726 100644 --- a/base/modules/psb_spmat_type.f90 +++ b/base/modules/psb_spmat_type.f90 @@ -28,18 +28,16 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! Module to define D_SPMAT, structure !! -!! for sparse matrix. !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! +! package: psb_spmat_type +! Data structure(s) for sparse matrices +! module psb_spmat_type use psb_error_mod use psb_realloc_mod use psb_const_mod implicit none - ! Typedef: psb_dspmat_type - ! Contains a sparse matrix - + ! ! ! Queries into spmat%info ! @@ -55,22 +53,40 @@ module psb_spmat_type integer, parameter :: psb_dupl_=11, psb_upd_=12 integer, parameter :: psb_ifasize_=16 ! - ! - ! Possible matrix states. + ! Types: psb_dspmat_type, psb_zspmat_type + ! + !| type psb_dspmat_type + !| integer :: m, k ! Row & column size + !| character(len=5) :: fida ! Storage format: CSR,COO etc. + !| character(len=11) :: descra ! Matrix type: encodes general, triang. + !| integer :: infoa(psb_ifasize_) ! Additional integer info + !| real(kind(1.d0)), allocatable :: aspk(:) ! Coefficients + !| integer, allocatable :: ia1(:), ia2(:) ! Row/column indices encoded + !| integer, allocatable :: pl(:), pr(:) ! Row/column permutation + !| end type psb_dspmat_type + !| type psb_zspmat_type + !| integer :: m, k + !| character(len=5) :: fida + !| character(len=11) :: descra + !| integer :: infoa(psb_ifasize_) + !| complex(kind(1.d0)), allocatable :: aspk(:) + !| integer, allocatable :: ia1(:), ia2(:) + !| integer, allocatable :: pl(:), pr(:) + !| end type psb_zspmat_type ! ! A sparse matrix can move between states according to the ! following state transition table. - ! In Out Routine - ! ---------------------------------- - ! Null Build psb_sp_all - ! Build Build psb_coins - ! Build Assembled psb_spcnv - ! Assembled Assembled psb_spcnv - ! Assembled Update psb_sp_reinit - ! Update Update psb_coins - ! Update Assembled psb_spcnv - ! * unchanged psb_sp_reall - ! Assembled Null psb_sp_free + !| In Out Routine + !| ---------------------------------- + !| Null Build psb_sp_all + !| Build Build psb_coins + !| Build Assembled psb_spcnv + !| Assembled Assembled psb_spcnv + !| Assembled Update psb_sp_reinit + !| Update Update psb_coins + !| Update Assembled psb_spcnv + !| * unchanged psb_sp_reall + !| Assembled Null psb_sp_free ! ! Note that psb_spcnv is overloaded in two flavours, ! psb_spcnv(a,info) @@ -81,7 +97,7 @@ module psb_spmat_type ! integer, parameter :: psb_spmat_null_=0, psb_spmat_bld_=1 integer, parameter :: psb_spmat_asb_=2, psb_spmat_upd_=4 - + integer, parameter :: psb_ireg_flgs_=10, psb_ip2_=0 integer, parameter :: psb_iflag_=2, psb_ichk_=3 integer, parameter :: psb_nnzt_=4, psb_zero_=5,psb_ipc_=6 @@ -105,35 +121,21 @@ module psb_spmat_type type psb_dspmat_type - ! Rows & columns integer :: m, k - ! Identify the representation method. Es: CSR, JAD, ... character(len=5) :: fida - ! describe some chacteristics of sparse matrix character(len=11) :: descra - ! Contains some additional informations on sparse matrix integer :: infoa(psb_ifasize_) - ! Contains sparse matrix coefficients real(kind(1.d0)), allocatable :: aspk(:) - ! Contains indeces that describes sparse matrix structure integer, allocatable :: ia1(:), ia2(:) - ! Permutations matrix integer, allocatable :: pl(:), pr(:) end type psb_dspmat_type type psb_zspmat_type - ! Rows & columns integer :: m, k - ! Identify the representation method. Es: CSR, JAD, ... character(len=5) :: fida - ! describe some chacteristics of sparse matrix character(len=11) :: descra - ! Contains some additional informations on sparse matrix integer :: infoa(psb_ifasize_) - ! Contains sparse matrix coefficients complex(kind(1.d0)), allocatable :: aspk(:) - ! Contains indeces that describes sparse matrix structure integer, allocatable :: ia1(:), ia2(:) - ! Permutations matrix integer, allocatable :: pl(:), pr(:) end type psb_zspmat_type @@ -243,12 +245,12 @@ contains return end function psb_get_zsp_ncols - + integer function psb_get_dsp_nnzeros(a) type(psb_dspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nztotreq_,a,ires,info) if (info == 0) then psb_get_dsp_nnzeros = ires @@ -260,7 +262,7 @@ contains integer function psb_get_zsp_nnzeros(a) type(psb_zspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nztotreq_,a,ires,info) if (info == 0) then psb_get_zsp_nnzeros = ires @@ -272,7 +274,7 @@ contains integer function psb_get_dsp_nzsize(a) type(psb_dspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nzsizereq_,a,ires,info) if (info == 0) then psb_get_dsp_nzsize = ires @@ -284,7 +286,7 @@ contains integer function psb_get_zsp_nzsize(a) type(psb_zspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nzsizereq_,a,ires,info) if (info == 0) then psb_get_zsp_nzsize = ires @@ -298,7 +300,7 @@ contains integer, intent(in) :: ir type(psb_dspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nzrowreq_,a,ires,info,iaux=ir) if (info == 0) then psb_get_dsp_nnz_row = ires @@ -310,7 +312,7 @@ contains integer, intent(in) :: ir type(psb_zspmat_type), intent(in) :: a integer :: ires,info - + call psb_sp_info(psb_nzrowreq_,a,ires,info,iaux=ir) if (info == 0) then psb_get_zsp_nnz_row = ires @@ -347,7 +349,7 @@ contains logical, parameter :: debug=.false. logical :: clear_ character(len=20) :: name - + info = 0 name = 'psb_sp_reinit' @@ -356,7 +358,7 @@ contains else clear_ = .true. end if - + select case(psb_sp_getifld(psb_state_,a,info)) case(psb_spmat_asb_) @@ -628,7 +630,7 @@ contains End Subroutine psb_dspclone - + ! Will be changed to use MOVE_ALLOC subroutine psb_dsp_transfer(a, b,info) implicit none @@ -637,9 +639,6 @@ contains Type(psb_dspmat_type), intent(inout) :: B Integer, intent(out) :: info - !locals - logical, parameter :: debug=.false. - info = 0 @@ -668,16 +667,13 @@ contains Type(psb_dspmat_type), intent(inout) :: A Integer, intent(in) :: field,val Integer, intent(out) :: info - - !locals - logical, parameter :: debug=.false. + info = 0 -!!$ call psb_realloc(psb_ifasize_,a%infoa,info) - + if (info == 0) & & call psb_setifield(val,field,a%infoa,psb_ifasize_,info) - + Return @@ -699,7 +695,6 @@ contains !locals Integer :: i1, i2, ia - logical, parameter :: debug=.false. info = 0 call psb_sp_trimsize(a,i1,i2,ia,info) @@ -718,7 +713,6 @@ contains Integer, intent(out) :: info !locals Integer :: i1, i2, ia - logical, parameter :: debug=.false. info = 0 call psb_sp_trimsize(a,i1,i2,ia,info) @@ -739,7 +733,6 @@ contains !locals Integer :: nza - logical, parameter :: debug=.false. info = 0 if (psb_sp_getifld(psb_upd_,a,info) == psb_upd_perm_) then @@ -775,7 +768,7 @@ contains Return End Subroutine psb_dsp_trimsize - + function psb_dsp_getifld(field,a,info) implicit none !....Parameters... @@ -786,7 +779,6 @@ contains Integer, intent(out) :: info !locals - logical, parameter :: debug=.false. integer :: val info = 0 @@ -799,7 +791,7 @@ contains endif call psb_getifield(val,field,a%infoa,psb_ifasize_,info) - + psb_dsp_getifld = val Return @@ -813,11 +805,10 @@ contains Integer :: psb_dspsizeof !locals - logical, parameter :: debug=.false. integer :: val val = 4*size(a%infoa) - + if (allocated(a%aspk)) then val = val + 8 * size(a%aspk) endif @@ -835,7 +826,7 @@ contains val = val + 4 * size(a%pr) endif - + psb_dspsizeof = val Return @@ -848,7 +839,6 @@ contains Type(psb_dspmat_type), intent(inout) :: A Integer, intent(out) :: info !locals - logical, parameter :: debug=.false. integer :: iret info = 0 @@ -902,10 +892,9 @@ contains logical, intent(in), optional :: clear !locals - logical, parameter :: debug=.false. logical :: clear_ character(len=20) :: name - + info = 0 name = 'psb_sp_reinit' @@ -914,7 +903,7 @@ contains else clear_ = .true. end if - + select case(psb_sp_getifld(psb_state_,a,info)) case(psb_spmat_asb_) @@ -1078,8 +1067,6 @@ contains Integer, intent(in) :: ni1,ni2,nz Integer, intent(inout) :: info - !locals - logical, parameter :: debug=.false. info = 0 call psb_realloc(nz,a%aspk,info) @@ -1113,9 +1100,6 @@ contains Integer, intent(in), optional :: ifc integer :: ifc_ - !locals - logical, parameter :: debug=.false. - info = 0 if (nnz.lt.0) then info=45 @@ -1154,10 +1138,6 @@ contains Type(psb_zspmat_type), intent(out) :: B Integer, intent(out) :: info - !locals - - logical, parameter :: debug=.false. - INFO = 0 call psb_nullify_sp(b) @@ -1191,9 +1171,6 @@ contains Type(psb_zspmat_type), intent(inout) :: B Integer, intent(out) :: info - !locals - logical, parameter :: debug=.false. - info = 0 call psb_transfer( a%aspk, b%aspk , info) @@ -1221,17 +1198,13 @@ contains Integer, intent(in) :: field,val Integer, intent(out) :: info - !locals - logical, parameter :: debug=.false. info = 0 -!!$ call psb_realloc(psb_ifasize_,a%infoa,info) - if (info == 0) & & call psb_setifield(val,field,a%infoa,psb_ifasize_,info) - + Return @@ -1247,7 +1220,6 @@ contains !locals Integer :: nza - logical, parameter :: debug=.false. info = 0 if (psb_sp_getifld(psb_upd_,a,info) == psb_upd_perm_) then @@ -1294,7 +1266,6 @@ contains Integer, intent(out) :: info !locals - logical, parameter :: debug=.false. integer :: val info = 0 @@ -1307,7 +1278,7 @@ contains endif call psb_getifield(val,field,a%infoa,psb_ifasize_,info) - + psb_zsp_getifld = val Return @@ -1321,11 +1292,10 @@ contains Integer :: psb_zspsizeof !locals - logical, parameter :: debug=.false. integer :: val val = 4*size(a%infoa) - + if (allocated(a%aspk)) then val = val + 16 * size(a%aspk) endif @@ -1342,8 +1312,8 @@ contains if (allocated(a%pr)) then val = val + 4 * size(a%pr) endif - - + + psb_zspsizeof = val Return @@ -1357,8 +1327,6 @@ contains !....Parameters... Type(psb_zspmat_type), intent(inout) :: A Integer, intent(out) :: info - !locals - logical, parameter :: debug=.false. info = 0 diff --git a/base/modules/psi_mod.f90 b/base/modules/psi_mod.f90 index 6d28fa3b..4690afa2 100644 --- a/base/modules/psi_mod.f90 +++ b/base/modules/psi_mod.f90 @@ -316,11 +316,14 @@ contains integer, allocatable :: idx_out(:) ! ...parameters + integer :: debug_level, debug_unit logical, parameter :: debug=.false. character(len=20) :: name name='psi_bld_cdesc' call psb_get_erraction(err_act) + debug_level = psb_get_debug_level() + debug_unit = psb_get_debug_unit() info = 0 ictxt = cdesc%matrix_data(psb_ctxt_) @@ -334,7 +337,7 @@ contains ! first the halo index - if (debug) write(0,*) me,'Calling crea_index on halo' + if (debug_level>0) write(debug_unit,*) me,'Calling crea_index on halo' call psi_crea_index(cdesc,halo_in, idx_out,.false.,nxch,nsnd,nrcv,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psi_crea_index') @@ -345,12 +348,12 @@ contains cdesc%matrix_data(psb_thal_snd_) = nsnd cdesc%matrix_data(psb_thal_rcv_) = nrcv - if (debug) write(0,*) me,'Done crea_index on halo' - if (debug) write(0,*) me,'Calling crea_index on ext' + if (debug_level>0) write(debug_unit,*) me,'Done crea_index on halo' + if (debug_level>0) write(debug_unit,*) me,'Calling crea_index on ext' ! then ext index - if (debug) write(0,*) me,'Calling crea_index on ext' + if (debug_level>0) write(debug_unit,*) me,'Calling crea_index on ext' call psi_crea_index(cdesc,ext_in, idx_out,.false.,nxch,nsnd,nrcv,info) if(info /= 0) then call psb_errpush(4010,name,a_err='psi_crea_index') @@ -361,8 +364,8 @@ contains cdesc%matrix_data(psb_text_snd_) = nsnd cdesc%matrix_data(psb_text_rcv_) = nrcv - if (debug) write(0,*) me,'Done crea_index on ext' - if (debug) write(0,*) me,'Calling crea_index on ovrlap' + if (debug_level>0) write(debug_unit,*) me,'Done crea_index on ext' + if (debug_level>0) write(debug_unit,*) me,'Calling crea_index on ovrlap' ! then the overlap index @@ -381,10 +384,10 @@ contains cdesc%matrix_data(psb_tovr_snd_) = nsnd cdesc%matrix_data(psb_tovr_rcv_) = nrcv - if (debug) write(0,*) me,'Calling crea_ovr_elem' + if (debug_level>0) write(debug_unit,*) me,'Calling crea_ovr_elem' ! next ovrlap_elem call psi_crea_ovr_elem(cdesc%ovrlap_index,cdesc%ovrlap_elem,info) - if (debug) write(0,*) me,'Done crea_ovr_elem' + if (debug_level>0) write(debug_unit,*) me,'Done crea_ovr_elem' if(info /= 0) then call psb_errpush(4010,name,a_err='psi_crea_ovr_elem') goto 9999 @@ -398,7 +401,7 @@ contains call psb_errpush(4010,name,a_err='psi_crea_bnd_elem') goto 9999 end if - if (debug) write(0,*) me,'Done crea_bnd_elem' + if (debug_level>0) write(debug_unit,*) me,'Done crea_bnd_elem' call psb_erractionrestore(err_act) return diff --git a/base/psblas/psb_damax.f90 b/base/psblas/psb_damax.f90 index 6a887c0d..8d657ed2 100644 --- a/base/psblas/psb_damax.f90 +++ b/base/psblas/psb_damax.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -166,7 +166,7 @@ end function psb_damax ! ! Arguments: ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_damaxv (x,desc_a, info) @@ -288,7 +288,7 @@ end function psb_damaxv ! Arguments: ! res - real. The result. ! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -410,7 +410,7 @@ end subroutine psb_damaxvs ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_dmamaxs (res,x,desc_a, info,jx) diff --git a/base/psblas/psb_dasum.f90 b/base/psblas/psb_dasum.f90 index be0c24c2..7a24444c 100644 --- a/base/psblas/psb_dasum.f90 +++ b/base/psblas/psb_dasum.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -184,7 +184,7 @@ end function psb_dasum ! ! Arguments: ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_dasumv (x,desc_a, info) @@ -322,7 +322,7 @@ end function psb_dasumv ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! diff --git a/base/psblas/psb_daxpby.f90 b/base/psblas/psb_daxpby.f90 index 5670f255..1b3b7fe7 100644 --- a/base/psblas/psb_daxpby.f90 +++ b/base/psblas/psb_daxpby.f90 @@ -44,7 +44,7 @@ ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! beta - real. The scalar used to multiply each component of sub( Y ). ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset for sub( X ). ! jy - integer(optional). The column offset for sub( Y ). @@ -199,7 +199,7 @@ end subroutine psb_daxpby ! x - real,dimension(:). The input vector containing the entries of X. ! beta - real. The scalar used to multiply each component of Y. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_daxpbyv(alpha, x, beta,y,desc_a,info) @@ -220,7 +220,6 @@ subroutine psb_daxpbyv(alpha, x, beta,y,desc_a,info) integer :: ictxt, np, me,& & err_act, iix, jjx, ix, iy, m, iiy, jjy character(len=20) :: name, ch_err - logical, parameter :: debug=.false. name='psb_dgeaxpby' if(psb_get_errstatus().ne.0) return diff --git a/base/psblas/psb_ddot.f90 b/base/psblas/psb_ddot.f90 index 9d530e0f..9616bc7a 100644 --- a/base/psblas/psb_ddot.f90 +++ b/base/psblas/psb_ddot.f90 @@ -42,7 +42,7 @@ ! Arguments: ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset for sub( X ). ! jy - integer(optional). The column offset for sub( Y ). @@ -199,7 +199,7 @@ end function psb_ddot ! Arguments: ! x - real,dimension(:). The input vector containing the entries of X. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_ddotv(x, y,desc_a, info) @@ -337,7 +337,7 @@ end function psb_ddotv ! res - real. The result. ! x - real,dimension(:). The input vector containing the entries of X. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_ddotvs(res, x, y,desc_a, info) @@ -478,7 +478,7 @@ end subroutine psb_ddotvs ! res - real. The result. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_dmdots(res, x, y, desc_a, info) diff --git a/base/psblas/psb_dnrm2.f90 b/base/psblas/psb_dnrm2.f90 index a7d472cd..a5c420a5 100644 --- a/base/psblas/psb_dnrm2.f90 +++ b/base/psblas/psb_dnrm2.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset for sub( X ). ! @@ -178,7 +178,7 @@ end function psb_dnrm2 ! ! Arguments: ! x - real,dimension(:). The input vector containing the entries of X. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_dnrm2v(x, desc_a, info) @@ -313,7 +313,7 @@ end function psb_dnrm2v ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector containing the entries of X. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_dnrm2vs(res, x, desc_a, info) diff --git a/base/psblas/psb_dnrmi.f90 b/base/psblas/psb_dnrmi.f90 index a5b1d6ad..3baccb83 100644 --- a/base/psblas/psb_dnrmi.f90 +++ b/base/psblas/psb_dnrmi.f90 @@ -36,8 +36,8 @@ ! normi := max(abs(sum(A(i,j)))) ! ! Arguments: -! a - type(). The sparse matrix containing A. -! desc_a - type(). The communication descriptor. +! a - type(psb_dspmat_type). The sparse matrix containing A. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_dnrmi(a,desc_a,info) diff --git a/base/psblas/psb_dspmm.f90 b/base/psblas/psb_dspmm.f90 index b33bb371..9b0dede6 100644 --- a/base/psblas/psb_dspmm.f90 +++ b/base/psblas/psb_dspmm.f90 @@ -64,11 +64,11 @@ ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_dspmat_type). The sparse matrix containing A. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! beta - real. The scalar beta. ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! k - integer(optional). The number of right-hand sides. @@ -404,11 +404,11 @@ end subroutine psb_dspmm ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_dspmat_type). The sparse matrix containing A. ! x - real,dimension(:). The input vector containing the entries of X. ! beta - real. The scalar beta. ! y - real,dimension(:. The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! work - real,dimension(:)(optional). Working area. @@ -449,15 +449,16 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& character :: itrans character(len=20) :: name, ch_err logical :: aliw - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit name='psb_dspmv' if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_a) - call psb_info(ictxt, me, np) if (np == -1) then info = 2010 @@ -509,7 +510,7 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& liwork= 2*ncol if (a%pr(1) /= 0) liwork = liwork + n * ik if (a%pl(1) /= 0) liwork = liwork + m * ik - ! write(0,*)'---->>>',work(1) + if (present(work)) then if (size(work) >= liwork) then aliw =.false. @@ -520,7 +521,6 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& aliw=.true. end if - aliw=.true. if (aliw) then allocate(iwork(liwork),stat=info) if(info /= 0) then @@ -533,7 +533,8 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& iwork => work endif - if (debug) write(0,*) me,name,' Allocated work ', info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' Allocated work ', info ! checking for matrix correctness call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) if(info /= 0) then @@ -543,7 +544,8 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& goto 9999 end if - if (debug) write(0,*) me,name,' Checkmat ', info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' Checkmat ', info if (itrans == 'N') then ! Matrix is not transposed if((ja /= ix).or.(ia /= iy)) then @@ -624,10 +626,12 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& yp => y(iiy:lldy) yp(nrow+1:ncol)=dzero - if (debug) write(0,*) me,name,' checkvect ', info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' checkvect ', info ! local Matrix-vector product call psb_csmm(alpha,a,xp,beta,yp,info,trans=itrans) - if (debug) write(0,*) me,name,' csmm ', info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' csmm ', info if(info /= 0) then info = 4010 ch_err='dcsmm' @@ -638,7 +642,8 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& if(idoswap /= 0)& & call psi_swaptran(ior(psb_swap_send_,psb_swap_recv_),& & done,yp,desc_a,iwork,info) - if (debug) write(0,*) me,name,' swaptran ', info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' swaptran ', info if(info /= 0) then info = 4010 ch_err='PSI_dSwapTran' @@ -649,7 +654,8 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& end if if (aliw) deallocate(iwork,stat=info) - if (debug) write(0,*) me,name,' deallocat ',aliw, info + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' deallocat ',aliw, info if(info /= 0) then info = 4010 ch_err='Deallocate iwork' @@ -660,8 +666,10 @@ subroutine psb_dspmv(alpha,a,x,beta,y,desc_a,info,& nullify(iwork) call psb_erractionrestore(err_act) - if (debug) call psb_barrier(ictxt) - if (debug) write(0,*) me,name,' Returning ' + if (debug_level >= psb_debug_comp_) then + call psb_barrier(ictxt) + write(debug_unit,*) me,' ',trim(name),' Returning ' + endif return 9999 continue diff --git a/base/psblas/psb_dspsm.f90 b/base/psblas/psb_dspsm.f90 index f91270e6..860a569b 100644 --- a/base/psblas/psb_dspsm.f90 +++ b/base/psblas/psb_dspsm.f90 @@ -56,11 +56,11 @@ ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_dspmat_type). The sparse matrix containing A. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! beta - real. The scalar beta. ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! unitd - character(optional). Specify some type of operation with the diagonal matrix D. @@ -366,11 +366,11 @@ end subroutine psb_dspsm ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_dspmat_type). The sparse matrix containing A. ! x - real,dimension(:). The input vector containing the entries of X. ! beta - real. The scalar beta. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! unitd - character(optional). Specify some type of operation with the diagonal matrix D. diff --git a/base/psblas/psb_zamax.f90 b/base/psblas/psb_zamax.f90 index 5daef01b..16ab18ca 100644 --- a/base/psblas/psb_zamax.f90 +++ b/base/psblas/psb_zamax.f90 @@ -28,9 +28,9 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_damax.f90 +! File: psb_zamax.f90 ! -! Function: psb_damax +! Function: psb_zamax ! Searches the absolute max of X. ! ! normi := max(abs(sub(X)(i)) @@ -38,8 +38,8 @@ ! where sub( X ) denotes X(1:N,JX:). ! ! Arguments: -! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! x - complex,dimension(:,:). The input vector. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -169,7 +169,7 @@ end function psb_zamax ! ! Arguments: ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_zamaxv (x,desc_a, info) @@ -296,7 +296,7 @@ end function psb_zamaxv ! Arguments: ! res - real. The result. ! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -422,7 +422,7 @@ end subroutine psb_zamaxvs ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_zmamaxs (res,x,desc_a, info,jx) diff --git a/base/psblas/psb_zasum.f90 b/base/psblas/psb_zasum.f90 index 50d229e2..e453b2c2 100644 --- a/base/psblas/psb_zasum.f90 +++ b/base/psblas/psb_zasum.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! @@ -189,7 +189,7 @@ end function psb_zasum ! ! Arguments: ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_zasumv (x,desc_a, info) @@ -333,7 +333,7 @@ end function psb_zasumv ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset. ! diff --git a/base/psblas/psb_zaxpby.f90 b/base/psblas/psb_zaxpby.f90 index 558a018f..81361649 100644 --- a/base/psblas/psb_zaxpby.f90 +++ b/base/psblas/psb_zaxpby.f90 @@ -28,9 +28,9 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_daxpby.f90 +! File: psb_zaxpby.f90 ! -! Subroutine: psb_daxpby +! Subroutine: psb_zaxpby ! Adds one distributed matrix to another, ! ! sub( Y ) := beta * sub( Y ) + alpha * sub( X ) @@ -40,14 +40,14 @@ ! sub( Y ) denotes Y(:,JY). ! ! Arguments: -! alpha - real. The scalar used to multiply each component of sub( X ). -! x - real,dimension(:,:). The input vector containing the entries of sub( X ). -! beta - real. The scalar used to multiply each component of sub( Y ). -! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. -! info - integer. Return code -! jx - integer(optional). The column offset for sub( X ). -! jy - integer(optional). The column offset for sub( Y ). +! alpha - complex,input The scalar used to multiply each component of X +! x(:,:) - complex,input The input vector containing the entries of X +! beta - real,input The scalar used to multiply each component of Y +! y(:,:) - real,inout The input vector Y +! desc_a - type(psb_desc_type) The communication descriptor. +! info - integer Return code +! jx - integer(optional) The column offset for X +! jy - integer(optional) The column offset for Y ! subroutine psb_zaxpby(alpha, x, beta,y,desc_a,info, n, jx, jy) use psb_descriptor_type @@ -188,18 +188,19 @@ end subroutine psb_zaxpby !!$ !!$ ! -! Subroutine: psb_dgeaxpbyv +! Subroutine: psb_zgeaxpbyv ! Adds one distributed matrix to another, ! ! Y := beta * Y + alpha * X ! ! Arguments: -! alpha - real. The scalar used to multiply each component of X. -! x - real,dimension(:). The input vector containing the entries of X. -! beta - real. The scalar used to multiply each component of Y. -! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. -! info - integer. Return code +! alpha - complex,input The scalar used to multiply each component of X +! x(:) - complex,input The input vector containing the entries of X +! beta - real,input The scalar used to multiply each component of Y +! y(:) - real,inout The input vector Y +! desc_a - type(psb_desc_type) The communication descriptor. +! info - integer Return code +! ! subroutine psb_zaxpbyv(alpha, x, beta,y,desc_a,info) use psb_descriptor_type diff --git a/base/psblas/psb_zdot.f90 b/base/psblas/psb_zdot.f90 index 44d66e22..dd161baa 100644 --- a/base/psblas/psb_zdot.f90 +++ b/base/psblas/psb_zdot.f90 @@ -42,7 +42,7 @@ ! Arguments: ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset for sub( X ). ! jy - integer(optional). The column offset for sub( Y ). @@ -198,7 +198,7 @@ end function psb_zdot ! Arguments: ! x - real,dimension(:). The input vector containing the entries of X. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_zdotv(x, y,desc_a, info) @@ -336,7 +336,7 @@ end function psb_zdotv ! res - real. The result. ! x - real,dimension(:). The input vector containing the entries of X. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_zdotvs(res, x, y,desc_a, info) @@ -476,7 +476,7 @@ end subroutine psb_zdotvs ! res - real. The result. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_zmdots(res, x, y, desc_a, info) diff --git a/base/psblas/psb_znrm2.f90 b/base/psblas/psb_znrm2.f90 index b47241f3..c0ec0c03 100644 --- a/base/psblas/psb_znrm2.f90 +++ b/base/psblas/psb_znrm2.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! jx - integer(optional). The column offset for sub( X ). ! @@ -177,7 +177,7 @@ end function psb_znrm2 ! ! Arguments: ! x - real,dimension(:). The input vector containing the entries of X. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_znrm2v(x, desc_a, info) @@ -312,7 +312,7 @@ end function psb_znrm2v ! Arguments: ! res - real. The result. ! x - real,dimension(:). The input vector containing the entries of X. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! subroutine psb_znrm2vs(res, x, desc_a, info) diff --git a/base/psblas/psb_znrmi.f90 b/base/psblas/psb_znrmi.f90 index 9b4410c5..26a95268 100644 --- a/base/psblas/psb_znrmi.f90 +++ b/base/psblas/psb_znrmi.f90 @@ -36,8 +36,8 @@ ! normi := max(abs(sum(A(i,j)))) ! ! Arguments: -! a - type(). The sparse matrix containing A. -! desc_a - type(). The communication descriptor. +! a - type(psb_dspmat_type). The sparse matrix containing A. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! function psb_znrmi(a,desc_a,info) diff --git a/base/psblas/psb_zspmm.f90 b/base/psblas/psb_zspmm.f90 index d123753c..bd35d059 100644 --- a/base/psblas/psb_zspmm.f90 +++ b/base/psblas/psb_zspmm.f90 @@ -64,11 +64,11 @@ ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_zspmat_type). The sparse matrix containing A. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! beta - real. The scalar beta. ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! k - integer(optional). The number of right-hand sides. @@ -398,11 +398,11 @@ end subroutine psb_zspmm ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_zspmat_type). The sparse matrix containing A. ! x - real,dimension(:). The input vector containing the entries of X. ! beta - real. The scalar beta. ! y - real,dimension(:. The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! work - real,dimension(:)(optional). Working area. @@ -443,11 +443,14 @@ subroutine psb_zspmv(alpha,a,x,beta,y,desc_a,info,& character :: itrans character(len=20) :: name, ch_err logical :: aliw + integer :: debug_level, debug_unit name='psb_zspmv' if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) @@ -467,9 +470,9 @@ subroutine psb_zspmv(alpha,a,x,beta,y,desc_a,info,& ib = 1 if (present(doswap)) then - idoswap = doswap + idoswap = doswap else - idoswap = 1 + idoswap = 1 endif if (present(trans)) then @@ -481,7 +484,7 @@ subroutine psb_zspmv(alpha,a,x,beta,y,desc_a,info,& goto 9999 end if else - itrans = 'N' + itrans = 'N' endif m = psb_cd_get_global_rows(desc_a) @@ -496,18 +499,17 @@ subroutine psb_zspmv(alpha,a,x,beta,y,desc_a,info,& liwork= 2*ncol if (a%pr(1) /= 0) liwork = liwork + n * ik if (a%pl(1) /= 0) liwork = liwork + m * ik - ! write(0,*)'---->>>',work(1) - if (present(work)) then + + if (present(work)) then if (size(work) >= liwork) then - aliw =.false. + aliw =.false. else - aliw=.true. + aliw=.true. endif else - aliw=.true. + aliw=.true. end if - aliw=.true. if (aliw) then allocate(iwork(liwork),stat=info) if(info /= 0) then @@ -517,136 +519,153 @@ subroutine psb_zspmv(alpha,a,x,beta,y,desc_a,info,& goto 9999 end if else - iwork => work + iwork => work endif - + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' Allocated work ', info ! checking for matrix correctness call psb_chkmat(m,n,ia,ja,desc_a,info,iia,jja) if(info /= 0) then - info=4010 - ch_err='psb_chkmat' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 + info=4010 + ch_err='psb_chkmat' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 end if - + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' Checkmat ', info if (itrans == 'N') then - ! Matrix is not transposed - if((ja /= ix).or.(ia /= iy)) then - ! this case is not yet implemented - info = 3030 - call psb_errpush(info,name) - goto 9999 - end if - - ! checking for vectors correctness - call psb_chkvect(n,ik,size(x),ix,jx,desc_a,info,iix,jjx) - if (info == 0) & - & call psb_chkvect(m,ik,size(y),iy,jy,desc_a,info,iiy,jjy) - if(info /= 0) then - info=4010 - ch_err='psb_chkvect' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if((iix /= 1).or.(iiy /= 1)) then - ! this case is not yet implemented - info = 3040 - call psb_errpush(info,name) - goto 9999 - end if - - if (idoswap == 0) then - x(nrow+1:ncol)=zzero - else - call psi_swapdata(ior(psb_swap_send_,psb_swap_recv_),& - & zzero,x,desc_a,iwork,info,data=psb_comm_halo_) - end if - - ! local Matrix-vector product - call psb_csmm(alpha,a,x(iix:lldx),beta,y(iiy:lldy),info) - - if(info /= 0) then - info = 4011 - call psb_errpush(info,name) - goto 9999 - end if + ! Matrix is not transposed + if((ja /= ix).or.(ia /= iy)) then + ! this case is not yet implemented + info = 3030 + call psb_errpush(info,name) + goto 9999 + end if + + ! checking for vectors correctness + call psb_chkvect(n,ik,size(x),ix,jx,desc_a,info,iix,jjx) + if (info == 0) & + & call psb_chkvect(m,ik,size(y),iy,jy,desc_a,info,iiy,jjy) + if(info /= 0) then + info=4010 + ch_err='psb_chkvect' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if((iix /= 1).or.(iiy /= 1)) then + ! this case is not yet implemented + info = 3040 + call psb_errpush(info,name) + goto 9999 + end if + + if (idoswap == 0) then + x(nrow+1:ncol)=zzero + else + call psi_swapdata(ior(psb_swap_send_,psb_swap_recv_),& + & zzero,x,desc_a,iwork,info,data=psb_comm_halo_) + end if + + ! local Matrix-vector product + call psb_csmm(alpha,a,x(iix:lldx),beta,y(iiy:lldy),info) + + if(info /= 0) then + info = 4011 + call psb_errpush(info,name) + goto 9999 + end if else - ! Matrix is transposed - if((ja /= iy).or.(ia /= ix)) then - ! this case is not yet implemented - info = 3030 - call psb_errpush(info,name) - goto 9999 - end if - - if(desc_a%ovrlap_elem(1) /= -1) then - info = 3070 - call psb_errpush(info,name) - goto 9999 - end if - - ! checking for vectors correctness - call psb_chkvect(m,ik,size(x),ix,jx,desc_a,info,iix,jjx) - if (info == 0)& - & call psb_chkvect(n,ik,size(y),iy,jy,desc_a,info,iiy,jjy) - if(info /= 0) then - info=4010 - ch_err='psb_chkvect' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if((iix /= 1).or.(iiy /= 1)) then - ! this case is not yet implemented - info = 3040 - call psb_errpush(info,name) - goto 9999 - end if - - xp => x(iix:lldx) - yp => y(iiy:lldy) - - yp(nrow+1:ncol)=zzero - - ! local Matrix-vector product - call psb_csmm(alpha,a,xp,beta,yp,info,trans=itrans) - - if(info /= 0) then - info = 4010 - ch_err='dcsmm' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if(idoswap /= 0)& - & call psi_swaptran(ior(psb_swap_send_,psb_swap_recv_),& - & zone,yp,desc_a,iwork,info) - if(info /= 0) then - info = 4010 - ch_err='PSI_dSwapTran' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if + ! Matrix is transposed + if((ja /= iy).or.(ia /= ix)) then + ! this case is not yet implemented + info = 3030 + call psb_errpush(info,name) + goto 9999 + end if + + if(desc_a%ovrlap_elem(1) /= -1) then + info = 3070 + call psb_errpush(info,name) + goto 9999 + end if + + ! checking for vectors correctness + call psb_chkvect(m,ik,size(x),ix,jx,desc_a,info,iix,jjx) + if (info == 0)& + & call psb_chkvect(n,ik,size(y),iy,jy,desc_a,info,iiy,jjy) + if(info /= 0) then + info=4010 + ch_err='psb_chkvect' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if((iix /= 1).or.(iiy /= 1)) then + ! this case is not yet implemented + info = 3040 + call psb_errpush(info,name) + goto 9999 + end if + + xp => x(iix:lldx) + yp => y(iiy:lldy) + + yp(nrow+1:ncol)=zzero + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' checkvect ', info + ! local Matrix-vector product + call psb_csmm(alpha,a,xp,beta,yp,info,trans=itrans) + + if(info /= 0) then + info = 4010 + ch_err='zcsmm' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + + if(idoswap /= 0)& + & call psi_swaptran(ior(psb_swap_send_,psb_swap_recv_),& + & zone,yp,desc_a,iwork,info) + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' swaptran ', info + if(info /= 0) then + info = 4010 + ch_err='PSI_dSwapTran' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if end if - if(aliw) deallocate(iwork) + if (aliw) deallocate(iwork,stat=info) + if (debug_level >= psb_debug_comp_) & + & write(debug_unit,*) me,' ',trim(name),' deallocat ',aliw, info + if(info /= 0) then + info = 4010 + ch_err='Deallocate iwork' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + nullify(iwork) call psb_erractionrestore(err_act) - + if (debug_level >= psb_debug_comp_) then + call psb_barrier(ictxt) + write(debug_unit,*) me,' ',trim(name),' Returning ' + endif return 9999 continue call psb_erractionrestore(err_act) if (err_act == psb_act_abort_) then - call psb_error(ictxt) - return + call psb_error(ictxt) + return end if return end subroutine psb_zspmv diff --git a/base/psblas/psb_zspsm.f90 b/base/psblas/psb_zspsm.f90 index f2c69937..694e30cf 100644 --- a/base/psblas/psb_zspsm.f90 +++ b/base/psblas/psb_zspsm.f90 @@ -56,11 +56,11 @@ ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_zspmat_type). The sparse matrix containing A. ! x - real,dimension(:,:). The input vector containing the entries of sub( X ). ! beta - real. The scalar beta. ! y - real,dimension(:,:). The input vector containing the entries of sub( Y ). -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! unitd - character(optional). Specify some type of operation with the diagonal matrix D. @@ -369,11 +369,11 @@ end subroutine psb_zspsm ! ! Arguments: ! alpha - real. The scalar alpha. -! a - type(). The sparse matrix containing A. +! a - type(psb_zspmat_type). The sparse matrix containing A. ! x - real,dimension(:). The input vector containing the entries of X. ! beta - real. The scalar beta. ! y - real,dimension(:). The input vector containing the entries of Y. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! trans - character(optional). Whether A or A'. If not present 'N' is assumed. ! unitd - character(optional). Specify some type of operation with the diagonal matrix D. diff --git a/base/serial/aux/dasr.f90 b/base/serial/aux/dasr.f90 index 788e2efc..969d7a2b 100644 --- a/base/serial/aux/dasr.f90 +++ b/base/serial/aux/dasr.f90 @@ -69,7 +69,6 @@ subroutine dasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -194,7 +193,6 @@ subroutine dasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/dasrx.f90 b/base/serial/aux/dasrx.f90 index f97a660b..a90d62f1 100644 --- a/base/serial/aux/dasrx.f90 +++ b/base/serial/aux/dasrx.f90 @@ -81,7 +81,6 @@ subroutine dasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -220,7 +219,6 @@ subroutine dasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/dsr.f90 b/base/serial/aux/dsr.f90 index 14194f99..5a92ea7b 100644 --- a/base/serial/aux/dsr.f90 +++ b/base/serial/aux/dsr.f90 @@ -69,7 +69,6 @@ subroutine dsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -194,7 +193,6 @@ subroutine dsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/dsrx.f90 b/base/serial/aux/dsrx.f90 index f5c23fe5..f8d9e87c 100644 --- a/base/serial/aux/dsrx.f90 +++ b/base/serial/aux/dsrx.f90 @@ -81,7 +81,6 @@ subroutine dsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -221,7 +220,6 @@ subroutine dsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/iasr.f90 b/base/serial/aux/iasr.f90 index 07c7d940..b19610eb 100644 --- a/base/serial/aux/iasr.f90 +++ b/base/serial/aux/iasr.f90 @@ -69,7 +69,6 @@ subroutine iasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -194,7 +193,6 @@ subroutine iasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/iasrx.f90 b/base/serial/aux/iasrx.f90 index 99f990b4..113841ce 100644 --- a/base/serial/aux/iasrx.f90 +++ b/base/serial/aux/iasrx.f90 @@ -81,7 +81,6 @@ subroutine iasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -220,7 +219,6 @@ subroutine iasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/imsru.f90 b/base/serial/aux/imsru.f90 index 914cd236..15f434fb 100644 --- a/base/serial/aux/imsru.f90 +++ b/base/serial/aux/imsru.f90 @@ -42,7 +42,6 @@ subroutine imsru(n,x,idir,nout) nout = 0 if (n<0) then -!!$ write(0,*) 'Error: IMSR: N<0' return endif diff --git a/base/serial/aux/isr.f90 b/base/serial/aux/isr.f90 index 20ac8156..219bcac4 100644 --- a/base/serial/aux/isr.f90 +++ b/base/serial/aux/isr.f90 @@ -69,7 +69,6 @@ subroutine isr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -194,7 +193,6 @@ subroutine isr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/isrx.f90 b/base/serial/aux/isrx.f90 index bf65d491..410c9de7 100644 --- a/base/serial/aux/isrx.f90 +++ b/base/serial/aux/isrx.f90 @@ -80,7 +80,6 @@ subroutine isrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -221,7 +220,6 @@ subroutine isrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zalsr.f90 b/base/serial/aux/zalsr.f90 index 257e90e9..a01a20d9 100644 --- a/base/serial/aux/zalsr.f90 +++ b/base/serial/aux/zalsr.f90 @@ -70,7 +70,6 @@ subroutine zalsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -195,7 +194,6 @@ subroutine zalsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zalsrx.f90 b/base/serial/aux/zalsrx.f90 index 9fd57339..9857bf1f 100644 --- a/base/serial/aux/zalsrx.f90 +++ b/base/serial/aux/zalsrx.f90 @@ -82,7 +82,6 @@ subroutine zalsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -223,7 +222,6 @@ subroutine zalsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zasr.f90 b/base/serial/aux/zasr.f90 index 36c0059c..53441ce9 100644 --- a/base/serial/aux/zasr.f90 +++ b/base/serial/aux/zasr.f90 @@ -70,7 +70,6 @@ subroutine zasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -195,7 +194,6 @@ subroutine zasr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zasrx.f90 b/base/serial/aux/zasrx.f90 index 935d2615..9be9a176 100644 --- a/base/serial/aux/zasrx.f90 +++ b/base/serial/aux/zasrx.f90 @@ -82,7 +82,6 @@ subroutine zasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -223,7 +222,6 @@ subroutine zasrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zlsr.f90 b/base/serial/aux/zlsr.f90 index 193b11c0..ba4336ed 100644 --- a/base/serial/aux/zlsr.f90 +++ b/base/serial/aux/zlsr.f90 @@ -70,7 +70,6 @@ subroutine zlsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -195,7 +194,6 @@ subroutine zlsr(n,x,dir) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/aux/zlsrx.f90 b/base/serial/aux/zlsrx.f90 index 0f7e6fa3..457949ff 100644 --- a/base/serial/aux/zlsrx.f90 +++ b/base/serial/aux/zlsrx.f90 @@ -82,7 +82,6 @@ subroutine zlsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location @@ -223,7 +222,6 @@ subroutine zlsrx(n,x,indx,dir,flag) ilx = istack(1,istp) iux = istack(2,istp) istp = istp - 1 - !$$$ write(0,*) 'Debug 1: ',ilx,iux ! ! Choose a pivot with median-of-three heuristics, leave it ! in the LPIV location diff --git a/base/serial/coo/Makefile b/base/serial/coo/Makefile index 6b3ca95e..7b29f679 100644 --- a/base/serial/coo/Makefile +++ b/base/serial/coo/Makefile @@ -3,7 +3,7 @@ include ../../../Make.inc # # The object files # -FOBJS = dcooprt.o dcoonrmi.o dcoomm.o dcoomv.o dcoosm.o dcoosv.o dcoorws.o\ +FOBJS = dcoonrmi.o dcoomm.o dcoomv.o dcoosm.o dcoosv.o dcoorws.o\ zcoomm.o zcoomv.o zcoonrmi.o zcoorws.o zcoosm.o zcoosv.o diff --git a/base/serial/coo/dcooprt.f b/base/serial/coo/dcooprt.f deleted file mode 100644 index d6db91a9..00000000 --- a/base/serial/coo/dcooprt.f +++ /dev/null @@ -1,80 +0,0 @@ -C -C Parallel Sparse BLAS v2.0 -C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata -C Alfredo Buttari University of Rome Tor Vergata -C -C Redistribution and use in source and binary forms, with or without -C modification, are permitted provided that the following conditions -C are met: -C 1. Redistributions of source code must retain the above copyright -C notice, this list of conditions and the following disclaimer. -C 2. Redistributions in binary form must reproduce the above copyright -C notice, this list of conditions, and the following disclaimer in the -C documentation and/or other materials provided with the distribution. -C 3. The name of the PSBLAS group or the names of its contributors may -C not be used to endorse or promote products derived from this -C software without specific written permission. -C -C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS -C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -C POSSIBILITY OF SUCH DAMAGE. -C -C -c -c What if a wrong DESCRA is passed? -c -c - SUBROUTINE DCOOPRT(M,N,DESCRA,AR,IA,JA,INFOA,TITLE,IOUT) -C -C -C .. Scalar Arguments .. - INTEGER M, N, IOUT -C .. Array Arguments .. - DOUBLE PRECISION AR(*) - INTEGER IA(*), JA(*),INFOA(*) - CHARACTER DESCRA*11, TITLE*(*) -C .. Local Scalars .. - INTEGER J - - -C .. External Subroutines .. -C -C - if ((descra(1:1).eq.'g').or.(descra(1:1).eq.'G')) then - write(iout,fmt=998) - else if ((descra(1:1).eq.'s').or.(descra(1:1).eq.'S')) then - write(iout,fmt=997) - else - write(iout,fmt=998) - endif - nnzero = infoa(1) - write(iout,fmt=992) - write(iout,fmt=996) - write(iout,fmt=996) title - write(iout,fmt=995) 'Number of rows: ',m - write(iout,fmt=995) 'Number of columns: ',n - write(iout,fmt=995) 'Nonzero entries: ',nnzero - write(iout,fmt=996) - write(iout,fmt=992) - write(iout,*) m,n,nnzero - 998 format('%%MatrixMarket matrix coordinate real general') - 997 format('%%MatrixMarket matrix coordinate real symmetric') - 992 format('%======================================== ') - 996 format('% ',a) - 995 format('% ',a,i9,a,i9,a,i9) - do j=1,nnzero - write(iout,fmt=994) ia(j),ja(j),ar(j) - 994 format(i6,1x,i6,1x,e16.8) - enddo - - - RETURN - END diff --git a/base/serial/coo/dcoosm.f b/base/serial/coo/dcoosm.f index 05114e50..14831c04 100644 --- a/base/serial/coo/dcoosm.f +++ b/base/serial/coo/dcoosm.f @@ -30,9 +30,8 @@ C C SUBROUTINE DCOOSM(TRANST,M,N,UNITD,D,ALPHA,DESCRA,A,IA,JA,INFOA, * B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) + use psb_error_mod IMPLICIT NONE - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) DOUBLE PRECISION ALPHA, BETA INTEGER LDB, LDC, LWORK, M, N, IERROR CHARACTER UNITD, TRANST @@ -43,18 +42,21 @@ C CHARACTER DIAG, UPLO INTRINSIC DBLE, IDINT CHARACTER*20 NAME + integer :: debug_level, debug_unit - NAME = 'DCOOSM\0' + NAME = 'ZCOOSM\0' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF((ALPHA.NE.1.D0) .OR. (BETA.NE.0.D0))then IERROR=5 CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) GOTO 9999 ENDIF - if (debug) write(*,*) 'DCOOSM ',m - if (debug) write(*,*) 'DCOOSM ',m,ierror + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),':' ,m,ierror UPLO = '?' IF (DESCRA(1:1).EQ.'T' .AND. DESCRA(2:2).EQ.'U') UPLO = 'U' diff --git a/base/serial/coo/dcoosv.f b/base/serial/coo/dcoosv.f index b6138444..a02d2ae7 100644 --- a/base/serial/coo/dcoosv.f +++ b/base/serial/coo/dcoosv.f @@ -34,10 +34,9 @@ C "right" place, i.e. the last in its row for Lower and the first C for Upper. C SUBROUTINE DCOOSV (UPLO,TRANS,DIAG,N,AS,IA,JA,INFOA,B,X,IERROR) + use psb_error_mod DOUBLE PRECISION ZERO PARAMETER (ZERO=0.0D0) - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) INTEGER N,IERROR CHARACTER DIAG, TRANS, UPLO DOUBLE PRECISION AS(*), B(*), X(*) @@ -45,120 +44,129 @@ C DOUBLE PRECISION ACC INTEGER I, J, K, NNZ, II LOGICAL LOW, TRA, UNI - if (debug) write(*,*) 'DCOOSV ',n - if (debug) write(*,*) 'DCOOSV ',n,nnz,diag,trans,uplo + integer :: debug_level, debug_unit + character(len=20) :: name='dcoosv' + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + UNI = (DIAG.EQ.'U') TRA = (TRANS.EQ.'T') LOW = (UPLO.EQ.'L') NNZ = INFOA(1) - if (debug) write(*,*) 'DCOOSV ',n,nnz,uni,tra,low,ia(1),ja(1) IERROR = 0 - if (debug) write(*,*) 'DCOOSV ierror ',ierror + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),':',n,nnz,diag,trans,uplo IF ( .NOT. TRA) THEN - if (debug) write(*,*) 'DCOOSV NOT TRA' - IF (LOW) THEN - if (debug) write(*,*) 'DCOOSV LOW' - IF ( .NOT. UNI) THEN - if (debug) write(*,*) 'DCOOSV NOT UNI' - I = 1 - J = I - DO WHILE (I.LE.NNZ) + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT TRA' + IF (LOW) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': LOW' + IF ( .NOT. UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT UNI' + I = 1 + J = I + DO WHILE (I.LE.NNZ) + DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) + J = J+1 + ENDDO + ACC = ZERO + IR = IA(I) + DO K = I, J-2 + JC = JA(K) + ACC = ACC + AS(K)*X(JC) + ENDDO + X(IR) = (B(IR)-ACC)/AS(J-1) + I = J + ENDDO + + ELSE IF (UNI) THEN +C +C Bug warning: if UNI, some rows might be empty +C + I = 1 + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': UNILOW ', + + i,n,nnz,uni,tra,low + DO II = 1, N + DO WHILE ((I.LE.NNZ).AND.(IA(I).LT.II)) + I = I + 1 + ENDDO + ACC = ZERO + IF ((I.LE.NNZ).AND.(IA(I).EQ.II)) THEN + J = I + 1 DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) J = J+1 ENDDO - ACC = ZERO - IR = IA(I) - DO K = I, J-2 + DO K = I, J-1 JC = JA(K) ACC = ACC + AS(K)*X(JC) ENDDO - X(IR) = (B(IR)-ACC)/AS(J-1) - I = J - ENDDO + ELSE + J = I + ENDIF + X(II) = (B(II)-ACC) + I = J + ENDDO - ELSE IF (UNI) THEN -C -C Bug warning: if UNI, some rows might be empty -C - I = 1 - if (debug) write(*,*) 'DCOOSV UNILOW ', - + i,n,nnz,uni,tra,low - DO II = 1, N - if (debug) write(*,*) 'Loop1 COOSV',i,j,ii,x(ii),b(ii) - DO WHILE ((I.LE.NNZ).AND.(IA(I).LT.II)) - I = I + 1 -c$$$ if (debug) write(*,*) 'Loop2 COOSV',i,ia(i),ii - ENDDO - ACC = ZERO - IF ((I.LE.NNZ).AND.(IA(I).EQ.II)) THEN - J = I + 1 - DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) - J = J+1 - ENDDO - DO K = I, J-1 - JC = JA(K) - ACC = ACC + AS(K)*X(JC) - ENDDO - ELSE - J = I - ENDIF - X(II) = (B(II)-ACC) - if (debug) write(*,*) 'Loop COOSV',i,j,ii,x(ii),b(ii) - I = J - ENDDO + END IF - END IF + ELSE IF ( .NOT. LOW) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT LOW' + IF ( .NOT. UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT UNI' + I = NNZ + J = NNZ + DO WHILE (I.GT.0) + DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) + J = J-1 + ENDDO + ACC = ZERO + IR = IA(I) + DO K = I, J+2,-1 + JC = JA(K) + ACC = ACC + AS(K)*X(JC) + ENDDO + X(IR) = (B(IR)-ACC)/AS(J+1) + I = J + ENDDO - ELSE IF ( .NOT. LOW) THEN - if (debug) write(*,*) 'DCOOSV NOT LOW' - IF ( .NOT. UNI) THEN - if (debug) write(*,*) 'DCOOSV NOT UNI' - I = NNZ - J = NNZ - DO WHILE (I.GT.0) - DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) + ELSE IF (UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': UNI' + I = NNZ + DO II = N,1,-1 + DO WHILE ((I.GT.0).AND.(IA(I).GT.II)) + I = I -1 + ENDDO + ACC = ZERO + IF ((I.GT.0).AND.(IA(I).EQ.II)) THEN + J = I - 1 + DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) J = J-1 ENDDO - ACC = ZERO - IR = IA(I) - DO K = I, J+2,-1 + DO K = I, J+1, -1 JC = JA(K) ACC = ACC + AS(K)*X(JC) - ENDDO - X(IR) = (B(IR)-ACC)/AS(J+1) - I = J - ENDDO - - ELSE IF (UNI) THEN - if (debug) write(*,*) 'DCOOSV UNI' - I = NNZ - DO II = N,1,-1 - DO WHILE ((I.GT.0).AND.(IA(I).GT.II)) - I = I -1 - ENDDO - ACC = ZERO - IF ((I.GT.0).AND.(IA(I).EQ.II)) THEN - J = I - 1 - DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) - J = J-1 - ENDDO - DO K = I, J+1, -1 - JC = JA(K) - ACC = ACC + AS(K)*X(JC) - ENDDO - ELSE - J = I - ENDIF - X(II) = (B(II)-ACC) - if (debug) write(*,*) 'Loop COOSV',i,j,ii,x(ii),b(ii) - I = J - ENDDO + ENDDO + ELSE + J = I + ENDIF + X(II) = (B(II)-ACC) + I = J + ENDDO - END IF + END IF - END IF + END IF ELSE IF (TRA) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': TRA' IERROR = 3010 return CCCCCCCCCCCCCCCC @@ -166,48 +174,48 @@ C C TBF C CCCCCCCCCCCCCCCC - DO 180 I = 1, N - X(I) = B(I) - 180 CONTINUE - IF (LOW) THEN - IF ( .NOT. UNI) THEN - DO 220 I = N, 1, -1 - X(I) = X(I)/AS(IA(I+1)-1) - ACC = X(I) - DO 200 J = IA(I), IA(I+1) - 2 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 200 CONTINUE - 220 CONTINUE - ELSE IF (UNI) THEN - DO 260 I = N, 1, -1 - ACC = X(I) - DO 240 J = IA(I), IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 240 CONTINUE - 260 CONTINUE - END IF - ELSE IF ( .NOT. LOW) THEN - IF ( .NOT. UNI) THEN - DO 300 I = 1, N - X(I) = X(I)/AS(IA(I)) - ACC = X(I) - DO 280 J = IA(I) + 1, IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 280 CONTINUE - 300 CONTINUE - ELSE IF (UNI) THEN - DO 340 I = 1, N - ACC = X(I) - DO 320 J = IA(I), IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 320 CONTINUE - 340 CONTINUE - END IF - END IF + DO 180 I = 1, N + X(I) = B(I) + 180 CONTINUE + IF (LOW) THEN + IF ( .NOT. UNI) THEN + DO 220 I = N, 1, -1 + X(I) = X(I)/AS(IA(I+1)-1) + ACC = X(I) + DO 200 J = IA(I), IA(I+1) - 2 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 200 CONTINUE + 220 CONTINUE + ELSE IF (UNI) THEN + DO 260 I = N, 1, -1 + ACC = X(I) + DO 240 J = IA(I), IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 240 CONTINUE + 260 CONTINUE + END IF + ELSE IF ( .NOT. LOW) THEN + IF ( .NOT. UNI) THEN + DO 300 I = 1, N + X(I) = X(I)/AS(IA(I)) + ACC = X(I) + DO 280 J = IA(I) + 1, IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 280 CONTINUE + 300 CONTINUE + ELSE IF (UNI) THEN + DO 340 I = 1, N + ACC = X(I) + DO 320 J = IA(I), IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 320 CONTINUE + 340 CONTINUE + END IF + END IF END IF RETURN END diff --git a/base/serial/coo/zcoomm.f b/base/serial/coo/zcoomm.f index 30a1ad20..37dcc151 100644 --- a/base/serial/coo/zcoomm.f +++ b/base/serial/coo/zcoomm.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C c c What if a wrong DESCRA is passed? c diff --git a/base/serial/coo/zcoomv.f b/base/serial/coo/zcoomv.f index 9eb1a7ce..6c249761 100644 --- a/base/serial/coo/zcoomv.f +++ b/base/serial/coo/zcoomv.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C *********************************************************************** * ZCOOMV. Prolog to be updated. * * * diff --git a/base/serial/coo/zcoonrmi.f b/base/serial/coo/zcoonrmi.f index 858f9e36..5eac4443 100644 --- a/base/serial/coo/zcoonrmi.f +++ b/base/serial/coo/zcoonrmi.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C C ... Compute Infinity norm for sparse matrix in CSR Format ... DOUBLE PRECISION FUNCTION ZCOONRMI(TRANS,M,N,DESCRA,A,IA1,IA2, + INFOA,IERROR) diff --git a/base/serial/coo/zcoorws.f b/base/serial/coo/zcoorws.f index e332e7b3..ec756ec7 100644 --- a/base/serial/coo/zcoorws.f +++ b/base/serial/coo/zcoorws.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C SUBROUTINE ZCOORWS(TRANS,M,N,DESCRA,A,IA1,IA2, & INFOA,ROWSUM,IERROR) IMPLICIT NONE diff --git a/base/serial/coo/zcoosm.f b/base/serial/coo/zcoosm.f index 3560fff1..4ef70a33 100644 --- a/base/serial/coo/zcoosm.f +++ b/base/serial/coo/zcoosm.f @@ -1,36 +1,77 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C +C SUBROUTINE ZCOOSM(TRANST,M,N,UNITD,D,ALPHA,DESCRA,A,IA,JA,INFOA, * B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) - COMPLEX*16 ALPHA, BETA + use psb_error_mod + IMPLICIT NONE + COMPLEX*16 ALPHA, BETA INTEGER LDB, LDC, LWORK, M, N, IERROR CHARACTER UNITD, TRANST COMPLEX*16 A(*), B(LDB,*), C(LDC,*), D(*), WORK(*) - INTEGER IA(*), JA(*), INFOA(*) + INTEGER IA(*), JA(*), INFOA(*), INT_VAL(5) CHARACTER DESCRA*11 - INTEGER I, K + INTEGER I, K, ERR_ACT CHARACTER DIAG, UPLO - EXTERNAL XERBLA + INTRINSIC DBLE, IDINT + CHARACTER*20 NAME + integer :: debug_level, debug_unit + + NAME = 'DCOOSM\0' + IERROR = 0 + CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF((ALPHA.NE.1.D0) .OR. (BETA.NE.0.D0))then - call xerbla('DCSSM ',9) - RETURN + IERROR=5 + CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) + GOTO 9999 ENDIF - if (debug) write(*,*) 'ZCOOSM ',m - if (debug) write(*,*) 'ZCOOSM ',m,ierror + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),':' ,m,ierror UPLO = '?' IF (DESCRA(1:1).EQ.'T' .AND. DESCRA(2:2).EQ.'U') UPLO = 'U' IF (DESCRA(1:1).EQ.'T' .AND. DESCRA(2:2).EQ.'L') UPLO = 'L' IF (UPLO.EQ.'?') THEN - CALL XERBLA('ZCSSM ',10) - RETURN + IERROR=5 + CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) + GOTO 9999 END IF IF (DESCRA(3:3).EQ.'N') DIAG = 'N' IF (DESCRA(3:3).EQ.'U') DIAG = 'U' IF(UNITD.EQ.'B') THEN - CALL XERBLA('ZCSSM ',11) - RETURN + IERROR=5 + CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) + GOTO 9999 ENDIF IF (UNITD.EQ.'R') THEN DO 40 I = 1, N @@ -44,6 +85,12 @@ CALL ZCOOSV(UPLO,TRANST,DIAG,M,A,IA,JA,INFOA, + B(1,I),C(1,I),IERROR) 60 CONTINUE + IF(IERROR.NE.0) THEN + INT_VAL(1)=IERROR + CALL FCPSB_ERRPUSH(4012,NAME,INT_VAL) + GOTO 9999 + END IF + IF (UNITD.EQ.'L') THEN DO 45 I = 1, N DO 25 K = 1, M @@ -51,5 +98,16 @@ 25 CONTINUE 45 CONTINUE END IF + CALL FCPSB_ERRACTIONRESTORE(ERR_ACT) + RETURN + + 9999 CONTINUE + CALL FCPSB_ERRACTIONRESTORE(ERR_ACT) + + IF ( ERR_ACT .NE. 0 ) THEN + CALL FCPSB_SERROR() + RETURN + ENDIF + RETURN END diff --git a/base/serial/coo/zcoosv.f b/base/serial/coo/zcoosv.f index 02516d4c..040745df 100644 --- a/base/serial/coo/zcoosv.f +++ b/base/serial/coo/zcoosv.f @@ -1,13 +1,41 @@ C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C +C C Assumption: the triangular matrix has the diagonal element in the C "right" place, i.e. the last in its row for Lower and the first C for Upper. C SUBROUTINE ZCOOSV (UPLO,TRANS,DIAG,N,AS,IA,JA,INFOA,B,X,IERROR) + use psb_error_mod COMPLEX*16 ZERO PARAMETER (ZERO=(0.0D0,0.0D0)) - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) INTEGER N,IERROR CHARACTER DIAG, TRANS, UPLO COMPLEX*16 AS(*), B(*), X(*) @@ -15,120 +43,129 @@ C COMPLEX*16 ACC INTEGER I, J, K, NNZ, II, JJ LOGICAL LOW, TRA, UNI - if (debug) write(*,*) 'ZCOOSV ',n - if (debug) write(*,*) 'ZCOOSV ',n,nnz,diag,trans,uplo + integer :: debug_level, debug_unit + character(len=20) :: name='zcoosv' + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + UNI = (DIAG.EQ.'U') TRA = (TRANS.EQ.'T') LOW = (UPLO.EQ.'L') NNZ = INFOA(1) - if (debug) write(*,*) 'ZCOOSV ',n,nnz,uni,tra,low,ia(1),ja(1) IERROR = 0 - if (debug) write(*,*) 'ZCOOSV ierror ',ierror + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),':',n,nnz,diag,trans,uplo IF ( .NOT. TRA) THEN - if (debug) write(*,*) 'ZCOOSV NOT TRA' - IF (LOW) THEN - if (debug) write(*,*) 'ZCOOSV LOW' - IF ( .NOT. UNI) THEN - if (debug) write(*,*) 'ZCOOSV NOT UNI' - I = 1 - J = I - DO WHILE (I.LE.NNZ) + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT TRA' + IF (LOW) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': LOW' + IF ( .NOT. UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT UNI' + I = 1 + J = I + DO WHILE (I.LE.NNZ) + DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) + J = J+1 + ENDDO + ACC = ZERO + IR = IA(I) + DO K = I, J-2 + JC = JA(K) + ACC = ACC + AS(K)*X(JC) + ENDDO + X(IR) = (B(IR)-ACC)/AS(J-1) + I = J + ENDDO + + ELSE IF (UNI) THEN +C +C Bug warning: if UNI, some rows might be empty +C + I = 1 + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': UNILOW ', + + i,n,nnz,uni,tra,low + DO II = 1, N + DO WHILE ((I.LE.NNZ).AND.(IA(I).LT.II)) + I = I + 1 + ENDDO + ACC = ZERO + IF ((I.LE.NNZ).AND.(IA(I).EQ.II)) THEN + J = I + 1 DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) J = J+1 ENDDO - ACC = ZERO - IR = IA(I) - DO K = I, J-2 + DO K = I, J-1 JC = JA(K) ACC = ACC + AS(K)*X(JC) ENDDO - X(IR) = (B(IR)-ACC)/AS(J-1) - I = J - ENDDO + ELSE + J = I + ENDIF + X(II) = (B(II)-ACC) + I = J + ENDDO - ELSE IF (UNI) THEN -C -C Bug warning: if UNI, some rows might be empty -C - I = 1 - if (debug) write(*,*) 'ZCOOSV UNILOW ', - + i,n,nnz,uni,tra,low - DO II = 1, N - if (debug) write(*,*) 'Loop1 COOSV',i,j,ii,x(ii),b(ii) - DO WHILE ((I.LE.NNZ).AND.(IA(I).LT.II)) - I = I + 1 -c$$$ if (debug) write(*,*) 'Loop2 COOSV',i,ia(i),ii - ENDDO - ACC = ZERO - IF ((I.LE.NNZ).AND.(IA(I).EQ.II)) THEN - J = I + 1 - DO WHILE ((J.LE.NNZ).AND.(IA(J).EQ.IA(I))) - J = J+1 - ENDDO - DO K = I, J-1 - JC = JA(K) - ACC = ACC + AS(K)*X(JC) - ENDDO - ELSE - J = I - ENDIF - X(II) = (B(II)-ACC) - if (debug) write(*,*) 'Loop COOSV',i,j,ii,x(ii),b(ii) - I = J - ENDDO + END IF - END IF + ELSE IF ( .NOT. LOW) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT LOW' + IF ( .NOT. UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NOT UNI' + I = NNZ + J = NNZ + DO WHILE (I.GT.0) + DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) + J = J-1 + ENDDO + ACC = ZERO + IR = IA(I) + DO K = I, J+2,-1 + JC = JA(K) + ACC = ACC + AS(K)*X(JC) + ENDDO + X(IR) = (B(IR)-ACC)/AS(J+1) + I = J + ENDDO - ELSE IF ( .NOT. LOW) THEN - if (debug) write(*,*) 'ZCOOSV NOT LOW' - IF ( .NOT. UNI) THEN - if (debug) write(*,*) 'ZCOOSV NOT UNI' - I = NNZ - J = NNZ - DO WHILE (I.GT.0) - DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) + ELSE IF (UNI) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': UNI' + I = NNZ + DO II = N,1,-1 + DO WHILE ((I.GT.0).AND.(IA(I).GT.II)) + I = I -1 + ENDDO + ACC = ZERO + IF ((I.GT.0).AND.(IA(I).EQ.II)) THEN + J = I - 1 + DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) J = J-1 ENDDO - ACC = ZERO - IR = IA(I) - DO K = I, J+2,-1 + DO K = I, J+1, -1 JC = JA(K) ACC = ACC + AS(K)*X(JC) - ENDDO - X(IR) = (B(IR)-ACC)/AS(J+1) - I = J - ENDDO - - ELSE IF (UNI) THEN - if (debug) write(*,*) 'ZCOOSV UNI' - I = NNZ - DO II = N,1,-1 - DO WHILE ((I.GT.0).AND.(IA(I).GT.II)) - I = I -1 - ENDDO - ACC = ZERO - IF ((I.GT.0).AND.(IA(I).EQ.II)) THEN - J = I - 1 - DO WHILE ((J.GT.0).AND.(IA(J).EQ.IA(I))) - J = J-1 - ENDDO - DO K = I, J+1, -1 - JC = JA(K) - ACC = ACC + AS(K)*X(JC) - ENDDO - ELSE - J = I - ENDIF - X(II) = (B(II)-ACC) - if (debug) write(*,*) 'Loop COOSV',i,j,ii,x(ii),b(ii) - I = J - ENDDO + ENDDO + ELSE + J = I + ENDIF + X(II) = (B(II)-ACC) + I = J + ENDDO - END IF + END IF - END IF + END IF ELSE IF (TRA) THEN + if (debug_level>=psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': TRA' IERROR = 3010 return CCCCCCCCCCCCCCCC @@ -136,48 +173,48 @@ C C TBF C CCCCCCCCCCCCCCCC - DO 180 I = 1, N - X(I) = B(I) - 180 CONTINUE - IF (LOW) THEN - IF ( .NOT. UNI) THEN - DO 220 I = N, 1, -1 - X(I) = X(I)/AS(IA(I+1)-1) - ACC = X(I) - DO 200 J = IA(I), IA(I+1) - 2 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 200 CONTINUE - 220 CONTINUE - ELSE IF (UNI) THEN - DO 260 I = N, 1, -1 - ACC = X(I) - DO 240 J = IA(I), IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 240 CONTINUE - 260 CONTINUE - END IF - ELSE IF ( .NOT. LOW) THEN - IF ( .NOT. UNI) THEN - DO 300 I = 1, N - X(I) = X(I)/AS(IA(I)) - ACC = X(I) - DO 280 J = IA(I) + 1, IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 280 CONTINUE - 300 CONTINUE - ELSE IF (UNI) THEN - DO 340 I = 1, N - ACC = X(I) - DO 320 J = IA(I), IA(I+1) - 1 - K = JA(J) - X(K) = X(K) - AS(J)*ACC - 320 CONTINUE - 340 CONTINUE - END IF - END IF + DO 180 I = 1, N + X(I) = B(I) + 180 CONTINUE + IF (LOW) THEN + IF ( .NOT. UNI) THEN + DO 220 I = N, 1, -1 + X(I) = X(I)/AS(IA(I+1)-1) + ACC = X(I) + DO 200 J = IA(I), IA(I+1) - 2 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 200 CONTINUE + 220 CONTINUE + ELSE IF (UNI) THEN + DO 260 I = N, 1, -1 + ACC = X(I) + DO 240 J = IA(I), IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 240 CONTINUE + 260 CONTINUE + END IF + ELSE IF ( .NOT. LOW) THEN + IF ( .NOT. UNI) THEN + DO 300 I = 1, N + X(I) = X(I)/AS(IA(I)) + ACC = X(I) + DO 280 J = IA(I) + 1, IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 280 CONTINUE + 300 CONTINUE + ELSE IF (UNI) THEN + DO 340 I = 1, N + ACC = X(I) + DO 320 J = IA(I), IA(I+1) - 1 + K = JA(J) + X(K) = X(K) - AS(J)*ACC + 320 CONTINUE + 340 CONTINUE + END IF + END IF END IF RETURN END diff --git a/base/serial/csr/Makefile b/base/serial/csr/Makefile index 5129863e..2a96a6c5 100644 --- a/base/serial/csr/Makefile +++ b/base/serial/csr/Makefile @@ -5,7 +5,7 @@ include ../../../Make.inc # FOBJS = dcsrck.o dcsrmm.o dcsrsm.o dcsrmv.o dcsrsv.o dcrnrmi.o \ - dcsrprt.o dcsrmv4.o dcsrmv2.o dcsrmv3.o dcsrrws.o\ + dcsrmv4.o dcsrmv2.o dcsrmv3.o dcsrrws.o\ zcrnrmi.o zcsrmm.o zcsrrws.o zcsrsm.o zsrmv.o zsrsv.o zcsrck.o OBJS=$(FOBJS) diff --git a/base/serial/csr/dcsrprt.f b/base/serial/csr/dcsrprt.f deleted file mode 100644 index e5e48831..00000000 --- a/base/serial/csr/dcsrprt.f +++ /dev/null @@ -1,84 +0,0 @@ -C -C Parallel Sparse BLAS v2.0 -C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata -C Alfredo Buttari University of Rome Tor Vergata -C -C Redistribution and use in source and binary forms, with or without -C modification, are permitted provided that the following conditions -C are met: -C 1. Redistributions of source code must retain the above copyright -C notice, this list of conditions and the following disclaimer. -C 2. Redistributions in binary form must reproduce the above copyright -C notice, this list of conditions, and the following disclaimer in the -C documentation and/or other materials provided with the distribution. -C 3. The name of the PSBLAS group or the names of its contributors may -C not be used to endorse or promote products derived from this -C software without specific written permission. -C -C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS -C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -C POSSIBILITY OF SUCH DAMAGE. -C -C -c -c What if a wrong DESCRA is passed? -c -c -* -* - SUBROUTINE DCSRPRT(M,N,DESCRA,AR,JA,IA,TITLE,IOUT) -C -C -C .. Scalar Arguments .. - INTEGER M, N, IOUT -C .. Array Arguments .. - DOUBLE PRECISION AR(*) - INTEGER IA(*), JA(*) - CHARACTER DESCRA*11, TITLE*(*) -C .. Local Scalars .. - INTEGER I, J, nnzero - - -C .. External Subroutines .. -C -C - if ((descra(1:1).eq.'g').or.(descra(1:1).eq.'G')) then - write(iout,fmt=998) - else if ((descra(1:1).eq.'s').or.(descra(1:1).eq.'S')) then - write(iout,fmt=997) - else - write(iout,fmt=998) - endif - nnzero = ia(m+1) -1 - write(iout,fmt=992) - write(iout,fmt=996) - write(iout,fmt=996) title - write(iout,fmt=995) 'Number of rows: ',m - write(iout,fmt=995) 'Number of columns: ',n - write(iout,fmt=995) 'Nonzero entries: ',nnzero - write(iout,fmt=996) - write(iout,fmt=992) - write(iout,*) m,n,nnzero - 998 format('%%MatrixMarket matrix coordinate real general') - 997 format('%%MatrixMarket matrix coordinate real symmetric') - 992 format('%======================================== ') - 996 format('% ',a) - 995 format('% ',a,i9,a,i9,a,i9) - - do i=1, m - do j=ia(i),ia(i+1)-1 - write(iout,fmt=994) i,ja(j),ar(j) - 994 format(i6,1x,i6,1x,e16.8) - enddo - enddo - - RETURN - END diff --git a/base/serial/csr/dcsrsm.f b/base/serial/csr/dcsrsm.f index 62251dc4..e21e969d 100644 --- a/base/serial/csr/dcsrsm.f +++ b/base/serial/csr/dcsrsm.f @@ -38,8 +38,6 @@ C CHARACTER DESCRA*11 INTEGER I, K CHARACTER DIAG, UPLO - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) C .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5), err_Act @@ -97,13 +95,6 @@ C .. Local Arrays .. GOTO 9999 END IF - if (debug) then - write(0,*) 'Check from DCSRSM' - do k=1,m - write(0,*) k, b(k,1),c(k,1) - enddo - endif - IF (UNITD.EQ.'L') THEN DO 45 I = 1, N DO 25 K = 1, M diff --git a/base/serial/csr/zcrnrmi.f b/base/serial/csr/zcrnrmi.f index 46498f60..2579212b 100644 --- a/base/serial/csr/zcrnrmi.f +++ b/base/serial/csr/zcrnrmi.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C DOUBLE PRECISION FUNCTION ZCRNRMI(TRANS,M,N,DESCRA,A,IA1,IA2, & INFOA,IERROR) IMPLICIT NONE diff --git a/base/serial/csr/zcsrmm.f b/base/serial/csr/zcsrmm.f index 7b778d85..fdb41ea2 100644 --- a/base/serial/csr/zcsrmm.f +++ b/base/serial/csr/zcsrmm.f @@ -1,4 +1,33 @@ C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C +C C SUBROUTINE ZCSRMM(TRANSA,M,K,N,ALPHA,DESCRA,AR, C * JA,IA,B,LDB,BETA,C,LDC,WORK,LWORK) C diff --git a/base/serial/csr/zcsrrws.f b/base/serial/csr/zcsrrws.f index 67647e25..036c5955 100644 --- a/base/serial/csr/zcsrrws.f +++ b/base/serial/csr/zcsrrws.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C SUBROUTINE ZCSRRWS(TRANS,M,N,DESCRA,A,IA1,IA2, & INFOA,ROWSUM,IERROR) IMPLICIT NONE diff --git a/base/serial/csr/zsrmv.f b/base/serial/csr/zsrmv.f index b0e5e8c6..2d86973c 100644 --- a/base/serial/csr/zsrmv.f +++ b/base/serial/csr/zsrmv.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C *********************************************************************** * ZSRMV modified for SPARKER * * * diff --git a/base/serial/csr/zsrsv.f b/base/serial/csr/zsrsv.f index cf0e5158..1c4a286b 100644 --- a/base/serial/csr/zsrsv.f +++ b/base/serial/csr/zsrsv.f @@ -1,3 +1,32 @@ +C +C Parallel Sparse BLAS v2.0 +C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata +C Alfredo Buttari University of Rome Tor Vergata +C +C Redistribution and use in source and binary forms, with or without +C modification, are permitted provided that the following conditions +C are met: +C 1. Redistributions of source code must retain the above copyright +C notice, this list of conditions and the following disclaimer. +C 2. Redistributions in binary form must reproduce the above copyright +C notice, this list of conditions, and the following disclaimer in the +C documentation and/or other materials provided with the distribution. +C 3. The name of the PSBLAS group or the names of its contributors may +C not be used to endorse or promote products derived from this +C software without specific written permission. +C +C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS +C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +C POSSIBILITY OF SUCH DAMAGE. +C SUBROUTINE ZSRSV (UPLO,TRANS,DIAG,N,AS,JA,IA,B,X) COMPLEX*16 ZERO PARAMETER (ZERO = (0.0D0, 0.0D0)) diff --git a/base/serial/dp/dcoco.f b/base/serial/dp/dcoco.f index 69517f73..ca22086f 100644 --- a/base/serial/dp/dcoco.f +++ b/base/serial/dp/dcoco.f @@ -33,7 +33,7 @@ c subroutine dcoco(trans,m,n,unitd,d,descra,ar,ia1,ia2,info, * p1,descrn,arn,ia1n,ia2n,infon,p2,larn,lia1n, * lia2n,aux,laux,ierror) - + use psb_error_mod use psb_const_mod use psb_spmat_type use psb_string_mod @@ -55,8 +55,7 @@ c .. local scalars .. integer elem_in, elem_out logical scale integer max_nnzero - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit c .. local arrays .. character*20 name integer int_val(5) @@ -69,9 +68,11 @@ c .. external subroutines .. c .. executable statements .. c - name = 'dcoco\0' + name = 'dcoco' ierror = 0 call fcpsb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_getifield(check_flag,psb_dupl_,infon,psb_ifasize_,ierror) @@ -81,8 +82,8 @@ c p2(1) = 0 call psb_getifield(nnz,psb_nnz_,info,psb_ifasize_,ierror) - if (debug) then - write(*,*) 'on entry to dcoco: nnz laux ', + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),': on entry nnz laux ', + nnz,laux,larn,lia1n,lia2n endif if (laux.lt.nnz+2) then @@ -119,14 +120,16 @@ c c c sort COO data structure c - if (debug) write(*,*)'first sort',nnz + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': first sort',nnz do k=1, nnz arn(k) = ar(k) ia1n(k) = ia1(k) ia2n(k) = ia2(k) enddo - if (debug) write(*,*)'second sort' + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': second sort' if ((lia2n.ge.(2*nnz+psb_ireg_flgs_+1)) + .and.(laux.ge.2*(2+nnz))) then @@ -145,7 +148,9 @@ c ia2n(ip1+psb_nnzt_) = nnz ia2n(ip1+psb_nnz_) = 0 ia2n(ip1+psb_ichk_) = nnz+check_flag - if (debug) write(0,*) 'build check :',ia2n(ip1+psb_nnzt_) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': build check :',ia2n(ip1+psb_nnzt_) c .... order with key ia1n ... call msort_up(nnz,ia1n,aux,iret) @@ -183,7 +188,7 @@ c ... error, there are duplicated elements ... c ... insert only the first duplicated element ... ia2n(ip2+aux(ipx+elem_in-1)-1) = elem_out else if (check_flag.eq.psb_dupl_add_) then -c ... add the duplicated element ... +c ... sum the duplicated element ... arn(elem_out) = arn(elem_out) + arn(elem_in) ia2n(ip2+aux(ipx+elem_in-1)-1) = elem_out end if @@ -230,7 +235,7 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the first duplicated element ... else if (check_flag.eq.psb_dupl_add_) then -c ... add the duplicated element ... +c ... sum the duplicated element ... arn(elem_out) = arn(elem_out) + arn(elem_in) end if else @@ -244,7 +249,9 @@ c ... add the duplicated element ... infon(psb_nnz_) = elem_out infon(psb_srtd_) = psb_isrtdcoo_ - if (debug) write(*,*)'done rebuild COO',infon(1) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': done rebuild COO',infon(1) else if (toupper(descra(1:1)).eq.'S' .and. + toupper(descra(2:2)).eq.'U') then diff --git a/base/serial/dp/dcocr.f b/base/serial/dp/dcocr.f index e045a590..7f751a44 100644 --- a/base/serial/dp/dcocr.f +++ b/base/serial/dp/dcocr.f @@ -34,8 +34,9 @@ C SUBROUTINE DCOCR(TRANS,M,N,UNITD,D,DESCRA,AR,JA,IA,INFO, * P1,DESCRN,ARN,IAN1,IAN2,INFON,P2,LARN,LIAN1, * LIAN2,AUX,LAUX,IERROR) - + use psb_const_mod + use psb_error_mod use psb_spmat_type use psb_string_mod IMPLICIT NONE @@ -57,12 +58,11 @@ C .. Local Scalars .. integer elem, elem_csr,regen_flag logical scale integer max_nnzero - logical debug - parameter (debug=.false.) integer, allocatable :: itmp(:) c .. local arrays .. character*20 name integer int_val(5) + integer :: debug_level, debug_unit c C ...Common variables... @@ -72,9 +72,11 @@ C .. External Subroutines .. C .. Executable Statements .. C - NAME = 'DCOCR\0' + NAME = 'DCOCR' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_getifield(check_flag,psb_dupl_,infon,psb_ifasize_,ierror) call psb_getifield(regen_flag,psb_upd_,infon,psb_ifasize_,ierror) @@ -84,10 +86,9 @@ C SCALE = (toupper(UNITD).EQ.'L') ! meaningless P1(1) = 0 P2(1) = 0 - nnz = info(1) - if (debug) then - write(0,*) 'On entry to DCOCR: NNZ LAUX ', + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),': On entry NNZ LAUX ', + nnz,laux,larn,lian1,lian2 endif IF (LAUX.LT.NNZ+2) THEN @@ -139,10 +140,9 @@ C C C Sort COO data structure C - if (debug) write(0,*)'First sort',nnz -c$$$ write(0,*) 'DCOCR Sizes ',lian2,((m+1)+nnz+psb_ireg_flgs_+1), -c$$$ + m+1,nnz,psb_ireg_flgs_, -c$$$ + laux,2*(2+nnz) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': First sort',nnz + if ((regen_flag==psb_upd_perm_).and. + (lian2.ge.((m+1)+nnz+psb_ireg_flgs_+1)) + .and.(laux.ge.2*(2+nnz))) then @@ -162,17 +162,22 @@ c ian2(ip1+psb_nnz_) = 0 ian2(ip1+psb_ichk_) = nnz+check_flag - if (debug) write(0,*) 'Build check :',ian2(ip1+psb_nnzt_) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Build check :',ian2(ip1+psb_nnzt_) + C .... Order with key IA ... call msort_up(nnz,itmp,aux,iret) if (iret.eq.0) call reordvn3(nnz,arn,itmp,ian1,aux(ipx),aux) - if (debug) then + if (debug_level >= psb_debug_serial_) then do i=1, nnz-1 if (itmp(i).gt.itmp(i+1)) then - write(0,*) 'Sorting error:',i,itmp(i),itmp(i+1) + write(debug_unit,*) trim(name), + + 'Sorting error:',i,itmp(i),itmp(i+1) endif enddo - write(0,*) 'nnz :',m,nnz,itmp(nnz),ian1(nnz) + write(debug_unit,*) trim(name), + + 'nnz :',m,nnz,itmp(nnz),ian1(nnz) endif C .... Order with key JA ... @@ -200,7 +205,10 @@ c ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr @@ -233,14 +241,10 @@ c ... error, there are duplicated elements ... c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr-1 - if (debug) write(0,*) 'duplicated overwrite perm ', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr-1 - if (debug) write(0,*) 'duplicated add perm ', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -280,7 +284,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -309,13 +316,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -324,13 +327,9 @@ c ... sum the duplicated element ... enddo endif - if (debug) write(0,*)'Done Rebuild CSR', + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': Done Rebuild CSR', + ian2(m+1),ia(elem) -c$$$ if (debug) then -c$$$ do i=ian2(m+1), nnz -c$$$ write(0,*) 'Overflow check :',ia(i),ja(i),ar(i) -c$$$ enddo -c$$$ endif ELSE IF (toupper(DESCRA(1:1)).EQ.'S' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN @@ -342,7 +341,6 @@ c$$$ endif else if (toupper(DESCRA(1:1)).EQ.'T' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN - call msort_up(nnz,itmp,aux,iret) if (iret.eq.0) call reordvn(nnz,arn,itmp,ian1,aux) C .... Order with key JA ... @@ -371,7 +369,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -400,13 +401,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -436,8 +433,6 @@ C .... Order with key JA ... i = j enddo - - C ... Construct CSR Representation... elem = 1 elem_csr = 1 @@ -445,7 +440,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -474,13 +472,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -488,13 +482,9 @@ c ... sum the duplicated element ... ian2(row+1) = elem_csr enddo - if (debug) write(0,*)'Done Rebuild CSR', - + ian2(m+1),ia(elem) - if (debug) then - do i=ian2(m+1), nnz - write(0,*) 'Overflow check :',ia(i),ja(i),ar(i) - enddo - endif + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': Done Rebuild CSR', + + ian2(m+1),ia(elem) end if diff --git a/base/serial/dp/dcrco.f b/base/serial/dp/dcrco.f index dc8c0c56..b15cded0 100644 --- a/base/serial/dp/dcrco.f +++ b/base/serial/dp/dcrco.f @@ -35,6 +35,7 @@ C use psb_const_mod use psb_spmat_type use psb_string_mod + use psb_error_mod IMPLICIT NONE C @@ -54,23 +55,27 @@ C .. Local Scalars .. c .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit C .. External Subroutines .. EXTERNAL MAX_NNZERO C .. Executable Statements .. C - NAME = 'DCRCO\0' + NAME = 'DCRCO' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF (toupper(TRANS).EQ.'N') THEN SCALE = (toupper(UNITD).EQ.'L') ! meaningless IP1(1) = 0 IP2(1) = 0 NNZ = IA2(M+1)-1 - if (debug) write(0,*) 'CRCO: ',m,n,nnz,' : ', - + descra,' : ',descrn + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': entry',m,n,nnz, + + ' : ',descra,' : ',descrn + IF (LARN.LT.NNZ) THEN IERROR = 60 INT_VAL(1) = 18 @@ -106,7 +111,10 @@ C ... Construct COO Representation... ENDDO ENDDO INFON(psb_nnz_) = elem - if (debug) write(0,*) 'CRCO endloop',m,elem + + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': endloop',m,elem + ELSE IF (toupper(DESCRA(1:1)).EQ.'S' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN diff --git a/base/serial/dp/dcrcr.f b/base/serial/dp/dcrcr.f index d6285172..a661331c 100644 --- a/base/serial/dp/dcrcr.f +++ b/base/serial/dp/dcrcr.f @@ -188,18 +188,20 @@ C .. Intrinsic Functions .. C .. Executable Statements .. C EXIT=.FALSE. - NAME = 'DCOCO\0' + NAME = 'DCRCR' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) C C Check for argument errors C idescra=toupper(descra) - IF(((idescra(1:1) .EQ. 'S' .OR. idescra(1:1) .EQ. 'H' .OR. - & idescra(1:1) .EQ. 'A') .AND. (toupper(unitd) .NE. 'B')) .OR. + IF (((idescra(1:1) .EQ. 'S' .OR. idescra(1:1) .EQ. 'H' .OR. + & idescra(1:1) .EQ. 'A') .AND. (toupper(unitd) .NE. 'B')) + + .OR. & (.NOT.((idescra(3:3).EQ.'N').OR.(idescra(3:3).EQ.'L').OR. - + (idescra(3:3).EQ.'U'))) .OR. - + toupper(TRANS).NE.'N') THEN + + (idescra(3:3).EQ.'U'))) + + .OR. + + toupper(TRANS).NE.'N') THEN IERROR = 20 ENDIF IF(LAN.LT.(IA2(M+1)-1)) THEN diff --git a/base/serial/dp/dcrjd.f b/base/serial/dp/dcrjd.f index e185f079..d936205e 100644 --- a/base/serial/dp/dcrjd.f +++ b/base/serial/dp/dcrjd.f @@ -78,8 +78,6 @@ C .. Local Scalars .. INTEGER IOFF, ISTROW, NJA, NZ, PIA, + PJA, PNG, K, MAX_NG, NG, LJA, ERR_ACT LOGICAL SCALE - logical debug - parameter (debug=.false.) CHARACTER UPLO INTEGER MAX_NNZERO c .. Local Arrays .. diff --git a/base/serial/dp/djadrp1.f b/base/serial/dp/djadrp1.f index 50d06d6f..3e52dc8d 100644 --- a/base/serial/dp/djadrp1.f +++ b/base/serial/dp/djadrp1.f @@ -114,8 +114,6 @@ C .. Local Scalars .. INTEGER I, K, IPG, ERR_ACT C .. Intrinsic Functions .. INTRINSIC DBLE - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) C .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5) @@ -127,7 +125,6 @@ C CALL FCPSB_ERRACTIONSAVE(ERR_ACT) IF(toupper(TRANS).EQ.'N') THEN - IF (DEBUG) WRITE(0,*)'DJADRP1:',NG DO IPG = 1, NG DO K = IA(2,IPG), IA(3,IPG)-1 DO I = JA(K), JA(K+1) - 1 diff --git a/base/serial/dp/djdco.f b/base/serial/dp/djdco.f index 2216e292..252dfb96 100644 --- a/base/serial/dp/djdco.f +++ b/base/serial/dp/djdco.f @@ -32,6 +32,7 @@ C * IP1,DESCRN,ARN,IA1N,IA2N,INFON,IP2,LARN,LIA1N, * LIA2N,AUX,LAUX,IERROR) use psb_const_mod + use psb_error_mod IMPLICIT NONE C C .. Scalar Arguments .. @@ -45,21 +46,23 @@ C .. Array Arguments .. CHARACTER DESCRA*11, DESCRN*11 C .. Local Scalars .. INTEGER PIA, PJA, PNG, ERR_ACT - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit c .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5) - NAME = 'DJDCO\0' + NAME = 'DJDCO' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() PNG = IA2(1) PIA = IA2(2) PJA = IA2(3) - if(debug) write(*,*) 'On entry to DJDCO: NNZ LAUX ', + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': On entry NNZ LAUX ', + info(1),laux,larn,lia1n,lia2n CALL DJDCOX(TRANS,M,N,DESCRA,AR,IA2(PIA),IA2(PJA), diff --git a/base/serial/dp/djdcox.f b/base/serial/dp/djdcox.f index dcfaf5e9..de95e4e7 100755 --- a/base/serial/dp/djdcox.f +++ b/base/serial/dp/djdcox.f @@ -38,6 +38,7 @@ C use psb_const_mod use psb_string_mod + use psb_error_mod IMPLICIT NONE C @@ -54,8 +55,7 @@ C .. Local Scalars .. INTEGER IPX, IPG, NNZ, K, ROW, * I, J, NZL, IRET, ERR_ACT LOGICAL SCALE - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit c .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5) @@ -63,9 +63,11 @@ c .. Local Arrays .. C C .. Executable Statements .. C - NAME = 'DJDCOX\0' + NAME = 'DJDCOX' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF (toupper(TRANS).EQ.'N') THEN C SCALE = (UNITD.EQ.'L') ! meaningless @@ -80,8 +82,8 @@ C SCALE = (UNITD.EQ.'L') ! meaningless NNZ = JA(IA(2,NG+1)-1 +1)-1 - if (debug) then - write(0,*) 'On entry to DJDCOX: NNZ LAUX ', + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),': On entry NNZ LAUX ', + nnz,laux,larn,lia1n,lia2n endif IF (LAUX.LT.NNZ+2) THEN diff --git a/base/serial/dp/dvtfg.f b/base/serial/dp/dvtfg.f index c8dbf102..b2e39baf 100644 --- a/base/serial/dp/dvtfg.f +++ b/base/serial/dp/dvtfg.f @@ -34,6 +34,7 @@ C SUBROUTINE DVTFG (UPLO,M,JA,IA,NG,IPA,IPAT,KLEN,IWORK1,IWORK2, * IWORK3) use psb_string_mod + use psb_error_mod implicit none C .. Scalar Arguments .. INTEGER M, NG @@ -45,10 +46,12 @@ C .. Local Scalars .. INTEGER I, J, L, L0, L1, LEV, NP, iret C .. Intrinsic Functions .. INTRINSIC MAX - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit + character(len=20) :: name='DVTFG' C .. Executable Statements .. C + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() NG = 0 C C CHECK ON THE NUMBERS OF THE ELEMENTS OF THE MATRIX @@ -152,7 +155,9 @@ C DO 260 L = 1, L1 IPA(L) = IWORK3(L) 260 CONTINUE - if (debug) write(0,*) 'DVTFG: Group ',1,':',(ipa(l),l=1,l1) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Group ',1,':',(ipa(l),l=1,l1) DO 360 LEV = 2, NG C C LOOP ON GROUPS @@ -177,8 +182,9 @@ C IPA(L0+L) = IWORK3(L0+L) 320 CONTINUE ENDIF - if (debug) write(0,*) 'DVTFG: Group ',lev, - + ':',(ipa(l0+l),l=1,l1) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Group ',lev,':',(ipa(l0+l),l=1,l1) 360 CONTINUE C C IPAT = IPA-1 diff --git a/base/serial/dp/zcoco.f b/base/serial/dp/zcoco.f index 77c501e9..ad3c62cd 100644 --- a/base/serial/dp/zcoco.f +++ b/base/serial/dp/zcoco.f @@ -33,7 +33,7 @@ c subroutine zcoco(trans,m,n,unitd,d,descra,ar,ia1,ia2,info, * p1,descrn,arn,ia1n,ia2n,infon,p2,larn,lia1n, * lia2n,aux,laux,ierror) - + use psb_error_mod use psb_const_mod use psb_spmat_type use psb_string_mod @@ -55,8 +55,7 @@ c .. local scalars .. integer elem_in, elem_out logical scale integer max_nnzero - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit c .. local arrays .. character*20 name integer int_val(5) @@ -72,16 +71,19 @@ c name = 'zcoco' ierror = 0 call fcpsb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_getifield(check_flag,psb_dupl_,infon,psb_ifasize_,ierror) + if (toupper(trans).eq.'N') then scale = (toupper(unitd).eq.'L') ! meaningless p1(1) = 0 p2(1) = 0 call psb_getifield(nnz,psb_nnz_,info,psb_ifasize_,ierror) - if (debug) then - write(*,*) 'on entry to dcoco: nnz laux ', + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),': on entry nnz laux ', + nnz,laux,larn,lia1n,lia2n endif if (laux.lt.nnz+2) then @@ -118,14 +120,16 @@ c c c sort COO data structure c - if (debug) write(*,*)'first sort',nnz + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': first sort',nnz do k=1, nnz arn(k) = ar(k) ia1n(k) = ia1(k) ia2n(k) = ia2(k) enddo - if (debug) write(*,*)'second sort' + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': second sort' if ((lia2n.ge.(2*nnz+psb_ireg_flgs_+1)) + .and.(laux.ge.2*(2+nnz))) then @@ -144,7 +148,9 @@ c ia2n(ip1+psb_nnzt_) = nnz ia2n(ip1+psb_nnz_) = 0 ia2n(ip1+psb_ichk_) = nnz+check_flag - if (debug) write(0,*) 'build check :',ia2n(ip1+psb_nnzt_) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': build check :',ia2n(ip1+psb_nnzt_) c .... order with key ia1n ... call msort_up(nnz,ia1n,aux,iret) @@ -244,7 +250,9 @@ c ... sum the duplicated element ... infon(psb_nnz_) = elem_out infon(psb_srtd_) = psb_isrtdcoo_ - if (debug) write(*,*)'done rebuild COO',infon(1) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': done rebuild COO',infon(1) else if (toupper(descra(1:1)).eq.'S' .and. + toupper(descra(2:2)).eq.'U') then diff --git a/base/serial/dp/zcocr.f b/base/serial/dp/zcocr.f index 6230b3bc..508def65 100644 --- a/base/serial/dp/zcocr.f +++ b/base/serial/dp/zcocr.f @@ -36,6 +36,7 @@ C * LIAN2,AUX,LAUX,IERROR) use psb_const_mod + use psb_error_mod use psb_spmat_type use psb_string_mod IMPLICIT NONE @@ -56,13 +57,12 @@ C .. Local Scalars .. integer ipx, ip1, ip2, check_flag, err_act integer elem, elem_csr,regen_flag logical scale - integer max_nnzero - logical debug - parameter (debug=.false.) + integer max_nnzero integer, allocatable :: itmp(:) c .. local arrays .. character*20 name integer int_val(5) + integer :: debug_level, debug_unit C C ...Common variables... @@ -71,10 +71,11 @@ C .. External Subroutines .. EXTERNAL MAX_NNZERO C .. Executable Statements .. C - - NAME = 'ZCOCR\0' + NAME = 'ZCOCR' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_getifield(check_flag,psb_dupl_,infon,psb_ifasize_,ierror) call psb_getifield(regen_flag,psb_upd_,infon,psb_ifasize_,ierror) @@ -84,10 +85,9 @@ C SCALE = (toupper(UNITD).EQ.'L') ! meaningless P1(1) = 0 P2(1) = 0 - nnz = info(1) - if (debug) then - write(0,*) 'On entry to ZCOCR: NNZ LAUX ', + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),': On entry NNZ LAUX ', + nnz,laux,larn,lian1,lian2 endif IF (LAUX.LT.NNZ+2) THEN @@ -131,15 +131,17 @@ C ian1(k) = ja(k) itmp(k) = ia(k) enddo + ! Mark as unavailable by default. + infon(psb_upd_pnt_) = 0 + IF (toupper(descra(1:1)).EQ.'G') THEN C C Sort COO data structure C - if (debug) write(0,*)'First sort',nnz -c$$$ write(0,*) 'ZCOCR Sizes ',lian2,((m+1)+nnz+psb_ireg_flgs_+1), -c$$$ + m+1,nnz,psb_ireg_flgs_, -c$$$ + laux,2*(2+nnz) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': First sort',nnz + if ((regen_flag==psb_upd_perm_).and. + (lian2.ge.((m+1)+nnz+psb_ireg_flgs_+1)) + .and.(laux.ge.2*(2+nnz))) then @@ -159,24 +161,23 @@ c ian2(ip1+psb_nnz_) = 0 ian2(ip1+psb_ichk_) = nnz+check_flag -c$$$ write(0,*)'ZCOCR Check: ',ip2,ian2(ip1+psb_iflag_), -c$$$ + ian2(ip1+psb_nnzt_), ian2(ip1+psb_nnz_), -c$$$ + ian2(ip1+psb_ichk_) + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Build check :',ian2(ip1+psb_nnzt_) -c$$$ + ip1,ip2,nnz,ian2(ip1+nnzt_) - - if (debug) write(0,*) 'Build check :',ian2(ip1+psb_nnzt_) C .... Order with key IA ... call msort_up(nnz,itmp,aux,iret) if (iret.eq.0) + call zreordvn3(nnz,arn,itmp,ian1,aux(ipx),aux) - if (debug) then + if (debug_level >= psb_debug_serial_) then do i=1, nnz-1 if (itmp(i).gt.itmp(i+1)) then - write(0,*) 'Sorting error:',i,itmp(i),itmp(i+1) + write(debug_unit,*) trim(name), + + 'Sorting error:',i,itmp(i),itmp(i+1) endif enddo - write(0,*) 'nnz :',m,nnz,itmp(nnz),ian1(nnz) + write(debug_unit,*) trim(name), + + 'nnz :',m,nnz,itmp(nnz),ian1(nnz) endif C .... Order with key JA ... @@ -204,7 +205,10 @@ c ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr @@ -237,14 +241,10 @@ c ... error, there are duplicated elements ... c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr-1 - if (debug) write(0,*) 'duplicated overwrite perm ', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) ian2(ip2+aux(ipx+elem-1)-1) = elem_csr-1 - if (debug) write(0,*) 'duplicated add perm ', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -284,7 +284,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -313,13 +316,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -328,13 +327,9 @@ c ... sum the duplicated element ... enddo endif - if (debug) write(0,*)'Done Rebuild CSR', + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': Done Rebuild CSR', + ian2(m+1),ia(elem) -c$$$ if (debug) then -c$$$ do i=ian2(m+1), nnz -c$$$ write(0,*) 'Overflow check :',ia(i),ja(i),ar(i) -c$$$ enddo -c$$$ endif ELSE IF (toupper(DESCRA(1:1)).EQ.'S' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN @@ -346,7 +341,6 @@ c$$$ endif else if (toupper(DESCRA(1:1)).EQ.'T' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN - call msort_up(nnz,itmp,aux,iret) if (iret.eq.0) call zreordvn(nnz,arn,itmp,ian1,aux) C .... Order with key JA ... @@ -375,7 +369,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -404,13 +401,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -440,8 +433,6 @@ C .... Order with key JA ... i = j enddo - - C ... Construct CSR Representation... elem = 1 elem_csr = 1 @@ -449,7 +440,10 @@ C ... Insert first element ... do row = 1, itmp(1) ian2(row) = 1 enddo - if (debug) write(0,*)'Rebuild CSR',ia(1),elem_csr + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name), + + ': Rebuild CSR',ia(1),elem_csr + ian1(elem_csr) = ian1(elem) arn(elem_csr) = arn(elem) elem = elem+1 @@ -478,13 +472,9 @@ c ... error, there are duplicated elements ... else if (check_flag.eq.psb_dupl_ovwrt_) then c ... insert only the last duplicated element ... arn(elem_csr-1) = arn(elem) - if (debug) write(0,*) 'Duplicated overwrite srch', - + elem_csr-1,elem else if (check_flag.eq.psb_dupl_add_) then c ... sum the duplicated element ... arn(elem_csr-1) = arn(elem_csr-1) + arn(elem) - if (debug) write(0,*) 'Duplicated add srch', - + elem_csr-1,elem end if endif elem = elem + 1 @@ -492,13 +482,9 @@ c ... sum the duplicated element ... ian2(row+1) = elem_csr enddo - if (debug) write(0,*)'Done Rebuild CSR', - + ian2(m+1),ia(elem) - if (debug) then - do i=ian2(m+1), nnz - write(0,*) 'Overflow check :',ia(i),ja(i),ar(i) - enddo - endif + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': Done Rebuild CSR', + + ian2(m+1),ia(elem) end if diff --git a/base/serial/dp/zcrco.f b/base/serial/dp/zcrco.f index 483724d8..84db6f49 100644 --- a/base/serial/dp/zcrco.f +++ b/base/serial/dp/zcrco.f @@ -35,6 +35,7 @@ C use psb_const_mod use psb_spmat_type use psb_string_mod + use psb_error_mod IMPLICIT NONE C @@ -54,21 +55,27 @@ C .. Local Scalars .. c .. Local Arrays .. CHARACTER*20 NAME INTEGER INT_VAL(5) - + integer :: debug_level, debug_unit C .. External Subroutines .. EXTERNAL MAX_NNZERO C .. Executable Statements .. C - NAME = 'ZCRCO\0' + NAME = 'ZCRCO' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF (toupper(TRANS).EQ.'N') THEN SCALE = (toupper(UNITD).EQ.'L') ! meaningless IP1(1) = 0 IP2(1) = 0 NNZ = IA2(M+1)-1 + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': entry',m,n,nnz, + + ' : ',descra,' : ',descrn + IF (LARN.LT.NNZ) THEN IERROR = 60 INT_VAL(1) = 18 @@ -93,17 +100,20 @@ C IF (toupper(DESCRA(1:1)).EQ.'G') THEN C ... Construct COO Representation... - ELEM = 1 + ELEM = 0 DO ROW = 1, M DO J = IA2(ROW), IA2(ROW+1)-1 + ELEM = ELEM + 1 IAN1(ELEM) = ROW IAN2(ELEM) = IA1(J) ARN(ELEM) = AR(J) - ELEM = ELEM + 1 ENDDO ENDDO - INFON(psb_nnz_) = IA2(M+1)-1 + INFON(psb_nnz_) = elem + + if (debug_level >= psb_debug_serial_) + + write(debug_unit,*) trim(name),': endloop',m,elem ELSE IF (toupper(DESCRA(1:1)).EQ.'S' .AND. + toupper(DESCRA(2:2)).EQ.'U') THEN diff --git a/base/serial/dp/zcrcr.f b/base/serial/dp/zcrcr.f index 3ac0f729..7b480d51 100644 --- a/base/serial/dp/zcrcr.f +++ b/base/serial/dp/zcrcr.f @@ -188,7 +188,7 @@ C .. Intrinsic Functions .. C .. Executable Statements .. C EXIT=.FALSE. - NAME = 'DCOCO\0' + NAME = 'ZCRCR' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) C diff --git a/base/serial/dp/zcrjd.f b/base/serial/dp/zcrjd.f index cfc23775..0b255451 100644 --- a/base/serial/dp/zcrjd.f +++ b/base/serial/dp/zcrjd.f @@ -78,8 +78,6 @@ C .. Local Scalars .. INTEGER IOFF, ISTROW, NJA, NZ, PIA, + PJA, PNG, K, MAX_NG, NG, LJA, ERR_ACT LOGICAL SCALE - logical debug - parameter (debug=.false.) CHARACTER UPLO INTEGER MAX_NNZERO c .. Local Arrays .. diff --git a/base/serial/f77/Makefile b/base/serial/f77/Makefile index 38333efe..18b1d713 100644 --- a/base/serial/f77/Makefile +++ b/base/serial/f77/Makefile @@ -4,7 +4,7 @@ include ../../../Make.inc # The object files # FOBJS = daxpby.o dcsmm.o dcsnmi.o dcsrp.o dcssm.o \ - dgelp.o dlpupd.o dswmm.o dswprt.o \ + dgelp.o dlpupd.o dswmm.o \ dswsm.o smmp.o dcsrws.o \ zcsnmi.o zaxpby.o zcsmm.o zcssm.o zswmm.o zswsm.o\ zcsrws.o zgelp.o zlpupd.o diff --git a/base/serial/f77/dcsrp.f b/base/serial/f77/dcsrp.f index e934bc48..88788720 100644 --- a/base/serial/f77/dcsrp.f +++ b/base/serial/f77/dcsrp.f @@ -118,6 +118,7 @@ C C SUBROUTINE DCSRP(TRANS,M,N,FIDA,DESCRA,IA1,IA2,INFOA, + P,WORK,LWORK,IERROR) + use psb_error_mod IMPLICIT NONE C .. Scalar Arguments .. INTEGER LWORK, M, N, IERROR @@ -130,9 +131,7 @@ C .. Array Arguments .. CHARACTER DESCRA*11, FIDA*5 C .. External Subroutines .. EXTERNAL DCSRRP - logical debug - parameter (debug=.false.) - + integer :: debug_level, debug_unit CHARACTER*20 NAME C C .. Executable Statements .. @@ -140,7 +139,9 @@ C C C Check on M, N, TRANS C - NAME = 'DCSRP\0' + NAME = 'DCSRP' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) @@ -167,14 +168,15 @@ C C C Switching on FIDA C -c$$$ write(0,*) 'DCSRP FORMAT: ',fida IF (FIDA(1:3).EQ.'CSR') THEN C C Permuting CSR structure C CALL DCSRRP(TRANS,M,N,DESCRA,IA1,IA2,P,WORK,LWORK) ELSE IF (FIDA(1:3).EQ.'JAD') THEN - if (debug) write(0,*) 'Calling djadrp',m,p(1),lwork + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name), + + ': Calling djadrp',m,p(1),lwork CALL DJADRP(TRANS,M,N,DESCRA,IA1,IA2,P,WORK,LWORK) ELSE C diff --git a/base/serial/f77/dcssm.f b/base/serial/f77/dcssm.f index 7eb4719f..005840a9 100644 --- a/base/serial/f77/dcssm.f +++ b/base/serial/f77/dcssm.f @@ -196,6 +196,7 @@ C + PL,FIDT,DESCRT,T,IT1,IT2,INFOT,PR, + B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) C .. Scalar Arguments .. + use psb_error_mod IMPLICIT NONE DOUBLE PRECISION ALPHA, BETA INTEGER N, LDB, LDC, M, LWORK, IERROR @@ -211,11 +212,11 @@ C .. Local Scalars .. C .. Local Array.. INTEGER INT_VAL(5) CHARACTER*30 STRINGS(2) - CHARACTER NAME*30 + CHARACTER NAME*20 + integer :: debug_level, debug_unit + C .. Parameters .. PARAMETER (ZERO=0.D0) - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) C .. External Subroutines .. EXTERNAL DSWSM, DLPUPD C .. Intrinsic Functions .. @@ -225,10 +226,12 @@ C C Check for argument errors C IERROR = 0 - NAME = 'DCSSM\0' + NAME = 'DCSSM' CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - IF (M.LT.0) THEN + IF (M.LT.0) THEN IERROR = 10 INT_VAL(1) = 2 INT_VAL(2) = M @@ -299,6 +302,9 @@ C C C Both right and left permutations required C + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': RP LP ',m,n,ierror + CALL DLPUPD(M,N,PR,B,LDB,BETA,WORK,M) CALL DSWSM(TRANS,M,N,ALPHA,UNITD,D,FIDT,DESCRT,T,IT1,IT2, & INFOT,WORK,M,ZERO,WORK(P),M,WORK(P+LWORKB),LWORK,IERROR) @@ -314,7 +320,9 @@ C C C Only right permutation required C -c$$$ write(0,*) 'DCSSM: RP' + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': RP NLP ',m,n,ierror + CALL DLPUPD(M,N,PR,B,LDB,BETA,WORK,M) CALL DSWSM(TRANS,M,N,ALPHA,UNITD,D,FIDT,DESCRT,T,IT1,IT2, & INFOT,WORK,M,ZERO,C,LDC,WORK(P),LWORK,IERROR) @@ -330,7 +338,8 @@ c$$$ write(0,*) 'DCSSM: RP' C C Only left permutation required C -c$$$ write(0,*) 'DCSSM: LP' + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NRP LP ',m,n,ierror CALL DSWSM(TRANS,M,N,ALPHA,UNITD,D,FIDT,DESCRT,T,IT1,IT2, & INFOT,B,LDB,BETA,WORK,M,WORK(P),LWORK,IERROR) LWORKS = IDINT(WORK(P)) @@ -345,8 +354,8 @@ c$$$ write(0,*) 'DCSSM: LP' C C Only triangular systems solver required C - if (debug) write(*,*) 'DCSSM ',m,n - if (debug) write(*,*) 'DCSSM ',m,n,ierror + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': NRP NLP ',m,n,ierror CALL DSWSM(TRANS,M,N,ALPHA,UNITD,D,FIDT,DESCRT,T,IT1,IT2, & INFOT,B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) LWORKS = IDINT(WORK(1)) diff --git a/base/serial/f77/dswprt.f b/base/serial/f77/dswprt.f deleted file mode 100644 index b8cbc326..00000000 --- a/base/serial/f77/dswprt.f +++ /dev/null @@ -1,211 +0,0 @@ -C -C Parallel Sparse BLAS v2.0 -C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata -C Alfredo Buttari University of Rome Tor Vergata -C -C Redistribution and use in source and binary forms, with or without -C modification, are permitted provided that the following conditions -C are met: -C 1. Redistributions of source code must retain the above copyright -C notice, this list of conditions and the following disclaimer. -C 2. Redistributions in binary form must reproduce the above copyright -C notice, this list of conditions, and the following disclaimer in the -C documentation and/or other materials provided with the distribution. -C 3. The name of the PSBLAS group or the names of its contributors may -C not be used to endorse or promote products derived from this -C software without specific written permission. -C -C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS -C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -C POSSIBILITY OF SUCH DAMAGE. -C -C -C SUBROUTINE DSWMM(TRANS,M,N,K,ALPHA,FIDA,DESCRA,A,IA1,IA2, -C INFOA,B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) -C Purpose -C ======= -C -C Computing C <-- ALPHA A B + BETA C or -C C <-- ALPHA At B + BETA C -C Called by DCSMM -C Actual computing performed by sparse Toolkit kernels. -C This routine selects the proper kernel for each -C data structure. -C -C Parameters -C ========== -C -C TRANS - CHARACTER*1 -C On entry TRANS specifies if the routine operates with matrix A -C or with the transpose of A as follows: -C TRANS = 'N' -> use matrix A -C TRANS = 'T' or 'C' -> use A' (transpose of matrix A) -C Unchanged on exit. -C -C M - INTEGER -C On entry: number of rows of matrix A (A') and -C number of rows of matrix C -C Unchanged on exit. -C -C N - INTEGER -C On entry: number of columns of matrix B -C and number of columns of matrix C. -C Unchanged on exit. -C -C K - INTEGER -C On entry: number of columns of matrix A (A') and -C number of rows of matrix B -C Unchanged on exit. -C -C ALPHA - DOUBLE PRECISION -C On entry: multiplicative constant. -C Unchanged on exit. -C -C FIDA - CHARACTER*5 -C On entry FIDA defines the format of the input sparse matrix. -C Unchanged on exit. -C -C DESCRA - CHARACTER*1 array of DIMENSION (9) -C On entry DESCRA describes the characteristics of the input -C sparse matrix. -C Unchanged on exit. -C -C A - DOUBLE PRECISION array of DIMENSION (*) -C On entry A specifies the values of the input sparse -C matrix. -C Unchanged on exit. -C -C IA1 - INTEGER array of dimension (*) -C On entry IA1 holds integer information on input sparse -C matrix. Actual information will depend on data format used. -C Unchanged on exit. -C -C IA2 - INTEGER array of dimension (*) -C On entry IA2 holds integer information on input sparse -C matrix. Actual information will depend on data format used. -C Unchanged on exit. -C -C INFOA - INTEGER array of length 10. -C On entry can hold auxiliary information on input matrices -C formats or environment of subsequent calls. -C Might be changed on exit. -C -C B - DOUBLE PRECISION matrix of dimension (LDB,*) -C On entry: dense matrix. -C Unchanged on exit. -C -C LDB - INTEGER -C On entry: leading dimension of B -C Unchanged on exit. -C -C BETA - DOUBLE PRECISION -C On entry: multiplicative constant. -C Unchanged on exit. -C -C C - DOUBLE PRECISION matrix of dimension (LDC,*) -C On entry: dense matrix. -C On exit is updated with the matrix-matrix product. -C -C LDC - INTEGER -C On entry: leading dimension of C -C Unchanged on exit. -C -C WORK - DOUBLE PRECISION array of dimension (LWORK) -C On entry: work area. -C On exit INT(WORK(1)) contains the minimum value -C for LWORK satisfying DSWMM memory requirements. -C -C LWORK - INTEGER -C On entry LWORK specifies the dimension of WORK -C Unchanged on exit. -C -C IERROR - INTEGER -C On exit IERROR contains the value of error flag as follows: -C IERROR = 0 no error -C IERROR > 0 warning -C IERROR < 0 fatal error -C -C Note -C ==== -C All checks on argument are performed in the calling routine. -C -C - SUBROUTINE DSWPRT(M,N,FIDA,DESCRA,A,IA1,IA2,INFOA,TITLE, - + IOUT,IERROR) -C .. Scalar Arguments .. - integer m,n,iout,ierror -c .. array arguments .. - integer ia1(*),ia2(*),infoa(*) - character descra*11, fida*5, title*(*) - double precision a(*) - integer png,pia,pja - - CHARACTER*20 NAME - -C .. Executable Statements .. - - NAME = 'DSWPRT\0' - IERROR = 0 - CALL FCPSB_ERRACTIONSAVE(ERR_ACT) - -C -C Switching on FIDA: proper sparse BLAS routine is selected -C according to data structure -C - IF (FIDA(1:3).EQ.'CSR') THEN -C -C A, IA1, IA2 ---> AR, JA, IA -C VAL, INDX, PNTR -C INFOA(*) not used - - CALL DCSRPRT(M,N,DESCRA,A,IA1,IA2,TITLE,IOUT) - ELSE IF (FIDA(1:3).EQ.'COO') THEN -C -C A, IA1, IA2 ---> AR, JA, IA -C VAL, INDX, PNTR -C INFOA(*) not used - CALL DCOOPRT(M,N,DESCRA,A,IA1,IA2,INFOA,TITLE,IOUT) - ELSE IF (FIDA(1:3).EQ.'JAD') THEN -C -C A, IA1, IA2 ---> AR, JA, IA -C VAL, INDX, PNTR -C INFOA(*) not used - PNG = IA2(1) - PIA = IA2(2) - PJA = IA2(3) - - CALL DJADPRT(M,N,IA2(PNG),A,IA1,IA2(PJA),IA2(PIA), - + TITLE,IOUT) - ELSE - - -C -C This data structure not yet considered -C - IERROR = 3010 - CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) - GOTO 9999 - - END IF - - CALL FCPSB_ERRACTIONRESTORE(ERR_ACT) - RETURN - - 9999 CONTINUE - CALL FCPSB_ERRACTIONRESTORE(ERR_ACT) - - IF ( ERR_ACT .NE. 0 ) THEN - CALL FCPSB_SERROR() - RETURN - ENDIF - - RETURN - END diff --git a/base/serial/f77/dswsm.f b/base/serial/f77/dswsm.f index 4d6ecd54..f3a1e2f6 100644 --- a/base/serial/f77/dswsm.f +++ b/base/serial/f77/dswsm.f @@ -153,6 +153,8 @@ C C SUBROUTINE DSWSM(TRANS,M,N,ALPHA,UNITD,D,FIDT,DESCRT,T,IT1,IT2, & INFOT,B,LDB,BETA,C,LDC,WORK,LWORK,IERROR) + use psb_error_mod + implicit none C .. Scalar Arguments .. INTEGER M, N, LDB, LDC, LWORK, IERROR CHARACTER UNITD, TRANS @@ -167,16 +169,16 @@ C .. Parameters .. PARAMETER (ONE=1) C .. External Subroutines .. EXTERNAL DCSRSM, DCOPY - LOGICAL DEBUG - PARAMETER (DEBUG=.FALSE.) - + integer debug_level, debug_unit, err_act, int_val(5) CHARACTER*20 NAME C .. Executable Statements .. - NAME = 'DSWSM\0' + NAME = 'DSWSM' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() C C Check for identity matrix @@ -186,7 +188,8 @@ C GOTO 9998 ENDIF - if (debug) write(*,*) 'DSWSM ',m,n,ierror,' ',unitd + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': entry ',m,n,ierror,' ',unitd C C Switching on FIDT: proper sparse BLAS routine is selected C according to data structure diff --git a/base/serial/jad/Makefile b/base/serial/jad/Makefile index 0114d792..ec1c0fa3 100644 --- a/base/serial/jad/Makefile +++ b/base/serial/jad/Makefile @@ -3,7 +3,7 @@ include ../../../Make.inc # The object files # -FOBJS = djadmm.o djadmv.o djadsm.o djadsv.o djdnrmi.o djadnr.o djadprt.o\ +FOBJS = djadmm.o djadmv.o djadsm.o djadsv.o djdnrmi.o djadnr.o\ djadmv2.o djadmv3.o djadmv4.o djadrws.o djdrws.o OBJS=$(FOBJS) diff --git a/base/serial/jad/djadprt.f b/base/serial/jad/djadprt.f deleted file mode 100644 index 3af07bce..00000000 --- a/base/serial/jad/djadprt.f +++ /dev/null @@ -1,93 +0,0 @@ -C -C Parallel Sparse BLAS v2.0 -C (C) Copyright 2006 Salvatore Filippone University of Rome Tor Vergata -C Alfredo Buttari University of Rome Tor Vergata -C -C Redistribution and use in source and binary forms, with or without -C modification, are permitted provided that the following conditions -C are met: -C 1. Redistributions of source code must retain the above copyright -C notice, this list of conditions and the following disclaimer. -C 2. Redistributions in binary form must reproduce the above copyright -C notice, this list of conditions, and the following disclaimer in the -C documentation and/or other materials provided with the distribution. -C 3. The name of the PSBLAS group or the names of its contributors may -C not be used to endorse or promote products derived from this -C software without specific written permission. -C -C THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -C ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -C TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -C PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PSBLAS GROUP OR ITS CONTRIBUTORS -C BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -C CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -C SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -C INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -C CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -C ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -C POSSIBILITY OF SUCH DAMAGE. -C -C -c -c What if a wrong DESCRA is passed? -c WARNING: THIS CANNOT POSSIBLY WORK CORRECTLY BECAUSE -c IT DOES NOT ACCOUNT FOR ROW PERMUTATION. -* -* - SUBROUTINE DJADPRT(NROW,NCOL,NG,A,KA,JA,IA,TITLE,IOUT) -C -C -C .. Scalar Arguments .. - INTEGER IOUT -C .. Array Arguments .. - DOUBLE PRECISION A(*) - INTEGER IA(3,*), JA(*), KA(*) - CHARACTER DESCRA*11, TITLE*(*) -C .. Local Scalars .. - INTEGER I, K - - -C .. External Subroutines .. -C -C - - nnzero = ja(ia(2,ng+1)-1+1)-1 - - write(iout,fmt=998) - - write(iout,fmt=992) - write(iout,fmt=996) - write(iout,fmt=996) title - write(iout,fmt=995) 'Number of rows: ',nrow - write(iout,fmt=995) 'Number of columns: ',ncol - write(iout,fmt=995) 'Nonzero entries: ',nnzero - write(iout,fmt=996) - write(iout,fmt=992) - write(iout,*) nrow,ncol,nnzero - 998 format('%%MatrixMarket matrix coordinate real general') - 997 format('%%MatrixMarket matrix coordinate real symmetric') - 992 format('%======================================== ') - 996 format('% ',a) - 995 format('% ',a,i9,a,i9,a,i9) - 994 format(i6,1x,i6,1x,e16.8) - - do ipg=1, ng - do k = ia(2,ipg), ia(3,ipg)-1 - ipx = ia(1,ipg) - do i = ja(k), ja(k+1) - 1 - write(iout,994) ipx,ka(i),a(i) - ipx = ipx + 1 - enddo - enddo - - ipx = ia(1,ipg) - do k = ia(3,ipg), ia(2,ipg+1)-1 - do i = ja(k), ja(k+1) - 1 - write(iout,994) ipx,ka(i),a(i) - enddo - ipx = ipx + 1 - enddo - enddo - - return - end diff --git a/base/serial/jad/djadsm.f b/base/serial/jad/djadsm.f index b201528c..3893fccc 100644 --- a/base/serial/jad/djadsm.f +++ b/base/serial/jad/djadsm.f @@ -30,6 +30,9 @@ C C SUBROUTINE DJADSM(TRANST,M,N,VDIAG,TDIAG,PERMQ,ALPHA,DESCRA, + AR,JA,IA,PERMP,B,LDB,BETA,C,LDC,WORK) + use psb_error_mod + use psb_string_mod + implicit none C C C .. Scalar Arguments .. @@ -44,15 +47,16 @@ C .. Local Scalars .. INTEGER PIA, PJA, PNG INTEGER I, K, ERR_ACT CHARACTER UPLO,UNITD - logical debug - parameter (debug=.false.) + integer :: debug_level, debug_unit CHARACTER*20 NAME - INTEGER INT_VAL(5) + INTEGER INT_VAL(5),ierror C .. Executable Statements .. C - NAME = 'DJADSM\0' + NAME = 'DJADSM' IERROR = 0 CALL FCPSB_ERRACTIONSAVE(ERR_ACT) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() IF((ALPHA.NE.1.D0) .OR. (BETA.NE.0.D0))then IERROR=5 @@ -60,8 +64,10 @@ C GOTO 9999 ENDIF UPLO = '?' - IF (DESCRA(1:1).EQ.'T' .AND. DESCRA(2:2).EQ.'U') UPLO = 'U' - IF (DESCRA(1:1).EQ.'T' .AND. DESCRA(2:2).EQ.'L') UPLO = 'L' + IF (toupper(DESCRA(1:1)).EQ.'T' .AND. + + toupper(DESCRA(2:2)).EQ.'U') UPLO = 'U' + IF (toupper(DESCRA(1:1)).EQ.'T' .AND. + + toupper(DESCRA(2:2)).EQ.'L') UPLO = 'L' C IF (UPLO.EQ.'?') THEN IERROR=5 @@ -69,7 +75,7 @@ C GOTO 9999 END IF - IF (DESCRA(3:3).NE.'U') THEN + IF (toupper(DESCRA(3:3)).NE.'U') THEN IERROR=5 CALL FCPSB_ERRPUSH(IERROR,NAME,INT_VAL) GOTO 9999 @@ -78,10 +84,12 @@ C C C B = INV(A)*B OR B=INV(A')*B C - if (debug) write(0,*) 'DJADSM : ',m,n,' ',tdiag + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': entry',m,n - IF (TDIAG.EQ.'R') THEN - if (debug) write(0,*) 'DJADSM : Right Scale',m,n + IF (toupper(TDIAG).EQ.'R') THEN + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': Right Scale' DO I = 1, N DO K = 1, M B(K,I) = B(K,I)*VDIAG(K) @@ -104,21 +112,16 @@ C END IF - if (debug) then - write(0,*) 'Check from DJADSM' - do k=1,m - write(0,*) k, b(k,1),c(k,1) - enddo - endif - - IF (TDIAG.EQ.'L') THEN + IF (toupper(TDIAG).EQ.'L') THEN + if (debug_level >= psb_debug_serial_comp_) + + write(debug_unit,*) trim(name),': Left Scale' DO I = 1, N DO K = 1, M C(K,I) = C(K,I)*VDIAG(K) ENDDO ENDDO END IF -c write(*,*) 'exit djadsm' + CALL FCPSB_ERRACTIONRESTORE(ERR_ACT) RETURN diff --git a/base/serial/psb_dcoins.f90 b/base/serial/psb_dcoins.f90 index dc323818..c636cbb4 100644 --- a/base/serial/psb_dcoins.f90 +++ b/base/serial/psb_dcoins.f90 @@ -28,9 +28,30 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psbdcoins.f90 - ! Subroutine: - ! Parameters: +! File: psb_dcoins.f90 +! Subroutine: psb_dcoins +! Takes a cloud of coefficients and inserts them into a sparse matrix. +! This subroutine is the serial, inner counterpart to the outer, user-level +! psb_spins. +! +! Arguments: +! +! nz - integer, input The number of points to insert. +! ia(:) - integer, input The row indices of the coefficients. +! ja(:) - integer, input The column indices of the coefficients. +! val(:) - real, input The values of the coefficients to be inserted. +! a - type(psb_dspmat_type), inout The sparse destination matrix. +! imin - integer, input The minimum valid row index +! imax - integer, input The maximum valid row index +! jmin - integer, input The minimum valid col index +! jmax - integer, input The maximum valid col index +! info - integer, output Return code. +! gtl(:) - integer, input,optional An index mapping to be applied +! default: identity +! rebuild - logical, input, optional Rebuild in case of update +! finding a new index. Default: false. +! Not fully tested. +! subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) use psb_spmat_type @@ -53,7 +74,7 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) character(len=5) :: ufida integer :: ng, nza, isza,spstate, & & ip1, nzl, err_act, int_err(5), iupd, irst - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit logical :: rebuild_ character(len=20) :: name, ch_err type(psb_dspmat_type) :: tmp @@ -61,6 +82,8 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) name='psb_dcoins' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() info = 0 if (nz <= 0) then @@ -134,14 +157,14 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) & imin,imax,jmin,jmax,info,gtl,ng) if(info /= izero) then - + ch_err='psb_inner_ins' call psb_errpush(4013,name,a_err=ch_err,i_err=(/info,0,0,0,0/)) goto 9999 endif - if (debug) then + if (debug_level >= psb_debug_serial_) then if ((nza - a%infoa(psb_nnz_)) /= nz) then - write(0,*) 'PSB_COINS: insert discarded items ' + write(debug_unit,*) trim(name),': insert discarded items ' end if end if if ((nza - psb_sp_getifld(psb_nnz_,a,info)) /= nz) then @@ -171,9 +194,9 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) call psb_errpush(4013,name,a_err=ch_err,i_err=(/info,0,0,0,0/)) goto 9999 endif - if (debug) then + if (debug_level >= psb_debug_serial_) then if ((nza - a%ia2(ip1+psb_nnz_)) /= nz) then - write(0,*) 'PSB_COINS: update discarded items ' + write(debug_unit,*) trim(name),': update discarded items ' end if end if @@ -184,7 +207,8 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) a%ia2(ip1+psb_nnz_) = nza end select - if (debug) write(0,*) 'From COINS(UPD) : NZA:',nza + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': (UPD) : NZA:',nza case (psb_upd_srch_) @@ -193,8 +217,10 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) if (info > 0) then if (rebuild_) then - if (debug) write(0,*)& - & 'COINS: Going through rebuild_ fingers crossed!' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*)& + & trim(name),& + & ': Going through rebuild_ fingers crossed!' irst = info call psb_nullify_sp(tmp) call psb_spcnv(a,tmp,info,afmt='coo') @@ -205,9 +231,9 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) goto 9999 endif call psb_sp_setifld(psb_spmat_bld_,psb_state_,tmp,info) - if (debug) then - write(0,*) 'COINS Rebuild: size',tmp%infoa(psb_nnz_) ,irst - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Rebuild size',tmp%infoa(psb_nnz_) ,irst call psb_sp_transfer(tmp,a,info) if(info /= izero) then info=4010 @@ -224,8 +250,9 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) goto 9999 endif - if (debug) write(0,*)& - & 'COINS: Reinserting',a%fida,nza,isza,irst,nz + if (debug_level >= psb_debug_serial_) write(debug_unit,*)& + & trim(name),': Reinserting',a%fida,nza,isza,irst,nz + if ((nza+nz)>isza) then call psb_sp_reall(a,max(nza+nz,int(1.5*isza)),info) if(info /= izero) then @@ -244,7 +271,7 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) ch_err='psb_inner_ins' call psb_errpush(4013,name,a_err=ch_err,i_err=(/info,0,0,0,0/)) endif - + call psb_sp_setifld(nza,psb_del_bnd_,a,info) call psb_sp_setifld(nza,psb_nnz_,a,info) end if @@ -320,14 +347,13 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) goto 9999 endif - if (debug) then + if (debug_level >= psb_debug_serial_) then if ((nza - a%infoa(psb_nnz_)) /= nz) then - write(0,*) 'PSB_COINS: insert discarded items ' + write(debug_unit,*) trim(name),': insert discarded items ' end if end if if ((nza - psb_sp_getifld(psb_nnz_,a,info)) /= nz) then call psb_sp_setifld(nza,psb_del_bnd_,a,info) -!!$ write(0,*) 'Settind del_bnd_ 2: ',nza endif call psb_sp_setifld(nza,psb_nnz_,a,info) @@ -349,14 +375,15 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) goto 9999 endif - if (debug) then + if (debug_level >= psb_debug_serial_) then if ((nza - a%ia2(ip1+psb_nnz_)) /= nz) then - write(0,*) 'PSB_COINS: update discarded items ' + write(debug_unit,*) trim(name),': update discarded items ' end if end if a%ia2(ip1+psb_nnz_) = nza - if (debug) write(0,*) 'From COINS(UPD) : NZA:',nza + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),':(UPD) : NZA:',nza case (psb_upd_srch_) @@ -365,15 +392,17 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) if (info > 0) then if (rebuild_) then - if (debug) write(0,*)& - & 'COINS: Going through rebuild_ fingers crossed!' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*)& + & trim(name),& + & ': Going through rebuild_ fingers crossed!' irst = info call psb_nullify_sp(tmp) call psb_spcnv(a,tmp,info,afmt='coo') call psb_sp_setifld(psb_spmat_bld_,psb_state_,tmp,info) - if (debug) then - write(0,*) 'COINS Rebuild: size',tmp%infoa(psb_nnz_) ,irst - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Rebuild size',tmp%infoa(psb_nnz_) ,irst call psb_sp_transfer(tmp,a,info) call psb_sp_info(psb_nztotreq_,a,nza,info) call psb_sp_info(psb_nzsizereq_,a,isza,info) @@ -384,8 +413,9 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) goto 9999 endif - if (debug) write(0,*)& - & 'COINS: Reinserting',a%fida,nza,isza + if (debug_level >= psb_debug_serial_) write(debug_unit,*)& + & trim(name),': Reinserting',a%fida,nza,isza + if ((nza+nz)>isza) then call psb_sp_reall(a,max(nza+nz,int(1.5*isza)),info) if(info /= izero) then @@ -404,7 +434,7 @@ subroutine psb_dcoins(nz,ia,ja,val,a,imin,imax,jmin,jmax,info,gtl,rebuild) ch_err='psb_inner_ins' call psb_errpush(4013,name,a_err=ch_err,i_err=(/info,0,0,0,0/)) endif - + call psb_sp_setifld(nza,psb_del_bnd_,a,info) call psb_sp_setifld(nza,psb_nnz_,a,info) end if @@ -473,7 +503,6 @@ contains do i=1, nz nza = nza + 1 if (nza>maxsz) then - write(0,*) 'Out of bounds in INNER_UPD ',nza,maxsz info = -71 return endif diff --git a/base/serial/psb_dcsrp.f90 b/base/serial/psb_dcsrp.f90 index cd5dc333..b0255bdf 100644 --- a/base/serial/psb_dcsrp.f90 +++ b/base/serial/psb_dcsrp.f90 @@ -40,7 +40,7 @@ ! should be applied ! iperm - integer, dimension(:) A permutation vector; its size ! must be either N_ROW or N_COL -! a - type( psb_dcsrp @@ -81,11 +81,6 @@ subroutine psb_dcsrp(trans,iperm,a, info) integer :: n_row,err_act, int_err(5) character(len=20) :: name, char_err - real(kind(1.d0)) :: time(10) - logical, parameter :: debug=.false. - - time(1) = psb_wtime() - n_row = psb_get_sp_nrows(a) n_col = psb_get_sp_ncols(a) @@ -146,10 +141,13 @@ subroutine psb_dcsrp(trans,iperm,a, info) goto 9999 end if - deallocate(ipt,work_dcsdp) - - time(4) = psb_wtime() - time(4) = time(4) - time(3) + deallocate(ipt,work_dcsdp,stat=info) + if(info /= psb_no_err_) then + info=4010 + char_err='Deallocate' + call psb_errpush(info,name,a_err=char_err) + goto 9999 + end if call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_dfixcoo.f90 b/base/serial/psb_dfixcoo.f90 index e30331fb..770f8399 100644 --- a/base/serial/psb_dfixcoo.f90 +++ b/base/serial/psb_dfixcoo.f90 @@ -49,15 +49,19 @@ subroutine psb_dfixcoo(a,info,idir) !locals Integer :: nza, nzl,iret,idir_, dupl_ integer :: i,j, irw, icl, err_act - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name = 'psb_fixcoo' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'fixcoo: ',size(a%ia1),size(a%ia2) + if(debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': start ',& + & size(a%ia1),size(a%ia2) if (toupper(a%fida) /= 'COO') then - write(0,*) 'Fixcoo Invalid input ',a%fida + write(debug_unit,*) 'Fixcoo Invalid input ',a%fida info = -1 return end if @@ -155,7 +159,8 @@ subroutine psb_dfixcoo(a,info,idir) end select - if(debug) write(0,*)'FIXCOO: end second loop' + if(debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end second loop' case(1) ! Col major order @@ -231,9 +236,10 @@ subroutine psb_dfixcoo(a,info,idir) endif enddo end select - if(debug) write(0,*)'FIXCOO: end second loop' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end second loop' case default - write(0,*) 'Fixcoo: unknown direction ',idir_ + write(debug_unit,*) trim(name),': unknown direction ',idir_ end select call psb_sp_setifld(psb_isrtdcoo_,psb_srtd_,a,info) diff --git a/base/serial/psb_dgelp.f90 b/base/serial/psb_dgelp.f90 index 49773d8b..b56643ef 100644 --- a/base/serial/psb_dgelp.f90 +++ b/base/serial/psb_dgelp.f90 @@ -56,7 +56,7 @@ subroutine psb_dgelp(trans,iperm,x,info) integer :: int_err(5), i1sz, i2sz, err_act integer, allocatable :: itemp(:) real(kind(1.d0)),parameter :: one=1 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit interface dgelp subroutine dgelp(trans,m,n,p,b,ldb,work,lwork,ierror) @@ -82,11 +82,15 @@ subroutine psb_dgelp(trans,iperm,x,info) if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() i1sz = size(x,dim=1) i2sz = size(x,dim=2) - if (debug) write(*,*) 'gelp: ',i1sz,i2sz + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': size',i1sz,i2sz + allocate(dtemp(i1sz),itemp(size(iperm)),stat=info) if (info /= 0) then info=2040 @@ -186,7 +190,7 @@ subroutine psb_dgelpv(trans,iperm,x,info) real(kind(1.d0)),allocatable :: dtemp(:) integer, allocatable :: itemp(:) real(kind(1.d0)),parameter :: one=1 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit interface dgelp subroutine dgelp(trans,m,n,p,b,ldb,work,lwork,ierror) @@ -212,10 +216,13 @@ subroutine psb_dgelpv(trans,iperm,x,info) if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() i1sz = size(x) - if (debug) write(*,*) 'gelp: ',i1sz + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': size',i1sz allocate(dtemp(i1sz),itemp(size(iperm)),stat=info) if (info /= 0) then info=2040 diff --git a/base/serial/psb_dipcoo2csc.f90 b/base/serial/psb_dipcoo2csc.f90 index fcbbf8e5..0bbbfcd3 100644 --- a/base/serial/psb_dipcoo2csc.f90 +++ b/base/serial/psb_dipcoo2csc.f90 @@ -51,16 +51,19 @@ subroutine psb_dipcoo2csc(a,info,clshr) logical :: clshr_ Integer :: nza, i,j, idl,err_act,nc,icl Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name name='psb_ipcoo2csc' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'Inside ipcoo2csc',a%fida,a%m + if(debug_level >= psb_debug_serial_) write(debug_unit,*) & + & trim(name),': start',a%fida,a%m if (toupper(a%fida) /= 'COO') then - write(0,*) 'ipcoo2csc Invalid input ',a%fida + write(debug_unit,*) trim(name),' Invalid input ',a%fida info = -1 call psb_errpush(info,name) goto 9999 @@ -80,7 +83,8 @@ subroutine psb_dipcoo2csc(a,info,clshr) call psb_errpush(info,name,a_err='integer',i_err=(/max(nc+1,1),0,0,0,0/)) goto 9999 end if - if(debug) write(0,*)'DIPCOO2CSC: out of fixcoo',nza,nc,size(a%ia2),size(iaux) + if(debug_level >= psb_debug_serial_) write(debug_unit,*) trim(name),& + & ': out of fixcoo',nza,nc,size(a%ia2),size(iaux) call psb_transfer(a%ia2,itemp,info) call psb_transfer(iaux,a%ia2,info) @@ -117,13 +121,13 @@ subroutine psb_dipcoo2csc(a,info,clshr) icl = itemp(j) i = i + 1 if (i>nc) then - write(0,*) 'IPCOO2CSC: CLSHR=.true. : ',& + write(debug_unit,*) trim(name),': CLSHR=.true. : ',& & i, nc,' Expect trouble!' exit end if endif enddo -! write(0,*) 'Exit from loop',j,nza,i +! write(debug_unit,*) 'Exit from loop',j,nza,i do if (i>=nc+1) exit a%ia2(i+1) = j @@ -133,7 +137,7 @@ subroutine psb_dipcoo2csc(a,info,clshr) else if (nc < itemp(nza)) then - write(0,*) 'IPCOO2CSC: CLSHR=.false. : ',& + write(debug_unit,*) trim(name),': CLSHR=.false. : ',& &nc,itemp(nza),' Expect trouble!' end if @@ -146,7 +150,8 @@ subroutine psb_dipcoo2csc(a,info,clshr) inner: do if (i >= icl) exit inner if (i>nc) then - write(0,*) 'strange situation: i>nc ',i,nc,j,nza,icl,idl + write(debug_unit,*) trim(name),& + & 'strange situation: i>nc ',i,nc,j,nza,icl,idl exit outer end if a%ia2(i+1) = a%ia2(i) @@ -156,7 +161,8 @@ subroutine psb_dipcoo2csc(a,info,clshr) if (j > nza) exit if (itemp(j) /= icl) then if (i>nc) then - write(0,*) 'Strange situation in coo2csc: ',i,nc,size(a%ia2),& + write(debug_unit,*) trim(name), & + &'Strange situation: ',i,nc,size(a%ia2),& & nza,j,itemp(j) end if a%ia2(i+1) = j @@ -169,7 +175,7 @@ subroutine psb_dipcoo2csc(a,info,clshr) ! Cleanup empty cols at the end ! if (j /= (nza+1)) then - write(0,*) 'IPCOO2CSC : Problem from loop :',j,nza,itemp(j) + write(debug_unit,*) trim(name),': Problem from loop :',j,nza,itemp(j) endif do if (i>nc) exit @@ -181,11 +187,18 @@ subroutine psb_dipcoo2csc(a,info,clshr) end if -!!$ write(0,*) 'IPcoo2csc end loop ',i,nc,a%ia2(nc+1),nza +!!$ write(debug_unit,*) 'IPcoo2csc end loop ',i,nc,a%ia2(nc+1),nza a%fida='CSC' a%infoa(psb_upd_) = psb_upd_srch_ - deallocate(itemp) + deallocate(itemp,stat=info) + if (info /= 0) then + info=4010 + call psb_errpush(info,name,a_err='deallocate') + goto 9999 + end if + if(debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_dipcoo2csr.f90 b/base/serial/psb_dipcoo2csr.f90 index d5ed2c60..04be25a4 100644 --- a/base/serial/psb_dipcoo2csr.f90 +++ b/base/serial/psb_dipcoo2csr.f90 @@ -51,16 +51,19 @@ subroutine psb_dipcoo2csr(a,info,rwshr) logical :: rwshr_ Integer :: nza, nr, i,j,irw, idl,err_act Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name name='psb_ipcoo2csr' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'Inside ipcoo2csr',a%fida,a%m + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': start',a%fida,a%m if (toupper(a%fida) /= 'COO') then - write(0,*) 'ipcoo2csr Invalid input ',a%fida + write(debug_unit,*) trim(name),': Invalid input ',a%fida info = -1 call psb_errpush(info,name) goto 9999 @@ -81,7 +84,9 @@ subroutine psb_dipcoo2csr(a,info,rwshr) goto 9999 end if - if(debug) write(0,*)'DIPCOO2CSR: out of fixcoo',nza,nr,size(a%ia2),size(iaux) + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & ': out of fixcoo',nza,nr,size(a%ia2),size(iaux) call psb_transfer(a%ia1,itemp,info) call psb_transfer(a%ia2,a%ia1,info) @@ -120,13 +125,12 @@ subroutine psb_dipcoo2csr(a,info,rwshr) irw = itemp(j) i = i + 1 if (i>nr) then - write(0,*) 'IPCOO2CSR: RWSHR=.true. : ',& + write(debug_unit,*) trim(name),': RWSHR=.true. : ',& & i, nr,' Expect trouble!' exit end if endif enddo -! write(0,*) 'Exit from loop',j,nza,i do if (i>=nr+1) exit a%ia2(i+1) = j @@ -136,7 +140,7 @@ subroutine psb_dipcoo2csr(a,info,rwshr) else if (nr < itemp(nza)) then - write(0,*) 'IPCOO2CSR: RWSHR=.false. : ',& + write(debug_unit,*) trim(name),': RWSHR=.false. : ',& &nr,itemp(nza),' Expect trouble!' info = 12 end if @@ -150,7 +154,8 @@ subroutine psb_dipcoo2csr(a,info,rwshr) inner: do if (i >= irw) exit inner if (i>nr) then - write(0,*) 'Strange situation: i>nr ',i,nr,j,nza,irw,idl + write(debug_unit,*) trim(name),& + & 'Strange situation: i>nr ',i,nr,j,nza,irw,idl exit outer end if a%ia2(i+1) = a%ia2(i) @@ -169,7 +174,7 @@ subroutine psb_dipcoo2csr(a,info,rwshr) ! Cleanup empty rows at the end ! if (j /= (nza+1)) then - write(0,*) 'IPCOO2CSR : Problem from loop :',j,nza + write(debug_unit,*) trim(name),': Problem from loop :',j,nza info = 13 endif do @@ -182,11 +187,17 @@ subroutine psb_dipcoo2csr(a,info,rwshr) end if -!!$ write(0,*) 'IPcoo2csr end loop ',i,nr,a%ia2(nr+1),nza a%fida='CSR' a%infoa(psb_upd_) = psb_upd_srch_ - deallocate(itemp) + deallocate(itemp,stat=info) + if (info /= 0) then + info=4010 + call psb_errpush(info,name,a_err='deallocate') + goto 9999 + end if + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_dipcsr2coo.f90 b/base/serial/psb_dipcsr2coo.f90 index e952ef36..62714db7 100644 --- a/base/serial/psb_dipcsr2coo.f90 +++ b/base/serial/psb_dipcsr2coo.f90 @@ -48,11 +48,9 @@ Subroutine psb_dipcsr2coo(a,info) !locals Integer :: nza, nr integer :: i,j,err_act - logical, parameter :: debug=.false. integer, allocatable :: iaux(:), itemp(:) - character(len=20) :: name + character(len=20) :: name='psb_dipcsr2coo' - name='psb_dipcsr2coo' info = 0 call psb_erractionsave(err_act) diff --git a/base/serial/psb_dspcnv.f90 b/base/serial/psb_dspcnv.f90 index 86a92e51..ef205a55 100644 --- a/base/serial/psb_dspcnv.f90 +++ b/base/serial/psb_dspcnv.f90 @@ -28,20 +28,17 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_dcsdp.f90 +! File: psb_dspcnv.f90 ! -! Subroutine: psb_dcsdp -! This subroutine performs the assembly of -! the local part of a sparse distributed matrix +! Subroutine: psb_dspcnv2 +! This subroutine converts the storage format of a matrix. ! ! Arguments: -! a - type(). The input matrix to be assembled. -! b - type(). The assembled output matrix. +! +! a - type(psb_spmat_type), input The input matrix to be converted. +! b - type(psb_spmat_type), output The assembled output matrix. ! info - integer. Return code -! ifc - integer(optional). ??? -! check - character(optional). ??? -! trans - character(optional). ??? -! unitd - character(optional). ??? +! afmt - character, optional The desired storage format ! subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) use psb_const_mod @@ -67,12 +64,14 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) character :: check_,trans_,unitd_ character(len=5) :: afmt_ Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err - name='psb_spcnv' + name='psb_spcnv2' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ntry=0 @@ -128,7 +127,6 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) b%k=a%k b%fida=afmt_ size_req = psb_sp_get_nnzeros(a) - if (debug) write(0,*) 'DCSDP : size_req 1:',size_req ! n_row=b%m n_col=b%k @@ -167,6 +165,9 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) b%pr(:) = 0 b%descra = a%descra + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': size_req 1:',& + & size_req, trans_,upd_,dupl_,b%fida,b%descra select case (tolower(a%fida)) @@ -205,12 +206,13 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) endif ntry = ntry + 1 - if (debug) then - write(0,*) 'On out from dcrjad ',nzr,info + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),' On out from dcrjad ',nzr,info end if if (nzr == 0) exit if (ntry > maxtry ) then - write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.' + write(debug_unit,*) trim(name),& + & ' Tried reallocating for DCRJAD for ',maxtry,': giving up now.' info=2040 call psb_errpush(info,name) goto 9999 @@ -232,7 +234,8 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) end if case ('coo') - if (debug) write(0,*) 'Calling CRCO ',a%descra + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),' Calling CRCO ',a%descra call dcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,& & a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,& & b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),& @@ -301,13 +304,13 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) end if ntry = ntry + 1 - if (debug) then - write(0,*) 'On out from dcrjad ',nzr,info + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),' On out from dcrjad ',nzr,info end if if (nzr == 0) exit if (ntry > maxtry ) then - write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,& - & ': giving up now.' + write(debug_unit,*) trim(name),' Tried reallocating for DCRJAD for ',& + & maxtry,': giving up now.' info=2040 call psb_errpush(info,name) goto 9999 @@ -366,6 +369,16 @@ subroutine psb_dspcnv2(a, b,info,afmt,upd,dupl) end subroutine psb_dspcnv2 +! +! Subroutine: psb_dspcnv1 +! This subroutine converts in place the storage format of a matrix. +! +! Arguments: +! +! a - type(psb_spmat_type), inout The input matrix to be converted. +! info - integer. Return code +! afmt - character, optional The desired storage format +! subroutine psb_dspcnv1(a, info, afmt, upd, dupl) use psb_spmat_type @@ -391,13 +404,15 @@ subroutine psb_dspcnv1(a, info, afmt, upd, dupl) integer :: err_act integer :: spstate integer :: upd_, dupl_ - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err info = 0 int_err(1)=0 - name = 'psb_spcnv' + name = 'psb_spcnv1' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if (present(upd)) then call psb_sp_setifld(upd,psb_upd_,a,info) @@ -431,10 +446,14 @@ subroutine psb_dspcnv1(a, info, afmt, upd, dupl) if (info /= 0) then goto 9999 endif - if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': Sparse matrix state:',& + & spstate,psb_spmat_bld_,psb_spmat_upd_ if (spstate /= psb_spmat_upd_) then ! Should we first figure out if we can do it in place? - if (debug) write(0,*) 'Update:',upd_,psb_upd_srch_,psb_upd_perm_ + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Update:',upd_,psb_upd_srch_,psb_upd_perm_ if (upd_ == psb_upd_srch_) then if (present(afmt)) then select case (tolower(a%fida)) @@ -473,7 +492,10 @@ subroutine psb_dspcnv1(a, info, afmt, upd, dupl) ! result is put in A call psb_spcnv(atemp,a,info,afmt=afmt,upd=upd,dupl=dupl) - IF (debug) WRITE (*, *) ' ASB: From SPCNV',info,' ',A%FIDA + if (debug_level >= psb_debug_serial_)& + & write(debug_unit, *) trim(name),& + & ': From SPCNV',info,' ',a%fida + if (info /= psb_no_err_) then info=4010 ch_err='psb_csdp' @@ -501,8 +523,6 @@ subroutine psb_dspcnv1(a, info, afmt, upd, dupl) goto 9999 end select - - ! check on error retuned by dcsdp if (info /= psb_no_err_) then info = 4010 ch_err='xx_regen' @@ -515,7 +535,9 @@ subroutine psb_dspcnv1(a, info, afmt, upd, dupl) info = 600 call psb_errpush(info,name) goto 9999 - if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ endif diff --git a/base/serial/psb_dspgetrow.f90 b/base/serial/psb_dspgetrow.f90 index fee8db2f..2f13dc96 100644 --- a/base/serial/psb_dspgetrow.f90 +++ b/base/serial/psb_dspgetrow.f90 @@ -32,10 +32,20 @@ ! Subroutine: psb_dspgetrow ! Gets one or more rows from a sparse matrix. ! Arguments: -!***************************************************************************** -!* * -!* * -!***************************************************************************** +! irw - integer, input The row to be extracted +! a - type(psb_dspmat_type),input The sparse matrix +! nz - integer, output The number of entries +! ia(:) - integer, allocatable, inout The output row indices +! ja(:) - integer, allocatable, inout The output col indices +! val(:) - real, allocatable,inout The coefficients +! info - integer, output Error code +! iren(:) - integer, input,optional Renumbering of indices +! lrw - integer, input,optional Extract rows irw:lrw, default lrw=irw +! append - logical, input,optional Should we append to already existing +! partial output? +! nzin - integer, input, optional If appending, how many entries were already +! occupied. +! subroutine psb_dspgetrow(irw,a,nz,ia,ja,val,info,iren,lrw,append,nzin) ! Output is always in COO format use psb_spmat_type diff --git a/base/serial/psb_dspgtdiag.f90 b/base/serial/psb_dspgtdiag.f90 index 4276115d..e083dbe9 100644 --- a/base/serial/psb_dspgtdiag.f90 +++ b/base/serial/psb_dspgtdiag.f90 @@ -58,7 +58,9 @@ subroutine psb_dspgtdiag(a,d,info) call psb_erractionsave(err_act) if (size(d) < min(a%k,a%m)) then - write(0,*) 'Insufficient space in DSPGTDIAG ', size(d),min(a%m,a%k) + info=35 + call psb_errpush(info,name,i_err=(/2,size(d),0,0,0/)) + goto 9999 end if d(:) = 0.d0 if (a%fida == 'CSR') then diff --git a/base/serial/psb_getrow_mod.f90 b/base/serial/psb_getrow_mod.f90 index 0a532eb9..63c22957 100644 --- a/base/serial/psb_getrow_mod.f90 +++ b/base/serial/psb_getrow_mod.f90 @@ -129,6 +129,7 @@ contains use psb_spmat_type use psb_const_mod + use psb_error_mod implicit none type(psb_dspmat_type), intent(in) :: a @@ -141,17 +142,21 @@ contains integer :: lrw,info integer, optional :: iren(:) integer :: nzin_, nza, idx,ip,jp,i,k, nzt - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='coo_dspgtrow' + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() nza = a%infoa(psb_nnz_) if (a%pl(1) /= 0) then - write(0,*) 'Fatal error in SPGTROW: do not feed a permuted mat so far!' + write(debug_unit,*) 'Fatal error in SPGTROW: do not feed a permuted mat so far!' idx = -1 else idx = irw endif if (idx<0) then - write(0,*) ' spgtrow Error : idx no good ',idx + write(debug_unit,*) ' spgtrow Error : idx no good ',idx return end if @@ -163,13 +168,16 @@ contains if (a%infoa(psb_srtd_) == psb_isrtdcoo_) then ! In this case we can do a binary search. - if (debug) write(0,*) 'coo_getrow: srtdcoo ' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name), ': srtdcoo ' do call ibsrch(ip,irw,nza,a%ia1) if (ip /= -1) exit irw = irw + 1 if (irw > lrw) then - write(0,*) 'Warning : did not find any rows. Is this an error? ',irw,lrw,idx + write(debug_unit,*) trim(name),& + & 'Warning : did not find any rows. Is this an error? ',& + & irw,lrw,idx exit end if end do @@ -192,7 +200,8 @@ contains if (jp /= -1) exit lrw = lrw - 1 if (irw > lrw) then - write(0,*) 'Warning : did not find any rows. Is this an error?' + write(debug_unit,*) trim(name),& + & 'Warning : did not find any rows. Is this an error?' exit end if end do @@ -208,7 +217,8 @@ contains end if end do end if - if (debug) write(0,*) 'coo_getrow: ip jp',ip,jp,nza + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': ip jp',ip,jp,nza if ((ip /= -1) .and.(jp /= -1)) then ! Now do the copy. nz = jp - ip +1 @@ -238,9 +248,10 @@ contains end if else - if (debug) write(0,*) 'coo_getrow: unsorted ' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': unsorted ' + nzt = (nza*(lrw-irw+1))/max(a%m,1) - call psb_ensure_size(nzin_+nzt,ia,info) if (info==0) call psb_ensure_size(nzin_+nzt,ja,info) if (info==0) call psb_ensure_size(nzin_+nzt,val,info) @@ -293,6 +304,7 @@ contains use psb_spmat_type use psb_const_mod + implicit none type(psb_dspmat_type), intent(in), target :: a @@ -424,6 +436,7 @@ contains use psb_spmat_type use psb_const_mod + use psb_error_mod implicit none type(psb_zspmat_type), intent(in) :: a @@ -438,6 +451,10 @@ contains integer :: idx,i,j, k, nr, row_idx, nzin_ integer, allocatable :: indices(:) + integer :: debug_level, debug_unit + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if (append) then nzin_ = nzin @@ -522,7 +539,8 @@ contains enddo end if if (a%pr(1) /= 0) then - write(0,*) 'Feeling lazy today, Right Permutation will have to wait' + write(debug_unit,*)& + & 'Feeling lazy today, Right Permutation will have to wait' endif endif @@ -534,6 +552,7 @@ contains use psb_spmat_type use psb_const_mod + use psb_error_mod implicit none type(psb_zspmat_type), intent(in) :: a @@ -546,17 +565,23 @@ contains integer :: lrw,info integer, optional :: iren(:) integer :: nzin_, nza, idx,ip,jp,i,k, nzt - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='coo_zspgtrow' + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() nza = a%infoa(psb_nnz_) if (a%pl(1) /= 0) then - write(0,*) 'Fatal error in SPGTROW: do not feed a permuted mat so far!' + write(debug_unit,*) trim(name),& + & 'Fatal error: do not feed a permuted mat so far!' idx = -1 else idx = irw endif if (idx<0) then - write(0,*) ' spgtrow Error : idx no good ',idx + write(debug_unit,*) trim(name),& + &' Error : idx no good ',idx return end if @@ -568,13 +593,16 @@ contains if (a%infoa(psb_srtd_) == psb_isrtdcoo_) then ! In this case we can do a binary search. - if (debug) write(0,*) 'coo_getrow: srtdcoo ' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': srtdcoo ' do call ibsrch(ip,irw,nza,a%ia1) if (ip /= -1) exit irw = irw + 1 if (irw > lrw) then - write(0,*) 'Warning : did not find any rows. Is this an error? ',irw,lrw,idx + write(debug_unit,*) trim(name),& + & 'Warning : did not find any rows. Is this an error? ',& + & irw,lrw,idx exit end if end do @@ -597,7 +625,8 @@ contains if (jp /= -1) exit lrw = lrw - 1 if (irw > lrw) then - write(0,*) 'Warning : did not find any rows. Is this an error?' + write(debug_unit,*) trim(name),& + & 'Warning : did not find any rows. Is this an error?' exit end if end do @@ -613,7 +642,8 @@ contains end if end do end if - if (debug) write(0,*) 'coo_getrow: ip jp',ip,jp,nza + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': ip jp',ip,jp,nza if ((ip /= -1) .and.(jp /= -1)) then ! Now do the copy. nz = jp - ip +1 @@ -643,7 +673,8 @@ contains end if else - if (debug) write(0,*) 'coo_getrow: unsorted ' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': unsorted ' nzt = (nza*(lrw-irw+1))/max(a%m,1) call psb_ensure_size(nzin_+nzt,ia,info) diff --git a/base/serial/psb_regen_mod.f90 b/base/serial/psb_regen_mod.f90 index 1cdfc16a..c025cc20 100644 --- a/base/serial/psb_regen_mod.f90 +++ b/base/serial/psb_regen_mod.f90 @@ -26,11 +26,14 @@ contains real(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + name='psb_spcnv' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! @@ -47,19 +50,21 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia2(ip1+psb_ip2_) nnz = a%ia2(ip1+psb_nnz_) iflag = a%ia2(ip1+psb_iflag_) ichk = a%ia2(ip1+psb_ichk_) nnzt = a%ia2(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),'Regeneration start: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& + write(debug_unit,*) trim(name),'Regeneration start error: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 @@ -89,7 +94,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 @@ -125,11 +132,14 @@ contains real(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + name='psb_spcnv' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! @@ -146,19 +156,21 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia2(ip1+psb_ip2_) nnz = a%ia2(ip1+psb_nnz_) iflag = a%ia2(ip1+psb_iflag_) ichk = a%ia2(ip1+psb_ichk_) nnzt = a%ia2(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration start: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& + write(debug_unit,*) trim(name),'Regeneration start error: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 @@ -188,7 +200,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 @@ -224,11 +238,13 @@ contains real(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit name='psb_spcnv' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! @@ -245,19 +261,21 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia1(ip1+psb_ip2_) nnz = a%ia1(ip1+psb_nnz_) iflag = a%ia1(ip1+psb_iflag_) ichk = a%ia1(ip1+psb_ichk_) nnzt = a%ia1(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration start: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& + write(debug_unit,*) trim(name),'Regeneration start error: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 @@ -287,7 +305,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 @@ -325,11 +345,13 @@ contains complex(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. - + integer :: debug_level, debug_unit + name='psb_spcnv' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! @@ -346,19 +368,21 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia2(ip1+psb_ip2_) nnz = a%ia2(ip1+psb_nnz_) iflag = a%ia2(ip1+psb_iflag_) ichk = a%ia2(ip1+psb_ichk_) nnzt = a%ia2(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration start: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& + write(debug_unit,*) trim(name),'Regeneration start error: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 @@ -388,7 +412,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 @@ -424,12 +450,13 @@ contains complex(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit name='psb_spcnv' info = 0 call psb_erractionsave(err_act) - + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! ! dupl_ and upd_ fields should not be changed. @@ -445,19 +472,21 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia2(ip1+psb_ip2_) nnz = a%ia2(ip1+psb_nnz_) iflag = a%ia2(ip1+psb_iflag_) ichk = a%ia2(ip1+psb_ichk_) nnzt = a%ia2(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),'Regeneration start: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& + write(debug_unit,*) trim(name),'Regeneration start error: ',& & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 @@ -487,7 +516,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 @@ -523,11 +554,13 @@ contains complex(kind(1.d0)), allocatable :: work(:) integer :: err_act character(len=20) :: name - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit name='psb_spcnv' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ! @@ -544,20 +577,22 @@ contains goto 9999 end if - if (debug) write(0,*) 'Regeneration with psb_upd_perm_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),'Regeneration with psb_upd_perm_' ip1 = psb_sp_getifld(psb_upd_pnt_,a,info) ip2 = a%ia1(ip1+psb_ip2_) nnz = a%ia1(ip1+psb_nnz_) iflag = a%ia1(ip1+psb_iflag_) ichk = a%ia1(ip1+psb_ichk_) nnzt = a%ia1(ip1+psb_nnzt_) - if (debug) write(*,*) 'Regeneration start: ',& - & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),'Regeneration start: ',& + & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,info if ((ichk/=nnzt+iflag).or.(nnz/=nnzt)) then info = 8889 - write(*,*) 'Regeneration start error: ',& - & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk + write(debug_unit,*) trim(name),'Regeneration start error: ',& + & a%infoa(psb_upd_),psb_upd_perm_,nnz,nnzt ,iflag,ichk call psb_errpush(info,name) goto 9999 endif @@ -586,7 +621,9 @@ contains case(psb_upd_srch_) ! Nothing to be done here. - if (debug) write(0,*) 'Going through on regeneration with psb_upd_srch_' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & 'Going through on regeneration with psb_upd_srch_' case default ! Wrong value info = 8888 diff --git a/base/serial/psb_update_mod.f90 b/base/serial/psb_update_mod.f90 index 1ccf37ec..95e8fb15 100644 --- a/base/serial/psb_update_mod.f90 +++ b/base/serial/psb_update_mod.f90 @@ -164,6 +164,7 @@ contains use psb_realloc_mod use psb_string_mod use psb_serial_mod + use psb_error_mod implicit none type(psb_dspmat_type), intent(inout) :: a @@ -174,15 +175,17 @@ contains integer, intent(out) :: info integer, intent(in), optional :: ng,gtl(*) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='d_csr_srch_upd' integer :: i,ir,ic, ilr, ilc, ip, & & i1,i2,nc,lb,ub,m,dupl info = 0 + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() dupl = psb_sp_getifld(psb_dupl_,a,info) - if (present(gtl)) then if (.not.present(ng)) then info = -1 @@ -213,8 +216,10 @@ contains if (ip>0) then a%aspk(i1+ip-1) = val(i) else - if (debug) & - & write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if @@ -227,7 +232,6 @@ contains do if (lb > ub) exit m = (lb+ub)/2 -!!$ write(0,*) 'Debug: ',lb,m,ub if (ic == a%ia1(m)) then ip = m lb = ub + 1 @@ -241,15 +245,19 @@ contains if (ip>0) then a%aspk(ip) = val(i) else - if (debug) write(0,*)'Was searching ',ic,& - & ' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if end if else - if (debug) write(0,*) 'Discarding row that does not belong to us.' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' end if end if end do @@ -268,25 +276,30 @@ contains i1 = a%ia2(ir) i2 = a%ia2(ir+1) nc = i2-i1 -!!$ write(0,*) 'ir ic ',ir,ic,i1,i2,a%m,a%k call issrch(ip,ic,nc,a%ia1(i1:i2-1)) if (ip>0) then a%aspk(i1+ip-1) = a%aspk(i1+ip-1) + val(i) else - if (debug) write(0,*)'Was searching ',ic,& - & ' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if else - if (debug) write(0,*) 'Discarding row that does not belong to us.' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' end if end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select else @@ -314,21 +327,21 @@ contains if (ip>0) then a%aspk(i1+ip-1) = val(i) else - if (debug) write(0,*)'Was searching ',ic,& - & ' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if else -!!$ ip = -1 lb = i1 ub = i2-1 do if (lb > ub) exit m = (lb+ub)/2 -!!$ write(0,*) 'Debug: ',lb,m,ub if (ic == a%ia1(m)) then ip = m lb = ub + 1 @@ -342,14 +355,18 @@ contains if (ip>0) then a%aspk(ip) = val(i) else - if (debug) write(0,*)'Was searching ',ic,& - & ' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if end if else - if (debug) write(0,*) 'Discarding row that does not belong to us.' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' end if end do @@ -373,13 +390,17 @@ contains return end if else - if (debug) write(0,*) 'Discarding row that does not belong to us.' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select end if @@ -404,10 +425,12 @@ contains integer, intent(in), optional :: ng,gtl(*) integer :: i,ir,ic, ilr, ilc, ip, & & i1,i2,nc,nnz,dupl - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='d_coo_srch_upd' info = 0 - + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() dupl = psb_sp_getifld(psb_dupl_,a,info) if (psb_sp_getifld(psb_srtd_,a,info) /= psb_isrtdcoo_) then @@ -464,7 +487,9 @@ contains return end if else - if (debug) write(0,*) 'Discarding row does not belong' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' endif end if end do @@ -505,15 +530,18 @@ contains return end if else - if (debug) write(0,*) 'Discarding row does not belong' - + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' end if end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select else @@ -594,7 +622,9 @@ contains case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select end if @@ -860,12 +890,15 @@ contains integer :: i,ir,ic, ilr, ilc, ip, & & i1,i2,nc,lb,ub,m,dupl - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='z_csr_srch_upd' + info = 0 + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() dupl = psb_sp_getifld(psb_dupl_,a,info) - if (present(gtl)) then if (.not.present(ng)) then info = -1 @@ -884,7 +917,7 @@ contains ic = ja(i) if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then ir = gtl(ir) - ic = gtl(ic) + ic = gtl(ic) if ((ir > 0).and.(ir <= a%m)) then i1 = a%ia2(ir) i2 = a%ia2(ir+1) @@ -896,7 +929,10 @@ contains if (ip>0) then a%aspk(i1+ip-1) = val(i) else - write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if @@ -909,7 +945,6 @@ contains do if (lb > ub) exit m = (lb+ub)/2 -!!$ write(0,*) 'Debug: ',lb,m,ub if (ic == a%ia1(m)) then ip = m lb = ub + 1 @@ -923,16 +958,20 @@ contains if (ip>0) then a%aspk(ip) = val(i) else - write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if end if else - if (debug) write(0,*) 'Discarding row does not belong' - endif - + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' + end if end if end do @@ -945,7 +984,7 @@ contains ic = ja(i) if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then ir = gtl(ir) - ic = gtl(ic) + ic = gtl(ic) if ((ir > 0).and.(ir <= a%m)) then i1 = a%ia2(ir) i2 = a%ia2(ir+1) @@ -954,18 +993,26 @@ contains if (ip>0) then a%aspk(i1+ip-1) = a%aspk(i1+ip-1) + val(i) else + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if else - if (debug) write(0,*) 'Discarding row does not belong' - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' + end if end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select else @@ -980,7 +1027,9 @@ contains do i=1, nz ir = ia(i) ic = ja(i) + if ((ir > 0).and.(ir <= a%m)) then + i1 = a%ia2(ir) i2 = a%ia2(ir+1) nc=i2-i1 @@ -991,20 +1040,21 @@ contains if (ip>0) then a%aspk(i1+ip-1) = val(i) else - write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if else -!!$ ip = -1 lb = i1 ub = i2-1 do if (lb > ub) exit m = (lb+ub)/2 -!!$ write(0,*) 'Debug: ',lb,m,ub if (ic == a%ia1(m)) then ip = m lb = ub + 1 @@ -1018,15 +1068,20 @@ contains if (ip>0) then a%aspk(ip) = val(i) else - write(0,*)'Was searching ',ic,' in: ',i1,i2,' : ',a%ia1(i1:i2-1) + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Was searching ',ic,' in: ',i1,i2,& + & ' : ',a%ia1(i1:i2-1) info = i return end if - end if else - if (debug) write(0,*) 'Discarding row does not belong' - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' + end if + end do case(psb_dupl_add_) @@ -1048,13 +1103,17 @@ contains return end if else - if (debug) write(0,*) 'Discarding row does not belong' - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' + end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select end if @@ -1079,10 +1138,13 @@ contains integer, intent(in), optional :: ng,gtl(*) integer :: i,ir,ic, ilr, ilc, ip, & & i1,i2,nc,nnz,dupl - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit + character(len=20) :: name='z_coo_srch_upd' - info = 0 + info = 0 + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() dupl = psb_sp_getifld(psb_dupl_,a,info) if (psb_sp_getifld(psb_srtd_,a,info) /= psb_isrtdcoo_) then @@ -1110,8 +1172,8 @@ contains ic = ja(i) if ((ir >=1).and.(ir<=ng).and.(ic>=1).and.(ic<=ng)) then ir = gtl(ir) - ic = gtl(ic) if ((ir > 0).and.(ir <= a%m)) then + ic = gtl(ic) if (ir /= ilr) then call ibsrch(i1,ir,nnz,a%ia1) i2 = i1 @@ -1139,7 +1201,9 @@ contains return end if else - if (debug) write(0,*) 'Discarding row does not belong' + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' endif end if end do @@ -1152,6 +1216,7 @@ contains ir = gtl(ir) ic = gtl(ic) if ((ir > 0).and.(ir <= a%m)) then + if (ir /= ilr) then call ibsrch(i1,ir,nnz,a%ia1) i2 = i1 @@ -1179,14 +1244,18 @@ contains return end if else - if (debug) write(0,*) 'Discarding row does not belong' - endif + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Discarding row that does not belong to us.' + end if end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select else @@ -1199,6 +1268,7 @@ contains ir = ia(i) ic = ja(i) if ((ir > 0).and.(ir <= a%m)) then + if (ir /= ilr) then call ibsrch(i1,ir,nnz,a%ia1) i2 = i1 @@ -1225,9 +1295,7 @@ contains info = i return end if - else - if (debug) write(0,*) 'Discarding row does not belong' - endif + end if end do case(psb_dupl_add_) @@ -1236,6 +1304,7 @@ contains ir = ia(i) ic = ja(i) if ((ir > 0).and.(ir <= a%m)) then + if (ir /= ilr) then call ibsrch(i1,ir,nnz,a%ia1) i2 = i1 @@ -1262,14 +1331,14 @@ contains info = i return end if - else - if (debug) write(0,*) 'Discarding row does not belong' - endif + end if end do case default info = -3 - if (debug) write(0,*) 'Duplicate handling: ',dupl + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Duplicate handling: ',dupl end select end if diff --git a/base/serial/psb_zcsrp.f90 b/base/serial/psb_zcsrp.f90 index 2dffde7e..c4d27294 100644 --- a/base/serial/psb_zcsrp.f90 +++ b/base/serial/psb_zcsrp.f90 @@ -40,7 +40,7 @@ ! should be applied ! iperm - integer, dimension(:) A permutation vector; its size ! must be either N_ROW or N_COL -! a - type( psb_zcsrp @@ -79,10 +79,7 @@ subroutine psb_zcsrp(trans,iperm,a, info) complex(kind(1.d0)), allocatable :: work_dcsdp(:) integer :: n_row,err_act, int_err(5) character(len=20) :: name, char_err - real(kind(1.d0)) :: time(10) - logical, parameter :: debug=.false. - time(1) = psb_wtime() n_row = psb_get_sp_nrows(a) n_col = psb_get_sp_ncols(a) @@ -144,10 +141,13 @@ subroutine psb_zcsrp(trans,iperm,a, info) goto 9999 end if - deallocate(ipt,work_dcsdp) - - time(4) = psb_wtime() - time(4) = time(4) - time(3) + deallocate(ipt,work_dcsdp,stat=info) + if(info /= psb_no_err_) then + info=4010 + char_err='Deallocate' + call psb_errpush(info,name,a_err=char_err) + goto 9999 + end if call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_zfixcoo.f90 b/base/serial/psb_zfixcoo.f90 index ae4e62cb..8298e0fb 100644 --- a/base/serial/psb_zfixcoo.f90 +++ b/base/serial/psb_zfixcoo.f90 @@ -49,15 +49,19 @@ Subroutine psb_zfixcoo(a,info,idir) !locals Integer :: nza, nzl,iret,idir_, dupl_ integer :: i,j, irw, icl, err_act - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name = 'psb_fixcoo' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'fixcoo: ',size(a%ia1),size(a%ia2) + if(debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': start ',& + & size(a%ia1),size(a%ia2) if (toupper(a%fida) /= 'COO') then - write(0,*) 'Fixcoo Invalid input ',a%fida + write(debug_unit,*) 'Fixcoo Invalid input ',a%fida info = -1 return end if @@ -155,7 +159,8 @@ Subroutine psb_zfixcoo(a,info,idir) end select - if(debug) write(0,*)'FIXCOO: end second loop' + if(debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end second loop' case(1) ! Col major order @@ -231,9 +236,10 @@ Subroutine psb_zfixcoo(a,info,idir) endif enddo end select - if(debug) write(0,*)'FIXCOO: end second loop' + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end second loop' case default - write(0,*) 'Fixcoo: unknown direction ',idir_ + write(debug_unit,*) trim(name),': unknown direction ',idir_ end select call psb_sp_setifld(psb_isrtdcoo_,psb_srtd_,a,info) diff --git a/base/serial/psb_zipcoo2csc.f90 b/base/serial/psb_zipcoo2csc.f90 index e137348d..4d8bc1ca 100644 --- a/base/serial/psb_zipcoo2csc.f90 +++ b/base/serial/psb_zipcoo2csc.f90 @@ -51,16 +51,19 @@ subroutine psb_zipcoo2csc(a,info,clshr) logical :: clshr_ Integer :: nza, i,j, idl,err_act,nc,icl Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name name='psb_ipcoo2csc' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'Inside ipcoo2csc',a%fida,a%m + if(debug_level >= psb_debug_serial_) write(debug_unit,*) & + & trim(name),': start',a%fida,a%m if (toupper(a%fida) /= 'COO') then - write(0,*) 'ipcoo2csc Invalid input ',a%fida + write(debug_unit,*) trim(name),' Invalid input ',a%fida info = -1 call psb_errpush(info,name) goto 9999 @@ -80,7 +83,8 @@ subroutine psb_zipcoo2csc(a,info,clshr) call psb_errpush(info,name,a_err='integer',i_err=(/max(nc+1,1),0,0,0,0/)) goto 9999 end if - if(debug) write(0,*)'DIPCOO2CSC: out of fixcoo',nza,nc,size(a%ia2),size(iaux) + if(debug_level >= psb_debug_serial_) write(debug_unit,*) trim(name),& + & ': out of fixcoo',nza,nc,size(a%ia2),size(iaux) call psb_transfer(a%ia2,itemp,info) call psb_transfer(iaux,a%ia2,info) @@ -117,13 +121,13 @@ subroutine psb_zipcoo2csc(a,info,clshr) icl = itemp(j) i = i + 1 if (i>nc) then - write(0,*) 'IPCOO2CSC: CLSHR=.true. : ',& + write(debug_unit,*) trim(name),': CLSHR=.true. : ',& & i, nc,' Expect trouble!' exit end if endif enddo -! write(0,*) 'Exit from loop',j,nza,i +! write(debug_unit,*) 'Exit from loop',j,nza,i do if (i>=nc+1) exit a%ia2(i+1) = j @@ -133,7 +137,7 @@ subroutine psb_zipcoo2csc(a,info,clshr) else if (nc < itemp(nza)) then - write(0,*) 'IPCOO2CSC: CLSHR=.false. : ',& + write(debug_unit,*) trim(name),': CLSHR=.false. : ',& &nc,itemp(nza),' Expect trouble!' end if @@ -146,7 +150,8 @@ subroutine psb_zipcoo2csc(a,info,clshr) inner: do if (i >= icl) exit inner if (i>nc) then - write(0,*) 'strange situation: i>nc ',i,nc,j,nza,icl,idl + write(debug_unit,*) trim(name),& + & 'strange situation: i>nc ',i,nc,j,nza,icl,idl exit outer end if a%ia2(i+1) = a%ia2(i) @@ -156,7 +161,8 @@ subroutine psb_zipcoo2csc(a,info,clshr) if (j > nza) exit if (itemp(j) /= icl) then if (i>nc) then - write(0,*) 'Strange situation in coo2csc: ',i,nc,size(a%ia2),& + write(debug_unit,*) trim(name), & + &'Strange situation: ',i,nc,size(a%ia2),& & nza,j,itemp(j) end if a%ia2(i+1) = j @@ -169,7 +175,7 @@ subroutine psb_zipcoo2csc(a,info,clshr) ! Cleanup empty cols at the end ! if (j /= (nza+1)) then - write(0,*) 'IPCOO2CSC : Problem from loop :',j,nza,itemp(j) + write(debug_unit,*) trim(name),': Problem from loop :',j,nza,itemp(j) endif do if (i>nc) exit @@ -181,11 +187,18 @@ subroutine psb_zipcoo2csc(a,info,clshr) end if -!!$ write(0,*) 'IPcoo2csc end loop ',i,nc,a%ia2(nc+1),nza +!!$ write(debug_unit,*) 'IPcoo2csc end loop ',i,nc,a%ia2(nc+1),nza a%fida='CSC' a%infoa(psb_upd_) = psb_upd_srch_ - deallocate(itemp) + deallocate(itemp,stat=info) + if (info /= 0) then + info=4010 + call psb_errpush(info,name,a_err='deallocate') + goto 9999 + end if + if(debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_zipcoo2csr.f90 b/base/serial/psb_zipcoo2csr.f90 index 6cc5474e..90f633a7 100644 --- a/base/serial/psb_zipcoo2csr.f90 +++ b/base/serial/psb_zipcoo2csr.f90 @@ -51,16 +51,19 @@ subroutine psb_zipcoo2csr(a,info,rwshr) logical :: rwshr_ Integer :: nza, nr, i,j,irw, idl,err_act Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name name='psb_ipcoo2csr' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if(debug) write(0,*)'Inside ipcoo2csr ',a%fida,a%m + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': start',a%fida,a%m if (toupper(a%fida) /= 'COO') then - write(0,*) 'ipcoo2csr Invalid input ',a%fida + write(debug_unit,*) trim(name),': Invalid input ',a%fida info = -1 call psb_errpush(info,name) goto 9999 @@ -81,7 +84,9 @@ subroutine psb_zipcoo2csr(a,info,rwshr) goto 9999 end if - if(debug) write(0,*)'DIPCOO2CSR: out of fixcoo',nza,nr,size(a%ia2),size(iaux) + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & ': out of fixcoo',nza,nr,size(a%ia2),size(iaux) call psb_transfer(a%ia1,itemp,info) call psb_transfer(a%ia2,a%ia1,info) @@ -120,13 +125,12 @@ subroutine psb_zipcoo2csr(a,info,rwshr) irw = itemp(j) i = i + 1 if (i>nr) then - write(0,*) 'IPCOO2CSR: RWSHR=.true. : ',& + write(debug_unit,*) trim(name),': RWSHR=.true. : ',& & i, nr,' Expect trouble!' exit end if endif enddo -! write(0,*) 'Exit from loop',j,nza,i do if (i>=nr+1) exit a%ia2(i+1) = j @@ -136,8 +140,9 @@ subroutine psb_zipcoo2csr(a,info,rwshr) else if (nr < itemp(nza)) then - write(0,*) 'IPCOO2CSR: RWSHR=.false. : ',& + write(debug_unit,*) trim(name),': RWSHR=.false. : ',& &nr,itemp(nza),' Expect trouble!' + info = 12 end if @@ -149,7 +154,8 @@ subroutine psb_zipcoo2csr(a,info,rwshr) inner: do if (i >= irw) exit inner if (i>nr) then - write(0,*) 'Strange situation: i>nr ',i,nr,j,nza,irw,idl + write(debug_unit,*) trim(name),& + & 'Strange situation: i>nr ',i,nr,j,nza,irw,idl exit outer end if a%ia2(i+1) = a%ia2(i) @@ -168,7 +174,8 @@ subroutine psb_zipcoo2csr(a,info,rwshr) ! Cleanup empty rows at the end ! if (j /= (nza+1)) then - write(0,*) 'IPCOO2CSR : Problem from loop :',j,nza + write(debug_unit,*) trim(name),': Problem from loop :',j,nza + info = 13 endif do if (i>nr) exit @@ -180,11 +187,17 @@ subroutine psb_zipcoo2csr(a,info,rwshr) end if -!!$ write(0,*) 'IPcoo2csr end loop ',i,nr,a%ia2(nr+1),nza a%fida='CSR' a%infoa(psb_upd_) = psb_upd_srch_ - deallocate(itemp) + deallocate(itemp,stat=info) + if (info /= 0) then + info=4010 + call psb_errpush(info,name,a_err='deallocate') + goto 9999 + end if + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/serial/psb_zipcsr2coo.f90 b/base/serial/psb_zipcsr2coo.f90 index 5720b66b..1d1bf746 100644 --- a/base/serial/psb_zipcsr2coo.f90 +++ b/base/serial/psb_zipcsr2coo.f90 @@ -48,11 +48,9 @@ Subroutine psb_zipcsr2coo(a,info) !locals Integer :: nza, nr integer :: i,j,err_act - logical, parameter :: debug=.false. integer, allocatable :: iaux(:), itemp(:) - character(len=20) :: name + character(len=20) :: name='psb_zipcsr2coo' - name='psb_zipcsr2coo' info = 0 call psb_erractionsave(err_act) diff --git a/base/serial/psb_zspcnv.f90 b/base/serial/psb_zspcnv.f90 index 7e067411..255a9cd7 100644 --- a/base/serial/psb_zspcnv.f90 +++ b/base/serial/psb_zspcnv.f90 @@ -28,20 +28,17 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_dcsdp.f90 +! File: psb_zspcnv.f90 ! -! Subroutine: psb_dcsdp -! This subroutine performs the assembly of -! the local part of a sparse distributed matrix +! Subroutine: psb_zspcnv2 +! This subroutine converts the storage format of a matrix. ! ! Arguments: -! a - type(). The input matrix to be assembled. -! b - type(). The assembled output matrix. +! +! a - type(psb_spmat_type), input The input matrix to be converted. +! b - type(psb_spmat_type), output The assembled output matrix. ! info - integer. Return code -! ifc - integer(optional). ??? -! check - character(optional). ??? -! trans - character(optional). ??? -! unitd - character(optional). ??? +! afmt - character, optional The desired storage format ! subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) use psb_const_mod @@ -67,12 +64,14 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) character :: check_,trans_,unitd_ character(len=5) :: afmt_ Integer, Parameter :: maxtry=8 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err - name='psb_spcnv' + name='psb_spcnv2' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ntry=0 @@ -128,14 +127,13 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) b%k=a%k b%fida=afmt_ size_req = psb_sp_get_nnzeros(a) - if (debug) write(0,*) 'DCSDP : size_req 1:',size_req ! n_row=b%m n_col=b%k call psb_cest(afmt_,n_row,n_col,size_req,& & ia1_size, ia2_size, aspk_size, upd_,info) b%fida=afmt_ - + if (info /= psb_no_err_) then info=4010 ch_err='psb_cest' @@ -167,6 +165,9 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) b%pr(:) = 0 b%descra = a%descra + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': size_req 1:',& + & size_req, trans_,upd_,dupl_,b%fida,b%descra select case (tolower(a%fida)) @@ -205,12 +206,13 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) endif ntry = ntry + 1 - if (debug) then - write(0,*) 'On out from dcrjad ',nzr,info + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),' On out from dcrjad ',nzr,info end if if (nzr == 0) exit if (ntry > maxtry ) then - write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,': giving up now.' + write(debug_unit,*) trim(name),& + & ' Tried reallocating for DCRJAD for ',maxtry,': giving up now.' info=2040 call psb_errpush(info,name) goto 9999 @@ -232,7 +234,8 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) end if case ('coo') - if (debug) write(0,*) 'Calling CRCO ',a%descra + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),' Calling CRCO ',a%descra call zcrco(trans_, a%m, a%k, unitd_, d, a%descra, a%aspk,& & a%ia1, a%ia2, a%infoa, b%pl, b%descra, b%aspk, b%ia1,& & b%ia2, b%infoa, b%pr, size(b%aspk), size(b%ia1),& @@ -301,13 +304,13 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) end if ntry = ntry + 1 - if (debug) then - write(0,*) 'On out from dcrjad ',nzr,info + if (debug_level >= psb_debug_serial_) then + write(debug_unit,*) trim(name),' On out from dcrjad ',nzr,info end if if (nzr == 0) exit if (ntry > maxtry ) then - write(0,*) 'Tried reallocating for DCRJAD for ',maxtry,& - & ': giving up now.' + write(debug_unit,*) trim(name),' Tried reallocating for DCRJAD for ',& + & maxtry,': giving up now.' info=2040 call psb_errpush(info,name) goto 9999 @@ -366,6 +369,16 @@ subroutine psb_zspcnv2(a, b,info,afmt,upd,dupl) end subroutine psb_zspcnv2 +! +! Subroutine: psb_zspcnv1 +! This subroutine converts in place the storage format of a matrix. +! +! Arguments: +! +! a - type(psb_spmat_type), inout The input matrix to be converted. +! info - integer. Return code +! afmt - character, optional The desired storage format +! subroutine psb_zspcnv1(a, info, afmt, upd, dupl) use psb_spmat_type @@ -391,13 +404,15 @@ subroutine psb_zspcnv1(a, info, afmt, upd, dupl) integer :: err_act integer :: spstate integer :: upd_, dupl_ - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err info = 0 int_err(1)=0 name = 'psb_spcnv' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if (present(upd)) then call psb_sp_setifld(upd,psb_upd_,a,info) @@ -431,10 +446,14 @@ subroutine psb_zspcnv1(a, info, afmt, upd, dupl) if (info /= 0) then goto 9999 endif - if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),': Sparse matrix state:',& + & spstate,psb_spmat_bld_,psb_spmat_upd_ if (spstate /= psb_spmat_upd_) then ! Should we first figure out if we can do it in place? - if (debug) write(0,*) 'Update:',upd_,psb_upd_srch_,psb_upd_perm_ + if (debug_level >= psb_debug_serial_) & + & write(debug_unit,*) trim(name),& + & ': Update:',upd_,psb_upd_srch_,psb_upd_perm_ if (upd_ == psb_upd_srch_) then if (present(afmt)) then select case (tolower(a%fida)) @@ -473,7 +492,10 @@ subroutine psb_zspcnv1(a, info, afmt, upd, dupl) ! result is put in A call psb_spcnv(atemp,a,info,afmt=afmt,upd=upd,dupl=dupl) - IF (debug) WRITE (*, *) ' ASB: From SPCNV',info,' ',A%FIDA + if (debug_level >= psb_debug_serial_)& + & write(debug_unit, *) trim(name),& + & ': From SPCNV',info,' ',a%fida + if (info /= psb_no_err_) then info=4010 ch_err='psb_csdp' @@ -501,8 +523,6 @@ subroutine psb_zspcnv1(a, info, afmt, upd, dupl) goto 9999 end select - - ! check on error retuned by dcsdp if (info /= psb_no_err_) then info = 4010 ch_err='xx_regen' @@ -515,7 +535,9 @@ subroutine psb_zspcnv1(a, info, afmt, upd, dupl) info = 600 call psb_errpush(info,name) goto 9999 - if (debug) write(0,*) 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ + if (debug_level >= psb_debug_serial_)& + & write(debug_unit,*) trim(name),& + & 'Sparse matrix state:',spstate,psb_spmat_bld_,psb_spmat_upd_ endif diff --git a/base/serial/psb_zspgetrow.f90 b/base/serial/psb_zspgetrow.f90 index cb2cea7e..e9cdf8b0 100644 --- a/base/serial/psb_zspgetrow.f90 +++ b/base/serial/psb_zspgetrow.f90 @@ -32,10 +32,20 @@ ! Subroutine: psb_zspgetrow ! Gets one or more rows from a sparse matrix. ! Arguments: -!***************************************************************************** -!* * -!* * -!***************************************************************************** +! irw - integer, input The row to be extracted +! a - type(psb_zspmat_type),input The sparse matrix +! nz - integer, output The number of entries +! ia(:) - integer, allocatable, inout The output row indices +! ja(:) - integer, allocatable, inout The output col indices +! val(:) - complex, allocatable,inout The coefficients +! info - integer, output Error code +! iren(:) - integer, input,optional Renumbering of indices +! lrw - integer, input,optional Extract rows irw:lrw, default lrw=irw +! append - logical, input,optional Should we append to already existing +! partial output? +! nzin - integer, input, optional If appending, how many entries were already +! occupied. +! subroutine psb_zspgetrow(irw,a,nz,ia,ja,val,info,iren,lrw,append,nzin) ! Output is always in COO format use psb_spmat_type diff --git a/base/serial/psb_zspgtdiag.f90 b/base/serial/psb_zspgtdiag.f90 index 80778a09..b4e225dd 100644 --- a/base/serial/psb_zspgtdiag.f90 +++ b/base/serial/psb_zspgtdiag.f90 @@ -58,7 +58,9 @@ subroutine psb_zspgtdiag(a,d,info) call psb_erractionsave(err_act) if (size(d) < min(a%k,a%m)) then - write(0,*) 'Insufficient space in ZSPGTDIAG ', size(d),min(a%m,a%k) + info=35 + call psb_errpush(info,name,i_err=(/2,size(d),0,0,0/)) + goto 9999 end if d(:) = 0.d0 if (a%fida == 'CSR') then diff --git a/base/tools/psb_cd_inloc.f90 b/base/tools/psb_cd_inloc.f90 index 0e43c161..539bc66e 100644 --- a/base/tools/psb_cd_inloc.f90 +++ b/base/tools/psb_cd_inloc.f90 @@ -28,9 +28,9 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_cdalv.f90 +! File: psb_cd_inloc.f90 ! -! Subroutine: psb_cdalv +! Subroutine: psb_cd_inloc ! Allocate descriptor with a local vector V containing the list ! of indices that are assigned to the current process. The global size ! is equal to the largest index found on any process. @@ -38,7 +38,7 @@ ! Arguments: ! v - integer, dimension(:). The array containg the partitioning scheme. ! ictxt - integer. The communication context. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Eventually returns an error code subroutine psb_cd_inloc(v, ictxt, desc_a, info) use psb_descriptor_type @@ -56,18 +56,21 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) Integer :: counter,i,j,np,me,loc_row,err,& & loc_col,nprocs,n,itmpov, k,glx,& & l_ov_ix,l_ov_el,idx, flag_, err_act,m - integer :: int_err(5),exch(3) - Integer, allocatable :: temp_ovrlap(:), ov_idx(:),ov_el(:),tmpgidx(:,:) - logical, parameter :: debug=.false. - character(len=20) :: name + integer :: int_err(5),exch(3) + Integer, allocatable :: temp_ovrlap(:), ov_idx(:),ov_el(:),tmpgidx(:,:) + integer :: debug_level, debug_unit + character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 err=0 name = 'psb_cd_inloc' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_info(ictxt, me, np) - if (debug) write(*,*) 'psb_cdall: ',np,me + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': start',np loc_row = size(v) @@ -117,7 +120,8 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) call psb_cd_set_large_threshold(exch(3)) endif - if (debug) write(*,*) 'psb_cdall: doing global checks' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': doing global checks' allocate(tmpgidx(m,2),stat=info) if (info /=0) then info=4000 @@ -184,7 +188,8 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) call psb_get_mpicomm(ictxt,desc_a%matrix_data(psb_mpi_c_)) - if (debug) write(*,*) 'PSB_CDALL: starting main loop' ,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': starting main loop' ,info counter = 0 itmpov = 0 temp_ovrlap(:) = -1 @@ -221,13 +226,15 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) loc_row=counter ! check on parts function - if (debug) write(*,*) 'PSB_CDALL: End main loop:' ,loc_row,itmpov,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': End main loop:' ,loc_row,itmpov,info if (info /= 0) then call psb_errpush(info,name,i_err=int_err) goto 9999 end if - if (debug) write(*,*) 'PSB_CDALL: error check:' ,err + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': error check:' ,err ! estimate local cols number loc_col = min(2*loc_row,m) @@ -297,13 +304,15 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) loc_row=counter ! check on parts function - if (debug) write(*,*) 'PSB_CDALL: End main loop:' ,loc_row,itmpov,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': End main loop:' ,loc_row,itmpov,info if (info /= 0) then call psb_errpush(info,name,i_err=int_err) goto 9999 end if - if (debug) write(*,*) 'PSB_CDALL: error check:' ,err + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': error check:' ,err ! estimate local cols number loc_col = min(2*loc_row,m) @@ -345,7 +354,8 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) l_ov_ix = l_ov_ix+3 l_ov_el = l_ov_el+3 - if (debug) write(*,*) 'PSB_CDALL: Ov len',l_ov_ix,l_ov_el + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Ov len',l_ov_ix,l_ov_el allocate(ov_idx(l_ov_ix),ov_el(l_ov_el), stat=info) if (info /= 0) then info=4025 @@ -402,6 +412,8 @@ subroutine psb_cd_inloc(v, ictxt, desc_a, info) end if desc_a%halo_index(:) = -1 desc_a%ext_index(:) = -1 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdals.f90 b/base/tools/psb_cdals.f90 index 9b9d4708..4bb03ddd 100644 --- a/base/tools/psb_cdals.f90 +++ b/base/tools/psb_cdals.f90 @@ -28,9 +28,9 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_cdall.f90 +! File: psb_cdals.f90 ! -! Subroutine: psb_cdall +! Subroutine: psb_cdals ! Allocate descriptor ! and checks correctness of PARTS subroutine ! @@ -40,7 +40,7 @@ ! parts - external subroutine. The routine that contains the ! partitioning scheme. ! ictxt - integer. The communication context. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Error code (if any). subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) use psb_error_mod @@ -57,21 +57,25 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) integer, intent(out) :: info !locals - Integer :: counter,i,j,np,me,loc_row,err,loc_col,nprocs,& + Integer :: counter,i,j,np,me,loc_row,err,loc_col,nprocs,& & l_ov_ix,l_ov_el,idx, err_act, itmpov, k, glx - integer :: int_err(5),exch(3) + integer :: int_err(5),exch(3) integer, allocatable :: prc_v(:), temp_ovrlap(:), ov_idx(:),ov_el(:) - logical, parameter :: debug=.false. - character(len=20) :: name + integer :: debug_level, debug_unit + character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 err=0 name = 'psb_cdall' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + call psb_info(ictxt, me, np) - if (debug) write(*,*) 'psb_cdall: ',np,me + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',np ! ....verify blacs grid correctness.. !... check m and n parameters.... @@ -92,7 +96,8 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) endif - if (debug) write(*,*) 'psb_cdall: doing global checks' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': doing global checks' !global check on m and n parameters if (me == psb_root_) then exch(1)=m @@ -142,7 +147,8 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) call psb_get_mpicomm(ictxt,desc_a%matrix_data(psb_mpi_c_)) - if (debug) write(*,*) 'PSB_CDALL: starting main loop' ,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': starting main loop' ,info counter = 0 itmpov = 0 temp_ovrlap(:) = -1 @@ -350,10 +356,12 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) end if ! check on parts function - if (debug) write(*,*) 'PSB_CDALL: End main loop:' ,loc_row,itmpov,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': End main loop:' ,loc_row,itmpov,info - if (debug) write(*,*) 'PSB_CDALL: error check:' ,err + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': error check:' ,err l_ov_ix=0 l_ov_el=0 @@ -371,7 +379,8 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) l_ov_ix = l_ov_ix+3 l_ov_el = l_ov_el+3 - if (debug) write(*,*) 'PSB_CDALL: Ov len',l_ov_ix,l_ov_el + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Ov len',l_ov_ix,l_ov_el allocate(ov_idx(l_ov_ix),ov_el(l_ov_el), stat=info) if (info /= psb_no_err_) then info=4010 @@ -430,6 +439,8 @@ subroutine psb_cdals(m, n, parts, ictxt, desc_a, info) desc_a%halo_index(:) = -1 desc_a%ext_index(:) = -1 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdalv.f90 b/base/tools/psb_cdalv.f90 index 8683f78d..3d1a1257 100644 --- a/base/tools/psb_cdalv.f90 +++ b/base/tools/psb_cdalv.f90 @@ -39,7 +39,7 @@ ! Arguments: ! v - integer, dimension(:). The array containg the partitioning scheme. ! ictxt - integer. The communication context. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code ! flag - integer. Are V's contents 0- or 1-based? subroutine psb_cdalv(v, ictxt, desc_a, info, flag) @@ -61,16 +61,19 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) & l_ov_ix,l_ov_el,idx, flag_, err_act integer :: int_err(5),exch(3) Integer, allocatable :: temp_ovrlap(:), ov_idx(:),ov_el(:) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name if(psb_get_errstatus() /= 0) return - info=0 - err=0 + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + info = 0 + err = 0 name = 'psb_cdalv' call psb_info(ictxt, me, np) - if (debug) write(*,*) 'psb_cdall: ',np,me + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',np,me m = size(v) n = m @@ -154,7 +157,8 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) desc_a%matrix_data(psb_ctxt_) = ictxt call psb_get_mpicomm(ictxt,desc_a%matrix_data(psb_mpi_c_)) - if (debug) write(*,*) 'PSB_CDALL: starting main loop' ,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': starting main loop' ,info counter = 0 itmpov = 0 temp_ovrlap(:) = -1 @@ -192,13 +196,15 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) loc_row=counter ! check on parts function - if (debug) write(*,*) 'PSB_CDALL: End main loop:' ,loc_row,itmpov,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': End main loop:' ,loc_row,itmpov,info if (info /= 0) then call psb_errpush(info,name,i_err=int_err) goto 9999 end if - if (debug) write(*,*) 'PSB_CDALL: error check:' ,err + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': error check:' ,err ! estimate local cols number loc_col = min(2*loc_row,m) @@ -268,13 +274,15 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) loc_row=counter ! check on parts function - if (debug) write(*,*) 'PSB_CDALL: End main loop:' ,loc_row,itmpov,info + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': End main loop:' ,loc_row,itmpov,info if (info /= 0) then call psb_errpush(info,name,i_err=int_err) goto 9999 end if - if (debug) write(*,*) 'PSB_CDALL: error check:' ,err + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': error check:' ,err ! estimate local cols number loc_col = min(2*loc_row,m) @@ -316,7 +324,8 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) l_ov_ix = l_ov_ix+3 l_ov_el = l_ov_el+3 - if (debug) write(*,*) 'PSB_CDALL: Ov len',l_ov_ix,l_ov_el + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Ov len',l_ov_ix,l_ov_el allocate(ov_idx(l_ov_ix),ov_el(l_ov_el), stat=info) if (info /= 0) then info=4025 @@ -381,6 +390,8 @@ subroutine psb_cdalv(v, ictxt, desc_a, info, flag) desc_a%ext_index(:) = -1 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdcpy.f90 b/base/tools/psb_cdcpy.f90 index 11224394..b2a65964 100644 --- a/base/tools/psb_cdcpy.f90 +++ b/base/tools/psb_cdcpy.f90 @@ -34,8 +34,8 @@ ! Produces a clone of a descriptor. ! ! Arguments: -! desc_in - type(). The communication descriptor to be cloned. -! desc_out - type(). The output communication descriptor. +! desc_in - type(psb_desc_type). The communication descriptor to be cloned. +! desc_out - type(psb_desc_type). The output communication descriptor. ! info - integer. Return code. subroutine psb_cdcpy(desc_in, desc_out, info) @@ -55,9 +55,12 @@ subroutine psb_cdcpy(desc_in, desc_out, info) !locals integer :: np,me,ictxt, err_act - logical, parameter :: debug=.false.,debugprt=.false. + integer :: debug_level, debug_unit character(len=20) :: name - if (debug) write(0,*) me,'Entered CDCPY' + + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + if (psb_get_errstatus() /= 0) return info = 0 call psb_erractionsave(err_act) @@ -67,15 +70,13 @@ subroutine psb_cdcpy(desc_in, desc_out, info) ! check on blacs grid call psb_info(ictxt, me, np) - if (debug) write(0,*) me,'Entered CDCPY' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Entered' if (np == -1) then info = 2010 call psb_errpush(info,name) goto 9999 endif -!!$ call psb_cdfree(desc_out,info) - -!!$ call psb_nullify_desc(desc_out) call psb_safe_cpy(desc_in%matrix_data,desc_out%matrix_data,info) if (info == 0) call psb_safe_cpy(desc_in%halo_index,desc_out%halo_index,info) @@ -106,6 +107,8 @@ subroutine psb_cdcpy(desc_in, desc_out, info) call psb_errpush(info,name) goto 9999 endif + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Done' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdfree.f90 b/base/tools/psb_cdfree.f90 index f3492a5b..8a247d1a 100644 --- a/base/tools/psb_cdfree.f90 +++ b/base/tools/psb_cdfree.f90 @@ -34,7 +34,7 @@ ! Frees a descriptor data structure. ! ! Arguments: -! desc_a - type(). The communication descriptor to be freed. +! desc_a - type(psb_desc_type). The communication descriptor to be freed. ! info - integer. return code. subroutine psb_cdfree(desc_a,info) !...free descriptor structure... diff --git a/base/tools/psb_cdins.f90 b/base/tools/psb_cdins.f90 index 1371c0ba..429e787c 100644 --- a/base/tools/psb_cdins.f90 +++ b/base/tools/psb_cdins.f90 @@ -39,7 +39,7 @@ ! nz - integer. The number of points to insert. ! ia(:) - integer The row indices of the points. ! ja(:) - integer The column indices of the points. -! desc_a - type(). The communication descriptor to be freed. +! desc_a - type(psb_desc_type). The communication descriptor to be freed. ! info - integer. Return code. ! ila(:) - integer, optional The row indices in local numbering ! jla(:) - integer, optional The col indices in local numbering diff --git a/base/tools/psb_cdprt.f90 b/base/tools/psb_cdprt.f90 index 0bcc6702..4ebf0c58 100644 --- a/base/tools/psb_cdprt.f90 +++ b/base/tools/psb_cdprt.f90 @@ -35,7 +35,7 @@ ! ! Arguments: ! iout - integer. The output unit to print to. -! desc_p - type(). The communication descriptor to be printed. +! desc_p - type(psb_desc_type). The communication descriptor to be printed. ! glob - logical(otpional). Wheter to print out global or local data. ! short - logical(optional). Used to choose a verbose output. ! diff --git a/base/tools/psb_cdren.f90 b/base/tools/psb_cdren.f90 index 52b0091d..f6e10f95 100644 --- a/base/tools/psb_cdren.f90 +++ b/base/tools/psb_cdren.f90 @@ -39,7 +39,7 @@ ! trans - character. Whether iperm or its transpose ! should be applied. ! iperm - integer,dimension(:). The renumbering scheme. -! desc_a - type(). The communication descriptor +! desc_a - type(psb_desc_type). The communication descriptor ! to be updated. ! info - integer. Return code ! @@ -64,19 +64,18 @@ subroutine psb_cdren(trans,iperm,desc_a,info) character, intent(in) :: trans integer, intent(out) :: info !....locals.... - integer :: i,j,np,me, n_col, kh, nh - integer :: dectype - integer :: ictxt,n_row, int_err(5), err_act - real(kind(1.d0)) :: time(10) - logical, parameter :: debug=.false. - character(len=20) :: name + integer :: i,j,np,me, n_col, kh, nh + integer :: dectype + integer :: ictxt,n_row, int_err(5), err_act + integer :: debug_level, debug_unit + character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) name = 'psb_dcren' - - time(1) = psb_wtime() + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) dectype = psb_cd_get_dectype(desc_a) @@ -107,15 +106,14 @@ subroutine psb_cdren(trans,iperm,desc_a,info) endif endif - if (debug) write (*, *) ' begin matrix assembly...' !check on errors encountered in psdspins if ((iperm(1) /= 0)) then - if (debug) write(0,*) 'spasb: here we go with ',iperm(1) - deallocate(desc_a%lprm) - allocate(desc_a%lprm(n_col)) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': here we go with ',iperm(1) + call psb_ensure_size(n_col,desc_a%lprm,info) if (toupper(trans) == 'N') then do i=1, n_row desc_a%lprm(iperm(i)) = i @@ -135,18 +133,21 @@ subroutine psb_cdren(trans,iperm,desc_a,info) ! fix glob_to_loc/loc_to_glob mappings, then indices lists ! hmm, maybe we should just moe all of this onto a different level, ! have a specialized subroutine, and do it in the solver context???? - if (debug) write(0,*) 'spasb: renumbering glob_to_loc' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': renumbering glob_to_loc' do i=1, n_col desc_a%glob_to_loc(desc_a%loc_to_glob(desc_a%lprm(i))) = i enddo - if (debug) write(0,*) 'spasb: renumbering loc_to_glob' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': renumbering loc_to_glob' do i=1,psb_cd_get_global_rows(desc_a) j = desc_a%glob_to_loc(i) if (j>0) then desc_a%loc_to_glob(j) = i endif enddo - if (debug) write(0,*) 'spasb: renumbering halo_index' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': renumbering halo_index' i=1 kh=desc_a%halo_index(i) do while (kh /= -1) @@ -165,7 +166,8 @@ subroutine psb_cdren(trans,iperm,desc_a,info) i = i + nh + 1 kh=desc_a%halo_index(i) enddo - if (debug) write(0,*) 'spasb: renumbering ovrlap_index' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': renumbering ovrlap_index' i=1 kh=desc_a%ovrlap_index(i) do while (kh /= -1) @@ -178,7 +180,8 @@ subroutine psb_cdren(trans,iperm,desc_a,info) i = i + nh + 1 kh=desc_a%ovrlap_index(i) enddo - if (debug) write(0,*) 'spasb: renumbering ovrlap_elem' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': renumbering ovrlap_elem' i = 1 kh=desc_a%ovrlap_elem(i) do while (kh /= -1) @@ -187,36 +190,14 @@ subroutine psb_cdren(trans,iperm,desc_a,info) i = i+2 kh=desc_a%ovrlap_elem(i) enddo - if (debug) write(0,*) 'spasb: done renumbering' - if (debug) then - write(60+me,*) 'n_row ',n_row,' n_col',n_col, ' trans: ',trans - do i=1,n_col - write(60+me,*)i, ' lprm ', desc_a%lprm(i), ' iperm',iperm(i) - enddo - i=1 - kh = desc_a%halo_index(i) - do while (kh /= -1) - write(60+me,*) i, kh - i = i+1 - kh = desc_a%halo_index(i) - enddo - close(60+me) - end if - -!!$ iperm(1) = 0 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': done renumbering' else -!!$ allocate(desc_a%lprm(1)) -!!$ desc_a%lprm(1) = 0 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': nothing to be done' endif - - - time(4) = psb_wtime() - time(4) = time(4) - time(3) - if (debug) then - call psb_amx(ictxt, time(4)) - - write (*, *) ' comm structs assembly: ', time(4)*1.d-3 - end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdrep.f90 b/base/tools/psb_cdrep.f90 index dbec4430..f5574138 100644 --- a/base/tools/psb_cdrep.f90 +++ b/base/tools/psb_cdrep.f90 @@ -118,16 +118,19 @@ subroutine psb_cdrep(m, ictxt, desc_a, info) !locals Integer :: i,np,me,err,n,err_act integer :: int_err(5),exch(2), thalo(1), tovr(1), text(1) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 err=0 name = 'psb_cdrep' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_info(ictxt, me, np) - if (debug) write(*,*) 'psb_cdrep: ',np,me + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',np n = m !... check m and n parameters.... @@ -146,7 +149,8 @@ subroutine psb_cdrep(m, ictxt, desc_a, info) goto 9999 end if - if (debug) write(*,*) 'psb_dscall: doing global checks' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': doing global checks' !global check on m and n parameters if (me == psb_root_) then exch(1)=m @@ -213,6 +217,9 @@ subroutine psb_cdrep(m, ictxt, desc_a, info) desc_a%matrix_data(psb_dec_type_) = psb_desc_repl_ + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' + call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_cdtransfer.f90 b/base/tools/psb_cdtransfer.f90 index 706f8304..27e78581 100644 --- a/base/tools/psb_cdtransfer.f90 +++ b/base/tools/psb_cdtransfer.f90 @@ -36,9 +36,9 @@ ! ! ! Arguments: -! desc_in - type(). The communication descriptor to be +! desc_in - type(psb_desc_type). The communication descriptor to be ! transferred. -! desc_out - type(). The output communication descriptor. +! desc_out - type(psb_desc_type). The output communication descriptor. ! info - integer. Return code. subroutine psb_cdtransfer(desc_in, desc_out, info) @@ -58,19 +58,21 @@ subroutine psb_cdtransfer(desc_in, desc_out, info) !locals integer :: np,me,ictxt, err_act - logical, parameter :: debug=.false.,debugprt=.false. + integer :: debug_level, debug_unit character(len=20) :: name - if (debug) write(0,*) me,'Entered CDTRANSFER' - if (psb_get_errstatus().ne.0) return + if (psb_get_errstatus()/=0) return info = 0 call psb_erractionsave(err_act) name = 'psb_cdtransfer' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_in) call psb_info(ictxt, me, np) - if (debug) write(0,*) me,'Entered CDTRANSFER' + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Entered.' if (np == -1) then info = 2010 call psb_errpush(info,name) @@ -108,6 +110,8 @@ subroutine psb_cdtransfer(desc_in, desc_out, info) call psb_errpush(info,name) goto 9999 endif + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_dallc.f90 b/base/tools/psb_dallc.f90 index 42e9e25e..bbc8db87 100644 --- a/base/tools/psb_dallc.f90 +++ b/base/tools/psb_dallc.f90 @@ -55,14 +55,13 @@ subroutine psb_dalloc(x, desc_a, info, n) integer,intent(out) :: info integer, optional, intent(in) :: n - !locals integer :: np,me,err,n_col,n_row,i,j,err_act integer :: ictxt,n_ integer :: int_err(5), exch(3) character(len=20) :: name - name='psb_dallc' + name='psb_dgeall_m' if(psb_get_errstatus() /= 0) return info=0 err=0 @@ -207,13 +206,15 @@ subroutine psb_dallocv(x, desc_a,info,n) !locals integer :: np,me,n_col,n_row,i,err_act integer :: ictxt, int_err(5) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 - name='psb_dallcv' + name='psb_dgeall_v' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_a) @@ -261,7 +262,9 @@ subroutine psb_dallocv(x, desc_a,info,n) x(i) = 0.0d0 end do else - write(0,*) 'Did not allocate anything because of dectype',psb_cd_get_dectype(desc_a) + if (debug_level > psb_debug_ext_) & + & write(debug_unit,*) me,name,& + & ': Did not allocate anything because of dectype',psb_cd_get_dectype(desc_a) endif call psb_erractionrestore(err_act) diff --git a/base/tools/psb_dasb.f90 b/base/tools/psb_dasb.f90 index 27543e62..69c0a6a6 100644 --- a/base/tools/psb_dasb.f90 +++ b/base/tools/psb_dasb.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x(:,:) - real,allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code subroutine psb_dasb(x, desc_a, info) !....assembly dense matrix x ..... @@ -58,27 +58,28 @@ subroutine psb_dasb(x, desc_a, info) ! local variables integer :: ictxt,np,me,nrow,ncol, err_act integer :: i1sz, i2sz - real(kind(1.d0)),parameter :: one=1 - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 - name='psb_dasb' + name='psb_dgeasb_m' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if ((.not.allocated(desc_a%matrix_data))) then info=3110 call psb_errpush(info,name) goto 9999 endif - ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) write(*,*) 'asb start: ',np,me,& + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': start: ',np,& & psb_cd_get_dectype(desc_a) ! ....verify blacs grid correctness.. if (np == -1) then @@ -86,7 +87,8 @@ subroutine psb_dasb(x, desc_a, info) call psb_errpush(info,name) goto 9999 else if (.not.psb_is_asb_desc(desc_a)) then - if (debug) write(*,*) 'asb error ',& + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),' error ',& & psb_cd_get_dectype(desc_a) info = 3110 call psb_errpush(info,name) @@ -99,7 +101,8 @@ subroutine psb_dasb(x, desc_a, info) ncol = psb_cd_get_local_cols(desc_a) i1sz = size(x,dim=1) i2sz = size(x,dim=2) - if (debug) write(*,*) 'asb: ',i1sz,i2sz,nrow,ncol + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',i1sz,i2sz,nrow,ncol if (i1sz < ncol) then call psb_realloc(ncol,i2sz,x,info) @@ -118,6 +121,8 @@ subroutine psb_dasb(x, desc_a, info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return @@ -172,7 +177,7 @@ end subroutine psb_dasb ! ! Arguments: ! x(:) - real,allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_dasbv(x, desc_a, info) !....assembly dense matrix x ..... @@ -191,15 +196,16 @@ subroutine psb_dasbv(x, desc_a, info) ! local variables integer :: ictxt,np,me integer :: int_err(5), i1sz,nrow,ncol, err_act - real(kind(1.d0)),parameter :: one=1 - logical, parameter :: debug=.false. - character(len=20) :: name,ch_err + integer :: debug_level, debug_unit + character(len=20) :: name,ch_err info = 0 int_err(1) = 0 - name = 'psb_dasbv' + name = 'psb_dgeasb_v' ictxt = psb_cd_get_context(desc_a) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_info(ictxt, me, np) @@ -216,9 +222,11 @@ subroutine psb_dasbv(x, desc_a, info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - if (debug) write(*,*) name,' sizes: ',nrow,ncol + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes: ',nrow,ncol i1sz = size(x) - if (debug) write(*,*) 'dasb: sizes ',i1sz,ncol + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes ',i1sz,ncol if (i1sz < ncol) then call psb_realloc(ncol,x,info) if (info /= 0) then @@ -236,6 +244,8 @@ subroutine psb_dasbv(x, desc_a, info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_dcdovr.F90 b/base/tools/psb_dcdovr.F90 index a9c119de..5114d8c4 100644 --- a/base/tools/psb_dcdovr.F90 +++ b/base/tools/psb_dcdovr.F90 @@ -36,10 +36,10 @@ ! specified on input. ! ! Arguments: -! a - type(). The input sparse matrix. -! desc_a - type(). The input communication descriptor. +! a - type(psb_dspmat_type). The input sparse matrix. +! desc_a - type(psb_desc_type). The input communication descriptor. ! novr - integer. The number of overlap levels. -! desc_ov - type(). The auxiliary output communication +! desc_ov - type(psb_desc_type). The auxiliary output communication ! descriptor. ! info - integer. Return code. ! extype - integer. Choice of type of overlap: @@ -55,8 +55,8 @@ ! the ext_ structure to provide ! the mapping between the base ! descriptor and the overlapped one. -! c. The (novr+1) layer becomes the new -! halo. +! c. The (novr+1)-th layer becomes the +! new halo. ! Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) @@ -108,18 +108,21 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) Integer,allocatable :: halo(:),works(:),workr(:),t_halo_in(:),& & t_halo_out(:),temp(:),maskr(:) Integer,allocatable :: brvindx(:),rvsz(:), bsdindx(:),sdsz(:) - Logical,Parameter :: debug=.false. - character(len=20) :: name, ch_err + integer :: debug_level, debug_unit + character(len=20) :: name, ch_err - name='psb_cdovr' + name='psb_dcdovr' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) icomm = psb_cd_get_mpic(desc_a) Call psb_info(ictxt, me, np) - If(debug) Write(0,*)'in psb_cdovr',novr + If (debug_level >= psb_debug_outer_) & + & Write(debug_unit,*) me,' ',trim(name),': start',novr if (present(extype)) then extype_ = extype @@ -132,7 +135,6 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) n_col = psb_cd_get_local_cols(desc_a) nhalo = n_col-m - If(debug) Write(0,*)'IN CDOVR1',novr ,m,nnzero,n_col if (novr<0) then info=10 int_err(1)=1 @@ -141,7 +143,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 endif - if (debug) write(0,*) 'Calling desccpy' + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Calling desccpy' call psb_cdcpy(desc_a,desc_ov,info) if (info /= 0) then info=4010 @@ -149,7 +152,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if - if (debug) write(0,*) 'From desccpy' + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':From desccpy' if (novr==0) then ! ! Just copy the input. @@ -159,8 +163,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) - If(debug)then - Write(0,*)'BEGIN cdovr',me,nhalo + If (debug_level >= psb_debug_outer_)then + Write(debug_unit,*) me,' ',trim(name),':BEGIN ',nhalo call psb_barrier(ictxt) endif @@ -179,7 +183,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name) goto 9999 endif - If(debug)Write(0,*)'ovr_est done',me,novr,lovr + If (debug_level >= psb_debug_outer_)& + & Write(debug_unit,*) me,' ',trim(name),':ovr_est done',novr,lovr index_dim = size(desc_a%halo_index) elem_dim = size(desc_a%halo_index) @@ -187,12 +192,10 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) l_tmp_ovr_idx = novr*(3*Max(2*index_dim,1)+1) l_tmp_halo = novr*(3*Size(desc_a%halo_index)) -!!$ write(0,*) 'Size of desc_ov ', desc_ov%matrix_data(psb_desc_size_), & -!!$ & psb_desc_normal_,psb_desc_large_ call psb_cd_set_bld(desc_ov,info) - If(debug) then - Write(0,*)'Start cdovrbld',me,lworks,lworkr + If (debug_level >= psb_debug_outer_) then + Write(debug_unit,*) me,' ',trim(name),':Start',lworks,lworkr call psb_barrier(ictxt) endif @@ -296,7 +299,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) ! Do i_ovr = 1, novr - if (debug) write(0,*) me,'Running on overlap level ',i_ovr,' of ',novr + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Running on overlap level ',i_ovr,' of ',novr ! ! At this point, halo contains a valid halo corresponding to the @@ -327,7 +331,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end If tot_recv=tot_recv+n_elem_recv - if (debug) write(0,*) me,' CDOVRBLD tot_recv:',proc,n_elem_recv,tot_recv + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': tot_recv:',proc,n_elem_recv,tot_recv ! ! ! The format of the halo vector exists in two forms: 1. Temporary @@ -382,7 +387,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) counter_h=counter_h+3 Enddo - if (debug) write(0,*) me,'Checktmp_o_i Loop Mid1',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop Mid1',tmp_ovr_idx(1:10) counter = counter+n_elem_recv ! @@ -393,7 +399,7 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) idx = halo(counter+psb_elem_send_+j) gidx = desc_ov%loc_to_glob(idx) if (idx > psb_cd_get_local_rows(Desc_a)) & - & write(0,*) me,i_ovr,'Out of local rows ',& + & write(debug_unit,*) me,' ',trim(name),':Out of local rows ',i_ovr,& & idx,psb_cd_get_local_rows(Desc_a) call psb_ensure_size((counter_o+3),tmp_ovr_idx,info,pad=-1) @@ -423,7 +429,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) If((n_elem) > size(blk%ia2)) Then isz = max((3*size(blk%ia2))/2,(n_elem)) - if (debug) write(0,*) me,'Realloc blk',isz + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,'Realloc blk',isz call psb_sp_reall(blk,isz,info) if (info /= 0) then info=4010 @@ -440,7 +447,6 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if -!!$ write(0,*) me,'Iteration: ',j,i_ovr Do jj=1,n_elem works(idxs+tot_elem+jj)=desc_ov%loc_to_glob(blk%ia2(jj)) End Do @@ -455,14 +461,17 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_msort_unique(works(idxs+1:idxs+tot_elem),i) tot_elem=i endif - if (debug) write(0,*) me,'Checktmp_o_i Loop Mid2',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop Mid2',tmp_ovr_idx(1:10) sdsz(proc+1) = tot_elem idxs = idxs + tot_elem end if counter = counter+n_elem_send+3 - if (debug) write(0,*) me,'Checktmp_o_i Loop End',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop End',tmp_ovr_idx(1:10) Enddo - if (debug) write(0,*)me,'End phase 1 CDOVRBLD', m, n_col, tot_recv + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':End phase 1', m, n_col, tot_recv if (i_ovr <= novr) then ! @@ -515,7 +524,8 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end if - if (debug) write(0,*) 'ISZR :',iszr + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': ISZR :',iszr if (psb_is_large_desc(desc_ov)) then call psb_ensure_size(iszr,maskr,info) @@ -565,8 +575,6 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) t_halo_in(counter_t+2)=lidx t_halo_in(counter_t+3)=-1 counter_t=counter_t+3 - if (.false.) write(0,*) me,' CDOVRBLD: Added t_halo_in ',& - &proc_id,lidx,idx endif end Do n_col = psb_cd_get_local_cols(desc_ov) @@ -607,10 +615,12 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) t_halo_in(counter_t+2)=n_col t_halo_in(counter_t+3)=-1 counter_t=counter_t+3 - if (debug) write(0,*) me,' CDOVRBLD: Added into t_halo_in from recv',& + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': Added into t_halo_in from recv',& &proc_id,n_col,idx else if (desc_ov%glob_to_loc(idx) < 0) Then - if (debug) write(0,*) me,'Wrong input to cdovrbld?',& + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Wrong input to cdovrbld?',& &idx,desc_ov%glob_to_loc(idx) End If End Do @@ -631,25 +641,23 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) If (i_ovr < (novr)) Then - if (debug) write(0,*) me,'Checktmp_o_i 1',tmp_ovr_idx(1:10) - if (debug) write(0,*) me,'Calling Crea_Halo' + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i 1',tmp_ovr_idx(1:10) + write(debug_unit,*) me,' ',trim(name),':Calling Crea_index' + end if call psi_crea_index(desc_ov,t_halo_in,t_halo_out,.false.,& & nxch,nsnd,nrcv,info) - - if (debug) then - write(0,*) me,'Done Crea_Index' + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),':Done Crea_Index' call psb_barrier(ictxt) end if - if (debug) write(0,*) me,'Checktmp_o_i 2',tmp_ovr_idx(1:10) - if (debug) write(0,*) me,'Done Crea_Halo' call psb_transfer(t_halo_out,halo,info) ! ! At this point we have built the halo necessary for I_OVR+1. ! End If - if (debug) write(0,*) me,'Checktmp_o_i ',tmp_ovr_idx(1:10) - End Do @@ -721,16 +729,13 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) ! called inside CDASB. ! - if (debug) then - write(0,*) 'psb_cdovrbld: converting indexes' + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),': converting indexes' call psb_barrier(ictxt) end if + call psb_icdasb(desc_ov,info,ext_hv=.true.) - if (debug) then - write(0,*) me,'Done CDASB' - call psb_barrier(ictxt) - end if if (info == 0) call psb_sp_free(blk,info) if (info /= 0) then @@ -739,6 +744,9 @@ Subroutine psb_dcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': end' + call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_dfree.f90 b/base/tools/psb_dfree.f90 index 4f12de4d..b6ae0ec2 100644 --- a/base/tools/psb_dfree.f90 +++ b/base/tools/psb_dfree.f90 @@ -35,7 +35,7 @@ ! ! Arguments: ! x(:,:) - real, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_dfree(x, desc_a, info) !...free dense matrix structure... @@ -110,7 +110,7 @@ end subroutine psb_dfree ! ! Arguments: ! x():) - real, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_dfreev(x, desc_a, info) !...free dense matrix structure... diff --git a/base/tools/psb_dins.f90 b/base/tools/psb_dins.f90 index 0c43fd97..b3f55565 100644 --- a/base/tools/psb_dins.f90 +++ b/base/tools/psb_dins.f90 @@ -39,7 +39,7 @@ ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:) - real The source dense submatrix. ! x(:) - real The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite @@ -224,7 +224,7 @@ end subroutine psb_dinsvi ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:,:) - real The source dense submatrix. ! x(:,:) - real The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite diff --git a/base/tools/psb_dspalloc.f90 b/base/tools/psb_dspalloc.f90 index f1a769b2..2c12d478 100644 --- a/base/tools/psb_dspalloc.f90 +++ b/base/tools/psb_dspalloc.f90 @@ -34,8 +34,8 @@ ! Allocate sparse matrix structure for psblas routines. ! ! Arguments: -! a - type(). The sparse matrix to be allocated. -! desc_a - type(). The communication descriptor to be updated. +! a - type(psb_dspmat_type). The sparse matrix to be allocated. +! desc_a - type(psb_desc_type). The communication descriptor to be updated. ! info - integer. Return code. ! nnz - integer(optional). The number of nonzeroes in the matrix. ! (local, user estimate) @@ -61,13 +61,15 @@ subroutine psb_dspalloc(a, desc_a, info, nnz) integer :: np,me,loc_row,loc_col,& & length_ia1,length_ia2, err_act,m,n integer :: int_err(5) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) - name = 'psb_dspalloc' + name = 'psb_dspall' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) dectype = psb_cd_get_dectype(desc_a) @@ -101,7 +103,8 @@ subroutine psb_dspalloc(a, desc_a, info, nnz) length_ia1=max(1,5*loc_row) endif - if (debug) write(*,*) 'allocating size:',length_ia1 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),':allocating size:',length_ia1 !....allocate aspk, ia1, ia2..... call psb_sp_all(loc_row,loc_col,a,length_ia1,info) @@ -112,7 +115,8 @@ subroutine psb_dspalloc(a, desc_a, info, nnz) goto 9999 end if - if (debug) write(0,*) 'spall: ', & + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ', & & psb_cd_get_dectype(desc_a),psb_desc_bld_ return diff --git a/base/tools/psb_dspasb.f90 b/base/tools/psb_dspasb.f90 index 8458dd38..2c886288 100644 --- a/base/tools/psb_dspasb.f90 +++ b/base/tools/psb_dspasb.f90 @@ -34,8 +34,8 @@ ! Assemble sparse matrix ! ! Arguments: -! a - type(). The sparse matrix to be allocated. -! desc_a - type(). The communication descriptor. +! a - type(psb_dspmat_type). The sparse matrix to be allocated. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! afmt - character(optional) The desired output storage format. ! upd - character(optional). How will the matrix be updated? @@ -70,13 +70,15 @@ subroutine psb_dspasb(a,desc_a, info, afmt, upd, dupl) integer :: np,me,n_col, err_act integer :: spstate integer :: ictxt,n_row - logical, parameter :: debug=.false., debugwrt=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err info = 0 int_err(1)=0 name = 'psb_spasb' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -97,7 +99,9 @@ subroutine psb_dspasb(a,desc_a, info, afmt, upd, dupl) goto 9999 endif - if (debug) Write (*, *) ' Begin matrix assembly...' + if (debug_level >= psb_debug_ext_)& + & write(debug_unit, *) me,' ',trim(name),& + & ' Begin matrix assembly...' !check on errors encountered in psdspins @@ -115,7 +119,9 @@ subroutine psb_dspasb(a,desc_a, info, afmt, upd, dupl) call psb_spcnv(a,info,afmt=afmt,upd=upd,dupl=dupl) - IF (debug) WRITE (*, *) me,' ASB: From SPCNV',info,' ',A%FIDA + IF (debug_level >= psb_debug_ext_)& + & write(debug_unit, *) me,' ',trim(name),': From SPCNV',& + & info,' ',A%FIDA if (info /= psb_no_err_) then info=4010 ch_err='psb_spcnv' diff --git a/base/tools/psb_dspfree.f90 b/base/tools/psb_dspfree.f90 index c43456ba..e444d840 100644 --- a/base/tools/psb_dspfree.f90 +++ b/base/tools/psb_dspfree.f90 @@ -34,8 +34,8 @@ ! Frees a sparse matrix structure. ! ! Arguments: -! a - type(). The sparse matrix to be freed. -! desc_a - type(). The communication descriptor. +! a - type(psb_dspmat_type). The sparse matrix to be freed. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psb_dspfree(a, desc_a,info) @@ -48,9 +48,9 @@ subroutine psb_dspfree(a, desc_a,info) implicit none !....parameters... - type(psb_desc_type), intent(in) :: desc_a - type(psb_dspmat_type), intent(inout) ::a - integer, intent(out) :: info + type(psb_desc_type), intent(in) :: desc_a + type(psb_dspmat_type), intent(inout) :: a + integer, intent(out) :: info !...locals.... integer :: ictxt,err_act character(len=20) :: name diff --git a/base/tools/psb_dsphalo.F90 b/base/tools/psb_dsphalo.F90 index abcaba00..f2d89976 100644 --- a/base/tools/psb_dsphalo.F90 +++ b/base/tools/psb_dsphalo.F90 @@ -38,7 +38,7 @@ ! ! Arguments: ! a - type(psb_dspmat_type) The local part of input matrix A -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! blck - type(psb_dspmat_type) The local part of output matrix BLCK ! info - integer. Return code ! rowcnv - logical Should row/col indices be converted @@ -89,19 +89,22 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& Integer, allocatable :: sdid(:,:), brvindx(:),rvid(:,:), & & rvsz(:), bsdindx(:),sdsz(:), iasnd(:), jasnd(:) real(kind(1.d0)), allocatable :: valsnd(:) - integer, pointer :: idxv(:) - logical :: rowcnv_,colcnv_,rowscale_,colscale_ + integer, pointer :: idxv(:) + logical :: rowcnv_,colcnv_,rowscale_,colscale_ character(len=5) :: outfmt_ - Logical,Parameter :: debug=.false., debugprt=.false. - real(kind(1.d0)) :: t1,t2,t3,t4,t5 - character(len=20) :: name, ch_err + integer :: debug_level, debug_unit + character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 name='psb_dsphalo' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': Start' - if(debug) write(0,*)'Inside DSPHALO' if (present(rowcnv)) then rowcnv_ = rowcnv else @@ -139,7 +142,6 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& Call psb_info(ictxt, me, np) - t1 = psb_wtime() Allocate(sdid(np,3),rvid(np,3),brvindx(np+1),& & rvsz(np),sdsz(np),bsdindx(np+1),stat=info) @@ -149,8 +151,8 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - If (debug) Write(0,*)'dsphalo',me - + If (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Data selector',data_ select case(data_) case(psb_comm_halo_) idxv => desc_a%halo_index @@ -158,9 +160,9 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& case(psb_comm_ext_) idxv => desc_a%ext_index -!!$ case(psb_comm_ovr_) -!!$ idxv => desc_a%ovrlap_index -!!$ ! Do not accept OVRLAP_INDEX any longer. +! !$ case(psb_comm_ovr_) +! !$ idxv => desc_a%ovrlap_index +! Do not accept OVRLAP_INDEX any longer. case default call psb_errpush(4010,name,a_err='wrong Data selector') goto 9999 @@ -227,7 +229,9 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& iszr=sum(rvsz) call psb_sp_reall(blk,max(iszr,1),info) - if(debug) write(0,*)me,'SPHALO Sizes:',size(blk%ia1),size(blk%ia2) + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Sizes:',size(blk%ia1),size(blk%ia2),& + & ' Send:',sdsz(:),' Receive:',rvsz(:) if (info /= 0) then info=4010 ch_err='psb_sp_reall' @@ -240,15 +244,6 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& if (info == 0) call psb_ensure_size(max(iszs,1),jasnd,info) if (info == 0) call psb_ensure_size(max(iszs,1),valsnd,info) - if (debugprt) then - open(20+me) - do i=1, psb_cd_get_local_cols(desc_a) - write(20+me,*) i,desc_a%loc_to_glob(i) - end do - close(20+me) - end if - t2 = psb_wtime() - l1 = 0 ipx = 1 counter=1 @@ -306,9 +301,6 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - t3 = psb_wtime() - - ! ! Convert into local numbering ! @@ -322,13 +314,6 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - if (debugprt) then - blk%fida='COO' - blk%infoa(psb_nnz_)=iszr - open(40+me) - call psb_csprt(40+me,blk,head='% SPHALO border .') - close(40+me) - end if l1 = 0 blk%m=0 ! @@ -367,15 +352,10 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& blk%fida = 'COO' blk%infoa(psb_nnz_) = l1 - if (debugprt) then - open(50+me) - call psb_csprt(50+me,blk,head='% SPHALO border .') - close(50+me) - call psb_barrier(ictxt) - end if - t4 = psb_wtime() - if(debug) Write(0,*)me,'End first loop',counter,l1,blk%m + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),& + & ': End data exchange',counter,l1,blk%m ! Do we expect any duplicates to appear???? call psb_spcnv(blk,info,afmt=outfmt_,dupl=psb_dupl_add_) @@ -386,15 +366,10 @@ Subroutine psb_dsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - t5 = psb_wtime() - -!!$ write(0,'(i3,1x,a,4(1x,i14))') me,'DSPHALO sizes:',iszr,iszs -!!$ write(0,'(i3,1x,a,4(1x,g14.5))') me,'DSPHALO timings:',t6-t2,t7-t6,t8-t7,t3-t8 -!!$ write(0,'(i3,1x,a,4(1x,g14.5))') me,'DSPHALO timings:',t2-t1,t3-t2,t4-t3,t5-t4 - Deallocate(sdid,brvindx,rvid,bsdindx,rvsz,sdsz,& & iasnd,jasnd,valsnd,stat=info) - + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Done' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_dspins.f90 b/base/tools/psb_dspins.f90 index 52e0174d..db710d5f 100644 --- a/base/tools/psb_dspins.f90 +++ b/base/tools/psb_dspins.f90 @@ -37,15 +37,15 @@ ! If desc_a is in the build state this routine implies a call to psb_cdins. ! ! Arguments: -! nz - integer. The number of points to insert. -! ia(:) - integer The row indices of the coefficients. -! ja(:) - integer The column indices of the coefficients. -! val(:) - real The values of the coefficients to be inserted. -! a - type(). The sparse destination matrix. -! desc_a - type(). The communication descriptor. -! info - integer. Error code -! rebuild - logical Allows to reopen a matrix under -! certain circumstances. +! nz - integer. The number of points to insert. +! ia(:) - integer The row indices of the coefficients. +! ja(:) - integer The column indices of the coefficients. +! val(:) - real The values of the coefficients to be inserted. +! a - type(psb_dspmat_type). The sparse destination matrix. +! desc_a - type(psb_desc_type). The communication descriptor. +! info - integer. Error code +! rebuild - logical Allows to reopen a matrix under +! certain circumstances. ! subroutine psb_dspins(nz,ia,ja,val,a,desc_a,info,rebuild) diff --git a/base/tools/psb_dsprn.f90 b/base/tools/psb_dsprn.f90 index 1edab70a..70ff87e7 100644 --- a/base/tools/psb_dsprn.f90 +++ b/base/tools/psb_dsprn.f90 @@ -35,8 +35,8 @@ ! is in the update state. ! ! Arguments: -! a - type(). The sparse matrix to be reinitiated. -! desc_a - type(). The communication descriptor. +! a - type(psb_dspmat_type). The sparse matrix to be reinitiated. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! clear - logical, optional Whether the coefficients should be zeroed ! default .true. @@ -58,9 +58,8 @@ Subroutine psb_dsprn(a, desc_a,info,clear) !locals - Integer :: ictxt - Integer :: np,me,err,err_act - logical, parameter :: debug=.false. + Integer :: ictxt,np,me,err,err_act + integer :: debug_level, debug_unit integer :: int_err(5) character(len=20) :: name logical :: clear_ @@ -70,12 +69,13 @@ Subroutine psb_dsprn(a, desc_a,info,clear) int_err(1)=0 name = 'psb_dsprn' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) - call psb_info(ictxt, me, np) - if (debug) & - &write(*,*) 'starting spalloc ',ictxt,np,me + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': start ' if (psb_is_bld_desc(desc_a)) then ! Should do nothing, we are called redundantly @@ -95,6 +95,8 @@ Subroutine psb_dsprn(a, desc_a,info,clear) call psb_sp_reinit(a,info,clear=clear_) if (info /= 0) goto 9999 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': done' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_get_overlap.f90 b/base/tools/psb_get_overlap.f90 index 2ee4ec73..0aef5b6a 100644 --- a/base/tools/psb_get_overlap.f90 +++ b/base/tools/psb_get_overlap.f90 @@ -38,7 +38,7 @@ ! ! Arguments: ! ovrel(:) - integer, allocatable Array containing the output list -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psb_get_ovrlap(ovrel,desc,info) diff --git a/base/tools/psb_glob_to_loc.f90 b/base/tools/psb_glob_to_loc.f90 index 093f5093..b45ad262 100644 --- a/base/tools/psb_glob_to_loc.f90 +++ b/base/tools/psb_glob_to_loc.f90 @@ -37,7 +37,7 @@ ! Arguments: ! x(:) - integer Array containing the indices to be translated. ! y(:) - integer Array containing the translated indices. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! iact - character, optional A character defining the behaviour on ! an index not belonging to the calling process @@ -63,12 +63,11 @@ subroutine psb_glob_to_loc2(x,y,desc_a,info,iact,owned) logical, intent(in), optional :: owned !....locals.... - integer :: n - character :: act - integer :: int_err(5), err_act - real(kind(1.d0)) :: real_val + integer :: n + character :: act + integer :: int_err(5), err_act logical :: owned_ - integer, parameter :: zero=0 + integer, parameter :: zero=0 character(len=20) :: name if(psb_get_errstatus() /= 0) return @@ -88,9 +87,7 @@ subroutine psb_glob_to_loc2(x,y,desc_a,info,iact,owned) owned_=.false. end if - int_err=0 - real_val = 0.d0 - + int_err = 0 n = size(x) call psi_idx_cnv(n,x,y,desc_a,info,owned=owned_) @@ -163,7 +160,7 @@ end subroutine psb_glob_to_loc2 ! Arguments: ! x(:) - integer Array containing the indices to be translated. ! overwritten on output with the result. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! iact - character, optional A character defining the behaviour on ! an index not belonging to the calling process diff --git a/base/tools/psb_ialloc.f90 b/base/tools/psb_ialloc.f90 index d7ef41b7..6c46ee5d 100644 --- a/base/tools/psb_ialloc.f90 +++ b/base/tools/psb_ialloc.f90 @@ -184,7 +184,7 @@ end subroutine psb_ialloc ! Arguments: ! m - integer. The number of rows. ! x - integer,dimension(:). The matrix to be allocated. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Eventually returns an error code subroutine psb_iallocv(x, desc_a, info,n) !....allocate sparse matrix structure for psblas routines..... @@ -203,16 +203,17 @@ subroutine psb_iallocv(x, desc_a, info,n) integer, optional, intent(in) :: n !locals - integer :: np,me,n_col,n_row,err_act - integer :: ictxt - integer :: int_err(5) - logical, parameter :: debug=.false. + integer :: np,me,n_col,n_row,i,err_act + integer :: ictxt, int_err(5) + integer :: debug_level, debug_unit character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 - name='psb_iallocv' + name='psb_igeall_v' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_a) @@ -252,6 +253,13 @@ subroutine psb_iallocv(x, desc_a, info,n) call psb_errpush(info,name,int_err,a_err='integer') goto 9999 endif + do i=1,n_row + x(i) = 0.0d0 + end do + else + if (debug_level > psb_debug_ext_) & + & write(debug_unit,*) me,name,& + & ': Did not allocate anything because of dectype',psb_cd_get_dectype(desc_a) endif x = 0 diff --git a/base/tools/psb_iasb.f90 b/base/tools/psb_iasb.f90 index 3aa7b33d..6e47a8eb 100644 --- a/base/tools/psb_iasb.f90 +++ b/base/tools/psb_iasb.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x(:,:) - integer,allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code subroutine psb_iasb(x, desc_a, info) !....assembly dense matrix x ..... @@ -58,26 +58,28 @@ subroutine psb_iasb(x, desc_a, info) ! local variables integer :: ictxt,np,me,nrow,ncol,err_act integer :: int_err(5), i1sz, i2sz - logical, parameter :: debug=.false. - character(len=20) :: name + integer :: debug_level, debug_unit + character(len=20) :: name,ch_err if(psb_get_errstatus() /= 0) return info=0 - name='psb_iasb' + name='psb_igeasb_m' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if ((.not.allocated(desc_a%matrix_data))) then - info=3110 - call psb_errpush(info,name) - return + info=3110 + call psb_errpush(info,name) + goto 9999 endif - ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) write(*,*) 'asb start: ',np,me,& + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': start: ',np,& & psb_cd_get_dectype(desc_a) ! ....verify blacs grid correctness.. if (np == -1) then @@ -85,7 +87,8 @@ subroutine psb_iasb(x, desc_a, info) call psb_errpush(info,name) goto 9999 else if (.not.psb_is_asb_desc(desc_a)) then - if (debug) write(*,*) 'asb error ',& + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),' error ',& & psb_cd_get_dectype(desc_a) info = 3110 call psb_errpush(info,name) @@ -98,19 +101,28 @@ subroutine psb_iasb(x, desc_a, info) ncol = psb_cd_get_local_cols(desc_a) i1sz = size(x,dim=1) i2sz = size(x,dim=2) - if (debug) write(*,*) 'asb: ',i1sz,i2sz,nrow,ncol - if (i1sz.lt.ncol) then + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',i1sz,i2sz,nrow,ncol + + if (i1sz < ncol) then call psb_realloc(ncol,i2sz,x,info) if (info /= 0) then - info=4025 - int_err(1)=ncol*i2sz - call psb_errpush(info,name,int_err,a_err='integer') + info=4010 + call psb_errpush(info,name,a_err='psb_realloc') goto 9999 endif endif ! ..update halo elements.. - call psb_halo(x,desc_a,info,alpha=done) + call psb_halo(x,desc_a,info) + if(info /= 0) then + info=4010 + ch_err='psb_halo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return @@ -166,7 +178,7 @@ end subroutine psb_iasb ! ! Arguments: ! x(:) - integer,allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code subroutine psb_iasbv(x, desc_a, info) !....assembly dense matrix x ..... @@ -183,18 +195,18 @@ subroutine psb_iasbv(x, desc_a, info) integer, intent(out) :: info ! local variables - integer :: ictxt,np,me, err_act - integer :: int_err(5), i1sz,nrow,ncol - logical, parameter :: debug=.false. - character(len=20) :: name + integer :: ictxt,np,me + integer :: int_err(5), i1sz,nrow,ncol, err_act + integer :: debug_level, debug_unit + character(len=20) :: name,ch_err + + info = 0 + int_err(1) = 0 + name = 'psb_igeasb_v' - if(psb_get_errstatus().ne.0) return - info=0 - call psb_erractionsave(err_act) - name = 'psb_iasbv' - - ictxt = psb_cd_get_context(desc_a) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_info(ictxt, me, np) @@ -211,22 +223,30 @@ subroutine psb_iasbv(x, desc_a, info) nrow = psb_cd_get_local_rows(desc_a) ncol = psb_cd_get_local_cols(desc_a) - - if (debug) write(*,*) name,' sizes: ',nrow,ncol + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes: ',nrow,ncol i1sz = size(x) - if (debug) write(*,*) 'dasb: sizes ',i1sz,ncol - if (i1sz.lt.ncol) then + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes ',i1sz,ncol + if (i1sz < ncol) then call psb_realloc(ncol,x,info) if (info /= 0) then - info=4025 - int_err(1)=ncol - call psb_errpush(info,name,int_err,a_err='integer') + info=4010 + call psb_errpush(info,name,a_err='psb_realloc') goto 9999 endif endif ! ..update halo elements.. - call psb_halo(x,desc_a,info,alpha=done) + call psb_halo(x,desc_a,info) + if(info /= 0) then + info=4010 + ch_err='f90_pshalo' + call psb_errpush(info,name,a_err=ch_err) + goto 9999 + end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_icdasb.F90 b/base/tools/psb_icdasb.F90 index cc48298c..9fbf1ee2 100644 --- a/base/tools/psb_icdasb.F90 +++ b/base/tools/psb_icdasb.F90 @@ -28,13 +28,14 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ -! File: psb_cdasb.f90 +! File: psb_icdasb.f90 ! -! Subroutine: psb_cdasb -! Assemble the psblas communications descriptor. +! Subroutine: psb_icdasb +! Assemble the psblas communications descriptor: inner part. +! The user callable routine is defined in the psb_tools_mod module. ! ! Arguments: -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! ext_hv - logical Essentially this distinguishes a call ! coming from the build of an extended @@ -64,17 +65,19 @@ subroutine psb_icdasb(desc_a,info,ext_hv) integer :: int_err(5) integer,allocatable :: ovrlap_index(:),halo_index(:), ext_index(:) - integer :: i,np,me, n_col, dectype, err_act, icomm - integer :: ictxt,n_row - logical :: ext_hv_ - logical, parameter :: debug=.false., debugwrt=.false. - character(len=20) :: name + integer :: i,np,me, n_col, dectype, err_act, icomm + integer :: ictxt,n_row + logical :: ext_hv_ + integer :: debug_level, debug_unit + character(len=20) :: name info = 0 int_err(1) = 0 name = 'psb_cdasb' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) dectype = psb_cd_get_dectype(desc_a) @@ -102,10 +105,12 @@ subroutine psb_icdasb(desc_a,info,ext_hv) else ext_hv_ = .false. end if - if (debug) write (0, *) ' Begin matrix assembly...' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit, *) me,' ',trim(name),': start' if (psb_is_bld_desc(desc_a)) then - if (debug) write(0,*) 'psb_cdasb: Checking rows insertion' + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Checking rows insertion' ! check if all local row are inserted do i=1,psb_cd_get_local_cols(desc_a) if (desc_a%loc_to_glob(i) < 0) then @@ -124,6 +129,8 @@ subroutine psb_icdasb(desc_a,info,ext_hv) ! If large index space, we have to pre-process and rebuild ! the list of halo indices as if it was in small index space if (psb_is_large_desc(desc_a)) then + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Large descriptor, calling ldsc_pre_halo' call psi_ldsc_pre_halo(desc_a,ext_hv_,info) end if @@ -132,6 +139,8 @@ subroutine psb_icdasb(desc_a,info,ext_hv) call psb_transfer(desc_a%halo_index,halo_index,info) call psb_transfer(desc_a%ext_index,ext_index,info) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Final conversion' ! Then convert and put them back where they belong. call psi_cnv_dsc(halo_index,ovrlap_index,ext_index,desc_a,info) if (info /= 0) then @@ -163,10 +172,11 @@ subroutine psb_icdasb(desc_a,info,ext_hv) info = 600 call psb_errpush(info,name) goto 9999 - if (debug) write(0,*) 'dectype 2 :',psb_cd_get_dectype(desc_a),& - &psb_desc_bld_,psb_desc_asb_,psb_desc_upd_ endif + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': Done' + call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_ifree.f90 b/base/tools/psb_ifree.f90 index 3bbc75bb..8af942a5 100644 --- a/base/tools/psb_ifree.f90 +++ b/base/tools/psb_ifree.f90 @@ -35,7 +35,7 @@ ! ! Arguments: ! x(:,:) - integer, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Eventually returns an error code subroutine psb_ifree(x, desc_a, info) !...free dense matrix structure... @@ -140,7 +140,7 @@ end subroutine psb_ifree ! ! Arguments: ! x(:) - integer, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Eventually returns an error code subroutine psb_ifreev(x, desc_a,info) !...free dense matrix structure... diff --git a/base/tools/psb_iins.f90 b/base/tools/psb_iins.f90 index 0381fa21..30747fa5 100644 --- a/base/tools/psb_iins.f90 +++ b/base/tools/psb_iins.f90 @@ -39,7 +39,7 @@ ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:) - integer The source dense submatrix. ! x(:) - integer The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite @@ -223,7 +223,7 @@ end subroutine psb_iinsvi ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:,:) - integer The source dense submatrix. ! x(:,:) - integer The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite diff --git a/base/tools/psb_loc_to_glob.f90 b/base/tools/psb_loc_to_glob.f90 index e53e9050..395d3696 100644 --- a/base/tools/psb_loc_to_glob.f90 +++ b/base/tools/psb_loc_to_glob.f90 @@ -37,7 +37,7 @@ ! Arguments: ! x(:) - integer Array containing the indices to be translated. ! y(:) - integer Array containing the translated indices. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! iact - character, optional A character defining the behaviour on ! an out of range index @@ -62,7 +62,6 @@ subroutine psb_loc_to_glob2(x,y,desc_a,info,iact) integer :: n, i, tmp character :: act integer :: int_err(5), err_act - real(kind(1.d0)) :: real_val integer, parameter :: zero=0 character(len=20) :: name @@ -78,8 +77,6 @@ subroutine psb_loc_to_glob2(x,y,desc_a,info,iact) endif act=toupper(act) - real_val = 0.d0 - n=size(x) do i=1,n if ((x(i).gt.psb_cd_get_local_cols(desc_a)).or.& @@ -166,7 +163,7 @@ end subroutine psb_loc_to_glob2 ! Arguments: ! x(:) - integer Array containing the indices to be translated. ! Overwritten on output. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! iact - character, optional A character defining the behaviour on ! an out of range index @@ -190,7 +187,6 @@ subroutine psb_loc_to_glob(x,desc_a,info,iact) integer :: n ,i, tmp, err_act character :: act integer :: int_err(5) - real(kind(1.d0)) :: real_val integer, parameter :: zero=0 character(len=20) :: name @@ -206,8 +202,6 @@ subroutine psb_loc_to_glob(x,desc_a,info,iact) endif act = toupper(act) - real_val = 0.d0 - n=size(x) do i=1,n if ((x(i).gt.psb_cd_get_local_cols(desc_a)).or.& diff --git a/base/tools/psb_zallc.f90 b/base/tools/psb_zallc.f90 index 42ddc47c..3b9053bc 100644 --- a/base/tools/psb_zallc.f90 +++ b/base/tools/psb_zallc.f90 @@ -32,13 +32,13 @@ ! File: psb_zallc.f90 ! ! Function: psb_zalloc -! Allocates dense matrix for PSBLAS routines +! Allocates dense matrix for PSBLAS routines. ! The descriptor may be in either the build or assembled state. ! ! Arguments: ! x - the matrix to be allocated. ! desc_a - the communication descriptor. -! info - possibly returns an error code +! info - Return code ! n - optional number of columns. subroutine psb_zalloc(x, desc_a, info, n) !....allocate dense matrix for psblas routines..... @@ -52,7 +52,7 @@ subroutine psb_zalloc(x, desc_a, info, n) !....parameters... complex(kind(1.d0)), allocatable, intent(out) :: x(:,:) type(psb_desc_type), intent(in) :: desc_a - integer :: info + integer,intent(out) :: info integer, optional, intent(in) :: n !locals @@ -61,7 +61,7 @@ subroutine psb_zalloc(x, desc_a, info, n) integer :: int_err(5),exch(3) character(len=20) :: name - name='psb_zallc' + name='psb_zgeall_m' if(psb_get_errstatus() /= 0) return info=0 err=0 @@ -185,7 +185,7 @@ end subroutine psb_zalloc ! Arguments: ! x - the matrix to be allocated. ! desc_a - the communication descriptor. -! info - possibly returns an error code +! info - return code subroutine psb_zallocv(x, desc_a,info,n) !....allocate sparse matrix structure for psblas routines..... use psb_descriptor_type @@ -199,19 +199,21 @@ subroutine psb_zallocv(x, desc_a,info,n) !....parameters... complex(kind(1.d0)), allocatable, intent(out) :: x(:) type(psb_desc_type), intent(in) :: desc_a - integer :: info - integer, optional, intent(in) :: n + integer,intent(out) :: info + integer, optional, intent(in) :: n !locals integer :: np,me,n_col,n_row,i,err_act integer :: ictxt, int_err(5) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name if(psb_get_errstatus() /= 0) return info=0 - name='psb_zallcv' + name='psb_zgeall_v' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt=psb_cd_get_context(desc_a) @@ -223,7 +225,6 @@ subroutine psb_zallocv(x, desc_a,info,n) goto 9999 endif - if (debug) write(0,*) 'dall: is_ok?',psb_is_ok_desc(desc_a) !... check m and n parameters.... if (.not.psb_is_ok_desc(desc_a)) then info = 3110 @@ -259,6 +260,10 @@ subroutine psb_zallocv(x, desc_a,info,n) do i=1,n_row x(i) = 0.0d0 end do + else + if (debug_level > psb_debug_ext_) & + & write(debug_unit,*) me,name,& + & ': Did not allocate anything because of dectype',psb_cd_get_dectype(desc_a) endif call psb_erractionrestore(err_act) diff --git a/base/tools/psb_zasb.f90 b/base/tools/psb_zasb.f90 index 4385a8ba..0e02e9b6 100644 --- a/base/tools/psb_zasb.f90 +++ b/base/tools/psb_zasb.f90 @@ -39,7 +39,7 @@ ! ! Arguments: ! x(:,:) - complex, allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code subroutine psb_zasb(x, desc_a, info) !....assembly dense matrix x ..... @@ -57,26 +57,29 @@ subroutine psb_zasb(x, desc_a, info) ! local variables integer :: ictxt,np,me,nrow,ncol, err_act - integer :: int_err(5), i1sz, i2sz - logical, parameter :: debug=.false. + integer :: i1sz, i2sz + integer :: debug_level, debug_unit character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 - name='psb_zasb' + name='psb_zgeasb_m' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() if ((.not.allocated(desc_a%matrix_data))) then info=3110 call psb_errpush(info,name) goto 9999 endif - - ictxt=psb_cd_get_context(desc_a) + ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) write(*,*) 'asb start: ',np,me,& + + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': start: ',np,& & psb_cd_get_dectype(desc_a) ! ....verify blacs grid correctness.. if (np == -1) then @@ -84,10 +87,11 @@ subroutine psb_zasb(x, desc_a, info) call psb_errpush(info,name) goto 9999 else if (.not.psb_is_asb_desc(desc_a)) then - if (debug) write(*,*) 'asb error ',& + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),' error ',& & psb_cd_get_dectype(desc_a) info = 3110 - call psb_errpush(info,name,i_err=int_err) + call psb_errpush(info,name) goto 9999 endif @@ -97,8 +101,10 @@ subroutine psb_zasb(x, desc_a, info) ncol = psb_cd_get_local_cols(desc_a) i1sz = size(x,dim=1) i2sz = size(x,dim=2) - if (debug) write(*,*) 'asb: ',i1sz,i2sz,nrow,ncol - if (i1sz.lt.ncol) then + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ',i1sz,i2sz,nrow,ncol + + if (i1sz < ncol) then call psb_realloc(ncol,i2sz,x,info) if (info /= 0) then info=4010 @@ -115,6 +121,8 @@ subroutine psb_zasb(x, desc_a, info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return @@ -169,7 +177,7 @@ end subroutine psb_zasb ! ! Arguments: ! x(:) - complex, allocatable The matrix to be assembled. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_zasbv(x, desc_a, info) !....assembly dense matrix x ..... @@ -188,15 +196,16 @@ subroutine psb_zasbv(x, desc_a, info) ! local variables integer :: ictxt,np,me integer :: int_err(5), i1sz,nrow,ncol, err_act - - logical, parameter :: debug=.false. - character(len=20) :: name,ch_err + integer :: debug_level, debug_unit + character(len=20) :: name,ch_err info = 0 int_err(1) = 0 - name = 'psb_zasbv' + name = 'psb_zgeasb_v' - ictxt=psb_cd_get_context(desc_a) + ictxt = psb_cd_get_context(desc_a) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() call psb_info(ictxt, me, np) @@ -211,19 +220,20 @@ subroutine psb_zasbv(x, desc_a, info) goto 9999 endif - nrow=psb_cd_get_local_rows(desc_a) - ncol=psb_cd_get_local_cols(desc_a) - if (debug) write(*,*) name,' sizes: ',nrow,ncol + nrow = psb_cd_get_local_rows(desc_a) + ncol = psb_cd_get_local_cols(desc_a) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes: ',nrow,ncol i1sz = size(x) - if (debug) write(*,*) 'dasb: sizes ',i1sz,ncol - if (i1sz.lt.ncol) then + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': sizes ',i1sz,ncol + if (i1sz < ncol) then call psb_realloc(ncol,x,info) if (info /= 0) then info=4010 call psb_errpush(info,name,a_err='psb_realloc') goto 9999 endif - endif ! ..update halo elements.. @@ -234,6 +244,8 @@ subroutine psb_zasbv(x, desc_a, info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': end' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_zcdovr.F90 b/base/tools/psb_zcdovr.F90 index 9acdc5a3..2fa68972 100644 --- a/base/tools/psb_zcdovr.F90 +++ b/base/tools/psb_zcdovr.F90 @@ -36,10 +36,10 @@ ! specified on input. ! ! Arguments: -! a - type(). The input sparse matrix. -! desc_a - type(). The input communication descriptor. +! a - type(psb_zspmat_type). The input sparse matrix. +! desc_a - type(psb_desc_type). The input communication descriptor. ! novr - integer. The number of overlap levels. -! desc_ov - type(). The auxiliary output communication +! desc_ov - type(psb_desc_type). The auxiliary output communication ! descriptor. ! info - integer. Return code. ! extype - integer. Choice of type of overlap: @@ -55,8 +55,8 @@ ! the ext_ structure to provide ! the mapping between the base ! descriptor and the overlapped one. -! c. The (novr+1) layer becomes the new -! halo. +! c. The (novr+1)-th layer becomes the +! new halo. ! Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) @@ -107,18 +107,21 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) Integer,allocatable :: halo(:),works(:),workr(:),t_halo_in(:),& & t_halo_out(:),temp(:),maskr(:) Integer,allocatable :: brvindx(:),rvsz(:), bsdindx(:),sdsz(:) - Logical,Parameter :: debug=.false. - character(len=20) :: name, ch_err + integer :: debug_level, debug_unit + character(len=20) :: name, ch_err - name='psb_cdovr' + name='psb_zcdovr' info = 0 call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) icomm = psb_cd_get_mpic(desc_a) Call psb_info(ictxt, me, np) - If(debug) Write(0,*)'in psb_cdovr',novr + If (debug_level >= psb_debug_outer_) & + & Write(debug_unit,*) me,' ',trim(name),': start',novr if (present(extype)) then extype_ = extype @@ -131,7 +134,6 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) n_col = psb_cd_get_local_cols(desc_a) nhalo = n_col-m - If(debug) Write(0,*)'IN CDOVR1',novr ,m,nnzero,n_col if (novr<0) then info=10 int_err(1)=1 @@ -140,7 +142,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 endif - if (debug) write(0,*) 'Calling desccpy' + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Calling desccpy' call psb_cdcpy(desc_a,desc_ov,info) if (info /= 0) then info=4010 @@ -148,7 +151,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if - if (debug) write(0,*) 'From desccpy' + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':From desccpy' if (novr==0) then ! ! Just copy the input. @@ -158,8 +162,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) - If(debug)then - Write(0,*)'BEGIN cdovr',me,nhalo + If (debug_level >= psb_debug_outer_)then + Write(debug_unit,*) me,' ',trim(name),':BEGIN ',nhalo call psb_barrier(ictxt) endif @@ -178,7 +182,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name) goto 9999 endif - If(debug)Write(0,*)'ovr_est done',me,novr,lovr + If (debug_level >= psb_debug_outer_)& + & Write(debug_unit,*) me,' ',trim(name),':ovr_est done',novr,lovr index_dim = size(desc_a%halo_index) elem_dim = size(desc_a%halo_index) @@ -186,12 +191,10 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) l_tmp_ovr_idx = novr*(3*Max(2*index_dim,1)+1) l_tmp_halo = novr*(3*Size(desc_a%halo_index)) -!!$ write(0,*) 'Size of desc_ov ', desc_ov%matrix_data(psb_desc_size_), & -!!$ & psb_desc_normal_,psb_desc_large_ call psb_cd_set_bld(desc_ov,info) - If(debug) then - Write(0,*)'Start cdovrbld',me,lworks,lworkr + If (debug_level >= psb_debug_outer_) then + Write(debug_unit,*) me,' ',trim(name),':Start',lworks,lworkr call psb_barrier(ictxt) endif @@ -295,7 +298,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) ! Do i_ovr = 1, novr - if (debug) write(0,*) me,'Running on overlap level ',i_ovr,' of ',novr + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Running on overlap level ',i_ovr,' of ',novr ! ! At this point, halo contains a valid halo corresponding to the @@ -326,7 +330,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end If tot_recv=tot_recv+n_elem_recv - if (debug) write(0,*) me,' CDOVRBLD tot_recv:',proc,n_elem_recv,tot_recv + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': tot_recv:',proc,n_elem_recv,tot_recv ! ! ! The format of the halo vector exists in two forms: 1. Temporary @@ -381,7 +386,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) counter_h=counter_h+3 Enddo - if (debug) write(0,*) me,'Checktmp_o_i Loop Mid1',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop Mid1',tmp_ovr_idx(1:10) counter = counter+n_elem_recv ! @@ -392,7 +398,7 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) idx = halo(counter+psb_elem_send_+j) gidx = desc_ov%loc_to_glob(idx) if (idx > psb_cd_get_local_rows(Desc_a)) & - & write(0,*) me,i_ovr,'Out of local rows ',& + & write(debug_unit,*) me,' ',trim(name),':Out of local rows ',i_ovr,& & idx,psb_cd_get_local_rows(Desc_a) call psb_ensure_size((counter_o+3),tmp_ovr_idx,info,pad=-1) @@ -422,7 +428,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) If((n_elem) > size(blk%ia2)) Then isz = max((3*size(blk%ia2))/2,(n_elem)) - if (debug) write(0,*) me,'Realloc blk',isz + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,'Realloc blk',isz call psb_sp_reall(blk,isz,info) if (info /= 0) then info=4010 @@ -439,7 +446,6 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if -!!$ write(0,*) me,'Iteration: ',j,i_ovr Do jj=1,n_elem works(idxs+tot_elem+jj)=desc_ov%loc_to_glob(blk%ia2(jj)) End Do @@ -454,14 +460,17 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) call psb_msort_unique(works(idxs+1:idxs+tot_elem),i) tot_elem=i endif - if (debug) write(0,*) me,'Checktmp_o_i Loop Mid2',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop Mid2',tmp_ovr_idx(1:10) sdsz(proc+1) = tot_elem idxs = idxs + tot_elem end if counter = counter+n_elem_send+3 - if (debug) write(0,*) me,'Checktmp_o_i Loop End',tmp_ovr_idx(1:10) + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i Loop End',tmp_ovr_idx(1:10) Enddo - if (debug) write(0,*)me,'End phase 1 CDOVRBLD', m, n_col, tot_recv + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':End phase 1', m, n_col, tot_recv if (i_ovr <= novr) then ! @@ -514,7 +523,8 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end if - if (debug) write(0,*) 'ISZR :',iszr + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': ISZR :',iszr if (psb_is_large_desc(desc_ov)) then call psb_ensure_size(iszr,maskr,info) @@ -564,8 +574,6 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) t_halo_in(counter_t+2)=lidx t_halo_in(counter_t+3)=-1 counter_t=counter_t+3 - if (.false.) write(0,*) me,' CDOVRBLD: Added t_halo_in ',& - &proc_id,lidx,idx endif end Do n_col = psb_cd_get_local_cols(desc_ov) @@ -606,10 +614,12 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) t_halo_in(counter_t+2)=n_col t_halo_in(counter_t+3)=-1 counter_t=counter_t+3 - if (debug) write(0,*) me,' CDOVRBLD: Added into t_halo_in from recv',& + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': Added into t_halo_in from recv',& &proc_id,n_col,idx else if (desc_ov%glob_to_loc(idx) < 0) Then - if (debug) write(0,*) me,'Wrong input to cdovrbld?',& + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),':Wrong input to cdovrbld?',& &idx,desc_ov%glob_to_loc(idx) End If End Do @@ -630,25 +640,23 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) If (i_ovr < (novr)) Then - if (debug) write(0,*) me,'Checktmp_o_i 1',tmp_ovr_idx(1:10) - if (debug) write(0,*) me,'Calling Crea_Halo' + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),':Checktmp_o_i 1',tmp_ovr_idx(1:10) + write(debug_unit,*) me,' ',trim(name),':Calling Crea_index' + end if call psi_crea_index(desc_ov,t_halo_in,t_halo_out,.false.,& & nxch,nsnd,nrcv,info) - - if (debug) then - write(0,*) me,'Done Crea_Index' + + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),':Done Crea_Index' call psb_barrier(ictxt) end if - if (debug) write(0,*) me,'Checktmp_o_i 2',tmp_ovr_idx(1:10) - if (debug) write(0,*) me,'Done Crea_Halo' call psb_transfer(t_halo_out,halo,info) ! ! At this point we have built the halo necessary for I_OVR+1. ! End If - if (debug) write(0,*) me,'Checktmp_o_i ',tmp_ovr_idx(1:10) - End Do @@ -720,16 +728,13 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) ! called inside CDASB. ! - if (debug) then - write(0,*) 'psb_cdovrbld: converting indexes' + if (debug_level >= psb_debug_outer_) then + write(debug_unit,*) me,' ',trim(name),': converting indexes' call psb_barrier(ictxt) end if + call psb_icdasb(desc_ov,info,ext_hv=.true.) - if (debug) then - write(0,*) me,'Done CDASB' - call psb_barrier(ictxt) - end if if (info == 0) call psb_sp_free(blk,info) if (info /= 0) then @@ -738,6 +743,9 @@ Subroutine psb_zcdovr(a,desc_a,novr,desc_ov,info, extype) goto 9999 end if + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': end' + call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_zfree.f90 b/base/tools/psb_zfree.f90 index befa1a59..3582043a 100644 --- a/base/tools/psb_zfree.f90 +++ b/base/tools/psb_zfree.f90 @@ -35,7 +35,7 @@ ! ! Arguments: ! x(:,:) - complex, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_zfree(x, desc_a, info) !...free dense matrix structure... @@ -110,7 +110,7 @@ end subroutine psb_zfree ! ! Arguments: ! x(:) - complex, allocatable The dense matrix to be freed. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code subroutine psb_zfreev(x, desc_a, info) !...free dense matrix structure... diff --git a/base/tools/psb_zins.f90 b/base/tools/psb_zins.f90 index d2127961..f293b6b5 100644 --- a/base/tools/psb_zins.f90 +++ b/base/tools/psb_zins.f90 @@ -39,7 +39,7 @@ ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:) - complex The source dense submatrix. ! x(:) - complex The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite @@ -224,7 +224,7 @@ end subroutine psb_zinsvi ! irw(:) - integer Row indices of rows of val (global numbering) ! val(:,:) - complex The source dense submatrix. ! x(:,:) - complex The destination dense matrix. -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code ! dupl - integer What to do with duplicates: ! psb_dupl_ovwrt_ overwrite diff --git a/base/tools/psb_zspalloc.f90 b/base/tools/psb_zspalloc.f90 index 322b8a18..2c448279 100644 --- a/base/tools/psb_zspalloc.f90 +++ b/base/tools/psb_zspalloc.f90 @@ -34,8 +34,8 @@ ! Allocate sparse matrix structure for psblas routines. ! ! Arguments: -! a - type(). The sparse matrix to be allocated. -! desc_a - type(). The communication descriptor to be updated. +! a - type(psb_zspmat_type). The sparse matrix to be allocated. +! desc_a - type(psb_desc_type). The communication descriptor to be updated. ! info - integer. Return code. ! nnz - integer(optional). The number of nonzeroes in the matrix. ! (local, user estimate) @@ -61,13 +61,15 @@ subroutine psb_zspalloc(a, desc_a, info, nnz) integer :: np,me,loc_row,loc_col,& & length_ia1,length_ia2, err_act,m,n integer :: int_err(5) - logical, parameter :: debug=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 call psb_erractionsave(err_act) - name = 'psb_zspalloc' + name = 'psb_zspall' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) dectype = psb_cd_get_dectype(desc_a) @@ -101,7 +103,8 @@ subroutine psb_zspalloc(a, desc_a, info, nnz) length_ia1=max(1,5*loc_row) endif - if (debug) write(*,*) 'allocating size:',length_ia1 + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),':allocating size:',length_ia1 !....allocate aspk, ia1, ia2..... call psb_sp_all(loc_row,loc_col,a,length_ia1,info) @@ -112,7 +115,8 @@ subroutine psb_zspalloc(a, desc_a, info, nnz) goto 9999 end if - if (debug) write(0,*) 'spall: ', & + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),': ', & & psb_cd_get_dectype(desc_a),psb_desc_bld_ return diff --git a/base/tools/psb_zspasb.f90 b/base/tools/psb_zspasb.f90 index be928bc0..6723eed7 100644 --- a/base/tools/psb_zspasb.f90 +++ b/base/tools/psb_zspasb.f90 @@ -34,8 +34,8 @@ ! Assemble sparse matrix ! ! Arguments: -! a - type(). The sparse matrix to be assembled -! desc_a - type(). The communication descriptor. +! a - type(psb_zspmat_type). The sparse matrix to be assembled +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! afmt - character(optional) The desired output storage format. ! upd - character(optional). How will the matrix be updated? @@ -71,13 +71,15 @@ subroutine psb_zspasb(a,desc_a, info, afmt, upd, dupl) integer :: np,me,n_col, err_act integer :: spstate integer :: ictxt,n_row - logical, parameter :: debug=.false., debugwrt=.false. + integer :: debug_level, debug_unit character(len=20) :: name, ch_err info = 0 int_err(1)=0 name = 'psb_spasb' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -98,11 +100,13 @@ subroutine psb_zspasb(a,desc_a, info, afmt, upd, dupl) goto 9999 endif - if (debug) Write (*, *) ' Begin matrix assembly...' + if (debug_level >= psb_debug_ext_)& + & write(debug_unit, *) me,' ',trim(name),& + & ' Begin matrix assembly...' !check on errors encountered in psdspins - spstate = a%infoa(psb_state_) + spstate = a%infoa(psb_state_) if (spstate == psb_spmat_bld_) then ! ! First case: we come from a fresh build. @@ -116,7 +120,9 @@ subroutine psb_zspasb(a,desc_a, info, afmt, upd, dupl) call psb_spcnv(a,info,afmt=afmt,upd=upd,dupl=dupl) - IF (debug) WRITE (*, *) me,' ASB: From spcnv',info,' ',A%FIDA + IF (debug_level >= psb_debug_ext_)& + & write(debug_unit, *) me,' ',trim(name),': From SPCNV',& + & info,' ',A%FIDA if (info /= psb_no_err_) then info=4010 ch_err='psb_spcnv' diff --git a/base/tools/psb_zspfree.f90 b/base/tools/psb_zspfree.f90 index ac806d19..48da34a2 100644 --- a/base/tools/psb_zspfree.f90 +++ b/base/tools/psb_zspfree.f90 @@ -34,8 +34,8 @@ ! Frees a sparse matrix structure. ! ! Arguments: -! a - type(). The sparse matrix to be freed. -! desc_a - type(). The communication descriptor. +! a - type(psb_zspmat_type). The sparse matrix to be freed. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. return code. ! subroutine psb_zspfree(a, desc_a,info) diff --git a/base/tools/psb_zsphalo.F90 b/base/tools/psb_zsphalo.F90 index d33f265f..bf9770af 100644 --- a/base/tools/psb_zsphalo.F90 +++ b/base/tools/psb_zsphalo.F90 @@ -38,7 +38,7 @@ ! ! Arguments: ! a - type(psb_zspmat_type) The local part of input matrix A -! desc_a - type(). The communication descriptor. +! desc_a - type(psb_desc_type). The communication descriptor. ! blck - type(psb_zspmat_type) The local part of output matrix BLCK ! info - integer. Return code ! rowcnv - logical Should row/col indices be converted @@ -91,16 +91,19 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& integer, pointer :: idxv(:) logical :: rowcnv_,colcnv_,rowscale_,colscale_ character(len=5) :: outfmt_ - Logical,Parameter :: debug=.false., debugprt=.false. - real(kind(1.d0)) :: t1,t2,t3,t4,t5 - character(len=20) :: name, ch_err + integer :: debug_level, debug_unit + character(len=20) :: name, ch_err if(psb_get_errstatus() /= 0) return info=0 name='psb_zsphalo' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() + + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': Start' - if(debug) write(0,*)'Inside DSPHALO' if (present(rowcnv)) then rowcnv_ = rowcnv else @@ -138,7 +141,6 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& Call psb_info(ictxt, me, np) - t1 = psb_wtime() Allocate(sdid(np,3),rvid(np,3),brvindx(np+1),& & rvsz(np),sdsz(np),bsdindx(np+1),stat=info) @@ -148,8 +150,8 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - If (debug) Write(0,*)'dsphalo',me - + If (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Data selector',data_ select case(data_) case(psb_comm_halo_) idxv => desc_a%halo_index @@ -157,9 +159,9 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& case(psb_comm_ext_) idxv => desc_a%ext_index -!!$ case(psb_comm_ovr_) -!!$ idxv => desc_a%ovrlap_index -!!$ ! Do not accept OVRLAP_INDEX any longer. +! !$ case(psb_comm_ovr_) +! !$ idxv => desc_a%ovrlap_index +! Do not accept OVRLAP_INDEX any longer. case default call psb_errpush(4010,name,a_err='wrong Data selector') goto 9999 @@ -226,7 +228,9 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& iszr=sum(rvsz) call psb_sp_reall(blk,max(iszr,1),info) - if(debug) write(0,*)me,'SPHALO Sizes:',size(blk%ia1),size(blk%ia2) + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Sizes:',size(blk%ia1),size(blk%ia2),& + & ' Send:',sdsz(:),' Receive:',rvsz(:) if (info /= 0) then info=4010 ch_err='psb_sp_reall' @@ -239,15 +243,6 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& if (info == 0) call psb_ensure_size(max(iszs,1),jasnd,info) if (info == 0) call psb_ensure_size(max(iszs,1),valsnd,info) - if (debugprt) then - open(20+me) - do i=1, psb_cd_get_local_cols(desc_a) - write(20+me,*) i,desc_a%loc_to_glob(i) - end do - close(20+me) - end if - t2 = psb_wtime() - l1 = 0 ipx = 1 counter=1 @@ -305,9 +300,6 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - t3 = psb_wtime() - - ! ! Convert into local numbering ! @@ -321,13 +313,6 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - if (debugprt) then - blk%fida='COO' - blk%infoa(psb_nnz_)=iszr - open(40+me) - call psb_csprt(40+me,blk,head='% SPHALO border .') - close(40+me) - end if l1 = 0 blk%m=0 ! @@ -366,15 +351,10 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& blk%fida = 'COO' blk%infoa(psb_nnz_) = l1 - if (debugprt) then - open(50+me) - call psb_csprt(50+me,blk,head='% SPHALO border .') - close(50+me) - call psb_barrier(ictxt) - end if - t4 = psb_wtime() - if(debug) Write(0,*)me,'End first loop',counter,l1,blk%m + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),& + & ': End data exchange',counter,l1,blk%m ! Do we expect any duplicates to appear???? call psb_spcnv(blk,info,afmt=outfmt_,dupl=psb_dupl_add_) @@ -385,15 +365,10 @@ Subroutine psb_zsphalo(a,desc_a,blk,info,rowcnv,colcnv,& goto 9999 end if - t5 = psb_wtime() - -!!$ write(0,'(i3,1x,a,4(1x,i14))') me,'DSPHALO sizes:',iszr,iszs -!!$ write(0,'(i3,1x,a,4(1x,g14.5))') me,'DSPHALO timings:',t6-t2,t7-t6,t8-t7,t3-t8 -!!$ write(0,'(i3,1x,a,4(1x,g14.5))') me,'DSPHALO timings:',t2-t1,t3-t2,t4-t3,t5-t4 - Deallocate(sdid,brvindx,rvid,bsdindx,rvsz,sdsz,& & iasnd,jasnd,valsnd,stat=info) - + if (debug_level >= psb_debug_outer_)& + & write(debug_unit,*) me,' ',trim(name),': Done' call psb_erractionrestore(err_act) return diff --git a/base/tools/psb_zspins.f90 b/base/tools/psb_zspins.f90 index de996f12..c3cac980 100644 --- a/base/tools/psb_zspins.f90 +++ b/base/tools/psb_zspins.f90 @@ -37,15 +37,15 @@ ! If desc_a is in the build state this routine implies a call to psb_cdins. ! ! Arguments: -! nz - integer. The number of points to insert. -! ia(:) - integer The row indices of the coefficients. -! ja(:) - integer The column indices of the coefficients. -! val(:) - complex The values of the coefficients to be inserted. -! a - type(). The sparse destination matrix. -! desc_a - type(). The communication descriptor. -! info - integer. Error code -! rebuild - logical Allows to reopen a matrix under -! certain circumstances. +! nz - integer. The number of points to insert. +! ia(:) - integer The row indices of the coefficients. +! ja(:) - integer The column indices of the coefficients. +! val(:) - complex The values of the coefficients to be inserted. +! a - type(psb_dspmat_type). The sparse destination matrix. +! desc_a - type(psb_desc_type). The communication descriptor. +! info - integer. Error code +! rebuild - logical Allows to reopen a matrix under +! certain circumstances. ! subroutine psb_zspins(nz,ia,ja,val,a,desc_a,info,rebuild) diff --git a/base/tools/psb_zsprn.f90 b/base/tools/psb_zsprn.f90 index 19941e84..08974c50 100644 --- a/base/tools/psb_zsprn.f90 +++ b/base/tools/psb_zsprn.f90 @@ -35,8 +35,8 @@ ! is in the update state. ! ! Arguments: -! a - type(). The sparse matrix to be reinitiated. -! desc_a - type(). The communication descriptor. +! a - type(psb_zspmat_type). The sparse matrix to be reinitiated. +! desc_a - type(psb_desc_type). The communication descriptor. ! info - integer. Return code. ! clear - logical, optional Whether the coefficients should be zeroed ! default .true. @@ -58,8 +58,8 @@ Subroutine psb_zsprn(a, desc_a,info,clear) logical, intent(in), optional :: clear !locals - Integer :: ictxt, np,me,err,err_act - logical, parameter :: debug=.false. + Integer :: ictxt,np,me,err,err_act + integer :: debug_level, debug_unit integer :: int_err(5) character(len=20) :: name logical :: clear_ @@ -69,13 +69,14 @@ Subroutine psb_zsprn(a, desc_a,info,clear) int_err(1)=0 name = 'psb_zsprn' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) & - &write(*,*) 'starting spalloc ',ictxt,np,me + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': start ' - if (psb_is_bld_desc(desc_a)) then ! Should do nothing, we are called redundantly return @@ -94,6 +95,8 @@ Subroutine psb_zsprn(a, desc_a,info,clear) call psb_sp_reinit(a,info,clear=clear_) if (info /= 0) goto 9999 + if (debug_level >= psb_debug_outer_) & + & write(debug_unit,*) me,' ',trim(name),': done' call psb_erractionrestore(err_act) return diff --git a/krylov/psb_dbicg.f90 b/krylov/psb_dbicg.f90 index 97aec5e9..0f295c29 100644 --- a/krylov/psb_dbicg.f90 +++ b/krylov/psb_dbicg.f90 @@ -61,16 +61,15 @@ ! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner ! b - real,dimension(:) Input: vector containing the ! right hand side B ! x - real,dimension(:) Input/Output: vector containing the ! initial guess and final solution X. ! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. ! info - integer. Output: Return code ! ! itmax - integer(optional) Input: maximum number of iterations to be @@ -113,7 +112,7 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) real(kind(1.d0)) ::rerr integer ::litmax, naux, mglob, it, itrace_,& & np,me, n_row, n_col, istop_, err_act - logical, parameter :: debug = .false. + integer :: debug_level, debug_unit logical, parameter :: exchange=.true., noexchange=.false. integer, parameter :: irmax = 8 integer :: itx, isvch, ictxt @@ -124,11 +123,13 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) info = 0 name = 'psb_dbicg' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - if (debug) write(*,*) 'entering psb_dbicg' ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) write(*,*) 'psb_dbicg: from gridinfo',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -147,15 +148,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) ! istop_ = 1: normwise backward error, infinity norm ! istop_ = 2: ||r||/||b|| norm 2 ! -!!$ -!!$ if ((prec%prec < min_prec_).or.(prec%prec > max_prec_) ) then -!!$ write(0,*) 'f90_bicg: invalid iprec',prec%prec -!!$ if (present(ierr)) ierr=-1 -!!$ return -!!$ endif if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_bicg: invalid istop',istop_ info=5001 int_err=istop_ err=info @@ -236,7 +230,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) it = 0 call psb_geaxpby(done,b,dzero,r,desc_a,info) if (info == 0) call psb_spmm(-done,a,x,done,r,desc_a,info,work=aux) - if (debug) write(0,*) me,' Done spmm',info + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),' Done spmm',info if (info == 0) call psb_geaxpby(done,r,dzero,rt,desc_a,info) if(info.ne.0) then info=4011 @@ -245,7 +240,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) end if rho = dzero - if (debug) write(*,*) 'on entry to amax: b: ',size(b) + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),'on entry to amax: b: ',size(b) if (istop_ == 1) then rni = psb_geamax(r,desc_a,info) xni = psb_geamax(x,desc_a,info) @@ -283,7 +279,8 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) iteration: do it = it + 1 itx = itx + 1 - if (debug) write(*,*) 'iteration: ',itx + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),'iteration: ',itx call psb_precaply(prec,r,z,desc_a,info,work=aux) call psb_precaply(prec,rt,zt,desc_a,info,trans='t',work=aux) @@ -291,7 +288,9 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) rho_old = rho rho = psb_gedot(rt,z,desc_a,info) if (rho==dzero) then - if (debug) write(0,*) 'bicg itxation breakdown r',rho + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown r',rho exit iteration endif @@ -311,7 +310,9 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) sigma = psb_gedot(pt,q,desc_a,info) if (sigma==dzero) then - if (debug) write(0,*) 'cgs iteration breakdown s1', sigma + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown s1', sigma exit iteration endif @@ -355,7 +356,7 @@ subroutine psb_dbicg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) if (present(err)) err=rerr if (present(iter)) iter = itx if (rerr>eps) then - write(0,*) 'bicg failed to converge to ',eps,& + write(debug_unit,*) 'bicg failed to converge to ',eps,& & ' in ',itx,' iterations ' end if diff --git a/krylov/psb_dcg.f90 b/krylov/psb_dcg.f90 index 01d035f8..d2b300df 100644 --- a/krylov/psb_dcg.f90 +++ b/krylov/psb_dcg.f90 @@ -62,32 +62,31 @@ ! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - real,dimension(:) Input: vector containing the -! right hand side B -! x - real,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner +! b - real,dimension(:) Input: vector containing the +! right hand side B +! x - real,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! ! Subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) @@ -121,11 +120,11 @@ Subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) name = 'psb_dcg' call psb_erractionsave(err_act) - ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) + mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) n_col = psb_cd_get_local_cols(desc_a) @@ -140,12 +139,6 @@ Subroutine psb_dcg(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) ! ISTOP_ = 2: ||r||/||b|| norm 2 ! -!!$ If ((prec%prec < min_prec_).Or.(prec%prec > max_prec_) ) Then -!!$ Write(0,*) 'F90_CG: Invalid IPREC',prec%prec -!!$ If (Present(ierr)) ierr=-1 -!!$ Return -!!$ Endif - if ((istop_ < 1 ).or.(istop_ > 2 ) ) then write(0,*) 'psb_cg: invalid istop',istop_ info=5001 diff --git a/krylov/psb_dcgs.f90 b/krylov/psb_dcgs.f90 index 741522e4..85b4aa18 100644 --- a/krylov/psb_dcgs.f90 +++ b/krylov/psb_dcgs.f90 @@ -61,37 +61,35 @@ ! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - real,dimension(:) Input: vector containing the -! right hand side B -! x - real,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner +! b - real,dimension(:) Input: vector containing the +! right hand side B +! x - real,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! ! ! -Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& - &itmax,iter,err,itrace,istop) +Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) use psb_base_mod use psb_prec_mod implicit none @@ -117,7 +115,7 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& Logical, Parameter :: exchange=.True., noexchange=.False. Integer, Parameter :: irmax = 8 Integer :: itx, isvch, ictxt - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Real(Kind(1.d0)) :: alpha, beta, rho, rho_old, rni, xni, bni, ani,bn2,& & sigma character(len=20) :: name @@ -125,11 +123,13 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& info = 0 name = 'psb_dcgs' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - If (debug) Write(*,*) 'entering psb_dcgs' ictxt = psb_cd_get_context(desc_a) Call psb_info(ictxt, me, np) - If (debug) Write(*,*) 'psb_dcgs: from gridinfo',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -144,15 +144,8 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& ! istop_ = 1: normwise backward error, infinity norm ! istop_ = 2: ||r||/||b|| norm 2 ! -!!$ -!!$ If ((prec%prec < 0).Or.(prec%prec > 6) ) Then -!!$ Write(0,*) 'f90_cgstab: invalid iprec',prec%prec -!!$ If (Present(ierr)) ierr=-1 -!!$ Return -!!$ Endif if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_cgs: invalid istop',istop_ info=5001 int_err=istop_ err=info @@ -203,9 +196,9 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& Endif If (Present(itrace)) Then - itrace_ = itrace + itrace_ = itrace Else - itrace_ = 0 + itrace_ = 0 End If ! Ensure global coherence for convergence checks. @@ -241,7 +234,9 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& end if rho = dzero - If (debug) Write(*,*) 'on entry to amax: b: ',Size(b) + If (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),& + & ' on entry to amax: b: ',Size(b) if (istop_ == 1) then rni = psb_geamax(r,desc_a,info) @@ -264,15 +259,17 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& & write(*,'(a,i4,3(2x,es10.4))') 'cgs: ',itx,rerr end If - iteration: Do it = it + 1 itx = itx + 1 - If (debug) Write(*,*) 'iteration: ',itx + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),'iteration: ',itx rho_old = rho rho = psb_gedot(rt,r,desc_a,info) If (rho==dzero) Then - If (debug) Write(0,*) 'cgs iteration breakdown r',rho + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown r',rho Exit iteration Endif @@ -295,7 +292,9 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& sigma = psb_gedot(rt,v,desc_a,info) If (sigma==dzero) Then - If (debug) Write(0,*) 'cgs iteration breakdown s1', sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown s1', sigma Exit iteration Endif @@ -348,7 +347,7 @@ Subroutine psb_dcgs(a,prec,b,x,eps,desc_a,info,& If (Present(err)) err=rerr If (Present(iter)) iter = itx If (rerr>eps) Then - Write(0,*) 'cgs failed to converge to ',eps,& + write(debug_unit,*) 'cgs failed to converge to ',eps,& & ' in ',itx,' iterations ' End If diff --git a/krylov/psb_dcgstab.F90 b/krylov/psb_dcgstab.F90 index 705249a2..00b98d51 100644 --- a/krylov/psb_dcgstab.F90 +++ b/krylov/psb_dcgstab.F90 @@ -61,32 +61,31 @@ ! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - real,dimension(:) Input: vector containing the -! right hand side B -! x - real,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner +! b - real,dimension(:) Input: vector containing the +! right hand side B +! x - real,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! ! ! @@ -112,7 +111,7 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) Real(Kind(1.d0)) :: rerr Integer :: litmax, naux, mglob, it,itrace_,& & np,me, n_row, n_col - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Logical, Parameter :: exchange=.True., noexchange=.False., debug1 = .False. Integer, Parameter :: irmax = 8 Integer :: itx, isvch, ictxt, err_act, int_err(5) @@ -128,11 +127,13 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) info = 0 name = 'psb_dcgstab' call psb_erractionsave(err_act) - - If (debug) Write(*,*) 'Entering PSB_DCGSTAB',present(istop) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) call psb_info(ictxt, me, np) - if (debug) write(*,*) 'PSB_DCGSTAB: From GRIDINFO',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np + #ifdef MPE_KRYLOV call psb_get_mpicomm(ictxt,icomm) call psb_get_rank(irank,ictxt,me) @@ -168,7 +169,6 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) #endif if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_bicgstab: invalid istop',istop_ info=5001 int_err(1)=istop_ err=info @@ -259,12 +259,14 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) End If rho = dzero - If (debug) Write(*,*) 'On entry to AMAX: B: ',Size(b) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' On entry to AMAX: B: ',Size(b) -! -! Must always provide norm of R into RNI below for first check on -! residual -! + ! + ! Must always provide norm of R into RNI below for first check on + ! residual + ! If (istop_ == 1) Then rni = psb_geamax(r,desc_a,info) xni = psb_geamax(x,desc_a,info) @@ -311,13 +313,19 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) iteration: Do it = it + 1 itx = itx + 1 - If (debug) Write(*,*) 'Iteration: ',itx + If (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration: ',itx rho_old = rho rho = psb_gedot(q,r,desc_a,info) -!!$ write(0,'(i2," rho old ",2(f,2x))')me,rho,rho_old - If (debug) Write(0,*) 'Bi-CGSTAB RHO:',rho + + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' RHO:',rho If (rho==dzero) Then - If (debug) Write(0,*) 'Bi-CGSTAB Itxation breakdown R',rho + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown R',rho Exit iteration Endif @@ -346,10 +354,14 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) sigma = psb_gedot(q,v,desc_a,info) If (sigma==dzero) Then - If (debug) Write(0,*) 'Bi-CGSTAB Iteration breakdown S1', sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown S1', sigma Exit iteration Endif - If (debug) Write(0,*) 'Bi-CGSTAB SIGMA:',sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' SIGMA:',sigma alpha = rho/sigma Call psb_geaxpby(done,r,dzero,s,desc_a,info) if(info /= 0) then @@ -390,15 +402,21 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) sigma = psb_gedot(t,t,desc_a,info) If (sigma==dzero) Then - If (debug) Write(0,*) 'BI-CGSTAB ITERATION BREAKDOWN S2', sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown S2', sigma Exit iteration Endif tau = psb_gedot(t,s,desc_a,info) omega = tau/sigma - If (debug) Write(0,*) 'Bi-CGSTAB OMEGA:',omega + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Omega:',omega If (omega==dzero) Then - If (debug) Write(0,*) 'BI-CGSTAB ITERATION BREAKDOWN O',omega + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown O',omega Exit iteration Endif @@ -438,7 +456,7 @@ Subroutine psb_dcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) If (Present(err)) err=rerr If (Present(iter)) iter = itx If (rerr>eps) Then - Write(0,*) 'BI-CGSTAB failed to converge to ',EPS,& + write(debug_unit,*) 'BI-CGSTAB failed to converge to ',EPS,& & ' in ',ITX,' iterations. ' End If diff --git a/krylov/psb_dcgstabl.f90 b/krylov/psb_dcgstabl.f90 index 443f4e8d..478ff446 100644 --- a/krylov/psb_dcgstabl.f90 +++ b/krylov/psb_dcgstabl.f90 @@ -68,34 +68,33 @@ ! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - real,dimension(:) Input: vector containing the -! right hand side B -! x - real,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner +! b - real,dimension(:) Input: vector containing the +! right hand side B +! x - real,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! irst - integer(optional) Input: restart parameter L +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! irst - integer(optional) Input: restart parameter L ! -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! ! ! @@ -126,7 +125,7 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is Logical, Parameter :: exchange=.True., noexchange=.False. Integer, Parameter :: irmax = 8 Integer :: itx, i, isvch, ictxt,istop_,j, int_err(5) - Logical, Parameter :: debug = .False. + integer :: debug_level, debug_unit Real(Kind(1.d0)) :: alpha, beta, rho, rho_old, rni, xni, bni, ani,bn2,& & omega character(len=20) :: name @@ -134,12 +133,14 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is info = 0 name = 'psb_dcgstabl' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - If (debug) Write(0,*) 'entering psb_dbicgstabl' ictxt = psb_cd_get_context(desc_a) Call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np - If (debug) Write(0,*) 'psb_dbicgstabl: from gridinfo',np,me mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -156,7 +157,6 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is ! if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_bicgstabl: invalid istop',istop_ info=5001 int_err=istop_ err=info @@ -178,13 +178,16 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is If (Present(irst)) Then nl = irst - If (debug) Write(0,*) 'present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & 'present: irst: ',irst,nl Else nl = 1 - If (debug) Write(0,*) 'not present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' not present: irst: ',irst,nl Endif if (nl <=0 ) then - write(0,*) 'psb_bicgstabl: invalid irst ',nl info=5001 int_err(1)=nl err=info @@ -257,7 +260,8 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is !!$ !!$ r0 = b-ax0 !!$ - If (debug) Write(0,*) 'restart: ',itx,it + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),' restart: ',itx,it If (itx.Ge.litmax) Exit restart it = 0 Call psb_geaxpby(done,b,dzero,r,desc_a,info) @@ -278,7 +282,9 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is alpha = dzero omega = done - If (debug) Write(0,*) 'on entry to amax: b: ',Size(b) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' on entry to amax: b: ',Size(b) if (istop_ == 1) then rni = psb_geamax(r,desc_a,info) @@ -306,32 +312,45 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is it = it + nl itx = itx + nl rho = -omega*rho - If (debug) Write(0,*) 'iteration: ',itx, rho,rh(1,0) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration: ',itx, rho,rh(1,0) Do j = 0, nl -1 - If (debug) Write(0,*) 'bicg part: ',j, nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),'bicg part: ',j, nl rho_old = rho rho = psb_gedot(rh(:,j),rt0,desc_a,info) If (rho==dzero) Then - If (debug) Write(0,*) 'bi-cgstab iteration breakdown r',rho + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' bi-cgstab iteration breakdown r',rho Exit iteration Endif beta = alpha*rho/rho_old - If (debug) Write(0,*) 'bicg part: ',alpha,beta,rho,rho_old + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' bicg part: ',alpha,beta,rho,rho_old rho_old = rho Call psb_geaxpby(done,rh(:,0:j),-beta,uh(:,0:j),desc_a,info) - If (debug) Write(0,*) 'bicg part: ',rh(1,0),beta + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' bicg part: ',rh(1,0),beta Call psb_spmm(done,a,uh(:,j),dzero,uh(:,j+1),desc_a,info,work=aux) call psb_precaply(prec,uh(:,j+1),desc_a,info) gamma(j) = psb_gedot(uh(:,j+1),rt0,desc_a,info) If (gamma(j)==dzero) Then - If (debug) Write(0,*) 'bi-cgstab iteration breakdown s2',gamma(j) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' bi-cgstab iteration breakdown s2',gamma(j) Exit iteration Endif alpha = rho/gamma(j) - If (debug) Write(0,*) 'bicg part: alpha=r/g ',alpha,rho,gamma(j) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' bicg part: alpha=r/g ',alpha,rho,gamma(j) Call psb_geaxpby(-alpha,uh(:,1:j+1),done,rh(:,0:j),desc_a,info) Call psb_geaxpby(alpha,uh(:,0),done,x,desc_a,info) @@ -342,17 +361,20 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is Enddo Do j=1, nl - If (debug) Write(0,*) 'mod g-s part: ',j, nl,rh(1,0) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' mod g-s part: ',j, nl,rh(1,0) Do i=1, j-1 taum(i,j) = psb_gedot(rh(:,i),rh(:,j),desc_a,info) taum(i,j) = taum(i,j)/sigma(i) Call psb_geaxpby(-taum(i,j),rh(:,i),done,rh(:,j),desc_a,info) Enddo - If (debug) Write(0,*) 'mod g-s part: dot prod ' sigma(j) = psb_gedot(rh(:,j),rh(:,j),desc_a,info) gamma1(j) = psb_gedot(rh(:,0),rh(:,j),desc_a,info) - If (debug) Write(0,*) 'mod g-s part: gamma1 ', & - &gamma1(j), sigma(j) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' mod g-s part: gamma1 ',gamma1(j), sigma(j) + gamma1(j) = gamma1(j)/sigma(j) Enddo @@ -365,7 +387,9 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is gamma(j) = gamma(j) - taum(j,i) * gamma(i) Enddo Enddo - If (debug) Write(0,*) 'first solve: ', gamma(:) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' first solve: ', gamma(:) Do j=1,nl-1 gamma2(j) = gamma(j+1) @@ -373,7 +397,9 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is gamma2(j) = gamma2(j) + taum(j,i) * gamma(i+1) Enddo Enddo - If (debug) Write(0,*) 'second solve: ', gamma(:) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' second solve: ', gamma(:) Call psb_geaxpby(gamma(1),rh(:,0),done,x,desc_a,info) Call psb_geaxpby(-gamma1(nl),rh(:,nl),done,rh(:,0),desc_a,info) @@ -413,7 +439,7 @@ Subroutine psb_dcgstabl(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,is If (Present(err)) err=rerr If (Present(iter)) iter = itx If (rerr>eps) Then - Write(0,*) 'bi-cgstabl failed to converge to ',eps,& + write(debug_unit,*) 'bi-cgstabl failed to converge to ',eps,& & ' in ',itx,' iterations ' End If diff --git a/krylov/psb_dgmresr.f90 b/krylov/psb_dgmresr.f90 index 04e5bf42..7e5e672e 100644 --- a/krylov/psb_dgmresr.f90 +++ b/krylov/psb_dgmresr.f90 @@ -70,37 +70,35 @@ ! This subroutine implements the restarted GMRES method with right ! preconditioning. ! -! ! Arguments: ! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - real,dimension(:) Input: vector containing the -! right hand side B -! x - real,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_dspmat_type) Input: sparse matrix containing A. +! prec - type(psb_dprec_type) Input: preconditioner +! b - real,dimension(:) Input: vector containing the +! right hand side B +! x - real,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! irst - integer(optional) Input: restart parameter -! -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! irst - integer(optional) Input: restart parameter +! +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop) use psb_base_mod @@ -127,7 +125,7 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist Logical, Parameter :: exchange=.True., noexchange=.False., use_drot=.true. Integer, Parameter :: irmax = 8 Integer :: itx, i, isvch, ictxt,istop_, err_act - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Real(Kind(1.d0)) :: rni, xni, bni, ani,bn2, dt real(kind(1.d0)), external :: dnrm2 character(len=20) :: name @@ -135,12 +133,13 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist info = 0 name = 'psb_dgmres' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - If (debug) Write(0,*) 'entering psb_dgmres' ictxt = psb_cd_get_context(desc_a) Call psb_info(ictxt, me, np) - - If (debug) Write(0,*) 'psb_dgmres: from gridinfo',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -157,7 +156,6 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_dgmres: invalid istop',istop_ info=5001 int_err(1)=istop_ err=info @@ -172,20 +170,23 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist Endif If (Present(itrace)) Then - itrace_ = itrace + itrace_ = itrace Else - itrace_ = 0 + itrace_ = 0 End If If (Present(irst)) Then nl = irst - If (debug) Write(0,*) 'present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' present: irst: ',irst,nl Else nl = 10 - If (debug) Write(0,*) 'not present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' not present: irst: ',irst,nl Endif if (nl <=0 ) then - write(0,*) 'psb_dgmres: invalid irst ',nl info=5001 int_err(1)=nl err=info @@ -220,12 +221,14 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist if (info == 0) Call psb_geasb(w1,desc_a,info) if (info == 0) Call psb_geasb(xt,desc_a,info) if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If - if (debug) write(0,*) 'Size of V,W,W1 ',size(v),size(v,1),& - &size(w),size(w,1),size(w1),size(w1,1), size(v(:,1)) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Size of V,W,W1 ',size(v),size(v,1),& + & size(w),size(w,1),size(w1),size(w1,1), size(v(:,1)) ! Ensure global coherence for convergence checks. call psb_set_coher(ictxt,isvch) @@ -237,9 +240,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist bn2 = psb_genrm2(b,desc_a,info) endif if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If itx = 0 @@ -249,32 +252,36 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! check convergence ! compute v1 = r0/||r0||_2 - If (debug) Write(0,*) 'restart: ',itx,it + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' restart: ',itx,it it = 0 Call psb_geaxpby(done,b,dzero,v(:,1),desc_a,info) if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If Call psb_spmm(-done,a,x,done,v(:,1),desc_a,info,work=aux) if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If rs(1) = psb_genrm2(v(:,1),desc_a,info) rs(2:) = dzero if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If scal=done/rs(1) ! rs(1) MIGHT BE VERY SMALL - USE DSCAL TO DEAL WITH IT? - If (debug) Write(0,*) 'on entry to amax: b: ',Size(b),rs(1),scal + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' on entry to amax: b: ',Size(b),rs(1),scal ! ! check convergence @@ -288,9 +295,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist rerr = rni/bn2 endif if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If If (rerr<=eps) Then @@ -343,7 +350,8 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist h(k,i) = -s(k-1)*dt + c(k-1)*h(k,i) enddo gm = safe_dn2(h(i,i),h(i+1,i)) - if (debug) write(0,*) 'GM : ',gm + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),' GM : ',gm gm = max(gm,epstol) c(i) = h(i,i)/gm @@ -359,7 +367,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist rst = rs xt = dzero call dtrsm('l','u','n','n',i,1,done,h,size(h,1),rst,size(rst,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rst(1:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rst(1:nl) do k=1, i call psb_geaxpby(rst(k),v(:,k),done,xt,desc_a,info) end do @@ -391,7 +401,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! build x ! call dtrsm('l','u','n','n',i,1,done,h,size(h,1),rs,size(rs,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rs(21:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rs(1:nl) w1 = dzero do k=1, i call psb_geaxpby(rs(k),v(:,k),done,w1,desc_a,info) @@ -418,7 +430,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! build x ! call dtrsm('l','u','n','n',nl,1,done,h,size(h,1),rs,size(rs,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rs(21:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rs(1:nl) w1 = dzero do k=1, nl call psb_geaxpby(rs(k),v(:,k),done,w1,desc_a,info) @@ -435,7 +449,7 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist If (Present(err)) err=rerr If (Present(iter)) iter = itx If ((rerr>eps).and. (me == 0)) Then - Write(0,*) 'gmresr(l) failed to converge to ',eps,& + write(debug_unit,*) 'gmresr(l) failed to converge to ',eps,& & ' in ',itx,' iterations ' End If @@ -450,9 +464,9 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist call psb_restore_coher(ictxt,isvch) if (info /= 0) then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 end if call psb_erractionrestore(err_act) @@ -461,8 +475,8 @@ Subroutine psb_dgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist 9999 continue call psb_erractionrestore(err_act) if (err_act.eq.psb_act_abort_) then - call psb_error() - return + call psb_error() + return end if return diff --git a/krylov/psb_krylov_mod.f90 b/krylov/psb_krylov_mod.f90 index 30a9d0d2..b1ab1b1f 100644 --- a/krylov/psb_krylov_mod.f90 +++ b/krylov/psb_krylov_mod.f90 @@ -28,6 +28,10 @@ !!$ POSSIBILITY OF SUCH DAMAGE. !!$ !!$ +! +! File: psb_krylov_mod.f90 +! Interfaces for Krylov subspace iterative methods. +! Module psb_krylov_mod @@ -189,9 +193,6 @@ Module psb_krylov_mod end interface contains - ! - ! File: psb_krylov_mod.f90 - ! ! Subroutine: psb_dkrylov ! ! Front-end for the Krylov subspace iterations, real version @@ -206,16 +207,16 @@ contains ! BICGSTABL ! RGMRES ! - ! a - type() Input: sparse matrix containing A. - ! prec - type() Input: preconditioner + ! a - type(psb_dspmat_type) Input: sparse matrix containing A. + ! prec - type(psb_dprec_type) Input: preconditioner ! b - real,dimension(:) Input: vector containing the ! right hand side B ! x - real,dimension(:) Input/Output: vector containing the ! initial guess and final solution X. ! eps - real Input: Stopping tolerance; the iteration is - ! stopped when the error estimate - ! |err| <= eps - ! desc_a - type(). Input: The communication descriptor. + ! stopped when the error + ! estimate |err| <= eps + ! desc_a - type(psb_desc_type). Input: The communication descriptor. ! info - integer. Output: Return code ! ! itmax - integer(optional) Input: maximum number of iterations to be @@ -236,8 +237,7 @@ contains ! estimate of) residual ! - Subroutine psb_dkrylov(method,a,prec,b,x,eps,desc_a,info,& - &itmax,iter,err,itrace,irst,istop) + Subroutine psb_dkrylov(method,a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop) use psb_base_mod use psb_prec_mod @@ -310,8 +310,6 @@ contains end subroutine psb_dkrylov - ! - ! File: psb_krylov_mod.f90 ! ! Subroutine: psb_zkrylov ! @@ -324,16 +322,17 @@ contains ! BICGSTAB ! RGMRES ! - ! a - type() Input: sparse matrix containing A. - ! prec - type() Input: preconditioner + ! a - type(psb_zspmat_type) Input: sparse matrix containing A. + ! prec - type(psb_zprec_type) Input: preconditioner ! b - complex,dimension(:) Input: vector containing the ! right hand side B ! x - complex,dimension(:) Input/Output: vector containing the ! initial guess and final solution X. ! eps - real Input: Stopping tolerance; the iteration is - ! stopped when the error estimate - ! |err| <= eps - ! desc_a - type(). Input: The communication descriptor. + ! stopped when the error + ! estimate |err| <= eps + ! + ! desc_a - type(psb_desc_type). Input: The communication descriptor. ! info - integer. Output: Return code ! ! itmax - integer(optional) Input: maximum number of iterations to be @@ -353,8 +352,7 @@ contains ! where r is the (preconditioned, recursive ! estimate of) residual ! - Subroutine psb_zkrylov(method,a,prec,b,x,eps,desc_a,info,& - &itmax,iter,err,itrace,irst,istop) + Subroutine psb_zkrylov(method,a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop) use psb_base_mod use psb_prec_mod character(len=*) :: method diff --git a/krylov/psb_zcgs.f90 b/krylov/psb_zcgs.f90 index fda690ce..be036dc9 100644 --- a/krylov/psb_zcgs.f90 +++ b/krylov/psb_zcgs.f90 @@ -60,37 +60,31 @@ ! ! Arguments: ! -! methd - character The specific method; can take the values: -! CGS -! BICGSTAB -! RGMRES -! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - complex,dimension(:) Input: vector containing the -! right hand side B -! x - complex,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_zspmat_type) Input: sparse matrix containing A. +! prec - type(psb_zprec_type) Input: preconditioner +! b - complex,dimension(:) Input: vector containing the +! right hand side B +! x - complex,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) use psb_base_mod @@ -118,7 +112,7 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) Logical, Parameter :: exchange=.True., noexchange=.False. Integer, Parameter :: irmax = 8 Integer :: itx, isvch, ictxt - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Real(Kind(1.d0)) :: rni, xni, bni, ani,bn2 complex(Kind(1.d0)) :: alpha, beta, rho, rho_old, sigma character(len=20) :: name @@ -126,36 +120,29 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) info = 0 name = 'psb_zcgs' call psb_erractionsave(err_act) - - If (debug) Write(*,*) 'entering psb_zcgs' + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) - Call psb_info(ictxt, me, np) - If (debug) Write(*,*) 'psb_zcgs: from gridinfo',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) - n_col = psb_cd_get_local_cols(desc_a) + n_col = psb_cd_get_local_cols(desc_a) If (Present(istop)) Then istop_ = istop Else istop_ = 1 Endif - ! - ! istop_ = 1: normwise backward error, infinity norm - ! istop_ = 2: ||r||/||b|| norm 2 - ! -!!$ -!!$ If ((prec%prec < 0).Or.(prec%prec > 6) ) Then -!!$ Write(0,*) 'f90_cgstab: invalid iprec',prec%prec -!!$ If (Present(ierr)) ierr=-1 -!!$ Return -!!$ Endif - +! +! istop_ = 1: normwise backward error, infinity norm +! istop_ = 2: ||r||/||b|| norm 2 +! + if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_cgs: invalid istop',istop_ info=5001 int_err=istop_ err=info @@ -181,9 +168,9 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) if (info == 0) Call psb_geall(wwrk,desc_a,info,n=11) if (info == 0) Call psb_geasb(wwrk,desc_a,info) if (info.ne.0) Then - info=4011 - call psb_errpush(info,name) - goto 9999 + info=4011 + call psb_errpush(info,name) + goto 9999 End If q => wwrk(:,1) @@ -242,9 +229,11 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) call psb_errpush(info,name) goto 9999 end if - + rho = zzero - If (debug) Write(*,*) 'on entry to amax: b: ',Size(b) + If (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),& + & ' on entry to amax: b: ',Size(b) if (istop_ == 1) then rni = psb_geamax(r,desc_a,info) @@ -271,11 +260,14 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) iteration: Do it = it + 1 itx = itx + 1 - If (debug) Write(*,*) 'iteration: ',itx + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),'iteration: ',itx rho_old = rho rho = psb_gedot(rt,r,desc_a,info) If (rho==zzero) Then - If (debug) Write(0,*) 'cgs iteration breakdown r',rho + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown r',rho Exit iteration Endif @@ -298,8 +290,10 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) sigma = psb_gedot(rt,v,desc_a,info) If (sigma==zzero) Then - If (debug) Write(0,*) 'cgs iteration breakdown s1', sigma - Exit iteration + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' iteration breakdown s1', sigma + Exit iteration Endif alpha = rho/sigma @@ -331,6 +325,7 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) If (rerr<=eps) Then Exit restart End If + If (itx.Ge.litmax) Exit restart If (itrace_ > 0) then @@ -341,13 +336,15 @@ Subroutine psb_zcgs(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) End Do iteration End Do restart If (itrace_ > 0) then - if (me == 0) write(*,'(a,i4,3(2x,es10.4))') 'cgs: ',itx,rerr + if ((mod(itx,itrace_)==0).and.(me == 0))& + & write(*,'(a,i4,3(2x,es10.4))') 'cgs: ',itx,rerr end If + If (Present(err)) err=rerr If (Present(iter)) iter = itx If (rerr>eps) Then - Write(0,*) 'cgs failed to converge to ',eps,& + write(debug_unit,*) 'cgs failed to converge to ',eps,& & ' in ',itx,' iterations ' End If diff --git a/krylov/psb_zcgstab.f90 b/krylov/psb_zcgstab.f90 index 9e633c3c..7dda3936 100644 --- a/krylov/psb_zcgstab.f90 +++ b/krylov/psb_zcgstab.f90 @@ -61,37 +61,31 @@ ! ! Arguments: ! -! methd - character The specific method; can take the values: -! CGS -! BICGSTAB -! RGMRES -! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - complex,dimension(:) Input: vector containing the -! right hand side B -! x - complex,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_zspmat_type) Input: sparse matrix containing A. +! prec - type(psb_zprec_type) Input: preconditioner +! b - complex,dimension(:) Input: vector containing the +! right hand side B +! x - complex,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) use psb_base_mod @@ -115,7 +109,7 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) Real(Kind(1.d0)) :: rerr Integer :: litmax, naux, mglob, it,itrace_,& & np,me, n_row, n_col - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Logical, Parameter :: exchange=.True., noexchange=.False., debug1 = .False. Integer, Parameter :: irmax = 8 Integer :: itx, isvch, ictxt, err_act, int_err(5) @@ -129,11 +123,12 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) info = 0 name = 'psb_zcgstab' call psb_erractionsave(err_act) - - If (debug) Write(*,*) 'Entering PSB_ZCGSTAB',present(istop) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() ictxt = psb_cd_get_context(desc_a) - CALL psb_info(ictxt, me, np) - if (debug) write(*,*) 'PSB_ZCGSTAB: From GRIDINFO',np,me + call psb_info(ictxt, me, np) + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -150,7 +145,6 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) ! if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_bicgstab: invalid istop',istop_ info=5001 int_err(1)=istop_ err=info @@ -202,7 +196,6 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) itrace_ = 0 End If - ! Ensure global coherence for convergence checks. call psb_set_coher(ictxt,isvch) @@ -236,7 +229,9 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) End If rho = zzero - If (debug) Write(*,*) 'On entry to AMAX: B: ',Size(b) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' On entry to AMAX: B: ',Size(b) ! ! Must always provide norm of R into RNI below for first check on @@ -258,6 +253,9 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) rn0 = rni End If If (rn0 == 0.d0 ) Then + If (itrace_ > 0 ) Then + If (me == 0) Write(*,*) 'BiCGSTAB: ',itx,rn0 + Endif Exit restart End If @@ -278,20 +276,26 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) End If If (itrace_ > 0) then - if ((mod(itx,itrace_)==0).and.(me == 0))& + if (((itx==0).or.(mod(itx,itrace_)==0)).and.(me == 0)) & & write(*,'(a,i4,3(2x,es10.4))') 'bicgstab: ',itx,rerr end If iteration: Do it = it + 1 itx = itx + 1 - If (debug) Write(*,*) 'Iteration: ',itx - + If (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration: ',itx rho_old = rho rho = psb_gedot(q,r,desc_a,info) + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' RHO:',rho If (rho==zzero) Then - If (debug) Write(0,*) 'Bi-CGSTAB Itxation breakdown R',rho + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown R',rho Exit iteration Endif @@ -310,24 +314,28 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) sigma = psb_gedot(q,v,desc_a,info) If (sigma==zzero) Then - If (debug) Write(0,*) 'Bi-CGSTAB Iteration breakdown S1', sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown S1', sigma Exit iteration Endif - + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' SIGMA:',sigma alpha = rho/sigma Call psb_geaxpby(zone,r,zzero,s,desc_a,info) - if(info.ne.0) then + if(info /= 0) then call psb_errpush(4010,name,a_err='psb_geaxpby') goto 9999 end if Call psb_geaxpby(-alpha,v,zone,s,desc_a,info) - if(info.ne.0) then + if(info /= 0) then call psb_errpush(4010,name,a_err='psb_geaxpby') goto 9999 end if Call psb_precaply(prec,s,z,desc_a,info,work=aux) - if(info.ne.0) then + if(info /= 0) then call psb_errpush(4010,name,a_err='psb_precaply') goto 9999 end if @@ -335,14 +343,16 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) Call psb_spmm(zone,a,z,zzero,t,desc_a,info,& & work=aux) - if(info.ne.0) then + if(info /= 0) then call psb_errpush(4010,name,a_err='psb_spmm') goto 9999 end if sigma = psb_gedot(t,t,desc_a,info) If (sigma==zzero) Then - If (debug) Write(0,*) 'BI-CGSTAB ITERATION BREAKDOWN S2', sigma + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown S2', sigma Exit iteration Endif @@ -350,7 +360,9 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) omega = tau/sigma If (omega==zzero) Then - If (debug) Write(0,*) 'BI-CGSTAB ITERATION BREAKDOWN O',omega + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Iteration breakdown O',omega Exit iteration Endif @@ -373,22 +385,24 @@ Subroutine psb_zcgstab(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,istop) End If If (itx.Ge.litmax) Exit restart - If (itrace_ > 0) then - if ((mod(itx,itrace_)==0).and.(me == 0))& - & write(*,'(a,i4,3(2x,es10.4))') 'bicgstab: ',itx,rerr - end If + If (itrace_ > 0) then + if ((mod(itx,itrace_)==0).and.(me == 0)) & + & write(*,'(a,i4,3(2x,es10.4))') & + & 'bicgstab: ',itx,rerr + Endif + End Do iteration End Do restart If (itrace_ > 0) then if (me == 0) write(*,'(a,i4,3(2x,es10.4))') 'bicgstab: ',itx,rerr - end If - + Endif + If (Present(err)) err=rerr If (Present(iter)) iter = itx If (rerr>eps) Then - Write(0,*) 'BI-cgstab failed to converge to ',eps,& - & ' in ',itx,' iterations. ' + write(debug_unit,*) 'BI-CGSTAB failed to converge to ',EPS,& + & ' in ',ITX,' iterations. ' End If Deallocate(aux) diff --git a/krylov/psb_zgmresr.f90 b/krylov/psb_zgmresr.f90 index c4bddea6..439e8f9d 100644 --- a/krylov/psb_zgmresr.f90 +++ b/krylov/psb_zgmresr.f90 @@ -66,45 +66,39 @@ !!$ CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC ! File: psb_dgmresr.f90 ! -! Subroutine: psb_dgmres +! Subroutine: psb_zgmres ! This subroutine implements the restarted GMRES method with right ! preconditioning. ! ! Arguments: ! -! methd - character The specific method; can take the values: -! CGS -! BICGSTAB -! RGMRES -! -! a - type() Input: sparse matrix containing A. -! prec - type() Input: preconditioner -! b - complex,dimension(:) Input: vector containing the -! right hand side B -! x - complex,dimension(:) Input/Output: vector containing the -! initial guess and final solution X. -! eps - real Input: Stopping tolerance; the iteration is -! stopped when the error estimate -! |err| <= eps -! desc_a - type(). Input: The communication descriptor. -! info - integer. Output: Return code +! a - type(psb_zspmat_type) Input: sparse matrix containing A. +! prec - type(psb_zprec_type) Input: preconditioner +! b - complex,dimension(:) Input: vector containing the +! right hand side B +! x - complex,dimension(:) Input/Output: vector containing the +! initial guess and final solution X. +! eps - real Input: Stopping tolerance; the iteration is +! stopped when the error estimate |err| <= eps +! desc_a - type(psb_desc_type). Input: The communication descriptor. +! info - integer. Output: Return code ! -! itmax - integer(optional) Input: maximum number of iterations to be -! performed. -! iter - integer(optional) Output: how many iterations have been -! performed. -! err - real (optional) Output: error estimate on exit -! itrace - integer(optional) Input: print an informational message -! with the error estimate every itrace -! iterations -! irst - integer(optional) Input: restart parameter -! -! istop - integer(optional) Input: stopping criterion, or how -! to estimate the error. -! 1: err = |r|/|b| -! 2: err = |r|/(|a||x|+|b|) -! where r is the (preconditioned, recursive -! estimate of) residual +! itmax - integer(optional) Input: maximum number of iterations to be +! performed. +! iter - integer(optional) Output: how many iterations have been +! performed. +! err - real (optional) Output: error estimate on exit +! itrace - integer(optional) Input: print an informational message +! with the error estimate every itrace +! iterations +! irst - integer(optional) Input: restart parameter +! +! istop - integer(optional) Input: stopping criterion, or how +! to estimate the error. +! 1: err = |r|/|b| +! 2: err = |r|/(|a||x|+|b|) +! where r is the (preconditioned, recursive +! estimate of) residual ! Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,istop) use psb_base_mod @@ -132,7 +126,7 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist Logical, Parameter :: exchange=.True., noexchange=.False. Integer, Parameter :: irmax = 8 Integer :: itx, i, isvch, ictxt,istop_, err_act - Logical, Parameter :: debug = .false. + integer :: debug_level, debug_unit Real(Kind(1.d0)) :: rni, xni, bni, ani,bn2 real(kind(1.d0)), external :: dznrm2 character(len=20) :: name @@ -140,12 +134,13 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist info = 0 name = 'psb_zgmres' call psb_erractionsave(err_act) + debug_unit = psb_get_debug_unit() + debug_level = psb_get_debug_level() - If (debug) Write(0,*) 'entering psb_zgmres' ictxt = psb_cd_get_context(desc_a) Call psb_info(ictxt, me, np) - - If (debug) Write(0,*) 'psb_dgmres: from gridinfo',np,me + if (debug_level >= psb_debug_ext_)& + & write(debug_unit,*) me,' ',trim(name),': from psb_info',np mglob = psb_cd_get_global_rows(desc_a) n_row = psb_cd_get_local_rows(desc_a) @@ -162,7 +157,6 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! if ((istop_ < 1 ).or.(istop_ > 2 ) ) then - write(0,*) 'psb_dgmres: invalid istop',istop_ info=5001 int_err(1)=istop_ err=info @@ -184,13 +178,16 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist If (Present(irst)) Then nl = irst - If (debug) Write(0,*) 'present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' present: irst: ',irst,nl Else nl = 10 - If (debug) Write(0,*) 'not present: irst: ',irst,nl + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' not present: irst: ',irst,nl Endif if (nl <=0 ) then - write(0,*) 'psb_dgmres: invalid irst ',nl info=5001 int_err(1)=nl err=info @@ -229,8 +226,10 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist call psb_errpush(info,name) goto 9999 End If - if (debug) write(0,*) 'Size of V,W,W1 ',size(v),size(v,1),& - &size(w),size(w,1),size(w1),size(w1,1), size(v(:,1)) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Size of V,W,W1 ',size(v),size(v,1),& + & size(w),size(w,1),size(w1),size(w1,1), size(v(:,1)) ! Ensure global coherence for convergence checks. call psb_set_coher(ictxt,isvch) @@ -254,7 +253,9 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! check convergence ! compute v1 = r0/||r0||_2 - If (debug) Write(0,*) 'restart: ',itx,it + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' restart: ',itx,it it = 0 Call psb_geaxpby(zone,b,zzero,v(:,1),desc_a,info) if (info.ne.0) Then @@ -279,7 +280,9 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist End If scal=done/rs(1) ! rs(1) MIGHT BE VERY SMALL - USE DSCAL TO DEAL WITH IT? - If (debug) Write(0,*) 'on entry to amax: b: ',Size(b),rs(1),scal + If (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' on entry to amax: b: ',Size(b),rs(1),scal ! ! check convergence @@ -348,7 +351,9 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist rst = rs xt = zzero call ztrsm('l','u','n','n',i,1,zone,h,size(h,1),rst,size(rst,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rst(1:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rst(1:nl) do k=1, i call psb_geaxpby(rst(k),v(:,k),zone,xt,desc_a,info) end do @@ -380,7 +385,9 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! build x ! call ztrsm('l','u','n','n',i,1,zone,h,size(h,1),rs,size(rs,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rs(21:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rs(1:nl) w1 = zzero do k=1, i call psb_geaxpby(rs(k),v(:,k),zone,w1,desc_a,info) @@ -407,7 +414,9 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist ! build x ! call ztrsm('l','u','n','n',nl,1,zone,h,size(h,1),rs,size(rs,1)) - if (debug) write(0,*) 'Rebuild x-> RS:',rs(21:nl) + if (debug_level >= psb_debug_ext_) & + & write(debug_unit,*) me,' ',trim(name),& + & ' Rebuild x-> RS:',rs(1:nl) w1 = zzero do k=1, nl call psb_geaxpby(rs(k),v(:,k),zone,w1,desc_a,info) @@ -424,7 +433,7 @@ Subroutine psb_zgmresr(a,prec,b,x,eps,desc_a,info,itmax,iter,err,itrace,irst,ist If (Present(err)) err=rerr If (Present(iter)) iter = itx If ((rerr>eps).and. (me == 0)) Then - Write(0,*) 'gmresr(l) failed to converge to ',eps,& + write(debug_unit,*) 'gmresr(l) failed to converge to ',eps,& & ' in ',itx,' iterations ' End If diff --git a/prec/psb_dbjac_aply.f90 b/prec/psb_dbjac_aply.f90 index 023c5fa5..a7c63b68 100644 --- a/prec/psb_dbjac_aply.f90 +++ b/prec/psb_dbjac_aply.f90 @@ -53,7 +53,7 @@ subroutine psb_dbjac_aply(alpha,prec,x,beta,y,desc_data,trans,work,info) integer :: n_row,n_col real(kind(1.d0)), pointer :: ww(:), aux(:) integer :: ictxt,np,me, err_act, int_err(5) - logical,parameter :: debug=.false., debugprt=.false. + logical,parameter :: debug=.false., debugprt=.false. character(len=20) :: name, ch_err name='psb_bjac_aply' diff --git a/prec/psb_ddiagsc_bld.f90 b/prec/psb_ddiagsc_bld.f90 index 8a46c65b..a5b8337d 100644 --- a/prec/psb_ddiagsc_bld.f90 +++ b/prec/psb_ddiagsc_bld.f90 @@ -44,7 +44,6 @@ subroutine psb_ddiagsc_bld(a,desc_a,p,upd,info) ! Local scalars Integer :: err, n_row, n_col,I,ictxt,& & me,np,mglob, err_act - real(kind(1.d0)),allocatable :: gd(:), work(:) integer :: int_err(5) logical, parameter :: debug=.false. @@ -77,13 +76,19 @@ subroutine psb_ddiagsc_bld(a,desc_a,p,upd,info) goto 9999 end if - call psb_csrws(p%d,a,info,trans='N') + ! + ! Retrieve the diagonal entries of the matrix A + ! + call psb_sp_getdiag(a,p%d,info) if(info /= 0) then info=4010 - ch_err='psb_csrws' + ch_err='psb_sp_getdiag' call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + ! + ! Copy into p%desc_data the descriptor associated to A + ! call psb_cdcpy(desc_a,p%desc_Data,info) if (info /= 0) then call psb_errpush(4010,name,a_err='psb_cdcpy') @@ -91,25 +96,25 @@ subroutine psb_ddiagsc_bld(a,desc_a,p,upd,info) end if if (debug) write(ilout+me,*) 'VDIAG ',n_row + ! + ! The i-th diagonal entry of the preconditioner is set to one if the + ! corresponding entry a_ii of the sparse matrix A is zero; otherwise + ! it is set to one/a_ii + ! do i=1,n_row - if (p%d(i).eq.dzero) then + if (p%d(i) == dzero) then p%d(i) = done else p%d(i) = done/p%d(i) endif if (debug) write(ilout+me,*) i,desc_a%loc_to_glob(i), p%d(i) - if (p%d(i).lt.0.d0) then - write(0,*) me,'Negative RWS? ',i,p%d(i) - endif end do + if (a%pl(1) /= 0) then - allocate(work(n_row),stat=info) - if (info /= 0) then - info=4000 - call psb_errpush(info,name) - goto 9999 - end if + ! + ! Apply the same row permutation as in the sparse matrix A + ! call psb_gelp('n',a%pl,p%d,info) if(info /= 0) then info=4010 @@ -117,33 +122,8 @@ subroutine psb_ddiagsc_bld(a,desc_a,p,upd,info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if - - deallocate(work) endif - if (debug) then - allocate(gd(mglob),stat=info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='Allocate') - goto 9999 - end if - - call psb_gather(gd, p%d, desc_a, info, root=iroot) - if(info /= 0) then - info=4010 - ch_err='psb_dgatherm' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (me.eq.iroot) then - write(iout+np,*) 'VDIAG CHECK ',mglob - do i=1,mglob - write(iout+np,*) i,gd(i) - enddo - endif - deallocate(gd) - endif if (debug) write(*,*) 'Preconditioner DIAG computed OK' diff --git a/prec/psb_zdiagsc_bld.f90 b/prec/psb_zdiagsc_bld.f90 index 0e5b7784..71e0d46e 100644 --- a/prec/psb_zdiagsc_bld.f90 +++ b/prec/psb_zdiagsc_bld.f90 @@ -44,7 +44,6 @@ subroutine psb_zdiagsc_bld(a,desc_a,p,upd,info) ! Local scalars Integer :: err, n_row, n_col,I,ictxt,& & me,np,mglob,err_act - complex(kind(1.d0)),pointer :: gd(:), work(:) integer :: int_err(5) logical, parameter :: debug=.false. @@ -77,15 +76,31 @@ subroutine psb_zdiagsc_bld(a,desc_a,p,upd,info) goto 9999 end if - call psb_csrws(p%d,a,info,trans='N') + ! + ! Retrieve the diagonal entries of the matrix A + ! + call psb_sp_getdiag(a,p%d,info) if(info /= 0) then info=4010 - ch_err='psb_csrws' + ch_err='psb_sp_getdiag' call psb_errpush(info,name,a_err=ch_err) goto 9999 end if + ! + ! Copy into p%desc_data the descriptor associated to A + ! + call psb_cdcpy(desc_a,p%desc_Data,info) + if (info /= 0) then + call psb_errpush(4010,name,a_err='psb_cdcpy') + goto 9999 + end if if (debug) write(ilout+me,*) 'VDIAG ',n_row + ! + ! The i-th diagonal entry of the preconditioner is set to one if the + ! corresponding entry a_ii of the sparse matrix A is zero; otherwise + ! it is set to one/a_ii + ! do i=1,n_row if (p%d(i) == zzero) then p%d(i) = zone @@ -94,17 +109,12 @@ subroutine psb_zdiagsc_bld(a,desc_a,p,upd,info) endif if (debug) write(ilout+me,*) i,desc_a%loc_to_glob(i), p%d(i) -!!$ if (p%d(i).lt.0.d0) then -!!$ write(0,*) me,'Negative RWS? ',i,p%d(i) -!!$ endif end do + if (a%pl(1) /= 0) then - allocate(work(n_row),stat=info) - if (info /= 0) then - info=4000 - call psb_errpush(info,name) - goto 9999 - end if + ! + ! Apply the same row permutation as in the sparse matrix A + ! call psb_gelp('n',a%pl,p%d,info) if(info /= 0) then info=4010 @@ -112,33 +122,8 @@ subroutine psb_zdiagsc_bld(a,desc_a,p,upd,info) call psb_errpush(info,name,a_err=ch_err) goto 9999 end if - - deallocate(work) endif - if (debug) then - allocate(gd(mglob),stat=info) - if (info /= 0) then - call psb_errpush(4010,name,a_err='Allocate') - goto 9999 - end if - - call psb_gather(gd, p%d, desc_a, info, root=iroot) - if(info /= 0) then - info=4010 - ch_err='psb_zgatherm' - call psb_errpush(info,name,a_err=ch_err) - goto 9999 - end if - - if (me.eq.iroot) then - write(iout+np,*) 'VDIAG CHECK ',mglob - do i=1,mglob - write(iout+np,*) i,gd(i) - enddo - endif - deallocate(gd) - endif if (debug) write(*,*) 'Preconditioner DIAG computed OK' diff --git a/test/pargen/runs/ppde.inp b/test/pargen/runs/ppde.inp index 44815ec2..cdbab3ef 100644 --- a/test/pargen/runs/ppde.inp +++ b/test/pargen/runs/ppde.inp @@ -5,7 +5,7 @@ CSR Storage format for matrix A: CSR COO JAD 60 Domain size (acutal system is this**3) 1 Stopping criterion 80 MAXIT -01 ITRACE +-1 ITRACE 20 IRST restart for RGMRES and BiCGSTABL diff --git a/util/psb_hbio_mod.f90 b/util/psb_hbio_mod.f90 index 1d258d45..b693a92e 100644 --- a/util/psb_hbio_mod.f90 +++ b/util/psb_hbio_mod.f90 @@ -58,7 +58,6 @@ contains character(len=*), parameter :: fmt10='(a72,a8,/,5i14,/,a3,11x,4i14,/,2a16,2a20)' character(len=*), parameter :: fmt11='(a1,13x,2i14)' character(len=*), parameter :: fmt111='(1x,a8,1x,i8,1x,a10)' - logical, parameter :: debug=.false. iret = 0 @@ -307,7 +306,6 @@ contains character(len=*), parameter :: fmt10='(a72,a8,/,5i14,/,a3,11x,4i14,/,2a16,2a20)' character(len=*), parameter :: fmt11='(a1,13x,2i14)' character(len=*), parameter :: fmt111='(1x,a8,1x,i8,1x,a10)' - logical, parameter :: debug=.false. iret = 0 diff --git a/util/psb_mmio_mod.f90 b/util/psb_mmio_mod.f90 index 73c5612d..9ebca2fd 100644 --- a/util/psb_mmio_mod.f90 +++ b/util/psb_mmio_mod.f90 @@ -51,7 +51,6 @@ contains character(1024) :: line integer :: nrow, ncol, nnzero integer :: ircode, i,nzr,infile - logical, parameter :: debug=.false. iret = 0 @@ -81,15 +80,12 @@ contains iret=909 return end if - if (debug) write(*,*) mmheader,':', object, ':',fmt,':', type,':', sym do read(infile,fmt='(a)') line if (line(1:1) /= '%') exit end do - if (debug) write(*,*) 'Line on input : "',line,'"' read(line,fmt=*) nrow,ncol,nnzero - if (debug) write(*,*) 'Out: ',nrow,ncol,nnzero if ((tolower(type) == 'real').and.(tolower(sym) == 'general')) then call psb_sp_all(nrow,ncol,a,nnzero,ircode) @@ -207,8 +203,6 @@ contains integer :: nrow, ncol, nnzero integer :: ircode, i,nzr,infile real(kind(1.d0)) :: are, aim - logical, parameter :: debug=.false. - iret = 0 @@ -238,15 +232,12 @@ contains iret=909 return end if - if (debug) write(*,*) mmheader,':', object, ':',fmt,':', type,':', sym do read(infile,fmt='(a)') line if (line(1:1) /= '%') exit end do - if (debug) write(*,*) 'Line on input : "',line,'"' read(line,fmt=*) nrow,ncol,nnzero - if (debug) write(*,*) 'Out: ',nrow,ncol,nnzero if ((tolower(type) == 'complex').and.(tolower(sym) == 'general')) then call psb_sp_all(nrow,ncol,a,nnzero,ircode)