1 |
cnh |
1.15 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/find_rho.F,v 1.14 2001/02/04 14:38:47 cnh Exp $ |
2 |
|
|
C $Name: $ |
3 |
cnh |
1.1 |
|
4 |
cnh |
1.9 |
#include "CPP_OPTIONS.h" |
5 |
adcroft |
1.5 |
#define USE_FACTORIZED_POLY |
6 |
cnh |
1.1 |
|
7 |
cnh |
1.15 |
CBOP |
8 |
|
|
C !ROUTINE: FIND_RHO |
9 |
|
|
C !INTERFACE: |
10 |
adcroft |
1.4 |
subroutine FIND_RHO( |
11 |
|
|
I bi, bj, iMin, iMax, jMin, jMax, k, kRef, eqn, |
12 |
adcroft |
1.13 |
I tFld, sFld, |
13 |
adcroft |
1.4 |
O rholoc, |
14 |
|
|
I myThid ) |
15 |
cnh |
1.15 |
|
16 |
|
|
C !DESCRIPTION: \bv |
17 |
|
|
C *==========================================================* |
18 |
|
|
C | o SUBROUTINE FIND_RHO |
19 |
|
|
C | Calculates [rho(S,T,z)-Rhonil] of a slice |
20 |
|
|
C *==========================================================* |
21 |
|
|
C | |
22 |
|
|
C | k - is the Theta/Salt level |
23 |
|
|
C | kRef - determines pressure reference level |
24 |
|
|
C | (not used in 'LINEAR' mode) |
25 |
|
|
C | eqn - determines the eqn. of state: 'LINEAR' or 'POLY3' |
26 |
|
|
C | |
27 |
|
|
C *==========================================================* |
28 |
|
|
C \ev |
29 |
|
|
|
30 |
|
|
C !USES: |
31 |
cnh |
1.1 |
implicit none |
32 |
heimbach |
1.12 |
C == Global variables == |
33 |
cnh |
1.1 |
#include "SIZE.h" |
34 |
cnh |
1.7 |
#include "EEPARAMS.h" |
35 |
cnh |
1.1 |
#include "PARAMS.h" |
36 |
heimbach |
1.12 |
|
37 |
cnh |
1.15 |
C !INPUT/OUTPUT PARAMETERS: |
38 |
heimbach |
1.12 |
C == Routine arguments == |
39 |
adcroft |
1.4 |
integer bi,bj,iMin,iMax,jMin,jMax |
40 |
|
|
integer k ! Level of Theta/Salt slice |
41 |
|
|
integer kRef ! Pressure reference level |
42 |
|
|
character*(*) eqn |
43 |
adcroft |
1.13 |
_RL tFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
44 |
|
|
_RL sFld(1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
45 |
adcroft |
1.4 |
_RL rholoc(1-Olx:sNx+Olx,1-Oly:sNy+Oly) |
46 |
|
|
integer myThid |
47 |
heimbach |
1.12 |
|
48 |
cnh |
1.15 |
C !LOCAL VARIABLES: |
49 |
heimbach |
1.12 |
C == Local variables == |
50 |
adcroft |
1.4 |
integer i,j |
51 |
|
|
_RL refTemp,refSalt,sigRef,tP,sP,deltaSig |
52 |
adcroft |
1.10 |
character*(max_len_mbuf) msgbuf |
53 |
cnh |
1.15 |
CEOP |
54 |
heimbach |
1.11 |
|
55 |
|
|
#ifdef ALLOW_AUTODIFF_TAMC |
56 |
|
|
DO j=1-OLy,sNy+OLy |
57 |
|
|
DO i=1-OLx,sNx+OLx |
58 |
|
|
rholoc(i,j) = 0.0 |
59 |
|
|
ENDDO |
60 |
|
|
ENDDO |
61 |
|
|
#endif |
62 |
cnh |
1.1 |
|
63 |
adcroft |
1.4 |
if (eqn.eq.'LINEAR') then |
64 |
|
|
|
65 |
|
|
C ***NOTE*** |
66 |
|
|
C In the linear EOS, to make the static stability calculation meaningful |
67 |
|
|
C we alway calculate the perturbation with respect to the surface level. |
68 |
|
|
C ********** |
69 |
adcroft |
1.6 |
refTemp=tRef(kRef) |
70 |
|
|
refSalt=sRef(kRef) |
71 |
adcroft |
1.4 |
|
72 |
cnh |
1.1 |
do j=jMin,jMax |
73 |
|
|
do i=iMin,iMax |
74 |
adcroft |
1.4 |
rholoc(i,j)=rhonil*( |
75 |
adcroft |
1.13 |
& sBeta*(sFld(i,j,k,bi,bj)-refSalt) |
76 |
|
|
& -tAlpha*(tFld(i,j,k,bi,bj)-refTemp) ) |
77 |
cnh |
1.1 |
enddo |
78 |
|
|
enddo |
79 |
cnh |
1.8 |
|
80 |
adcroft |
1.4 |
elseif (eqn.eq.'POLY3') then |
81 |
|
|
|
82 |
|
|
refTemp=eosRefT(kRef) |
83 |
|
|
refSalt=eosRefS(kRef) |
84 |
adcroft |
1.5 |
sigRef=eosSig0(kRef) + (1000.-Rhonil) |
85 |
adcroft |
1.4 |
|
86 |
|
|
do j=jMin,jMax |
87 |
|
|
do i=iMin,iMax |
88 |
adcroft |
1.13 |
tP=tFld(i,j,k,bi,bj)-refTemp |
89 |
|
|
sP=sFld(i,j,k,bi,bj)-refSalt |
90 |
adcroft |
1.5 |
#ifdef USE_FACTORIZED_POLY |
91 |
adcroft |
1.4 |
deltaSig= |
92 |
adcroft |
1.5 |
& (( eosC(9,kRef)*sP + eosC(5,kRef) )*sP + eosC(2,kRef) )*sP |
93 |
|
|
& + ( ( eosC(6,kRef) |
94 |
|
|
& *tP |
95 |
|
|
& +eosC(7,kRef)*sP + eosC(3,kRef) |
96 |
|
|
& )*tP |
97 |
|
|
& +(eosC(8,kRef)*sP + eosC(4,kRef) )*sP + eosC(1,kRef) |
98 |
|
|
& )*tP |
99 |
|
|
#else |
100 |
|
|
deltaSig= |
101 |
|
|
& eosC(1,kRef)*tP |
102 |
|
|
& +eosC(2,kRef) *sP |
103 |
|
|
& +eosC(3,kRef)*tP*tP |
104 |
|
|
& +eosC(4,kRef)*tP *sP |
105 |
|
|
& +eosC(5,kRef) *sP*sP |
106 |
|
|
& +eosC(6,kRef)*tP*tP*tP |
107 |
|
|
& +eosC(7,kRef)*tP*tP *sP |
108 |
|
|
& +eosC(8,kRef)*tP *sP*sP |
109 |
|
|
& +eosC(9,kRef) *sP*sP*sP |
110 |
|
|
#endif |
111 |
|
|
rholoc(i,j)=sigRef+deltaSig |
112 |
adcroft |
1.4 |
enddo |
113 |
|
|
enddo |
114 |
|
|
|
115 |
|
|
else |
116 |
adcroft |
1.13 |
write(msgbuf,'(3a)') ' FIND_RHO: eqn = "',eqn,'"' |
117 |
adcroft |
1.10 |
call print_error( msgbuf, mythid ) |
118 |
|
|
stop 'ABNORMAL END: S/R FIND_RHO' |
119 |
adcroft |
1.4 |
endif |
120 |
cnh |
1.1 |
|
121 |
|
|
return |
122 |
|
|
end |