/[MITgcm]/MITgcm_contrib/mlosch/cg2d_sr_bench/code/the_model_main.F
ViewVC logotype

Annotation of /MITgcm_contrib/mlosch/cg2d_sr_bench/code/the_model_main.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Sun Nov 29 11:02:03 2009 UTC (15 years, 8 months ago) by mlosch
Branch: MAIN
CVS Tags: HEAD
add Christopher Wolfe's benchmark for his implemenation of the single reduction cg2d solver

1 mlosch 1.1 C $Header: $
2     C $Name: $
3     CBOI
4     C This is a dummy model main to initialize and invoke the cg2d routine. Most of the
5     C guts of the model have been taken out.
6     C
7     C CLW, clwolfe@ucsd.edu November 2009
8     C
9     CEOI
10    
11     #include "AD_CONFIG.h"
12     #include "PACKAGES_CONFIG.h"
13     #include "CPP_OPTIONS.h"
14    
15     CBOP
16    
17     C !ROUTINE: THE_MODEL_MAIN
18    
19     C !INTERFACE:
20     SUBROUTINE THE_MODEL_MAIN(myThid)
21     IMPLICIT NONE
22    
23     C !DESCRIPTION: \bv
24     C *==========================================================*
25     C | SUBROUTINE THE_MODEL_MAIN
26     C | o Master controlling routine for model using the MITgcm
27     C | UV parallel wrapper.
28     C *==========================================================*
29     C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel
30     C | wrapper with a single integer argument "myThid". This
31     C | variable identifies the thread number of an instance of
32     C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works
33     C | on a particular region of the models domain and
34     C | synchronises with other instances as necessary. The
35     C | routine has to "understand" the MITgcm parallel
36     C | environment and the numerical algorithm. Editing this
37     C | routine is best done with some knowledge of both aspects.
38     C | Notes
39     C | =====
40     C | This variant of THE_MODEL_MAIN has been stripped down to
41     C | call difference variants of the conjugate gradient solver
42     C | and compare results and performance
43     C *==========================================================*
44     C \ev
45    
46     C !USES:
47     C == Global variables ===
48     #include "SIZE.h"
49     #include "EEPARAMS.h"
50     #include "PARAMS.h"
51    
52     C !INPUT/OUTPUT PARAMETERS:
53     C == Routine arguments ==
54     C myThid - Thread number for this instance of the routine.
55     INTEGER myThid
56    
57     C !LOCAL VARIABLES:
58     C == Local variables ==
59     C Note: Under the multi-threaded model myCurrentIter and
60     C myCurrentTime are local variables passed around as routine
61     C arguments. Although this is fiddly it saves the need to
62     C impose additional synchronisation points when they are
63     C updated.
64     C myCurrentTime - Time counter for this thread
65     C myCurrentIter - Iteration counter for this thread
66     INTEGER myCurrentIter
67     _RL myCurrentTime
68     logical exst
69     logical lastdiva
70     _RL firstResidual1,lastResidual1
71     _RL firstResidual2,lastResidual2
72     INTEGER numIters1, numIters2
73     INTEGER ks,i,nIter
74     _RL cg2d_b(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
75     _RL cg2d_x1(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
76     _RL cg2d_x2(1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
77     _RL port_rand
78     CEOP
79     c-- set default:
80     lastdiva = .TRUE.
81    
82     #ifdef ALLOW_DEBUG
83     IF (debugMode) CALL DEBUG_ENTER('THE_MODEL_MAIN',myThid)
84     #endif
85    
86     C-- This timer encompasses the whole code
87     CALL TIMER_START('ALL [THE_MODEL_MAIN]',myThid)
88    
89     #ifdef ALLOW_DEBUG
90     IF (debugMode) CALL DEBUG_CALL('INITIALISE_FIXED',myThid)
91     #endif
92    
93     C-- Set model configuration (fixed arrays)
94     CALL TIMER_START('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
95     CALL INITIALISE_FIXED( myThid )
96     CALL TIMER_STOP ('INITIALISE_FIXED [THE_MODEL_MAIN]',myThid)
97    
98     myCurrentTime = startTime
99     myCurrentIter = nIter0
100    
101    
102     #ifdef ALLOW_DEBUG
103     IF (debugMode) CALL DEBUG_CALL('THE_MAIN_LOOP',myThid)
104     #endif
105     C-- Call time stepping loop of full model
106    
107     C firstResidual1 = port_rand(1618033.+myProcId)
108    
109     DO I=1, nTimeSteps
110     nIter = nIter0 + I
111     C-- Initialize RHS for 2DCG solver.
112     CALL INI_RHS(cg2d_b,cg2d_x1,cg2d_x2,myThid)
113    
114     firstResidual1=0.
115     lastResidual1=0.
116     firstResidual2=0.
117     lastResidual2=0.
118     numIters1=cg2dMaxIters
119     numIters2=cg2dMaxIters
120     CALL TIMER_START('CG2D [THE_MODEL_MAIN]',myThid)
121     CALL CG2D(cg2d_b,
122     & cg2d_x1,
123     & firstResidual1,
124     & lastResidual1,
125     & numIters1,
126     & myThid )
127     CALL TIMER_STOP('CG2D [THE_MODEL_MAIN]',myThid)
128    
129     _BEGIN_MASTER(myThid)
130     WRITE(*,'(1x,a,i5,2(4x,a,e15.7),(4x,a,i5))') 'CG2D: ', i,
131     & 'firstResidual =',firstResidual1,
132     & 'lastResidual =',lastResidual1,
133     & 'numIters =',numIters1
134    
135     _END_MASTER(myThid)
136    
137     CALL TIMER_START('CG2D_SR [THE_MODEL_MAIN]',myThid)
138     CALL CG2D_SR(cg2d_b,
139     & cg2d_x2,
140     & firstResidual2,
141     & lastResidual2,
142     & numIters2,
143     & myThid )
144     CALL TIMER_STOP('CG2D_SR [THE_MODEL_MAIN]',myThid)
145    
146     _BEGIN_MASTER(myThid)
147     WRITE(*,'(1x,a,i5,2(4x,a,e15.7),(4x,a,i5))') 'CG2D_SR: ', i,
148     & 'firstResidual =',firstResidual2,
149     & 'lastResidual =',lastResidual2,
150     & 'numIters =',numIters2
151     _END_MASTER(myThid)
152     ENDDO
153     CALL WRITE_REC_XY_RL('rhs',cg2d_b,1,1,myThid)
154     CALL WRITE_REC_XY_RL('soln',cg2d_x1,1,1,myThid)
155     CALL WRITE_REC_XY_RL('soln_sr',cg2d_x2,1,1,myThid)
156    
157     #ifdef ALLOW_MNC
158     IF (useMNC) THEN
159     C Close all open NetCDF files
160     _BEGIN_MASTER( mythid )
161     CALL MNC_FILE_CLOSE_ALL( myThid )
162     _END_MASTER( mythid )
163     ENDIF
164     #endif
165    
166     C-- This timer encompasses the whole code
167     CALL TIMER_STOP ('ALL [THE_MODEL_MAIN]',myThid)
168    
169     C-- Write timer statistics
170     IF ( myThid .EQ. 1 ) THEN
171     CALL TIMER_PRINTALL( myThid )
172     CALL COMM_STATS
173     ENDIF
174    
175     C-- Check threads synchronization :
176     CALL BAR_CHECK( 9, myThid )
177    
178     #ifdef ALLOW_DEBUG
179     IF (debugMode) CALL DEBUG_LEAVE('THE_MODEL_MAIN',myThid)
180     #endif
181    
182     RETURN
183     END

  ViewVC Help
Powered by ViewVC 1.1.22