1 |
molod |
1.3 |
C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/salt_fill.F,v 1.2 2006/06/05 18:38:09 molod Exp $ |
2 |
molod |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "GAD_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
|
|
CBOP |
8 |
|
|
C !ROUTINE: SALT_FILL |
9 |
|
|
C !INTERFACE: ========================================================== |
10 |
|
|
SUBROUTINE SALT_FILL( |
11 |
|
|
. uVel, vVel, |
12 |
|
|
. salt, |
13 |
|
|
. flag,myTime,myIter,myThid) |
14 |
|
|
C |
15 |
|
|
C !DESCRIPTION: |
16 |
|
|
C Fills in negatives for the salt (specific humidity) field |
17 |
|
|
C |
18 |
|
|
C The algorithm is as follows: |
19 |
|
|
C |
20 |
|
|
C Simplest scheme (flag = 1) -> borrow from below and create |
21 |
|
|
C salt if needed at bottom level |
22 |
|
|
C 'Get it back' (flag = 2) -> Fill negative of salt by getting it |
23 |
|
|
C back from where it went |
24 |
|
|
C If no immediate surrounding value is large enough to fill negative, |
25 |
|
|
C the sum of immediate surrounding positive values is tried. |
26 |
|
|
C If sum is not large enough, salt is simply set to zero. |
27 |
|
|
C NOTE AS OF 6/2/06 -- DO NOT USE FLAG=2 OPTION - NOT WORKING |
28 |
|
|
C |
29 |
|
|
C !INPUT PARAMETERS: =================================================== |
30 |
|
|
C uVel :: zonal velocity component |
31 |
|
|
C vVel :: meridional velocity component |
32 |
|
|
C salt :: salt field |
33 |
|
|
C flag :: integer flag telling scheme how to fill |
34 |
|
|
C myTime :: current time |
35 |
|
|
C myIter :: iteration number |
36 |
|
|
C myThid :: thread number |
37 |
|
|
C !OUTPUT PARAMETERS: ================================================== |
38 |
|
|
C salt :: salt array is replaced |
39 |
|
|
CEOP |
40 |
|
|
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
41 |
|
|
IMPLICIT NONE |
42 |
|
|
#include "SIZE.h" |
43 |
|
|
#include "EEPARAMS.h" |
44 |
|
|
#include "PARAMS.h" |
45 |
|
|
#include "GRID.h" |
46 |
|
|
_RL uVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
47 |
|
|
_RL vVel (1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
48 |
|
|
_RL salt(1-Olx:sNx+Olx,1-Oly:sNy+Oly,Nr,nSx,nSy) |
49 |
|
|
INTEGER flag |
50 |
|
|
_RL myTime |
51 |
|
|
INTEGER myIter |
52 |
|
|
INTEGER myThid |
53 |
|
|
|
54 |
|
|
logical diagnostics_is_on |
55 |
|
|
external diagnostics_is_on |
56 |
|
|
|
57 |
|
|
INTEGER bi,bj,i,j,L,LM1 |
58 |
molod |
1.3 |
_RL dpratio, scale |
59 |
molod |
1.1 |
|
60 |
|
|
DO bj=myByLo(myThid),myByHi(myThid) |
61 |
|
|
DO bi=myBxLo(myThid),myBxHi(myThid) |
62 |
|
|
C Fill diagnostic for filling with negative of salt |
63 |
|
|
#ifdef ALLOW_DIAGNOSTICS |
64 |
|
|
IF (useDiagnostics)THEN |
65 |
molod |
1.2 |
if(diagnostics_is_on('SALTFILL',myThid) ) then |
66 |
molod |
1.3 |
scale = -1. _d 0 |
67 |
|
|
CALL DIAGNOSTICS_SCALE_FILL(salt,scale,1,'SALTFILL', |
68 |
|
|
. 0,Nr,-1,bi,bj,myThid) |
69 |
molod |
1.1 |
endif |
70 |
|
|
ENDIF |
71 |
|
|
#endif |
72 |
|
|
|
73 |
|
|
c Flag = 1: |
74 |
|
|
c --------------------------------- |
75 |
|
|
if(flag.eq.1) then |
76 |
|
|
|
77 |
|
|
do L=Nr,2,-1 |
78 |
|
|
LM1 = L-1 |
79 |
|
|
dpratio= rC(L)/rC(LM1) |
80 |
molod |
1.2 |
do j=1,sNy |
81 |
|
|
do i=1,sNx |
82 |
molod |
1.1 |
if( salt(i,j,L,bi,bj).lt.0.0 _d 0) then |
83 |
|
|
salt(i,j,LM1,bi,bj) = salt(i,j,LM1,bi,bj) + |
84 |
|
|
. salt(i,j,L,bi,bj)*dpratio |
85 |
|
|
salt(i,j,L,bi,bj) = 0.0 _d 0 |
86 |
|
|
endif |
87 |
|
|
enddo |
88 |
|
|
enddo |
89 |
|
|
enddo |
90 |
|
|
|
91 |
molod |
1.2 |
do j=1,sNy |
92 |
|
|
do i=1,sNx |
93 |
molod |
1.1 |
if(salt(i,j,1,bi,bj).lt.0.0 _d 0) |
94 |
|
|
. salt(i,j,1,bi,bj) = 0.0 _d 0 |
95 |
|
|
enddo |
96 |
|
|
enddo |
97 |
|
|
|
98 |
|
|
else |
99 |
|
|
print *,'Invalid Flag in salt_fill - nothing done ' |
100 |
|
|
endif |
101 |
|
|
|
102 |
|
|
C Fill diagnostic for filling with salt - get tendency |
103 |
|
|
#ifdef ALLOW_DIAGNOSTICS |
104 |
|
|
IF (useDiagnostics)THEN |
105 |
molod |
1.2 |
if(diagnostics_is_on('SALTFILL',myThid) ) then |
106 |
molod |
1.1 |
CALL DIAGNOSTICS_FILL(salt,'SALTFILL',0,Nr,1,bi,bj,myThid) |
107 |
|
|
endif |
108 |
|
|
ENDIF |
109 |
|
|
#endif |
110 |
|
|
ENDDO |
111 |
|
|
ENDDO |
112 |
|
|
|
113 |
|
|
RETURN |
114 |
|
|
END |