1 |
C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_write_state.F,v 1.15 2005/09/29 12:19:52 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PTRACERS_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: PTRACERS_WRITE_STATE |
8 |
|
9 |
C !INTERFACE: |
10 |
SUBROUTINE PTRACERS_WRITE_STATE( |
11 |
I myIter, myTime, myThid ) |
12 |
|
13 |
C !DESCRIPTION: |
14 |
C Calculates tendancy for passive tracers and integrates forward in |
15 |
C time. |
16 |
|
17 |
C !USES: |
18 |
IMPLICIT NONE |
19 |
#include "SIZE.h" |
20 |
#include "EEPARAMS.h" |
21 |
#include "PARAMS.h" |
22 |
#include "PTRACERS_SIZE.h" |
23 |
#include "PTRACERS.h" |
24 |
|
25 |
C !INPUT PARAMETERS: |
26 |
C myIter :: time-step number |
27 |
C myTime :: model time |
28 |
C myThid :: thread number |
29 |
INTEGER myIter |
30 |
_RL myTime |
31 |
INTEGER myThid |
32 |
CEOP |
33 |
|
34 |
#ifdef ALLOW_PTRACERS |
35 |
|
36 |
C === Functions ==== |
37 |
LOGICAL DIFFERENT_MULTIPLE |
38 |
EXTERNAL DIFFERENT_MULTIPLE |
39 |
INTEGER IO_ERRCOUNT |
40 |
EXTERNAL IO_ERRCOUNT |
41 |
|
42 |
C !LOCAL VARIABLES: |
43 |
C iTracer :: loop indices |
44 |
C suff :: character buffer for creating suffix in filename |
45 |
C iRec :: record number |
46 |
INTEGER iTracer |
47 |
CHARACTER*(MAX_LEN_MBUF) suff |
48 |
INTEGER iRec |
49 |
#ifdef ALLOW_MNC |
50 |
CHARACTER*(1) pf |
51 |
#endif |
52 |
|
53 |
IF ( DIFFERENT_MULTIPLE( PTRACERS_dumpFreq, myTime, deltaTClock ) |
54 |
& .OR. dumpInitAndLast.AND.( myTime.EQ.endTime .OR. |
55 |
& myTime.EQ.startTime ) |
56 |
& ) THEN |
57 |
|
58 |
C-- Write to files |
59 |
_BARRIER |
60 |
|
61 |
#ifdef ALLOW_MNC |
62 |
IF ( writeBinaryPrec .EQ. precFloat64 ) THEN |
63 |
pf(1:1) = 'D' |
64 |
ELSE |
65 |
pf(1:1) = 'R' |
66 |
ENDIF |
67 |
|
68 |
IF ( PTRACERS_snapshot_mnc ) THEN |
69 |
CALL MNC_CW_SET_UDIM('ptracers', -1, myThid) |
70 |
CALL MNC_CW_RL_W_S('D','ptracers',0,0,'T',myTime,myThid) |
71 |
CALL MNC_CW_SET_UDIM('ptracers', 0, myThid) |
72 |
CALL MNC_CW_I_W_S('I','ptracers',0,0,'iter',myIter,myThid) |
73 |
DO iTracer = 1,PTRACERS_numInUse |
74 |
CALL MNC_CW_RL_W(pf,'ptracers',0,0,PTRACERS_names(iTracer), |
75 |
& pTracer(1-OLx,1-OLy,1,1,1,iTracer),myThid) |
76 |
ENDDO |
77 |
ENDIF |
78 |
#endif /* ALLOW_MNC */ |
79 |
|
80 |
IF ( PTRACERS_snapshot_mdsio ) THEN |
81 |
|
82 |
C Loop over tracers |
83 |
DO iTracer=1,PTRACERS_numInUse |
84 |
|
85 |
#ifdef MULTIPLE_RECORD_STATE_FILES |
86 |
C Write each snap-shot as a record in a time-history file |
87 |
IF (PTRACERS_useRecords) THEN |
88 |
C Write each passive tracer as a record |
89 |
WRITE(suff,'(A)') 'PTRACERS' |
90 |
iRec = 1 + NINT( (myTime-startTime) / PTRACERS_dumpFreq ) |
91 |
iRec = (iRec-1)*PTRACERS_num + iTracer + 1 |
92 |
ELSE |
93 |
C Write each passive tracer in its own file |
94 |
WRITE(pref,'(A7,I2.2)') 'PTRACER',iTracer |
95 |
iRec = 1 + NINT( (myTime-startTime) / PTRACERS_dumpFreq ) |
96 |
ENDIF |
97 |
#else |
98 |
C Write each snap-shot as a new file with a 10-digit suffix to |
99 |
C indicate time-step number |
100 |
IF (PTRACERS_useRecords) THEN |
101 |
C Write each passive tracer as a record |
102 |
WRITE(suff,'(A,I10.10)') 'PTRACERS',myIter |
103 |
iRec=iTracer |
104 |
ELSE |
105 |
C Write each passive tracer in its own file |
106 |
WRITE(suff,'(A7,I2.2,A1,I10.10)') |
107 |
& 'PTRACER',iTracer,'.',myIter |
108 |
iRec=1 |
109 |
ENDIF |
110 |
#endif /* MULTIPLE_RECORD_STATE_FILES */ |
111 |
|
112 |
CALL WRITE_REC_XYZ_RL(suff, |
113 |
& pTracer(1-Olx,1-Oly,1,1,1,iTracer),iRec,myIter,myThid) |
114 |
|
115 |
C End of tracer loop |
116 |
ENDDO |
117 |
|
118 |
ENDIF |
119 |
|
120 |
_BARRIER |
121 |
C-- Writing to files: end |
122 |
ENDIF |
123 |
|
124 |
#endif /* ALLOW_PTRACERS */ |
125 |
|
126 |
RETURN |
127 |
END |