/[MITgcm]/MITgcm/model/src/write_state.F
ViewVC logotype

Annotation of /MITgcm/model/src/write_state.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.37 - (hide annotations) (download)
Sun Mar 21 03:44:23 2004 UTC (20 years, 2 months ago) by edhill
Branch: MAIN
Changes since 1.36: +21 -15 lines
 o finish implementation of the separate unlimited-dim handling for the
   MNC_CW_*_R_* and MNC_CW_*_W_* functions

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

  ViewVC Help
Powered by ViewVC 1.1.22