1 |
adcroft |
1.7 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/write_state.F,v 1.6 2001/02/04 14:38:48 cnh Exp $ |
2 |
|
|
C $Name: $ |
3 |
adcroft |
1.1 |
#include "CPP_OPTIONS.h" |
4 |
|
|
|
5 |
|
|
C-- File read_write.F: Routines to handle mid-level I/O interface. |
6 |
|
|
C-- o WRITE_STATE - Write out model state. |
7 |
|
|
|
8 |
adcroft |
1.5 |
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 |
adcroft |
1.1 |
CStartofinterface |
41 |
|
|
SUBROUTINE WRITE_STATE ( forceOutput, myCurrentTime, |
42 |
|
|
& myIter, myThid ) |
43 |
|
|
C /==========================================================\ |
44 |
|
|
C | SUBROUTINE WRITE_STATE | |
45 |
|
|
C | o Controlling routine for IO to dump model state. | |
46 |
|
|
C |==========================================================| |
47 |
|
|
C | Write model state files for post-processing. This file | |
48 |
|
|
C | includes code for diagnosing W and RHO for output. | |
49 |
|
|
C \==========================================================/ |
50 |
|
|
IMPLICIT NONE |
51 |
|
|
|
52 |
|
|
C == Global variables === |
53 |
|
|
#include "SIZE.h" |
54 |
|
|
#include "EEPARAMS.h" |
55 |
|
|
#include "PARAMS.h" |
56 |
|
|
#include "DYNVARS.h" |
57 |
|
|
#include "CG2D.h" |
58 |
|
|
#ifdef ALLOW_NONHYDROSTATIC |
59 |
|
|
#include "CG3D.h" |
60 |
|
|
#include "GW.h" |
61 |
|
|
#endif |
62 |
|
|
|
63 |
|
|
LOGICAL DIFFERENT_MULTIPLE |
64 |
|
|
EXTERNAL DIFFERENT_MULTIPLE |
65 |
|
|
INTEGER IO_ERRCOUNT |
66 |
|
|
EXTERNAL IO_ERRCOUNT |
67 |
|
|
|
68 |
|
|
C == Routine arguments == |
69 |
|
|
C myThid - Thread number for this instance of the routine. |
70 |
|
|
C myIter - Iteration number |
71 |
|
|
C myCurrentTime - Current time of simulation ( s ) |
72 |
|
|
LOGICAL forceOutput |
73 |
adcroft |
1.2 |
_RL myCurrentTime |
74 |
adcroft |
1.1 |
INTEGER myThid |
75 |
|
|
INTEGER myIter |
76 |
|
|
CEndofinterface |
77 |
|
|
|
78 |
|
|
C == Local variables == |
79 |
adcroft |
1.5 |
CHARACTER*(MAX_LEN_MBUF) suff |
80 |
heimbach |
1.4 |
INTEGER iRec |
81 |
adcroft |
1.1 |
|
82 |
|
|
IF ( |
83 |
heimbach |
1.4 |
& ( DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime, |
84 |
|
|
& myCurrentTime-deltaTClock) .AND. myCurrentTime.NE.startTime ) |
85 |
|
|
& .OR. forceOutput |
86 |
|
|
& ) 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 |
|
|
CALL WRITE_REC_XY_RL ('PS',cg2d_x,iRec,myIter,myThid) |
102 |
adcroft |
1.7 |
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
103 |
adcroft |
1.1 |
#ifdef ALLOW_NONHYDROSTATIC |
104 |
|
|
IF (nonHydroStatic) THEN |
105 |
heimbach |
1.4 |
CALL WRITE_REC_XYZ_RL( 'PNH',cg3d_x,iRec,myIter,myThid) |
106 |
adcroft |
1.1 |
ENDIF |
107 |
adcroft |
1.5 |
#endif /* ALLOW_NONHYDROSTATIC */ |
108 |
|
|
#else |
109 |
|
|
C Write each snap-shot as a new file (original and default method) |
110 |
|
|
C - creates many files but for large configurations is easier to |
111 |
|
|
C transfer analyse a particular snap-shots |
112 |
|
|
WRITE(suff,'(I10.10)') myIter |
113 |
|
|
CALL WRITE_FLD_XYZ_RL( 'U.',suff,uVel,myIter,myThid) |
114 |
|
|
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
115 |
|
|
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
116 |
|
|
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
117 |
|
|
CALL WRITE_FLD_XY_RL( 'PS.',suff,cg2d_x,myIter,myThid) |
118 |
adcroft |
1.7 |
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
119 |
adcroft |
1.5 |
#ifdef ALLOW_NONHYDROSTATIC |
120 |
|
|
IF (nonHydroStatic) THEN |
121 |
|
|
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,cg3d_x,myIter,myThid) |
122 |
|
|
ENDIF |
123 |
|
|
#endif /* ALLOW_NONHYDROSTATIC */ |
124 |
|
|
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
125 |
adcroft |
1.1 |
|
126 |
heimbach |
1.4 |
_END_MASTER( myThid ) |
127 |
|
|
_BARRIER |
128 |
adcroft |
1.1 |
|
129 |
|
|
ENDIF |
130 |
|
|
|
131 |
|
|
RETURN |
132 |
|
|
END |