-
Notifications
You must be signed in to change notification settings - Fork 237
/
ini_salt.F
134 lines (124 loc) · 4.01 KB
/
ini_salt.F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include "PACKAGES_CONFIG.h"
#include "CPP_OPTIONS.h"
CBOP
C !ROUTINE: INI_SALT
C !INTERFACE:
SUBROUTINE INI_SALT( myThid )
C !DESCRIPTION: \bv
C *==========================================================*
C | SUBROUTINE INI_SALT
C | o Set model initial salinity field.
C *==========================================================*
C | There are several options for setting the initial
C | temperature file
C | 1. Inline code
C | 2. Vertical profile ( uniform S in X and Y )
C | 3. Three-dimensional data from a file. For example from
C | Levitus or from a checkpoint file from a previous
C | integration.
C | In addition to setting the salinity field we also
C | set the initial salinity tendency term here.
C *==========================================================*
C \ev
C !USES:
IMPLICIT NONE
C === Global variables ===
#include "SIZE.h"
#include "EEPARAMS.h"
#include "PARAMS.h"
#include "GRID.h"
#include "DYNVARS.h"
#ifdef ALLOW_MNC
#include "MNC_PARAMS.h"
#endif
C !INPUT/OUTPUT PARAMETERS:
C == Routine arguments ==
C myThid :: Number of this instance of INI_SALT
INTEGER myThid
C !LOCAL VARIABLES:
C == Local variables ==
C bi,bj :: Tile indices
C i,j,k :: Loop counters
INTEGER bi, bj
INTEGER i, j, k, localWarnings
CHARACTER*(MAX_LEN_MBUF) msgBuf
CEOP
C-- Initialise salinity field to the vertical reference profile
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO k=1,Nr
DO j=1-OLy,sNy+OLy
DO i=1-OLx,sNx+OLx
salt(i,j,k,bi,bj) = sRef(k)
ENDDO
ENDDO
ENDDO
ENDDO
ENDDO
IF ( hydrogSaltFile .NE. ' ' ) THEN
#ifdef ALLOW_MNC
IF ( useMNC.AND.mnc_read_salt ) THEN
CALL MNC_FILE_CLOSE_ALL_MATCHING(hydrogSaltFile, myThid)
CALL MNC_CW_SET_UDIM(hydrogSaltFile, 1, myThid)
CALL MNC_CW_SET_CITER(hydrogSaltFile, 2, -1, -1, -1, myThid)
CALL MNC_CW_SET_UDIM(hydrogSaltFile, 1, myThid)
CALL MNC_CW_RL_R('D',hydrogSaltFile,0,0,'S',salt, myThid)
CALL MNC_FILE_CLOSE_ALL_MATCHING(hydrogSaltFile, myThid)
ELSE
#endif /* ALLOW_MNC */
CALL READ_FLD_XYZ_RL( hydrogSaltFile, ' ', salt, 0, myThid )
#ifdef ALLOW_MNC
ENDIF
#endif /* ALLOW_MNC */
_EXCH_XYZ_RL( salt, myThid )
ENDIF
C-- Apply mask and test consistency
localWarnings=0
DO bj = myByLo(myThid), myByHi(myThid)
DO bi = myBxLo(myThid), myBxHi(myThid)
DO k=1,Nr
IF ( maskIniSalt ) THEN
DO j=1-OLy,sNy+OLy
DO i=1-OLx,sNx+OLx
IF (maskC(i,j,k,bi,bj).EQ.0.) salt(i,j,k,bi,bj) = 0.
ENDDO
ENDDO
ENDIF
IF ( sRef(k).NE.0. ) THEN
DO j=1,sNy
DO i=1,sNx
IF ( maskC(i,j,k,bi,bj).NE.0.
& .AND. salt(i,j,k,bi,bj).EQ.0. ) THEN
localWarnings=localWarnings+1
ENDIF
ENDDO
ENDDO
ENDIF
ENDDO
ENDDO
ENDDO
IF ( localWarnings.NE.0 ) THEN
IF ( checkIniSalt ) THEN
WRITE(msgBuf,'(A,I10,A)')
& ' INI_SALT: found', localWarnings,
& ' wet grid-pts with salt=0 identically.'
CALL PRINT_ERROR( msgBuf , myThid)
WRITE(msgBuf,'(A,A)')
& ' If this is intentional, you need to',
& ' set checkIniSalt=.false. in "data", namelist PARM05'
CALL PRINT_ERROR( msgBuf , myThid)
STOP 'ABNORMAL END: S/R INI_SALT'
ELSE
WRITE(msgBuf,'(A,I10,A)')
& '** WARNINGS ** INI_SALT: found', localWarnings,
& ' wet grid-pts with salt=0 identically.'
CALL PRINT_MESSAGE( msgBuf, errorMessageUnit,
& SQUEEZE_RIGHT, myThid )
ENDIF
ENDIF
IF ( plotLevel.GE.debLevC ) THEN
CALL PLOT_FIELD_XYZRL( salt, 'Initial Salinity',
& Nr, 1, myThid )
ENDIF
RETURN
END