1 |
jmc |
1.3 |
C $Header: /u/gcmpack/MITgcm/pkg/obcs/obcs_check_depths.F,v 1.2 2011/05/24 14:31:14 jmc Exp $ |
2 |
jmc |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
|
|
#include "OBCS_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
SUBROUTINE OBCS_CHECK_DEPTHS( myThid ) |
7 |
|
|
C *==========================================================* |
8 |
jmc |
1.3 |
C | SUBROUTINE OBCS_CHECK_DEPTHS |
9 |
|
|
C | o Check for non-zero normal gradient across open |
10 |
|
|
C | boundaries |
11 |
|
|
C | o fix them if required and print a message |
12 |
jmc |
1.1 |
C *==========================================================* |
13 |
|
|
C *==========================================================* |
14 |
|
|
IMPLICIT NONE |
15 |
|
|
|
16 |
|
|
C === Global variables === |
17 |
|
|
#include "SIZE.h" |
18 |
|
|
#include "EEPARAMS.h" |
19 |
|
|
#include "PARAMS.h" |
20 |
|
|
#include "GRID.h" |
21 |
jmc |
1.2 |
#include "OBCS_PARAMS.h" |
22 |
|
|
#include "OBCS_GRID.h" |
23 |
jmc |
1.1 |
|
24 |
|
|
C === Routine arguments === |
25 |
jmc |
1.3 |
C myThid :: my Thread Id number |
26 |
jmc |
1.1 |
INTEGER myThid |
27 |
|
|
|
28 |
|
|
#ifdef ALLOW_OBCS |
29 |
|
|
C === Local variables === |
30 |
jmc |
1.3 |
C msgBuf :: Informational/error message buffer |
31 |
jmc |
1.1 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
32 |
|
|
INTEGER bi, bj, I, J, K, ichanged |
33 |
|
|
|
34 |
|
|
IF ( OBCSfixTopo ) THEN |
35 |
|
|
C-- Modify topography to ensure that outward d(topography)/dn >= 0, |
36 |
|
|
C topography at open boundary points must be equal or shallower than |
37 |
|
|
C topography one grid-point inward from open boundary |
38 |
|
|
ichanged = 0 |
39 |
|
|
DO bj = myByLo(myThid), myByHi(myThid) |
40 |
|
|
DO bi = myBxLo(myThid), myBxHi(myThid) |
41 |
|
|
|
42 |
|
|
DO K=1,Nr |
43 |
|
|
#ifdef ALLOW_OBCS_NORTH |
44 |
|
|
DO I=1,sNx |
45 |
|
|
J=OB_Jn(I,bi,bj) |
46 |
|
|
IF ( J .NE. 0 .AND. |
47 |
|
|
& ( R_low(I,J,bi,bj) .LT. R_low(I,J-1,bi,bj) ) ) THEN |
48 |
|
|
ichanged = ichanged + 1 |
49 |
|
|
R_low(I,J,bi,bj) = R_low(I,J-1,bi,bj) |
50 |
|
|
WRITE(msgBuf,'(2A,(1X,4I6))') |
51 |
|
|
& 'S/R OBCS_CHECK_DEPTHS: fixed topography at ', |
52 |
|
|
& '(i,j,bi,bj) = ', I, J, bi, bj |
53 |
|
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
54 |
|
|
& SQUEEZE_RIGHT, myThid) |
55 |
|
|
ENDIF |
56 |
|
|
ENDDO |
57 |
|
|
#endif |
58 |
|
|
#ifdef ALLOW_OBCS_SOUTH |
59 |
|
|
DO I=1,sNx |
60 |
|
|
J=OB_Js(I,bi,bj) |
61 |
|
|
IF ( J .NE. 0 .AND. |
62 |
|
|
& ( R_low(I,J,bi,bj) .LT. R_low(I,J+1,bi,bj) ) ) THEN |
63 |
|
|
ichanged = ichanged + 1 |
64 |
|
|
R_low(I,J,bi,bj) = R_low(I,J+1,bi,bj) |
65 |
|
|
WRITE(msgBuf,'(2A,(1X,4I6))') |
66 |
|
|
& 'S/R OBCS_CHECK_DEPTHS: fixed topography at ', |
67 |
|
|
& '(i,j,bi,bj) = ', I, J, bi, bj |
68 |
|
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
69 |
|
|
& SQUEEZE_RIGHT, myThid) |
70 |
|
|
ENDIF |
71 |
|
|
ENDDO |
72 |
|
|
#endif |
73 |
|
|
#ifdef ALLOW_OBCS_EAST |
74 |
|
|
DO J=1,sNy |
75 |
|
|
I = OB_Ie(J,bi,bj) |
76 |
|
|
IF ( I .NE. 0 .AND. |
77 |
|
|
& ( R_low(I,J,bi,bj) .LT. R_low(I-1,J,bi,bj) ) ) THEN |
78 |
|
|
ichanged = ichanged + 1 |
79 |
|
|
R_low(I,J,bi,bj) = R_low(I-1,J,bi,bj) |
80 |
|
|
WRITE(msgBuf,'(2A,(1X,4I6))') |
81 |
|
|
& 'S/R OBCS_CHECK_DEPTHS: fixed topography at ', |
82 |
|
|
& '(i,j,bi,bj) = ', I, J, bi, bj |
83 |
|
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
84 |
|
|
& SQUEEZE_RIGHT, myThid) |
85 |
|
|
ENDIF |
86 |
|
|
ENDDO |
87 |
|
|
#endif |
88 |
|
|
C Western boundary |
89 |
|
|
#ifdef ALLOW_OBCS_WEST |
90 |
|
|
DO J=1,sNy |
91 |
|
|
I = OB_Iw(J,bi,bj) |
92 |
|
|
IF ( I .NE. 0 .AND. |
93 |
|
|
& ( R_low(I,J,bi,bj) .LT. R_low(I+1,J,bi,bj) ) ) THEN |
94 |
|
|
ichanged = ichanged + 1 |
95 |
|
|
R_low(I,J,bi,bj) = R_low(I+1,J,bi,bj) |
96 |
|
|
WRITE(msgBuf,'(2A,(1X,4I6))') |
97 |
|
|
& 'S/R OBCS_CHECK_DEPTHS: fixed topography at ', |
98 |
|
|
& '(i,j,bi,bj) = ', I, J, bi, bj |
99 |
|
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
100 |
|
|
& SQUEEZE_RIGHT, myThid) |
101 |
|
|
ENDIF |
102 |
|
|
ENDDO |
103 |
|
|
#endif |
104 |
|
|
ENDDO |
105 |
|
|
|
106 |
|
|
ENDDO |
107 |
|
|
ENDDO |
108 |
|
|
C-- some diagnostics to stdout |
109 |
jmc |
1.3 |
CALL GLOBAL_SUM_INT( ichanged, myThid ) |
110 |
jmc |
1.1 |
IF ( ichanged .GT. 0 ) THEN |
111 |
|
|
WRITE(msgBuf,'(A,I7,A,A)') |
112 |
|
|
& 'OBCS message: corrected ', ichanged, |
113 |
|
|
& ' instances of problematic topography gradients', |
114 |
|
|
& ' normal to open boundaries' |
115 |
|
|
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
116 |
|
|
& SQUEEZE_RIGHT, myThid) |
117 |
|
|
ENDIF |
118 |
jmc |
1.3 |
|
119 |
jmc |
1.1 |
C endif (OBCSfixTopo) |
120 |
|
|
ENDIF |
121 |
|
|
#endif /* ALLOW_OBCS */ |
122 |
|
|
|
123 |
|
|
RETURN |
124 |
|
|
END |