Commit afa79361 authored by MARAIT Gilles's avatar MARAIT Gilles

Add option to keep convergence history in a seperate file for each solve

parent e46718fc
......@@ -446,6 +446,18 @@ this control is a entry of \textbf{mphs\%ICNTL}; and when an execution control s
\item Default = 10
\end{itemize}
\item [ICNTL(34)] Controls if the convergence history of the iterative solver is written in a file or
treated as regular output.
\iftoggle{devversion}{
\textcolor{red}{\*\emph{Enumeration: ICNTL\_ITS\_Output}}
}{}
\begin{itemize}
\item 0 = Convergence history is treated as regular output.
\item 1 = Convergence history is written in a file: for the $N^{th}$ call the the iterative solver,
the file is called \textit{gmres\_cvg\_N.dat} or \textit{cg\_cvg\_N.dat}.
\item Default = 0
\end{itemize}
\item [ICNTL(36)\label{itm:icntl36}] Is the control paramater that specify how to bind thread inside \maphys{}.
\iftoggle{devversion}{
\textcolor{red}{
......
......@@ -180,7 +180,8 @@ Module MPH_maphys_enum
Integer, Parameter :: ICNTL_ITS_ResStrategy = 25
Integer, Parameter :: ICNTL_ITS_Restart = 26
Integer, Parameter :: ICNTL_ITS_MatVect = 27
integer, parameter :: ICNTL_ITS_ResNorm = 28
Integer, Parameter :: ICNTL_ITS_ResNorm = 28
Integer, parameter :: ICNTL_ITS_Output = 34
! Ikeep
Integer, Parameter :: IKEEP_ITS_Solver = 20
Integer, Parameter :: IKEEP_ITS_OrtStrategy = 22
......@@ -189,8 +190,9 @@ Module MPH_maphys_enum
Integer, Parameter :: IKEEP_ITS_ResStrategy = 25
Integer, Parameter :: IKEEP_ITS_Restart = 26
Integer, Parameter :: IKEEP_ITS_MatVect = 27
integer, parameter :: IKEEP_ITS_ResNorm = 28
Integer, Parameter :: IKEEP_ITS_ResNorm = 28
Integer, Parameter :: IKEEP_ITS_Output = 34
! Rcntl
Integer, Parameter :: RCNTL_ITS_Tolerance = 21
......
......@@ -501,7 +501,7 @@ Contains
ikeep(IKEEP_ITS_ResNorm) == 2)) then
ikeep(IKEEP_ITS_ResNorm) = 1
end if
! nothing specific here
Call set_iteOutput
End Subroutine set_packcg
!****
Subroutine set_packgmres
......@@ -517,6 +517,7 @@ Contains
ikeep(IKEEP_ITS_ResNorm) = 1
end if
Call set_itsRestart
Call set_iteOutput
End Subroutine set_packgmres
!****
Subroutine set_itsrestart
......@@ -536,6 +537,11 @@ Contains
"Iterative solver -> Restart every X iterations unset. Take :")
End If
End Subroutine set_itsrestart
!****
Subroutine set_iteoutput
Call set_enum(IKEEP_ITS_Output, ICNTL_ITS_Output,0,1)
end Subroutine set_iteoutput
End Subroutine mph_strat_set
......
......@@ -454,7 +454,7 @@ Subroutine XMPH_maphys_Free & ! intents
Call XMPH_SLS_Free( mphs%sls_secondprecond_schur , iinfo )
End Select
!------------------------------------------------------------------
! [-] Finish
!------------------------------------------------------------------
......@@ -548,6 +548,7 @@ End Subroutine XMPH_maphys_free
icntl( ICNTL_ITS_Restart ) = 0
icntl( ICNTL_ITS_ResNorm ) = 1
icntl( ICNTL_ITS_MatVect ) = 0
icntl( ICNTL_ITS_Output ) = 0
! Schur Complement
icntl( ICNTL_SCHUR_Strategy ) = 0
......
......@@ -25,6 +25,8 @@ Module XMPH_schur_mod
Public :: XMPH_SCHUR_GMRES_solve
Public :: XMPH_SCHUR_CG_solve
Public :: XMPH_SCHUR_assemble_denseMatrix_bc
Integer, private :: solve_cnt=0 ! Number of solve performed
Contains
......@@ -735,6 +737,10 @@ Contains
Type(XMPH_dense_matrix_t) :: y
Type(XMPH_dense_matrix_t) :: z
! Output
Integer :: outfile
Character(len=10) :: buf
!- End of header -------------------------------------------------
!-----------------------------------------------------------------
......@@ -780,18 +786,33 @@ Contains
gmrcntl(5) = rhs_norm2
end if
! Set output
! Outputs
Call mph_log_GetVerbosity(verb)
If ( (verb >= MSG_STD).and.(rank == master) )Then
! print warning messages
Call mph_log_GetUnit(MSG_WARNING, gmicntl(2))
! print convergence history to stdout
Call mph_log_GetUnit(MSG_STD , gmicntl(3))
End If
If (rank == master) Then
! Warning messages
If (verb >= MSG_STD) Then
Call mph_log_GetUnit(MSG_WARNING, gmicntl(2))
If (mphs%ikeep(IKEEP_ITS_Output) == 0) Then
! print convergence history to stdout
Call mph_log_GetUnit(MSG_STD , gmicntl(3))
End If
End If
If (mphs%ikeep(IKEEP_ITS_Output) == 1) Then
! write convergence history in an output file
outfile = 101
solve_cnt = solve_cnt + 1
write(buf, '(I10)') solve_cnt
open(unit=outfile, file="gmres_cvg_"//trim(adjustl(buf))//".dat", action="write")
gmicntl(3) = outfile
End If
End If
! Force right preconditioning we use a preconditioner
If ( mphs%ikeep(IKEEP_Pcd_Strategy ) == PCD_STRATEGY_isNone ) &
gmicntl(4) = 0
......@@ -934,9 +955,13 @@ Contains
Case (4); Call XMPH_SCHUR_VectorScalarProduct(mphs, x, y, z, info)
Case Default; CHCKASSRT(.False., info ) ! Undocumented revcom
End Select
End Do
If (rank == master .and. mphs%ikeep(IKEEP_ITS_Output) /= 0) Then
Close(outfile)
End If
!---------------------------------------------------------------------------
! [-] Checking the outputs
!---------------------------------------------------------------------------
......@@ -1112,6 +1137,10 @@ Contains
Type(XMPH_dense_matrix_t) :: x
Type(XMPH_dense_matrix_t) :: y
Type(XMPH_dense_matrix_t) :: z
! Output
Integer :: outfile
Character(len=10) :: buf
!- End of header -------------------------------------------------
......@@ -1161,18 +1190,33 @@ Contains
cgrcntl(3) = rhs_norm2
end if
! Set output
Call mph_log_GetVerbosity(verb)
If ( (verb >= MSG_STD).and.(rank == master) )Then
! print warning messages
Call mph_log_GetUnit(MSG_WARNING, cgicntl(2))
! print convergence history to stdout
Call mph_log_GetUnit(MSG_STD , cgicntl(3))
End If
If (rank == master) Then
! Warning messages
If (verb >= MSG_STD) Then
Call mph_log_GetUnit(MSG_WARNING, cgicntl(2))
If (mphs%ikeep(IKEEP_ITS_Output) == 0) Then
! print convergence history to stdout
Call mph_log_GetUnit(MSG_STD , cgicntl(3))
End If
End If
If (mphs%ikeep(IKEEP_ITS_Output) == 1) Then
! write convergence history in an output file
outfile = 101
solve_cnt = solve_cnt + 1
write(buf, '(I10)') solve_cnt
open(unit=outfile, file="cg_cvg_"//trim(adjustl(buf))//".dat", action="write")
cgicntl(3) = outfile
End If
End If
! Create solution if no init guess
If (HasInitGuess .eqv. .False.) Then
......@@ -1299,7 +1343,11 @@ Contains
End Select
End Do
If (rank == master .and. mphs%ikeep(IKEEP_ITS_Output) /= 0) Then
Close(outfile)
End If
!---------------------------------------------------------------------------
! [-] Checking the outputs
!---------------------------------------------------------------------------
......@@ -1309,7 +1357,7 @@ Contains
!-----------------------------------------------
Select Case (revcom)
Case (0); Continue ! Gmres exited correctly
Case (0); Continue ! Cg exited correctly
Case (1); Call MPH_Log(MSG_ERROR,"Error occured in matrix/vector Product")
Case (2); Call MPH_Log(MSG_ERROR,"Error occured in preconditioning")
Case (3); Call MPH_Log(MSG_ERROR,"Error occured in scalar product")
......@@ -1319,7 +1367,7 @@ Contains
MPH_ONFAILURE_GOTO9999(info)
!----------------------------------------------------
! [--] Checking gmiinfo(1), the return status of PackGMRES
! [--] Checking cgiinfo(1), the return status of PackCG
!----------------------------------------------------
Select Case (cgiinfo(1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment