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