/[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.23 - (hide annotations) (download)
Sat Sep 27 07:45:51 2003 UTC (20 years, 8 months ago) by dimitri
Branch: MAIN
Changes since 1.22: +3 -3 lines
I/O bug fixes

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

  ViewVC Help
Powered by ViewVC 1.1.22