2 |
C $Name$ |
C $Name$ |
3 |
#include "CPP_OPTIONS.h" |
#include "CPP_OPTIONS.h" |
4 |
|
|
|
C-- File read_write.F: Routines to handle mid-level I/O interface. |
|
|
C-- o WRITE_STATE - Write out model state. |
|
|
|
|
|
C The following CPP flag (MULTIPLE_RECORD_STATE_FILES) is |
|
|
C #define/#undefed here since it is specific to this routine and |
|
|
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* |
|
|
|
|
5 |
#undef MULTIPLE_RECORD_STATE_FILES |
#undef MULTIPLE_RECORD_STATE_FILES |
|
|
|
6 |
|
|
7 |
|
CBOP |
8 |
|
C !ROUTINE: WRITE_STATE |
9 |
|
C !INTERFACE: |
10 |
|
SUBROUTINE WRITE_STATE ( myTime, 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 |
|
|
51 |
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 \==========================================================/ |
|
52 |
IMPLICIT NONE |
IMPLICIT NONE |
|
|
|
53 |
C == Global variables === |
C == Global variables === |
54 |
#include "SIZE.h" |
#include "SIZE.h" |
55 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
56 |
#include "PARAMS.h" |
#include "PARAMS.h" |
57 |
#include "DYNVARS.h" |
#include "DYNVARS.h" |
58 |
#include "CG2D.h" |
#include "GRID.h" |
59 |
#ifdef ALLOW_NONHYDROSTATIC |
#include "EOS.h" |
60 |
#include "CG3D.h" |
#ifdef ALLOW_PASSIVE_TRACER |
61 |
#include "GW.h" |
#include "TR1.h" |
62 |
#endif |
#endif |
|
|
|
63 |
LOGICAL DIFFERENT_MULTIPLE |
LOGICAL DIFFERENT_MULTIPLE |
64 |
EXTERNAL DIFFERENT_MULTIPLE |
EXTERNAL DIFFERENT_MULTIPLE |
65 |
INTEGER IO_ERRCOUNT |
INTEGER IO_ERRCOUNT |
66 |
EXTERNAL IO_ERRCOUNT |
EXTERNAL IO_ERRCOUNT |
67 |
|
|
68 |
|
C !INPUT/OUTPUT PARAMETERS: |
69 |
C == Routine arguments == |
C == Routine arguments == |
70 |
C myThid - Thread number for this instance of the routine. |
C myThid - Thread number for this instance of the routine. |
71 |
C myIter - Iteration number |
C myIter - Iteration number |
72 |
C myCurrentTime - Current time of simulation ( s ) |
C myTime - Current time of simulation ( s ) |
73 |
LOGICAL forceOutput |
_RL myTime |
|
_RL myCurrentTime |
|
74 |
INTEGER myThid |
INTEGER myThid |
75 |
INTEGER myIter |
INTEGER myIter |
|
CEndofinterface |
|
76 |
|
|
77 |
|
C !LOCAL VARIABLES: |
78 |
C == Local variables == |
C == Local variables == |
79 |
CHARACTER*(MAX_LEN_MBUF) suff |
CHARACTER*(MAX_LEN_MBUF) suff |
80 |
INTEGER iRec |
INTEGER iRec |
81 |
|
CEOP |
82 |
|
|
83 |
IF ( |
IF ( |
84 |
& ( DIFFERENT_MULTIPLE(dumpFreq,myCurrentTime, |
& DIFFERENT_MULTIPLE(dumpFreq,myTime, |
85 |
& myCurrentTime-deltaTClock) .AND. myCurrentTime.NE.startTime ) |
& myTime-deltaTClock) .OR. |
86 |
& .OR. forceOutput |
& myTime.EQ.endTime .OR. |
87 |
|
& myTime.EQ.startTime |
88 |
& ) THEN |
& ) THEN |
89 |
iRec = int ( (myCurrentTime-startTime) / dumpFreq +1.5 ) |
IF ( dumpFreq .EQ. 0.0 ) THEN |
90 |
|
iRec = 1 |
91 |
|
ELSE |
92 |
|
iRec = int ( (myTime-startTime) / dumpFreq +1.5 ) |
93 |
|
ENDIF |
94 |
|
|
95 |
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. |
96 |
_BARRIER |
_BARRIER |
97 |
_BEGIN_MASTER( myThid ) |
_BEGIN_MASTER( myThid ) |
98 |
|
|
99 |
C-- Write model fields |
C-- Write model fields |
100 |
|
|
101 |
#ifdef MULTIPLE_RECORD_STATE_FILES |
#ifdef MULTIPLE_RECORD_STATE_FILES |
102 |
|
|
103 |
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 |
104 |
C - creates relatively few files but these files can become huge |
C - creates relatively few files but these files can become huge |
105 |
CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'U', uVel,iRec,myIter,myThid) |
106 |
CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'V', vVel,iRec,myIter,myThid) |
107 |
CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'T', theta,iRec,myIter,myThid) |
108 |
CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'S', salt,iRec,myIter,myThid) |
109 |
CALL WRITE_REC_XY_RL ('PS',cg2d_x,iRec,myIter,myThid) |
CALL WRITE_REC_XY_RL('Eta',etaN,iRec,myIter,myThid) |
110 |
|
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
111 |
|
#ifdef ALLOW_PASSIVE_TRACER |
112 |
|
CALL WRITE_REC_XYZ_RL( 'TR1',tr1,iRec,myIter,myThid) |
113 |
|
#endif |
114 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
115 |
IF (nonHydroStatic) THEN |
IF (nonHydroStatic) THEN |
116 |
CALL WRITE_REC_XYZ_RL( 'PNH',cg3d_x,iRec,myIter,myThid) |
CALL WRITE_REC_XYZ_RL( 'PNH',phi_nh,iRec,myIter,myThid) |
117 |
ENDIF |
ENDIF |
|
CALL WRITE_REC_XYZ_RL( 'W',wVel,iRec,myIter,myThid) |
|
118 |
#endif /* ALLOW_NONHYDROSTATIC */ |
#endif /* ALLOW_NONHYDROSTATIC */ |
119 |
#else |
#ifdef NONLIN_FRSURF |
120 |
|
CALL WRITE_REC_XYZ_RS('hFacC.',hFacC,iRec,myIter,myThid) |
121 |
|
CALL WRITE_FLD_XYZ_RS('hFacW.',hFacW,iRec,myIter,myThid) |
122 |
|
CALL WRITE_FLD_XYZ_RS('hFacS.',hFacS,iRec,myIter,myThid) |
123 |
|
#endif /* NONLIN_FRSURF */ |
124 |
|
|
125 |
|
#else /* MULTIPLE_RECORD_STATE_FILES */ |
126 |
|
|
127 |
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) |
128 |
C - creates many files but for large configurations is easier to |
C - creates many files but for large configurations is easier to |
129 |
C transfer analyse a particular snap-shots |
C transfer analyse a particular snap-shots |
132 |
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'V.',suff,vVel,myIter,myThid) |
133 |
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'T.',suff,theta,myIter,myThid) |
134 |
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'S.',suff,salt,myIter,myThid) |
135 |
CALL WRITE_FLD_XY_RL( 'PS.',suff,cg2d_x,myIter,myThid) |
CALL WRITE_FLD_XY_RL('Eta.',suff,etaN,myIter,myThid) |
136 |
|
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
137 |
|
if ( buoyancyRelation .eq. 'OCEANIC' .and. |
138 |
|
& ( equationOfState .eq. 'JMD95P' |
139 |
|
& .or. equationOfState .eq. 'MDJWF' |
140 |
|
& .or. equationOfState .eq. 'UNESCO' ) ) then |
141 |
|
CALL WRITE_FLD_XYZ_RL( 'P.',suff,pressure,myIter,myThid) |
142 |
|
end if |
143 |
|
if ( buoyancyRelation .ne. 'ATMOSPHERIC' ) |
144 |
|
& CALL WRITE_FLD_XY_RL('PHL.',suff,phiHydLow,myIter,myThid) |
145 |
|
#ifdef ALLOW_PASSIVE_TRACER |
146 |
|
CALL WRITE_FLD_XYZ_RL( 'TR1.',suff,tr1,myIter,myThid) |
147 |
|
#endif |
148 |
#ifdef ALLOW_NONHYDROSTATIC |
#ifdef ALLOW_NONHYDROSTATIC |
149 |
IF (nonHydroStatic) THEN |
IF (nonHydroStatic) THEN |
150 |
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,cg3d_x,myIter,myThid) |
CALL WRITE_FLD_XYZ_RL( 'PNH.',suff,phi_nh,myIter,myThid) |
151 |
ENDIF |
ENDIF |
|
CALL WRITE_FLD_XYZ_RL( 'W.',suff,wVel,myIter,myThid) |
|
152 |
#endif /* ALLOW_NONHYDROSTATIC */ |
#endif /* ALLOW_NONHYDROSTATIC */ |
153 |
|
#ifdef NONLIN_FRSURF |
154 |
|
CALL WRITE_FLD_XYZ_RS('hFacC.',suff,hFacC,myIter,myThid) |
155 |
|
CALL WRITE_FLD_XYZ_RS('hFacW.',suff,hFacW,myIter,myThid) |
156 |
|
CALL WRITE_FLD_XYZ_RS('hFacS.',suff,hFacS,myIter,myThid) |
157 |
|
#endif /* NONLIN_FRSURF */ |
158 |
|
|
159 |
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
160 |
|
|
161 |
|
#ifdef ALLOW_PTRACERS |
162 |
|
IF (usePTRACERS) CALL PTRACERS_WRITE_STATE(myIter,myTime,myThid) |
163 |
|
#endif /* ALLOW_PTRACERS */ |
164 |
_END_MASTER( myThid ) |
_END_MASTER( myThid ) |
165 |
_BARRIER |
_BARRIER |
166 |
|
|