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