1 |
C $Header: /u/gcmpack/models/MITgcmUV/model/src/ini_theta.F,v 1.13 1999/08/26 17:43:52 adcroft Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
CStartOfInterface |
7 |
SUBROUTINE INI_THETA( myThid ) |
8 |
C /==========================================================\ |
9 |
C | SUBROUTINE INI_THETA | |
10 |
C | o Set model initial temperature field. | |
11 |
C |==========================================================| |
12 |
C | There are several options for setting the initial | |
13 |
C | temperature file | |
14 |
C | 1. Inline code | |
15 |
C | 2. Vertical profile ( uniform T in X and Y ) | |
16 |
C | 3. Three-dimensional data from a file. For example from | |
17 |
C | Levitus or from a checkpoint file from a previous | |
18 |
C | integration. | |
19 |
C | In addition to setting the temperature field we also | |
20 |
C | set the initial temperature tendency term here. | |
21 |
C \==========================================================/ |
22 |
IMPLICIT NONE |
23 |
|
24 |
C === Global variables === |
25 |
#include "SIZE.h" |
26 |
#include "EEPARAMS.h" |
27 |
#include "PARAMS.h" |
28 |
#include "GRID.h" |
29 |
#include "DYNVARS.h" |
30 |
|
31 |
C == Routine arguments == |
32 |
C myThid - Number of this instance of INI_THETA |
33 |
INTEGER myThid |
34 |
CEndOfInterface |
35 |
|
36 |
C == Local variables == |
37 |
C iC, jC - Center of domain |
38 |
C iD, jD - Disitance from domain center. |
39 |
C rad - Radius of initial patch |
40 |
C rD - Radial displacement of point I,J |
41 |
C iG, jG - Global coordinate index |
42 |
C bi,bj - Loop counters |
43 |
C I,J,K |
44 |
INTEGER iC, jC, iD, jD |
45 |
INTEGER iG, jG |
46 |
INTEGER bi, bj |
47 |
INTEGER I, J, K, localWarnings |
48 |
_RL rad, rD |
49 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
50 |
|
51 |
_BARRIER |
52 |
|
53 |
IF ( hydrogThetaFile .EQ. ' ' ) THEN |
54 |
C-- Example 1 |
55 |
C-- Initialise temperature field to a circular patch. |
56 |
iC = Nx/2 |
57 |
jC = Ny/2 |
58 |
rad = MIN(Ny/8,Nx/8) |
59 |
DO bj = myByLo(myThid), myByHi(myThid) |
60 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
61 |
DO K=1,Nr |
62 |
DO J=1,sNy |
63 |
DO I=1,sNx |
64 |
theta(I,J,K,bi,bj) = 0. _d 0 |
65 |
iG = myXGlobalLo-1+(bi-1)*sNx+I |
66 |
jG = myYGlobalLo-1+(bj-1)*sNy+J |
67 |
iD = iG-iC |
68 |
jD = jG-jC |
69 |
rD = SQRT(FLOAT(iD*iD+jD*jD)) |
70 |
IF ( rD .LT. rad ) theta(I,J,K,bi,bj) = 1. _d 0 |
71 |
ENDDO |
72 |
ENDDO |
73 |
ENDDO |
74 |
ENDDO |
75 |
ENDDO |
76 |
C-- Example 2 |
77 |
C-- Initialise temperature field to the vertical reference profile |
78 |
DO bj = myByLo(myThid), myByHi(myThid) |
79 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
80 |
DO K=1,Nr |
81 |
DO J=1,sNy |
82 |
DO I=1,sNx |
83 |
theta(I,J,K,bi,bj) = tRef(K) |
84 |
ENDDO |
85 |
ENDDO |
86 |
ENDDO |
87 |
ENDDO |
88 |
ENDDO |
89 |
ELSE |
90 |
_BEGIN_MASTER( myThid ) |
91 |
CALL READ_FLD_XYZ_RL( hydrogThetaFile, ' ', theta, 0, myThid ) |
92 |
_END_MASTER(myThid) |
93 |
ENDIF |
94 |
C Set initial tendency terms |
95 |
localWarnings=0 |
96 |
DO bj = myByLo(myThid), myByHi(myThid) |
97 |
DO bi = myBxLo(myThid), myBxHi(myThid) |
98 |
DO K=1,Nr |
99 |
DO J=1,sNy |
100 |
DO I=1,sNx |
101 |
gt (I,J,K,bi,bj) = 0. _d 0 |
102 |
gtNM1(I,J,K,bi,bj) = 0. _d 0 |
103 |
IF (hFacC(I,J,K,bi,bj).EQ.0) theta(I,J,K,bi,bj) = 0. |
104 |
IF (hFacC(I,J,K,bi,bj).NE.0.AND.theta(I,J,K,bi,bj).EQ.0.) |
105 |
& THEN |
106 |
localWarnings=localWarnings+1 |
107 |
ENDIF |
108 |
ENDDO |
109 |
ENDDO |
110 |
ENDDO |
111 |
ENDDO |
112 |
ENDDO |
113 |
IF (localWarnings.NE.0) THEN |
114 |
WRITE(msgBuf,'(A,A)') |
115 |
& 'S/R INI_THETA: theta = 0 identically. If this is intentional', |
116 |
& 'you will need to edit ini_theta.F to avoid this safety check' |
117 |
CALL PRINT_ERROR( msgBuf , myThid) |
118 |
STOP 'ABNORMAL END: S/R INI_THETA' |
119 |
ENDIF |
120 |
C |
121 |
_EXCH_XYZ_R8(theta , myThid ) |
122 |
_EXCH_XYZ_R8(gt , myThid ) |
123 |
_EXCH_XYZ_R8(gtNM1 , myThid ) |
124 |
|
125 |
CALL PLOT_FIELD_XYZRL( theta, 'Initial Temperature' , |
126 |
& Nr, 1, myThid ) |
127 |
|
128 |
RETURN |
129 |
END |