1 |
C $Header$ |
C $Header$ |
2 |
C $Name$ |
C $Name$ |
3 |
|
|
4 |
|
#include "PACKAGES_CONFIG.h" |
5 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
6 |
|
|
7 |
#undef MULTIPLE_RECORD_STATE_FILES |
#undef MULTIPLE_RECORD_STATE_FILES |
8 |
|
|
9 |
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
10 |
CBOP |
CBOP |
11 |
C !ROUTINE: WRITE_STATE |
C !ROUTINE: WRITE_STATE |
12 |
|
|
13 |
C !INTERFACE: |
C !INTERFACE: |
14 |
SUBROUTINE WRITE_STATE ( myTime, myIter, myThid ) |
SUBROUTINE WRITE_STATE ( myTime, myIter, myThid ) |
15 |
C !DESCRIPTION: \bv |
|
16 |
C *==========================================================* |
C !DESCRIPTION: |
17 |
C | SUBROUTINE WRITE_STATE |
C This is the controlling routine for writing mid-level IO. It |
18 |
C | o Controlling routine for IO to dump model state. |
C includes code for diagnosing W and RHO for output. |
19 |
C *==========================================================* |
|
20 |
C | Write model state files for post-processing. This file |
C The CPP flag (MULTIPLE_RECORD_STATE_FILES) is #define/#undefed |
21 |
C | includes code for diagnosing W and RHO for output. |
C here since it is specific to this routine and very user-preference |
22 |
C | File write_state.F: Routines to handle mid-level I/O |
C specific. If #undefed (default) the state files are written as in |
23 |
C | interface. |
C all versions prior to checkpoint32, where a file is created per |
24 |
C | o WRITE_STATE - Write out model state. |
C variable, per time and per tile. This *has* to be the default |
25 |
C | The following CPP flag (MULTIPLE_RECORD_STATE_FILES) is |
C because most users use this mode and all utilities and scripts |
26 |
C | #define/#undefed here since it is specific to this routine |
C (diagnostic) assume this form. It is also robust, as explained |
27 |
C | and very user-preference specific. |
C below. |
28 |
C | |
C |
29 |
C | If #undefed (default) the state files are written as in all versions |
C If #defined, subsequent snap-shots are written as records in the |
30 |
C | prior to checkpoint32, where a file is created per variable, per time |
C same file (no iteration number in filenames). The main advantage |
31 |
C | and per tile. This *has* to be the default because most users use this |
C is fewer files. The disadvantages are that: |
32 |
C | mode and all utilities and scripts (diagnostic) assume this form. |
C (1) it breaks a lot of diagnostic scripts, |
33 |
C | It is also robust, as explained below. |
C (2) for large or long problems this creates huge files, |
34 |
C | |
C (3) its an unexpected, unsolicited change in behaviour which |
35 |
C | If #defined, subsequent snap-shots are written as records in the |
C came as a surprise (in c32) and is an inconvenience to |
36 |
C | same file (no iteration number in filenames). |
C several users |
37 |
C | Advantages: - fewer files |
C (4) it can not accomodate changing the frequency of output |
38 |
C | - for small problems, is easy to copy the output around |
C after a pickup (this is trivial in previous method but |
39 |
C | Disadvantages: |
C needs new code and parameters in this new method) |
40 |
C | - breaks a lot of diagnostic scripts |
C |
41 |
C | - for large or long problems this creates huge files |
C Known Bugs include: |
42 |
C | - is an unexpected, unsolicited change in behaviour which came |
C (1) if the length of integration is not exactly an integer |
43 |
C | as a surprise (in c32) and inconvenience to several users |
C times the output frequency then the last record written |
44 |
C | - can not accomodate changing the frequency of output |
C (at end of integration) overwrites a previously written |
45 |
C | after a pickup (this is trivial in previous method |
C record corresponding to an earier time. *BE WARNED* |
|
C | but needs new code and parameters in this new method) |
|
|
C | Known Bugs: |
|
|
C | - if the length of integration is not exactly an integer |
|
|
C | times the output frequency then the last record written |
|
|
C | (at end of integration) overwrites a previously written |
|
|
C | record corresponding to an earier time. *BE WARNED* |
|
|
C *==========================================================* |
|
|
C \ev |
|
46 |
|
|
47 |
C !USES: |
C !USES: |
48 |
IMPLICIT NONE |
IMPLICIT NONE |
|
C == Global variables === |
|
49 |
#include "SIZE.h" |
#include "SIZE.h" |
50 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
51 |
#include "PARAMS.h" |
#include "PARAMS.h" |
52 |
|
#include "GRID.h" |
53 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
54 |
#include "GRID.h" |
#ifdef ALLOW_NONHYDROSTATIC |
55 |
#include "EOS.h" |
#include "NH_VARS.h" |
56 |
#ifdef ALLOW_PASSIVE_TRACER |
#endif |
57 |
#include "TR1.h" |
#ifdef ALLOW_MNC |
58 |
|
#include "MNC_PARAMS.h" |
59 |
#endif |
#endif |
60 |
|
|
61 |
LOGICAL DIFFERENT_MULTIPLE |
LOGICAL DIFFERENT_MULTIPLE |
62 |
EXTERNAL DIFFERENT_MULTIPLE |
EXTERNAL DIFFERENT_MULTIPLE |
63 |
INTEGER IO_ERRCOUNT |
INTEGER IO_ERRCOUNT |
64 |
EXTERNAL IO_ERRCOUNT |
EXTERNAL IO_ERRCOUNT |
65 |
|
|
66 |
C !INPUT/OUTPUT PARAMETERS: |
C !INPUT/OUTPUT PARAMETERS: |
|
C == Routine arguments == |
|
67 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
68 |
C myIter - Iteration number |
C myIter - Iteration number |
69 |
C myTime - Current time of simulation ( s ) |
C myTime - Current time of simulation ( s ) |
72 |
INTEGER myIter |
INTEGER myIter |
73 |
|
|
74 |
C !LOCAL VARIABLES: |
C !LOCAL VARIABLES: |
|
C == Local variables == |
|
75 |
CHARACTER*(MAX_LEN_MBUF) suff |
CHARACTER*(MAX_LEN_MBUF) suff |
76 |
INTEGER iRec |
INTEGER iRec |
77 |
|
#ifdef ALLOW_MNC |
78 |
|
CHARACTER*(1) pf |
79 |
|
#endif |
80 |
CEOP |
CEOP |
81 |
|
|
82 |
IF ( |
IF ( |
83 |
& DIFFERENT_MULTIPLE(dumpFreq,myTime, |
& DIFFERENT_MULTIPLE(dumpFreq,myTime,deltaTClock) |
84 |
& myTime-deltaTClock) .OR. |
& .OR. dumpInitAndLast.AND.( myTime.EQ.endTime .OR. |
85 |
& myTime.EQ.endTime .OR. |
& myTime.EQ.startTime ) |
86 |
& myTime.EQ.startTime |
& ) THEN |
87 |
& ) THEN |
IF ( dumpFreq .EQ. 0.0 ) THEN |
88 |
iRec = int ( (myTime-startTime) / dumpFreq +1.5 ) |
iRec = 1 |
89 |
|
ELSE |
90 |
C-- Going to really do some IO. Make everyone except master thread wait. |
iRec = int ( (myTime-startTime) / dumpFreq +1.5 ) |
91 |
_BARRIER |
ENDIF |
|
_BEGIN_MASTER( myThid ) |
|
92 |
|
|
93 |
C-- Write model fields |
C Going to really do some IO. Make everyone except master thread wait. |
94 |
|
C this is done within IO routines => no longer needed |
95 |
|
c _BARRIER |
96 |
|
|
97 |
|
C Write model fields |
98 |
|
IF (snapshot_mdsio) THEN |
99 |
|
|
100 |
#ifdef MULTIPLE_RECORD_STATE_FILES |
#ifdef MULTIPLE_RECORD_STATE_FILES |
101 |
|
|
102 |
C Write each snap-shot as a new record in one file per variable |
C Write each snap-shot as a new record in one file per variable |
103 |
C - creates relatively few files but these files can become huge |
C - creates relatively few files but these files can become huge |
104 |
CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid) |
105 |
CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid) |
106 |
CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid) |
107 |
CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid) |
108 |
CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid) |
CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid) |
109 |
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
|
#ifdef ALLOW_PASSIVE_TRACER |
|
|
CALL WRITE_REC_XYZ_RL( 'TR1',tr1,iRec,myIter,myThid) |
|
|
#endif |
|
110 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
111 |
IF (nonHydroStatic) THEN |
IF (nonHydroStatic) THEN |
112 |
CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid) |
113 |
ENDIF |
ENDIF |
114 |
#endif /* ALLOW_NONHYDROSTATIC */ |
#endif /* ALLOW_NONHYDROSTATIC */ |
115 |
#ifdef NONLIN_FRSURF |
#ifdef NONLIN_FRSURF |
116 |
CALL WRITE_REC_XYZ_RS('hFacC.',hFacC,iRec,myIter,myThid) |
c CALL WRITE_REC_XYZ_RS('hFacC.',hFacC,iRec,myIter,myThid) |
117 |
CALL WRITE_FLD_XYZ_RS('hFacW.',hFacW,iRec,myIter,myThid) |
c CALL WRITE_REC_XYZ_RS('hFacW.',hFacW,iRec,myIter,myThid) |
118 |
CALL WRITE_FLD_XYZ_RS('hFacS.',hFacS,iRec,myIter,myThid) |
c CALL WRITE_REC_XYZ_RS('hFacS.',hFacS,iRec,myIter,myThid) |
119 |
#endif /* NONLIN_FRSURF */ |
#endif /* NONLIN_FRSURF */ |
120 |
|
|
121 |
#else /* MULTIPLE_RECORD_STATE_FILES */ |
#else /* MULTIPLE_RECORD_STATE_FILES */ |
122 |
|
|
123 |
C Write each snap-shot as a new file (original and default method) |
C Write each snap-shot as a new file (original and default |
124 |
C - creates many files but for large configurations is easier to |
C method) -- creates many files but for large configurations is |
125 |
C transfer analyse a particular snap-shots |
C easier to transfer analyse a particular snap-shots |
126 |
WRITE(suff,'(I10.10)') myIter |
WRITE(suff,'(I10.10)') myIter |
127 |
CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid) |
128 |
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
129 |
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
130 |
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
131 |
CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid) |
CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid) |
132 |
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
133 |
if ( buoyancyRelation .eq. 'OCEANIC' .and. |
IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 ) THEN |
134 |
& ( equationOfState .eq. 'JMD95P' |
CALL WRITE_FLD_XYZ_RL('PH.',suff,totPhiHyd,myIter,myThid) |
135 |
& .or. equationOfState .eq. 'MDJWF' |
ENDIF |
136 |
& .or. equationOfState .eq. 'UNESCO' ) ) then |
IF ( fluidIsWater .AND. (myIter.NE.nIter0) ) THEN |
137 |
CALL WRITE_FLD_XYZ_RL( 'P.',suff,pressure,myIter,myThid) |
CALL WRITE_FLD_XY_RL('PHL.',suff,phiHydLow,myIter,myThid) |
138 |
end if |
ENDIF |
|
if ( buoyancyRelation .ne. 'ATMOSPHERIC' ) |
|
|
& CALL WRITE_FLD_XY_RL('PHL.',suff,phiHydLow,myIter,myThid) |
|
|
#ifdef ALLOW_PASSIVE_TRACER |
|
|
CALL WRITE_FLD_XYZ_RL( 'TR1.',suff,tr1,myIter,myThid) |
|
|
#endif |
|
139 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
140 |
IF (nonHydroStatic) THEN |
IF (nonHydroStatic) THEN |
141 |
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid) |
142 |
ENDIF |
ENDIF |
143 |
#endif /* ALLOW_NONHYDROSTATIC */ |
#endif /* ALLOW_NONHYDROSTATIC */ |
144 |
#ifdef NONLIN_FRSURF |
#ifdef NONLIN_FRSURF |
145 |
CALL WRITE_FLD_XYZ_RS('hFacC.',suff,hFacC,myIter,myThid) |
c CALL WRITE_FLD_XYZ_RS('hFacC.',suff,hFacC,myIter,myThid) |
146 |
CALL WRITE_FLD_XYZ_RS('hFacW.',suff,hFacW,myIter,myThid) |
c CALL WRITE_FLD_XYZ_RS('hFacW.',suff,hFacW,myIter,myThid) |
147 |
CALL WRITE_FLD_XYZ_RS('hFacS.',suff,hFacS,myIter,myThid) |
c CALL WRITE_FLD_XYZ_RS('hFacS.',suff,hFacS,myIter,myThid) |
148 |
#endif /* NONLIN_FRSURF */ |
#endif /* NONLIN_FRSURF */ |
149 |
|
|
150 |
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
151 |
|
|
152 |
#ifdef ALLOW_PTRACERS |
ENDIF |
153 |
IF (usePTRACERS) CALL PTRACERS_WRITE_STATE(myIter,myTime,myThid) |
|
154 |
#endif /* ALLOW_PTRACERS */ |
#ifdef ALLOW_MNC |
155 |
_END_MASTER( myThid ) |
IF (useMNC .AND. snapshot_mnc) THEN |
156 |
_BARRIER |
|
157 |
|
IF ( writeBinaryPrec .EQ. precFloat64 ) THEN |
158 |
|
pf(1:1) = 'D' |
159 |
|
ELSE |
160 |
|
pf(1:1) = 'R' |
161 |
|
ENDIF |
162 |
|
|
163 |
|
C Write dynvars using the MNC package |
164 |
|
CALL MNC_CW_SET_UDIM('state', -1, myThid) |
165 |
|
CALL MNC_CW_RL_W_S('D','state',0,0,'T', myTime, myThid) |
166 |
|
CALL MNC_CW_SET_UDIM('state', 0, myThid) |
167 |
|
CALL MNC_CW_I_W_S('I','state',0,0,'iter', myIter, myThid) |
168 |
|
C CALL MNC_CW_RL_W_S('D','state',0,0,'model_time',myTime,myThid) |
169 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'U', uVel, myThid) |
170 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'V', vVel, myThid) |
171 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'Temp', theta, myThid) |
172 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'S', salt, myThid) |
173 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'Eta', etaN, myThid) |
174 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'W', wVel, myThid) |
175 |
|
IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 ) THEN |
176 |
|
CALL MNC_CW_SET_UDIM('phiHyd', -1, myThid) |
177 |
|
CALL MNC_CW_RL_W_S('D','phiHyd',0,0,'T',myTime,myThid) |
178 |
|
CALL MNC_CW_SET_UDIM('phiHyd', 0, myThid) |
179 |
|
CALL MNC_CW_I_W_S('I','phiHyd',0,0,'iter',myIter,myThid) |
180 |
|
CALL MNC_CW_RL_W(pf,'phiHyd',0,0,'phiHyd', |
181 |
|
& totPhiHyd, myThid) |
182 |
|
ENDIF |
183 |
|
IF ( fluidIsWater .AND. (myIter .NE. nIter0) ) THEN |
184 |
|
CALL MNC_CW_SET_UDIM('phiHydLow', -1, myThid) |
185 |
|
CALL MNC_CW_RL_W_S('D','phiHydLow',0,0,'T', myTime, myThid) |
186 |
|
CALL MNC_CW_SET_UDIM('phiHydLow', 0, myThid) |
187 |
|
CALL MNC_CW_I_W_S('I','phiHydLow',0,0,'iter',myIter,myThid) |
188 |
|
CALL MNC_CW_RL_W(pf,'phiHydLow',0,0,'phiHydLow', |
189 |
|
& phiHydLow, myThid) |
190 |
|
ENDIF |
191 |
|
#ifdef ALLOW_NONHYDROSTATIC |
192 |
|
IF (nonHydroStatic) THEN |
193 |
|
CALL MNC_CW_RL_W(pf,'state',0,0,'phi_nh',phi_nh,myThid) |
194 |
|
ENDIF |
195 |
|
#endif /* ALLOW_NONHYDROSTATIC */ |
196 |
|
ENDIF |
197 |
|
#endif /* ALLOW_MNC */ |
198 |
|
|
199 |
ENDIF |
ENDIF |
200 |
|
|