/[MITgcm]/MITgcm/pkg/layers/layers_init_fixed.F
ViewVC logotype

Annotation of /MITgcm/pkg/layers/layers_init_fixed.F

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


Revision 1.6 - (hide annotations) (download)
Tue Sep 18 21:30:35 2012 UTC (11 years, 8 months ago) by gforget
Branch: MAIN
Changes since 1.5: +7 -1 lines
- add diagnostics to pkg/layers

1 gforget 1.6 C $Header: /u/gcmpack/MITgcm/pkg/layers/layers_init_fixed.F,v 1.5 2011/06/07 22:20:58 jmc Exp $
2 rpa 1.1 C $Name: $
3    
4     #include "LAYERS_OPTIONS.h"
5    
6     C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7    
8     SUBROUTINE LAYERS_INIT_FIXED( myThid )
9    
10     C ===================================================================
11     C Initialize LAYERS variables that are kept fixed during the run.
12     C ===================================================================
13    
14     IMPLICIT NONE
15     #include "EEPARAMS.h"
16     #include "SIZE.h"
17     #include "PARAMS.h"
18     #include "GRID.h"
19     #include "LAYERS_SIZE.h"
20     #include "LAYERS.h"
21    
22     C INPUT/OUTPUT PARAMETERS:
23     C myThid :: my Thread Id number
24     INTEGER myThid
25    
26     C LOCAL VARIABLES:
27     C k :: loop index
28     C kk,kkinit :: fine grid loop indices
29     C Zf :: depth at cell boundaries
30     C Zf :: depth at cell centers
31     C ZZf :: depth at cell boundaries (fine grid)
32     C ZZc :: depth at cell centers (fine grid)
33 jmc 1.4 C msgBuf :: Informational/error message buffer
34 rpa 1.1 INTEGER k,kk,kkinit
35     _RL Zf(Nr+1)
36     _RL Zc(Nr)
37     _RL ZZf(FineGridMax+1)
38     _RL ZZc(FineGridMax)
39    
40     CHARACTER*(MAX_LEN_MBUF) msgBuf
41    
42     #ifdef ALLOW_MNC
43     #ifdef LAYERS_MNC
44     IF (layers_MNC) THEN
45     CALL LAYERS_MNC_INIT( myThid )
46     ENDIF
47     #endif /* LAYERS_MNC */
48     #endif /* ALLOW_MNC */
49    
50     C Set up the vertical grid
51    
52     C for now, just use up the entire available array for ZZ
53     NZZ = FineGridMax
54    
55     C Z and ZZ are INCREASING DOWNWARD!!!
56     C Maybe this is dumb but it will work as long as we are consistent
57    
58    
59     C Each dF cell is split into FineGridFact fine cells
60     C Calculate dZZf on the fine grid
61     kkinit = 1
62     DO k=1,Nr
63     DO kk=kkinit,kkinit+FineGridFact-1
64     dZZf(kk) = dRf(k) / FineGridFact
65     ENDDO
66     kkinit = kkinit + FineGridFact
67     ENDDO
68    
69     C find the depths
70     Zf(1) = 0. _d 0
71     Zc(1) = drC(1)
72     DO k=2,Nr
73     Zf(k) = Zf(k-1) + drF(k-1)
74     Zc(k) = Zc(k-1) + drC(k)
75     ENDDO
76     Zf(Nr+1) = Zf(Nr) + drF(Nr)
77    
78     C create ZZ
79     ZZf(1) = 0. _d 0
80 rpa 1.3 ZZc(1) = 0.5 _d 0 * dZZf(1)
81 rpa 1.1
82 rpa 1.3 DO kk=2,NZZ+1
83 rpa 1.1 ZZf(kk) = ZZf(kk-1) + dZZf(kk-1)
84 rpa 1.3 ZZc(kk-1) = 0.5 _d 0 * (ZZf(kk) + ZZf(kk-1))
85 rpa 1.1 ENDDO
86    
87     C create the interpolating mapping arrays
88     k = 1
89     DO kk=1,NZZ
90     C see if ZZc point is less than the top Zc point
91     IF ( ZZc(kk) .LT. Zc(1) ) THEN
92     MapIndex(kk) = 1
93     MapFact(kk) = 1.0 _d 0
94     C see if ZZc point is greater than the bottom Zc point
95     ELSE IF ( (ZZc(kk) .GE. Zc(Nr)) .OR. (k .EQ. Nr) ) THEN
96     MapIndex(kk) = Nr - 1
97     MapFact(kk) = 0.0 _d 0
98     C Otherwise we are somewhere in between and need to do interpolation)
99     ELSE IF ( (ZZc(kk) .GE. Zc(k))
100     & .AND. (ZZc(kk) .LT. Zc(Nr)) ) THEN
101     C Find the proper k value
102     DO WHILE (ZZc(kk) .GE. Zc(k+1))
103     k = k + 1
104     ENDDO
105     C If the loop stopped, that means Zc(k) <= ZZc(kk) < ZZc(k+1)
106     MapIndex(kk) = k
107     MapFact(kk) = 1.0 - (( ZZc(kk) - Zc(k) ) / drC(k+1))
108     ELSE
109     C This means there was a problem
110     WRITE(msgBuf,'(A,I4,A,I4,A,1E14.6,A,2E14.6)')
111     & 'S/R LAYERS_INIT_FIXED: kk=', kk, ', k=', k,
112     & ', ZZc(kk)=', ZZc(kk),' , Zc(k)=',Zc(k)
113     CALL PRINT_ERROR( msgBuf, myThid )
114     STOP 'ABNORMAL END: S/R LAYERS_INIT_FIXED'
115 jmc 1.4 ENDIF
116 rpa 1.1
117     C See which grid box the point lies in
118 jmc 1.2 IF ( ZZc(kk).LT.Zf(MapIndex(kk)+1) ) THEN
119 rpa 1.1 CellIndex(kk) = MapIndex(kk)
120     ELSE
121     CellIndex(kk) = MapIndex(kk)+1
122 jmc 1.4 ENDIF
123 rpa 1.1 ENDDO
124    
125 jmc 1.5 IF ( debugLevel .GE. debLevB ) THEN
126 rpa 1.1 CALL PRINT_MESSAGE( 'LAYERS_INIT_FIXED Debugging:',
127 jmc 1.5 & standardMessageUnit, SQUEEZE_RIGHT, myThid )
128 rpa 1.1 DO kk=1,NZZ
129     WRITE(msgBuf,'(A,1F6.1,A,I3,A,I3,A,I3,A,1F6.4,A,I3,A,I3)')
130     & '// ZZc=', ZZc(kk),
131     & ', MapIndex(',kk,')=',MapIndex(kk),
132     & ', MapFact(',kk,')=',MapFact(kk),
133     & ', CellIndex(',kk,')=',CellIndex(kk)
134     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
135 jmc 1.5 & SQUEEZE_RIGHT, myThid )
136 rpa 1.1 ENDDO
137 jmc 1.4 ENDIF
138 rpa 1.1
139 rpa 1.3 C Output the layer coordinates
140 jmc 1.4 CALL WRITE_GLVEC_RL( 'layers_G', ' ', layers_G, 1+Nlayers,
141 rpa 1.3 & -1, myThid )
142    
143 gforget 1.6 #ifdef ALLOW_DIAGNOSTICS
144     IF ( useDiagnostics ) THEN
145     CALL LAYERS_DIAGNOSTICS_INIT( myThid )
146     ENDIF
147     #endif
148    
149 rpa 1.1 RETURN
150     END

  ViewVC Help
Powered by ViewVC 1.1.22