1 |
C $Header: /u/gcmpack/MITgcm/pkg/generic_advdiff/salt_fill.F,v 1.4 2006/06/29 16:14:36 dimitri Exp $ |
2 |
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 |
I uVel, vVel, |
12 |
U salt, |
13 |
I flag,myTime,myIter,myThid) |
14 |
|
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 |
|
29 |
C !USES: |
30 |
IMPLICIT NONE |
31 |
#include "SIZE.h" |
32 |
#include "EEPARAMS.h" |
33 |
#include "PARAMS.h" |
34 |
#include "GRID.h" |
35 |
|
36 |
C !INPUT PARAMETERS: =================================================== |
37 |
C uVel :: zonal velocity component |
38 |
C vVel :: meridional velocity component |
39 |
C salt :: salt field |
40 |
C flag :: integer flag telling scheme how to fill |
41 |
C myTime :: current time |
42 |
C myIter :: iteration number |
43 |
C myThid :: thread number |
44 |
C !OUTPUT PARAMETERS: ================================================== |
45 |
C salt :: salt array is replaced |
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 |
CEOP |
54 |
|
55 |
C !FUNCTIONS: |
56 |
c#ifdef ALLOW_DIAGNOSTICS |
57 |
c LOGICAL DIAGNOSTICS_IS_ON |
58 |
c EXTERNAL DIAGNOSTICS_IS_ON |
59 |
c#endif |
60 |
|
61 |
C !LOCAL VARIABLES: |
62 |
INTEGER bi,bj,i,j,L,LM1 |
63 |
_RL dpratio |
64 |
#ifdef ALLOW_DIAGNOSTICS |
65 |
_RL tmpFac |
66 |
#endif |
67 |
|
68 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
69 |
|
70 |
DO bj=myByLo(myThid),myByHi(myThid) |
71 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
72 |
#ifdef ALLOW_DIAGNOSTICS |
73 |
C Fill diagnostic for filling with negative of salt |
74 |
IF (useDiagnostics)THEN |
75 |
tmpFac = -1. _d 0 |
76 |
CALL DIAGNOSTICS_SCALE_FILL(salt,tmpFac,1,'SALTFILL', |
77 |
& 0,Nr,-1,bi,bj,myThid) |
78 |
ENDIF |
79 |
#endif |
80 |
|
81 |
c Flag = 1: |
82 |
c --------------------------------- |
83 |
if(flag.eq.1) then |
84 |
|
85 |
do L=Nr,2,-1 |
86 |
LM1 = L-1 |
87 |
dpratio= rC(L)/rC(LM1) |
88 |
do j=1,sNy |
89 |
do i=1,sNx |
90 |
if( salt(i,j,L,bi,bj).lt.0.0 _d 0) then |
91 |
salt(i,j,LM1,bi,bj) = salt(i,j,LM1,bi,bj) + |
92 |
. salt(i,j,L,bi,bj)*dpratio |
93 |
salt(i,j,L,bi,bj) = 0.0 _d 0 |
94 |
endif |
95 |
enddo |
96 |
enddo |
97 |
enddo |
98 |
|
99 |
do j=1,sNy |
100 |
do i=1,sNx |
101 |
if(salt(i,j,1,bi,bj).lt.0.0 _d 0) |
102 |
. salt(i,j,1,bi,bj) = 0.0 _d 0 |
103 |
enddo |
104 |
enddo |
105 |
|
106 |
else |
107 |
print *,'Invalid Flag in salt_fill - nothing done ' |
108 |
endif |
109 |
|
110 |
#ifdef ALLOW_DIAGNOSTICS |
111 |
C Fill diagnostic for filling with salt - get tendency |
112 |
IF ( useDiagnostics ) THEN |
113 |
CALL DIAGNOSTICS_FILL(salt,'SALTFILL',0,Nr,1,bi,bj,myThid) |
114 |
ENDIF |
115 |
#endif |
116 |
ENDDO |
117 |
ENDDO |
118 |
|
119 |
RETURN |
120 |
END |