/[MITgcm]/MITgcm/model/src/ini_pressure.F
ViewVC logotype

Annotation of /MITgcm/model/src/ini_pressure.F

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


Revision 1.9 - (hide annotations) (download)
Fri Aug 4 00:45:47 2006 UTC (17 years, 9 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58t_post, checkpoint58o_post, checkpoint58p_post, checkpoint58q_post, mitgcm_mapl_00, checkpoint58r_post, checkpoint58n_post, checkpoint58u_post, checkpoint58s_post
Changes since 1.8: +12 -1 lines
print only once (master thread)

1 jmc 1.9 C $Header: /u/gcmpack/MITgcm/model/src/ini_pressure.F,v 1.8 2006/07/25 22:22:08 jmc Exp $
2 edhill 1.6 C $Name: $
3 mlosch 1.1
4     #include "CPP_OPTIONS.h"
5    
6     CBOP
7     C !ROUTINE: INI_PRESSURE
8     C !INTERFACE:
9 jmc 1.3 SUBROUTINE INI_PRESSURE( myThid )
10 mlosch 1.1 C !DESCRIPTION: \bv
11     C *==========================================================*
12     C | SUBROUTINE INI_PRESSURE
13     C | o initialise the pressure field consistently with
14     C | temperature and salinity
15     C | - needs to be called after ini_theta, ini_salt, and
16     C | ini_psurf
17     C | - does not include surface pressure loading, because
18     C | that is only available until after
19 jmc 1.3 C | CALL packages_init_variables
20 mlosch 1.1 C *==========================================================*
21     C \ev
22    
23     C !USES:
24 jmc 1.3 IMPLICIT NONE
25 mlosch 1.1 C == Global variables ==
26     #include "SIZE.h"
27     #include "EEPARAMS.h"
28     #include "PARAMS.h"
29     #include "EOS.h"
30     #include "GRID.h"
31     #include "DYNVARS.h"
32    
33     C !INPUT/OUTPUT PARAMETERS:
34     C == Routine arguments ==
35     C myThid - Number of this instance of INI_PRESSURE
36     INTEGER myThid
37    
38     C !LOCAL VARIABLES:
39     C == Local variables ==
40 jmc 1.3 C dPhiHydX,Y :: Gradient (X & Y directions) of Hyd. Potential
41 mlosch 1.1 C bi,bj - Loop counters
42     C I,J,K
43     INTEGER bi, bj
44     INTEGER I, J, K
45 jmc 1.4 INTEGER iMin, iMax, jMin, jMax, npiter
46     _RL PhiHydF (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
47     _RL PhiHydC (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
48 jmc 1.3 _RL dPhiHydX(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
49     _RL dPhiHydY(1-Olx:sNx+Olx,1-Oly:sNy+Oly)
50 jmc 1.4 _RL oldPhi (1-Olx:sNx+Olx,1-Oly:sNy+Oly)
51 jmc 1.8 _RL count, rmspp, rmsppold
52 mlosch 1.1
53     CHARACTER*(MAX_LEN_MBUF) msgBuf
54 mlosch 1.2 CEOP
55 mlosch 1.1 iMin = 1-OLx
56     iMax = sNx+OLx
57     jMin = 1-OLy
58     jMax = sNy+OLy
59 jmc 1.8
60 jmc 1.9 _BEGIN_MASTER( myThid )
61 jmc 1.3 WRITE(msgBuf,'(a)')
62 mlosch 1.1 & 'Start initial hydrostatic pressure computation'
63 jmc 1.8 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
64     & SQUEEZE_RIGHT , myThid)
65 jmc 1.9 _END_MASTER( myThid )
66    
67 jmc 1.3 DO bj = myByLo(myThid), myByHi(myThid)
68     DO bi = myBxLo(myThid), myBxHi(myThid)
69     DO k = 1,Nr
70     DO j=1-OLy,sNy+OLy
71     DO i=1-OLx,sNx+OLx
72 jmc 1.4 totPhiHyd(i,j,k,bi,bj) = 0. _d 0
73 jmc 1.3 ENDDO
74     ENDDO
75     ENDDO
76     ENDDO
77     ENDDO
78 mlosch 1.1
79 jmc 1.4 IF ( useDynP_inEos_Zc ) THEN
80 mlosch 1.1
81 heimbach 1.5 #ifndef ALLOW_AUTODIFF_TAMC
82     cph-- deal with this iterative loop for AD once it will
83     cph-- really be needed;
84     cph-- would need storing of totPhiHyd for each npiter
85    
86 mlosch 1.1 rmspp = 1. _d 0
87     rmsppold = 0. _d 0
88     npiter = 0
89    
90     C iterate pressure p = integral of (g*rho(p)*dz)
91 jmc 1.4 DO npiter= 1, 15
92 mlosch 1.1 rmsppold = rmspp
93     rmspp = 0. _d 0
94 jmc 1.4 count = 0.
95 jmc 1.3 DO bj = myByLo(myThid), myByHi(myThid)
96     DO bi = myBxLo(myThid), myBxHi(myThid)
97 jmc 1.4 DO j=1-OLy,sNy+OLy
98     DO i=1-OLx,sNx+OLx
99     phiHydF(i,j) = 0. _d 0
100     ENDDO
101     ENDDO
102 jmc 1.3 DO k = 1, Nr
103 mlosch 1.1 C for each level save old pressure and compute new pressure
104 jmc 1.3 DO j=jMin,jMax
105     DO i=iMin,iMax
106 jmc 1.4 oldPhi(i,j) = totPhiHyd(i,j,k,bi,bj)
107 jmc 1.3 ENDDO
108     ENDDO
109     CALL CALC_PHI_HYD(
110     I bi, bj, iMin, iMax, jMin, jMax, k,
111 jmc 1.8 I theta, salt,
112 jmc 1.4 U phiHydF,
113     O phiHydC, dPhiHydX, dPhiHydY,
114 jmc 1.3 I startTime, nIter0, myThid)
115 mlosch 1.1 C compute convergence criterion
116 jmc 1.3 DO j=jMin,jMax
117     DO i=iMin,iMax
118 jmc 1.8 rmspp = rmspp
119 jmc 1.4 & + (totPhiHyd(i,j,k,bi,bj)-oldPhi(i,j))**2
120     count = count + maskC(i,j,k,bi,bj)
121 jmc 1.3 ENDDO
122     ENDDO
123 jmc 1.4 C -- end k loop
124 jmc 1.3 ENDDO
125     ENDDO
126     ENDDO
127 mlosch 1.1 Cml WRITE(msgBuf,'(I10.10)') npiter
128     Cml CALL WRITE_FLD_XYZ_RL( 'POLD.',msgBuf,pold,npiter,myThid)
129     Cml CALL WRITE_FLD_XYZ_RL( 'PINI.',msgBuf,pressure,npiter,myThid)
130 jmc 1.4 _GLOBAL_SUM_R8( rmspp, myThid )
131 jmc 1.8 _GLOBAL_SUM_R8( count, myThid )
132 jmc 1.4 IF ( count .EQ. 0. ) THEN
133 mlosch 1.1 rmspp = 0. _d 0
134 jmc 1.3 ELSE
135 jmc 1.4 rmspp = sqrt(rmspp/count)
136 jmc 1.3 ENDIF
137 jmc 1.9 _BEGIN_MASTER( myThid )
138 jmc 1.3 WRITE(msgBuf,'(a,i2,a,e20.13)')
139 mlosch 1.1 & 'Iteration ', npiter, ', RMS-difference = ', rmspp
140 jmc 1.8 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
141     & SQUEEZE_RIGHT , myThid)
142 jmc 1.9 _END_MASTER( myThid )
143 mlosch 1.1
144 jmc 1.4 C -- end npiter loop
145 jmc 1.3 ENDDO
146 mlosch 1.1 C print some diagnostics
147 jmc 1.9 _BEGIN_MASTER( myThid )
148 jmc 1.3 IF ( rmspp .ne. 0. ) THEN
149     IF ( rmspp .EQ. rmsppold ) THEN
150 jmc 1.4 WRITE(msgBuf,'(A)')
151 jmc 1.8 & 'Initial hydrostatic pressure did not converge perfectly,'
152     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
153     & SQUEEZE_RIGHT , myThid)
154 jmc 1.4 WRITE(msgBuf,'(A)')
155 mlosch 1.1 & 'but the RMS-difference is constant, indicating that the'
156 jmc 1.8 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
157     & SQUEEZE_RIGHT , myThid)
158 jmc 1.4 WRITE(msgBuf,'(A)')
159 jmc 1.8 & 'algorithm converged within machine precision.'
160     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
161     & SQUEEZE_RIGHT , myThid)
162 jmc 1.3 ELSE
163 jmc 1.4 WRITE(msgBuf,'(A,I2,A)')
164 jmc 1.8 & 'Initial hydrostatic pressure did not converge after ',
165 mlosch 1.1 & npiter-1, ' steps'
166     CALL PRINT_ERROR( msgBuf, myThid )
167     STOP 'ABNORMAL END: S/R INI_PRESSURE'
168 jmc 1.3 ENDIF
169     ENDIF
170 jmc 1.4 WRITE(msgBuf,'(A)')
171 jmc 1.8 & 'Initial hydrostatic pressure converged.'
172     CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
173     & SQUEEZE_RIGHT , myThid)
174 jmc 1.9 _END_MASTER( myThid )
175 mlosch 1.1
176 heimbach 1.5 #endif /* ALLOW_AUTODIFF_TAMC */
177    
178     c-- else of if useDynP_inEos_Zc
179 jmc 1.3 ELSE
180     C print a message and DO nothing
181 jmc 1.9 _BEGIN_MASTER( myThid )
182 jmc 1.4 WRITE(msgBuf,'(A,A)')
183 mlosch 1.1 & 'Pressure is predetermined for buoyancyRelation ',
184     & buoyancyRelation(1:11)
185 jmc 1.8 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
186     & SQUEEZE_RIGHT , myThid)
187 jmc 1.9 _END_MASTER( myThid )
188 mlosch 1.1
189 jmc 1.3 ENDIF
190 mlosch 1.1
191 jmc 1.9 _BEGIN_MASTER( myThid )
192 jmc 1.4 WRITE(msgBuf,'(A)') ' '
193 jmc 1.8 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
194     & SQUEEZE_RIGHT , myThid)
195 jmc 1.9 _END_MASTER( myThid )
196 mlosch 1.1
197 jmc 1.8 RETURN
198 jmc 1.3 END

  ViewVC Help
Powered by ViewVC 1.1.22