6 |
#define VERBOSE |
#define VERBOSE |
7 |
|
|
8 |
SUBROUTINE CG3D( |
SUBROUTINE CG3D( |
9 |
|
I cg3d_b, |
10 |
|
U cg3d_x, |
11 |
|
O firstResidual, |
12 |
|
O lastResidual, |
13 |
|
U numIters, |
14 |
I myThid ) |
I myThid ) |
15 |
C /==========================================================\ |
C /==========================================================\ |
16 |
C | SUBROUTINE CG3D | |
C | SUBROUTINE CG3D | |
44 |
#include "CG3D.h" |
#include "CG3D.h" |
45 |
|
|
46 |
C === Routine arguments === |
C === Routine arguments === |
47 |
C myThid - Thread on which I am working. |
C myThid - Thread on which I am working. |
48 |
|
C cg2d_b - The source term or "right hand side" |
49 |
|
C cg2d_x - The solution |
50 |
|
C firstResidual - the initial residual before any iterations |
51 |
|
C lastResidual - the actual residual reached |
52 |
|
C numIters - Entry: the maximum number of iterations allowed |
53 |
|
C Exit: the actual number of iterations used |
54 |
|
_RL cg3d_b(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
55 |
|
_RL cg3d_x(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
56 |
|
_RL firstResidual |
57 |
|
_RL lastResidual |
58 |
|
INTEGER numIters |
59 |
INTEGER myThid |
INTEGER myThid |
60 |
|
|
61 |
|
|
62 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
63 |
|
|
64 |
C === Local variables ==== |
C === Local variables ==== |
204 |
_GLOBAL_SUM_R8( err , myThid ) |
_GLOBAL_SUM_R8( err , myThid ) |
205 |
|
|
206 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
207 |
write(*,'(A,1PE30.14)') ' cg3d: Sum(rhs) = ',sumRHS |
write(*,'(A,1P2E22.14)') |
208 |
|
& ' cg3d: Sum(rhs),rhsMax = ',sumRHS,rhsMax |
209 |
_END_MASTER( ) |
_END_MASTER( ) |
210 |
|
|
211 |
actualIts = 0 |
actualIts = 0 |
212 |
actualResidual = SQRT(err) |
actualResidual = SQRT(err) |
213 |
C _BARRIER |
C _BARRIER |
214 |
_BEGIN_MASTER( myThid ) |
c _BEGIN_MASTER( myThid ) |
215 |
WRITE(*,'(A,I6,1PE30.14)') ' CG3D iters, err = ', |
c WRITE(*,'(A,I6,1PE30.14)') ' CG3D iters, err = ', |
216 |
& actualIts, actualResidual |
c & actualIts, actualResidual |
217 |
_END_MASTER( ) |
c _END_MASTER( ) |
218 |
|
firstResidual=actualResidual |
219 |
|
|
220 |
C >>>>>>>>>>>>>>> BEGIN SOLVER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
C >>>>>>>>>>>>>>> BEGIN SOLVER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
221 |
DO 10 it3d=1, cg3dMaxIters |
DO 10 it3d=1, cg3dMaxIters |
222 |
|
|
223 |
CcnhDebugStarts |
CcnhDebugStarts |
224 |
#ifdef VERBOSE |
#ifdef VERBOSE |
225 |
IF ( mod(it3d-1,10).EQ.0) |
c IF ( mod(it3d-1,10).EQ.0) |
226 |
& WRITE(*,*) ' CG3D: Iteration ',it3d-1, |
c & WRITE(*,*) ' CG3D: Iteration ',it3d-1, |
227 |
& ' residual = ',actualResidual |
c & ' residual = ',actualResidual |
228 |
#endif |
#endif |
229 |
CcnhDebugEnds |
CcnhDebugEnds |
230 |
IF ( actualResidual .LT. cg3dTargetResidual ) GOTO 11 |
IF ( actualResidual .LT. cg3dTargetResidual ) GOTO 11 |
478 |
ENDDO |
ENDDO |
479 |
|
|
480 |
Cadj _EXCH_XYZ_R8(cg3d_x, myThid ) |
Cadj _EXCH_XYZ_R8(cg3d_x, myThid ) |
481 |
_BEGIN_MASTER( myThid ) |
c _BEGIN_MASTER( myThid ) |
482 |
WRITE(*,'(A,I6,1PE30.14)') ' CG3D iters, err = ', |
c WRITE(*,'(A,I6,1PE30.14)') ' CG3D iters, err = ', |
483 |
& actualIts, actualResidual |
c & actualIts, actualResidual |
484 |
_END_MASTER( ) |
c _END_MASTER( ) |
485 |
|
lastResidual=actualResidual |
486 |
|
numIters=actualIts |
487 |
|
|
488 |
#endif /* ALLOW_NONHYDROSTATIC */ |
#endif /* ALLOW_NONHYDROSTATIC */ |
489 |
|
|