1 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagnostics_switch_onoff.F,v 1.2 2005/02/06 23:19:02 jmc 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( 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 myIter :: current Iteration number |
37 |
C myThid :: my Thread Id number |
38 |
INTEGER myIter |
39 |
INTEGER myThid |
40 |
CEOP |
41 |
|
42 |
C !LOCAL VARIABLES: |
43 |
C newIter :: future iteration number |
44 |
C j,m,n :: loop index |
45 |
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
46 |
INTEGER newIter |
47 |
INTEGER j, m, n |
48 |
integer realfreq,yymmdd,hhmmss,nsecf2 |
49 |
|
50 |
_BEGIN_MASTER(myThid) |
51 |
|
52 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
53 |
|
54 |
newIter = 1 + myIter |
55 |
DO n = 1,nlists |
56 |
realfreq = freq(n) |
57 |
#ifdef ALLOW_FIZHI |
58 |
if( useFIZHI) then |
59 |
yymmdd = int(freq(n)) |
60 |
realfreq = nsecf2(0,yymmdd,nymd) / deltaTclock |
61 |
endif |
62 |
#endif |
63 |
|
64 |
IF ( realfreq.LT.0 ) THEN |
65 |
C-- Select diagnostics list that uses instantaneous output |
66 |
|
67 |
c IF ( MOD(newIter,realfreq).EQ.0 ) THEN |
68 |
IF ( MOD(myIter,-realfreq).EQ.INT(-realfreq/2) ) THEN |
69 |
C-- switch ON diagnostics of output-stream # n |
70 |
DO m=1,nActive(n) |
71 |
j = jdiag(m,n) |
72 |
c IF (ndiag(j).NE.0) WRITE(0,*) myIter,j,ndiag(j),' ->',0 |
73 |
ndiag(j) = 0 |
74 |
ENDDO |
75 |
ELSE |
76 |
C-- switch OFF diagnostics of output-stream # n |
77 |
DO m=1,nActive(n) |
78 |
j = jdiag(m,n) |
79 |
c IF (ndiag(j).NE.-1) WRITE(0,*) myIter,j,ndiag(j),' ->',-1 |
80 |
ndiag(j) = -1 |
81 |
ENDDO |
82 |
ENDIF |
83 |
|
84 |
ENDIF |
85 |
ENDDO |
86 |
|
87 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
88 |
|
89 |
_END_MASTER(myThid) |
90 |
|
91 |
C-jmc: do we need a "BARRIER" at this point ? |
92 |
c _BARRIER |
93 |
|
94 |
RETURN |
95 |
END |