1 |
C $Header: /u/gcmpack/MITgcm/verification/fizhi-cs-aqualev20/code/ini_salt.F,v 1.1 2006/04/03 20:55:14 molod Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: INI_SALT |
8 |
C !INTERFACE: |
9 |
SUBROUTINE INI_SALT ( myThid ) |
10 |
C !DESCRIPTION: \bv |
11 |
C *==========================================================* |
12 |
C | SUBROUTINE INI_SALT |
13 |
C | o Set model initial salinity field. |
14 |
C *==========================================================* |
15 |
C | There are several options for setting the initial |
16 |
C | temperature file |
17 |
C | 1. Inline code |
18 |
C | 2. Vertical profile ( uniform S in X and Y ) |
19 |
C | 3. Three-dimensional data from a file. For example from |
20 |
C | Levitus or from a checkpoint file from a previous |
21 |
C | integration. |
22 |
C | In addition to setting the salinity field we also |
23 |
C | set the initial salinity tendency term here. |
24 |
C *==========================================================* |
25 |
C \ev |
26 |
|
27 |
C !USES: |
28 |
IMPLICIT NONE |
29 |
C === Global variables === |
30 |
#include "SIZE.h" |
31 |
#include "EEPARAMS.h" |
32 |
#include "PARAMS.h" |
33 |
#include "GRID.h" |
34 |
#include "DYNVARS.h" |
35 |
|
36 |
C !INPUT/OUTPUT PARAMETERS: |
37 |
C == Routine arguments == |
38 |
C myThid - Number of this instance of INI_SALT |
39 |
INTEGER myThid |
40 |
|
41 |
C !LOCAL VARIABLES: |
42 |
C == Local variables == |
43 |
C bi,bj - Loop counters |
44 |
C I,J,K |
45 |
INTEGER bi, bj |
46 |
INTEGER I, J, K, localWarnings |
47 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
48 |
CEOP |
49 |
|
50 |
_RL pedyn(Nr+1), pdyn(Nr), pkappa(Nr) |
51 |
integer Lbotij |
52 |
_RL getcon, kappa, dum, pinmb |
53 |
_RL temperature(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
54 |
_RL rhum(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
55 |
_RL qstar(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
56 |
|
57 |
C Need to convert from input RH to q -- Need pressure, temperature |
58 |
C Build pressures - we know there is no topography and eta = 0 |
59 |
pedyn(1) = 100000. |
60 |
do K = 2,Nr+1 |
61 |
pedyn(K) = pedyn(K-1) - drF(K-1) |
62 |
enddo |
63 |
do K = 1,Nr |
64 |
pdyn(K)=(pedyn(K+1)+pedyn(K))/2. |
65 |
enddo |
66 |
kappa = getcon('KAPPA') |
67 |
do K = 1,Nr |
68 |
pkappa(K)=(pdyn(K)/100000.)**kappa |
69 |
enddo |
70 |
C Now convert from theta to Temperature |
71 |
DO bj = myByLo(myThid), myByHi(myThid) |
72 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
73 |
DO K=1,Nr |
74 |
DO J=1,sNy |
75 |
DO I=1,sNx |
76 |
temperature(I,J,K,bi,bj) = theta(I,J,K,bi,bj) * pkappa(K) |
77 |
ENDDO |
78 |
ENDDO |
79 |
ENDDO |
80 |
ENDDO |
81 |
ENDDO |
82 |
|
83 |
C-- Initialise salinity field to the vertical reference profile |
84 |
DO bj = myByLo(myThid), myByHi(myThid) |
85 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
86 |
DO K=1,Nr |
87 |
DO J=1-Oly,sNy+Oly |
88 |
DO I=1-Olx,sNx+Olx |
89 |
salt(I,J,K,bi,bj) = sRef(K) |
90 |
ENDDO |
91 |
ENDDO |
92 |
ENDDO |
93 |
ENDDO |
94 |
ENDDO |
95 |
|
96 |
IF ( hydrogSaltFile .NE. ' ' ) THEN |
97 |
_BEGIN_MASTER( myThid ) |
98 |
CALL READ_FLD_XYZ_RL( hydrogSaltFile, ' ', rhum, 0, myThid ) |
99 |
_END_MASTER(myThid) |
100 |
|
101 |
C Now convert from rh to q |
102 |
DO bj = myByLo(myThid), myByHi(myThid) |
103 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
104 |
DO K=1,Nr-1 |
105 |
DO J=1,sNy |
106 |
DO I=1,sNx |
107 |
pinmb = pdyn(K)/100. |
108 |
call qsat(temperature(i,j,k,bi,bj),pinmb,qstar(i,j,k,bi,bj), |
109 |
. dum,.false.) |
110 |
salt(I,J,K,bi,bj) = rhum(i,j,k,bi,bj) * qstar(i,j,k,bi,bj) |
111 |
ENDDO |
112 |
ENDDO |
113 |
ENDDO |
114 |
ENDDO |
115 |
ENDDO |
116 |
|
117 |
_EXCH_XYZ_RL(salt , myThid ) |
118 |
|
119 |
ENDIF |
120 |
|
121 |
C Apply mask and test consistancy |
122 |
localWarnings=0 |
123 |
DO bj = myByLo(myThid), myByHi(myThid) |
124 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
125 |
DO K=1,Nr |
126 |
DO J=1,sNy |
127 |
DO I=1,sNx |
128 |
IF (hFacC(I,J,K,bi,bj).EQ.0) salt(I,J,K,bi,bj) = 0. |
129 |
IF (hFacC(I,J,K,bi,bj).NE.0.AND.salt(I,J,K,bi,bj).EQ.0. |
130 |
& .AND. sRef(k).NE.0.) THEN |
131 |
localWarnings=localWarnings+1 |
132 |
ENDIF |
133 |
ENDDO |
134 |
ENDDO |
135 |
ENDDO |
136 |
ENDDO |
137 |
ENDDO |
138 |
IF (localWarnings.NE.0) THEN |
139 |
WRITE(msgBuf,'(A,A)') |
140 |
& 'S/R INI_SALT: salt = 0 identically. If this is intentional', |
141 |
& 'you will need to edit ini_salt.F to avoid this safety check' |
142 |
CALL PRINT_ERROR( msgBuf , myThid) |
143 |
STOP 'ABNORMAL END: S/R INI_SALT' |
144 |
ENDIF |
145 |
|
146 |
CALL PLOT_FIELD_XYZRL( salt, 'Initial Salinity' , Nr, 1, myThid ) |
147 |
|
148 |
RETURN |
149 |
END |