1 |
cnh |
1.15 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/write_state.F,v 1.14 2001/08/14 00:20:49 heimbach Exp $ |
2 |
|
|
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 |
|
|
SUBROUTINE WRITE_STATE ( myCurrentTime, myIter, myThid ) |
11 |
|
|
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 |
heimbach |
1.14 |
#ifdef ALLOW_PASSIVE_TRACER |
59 |
heimbach |
1.13 |
#include "TR1.h" |
60 |
heimbach |
1.14 |
#endif |
61 |
adcroft |
1.1 |
LOGICAL DIFFERENT_MULTIPLE |
62 |
|
|
EXTERNAL DIFFERENT_MULTIPLE |
63 |
|
|
INTEGER IO_ERRCOUNT |
64 |
|
|
EXTERNAL IO_ERRCOUNT |
65 |
|
|
|
66 |
cnh |
1.15 |
C !INPUT/OUTPUT PARAMETERS: |
67 |
adcroft |
1.1 |
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 |
adcroft |
1.2 |
_RL myCurrentTime |
72 |
adcroft |
1.1 |
INTEGER myThid |
73 |
|
|
INTEGER myIter |
74 |
|
|
|
75 |
cnh |
1.15 |
C !LOCAL VARIABLES: |
76 |
adcroft |
1.1 |
C == Local variables == |
77 |
adcroft |
1.5 |
CHARACTER*(MAX_LEN_MBUF) suff |
78 |
heimbach |
1.4 |
INTEGER iRec |
79 |
cnh |
1.15 |
CEOP |
80 |
adcroft |
1.1 |
|
81 |
|
|
IF ( |
82 |
heimbach |
1.11 |
& DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime, |
83 |
|
|
& myCurrentTime-deltaTClock) .OR. |
84 |
|
|
& myCurrentTime.EQ.endTime .OR. |
85 |
|
|
& myCurrentTime.EQ.startTime |
86 |
heimbach |
1.4 |
& ) THEN |
87 |
|
|
iRec = int ( (myCurrentTime-startTime) / dumpFreq +1.5 ) |
88 |
|
|
|
89 |
|
|
C-- Going to really do some IO. Make everyone except master thread wait. |
90 |
|
|
_BARRIER |
91 |
|
|
_BEGIN_MASTER( myThid ) |
92 |
adcroft |
1.1 |
|
93 |
|
|
C-- Write model fields |
94 |
adcroft |
1.5 |
#ifdef MULTIPLE_RECORD_STATE_FILES |
95 |
|
|
C Write each snap-shot as a new record in one file per variable |
96 |
|
|
C - creates relatively few files but these files can become huge |
97 |
heimbach |
1.4 |
CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid) |
98 |
|
|
CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid) |
99 |
|
|
CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid) |
100 |
|
|
CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid) |
101 |
jmc |
1.10 |
CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid) |
102 |
adcroft |
1.7 |
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
103 |
heimbach |
1.14 |
#ifdef ALLOW_PASSIVE_TRACER |
104 |
heimbach |
1.13 |
CALL WRITE_REC_XYZ_RL( 'TR1',tr1,iRec,myIter,myThid) |
105 |
heimbach |
1.14 |
#endif |
106 |
adcroft |
1.1 |
#ifdef ALLOW_NONHYDROSTATIC |
107 |
|
|
IF (nonHydroStatic) THEN |
108 |
adcroft |
1.12 |
CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid) |
109 |
adcroft |
1.1 |
ENDIF |
110 |
adcroft |
1.5 |
#endif /* ALLOW_NONHYDROSTATIC */ |
111 |
|
|
#else |
112 |
|
|
C Write each snap-shot as a new file (original and default method) |
113 |
|
|
C - creates many files but for large configurations is easier to |
114 |
|
|
C transfer analyse a particular snap-shots |
115 |
|
|
WRITE(suff,'(I10.10)') myIter |
116 |
|
|
CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid) |
117 |
|
|
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
118 |
|
|
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
119 |
|
|
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
120 |
jmc |
1.10 |
CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid) |
121 |
adcroft |
1.7 |
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
122 |
heimbach |
1.14 |
#ifdef ALLOW_PASSIVE_TRACER |
123 |
heimbach |
1.13 |
CALL WRITE_FLD_XYZ_RL( 'TR1.',suff,tr1,myIter,myThid) |
124 |
heimbach |
1.14 |
#endif |
125 |
adcroft |
1.5 |
#ifdef ALLOW_NONHYDROSTATIC |
126 |
|
|
IF (nonHydroStatic) THEN |
127 |
adcroft |
1.12 |
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid) |
128 |
adcroft |
1.5 |
ENDIF |
129 |
|
|
#endif /* ALLOW_NONHYDROSTATIC */ |
130 |
|
|
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
131 |
adcroft |
1.1 |
|
132 |
heimbach |
1.4 |
_END_MASTER( myThid ) |
133 |
|
|
_BARRIER |
134 |
adcroft |
1.1 |
|
135 |
|
|
ENDIF |
136 |
|
|
|
137 |
|
|
RETURN |
138 |
|
|
END |