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

Diff of /MITgcm/pkg/diagnostics/diagnostics_utils.F

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

revision 1.5 by molod, Thu Feb 26 22:20:36 2004 UTC revision 1.31 by jmc, Sun Jun 12 19:08:21 2011 UTC
# Line 1  Line 1 
1        subroutine getdiag (myThid,lev,ipoint,undef,qtmp)  C $Header$
2  C***********************************************************************          C $Name$
 C  PURPOSE                                                                        
 C     Retrieve averaged model diagnostic  
 C  INPUT:                                                                        
 C     lev ..... Diagnostic LEVEL  
 C  ipoint ..... DIAGNOSTIC NUMBER FROM MENU                                      
 C   undef ..... UNDEFINED VALUE                                                  
 C      bi ..... X-direction process(or) number  
 C      bj ..... Y-direction process(or) number  
 C                                                                                
 C  OUTPUT:                                                                        
 C    qtmp ..... AVERAGED DIAGNOSTIC QUANTITY  
 C                                                                                
 C***********************************************************************          
       implicit none  
3    
4    #include "DIAG_OPTIONS.h"
5    
6    C--   File diagnostics_utils.F: General purpose support routines
7    C--    Contents:
8    C--    o DIAGNOSTICS_COUNT
9    C--    o DIAGNOSTICS_GET_DIAG
10    C--    o DIAGNOSTICS_GET_POINTERS
11    C--    o DIAGNOSTICS_SETKLEV
12    C--    o DIAGS_GET_PARMS_I (Function)
13    C--    o DIAGS_MK_UNITS (Function)
14    C--    o DIAGS_MK_TITLE (Function)
15    
16    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
17    
18    CBOP 0
19    C     !ROUTINE: DIAGNOSTICS_COUNT
20    C     !INTERFACE:
21          SUBROUTINE DIAGNOSTICS_COUNT( diagName,
22         I                              biArg, bjArg, myThid )
23    
24    C     !DESCRIPTION:
25    C***********************************************************************
26    C   routine to increment the diagnostic counter only
27    C***********************************************************************
28    C     !USES:
29          IMPLICIT NONE
30    
31    C     == Global variables ===
32  #include "EEPARAMS.h"  #include "EEPARAMS.h"
 #include "CPP_OPTIONS.h"  
33  #include "SIZE.h"  #include "SIZE.h"
34    #include "DIAGNOSTICS_SIZE.h"
35    #include "DIAGNOSTICS.h"
36    
37  #ifdef ALLOW_FIZHI  C     !INPUT PARAMETERS:
38  #include "fizhi_SIZE.h"  C***********************************************************************
39  #else  C  Arguments Description
40         integer Nrphys  C  ----------------------
41         parameter (Nrphys=1)  C     diagName :: name of diagnostic to increment the counter
42  #endif  C     biArg    :: X-direction tile number, or 0 if called outside bi,bj loops
43    C     bjArg    :: Y-direction tile number, or 0 if called outside bi,bj loops
44  #include "diagnostics_SIZE.h"  C     myThid   :: my thread Id number
45  #include "diagnostics.h"  C***********************************************************************
46          CHARACTER*8 diagName
47        integer myThid,lev,ipoint        INTEGER biArg, bjArg
48        _RL undef        INTEGER myThid
49        _RL qtmp(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nr+Nrphys,Nsx,Nsy)  CEOP
50    
51    C     !LOCAL VARIABLES:
52    C ===============
53          INTEGER m, n
54          INTEGER bi, bj
55          INTEGER ipt, ndId
56    c     CHARACTER*(MAX_LEN_MBUF) msgBuf
57    
58          IF ( biArg.EQ.0 .AND. bjArg.EQ.0 ) THEN
59            bi = myBxLo(myThid)
60            bj = myByLo(myThid)
61          ELSE
62            bi = MIN(biArg,nSx)
63            bj = MIN(bjArg,nSy)
64          ENDIF
65    
66        _RL factor  C--   Run through list of active diagnostics to find which counter
67        integer i,j,ipnt,klev  C     to increment (needs to be a valid & active diagnostic-counter)
68        integer bi,bj        DO n=1,nLists
69           DO m=1,nActive(n)
70            IF ( diagName.EQ.flds(m,n) .AND. idiag(m,n).GT.0 ) THEN
71             ipt = idiag(m,n)
72             IF (ndiag(ipt,bi,bj).GE.0) THEN
73              ndId = jdiag(m,n)
74              ipt = ipt + pdiag(n,bi,bj)*kdiag(ndId)
75    C-    Increment the counter for the diagnostic
76              IF ( biArg.EQ.0 .AND. bjArg.EQ.0 ) THEN
77               DO bj=myByLo(myThid), myByHi(myThid)
78                DO bi=myBxLo(myThid), myBxHi(myThid)
79                 ndiag(ipt,bi,bj) = ndiag(ipt,bi,bj) + 1
80                ENDDO
81               ENDDO
82              ELSE
83                 ndiag(ipt,bi,bj) = ndiag(ipt,bi,bj) + 1
84              ENDIF
85    C-    Increment is done
86             ENDIF
87            ENDIF
88           ENDDO
89          ENDDO
90    
91        if (ipoint.lt.1) go to 999        RETURN
92          END
93    
94    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
95    
96    CBOP 0
97    C     !ROUTINE: DIAGNOSTICS_GET_DIAG
98    
99    C     !INTERFACE:
100          SUBROUTINE DIAGNOSTICS_GET_DIAG(
101         I                    kl, undefRL,
102         O                    qtmp,
103         I                    ndId, mate, ip, im, bi, bj, myThid )
104    
105        klev = kdiag(ipoint)  C     !DESCRIPTION:
106        if(klev.ge.lev) then  C     Retrieve time-averaged (or snap-shot) diagnostic field
       ipnt = idiag(ipoint) + lev - 1  
       factor = 1.0  
       if(ndiag(ipoint).ne.0) factor = 1.0/ndiag(ipoint)  
   
       do bj=myByLo(myThid), myByHi(myThid)  
       do bi=myBxLo(myThid), myBxHi(myThid)  
   
       do j = 1,sNy  
       do i = 1,sNx  
        if( qdiag(i,j,ipnt,bi,bj).ne.undef ) then  
         qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj)*factor  
        else  
         qtmp(i,j,lev,bi,bj) = undef  
        endif  
       enddo  
       enddo  
   
       enddo  
       enddo  
   
       endif  
   
  999  return  
       end  
   
       subroutine getdiag2 (myThid,lev,ipoint,undef,qtmp)  
 C***********************************************************************          
 C  PURPOSE                                                                        
 C     Retrieve averaged model diagnostic  
 C  INPUT:                                                                        
 C     lev ..... Diagnostic LEVEL  
 C  ipoint ..... DIAGNOSTIC NUMBER FROM MENU                                      
 C   undef ..... UNDEFINED VALUE                                                  
 C                                                                                
 C  OUTPUT:                                                                        
 C    qtmp ..... AVERAGED DIAGNOSTIC QUANTITY  
 C                                                                                
 C***********************************************************************          
       implicit none  
107    
108    C     !USES:
109          IMPLICIT NONE
110  #include "EEPARAMS.h"  #include "EEPARAMS.h"
 #include "CPP_OPTIONS.h"  
111  #include "SIZE.h"  #include "SIZE.h"
112    #include "DIAGNOSTICS_SIZE.h"
113    #include "DIAGNOSTICS.h"
114    
115    C     !INPUT PARAMETERS:
116    C     kl      :: level selection: >0 : single selected lev ; =0 : all kdiag levels
117    C     undefRL :: undefined "_RL" type value
118    C     ndId    :: diagnostic Id number (in available diagnostics list)
119    C     mate    :: counter diagnostic number if any ; 0 otherwise
120    C     ip      :: pointer to storage array location for diag.
121    C     im      :: pointer to storage array location for mate
122    C     bi      :: X-direction tile number
123    C     bj      :: Y-direction tile number
124    C     myThid  :: my thread Id number
125          INTEGER kl
126          _RL undefRL
127          INTEGER ndId, mate, ip, im
128          INTEGER bi, bj, myThid
129    
130    C     !OUTPUT PARAMETERS:
131    C     qtmp    :: time-averaged (or snap-shot) diagnostic field
132          _RL qtmp(1-OLx:sNx+OLx,1-OLy:sNy+OLy,*)
133    CEOP
134    
135    C     !LOCAL VARIABLES:
136          _RL factor
137          INTEGER i, j, ipnt, ipCt
138          INTEGER k, kd, km, kLev
139    
140          IF (ndId.GE.1) THEN
141           kLev = kdiag(ndId)
142           IF ( kl.GE.1 .AND. kl.LE.kLev ) THEN
143            kLev = 1
144           ELSEIF ( kl.NE.0 ) THEN
145            kLev = 0
146           ENDIF
147    
148           DO k = 1,kLev
149            kd = k
150            IF ( kl.GE.1 ) kd = kl
151    
152            IF ( mate.EQ.0 ) THEN
153    C-      No counter diagnostics => average = Sum / ndiag :
154    
155              ipnt = ip + kd - 1
156              factor = FLOAT(ndiag(ip,bi,bj))
157              IF (ndiag(ip,bi,bj).NE.0) factor = 1. _d 0 / factor
158    
159  #ifdef ALLOW_FIZHI  #ifdef ALLOW_FIZHI
160  #include "fizhi_SIZE.h"            DO j = 1,sNy+1
161  #else              DO i = 1,sNx+1
162         integer Nrphys                IF ( qdiag(i,j,ipnt,bi,bj) .LE. undefRL ) THEN
163         parameter (Nrphys=1)                  qtmp(i,j,k) = qdiag(i,j,ipnt,bi,bj)*factor
164  #endif                ELSE
165                    qtmp(i,j,k) = undefRL
166  #include "diagnostics_SIZE.h"                ENDIF
167  #include "diagnostics.h"              ENDDO
168              ENDDO
169        integer myThid,lev,ipoint  #else /* ALLOW_FIZHI */
170        _RL undef            DO j = 1,sNy+1
171        _RL qtmp(1-OLx:sNx+Olx,1-Oly:sNy+Oly,Nr+Nrphys,Nsx,Nsy)              DO i = 1,sNx+1
172                  qtmp(i,j,k) = qdiag(i,j,ipnt,bi,bj)*factor
173        integer i,j,ipnt,klev              ENDDO
174        integer bi,bj            ENDDO
175    #endif /* ALLOW_FIZHI */
176        if (ipoint.lt.1) go to 999  
177            ELSE
178        klev = kdiag(ipoint)  C-      With counter diagnostics => average = Sum / counter:
179        if(klev.ge.lev) then  
180        ipnt = idiag(ipoint) + lev - 1            ipnt = ip + kd - 1
181              km = MIN(kd,kdiag(mate))
182        do bj=myByLo(myThid), myByHi(myThid)            ipCt = im + km - 1
183        do bi=myBxLo(myThid), myBxHi(myThid)            DO j = 1,sNy+1
184                DO i = 1,sNx+1
185        do j = 1,sNy                IF ( qdiag(i,j,ipCt,bi,bj) .NE. 0. ) THEN
186        do i = 1,sNx                  qtmp(i,j,k) = qdiag(i,j,ipnt,bi,bj)
187         if( qdiag(i,j,ipnt,bi,bj).ne.undef ) then       &                      / qdiag(i,j,ipCt,bi,bj)
188          qtmp(i,j,lev,bi,bj) = qdiag(i,j,ipnt,bi,bj)                ELSE
189         else                  qtmp(i,j,k) = undefRL
190          qtmp(i,j,lev,bi,bj) = undef                ENDIF
191         endif              ENDDO
192        enddo            ENDDO
193        enddo  
194            ENDIF
195        enddo         ENDDO
196        enddo        ENDIF
197    
198        endif        RETURN
199          END
200   999  return  
201        end  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
202        subroutine clrindx (myThid,listnum)  
203  C***********************************************************************  CBOP 0
204  C  C     !ROUTINE: DIAGNOSTICS_GET_POINTERS
205  C  PURPOSE  C     !INTERFACE:
206  C     DRIVER TO CLEAR DIAGNOSTICS SPECIFIED IN DIAGNOSTIC INDEX LIST        SUBROUTINE DIAGNOSTICS_GET_POINTERS(
207  C       I                       diagName, listId,
208  C  ARGUMENT DESCRIPTION       O                       ndId, ip,
209  C     listnum ....  diagnostics list number       I                       myThid )
210  C  
211  C***********************************************************************  C     !DESCRIPTION:
212    C     *================================================================*
213    C     | o Returns the diagnostic Id number and diagnostic
214    C     |   pointer to storage array for a specified diagnostic.
215    C     *================================================================*
216    C     | Note: A diagnostics field can be stored multiple times
217    C     |       (for different output frequency,phase, ...).
218    C     | operates in 2 ways:
219    C     | o listId =0 => find 1 diagnostics Id & pointer which name matches.
220    C     | o listId >0 => find the unique diagnostic Id & pointer with
221    C     |      the right name and same output time as "listId" output-list
222    C     | o return ip=0 if did not find the right diagnostic;
223    C     |   (ndId <>0 if diagnostic exist but output time does not match)
224    C     *================================================================*
225    
226        implicit none  C     !USES:
227          IMPLICIT NONE
228  #include "EEPARAMS.h"  #include "EEPARAMS.h"
 #include "CPP_OPTIONS.h"  
229  #include "SIZE.h"  #include "SIZE.h"
230    #include "DIAGNOSTICS_SIZE.h"
231    #include "DIAGNOSTICS.h"
232    
233  #ifdef ALLOW_FIZHI  C     !INPUT PARAMETERS:
234  #include "fizhi_SIZE.h"  C     diagName :: diagnostic identificator name (8 characters long)
235  #else  C     listId   :: list number that specify the output frequency
236         integer Nrphys  C     myThid   :: my Thread Id number
237         parameter (Nrphys=1)  C     !OUTPUT PARAMETERS:
238  #endif  C     ndId     :: diagnostics  Id number (in available diagnostics list)
239    C     ip       :: diagnostics  pointer to storage array
240  #include "diagnostics_SIZE.h"  
241  #include "diagnostics.h"  
242          CHARACTER*8 diagName
243        integer myThid, listnum        INTEGER listId
244          INTEGER ndId, ip
245        integer m, n        INTEGER myThid
246        character*8 parms1  CEOP
247        character*1 parse1(8)  
248        character*3 mate_index  C     !LOCAL VARIABLES:
249        integer mate        INTEGER n,m
250    
251        equivalence (     parms1 , parse1(1) )        ip   = 0
252        equivalence ( mate_index , parse1(6) )        ndId = 0
253    
254        do n=1,nfields(listnum)        IF ( listId.LE.0 ) THEN
255         do m=1,ndiagt  C--   select the 1rst one which name matches:
256          if( flds(n,listnum).eq.cdiag(m) .and. idiag(m).ne.0 ) then  
257           call clrdiag (myThid,m)  C-    search for this diag. in the active 2D/3D diagnostics list
258            DO n=1,nLists
259  c Check for Counter Diagnostic           DO m=1,nActive(n)
260  c ----------------------------             IF ( ip.EQ.0 .AND. diagName.EQ.flds(m,n)
261           parms1 =  gdiag(m)       &                  .AND. idiag(m,n).NE.0 ) THEN
262           if( parse1(5).eq.'C' ) then              ip   = ABS(idiag(m,n))
263            read (mate_index,100) mate              ndId = jdiag(m,n)
264            call clrdiag (myThid,mate)             ENDIF
265           endif           ENDDO
266          endif          ENDDO
267         enddo  
268        enddo        ELSEIF ( listId.LE.nLists ) THEN
269                      C--   select the unique diagnostic with output-time identical to listId
270    100 format(i3)  
271        RETURN        C-    search for this diag. in the active 2D/3D diagnostics list
272        END                    DO n=1,nLists
273             IF ( ip.EQ.0
274         &        .AND. freq(n) .EQ. freq(listId)
275        subroutine clrdiag (myThid,index)       &        .AND. phase(n).EQ.phase(listId)
276  C***********************************************************************               &        .AND. averageFreq(n) .EQ.averageFreq(listId)
277  C  PURPOSE                                                                             &        .AND. averagePhase(n).EQ.averagePhase(listId)
278  C     ZERO OUT MODEL DIAGNOSTIC ARRAY ELEMENTS       &        .AND. averageCycle(n).EQ.averageCycle(listId)
279  C***********************************************************************               &      ) THEN
280                                                                                              DO m=1,nActive(n)
281        implicit none             IF ( ip.EQ.0 .AND. diagName.EQ.flds(m,n)
282         &                  .AND. idiag(m,n).NE.0 ) THEN
283                ip   = ABS(idiag(m,n))
284                ndId = jdiag(m,n)
285               ENDIF
286              ENDDO
287             ELSEIF ( ip.EQ.0 ) THEN
288              DO m=1,nActive(n)
289               IF ( ip.EQ.0 .AND. diagName.EQ.flds(m,n)
290         &                  .AND. idiag(m,n).NE.0 ) THEN
291                ndId = jdiag(m,n)
292               ENDIF
293              ENDDO
294             ENDIF
295            ENDDO
296    
297          ELSE
298            STOP 'DIAGNOSTICS_GET_POINTERS: invalid listId number'
299          ENDIF
300    
301          RETURN
302          END
303    
304    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
305    
306    CBOP 0
307    C     !ROUTINE: DIAGNOSTICS_SETKLEV
308    
309    C     !INTERFACE:
310          SUBROUTINE DIAGNOSTICS_SETKLEV(
311         I                                diagName, nLevDiag, myThid )
312    
313    C     !DESCRIPTION:
314    C     *==========================================================*
315    C     | S/R DIAGNOSTICS_SETKLEV
316    C     | o Define explicitly the number of level (stored in kdiag)
317    C     |   of a diagnostic field. For most diagnostics, the number
318    C     |   of levels is derived (in S/R SET_LEVELS) from gdiag(10)
319    C     |   but occasionally one may want to set it explicitly.
320    C     *==========================================================*
321    
322    C     !USES:
323          IMPLICIT NONE
324  #include "EEPARAMS.h"  #include "EEPARAMS.h"
 #include "CPP_OPTIONS.h"  
325  #include "SIZE.h"  #include "SIZE.h"
326    #include "DIAGNOSTICS_SIZE.h"
327    #include "DIAGNOSTICS.h"
328    
329  #ifdef ALLOW_FIZHI  C     !INPUT PARAMETERS:
330  #include "fizhi_SIZE.h"  C     diagName  :: diagnostic identificator name (8 characters long)
331  #else  C     nLevDiag  :: number of level to set for this diagnostics field
332         integer Nrphys  C     myThid    :: my Thread Id number
333         parameter (Nrphys=1)        CHARACTER*8  diagName
334  #endif        INTEGER nLevDiag
335          INTEGER myThid
336  #include "diagnostics_SIZE.h"  CEOP
337  #include "diagnostics.h"  
338    C     !LOCAL VARIABLES:
339        integer myThid, index        CHARACTER*(MAX_LEN_MBUF) msgBuf
340          INTEGER n, ndId
341        integer bi,bj  
342        integer i,j,k  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
343    
344  C **********************************************************************                _BEGIN_MASTER( myThid)
345  C ****              SET DIAGNOSTIC AND COUNTER TO ZERO              ****          
346  C **********************************************************************          C--   Check if this S/R is called from the right place ;
347                                                                                    C     needs to be after DIAGNOSTICS_INIT_EARLY and before DIAGNOSTICS_INIT_FIXED
348        do bj=myByLo(myThid), myByHi(myThid)        IF ( .NOT.settingDiags ) THEN
349        do bi=myBxLo(myThid), myBxHi(myThid)          WRITE(msgBuf,'(4A,I5)') 'DIAGNOSTICS_SETKLEV: ',
350         do k = 1,kdiag(index)       &     'diagName="', diagName, '" , nLevDiag=', nLevDiag
351          do j = 1,sNy          CALL PRINT_ERROR( msgBuf, myThid )
352          do i = 1,sNx          WRITE(msgBuf,'(2A)') 'DIAGNOSTICS_SETKLEV: ',
353           qdiag(i,j,idiag(index)+k-1,bi,bj) = 0.0       &     '<== called from the WRONG place, i.e.'
354          enddo          CALL PRINT_ERROR( msgBuf, myThid )
355          enddo          WRITE(msgBuf,'(2A)') 'DIAGNOSTICS_SETKLEV: ',
356         enddo       &     'outside diagnostics setting section = from'
357        enddo          CALL PRINT_ERROR( msgBuf, myThid )
358        enddo          WRITE(msgBuf,'(2A)') 'DIAGNOSTICS_SETKLEV: ',
359         &     '   Diag_INIT_EARLY down to Diag_INIT_FIXED'
360            CALL PRINT_ERROR( msgBuf, myThid )
361            STOP 'ABNORMAL END: S/R DIAGNOSTICS_SETKLEV'
362          ENDIF
363    
364        ndiag(index) = 0  C--   Find this diagnostics in the list of available diag.
365          ndId = 0
366          DO n = 1,ndiagt
367            IF ( diagName.EQ.cdiag(n) ) THEN
368              ndId = n
369            ENDIF
370          ENDDO
371          IF ( ndId.EQ.0 ) THEN
372            WRITE(msgBuf,'(4A)') 'DIAGNOSTICS_SETKLEV: ',
373         &     'diagName="', diagName, '" not known.'
374            CALL PRINT_ERROR( msgBuf, myThid )
375            STOP 'ABNORMAL END: S/R DIAGNOSTICS_SETKLEV'
376          ENDIF
377    
378        return  C-    Optional level number diagnostics (X): set number of levels
379        end        IF ( kdiag(ndId).EQ.0
380         &   .AND. gdiag(ndId)(10:10).EQ.'X' ) THEN
381            kdiag(ndId) = nLevDiag
382          ELSEIF ( kdiag(ndId).EQ.nLevDiag
383         &   .AND. gdiag(ndId)(10:10).EQ.'X' ) THEN
384    C-    level number already set to same value: send warning
385            WRITE(msgBuf,'(4A,I5)') '** WARNING ** DIAGNOSTICS_SETKLEV: ',
386         &     'diagName="', diagName, '" , nLevDiag=', nLevDiag
387            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
388         &                      SQUEEZE_RIGHT , myThid )
389            WRITE(msgBuf,'(2A,I5,A)')'** WARNING ** DIAGNOSTICS_SETKLEV:',
390         &     ' level Nb (=', kdiag(ndId), ') already set.'
391            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
392         &                      SQUEEZE_RIGHT , myThid )
393          ELSEIF ( gdiag(ndId)(10:10).EQ.'X' ) THEN
394    C-    level number already set to a different value: do not reset but stop
395            WRITE(msgBuf,'(4A,I5)') 'DIAGNOSTICS_SETKLEV: ',
396         &     'diagName="', diagName, '" , nLevDiag=', nLevDiag
397            CALL PRINT_ERROR( msgBuf, myThid )
398            WRITE(msgBuf,'(2A,I5,3A)') 'DIAGNOSTICS_SETKLEV: ',
399         &     'level Nb already set to', kdiag(ndId), ' => STOP'
400            CALL PRINT_ERROR( msgBuf, myThid )
401          ELSE
402    C-    for now, do nothing but just send a warning
403            WRITE(msgBuf,'(4A,I5)') '** WARNING ** DIAGNOSTICS_SETKLEV: ',
404         &     'diagName="', diagName, '" , nLevDiag=', nLevDiag
405            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
406         &                      SQUEEZE_RIGHT , myThid )
407            WRITE(msgBuf,'(2A,I5,3A)') '** WARNING ** will set level Nb',
408         &     ' from diagCode(ndId=', ndId, ')="', gdiag(ndId)(1:10), '"'
409            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
410         &                      SQUEEZE_RIGHT , myThid )
411            WRITE(msgBuf,'(4A)') '** WARNING ** DIAGNOSTICS_SETKLEV',
412         &     '("', diagName, '") <== Ignore this call.'
413            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
414         &                      SQUEEZE_RIGHT , myThid )
415          ENDIF
416    
417        subroutine setdiag (myThid,num,ndiagmx)        _END_MASTER( myThid)
 C***********************************************************************  
 C  
 C  PURPOSE  
 C     SET POINTER LOCATIONS, NAMES, LEVELS and TITLES FOR DIAGNOSTIC NUM  
 C  
 C***********************************************************************  
418    
419        implicit none        RETURN
420  #include "CPP_OPTIONS.h"        END
421    
422    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
423    
424    CBOP 0
425    C     !ROUTINE: DIAGS_GET_PARMS_I
426    
427    C     !INTERFACE:
428          INTEGER FUNCTION DIAGS_GET_PARMS_I(
429         I                            parName, myThid )
430    
431    C     !DESCRIPTION:
432    C     *==========================================================*
433    C     | FUNCTION DIAGS_GET_PARMS_I
434    C     | o Return the value of integer parameter
435    C     |   from one of the DIAGNOSTICS.h common blocs
436    C     *==========================================================*
437    
438    C     !USES:
439          IMPLICIT NONE
440    #include "EEPARAMS.h"
441  #include "SIZE.h"  #include "SIZE.h"
442    #include "DIAGNOSTICS_SIZE.h"
443    #include "DIAGNOSTICS.h"
444    
445  #ifdef ALLOW_FIZHI  C     !INPUT PARAMETERS:
446  #include "fizhi_SIZE.h"  C     parName   :: string used to identify which parameter to get
447  #else  C     myThid    :: my Thread Id number
448         integer Nrphys        CHARACTER*(*) parName
449         parameter (Nrphys=1)        INTEGER myThid
450  #endif  CEOP
451    
452  #include "diagnostics_SIZE.h"  C     !LOCAL VARIABLES:
453  #include "diagnostics.h"        CHARACTER*(MAX_LEN_MBUF) msgBuf
454          INTEGER n
455        integer num,myThid,ndiagmx  
456        integer ipointer  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
457    
458        DATA IPOINTER / 1 /        n = LEN(parName)
459    c     write(0,'(3A,I4)')
460        character*8 parms1  c    &  'DIAGS_GET_PARMS_I: parName="',parName,'" , length=',n
461        character*1 parse1(8)  
462        character*3 mate_index        IF ( parName.EQ.'LAST_DIAG_ID' ) THEN
463        integer     mate           DIAGS_GET_PARMS_I = ndiagt
   
       equivalence (     parms1 , parse1(1) )  
       equivalence ( mate_index , parse1(6) )  
   
 C **********************************************************************  
 C ****                SET POINTERS FOR DIAGNOSTIC NUM               ****  
 C **********************************************************************  
   
       parms1 = gdiag(num)  
   
       IF( IDIAG(NUM).EQ.0 ) THEN  
         if(ndiagmx+kdiag(num).gt.numdiags) then  
           write(6,4000)num,cdiag(num)  
         else  
           IDIAG(NUM) = IPOINTER  
           IPOINTER   = IPOINTER + KDIAG(NUM)  
           ndiagmx    = ndiagmx  + KDIAG(NUM)  
           if(myThid.eq.1) WRITE(6,2000)KDIAG(NUM),NUM,CDIAG(NUM),ndiagmx  
         endif  
464        ELSE        ELSE
465            if(myThid.eq.1) WRITE(6,3000) NUM, CDIAG(NUM)           WRITE(msgBuf,'(4A)') 'DIAGS_GET_PARMS_I: ',
466         &    ' parName="', parName, '" not known.'
467             CALL PRINT_ERROR( msgBuf, myThid )
468             STOP 'ABNORMAL END: S/R DIAGS_GET_PARMS_I'
469        ENDIF        ENDIF
470    
471  c Check for Counter Diagnostic        RETURN
472  c ----------------------------        END
473        if( parse1(5).eq.'C') then  
474        read (mate_index,100) mate  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
475    
476        IF( IDIAG(mate).EQ.0 ) THEN  CBOP 0
477         if(ndiagmx+kdiag(num).gt.numdiags) then  C     !ROUTINE: DIAGS_MK_UNITS
478          write(6,5000)num,cdiag(num)  
479         else  C     !INTERFACE:
480          IDIAG(mate) = IPOINTER        CHARACTER*16 FUNCTION DIAGS_MK_UNITS(
481          IPOINTER    = IPOINTER + KDIAG(mate)       I                            diagUnitsInPieces, myThid )
482          ndiagmx     = ndiagmx  + KDIAG(mate)  
483          if(myThid.eq.1)WRITE(6,2000)KDIAG(mate),mate,CDIAG(mate),ndiagmx  C     !DESCRIPTION:
484         endif  C     *==========================================================*
485        ELSE  C     | FUNCTION DIAGS_MK_UNITS
486            if(myThid.eq.1) WRITE(6,3000) mate, CDIAG(mate)  C     | o Return the diagnostic units string (16c) removing
487    C     |   blanks from the input string
488    C     *==========================================================*
489    
490    C     !USES:
491          IMPLICIT NONE
492    #include "EEPARAMS.h"
493    
494    C     !INPUT PARAMETERS:
495    C     diagUnitsInPieces :: string for diagnostic units: in several
496    C                          pieces, with blanks in between
497    C     myThid            ::  my thread Id number
498          CHARACTER*(*) diagUnitsInPieces
499          INTEGER      myThid
500    CEOP
501    
502    C     !LOCAL VARIABLES:
503          CHARACTER*(MAX_LEN_MBUF) msgBuf
504          INTEGER i,j,n
505    
506          DIAGS_MK_UNITS = '                '
507          n = LEN(diagUnitsInPieces)
508    
509          j = 0
510          DO i=1,n
511           IF (diagUnitsInPieces(i:i) .NE. ' ' ) THEN
512             j = j+1
513             IF ( j.LE.16 ) DIAGS_MK_UNITS(j:j) = diagUnitsInPieces(i:i)
514           ENDIF
515          ENDDO
516    
517          IF ( j.GT.16 ) THEN
518             WRITE(msgBuf,'(2A,I4,A)') '** WARNING ** ',
519         &   'DIAGS_MK_UNITS: too long (',j,' >16) input string'
520            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
521         &       SQUEEZE_RIGHT , myThid)
522             WRITE(msgBuf,'(3A)') '** WARNING ** ',
523         &   'DIAGS_MK_UNITS: input=', diagUnitsInPieces
524            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
525         &       SQUEEZE_RIGHT , myThid)
526        ENDIF        ENDIF
       endif  
527    
528        RETURN        RETURN
529          END
530    
531    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
532    
533    CBOP 0
534    C     !ROUTINE: DIAGS_MK_TITLE
535    
536    100 format(i3)  C     !INTERFACE:
537   2000 FORMAT(1X,'Allocating ',I2,' Level(s) for Diagnostic # ',I3,        CHARACTER*80 FUNCTION DIAGS_MK_TITLE(
538       .          ' (',A8,'),  Total Number of Diagnostics: ',I5)       I                            diagTitleInPieces, myThid )
539   3000 FORMAT(1X,'Diagnostic # ',I3,' (',A8,') has already been set')  
540   4000 FORMAT(1X,'Unable to allocate space for Diagnostic # ',I3,  C     !DESCRIPTION:
541       .                      ' (',A8,')')  C     *==========================================================*
542   5000 FORMAT(1X,'Unable to allocate space for Counter Diagnostic # ',  C     | FUNCTION DIAGS_MK_TITLE
543       .    I3,' (',A8,')',' WARNING - Diag will not accumulate properly')  C     | o Return the diagnostic title string (80c) removing
544    C     |   consecutive blanks from the input string
545    C     *==========================================================*
546    
547    C     !USES:
548          IMPLICIT NONE
549    #include "EEPARAMS.h"
550    
551    C     !INPUT PARAMETERS:
552    C     diagTitleInPieces :: string for diagnostic units: in several
553    C                          pieces, with blanks in between
554    C     myThid            ::  my Thread Id number
555          CHARACTER*(*) diagTitleInPieces
556          INTEGER      myThid
557    CEOP
558    
559    C     !LOCAL VARIABLES:
560          CHARACTER*(MAX_LEN_MBUF) msgBuf
561          LOGICAL flag
562          INTEGER i,j,n
563    
564    C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
565    
566          DIAGS_MK_TITLE = '                                        '
567         &               //'                                        '
568          n = LEN(diagTitleInPieces)
569    
570          j = 0
571          flag = .FALSE.
572          DO i=1,n
573           IF (diagTitleInPieces(i:i) .NE. ' ' ) THEN
574             IF ( flag ) THEN
575               j = j+1
576               IF (j.LE.80) DIAGS_MK_TITLE(j:j) = ' '
577             ENDIF
578             j = j+1
579             IF ( j.LE.80 ) DIAGS_MK_TITLE(j:j) = diagTitleInPieces(i:i)
580             flag = .FALSE.
581           ELSE
582             flag = j.GE.1
583           ENDIF
584          ENDDO
585    
586          IF ( j.GT.80 ) THEN
587             WRITE(msgBuf,'(2A,I4,A)') '** WARNING ** ',
588         &   'DIAGS_MK_TITLE: too long (',j,' >80) input string'
589            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
590         &       SQUEEZE_RIGHT , myThid)
591             WRITE(msgBuf,'(3A)') '** WARNING ** ',
592         &   'DIAGS_MK_TITLE: input=', diagTitleInPieces
593            CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
594         &       SQUEEZE_RIGHT , myThid)
595          ENDIF
596    
597          RETURN
598        END        END

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.22