1 |
ce107 |
1.2 |
C $Id: $ |
2 |
ce107 |
1.1 |
SUBROUTINE THE_MODEL_MAIN |
3 |
|
|
C /==========================================================\ |
4 |
|
|
C | SUBROUTINE THE_MODEL_MAIN | |
5 |
|
|
C | o Master controlling routine for model using the MITgcm | |
6 |
|
|
C | UV parallel wrapper. | |
7 |
|
|
C |==========================================================| |
8 |
|
|
C | THE_MODEL_MAIN is invoked by the MITgcm UV parallel | |
9 |
|
|
C | wrapper with a single integer argument "myThid". This | |
10 |
|
|
C | variable identifies the thread number of an instance of | |
11 |
|
|
C | THE_MODEL_MAIN. Each instance of THE_MODEL_MAIN works | |
12 |
|
|
C | on a particular region of the models domain and | |
13 |
|
|
C | synchronises with other instances as necessary. The | |
14 |
|
|
C | routine has to "understand" the MITgcm parallel | |
15 |
|
|
C | environment and the numerical algorithm. Editing this | |
16 |
|
|
C | routine is best done with some knowledge of both aspects.| |
17 |
|
|
C | Notes | |
18 |
|
|
C | ===== | |
19 |
|
|
C | C*P* comments indicating place holders for which code is | |
20 |
|
|
C | presently being developed. | |
21 |
|
|
C \==========================================================/ |
22 |
|
|
|
23 |
|
|
C == Global variables === |
24 |
|
|
#include "SIZE.h" |
25 |
|
|
#include "EEPARAMS.h" |
26 |
|
|
#include "PARAMS.h" |
27 |
|
|
#include "CG2D.h" |
28 |
ce107 |
1.2 |
#ifdef ALLOW_MPI |
29 |
|
|
#include "mpif.h" |
30 |
ce107 |
1.1 |
#include "MPI_INFO.h" |
31 |
ce107 |
1.2 |
#endif |
32 |
|
|
#if defined(USE_PAPI_FLOPS) || defined(USE_PAPI_FLIPS) |
33 |
|
|
#include "PAPI.h" |
34 |
|
|
#endif |
35 |
ce107 |
1.1 |
|
36 |
|
|
C == Routine arguments == |
37 |
|
|
C myThid - Thread number for this instance of the routine. |
38 |
|
|
INTEGER myThid |
39 |
|
|
|
40 |
|
|
C == Local variables == |
41 |
|
|
INTEGER I |
42 |
ce107 |
1.2 |
REAL*8 wTime1, wTime2 |
43 |
|
|
REAL*8 fCount, fTime, fRate, wSetSize |
44 |
ce107 |
1.1 |
|
45 |
|
|
C-- Set model initial conditions |
46 |
|
|
CALL INITIALISE( myThid ) |
47 |
|
|
|
48 |
|
|
C-- Begin time stepping loop |
49 |
ce107 |
1.2 |
#ifdef USE_MPI_TIME |
50 |
|
|
wTime1=MPI_Wtime() |
51 |
|
|
#else |
52 |
ce107 |
1.1 |
CALL CLOC(wTime1) |
53 |
ce107 |
1.2 |
#endif |
54 |
|
|
|
55 |
|
|
C initialize PAPI stuff |
56 |
|
|
#if defined(USE_PAPI_FLOPS) |
57 |
|
|
call PAPIF_flops(real_time, proc_time, flpops, mflops, check) |
58 |
|
|
#else |
59 |
|
|
#if defined(USE_PAPI_FLIPS) |
60 |
|
|
call PAPIF_flips(real_time, proc_time, flpops, mflops, check) |
61 |
|
|
#endif |
62 |
|
|
#endif |
63 |
ce107 |
1.1 |
|
64 |
|
|
DO I=1, nTimeSteps |
65 |
|
|
nIter = nIter0 + I |
66 |
|
|
CALL CG2D |
67 |
|
|
ENDDO |
68 |
|
|
|
69 |
ce107 |
1.2 |
#ifdef USE_MPI_TIME |
70 |
|
|
wTime2=MPI_Wtime() |
71 |
|
|
#else |
72 |
ce107 |
1.1 |
CALL CLOC(wTime2) |
73 |
ce107 |
1.2 |
#endif |
74 |
ce107 |
1.1 |
|
75 |
|
|
C CALL PLOT_FIELD_XYR8( cg2d_x , 'CG2D_X AFTER SOLVE') |
76 |
|
|
C CALL PLOT_FIELD_XYR8( cg2d_Ax, 'CG2D_AX AFTER SOLVE') |
77 |
|
|
C CALL PLOT_FIELD_XYR8( cg2d_b, 'CG2D_B AFTER SOLVE') |
78 |
|
|
C CALL PLOT_FIELD_XYR8( cg2d_r, 'CG2D_R AFTER SOLVE') |
79 |
|
|
|
80 |
ce107 |
1.2 |
#if defined(USE_PAPI_FLOPS) |
81 |
|
|
#if !defined(PAPI_PER_ITERATION) && !defined(PAPI_PER_TIMESTEP) |
82 |
|
|
call PAPIF_flops(real_time, proc_time, flpops, mflops, check) |
83 |
|
|
WRITE(6,'(F10.3,A7,F10.3,A36)') mflops, ' user ', |
84 |
|
|
$ mflops*proc_time/real_time, |
85 |
|
|
$ ' wallclock Mflop/s during execution' |
86 |
|
|
#endif |
87 |
|
|
#else |
88 |
|
|
#if defined(USE_PAPI_FLIPS) |
89 |
|
|
#if !defined(PAPI_PER_ITERATION) && !defined(PAPI_PER) |
90 |
|
|
call PAPIF_flips(real_time, proc_time, flpops, mflops, check) |
91 |
|
|
WRITE(6,'(F10.3,A7,F10.3,A36)') mflops, ' user ', |
92 |
|
|
$ mflops*proc_time/real_time, |
93 |
|
|
$ ' wallclock Mflip/s during execution' |
94 |
|
|
#endif |
95 |
|
|
#endif |
96 |
|
|
#endif |
97 |
ce107 |
1.1 |
WRITE(6,*) 'Wall clock time = ', wTime2-wTime1 |
98 |
|
|
fTime = wTime2-wTime1 |
99 |
ce107 |
1.2 |
fCount = DBLE(nTImeSteps)*DBLE(cg2dMaxIters)*34.D0*DBLE(sNx) |
100 |
|
|
$ *DBLE(sNy) |
101 |
ce107 |
1.1 |
fRate = fCount/fTime/1.D6 |
102 |
ce107 |
1.2 |
WRITE(6,*) 'PID ',myProcId+1,' OF ',numberOfProcs,' MFLOP/s = ', |
103 |
|
|
$ fRate |
104 |
ce107 |
1.1 |
wSetSize=DBLE((sNx+2*OLx)*(sNy+2*OLy)*8*11)/1024./1024. |
105 |
ce107 |
1.2 |
WRITE(6,*) 'PID ',myProcId+1,' OF ',numberOfProcs,' MB = ', |
106 |
|
|
$ wSetSize |
107 |
ce107 |
1.1 |
WRITE(6,'(4(1X,I4),3F10.4)') |
108 |
|
|
& numberOfProcs, myProcId, sNx, sNy, |
109 |
|
|
& fTime, fRate, wSetSize |
110 |
|
|
|
111 |
|
|
RETURN |
112 |
|
|
END |
113 |
|
|
|