/[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.39 - (hide annotations) (download)
Wed May 12 17:12:53 2004 UTC (20 years, 1 month ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint53d_post, checkpoint53c_post, checkpoint53g_post, checkpoint53f_post, checkpoint53b_pre, checkpoint53b_post, checkpoint53d_pre
Changes since 1.38: +1 -3 lines
Deleting redundent comments

1 adcroft 1.39 C $Header: /u/gcmpack/MITgcm/model/src/write_state.F,v 1.38 2004/03/24 15:29:33 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 myThid - Thread number for this instance of the routine.
72     C myIter - Iteration number
73 adcroft 1.17 C myTime - Current time of simulation ( s )
74     _RL myTime
75 adcroft 1.1 INTEGER myThid
76     INTEGER myIter
77    
78 cnh 1.15 C !LOCAL VARIABLES:
79 adcroft 1.5 CHARACTER*(MAX_LEN_MBUF) suff
80 heimbach 1.4 INTEGER iRec
81 edhill 1.30 #ifdef ALLOW_MNC
82 edhill 1.32 _RL mnc_iter
83 edhill 1.30 #endif
84 cnh 1.15 CEOP
85 adcroft 1.1
86     IF (
87 adcroft 1.17 & DIFFERENT_MULTIPLE(dumpFreq,myTime,
88     & myTime-deltaTClock) .OR.
89     & myTime.EQ.endTime .OR.
90     & myTime.EQ.startTime
91 heimbach 1.4 & ) THEN
92 dimitri 1.20 IF ( dumpFreq .EQ. 0.0 ) THEN
93     iRec = 1
94     ELSE
95     iRec = int ( (myTime-startTime) / dumpFreq +1.5 )
96     ENDIF
97 heimbach 1.4
98     C-- Going to really do some IO. Make everyone except master thread wait.
99     _BARRIER
100     _BEGIN_MASTER( myThid )
101 adcroft 1.1
102     C-- Write model fields
103 jmc 1.16
104 adcroft 1.5 #ifdef MULTIPLE_RECORD_STATE_FILES
105 jmc 1.16
106 adcroft 1.5 C Write each snap-shot as a new record in one file per variable
107     C - creates relatively few files but these files can become huge
108 heimbach 1.4 CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid)
109     CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid)
110     CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid)
111     CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid)
112 jmc 1.10 CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid)
113 adcroft 1.7 CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid)
114 heimbach 1.14 #ifdef ALLOW_PASSIVE_TRACER
115 edhill 1.25 ceh3 needs an IF ( usePASSIVE_TRACER ) THEN
116 heimbach 1.13 CALL WRITE_REC_XYZ_RL( 'TR1',tr1,iRec,myIter,myThid)
117 edhill 1.25 #endif /* ALLOW_PASSIVE_TRACER */
118 adcroft 1.1 #ifdef ALLOW_NONHYDROSTATIC
119     IF (nonHydroStatic) THEN
120 adcroft 1.12 CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid)
121 adcroft 1.1 ENDIF
122 adcroft 1.5 #endif /* ALLOW_NONHYDROSTATIC */
123 jmc 1.16 #ifdef NONLIN_FRSURF
124 jmc 1.24 c CALL WRITE_REC_XYZ_RS('hFacC.',hFacC,iRec,myIter,myThid)
125     c CALL WRITE_REC_XYZ_RS('hFacW.',hFacW,iRec,myIter,myThid)
126     c CALL WRITE_REC_XYZ_RS('hFacS.',hFacS,iRec,myIter,myThid)
127 jmc 1.16 #endif /* NONLIN_FRSURF */
128    
129     #else /* MULTIPLE_RECORD_STATE_FILES */
130    
131 adcroft 1.5 C Write each snap-shot as a new file (original and default method)
132     C - creates many files but for large configurations is easier to
133     C transfer analyse a particular snap-shots
134     WRITE(suff,'(I10.10)') myIter
135     CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid)
136     CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid)
137     CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid)
138     CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid)
139 jmc 1.10 CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid)
140 adcroft 1.7 CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid)
141 jmc 1.22 IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 )
142     & CALL WRITE_FLD_XYZ_RL( 'PH.',suff,totPhiHyd,myIter,myThid)
143 jmc 1.24 IF (buoyancyRelation.NE.'ATMOSPHERIC' .AND. myIter.NE.nIter0)
144 jmc 1.21 & CALL WRITE_FLD_XY_RL('PHL.',suff,phiHydLow,myIter,myThid)
145 heimbach 1.14 #ifdef ALLOW_PASSIVE_TRACER
146 edhill 1.25 ceh3 needs an IF ( usePASSIVE_TRACER ) THEN
147 heimbach 1.13 CALL WRITE_FLD_XYZ_RL( 'TR1.',suff,tr1,myIter,myThid)
148 heimbach 1.14 #endif
149 adcroft 1.5 #ifdef ALLOW_NONHYDROSTATIC
150     IF (nonHydroStatic) THEN
151 adcroft 1.12 CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid)
152 adcroft 1.5 ENDIF
153     #endif /* ALLOW_NONHYDROSTATIC */
154 jmc 1.16 #ifdef NONLIN_FRSURF
155 jmc 1.24 c CALL WRITE_FLD_XYZ_RS('hFacC.',suff,hFacC,myIter,myThid)
156     c CALL WRITE_FLD_XYZ_RS('hFacW.',suff,hFacW,myIter,myThid)
157     c CALL WRITE_FLD_XYZ_RS('hFacS.',suff,hFacS,myIter,myThid)
158 jmc 1.16 #endif /* NONLIN_FRSURF */
159    
160 adcroft 1.5 #endif /* MULTIPLE_RECORD_STATE_FILES */
161 adcroft 1.1
162 adcroft 1.17 #ifdef ALLOW_PTRACERS
163     IF (usePTRACERS) CALL PTRACERS_WRITE_STATE(myIter,myTime,myThid)
164     #endif /* ALLOW_PTRACERS */
165 heimbach 1.4 _END_MASTER( myThid )
166     _BARRIER
167 edhill 1.26
168     #ifdef ALLOW_MNC
169 edhill 1.36 IF (useMNC) THEN
170     C Write dynvars using the MNC package
171     mnc_iter = myIter
172 edhill 1.37 CALL MNC_CW_SET_UDIM('state', -1, myThid)
173 edhill 1.38 CALL MNC_CW_RL_W('D','state',0,0,'iter',mnc_iter, myThid)
174 edhill 1.37 CALL MNC_CW_SET_UDIM('state', 0, myThid)
175 edhill 1.38 CALL MNC_CW_RL_W('D','state',0,0,'model_time',myTime, myThid)
176     CALL MNC_CW_RL_W('D','state',0,0,'U', uVel, myThid)
177     CALL MNC_CW_RL_W('D','state',0,0,'V', vVel, myThid)
178     CALL MNC_CW_RL_W('D','state',0,0,'T', theta, myThid)
179     CALL MNC_CW_RL_W('D','state',0,0,'S', salt, myThid)
180     CALL MNC_CW_RL_W('D','state',0,0,'Eta', etaN, myThid)
181     CALL MNC_CW_RL_W('D','state',0,0,'W', wVel, myThid)
182 edhill 1.36 IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 ) THEN
183 edhill 1.37 CALL MNC_CW_SET_UDIM('totPhiHyd', -1, myThid)
184 edhill 1.38 CALL MNC_CW_RL_W('R','totPhiHyd',0,0,'iter',mnc_iter,myThid)
185 edhill 1.37 CALL MNC_CW_SET_UDIM('totPhiHyd', 0, myThid)
186 edhill 1.38 CALL MNC_CW_RL_W('D','totPhiHyd',0,0,'totPhiHyd',
187 edhill 1.37 & totPhiHyd, myThid)
188 edhill 1.36 ENDIF
189     IF ((buoyancyRelation .NE. 'ATMOSPHERIC')
190     & .AND. (myIter .NE. nIter0)) THEN
191 edhill 1.37 CALL MNC_CW_SET_UDIM('phiHydLow', -1, myThid)
192 edhill 1.38 CALL MNC_CW_RL_W('D','phiHydLow',0,0,'iter',mnc_iter,myThid)
193 edhill 1.37 CALL MNC_CW_SET_UDIM('phiHydLow', 0, myThid)
194 edhill 1.38 CALL MNC_CW_RL_W('D','phiHydLow',0,0,'phiHydLow',
195 edhill 1.37 & phiHydLow, myThid)
196 edhill 1.36 ENDIF
197 edhill 1.32 #ifdef ALLOW_PASSIVE_TRACER
198 edhill 1.38 CALL MNC_CW_RL_W('D','state',0,0,'tr1', tr1, myThid)
199 edhill 1.32 #endif /* ALLOW_PASSIVE_TRACER */
200     #ifdef ALLOW_NONHYDROSTATIC
201 edhill 1.36 IF (nonHydroStatic) THEN
202 edhill 1.38 CALL MNC_CW_RL_W('D','state',0,0,'phi_nh', phi_nh, myThid)
203 edhill 1.36 ENDIF
204     #endif /* ALLOW_NONHYDROSTATIC */
205 edhill 1.32 ENDIF
206     #endif /* ALLOW_MNC */
207 adcroft 1.1
208     ENDIF
209    
210     RETURN
211     END

  ViewVC Help
Powered by ViewVC 1.1.22