1 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagnostics_switch_onoff.F,v 1.4 2005/05/13 18:32:46 molod Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "DIAG_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP 0 |
8 |
C !ROUTINE: DIAGNOSTICS_SWITCH_ONOFF |
9 |
|
10 |
C !INTERFACE: |
11 |
SUBROUTINE DIAGNOSTICS_SWITCH_ONOFF( myTime, myIter, myThid ) |
12 |
|
13 |
C !DESCRIPTION: |
14 |
C----- |
15 |
C Called at the beginning of the time-step, |
16 |
C to switch on/off diagnostics for snap-shot output |
17 |
C----- |
18 |
C during iterations that are multiple of |freq|, |
19 |
C switch ON diagnostics (ndiag>=0) that will become active |
20 |
C and then can be written at the end of the time-step ; |
21 |
C otherwise, put diagnostics in non-active mode (ndiag=-1) |
22 |
C----- |
23 |
|
24 |
C !USES: |
25 |
IMPLICIT NONE |
26 |
#include "SIZE.h" |
27 |
#include "EEPARAMS.h" |
28 |
#include "PARAMS.h" |
29 |
#include "DIAGNOSTICS_SIZE.h" |
30 |
#include "DIAGNOSTICS.h" |
31 |
#ifdef ALLOW_FIZHI |
32 |
#include "chronos.h" |
33 |
#endif |
34 |
|
35 |
C !INPUT PARAMETERS: |
36 |
C myTime :: current Time of simulation ( s ) |
37 |
C myIter :: current Iteration number |
38 |
C myThid :: my Thread Id number |
39 |
INTEGER myTime |
40 |
INTEGER myIter |
41 |
INTEGER myThid |
42 |
CEOP |
43 |
|
44 |
C !LOCAL VARIABLES: |
45 |
C newIter :: future iteration number |
46 |
C j,m,n :: loop index |
47 |
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
48 |
c INTEGER newIter |
49 |
INTEGER j, m, n |
50 |
LOGICAL time4SnapShot |
51 |
_RL phiSec, freqSec |
52 |
#ifdef ALLOW_FIZHI |
53 |
integer yymmdd,hhmmss,nsecf2 |
54 |
#endif |
55 |
|
56 |
LOGICAL DIFF_PHASE_MULTIPLE |
57 |
EXTERNAL DIFF_PHASE_MULTIPLE |
58 |
|
59 |
_BEGIN_MASTER(myThid) |
60 |
|
61 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
62 |
|
63 |
c newIter = 1 + myIter |
64 |
DO n = 1,nlists |
65 |
|
66 |
IF ( freq(n).LT.0. ) THEN |
67 |
C-- Select diagnostics list that uses instantaneous output |
68 |
|
69 |
freqSec = freq(n) |
70 |
phiSec = phase(n) |
71 |
#ifdef ALLOW_FIZHI |
72 |
if( useFIZHI) then |
73 |
yymmdd = int(freq(n)) |
74 |
hhmmss = int((freq(n) - int(freq(n)))*1.e6) |
75 |
freqSec = nsecf2(hhmmss,yymmdd,nymd) |
76 |
yymmdd = int(phase(n)) |
77 |
hhmmss = int((phase(n) - int(phase(n)))*1.e6) |
78 |
phiSec = nsecf2(hhmmss,yymmdd,nymd) |
79 |
endif |
80 |
#endif |
81 |
|
82 |
time4SnapShot = DIFF_PHASE_MULTIPLE( phiSec, freqSec, |
83 |
& myTime, deltaTclock ) |
84 |
|
85 |
IF ( time4SnapShot ) THEN |
86 |
C-- switch ON diagnostics of output-stream # n |
87 |
DO m=1,nActive(n) |
88 |
j = jdiag(m,n) |
89 |
c IF (ndiag(j).NE.0) WRITE(0,*) myIter,j,ndiag(j),' ->',0 |
90 |
ndiag(j) = 0 |
91 |
ENDDO |
92 |
ELSE |
93 |
C-- switch OFF diagnostics of output-stream # n |
94 |
DO m=1,nActive(n) |
95 |
j = jdiag(m,n) |
96 |
c IF (ndiag(j).NE.-1) WRITE(0,*) myIter,j,ndiag(j),' ->',-1 |
97 |
ndiag(j) = -1 |
98 |
ENDDO |
99 |
ENDIF |
100 |
|
101 |
ENDIF |
102 |
ENDDO |
103 |
|
104 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
105 |
|
106 |
_END_MASTER(myThid) |
107 |
|
108 |
C-jmc: do we need a "BARRIER" at this point ? |
109 |
c _BARRIER |
110 |
|
111 |
RETURN |
112 |
END |