Added psb_c_@X@global_vec_write

remotebuild
Cirdans-Home 3 years ago
parent 1369294635
commit 4b559c6a4b

@ -9,6 +9,7 @@ extern "C" {
/* I/O Routine */ /* I/O Routine */
psb_i_t psb_c_cmm_mat_write(psb_c_cspmat *ah, char *matrixtitle, char *filename); psb_i_t psb_c_cmm_mat_write(psb_c_cspmat *ah, char *matrixtitle, char *filename);
psb_i_t psb_c_cglobal_mat_write(psb_c_cspmat *ah,psb_c_descriptor *cdh); psb_i_t psb_c_cglobal_mat_write(psb_c_cspmat *ah,psb_c_descriptor *cdh);
psb_i_t psb_c_cglobal_vec_write(psb_c_cvector *vh,psb_c_descriptor *cdh);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -9,6 +9,7 @@ extern "C" {
/* I/O Routine */ /* I/O Routine */
psb_i_t psb_c_dmm_mat_write(psb_c_dspmat *ah, char *matrixtitle, char *filename); psb_i_t psb_c_dmm_mat_write(psb_c_dspmat *ah, char *matrixtitle, char *filename);
psb_i_t psb_c_dglobal_mat_write(psb_c_dspmat *ah,psb_c_descriptor *cdh); psb_i_t psb_c_dglobal_mat_write(psb_c_dspmat *ah,psb_c_descriptor *cdh);
psb_i_t psb_c_dglobal_vec_write(psb_c_dvector *vh,psb_c_descriptor *cdh);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -9,6 +9,7 @@ extern "C" {
/* I/O Routine */ /* I/O Routine */
psb_i_t psb_c_smm_mat_write(psb_c_sspmat *ah, char *matrixtitle, char *filename); psb_i_t psb_c_smm_mat_write(psb_c_sspmat *ah, char *matrixtitle, char *filename);
psb_i_t psb_c_sglobal_mat_write(psb_c_sspmat *ah,psb_c_descriptor *cdh); psb_i_t psb_c_sglobal_mat_write(psb_c_sspmat *ah,psb_c_descriptor *cdh);
psb_i_t psb_c_sglobal_vec_write(psb_c_svector *vh,psb_c_descriptor *cdh);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -84,5 +84,48 @@ contains
end function psb_c_cglobal_mat_write end function psb_c_cglobal_mat_write
function psb_c_cglobal_vec_write(vh,cdh) bind(c) result(res)
use psb_base_mod
use psb_util_mod
use psb_base_string_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_cvector) :: vh
type(psb_c_descriptor) :: cdh
type(psb_c_vect_type), pointer :: vp
type(psb_desc_type), pointer :: descp
! Local variables
complex(psb_spk_), allocatable :: vglobal(:)
integer(psb_ipk_) :: info, iam, np
type(psb_ctxt_type) :: ctxt
character(len=40) :: vecname
res = -1
if (c_associated(cdh%item)) then
call c_f_pointer(cdh%item,descp)
else
return
end if
if (c_associated(vh%item)) then
call c_f_pointer(vh%item,vp)
else
return
end if
ctxt = descp%get_ctxt()
call psb_info(ctxt,iam,np)
call psb_gather(vglobal,vp,descp,info)
if (iam == psb_root_) then
write(vecname,'("v-np-",I1,".mtx")') np
call mm_array_write(vglobal,"Global vector",info,filename=trim(vecname))
end if
deallocate(vglobal,stat=info)
res = info
end function psb_c_cglobal_vec_write
end module psb_cutil_cbind_mod end module psb_cutil_cbind_mod

@ -9,6 +9,7 @@ extern "C" {
/* I/O Routine */ /* I/O Routine */
psb_i_t psb_c_zmm_mat_write(psb_c_zspmat *ah, char *matrixtitle, char *filename); psb_i_t psb_c_zmm_mat_write(psb_c_zspmat *ah, char *matrixtitle, char *filename);
psb_i_t psb_c_zglobal_mat_write(psb_c_zspmat *ah,psb_c_descriptor *cdh); psb_i_t psb_c_zglobal_mat_write(psb_c_zspmat *ah,psb_c_descriptor *cdh);
psb_i_t psb_c_zglobal_vec_write(psb_c_zvector *vh,psb_c_descriptor *cdh);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -84,5 +84,48 @@ contains
end function psb_c_dglobal_mat_write end function psb_c_dglobal_mat_write
function psb_c_dglobal_vec_write(vh,cdh) bind(c) result(res)
use psb_base_mod
use psb_util_mod
use psb_base_string_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_dvector) :: vh
type(psb_c_descriptor) :: cdh
type(psb_d_vect_type), pointer :: vp
type(psb_desc_type), pointer :: descp
! Local variables
real(psb_dpk_), allocatable :: vglobal(:)
integer(psb_ipk_) :: info, iam, np
type(psb_ctxt_type) :: ctxt
character(len=40) :: vecname
res = -1
if (c_associated(cdh%item)) then
call c_f_pointer(cdh%item,descp)
else
return
end if
if (c_associated(vh%item)) then
call c_f_pointer(vh%item,vp)
else
return
end if
ctxt = descp%get_ctxt()
call psb_info(ctxt,iam,np)
call psb_gather(vglobal,vp,descp,info)
if (iam == psb_root_) then
write(vecname,'("v-np-",I1,".mtx")') np
call mm_array_write(vglobal,"Global vector",info,filename=trim(vecname))
end if
deallocate(vglobal,stat=info)
res = info
end function psb_c_dglobal_vec_write
end module psb_dutil_cbind_mod end module psb_dutil_cbind_mod

@ -84,5 +84,48 @@ contains
end function psb_c_sglobal_mat_write end function psb_c_sglobal_mat_write
function psb_c_sglobal_vec_write(vh,cdh) bind(c) result(res)
use psb_base_mod
use psb_util_mod
use psb_base_string_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_svector) :: vh
type(psb_c_descriptor) :: cdh
type(psb_s_vect_type), pointer :: vp
type(psb_desc_type), pointer :: descp
! Local variables
real(psb_spk_), allocatable :: vglobal(:)
integer(psb_ipk_) :: info, iam, np
type(psb_ctxt_type) :: ctxt
character(len=40) :: vecname
res = -1
if (c_associated(cdh%item)) then
call c_f_pointer(cdh%item,descp)
else
return
end if
if (c_associated(vh%item)) then
call c_f_pointer(vh%item,vp)
else
return
end if
ctxt = descp%get_ctxt()
call psb_info(ctxt,iam,np)
call psb_gather(vglobal,vp,descp,info)
if (iam == psb_root_) then
write(vecname,'("v-np-",I1,".mtx")') np
call mm_array_write(vglobal,"Global vector",info,filename=trim(vecname))
end if
deallocate(vglobal,stat=info)
res = info
end function psb_c_sglobal_vec_write
end module psb_sutil_cbind_mod end module psb_sutil_cbind_mod

@ -84,5 +84,48 @@ contains
end function psb_c_zglobal_mat_write end function psb_c_zglobal_mat_write
function psb_c_zglobal_vec_write(vh,cdh) bind(c) result(res)
use psb_base_mod
use psb_util_mod
use psb_base_string_cbind_mod
implicit none
integer(psb_c_ipk_) :: res
type(psb_c_zvector) :: vh
type(psb_c_descriptor) :: cdh
type(psb_z_vect_type), pointer :: vp
type(psb_desc_type), pointer :: descp
! Local variables
complex(psb_dpk_), allocatable :: vglobal(:)
integer(psb_ipk_) :: info, iam, np
type(psb_ctxt_type) :: ctxt
character(len=40) :: vecname
res = -1
if (c_associated(cdh%item)) then
call c_f_pointer(cdh%item,descp)
else
return
end if
if (c_associated(vh%item)) then
call c_f_pointer(vh%item,vp)
else
return
end if
ctxt = descp%get_ctxt()
call psb_info(ctxt,iam,np)
call psb_gather(vglobal,vp,descp,info)
if (iam == psb_root_) then
write(vecname,'("v-np-",I1,".mtx")') np
call mm_array_write(vglobal,"Global vector",info,filename=trim(vecname))
end if
deallocate(vglobal,stat=info)
res = info
end function psb_c_zglobal_vec_write
end module psb_zutil_cbind_mod end module psb_zutil_cbind_mod

File diff suppressed because one or more lines are too long

@ -291,7 +291,53 @@ Type: {\bf required} \\
An integer value; 0 means no error has been detected. An integer value; 0 means no error has been detected.
\end{description} \end{description}
{\par\noindent\large\bfseries Notes}
If this function is called on a vector \lstinline|v| on a distributed communicator
only the local part is written in output. To get a single MatrixMarket file with
the whole vector when appropriate, e.g. for debugging purposes, one could \emph{gather}
the whole vector on a single rank and then write it. Consider the following example
for a \emph{double} precision vector
\ifpdf
\begin{minted}[breaklines=true,bgcolor=bg,fontsize=\small]{fortran}
real(psb_dpk_), allocatable :: vglobal(:)
call psb_gather(vglobal,v,desc,info)
if (iam == psb_root_) then
call mm_array_write(vglobal,vtitle,info,filename)
end if
call deallocate(vglobal, stat=info)
\end{minted}
\else
\begin{center}
\begin{minipage}[tl]{0.9\textwidth}
\begin{verbatim}
real(psb_dpk_), allocatable :: vglobal(:)
call psb_gather(vglobal,v,desc,info)
if (iam == psb_root_) then
call mm_array_write(vglobal,vtitle,info,filename)
end if
call deallocate(vglobal, stat=info)
\end{verbatim}
\end{minipage}
\end{center}
\fi
To simplify this procedure in \verb|C|, there is a utility function
\ifpdf
\begin{minted}[breaklines=true,bgcolor=bg,fontsize=\small]{c}
psb_i_t psb_c_<s,d,c,z>global_vec_write(vh,cdh);
\end{minted}
\else
\begin{center}
\begin{minipage}[tl]{0.9\textwidth}
\begin{verbatim}
psb_i_t psb_c_<s,d,c,z>global_vec_write(vh,cdh);
\end{verbatim}
\end{minipage}
\end{center}
\fi
that produces exactly this result.
%%% Local Variables: %%% Local Variables:
%%% mode: latex %%% mode: latex

Loading…
Cancel
Save