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

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

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

revision 1.6 by cnh, Sun Feb 4 14:38:48 2001 UTC revision 1.32 by edhill, Thu Feb 5 19:38:55 2004 UTC
# Line 1  Line 1 
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    CBOP
10    C     !ROUTINE: WRITE_STATE
11    C     !INTERFACE:
12          SUBROUTINE WRITE_STATE ( myTime, myIter, myThid )
13    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    
53  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     \==========================================================/  
54        IMPLICIT NONE        IMPLICIT NONE
   
55  C     == Global variables ===  C     == Global variables ===
56  #include "SIZE.h"  #include "SIZE.h"
57  #include "EEPARAMS.h"  #include "EEPARAMS.h"
58  #include "PARAMS.h"  #include "PARAMS.h"
59  #include "DYNVARS.h"  #include "DYNVARS.h"
60  #include "CG2D.h"  #include "GRID.h"
61  #ifdef ALLOW_NONHYDROSTATIC  #include "EOS.h"
62  #include "CG3D.h"  #ifdef ALLOW_PASSIVE_TRACER
63  #include "GW.h"  #include "TR1.h"
64  #endif  #endif
   
65        LOGICAL  DIFFERENT_MULTIPLE        LOGICAL  DIFFERENT_MULTIPLE
66        EXTERNAL DIFFERENT_MULTIPLE        EXTERNAL DIFFERENT_MULTIPLE
67        INTEGER  IO_ERRCOUNT        INTEGER  IO_ERRCOUNT
68        EXTERNAL IO_ERRCOUNT        EXTERNAL IO_ERRCOUNT
69    
70    C     !INPUT/OUTPUT PARAMETERS:
71  C     == Routine arguments ==  C     == Routine arguments ==
72  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
73  C     myIter - Iteration number  C     myIter - Iteration number
74  C     myCurrentTime - Current time of simulation ( s )  C     myTime - Current time of simulation ( s )
75        LOGICAL forceOutput        _RL     myTime
       _RL     myCurrentTime  
76        INTEGER myThid        INTEGER myThid
77        INTEGER myIter        INTEGER myIter
 CEndofinterface  
78    
79    C     !LOCAL VARIABLES:
80  C     == Local variables ==  C     == Local variables ==
81        CHARACTER*(MAX_LEN_MBUF) suff        CHARACTER*(MAX_LEN_MBUF) suff
82        INTEGER iRec        INTEGER iRec
83    #ifdef ALLOW_MNC
84          _RL mnc_iter
85    #endif
86    CEOP
87    
88        IF (        IF (
89       &     ( DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime,       &     DIFFERENT_MULTIPLE(dumpFreq,myTime,
90       &     myCurrentTime-deltaTClock) .AND. myCurrentTime.NE.startTime )       &     myTime-deltaTClock) .OR.
91       &     .OR. forceOutput       &     myTime.EQ.endTime .OR.
92         &     myTime.EQ.startTime
93       &     ) THEN       &     ) THEN
94           iRec = int ( (myCurrentTime-startTime) / dumpFreq +1.5 )           IF ( dumpFreq .EQ. 0.0 ) THEN
95                iRec = 1
96             ELSE
97                iRec = int ( (myTime-startTime) / dumpFreq +1.5 )
98             ENDIF
99                    
100  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.
101           _BARRIER           _BARRIER
102           _BEGIN_MASTER( myThid )           _BEGIN_MASTER( myThid )
103    
104  C--     Write model fields  C--     Write model fields
105    
106  #ifdef MULTIPLE_RECORD_STATE_FILES  #ifdef MULTIPLE_RECORD_STATE_FILES
107    
108  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
109  C       - creates relatively few files but these files can become huge  C       - creates relatively few files but these files can become huge
110          CALL WRITE_REC_XYZ_RL( 'U',  uVel,iRec,myIter,myThid)          CALL WRITE_REC_XYZ_RL( 'U',  uVel,iRec,myIter,myThid)
111          CALL WRITE_REC_XYZ_RL( 'V',  vVel,iRec,myIter,myThid)          CALL WRITE_REC_XYZ_RL( 'V',  vVel,iRec,myIter,myThid)
112          CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid)          CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid)
113          CALL WRITE_REC_XYZ_RL( 'S',  salt,iRec,myIter,myThid)          CALL WRITE_REC_XYZ_RL( 'S',  salt,iRec,myIter,myThid)
114          CALL WRITE_REC_XY_RL ('PS',cg2d_x,iRec,myIter,myThid)          CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid)
115            CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid)
116    #ifdef ALLOW_PASSIVE_TRACER
117    ceh3 needs an IF ( usePASSIVE_TRACER ) THEN
118            CALL WRITE_REC_XYZ_RL( 'TR1',tr1,iRec,myIter,myThid)
119    #endif /* ALLOW_PASSIVE_TRACER */
120  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
121          IF (nonHydroStatic) THEN          IF (nonHydroStatic) THEN
122           CALL WRITE_REC_XYZ_RL( 'PNH',cg3d_x,iRec,myIter,myThid)           CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid)
123          ENDIF          ENDIF
         CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid)  
124  #endif /* ALLOW_NONHYDROSTATIC */  #endif /* ALLOW_NONHYDROSTATIC */
125  #else  #ifdef NONLIN_FRSURF
126    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    #endif /* NONLIN_FRSURF */
130    
131    #else /* MULTIPLE_RECORD_STATE_FILES */
132    
133  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 method)
134  C       - creates many files but for large configurations is easier to  C       - creates many files but for large configurations is easier to
135  C         transfer analyse a particular snap-shots  C         transfer analyse a particular snap-shots
# Line 114  C         transfer analyse a particular Line 138  C         transfer analyse a particular
138          CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid)
139          CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid)
140          CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid)
141          CALL WRITE_FLD_XY_RL( 'PS.',suff,cg2d_x,myIter,myThid)          CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid)
142            CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid)
143            IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 )
144         &  CALL WRITE_FLD_XYZ_RL( 'PH.',suff,totPhiHyd,myIter,myThid)
145            IF (buoyancyRelation.NE.'ATMOSPHERIC' .AND. myIter.NE.nIter0)
146         &   CALL WRITE_FLD_XY_RL('PHL.',suff,phiHydLow,myIter,myThid)
147    #ifdef ALLOW_PASSIVE_TRACER
148    ceh3 needs an IF ( usePASSIVE_TRACER ) THEN
149            CALL WRITE_FLD_XYZ_RL( 'TR1.',suff,tr1,myIter,myThid)
150    #endif
151  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
152          IF (nonHydroStatic) THEN          IF (nonHydroStatic) THEN
153           CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,cg3d_x,myIter,myThid)           CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid)
154          ENDIF          ENDIF
         CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid)  
155  #endif /* ALLOW_NONHYDROSTATIC */  #endif /* ALLOW_NONHYDROSTATIC */
156    #ifdef NONLIN_FRSURF
157    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    #endif /* NONLIN_FRSURF */
161    
162  #endif /* MULTIPLE_RECORD_STATE_FILES */  #endif /* MULTIPLE_RECORD_STATE_FILES */
163    
164    #ifdef ALLOW_PTRACERS
165           IF (usePTRACERS) CALL PTRACERS_WRITE_STATE(myIter,myTime,myThid)
166    #endif /* ALLOW_PTRACERS */
167           _END_MASTER( myThid )           _END_MASTER( myThid )
168           _BARRIER           _BARRIER
169    
170    #ifdef ALLOW_MNC
171    
172    C     Write dynvars using the MNC package
173          mnc_iter = myIter
174          CALL MNC_CW_RL_W_R(myThid,'state',0,0,'iter',-1,mnc_iter)
175          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'U', 0, uVel)
176          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'V', 0, vVel)
177          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'T', 0, theta)
178          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'S', 0, salt)
179          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'Eta', 0, etaN)
180          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'W', 0, wVel)
181          IF ( useDynP_inEos_Zc .OR. myIter.NE.nIter0 ) THEN
182            CALL MNC_CW_RL_W_R(myThid,'totPhiHyd',0,0,'iter',-1,mnc_iter)
183            CALL MNC_CW_RL_W_D(myThid,'totPhiHyd',0,0,'totPhiHyd',
184         &       0,totPhiHyd)
185          ENDIF
186          IF ((buoyancyRelation .NE. 'ATMOSPHERIC')
187         &     .AND. (myIter .NE. nIter0)) THEN
188            CALL MNC_CW_RL_W_R(myThid,'phiHydLow',0,0,'iter',-1,mnc_iter)
189            CALL MNC_CW_RL_W_D(myThid,'phiHydLow',0,0,'phiHydLow',
190         &       0,phiHydLow)
191          ENDIF
192    
193    #ifdef ALLOW_PASSIVE_TRACER
194          CALL MNC_CW_RL_W_D(myThid,'state',0,0,'tr1', 0, tr1)
195    #endif /*  ALLOW_PASSIVE_TRACER  */
196    
197    #ifdef ALLOW_NONHYDROSTATIC
198          IF (nonHydroStatic) THEN
199            CALL MNC_CW_RL_W_D(myThid,'state',0,0,'phi_nh', 0, phi_nh)
200          ENDIF
201    #endif /* ALLOW_NONHYDROSTATIC */
202    
203    #endif /*  ALLOW_MNC  */
204    
205        ENDIF        ENDIF
206    
207        RETURN        RETURN

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.22