-
Notifications
You must be signed in to change notification settings - Fork 237
/
diagnostics_write.F
182 lines (166 loc) · 5.8 KB
/
diagnostics_write.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include "DIAG_OPTIONS.h"
SUBROUTINE DIAGNOSTICS_WRITE(
I modelEnd,
I myTime, myIter, myThid )
C***********************************************************************
C Purpose
C -------
C Output sequence for the (multiple) diagnostics output files
C
C Arguments Description
C ----------------------
C modelEnd :: true if call at end of model run.
C myTime :: Current time of simulation ( s )
C myIter :: Current Iteration Number
C myThid :: my Thread Id number
C***********************************************************************
IMPLICIT NONE
#include "EEPARAMS.h"
#include "SIZE.h"
#include "PARAMS.h"
#include "DIAGNOSTICS_SIZE.h"
#include "DIAGNOSTICS_P2SHARE.h"
#include "DIAGNOSTICS.h"
C !INPUT PARAMETERS:
LOGICAL modelEnd
_RL myTime
INTEGER myIter, myThid
C !FUNCTIONS:
LOGICAL DIFF_PHASE_MULTIPLE
EXTERNAL DIFF_PHASE_MULTIPLE
#ifdef ALLOW_FIZHI
LOGICAL ALARM2
EXTERNAL ALARM2
#endif
c Local variables
c ===============
INTEGER n, nd
INTEGER myItM1, wrIter
LOGICAL dump2fileNow, write2file
LOGICAL writeDiags(numLists), writeStats(numLists)
_RL phiSec, freqSec, wrTime
#ifdef ALLOW_FIZHI
CHARACTER *9 tagname
#endif
IF ( myIter.NE.nIter0 ) THEN
myItM1 = myIter - 1
C***********************************************************************
C*** Check to see if its time for Diagnostic Output ***
C***********************************************************************
write2file = .FALSE.
DO n = 1,nlists
freqSec = freq(n)
phiSec = phase(n)
IF ( freqSec.LT.0. ) THEN
C-- write snap-shot with suffix = myIter to be consistent with
C time-average diagnostics (e.g., freq=-1 & freq=1):
c wrIter = myIter
c wrTime = myTime
C-- write snap-shot with suffix = myIter-1 to be consistent with
C state-variable time-step:
wrIter = myItM1
wrTime = myTime - deltaTClock
ELSE
wrIter = myIter
wrTime = myTime
ENDIF
dump2fileNow = DIFF_PHASE_MULTIPLE( phiSec, freqSec,
& wrTime, deltaTClock )
#ifdef ALLOW_FIZHI
IF ( useFIZHI ) THEN
WRITE(tagname,'(A,I2.2)')'diagtag',n
dump2fileNow = ALARM2(tagname)
ENDIF
#endif
#ifdef ALLOW_CAL
IF ( useCAL ) THEN
CALL CAL_TIME2DUMP( phiSec, freqSec, deltaTClock,
U dump2fileNow,
I wrTime, myIter, myThid )
ENDIF
#endif /* ALLOW_CAL */
IF ( dumpAtLast .AND. modelEnd
& .AND. freqSec.GE.0. ) dump2fileNow = .TRUE.
IF ( useDiag4AdjOutp ) THEN
nd = ABS(jdiag(1,n))
IF ( gdiag(nd)(4:4).EQ.'A' ) dump2fileNow = .FALSE.
ENDIF
IF ( dump2fileNow ) THEN
write2file = .TRUE.
CALL DIAGNOSTICS_OUT(n,wrTime,wrIter,myThid)
ENDIF
writeDiags(n) = dump2fileNow
C- end loop on list id number n
ENDDO
C--- Check to see if its time for Statistics Diag. Output
DO n = 1,diagSt_nbLists
freqSec = diagSt_freq(n)
phiSec = diagSt_phase(n)
IF ( freqSec.LT.0. ) THEN
C-- write snap-shot with suffix = myIter to be consistent with
C time-average diagnostics (e.g., freq=-1 & freq=1):
c wrIter = myIter
c wrTime = myTime
C-- write snap-shot with suffix = myIter-1 to be consistent with
C state-variable time-step:
wrIter = myItM1
wrTime = myTime - deltaTClock
ELSE
wrIter = myIter
wrTime = myTime
ENDIF
dump2fileNow = DIFF_PHASE_MULTIPLE( phiSec, freqSec,
& wrTime, deltaTClock )
#ifdef ALLOW_FIZHI
IF ( useFIZHI ) THEN
WRITE(tagname,'(A,I2.2)')'diagStg',n
dump2fileNow = ALARM2(tagname)
ENDIF
#endif
#ifdef ALLOW_CAL
IF ( useCAL ) THEN
CALL CAL_TIME2DUMP( phiSec, freqSec, deltaTClock,
U dump2fileNow,
I wrTime, myIter, myThid )
ENDIF
#endif /* ALLOW_CAL */
IF ( dumpAtLast .AND. modelEnd
& .AND. freqSec.GE.0. ) dump2fileNow = .TRUE.
IF ( dump2fileNow ) THEN
write2file = .TRUE.
CALL DIAGSTATS_OUTPUT(n,wrTime,wrIter,myThid)
ENDIF
writeStats(n) = dump2fileNow
C- end loop on list id number n
ENDDO
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
IF ( write2file ) THEN
IF ( diag_dBugLevel.GE.debLevC ) THEN
CALL DIAGNOSTICS_SUMMARY( 1, myTime, myIter, myThid )
ENDIF
C- wait for everyone before setting arrays to zero:
_BARRIER
ENDIF
IF ( modelEnd ) THEN
C- Track diagnostics pkg activation status:
c IF ( diag_pkgStatus.NE.ready2fillDiags ) STOP
_BARRIER
_BEGIN_MASTER(myThid)
C --- Do not disable diagnostics package for adj variables
IF ( .NOT.useDiag4AdjOutp ) diag_pkgStatus = 99
_END_MASTER(myThid)
_BARRIER
C Close all Stat-diags output files
CALL DIAGSTATS_CLOSE_IO( myThid )
ENDIF
C-- Clear storage space:
DO n = 1,nlists
IF ( writeDiags(n) ) CALL DIAGNOSTICS_CLEAR(n,myThid)
ENDDO
DO n = 1,diagSt_nbLists
IF ( writeStats(n) ) CALL DIAGSTATS_CLEAR( n, myThid )
ENDDO
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
ENDIF
RETURN
END