/[MITgcm]/MITgcm/pkg/diagnostics/diagstats_set_regions.F
ViewVC logotype

Contents of /MITgcm/pkg/diagnostics/diagstats_set_regions.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download)
Tue Oct 17 18:56:31 2006 UTC (17 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, mitgcm_mapl_00, checkpoint58u_post, checkpoint58w_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint58r_post, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint58x_post, checkpoint58t_post, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint58q_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint59j, checkpoint59, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint58v_post, checkpoint58s_post, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
Changes since 1.3: +4 -2 lines
clean-up multi-threaded problems (reported by debugger tcheck on ACES)

1 C $Header: /u/gcmpack/MITgcm/pkg/diagnostics/diagstats_set_regions.F,v 1.3 2006/07/31 16:26:32 jmc Exp $
2 C $Name: $
3
4 #include "DIAG_OPTIONS.h"
5
6 CBOP
7 C !ROUTINE: DIAGSTATS_SET_REGIONS
8 C !INTERFACE:
9 SUBROUTINE DIAGSTATS_SET_REGIONS( myThid )
10
11 C !DESCRIPTION: \bv
12 C *==================================================================
13 C | S/R DIAGSTATS_SET_REGIONS
14 C | o set region-mask for regional statistics diagnostics
15 C *==================================================================
16 C \ev
17
18 C !USES:
19 IMPLICIT NONE
20
21 C == Global variables ===
22 #include "EEPARAMS.h"
23 #include "SIZE.h"
24 #include "PARAMS.h"
25 #include "DIAGNOSTICS_SIZE.h"
26 #include "DIAGSTATS_REGIONS.h"
27
28 C !INPUT/OUTPUT PARAMETERS:
29 C == Routine arguments ==
30 C myThid - Thread number for this instance of the routine.
31 INTEGER myThid
32 CEOP
33
34 C !LOCAL VARIABLES:
35 C == Local variables ==
36 CHARACTER*(MAX_LEN_MBUF) msgBuf
37 INTEGER iLen
38 INTEGER i, j
39 INTEGER bi, bj
40 #ifdef DIAGSTATS_REGION_MASK
41 CHARACTER*(MAX_LEN_MBUF) tmpBuf
42 INTEGER ioUnit
43 INTEGER k, nbReg
44 _RS tmpVar(1-OLx:sNx+Olx,1-Oly:sNy+Oly,nSx,nSy)
45 COMMON / SET_REGIONS_LOCAL / tmpVar
46 #else
47 LOGICAL flag
48 #endif
49 INTEGER ILNBLNK
50 EXTERNAL ILNBLNK
51
52 #ifdef DIAGSTATS_REGION_MASK
53
54 C-- Initialize region-mask array to zero:
55 DO bj = myByLo(myThid), myByHi(myThid)
56 DO bi = myBxLo(myThid), myBxHi(myThid)
57 DO k=1,sizRegMsk
58 DO j=1-Oly,sNy+Oly
59 DO i=1-Olx,sNx+Olx
60 diagSt_regMask(i,j,k,bi,bj) = 0.
61 ENDDO
62 ENDDO
63 ENDDO
64 ENDDO
65 ENDDO
66 ioUnit = -1
67
68 _BEGIN_MASTER( myThid )
69 ioUnit = standardMessageUnit
70 C-- Check size & parameter first:
71 IF ( (diagSt_regMaskFile.NE.' ' .AND. nSetRegMskFile.EQ.0)
72 & .OR.(diagSt_regMaskFile.EQ.' ' .AND. nSetRegMskFile.GT.0) ) THEN
73 WRITE(msgBuf,'(2A)') 'DIAGSTATS_SET_REGIONS:',
74 & ' regMaskFile and nSetRegMskFile Not consistent'
75 CALL PRINT_ERROR( msgBuf , myThid )
76 STOP 'ABNORMAL END: S/R DIAGSTATS_SET_REGIONS'
77 ENDIF
78 IF ( nSetRegMskFile.GT.sizRegMsk ) THEN
79 WRITE(msgBuf,'(2A,I4,A,I4)') 'DIAGSTATS_SET_REGIONS:',
80 & ' regMaskFile set-index number=', nSetRegMskFile,
81 & ' exceeds sizRegMsk=', sizRegMsk
82 CALL PRINT_ERROR( msgBuf , myThid )
83 STOP 'ABNORMAL END: S/R DIAGSTATS_SET_REGIONS'
84 ENDIF
85 _END_MASTER( myThid )
86
87 C-- Read region-mask from file
88 IF ( diagSt_regMaskFile .NE. ' ' ) THEN
89 _BARRIER
90 iLen = ILNBLNK(diagSt_regMaskFile)
91 IF (ioUnit.GE.0 ) WRITE(ioUnit,'(2A)')
92 & ' DIAGSTATS_SET_REGIONS: start reading region-mask file: ',
93 & diagSt_regMaskFile(1:iLen)
94 DO k=1,nSetRegMskFile
95 C _BEGIN_MASTER( myThid )
96 IF (ioUnit.GE.0 ) WRITE(ioUnit,'(A,I3)')
97 & ' DIAGSTATS_SET_REGIONS: reading set k=',k
98 CALL READ_REC_XY_RS( diagSt_regMaskFile, tmpVar, k,
99 & nIter0, myThid )
100 IF (ioUnit.GE.0 ) WRITE(ioUnit,'(A,I3,A)')
101 & ' DIAGSTATS_SET_REGIONS: set k=',k,' <= done'
102 C _END_MASTER( myThid )
103 _EXCH_XY_RS( tmpVar, myThid )
104 DO bj = myByLo(myThid), myByHi(myThid)
105 DO bi = myBxLo(myThid), myBxHi(myThid)
106 DO j=1-Oly,sNy+Oly
107 DO i=1-Olx,sNx+Olx
108 diagSt_regMask(i,j,k,bi,bj) = tmpVar(i,j,bi,bj)
109 ENDDO
110 ENDDO
111 ENDDO
112 ENDDO
113 C- end of k loop
114 ENDDO
115 ENDIF
116
117 C-- Other way to define regions (e.g., latitude bands):
118 C set corresponding set-index of the region-mask array,
119 C starting from nSetRegMskFile+1 up to nSetRegMask
120 C note: for now, empty !
121 _BEGIN_MASTER( myThid )
122 nSetRegMask = nSetRegMskFile
123 _END_MASTER( myThid )
124
125 C-- Region Identificator arrays
126 C for now, directly filled when reading data.diagnostics
127
128 _BEGIN_MASTER( myThid )
129 C-- Check defined regions
130 nbReg = 0
131 DO j=1,nRegions
132 C- check for valid region-mask index:
133 IF ( diagSt_kRegMsk(j).LT.0 .OR.
134 & diagSt_kRegMsk(j).GT.sizRegMsk ) THEN
135 WRITE(msgBuf,'(2A,I3,A,I4)') 'DIAGSTATS_SET_REGIONS: ',
136 & '(region',j,') invalid region-mask index :',diagSt_kRegMsk(j)
137 CALL PRINT_ERROR( msgBuf , myThid )
138 STOP 'ABNORMAL END: S/R DIAGSTATS_SET_REGIONS'
139 C- check for unset region-mask:
140 ELSEIF ( diagSt_kRegMsk(j).GT.nSetRegMask ) THEN
141 WRITE(msgBuf,'(2A,I3,A,I3,A)') 'DIAGSTATS_SET_REGIONS: ',
142 & 'region',j,' , kRegMsk=', diagSt_kRegMsk(j),
143 & ' <- has not been set !'
144 CALL PRINT_ERROR( msgBuf , myThid )
145 STOP 'ABNORMAL END: S/R DIAGSTATS_SET_REGIONS'
146 ELSEIF ( diagSt_kRegMsk(j).NE.0 ) THEN
147 nbReg = nbReg + 1
148 C- check for empty region: build temp mask 0 / 1 :
149 c k = diagSt_kRegMsk(j)
150 c IF ( diagSt_regMask(i,j,k,bi,bj).EQ.diagSt_vRegMsk(j) ) THEN
151 c tmpVar(i,j,bi,bj) = 1.
152 c ELSE
153 c tmpVar(i,j,bi,bj) = 0.
154 c ELSE
155 C- print region mask:
156 c IF ( debugLevel.GE.debLevA ) THEN
157 c WRITE(msgBuf,'(A,I3,A)') 'DIAGSTAT Region',j,' mask:'
158 c iLen = ILNBLNK(msgBuf)
159 c CALL PLOT_FIELD_XYRS( tmpVar, msgBuf(1:iLen), -1, myThid )
160 c ENDIF
161 ENDIF
162 ENDDO
163
164 C- Global statistics (region # 0) <- done in diagnostics_readparams
165 c diagSt_kRegMsk(0) = 1
166 c diagSt_vRegMsk(0) = 0.
167
168
169 WRITE(msgBuf,'(A,I4,A)') 'DIAGSTATS_SET_REGIONS: define',
170 & nbReg,' regions:'
171 iLen = ILNBLNK(msgBuf)
172 DO j=1,nRegions
173 IF ( diagSt_kRegMsk(j).NE.0 ) THEN
174 iLen = MIN( iLen, MAX_LEN_MBUF -3 )
175 tmpBuf(1:iLen) = msgBuf(1:iLen)
176 WRITE(msgBuf,'(A,I3)') tmpBuf(1:iLen),j
177 iLen = iLen+3
178 ENDIF
179 ENDDO
180 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
181 & SQUEEZE_RIGHT , myThid)
182 WRITE(msgBuf,'(2A)')
183 & '------------------------------------------------------------'
184 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
185 & SQUEEZE_RIGHT , myThid)
186
187 _END_MASTER( myThid )
188
189 #else /* DIAGSTATS_REGION_MASK */
190
191 C-- Initialize region-mask array to zero:
192 DO bj = myByLo(myThid), myByHi(myThid)
193 DO bi = myBxLo(myThid), myBxHi(myThid)
194 c DO j=1-Oly,sNy+Oly
195 c DO i=1-Olx,sNx+Olx
196 DO j=1-Oly,1-Oly
197 DO i=1-Olx,1-Olx
198 diagSt_regMask(i,j,1,bi,bj) = 0.
199 ENDDO
200 ENDDO
201 ENDDO
202 ENDDO
203
204 _BEGIN_MASTER( myThid )
205 C-- Check parameter consitency:
206 flag = .FALSE.
207 DO j=1,nRegions
208 flag = flag .OR. diagSt_kRegMsk(j).NE.0
209 & .OR. diagSt_vRegMsk(j).NE.0.
210 ENDDO
211 iLen = ILNBLNK(diagSt_regMaskFile)
212 IF ( flag .OR. iLen.GE.1 .OR. nSetRegMskFile.NE.0 ) THEN
213 WRITE(msgBuf,'(2A)') 'DIAGSTATS_SET_REGIONS:',
214 & ' #define DIAGSTATS_REGION_MASK missing in DIAG_OPTIONS.h'
215 CALL PRINT_ERROR( msgBuf , myThid )
216 STOP 'ABNORMAL END: S/R DIAGSTATS_SET_REGIONS'
217 ENDIF
218
219 WRITE(msgBuf,'(A)') 'DIAGSTATS_SET_REGIONS: define no region'
220 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
221 & SQUEEZE_RIGHT , myThid)
222 WRITE(msgBuf,'(2A)')
223 & '------------------------------------------------------------'
224 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
225 & SQUEEZE_RIGHT , myThid)
226
227 _END_MASTER( myThid )
228
229 #endif /* DIAGSTATS_REGION_MASK */
230
231 RETURN
232 END

  ViewVC Help
Powered by ViewVC 1.1.22