1 |
molod |
1.15 |
C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagnostics_write.F,v 1.14 2005/05/14 20:45:27 jmc Exp $ |
2 |
edhill |
1.6 |
C $Name: $ |
3 |
|
|
|
4 |
edhill |
1.7 |
#include "DIAG_OPTIONS.h" |
5 |
|
|
|
6 |
jmc |
1.9 |
SUBROUTINE DIAGNOSTICS_WRITE ( myTime, myIter, myThid ) |
7 |
molod |
1.1 |
C*********************************************************************** |
8 |
|
|
C Purpose |
9 |
|
|
C ------- |
10 |
molod |
1.2 |
C Output sequence for the (multiple) diagnostics output files |
11 |
molod |
1.1 |
C |
12 |
|
|
C Arguments Description |
13 |
|
|
C ---------------------- |
14 |
jmc |
1.9 |
C myTime :: Current time of simulation ( s ) |
15 |
|
|
C myIter :: Current Iteration Number |
16 |
|
|
C myThid :: my thread Id number |
17 |
molod |
1.1 |
C*********************************************************************** |
18 |
jmc |
1.8 |
IMPLICIT NONE |
19 |
molod |
1.1 |
#include "SIZE.h" |
20 |
jmc |
1.8 |
#include "DIAGNOSTICS_SIZE.h" |
21 |
|
|
#include "DIAGNOSTICS.h" |
22 |
molod |
1.4 |
#include "EEPARAMS.h" |
23 |
|
|
#include "PARAMS.h" |
24 |
molod |
1.12 |
#ifdef ALLOW_FIZHI |
25 |
|
|
#include "chronos.h" |
26 |
|
|
#endif |
27 |
molod |
1.1 |
|
28 |
jmc |
1.14 |
C !INPUT PARAMETERS: |
29 |
jmc |
1.9 |
_RL myTime |
30 |
jmc |
1.8 |
INTEGER myIter, myThid |
31 |
molod |
1.1 |
|
32 |
|
|
c Local variables |
33 |
|
|
c =============== |
34 |
jmc |
1.8 |
INTEGER n |
35 |
jmc |
1.9 |
INTEGER myItM1, wrIter |
36 |
|
|
LOGICAL dump2fileNow |
37 |
jmc |
1.14 |
_RL phiSec, freqSec, wrTime |
38 |
|
|
#ifdef ALLOW_CAL |
39 |
dimitri |
1.10 |
INTEGER thisdate(4), prevdate(4) |
40 |
jmc |
1.14 |
#endif |
41 |
|
|
#ifdef ALLOW_FIZHI |
42 |
molod |
1.15 |
integer nsecf2,mmdd,hhmmss,alarm2 |
43 |
|
|
character *9 tagname |
44 |
jmc |
1.14 |
#endif |
45 |
|
|
|
46 |
|
|
LOGICAL DIFF_PHASE_MULTIPLE |
47 |
|
|
EXTERNAL DIFF_PHASE_MULTIPLE |
48 |
jmc |
1.8 |
|
49 |
jmc |
1.9 |
IF ( myIter.NE.nIter0 ) THEN |
50 |
|
|
myItM1 = myIter - 1 |
51 |
molod |
1.1 |
|
52 |
|
|
C*********************************************************************** |
53 |
jmc |
1.8 |
C*** Check to see IF its time for Diagnostic Output *** |
54 |
molod |
1.1 |
C*********************************************************************** |
55 |
|
|
|
56 |
dimitri |
1.10 |
#ifdef ALLOW_CAL |
57 |
|
|
IF ( calendarDumps ) THEN |
58 |
|
|
C- Determine calendar dates for this and previous time step. |
59 |
|
|
call cal_GetDate(myiter ,mytime ,thisdate,mythid) |
60 |
|
|
call cal_GetDate(myiter-1,mytime-deltaTClock,prevdate,mythid) |
61 |
|
|
ENDIF |
62 |
|
|
#endif |
63 |
|
|
|
64 |
jmc |
1.8 |
DO n = 1,nlists |
65 |
jmc |
1.14 |
freqSec = freq(n) |
66 |
|
|
phiSec = phase(n) |
67 |
molod |
1.12 |
#ifdef ALLOW_FIZHI |
68 |
|
|
if( useFIZHI) then |
69 |
molod |
1.15 |
mmdd = int(freq(n)) |
70 |
molod |
1.13 |
hhmmss = int((freq(n) - int(freq(n)))*1.e6) |
71 |
molod |
1.15 |
freqSec = nsecf2(hhmmss,mmdd,nymd) |
72 |
molod |
1.12 |
endif |
73 |
|
|
#endif |
74 |
|
|
|
75 |
jmc |
1.14 |
IF ( freqSec.LT.0. ) THEN |
76 |
jmc |
1.9 |
C-- write snap-shot with suffix = myIter to be consistent with |
77 |
|
|
C time-average diagnostics (e.g., freq=-1 & freq=1): |
78 |
|
|
c wrIter = myIter |
79 |
jmc |
1.14 |
c wrTime = myTime |
80 |
jmc |
1.9 |
C-- write snap-shot with suffix = myIter-1 to be consistent with |
81 |
|
|
C state-variable time-step: |
82 |
|
|
wrIter = myItM1 |
83 |
jmc |
1.14 |
wrTime = myTime - deltaTclock |
84 |
jmc |
1.9 |
ELSE |
85 |
|
|
wrIter = myIter |
86 |
jmc |
1.14 |
wrTime = myTime |
87 |
jmc |
1.9 |
ENDIF |
88 |
jmc |
1.14 |
dump2fileNow = DIFF_PHASE_MULTIPLE( phiSec, freqSec, |
89 |
|
|
& wrTime, deltaTclock ) |
90 |
molod |
1.15 |
#ifdef ALLOW_FIZHI |
91 |
|
|
if( useFIZHI) then |
92 |
|
|
write(tagname,'(A,I2.2)')'diagtag',n |
93 |
|
|
dump2fileNow = alarm2(tagname) |
94 |
|
|
endif |
95 |
|
|
#endif |
96 |
dimitri |
1.10 |
|
97 |
|
|
#ifdef ALLOW_CAL |
98 |
|
|
IF ( calendarDumps .AND. ( |
99 |
|
|
& ( freqSec.GE. 2592000 .AND. freqSec.LE. 2678400 ) .OR. |
100 |
dimitri |
1.11 |
& ( freqSec.GE.31104000 .AND. freqSec.LE.31968000 ))) THEN |
101 |
dimitri |
1.10 |
C-- Convert approximate months (30-31 days) and years (360-372 days) |
102 |
|
|
C to exact calendar months and years. |
103 |
dimitri |
1.11 |
dump2fileNow = .FALSE. |
104 |
dimitri |
1.10 |
C- Monthly freqSec: |
105 |
|
|
IF( freqSec.GE. 2592000 .AND. freqSec.LE. 2678400 .AND. |
106 |
dimitri |
1.11 |
& (thisdate(1)-prevdate(1)).GT.50 ) dump2fileNow = .TRUE. |
107 |
dimitri |
1.10 |
C- Yearly freqSec: |
108 |
|
|
IF( freqSec.GE.31104000 .AND. freqSec.LE.31968000 .AND. |
109 |
dimitri |
1.11 |
& (thisdate(1)-prevdate(1)).GT.5000 ) dump2fileNow = .TRUE. |
110 |
dimitri |
1.10 |
ENDIF |
111 |
|
|
#endif |
112 |
|
|
|
113 |
jmc |
1.9 |
IF ( dump2fileNow ) THEN |
114 |
|
|
CALL DIAGNOSTICS_OUT(n,wrIter,myThid) |
115 |
jmc |
1.8 |
ENDIF |
116 |
|
|
ENDDO |
117 |
|
|
|
118 |
|
|
C- wait for everyone before setting arrays to zero: |
119 |
|
|
_BARRIER |
120 |
|
|
DO n = 1,nlists |
121 |
jmc |
1.14 |
freqSec = freq(n) |
122 |
|
|
phiSec = phase(n) |
123 |
molod |
1.12 |
#ifdef ALLOW_FIZHI |
124 |
|
|
if( useFIZHI) then |
125 |
molod |
1.15 |
mmdd = int(freq(n)) |
126 |
molod |
1.13 |
hhmmss = int((freq(n) - int(freq(n)))*1.e6) |
127 |
molod |
1.15 |
freqSec = nsecf2(hhmmss,mmdd,nymd) |
128 |
molod |
1.12 |
endif |
129 |
|
|
#endif |
130 |
jmc |
1.14 |
wrTime = myTime |
131 |
|
|
IF ( freqSec.LT.0. ) wrTime = myTime - deltaTclock |
132 |
|
|
dump2fileNow = DIFF_PHASE_MULTIPLE( phiSec, freqSec, |
133 |
|
|
& wrTime, deltaTclock ) |
134 |
molod |
1.15 |
#ifdef ALLOW_FIZHI |
135 |
|
|
if( useFIZHI) then |
136 |
|
|
write(tagname,'(A,I2.2)')'diagtag',n |
137 |
|
|
dump2fileNow = alarm2(tagname) |
138 |
|
|
endif |
139 |
|
|
#endif |
140 |
jmc |
1.9 |
IF ( dump2fileNow ) CALL CLRINDX(n,myThid) |
141 |
jmc |
1.8 |
ENDDO |
142 |
|
|
|
143 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
144 |
|
|
ENDIF |
145 |
|
|
|
146 |
|
|
RETURN |
147 |
|
|
END |