/[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.1 by adcroft, Wed May 5 18:32:35 1999 UTC revision 1.12 by adcroft, Fri Jun 29 17:14:49 2001 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2    C $Name$
3  #include "CPP_OPTIONS.h"  #include "CPP_OPTIONS.h"
4    
5  C--  File read_write.F: Routines to handle mid-level I/O interface.  C--  File read_write.F: Routines to handle mid-level I/O interface.
 C--   Contents  
6  C--   o WRITE_STATE - Write out model state.  C--   o WRITE_STATE - Write out model state.
7    
8    C The following CPP flag (MULTIPLE_RECORD_STATE_FILES) is
9    C #define/#undefed here since it is specific to this routine and
10    C very user-preference specific.
11    C
12    C If #undefed (default) the state files are written as in all versions
13    C prior to checkpoint32, where a file is created per variable, per time
14    C and per tile. This *has* to be the default because most users use this
15    C mode and all utilities and scripts (diagnostic) assume this form.
16    C It is also robust, as explained below.
17    C
18    C If #defined, subsequent snap-shots are written as records in the
19    C same file (no iteration number in filenames).
20    C Advantages: - fewer files
21    C             - for small problems, is easy to copy the output around
22    C Disadvantages:
23    C             - breaks a lot of diagnostic scripts
24    C             - for large or long problems this creates huge files
25    C             - is an unexpected, unsolicited change in behaviour which came
26    C               as a surprise (in c32) and inconvenience to several users
27    C             - can not accomodate changing the frequency of output
28    C               after a pickup (this is trivial in previous method
29    C               but needs new code and parameters in this new method)
30    C Known Bugs:
31    C             - if the length of integration is not exactly an integer
32    C               times the output frequency then the last record written
33    C               (at end of integration) overwrites a previously written
34    C               record corresponding to an earier time. *BE WARNED*
35    
36    #undef  MULTIPLE_RECORD_STATE_FILES
37      
38    
39    
40  CStartofinterface  CStartofinterface
41        SUBROUTINE WRITE_STATE ( forceOutput, myCurrentTime,        SUBROUTINE WRITE_STATE ( myCurrentTime, myIter, myThid )
      &    myIter, myThid )  
42  C     /==========================================================\  C     /==========================================================\
43  C     | SUBROUTINE WRITE_STATE                                   |  C     | SUBROUTINE WRITE_STATE                                   |
44  C     | o Controlling routine for IO to dump model state.        |  C     | o Controlling routine for IO to dump model state.        |
# Line 22  C     == Global variables === Line 53  C     == Global variables ===
53  #include "EEPARAMS.h"  #include "EEPARAMS.h"
54  #include "PARAMS.h"  #include "PARAMS.h"
55  #include "DYNVARS.h"  #include "DYNVARS.h"
 #include "CG2D.h"  
 #ifdef ALLOW_NONHYDROSTATIC  
 #include "CG3D.h"  
 #include "GW.h"  
 #endif  
56    
57        LOGICAL  DIFFERENT_MULTIPLE        LOGICAL  DIFFERENT_MULTIPLE
58        EXTERNAL DIFFERENT_MULTIPLE        EXTERNAL DIFFERENT_MULTIPLE
# Line 37  C     == Routine arguments == Line 63  C     == Routine arguments ==
63  C     myThid - Thread number for this instance of the routine.  C     myThid - Thread number for this instance of the routine.
64  C     myIter - Iteration number  C     myIter - Iteration number
65  C     myCurrentTime - Current time of simulation ( s )  C     myCurrentTime - Current time of simulation ( s )
66        LOGICAL forceOutput        _RL     myCurrentTime
       REAL    myCurrentTime  
67        INTEGER myThid        INTEGER myThid
68        INTEGER myIter        INTEGER myIter
69  CEndofinterface  CEndofinterface
70    
71  C     == Local variables ==  C     == Local variables ==
 C     suff - Hold suffix part of a filename  
 C     beginIOErrCount - Begin and end IO error counts  
 C     endIOErrCount  
 C     msgBuf - Error message buffer  
       INTEGER beginIOErrCount  
       INTEGER endIOErrCount  
       CHARACTER*(MAX_LEN_MBUF) msgBuf  
72        CHARACTER*(MAX_LEN_MBUF) suff        CHARACTER*(MAX_LEN_MBUF) suff
73        CHARACTER*(80) fName        INTEGER iRec
74    
75        IF (        IF (
76       &  ( DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime,       &     DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime,
77       &    myCurrentTime-deltaTClock) .AND. myCurrentTime.NE.startTime )       &     myCurrentTime-deltaTClock) .OR.
78       &  .OR. forceOutput       &     myCurrentTime.EQ.endTime .OR.
79       & ) THEN       &     myCurrentTime.EQ.startTime
80         &     ) THEN
81  C--    Going to really do some IO. Make everyone except master thread wait.           iRec = int ( (myCurrentTime-startTime) / dumpFreq +1.5 )
82         _BARRIER          
83         _BEGIN_MASTER( myThid )  C--   Going to really do some IO. Make everyone except master thread wait.
84             _BARRIER
85          WRITE(suff,'(I10.10)') myIter           _BEGIN_MASTER( myThid )
86    
87  C--     Write model fields  C--     Write model fields
88    #ifdef MULTIPLE_RECORD_STATE_FILES
89    C       Write each snap-shot as a new record in one file per variable
90    C       - creates relatively few files but these files can become huge
91            CALL WRITE_REC_XYZ_RL( 'U',  uVel,iRec,myIter,myThid)
92            CALL WRITE_REC_XYZ_RL( 'V',  vVel,iRec,myIter,myThid)
93            CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid)
94            CALL WRITE_REC_XYZ_RL( 'S',  salt,iRec,myIter,myThid)
95            CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid)
96            CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid)
97    #ifdef ALLOW_NONHYDROSTATIC
98            IF (nonHydroStatic) THEN
99             CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid)
100            ENDIF
101    #endif /* ALLOW_NONHYDROSTATIC */
102    #else
103    C       Write each snap-shot as a new file (original and default method)
104    C       - creates many files but for large configurations is easier to
105    C         transfer analyse a particular snap-shots
106            WRITE(suff,'(I10.10)') myIter
107          CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid)
108          CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid)
109          CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid)
110          CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid)          CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid)
111          CALL WRITE_FLD_XY_RL( 'PS.',suff,cg2d_x,myIter,myThid)          CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid)
112            CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid)
113  #ifdef ALLOW_NONHYDROSTATIC  #ifdef ALLOW_NONHYDROSTATIC
114          IF (nonHydroStatic) THEN          IF (nonHydroStatic) THEN
115           CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,cg3d_x,myIter,myThid)           CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid)
116          ENDIF          ENDIF
117          CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid)  #endif /* ALLOW_NONHYDROSTATIC */
118  #endif  #endif /* MULTIPLE_RECORD_STATE_FILES */
119    
120         _END_MASTER( myThid )           _END_MASTER( myThid )
121         _BARRIER           _BARRIER
122    
123        ENDIF        ENDIF
124    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.22