1 | SUBROUTINE swap_timelevel |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: swap_timelevel.f90 98 2007-06-21 09:36:33Z raasch $ |
---|
11 | ! |
---|
12 | ! 95 2007-06-02 16:48:38Z raasch |
---|
13 | ! Swaping of salinity |
---|
14 | ! |
---|
15 | ! 75 2007-03-22 09:54:05Z raasch |
---|
16 | ! moisture renamed humidity |
---|
17 | ! |
---|
18 | ! 19 2007-02-23 04:53:48Z raasch |
---|
19 | ! Swaping of top fluxes |
---|
20 | ! |
---|
21 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
22 | ! |
---|
23 | ! Revision 1.8 2004/01/28 15:28:18 raasch |
---|
24 | ! Swaping for Runge-Kutta schemes implemented |
---|
25 | ! |
---|
26 | ! Revision 1.1 2000/01/10 10:08:58 10:08:58 raasch (Siegfried Raasch) |
---|
27 | ! Initial revision |
---|
28 | ! |
---|
29 | ! |
---|
30 | ! Description: |
---|
31 | ! ------------ |
---|
32 | ! Swap of timelevels of variables after each timestep |
---|
33 | !------------------------------------------------------------------------------! |
---|
34 | |
---|
35 | USE arrays_3d |
---|
36 | USE cpulog |
---|
37 | USE interfaces |
---|
38 | USE control_parameters |
---|
39 | |
---|
40 | IMPLICIT NONE |
---|
41 | |
---|
42 | |
---|
43 | CALL cpu_log( log_point(28), 'swap_timelevel', 'start' ) |
---|
44 | |
---|
45 | ! |
---|
46 | !-- Incrementing timestep counter |
---|
47 | timestep_count = timestep_count + 1 |
---|
48 | |
---|
49 | ! |
---|
50 | !-- Swap of 3-level variables |
---|
51 | IF ( timestep_scheme(1:5) /= 'runge' ) THEN |
---|
52 | |
---|
53 | SELECT CASE ( MOD( timestep_count, 3 ) ) |
---|
54 | |
---|
55 | CASE ( 0 ) |
---|
56 | |
---|
57 | u_m => u_1; u => u_2; u_p => u_3 |
---|
58 | v_m => v_1; v => v_2; v_p => v_3 |
---|
59 | w_m => w_1; w => w_2; w_p => w_3 |
---|
60 | pt_m => pt_1; pt => pt_2; pt_p => pt_3 |
---|
61 | IF ( .NOT. constant_diffusion ) THEN |
---|
62 | e_m => e_1; e => e_2; e_p => e_3 |
---|
63 | ENDIF |
---|
64 | IF ( humidity .OR. passive_scalar ) THEN |
---|
65 | q_m => q_1; q => q_2; q_p => q_3 |
---|
66 | ENDIF |
---|
67 | |
---|
68 | CASE ( 1 ) |
---|
69 | |
---|
70 | u_m => u_2; u => u_3; u_p => u_1 |
---|
71 | v_m => v_2; v => v_3; v_p => v_1 |
---|
72 | w_m => w_2; w => w_3; w_p => w_1 |
---|
73 | pt_m => pt_2; pt => pt_3; pt_p => pt_1 |
---|
74 | IF ( .NOT. constant_diffusion ) THEN |
---|
75 | e_m => e_2; e => e_3; e_p => e_1 |
---|
76 | ENDIF |
---|
77 | IF ( humidity .OR. passive_scalar ) THEN |
---|
78 | q_m => q_2; q => q_3; q_p => q_1 |
---|
79 | ENDIF |
---|
80 | |
---|
81 | CASE ( 2 ) |
---|
82 | |
---|
83 | u_m => u_3; u => u_1; u_p => u_2 |
---|
84 | v_m => v_3; v => v_1; v_p => v_2 |
---|
85 | w_m => w_3; w => w_1; w_p => w_2 |
---|
86 | pt_m => pt_3; pt => pt_1; pt_p => pt_2 |
---|
87 | IF ( .NOT. constant_diffusion ) THEN |
---|
88 | e_m => e_3; e => e_1; e_p => e_2 |
---|
89 | ENDIF |
---|
90 | IF ( humidity .OR. passive_scalar ) THEN |
---|
91 | q_m => q_3; q => q_1; q_p => q_2 |
---|
92 | ENDIF |
---|
93 | |
---|
94 | END SELECT |
---|
95 | |
---|
96 | ENDIF |
---|
97 | |
---|
98 | ! |
---|
99 | !-- Swap of 2-level variables |
---|
100 | SELECT CASE ( MOD( timestep_count, 2 ) ) |
---|
101 | |
---|
102 | CASE ( 0 ) |
---|
103 | |
---|
104 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
105 | |
---|
106 | u => u_1; u_p => u_2 |
---|
107 | v => v_1; v_p => v_2 |
---|
108 | w => w_1; w_p => w_2 |
---|
109 | pt => pt_1; pt_p => pt_2 |
---|
110 | IF ( .NOT. constant_diffusion ) THEN |
---|
111 | e => e_1; e_p => e_2 |
---|
112 | ENDIF |
---|
113 | IF ( ocean ) THEN |
---|
114 | sa => sa_1; sa_p => sa_2 |
---|
115 | ENDIF |
---|
116 | IF ( humidity .OR. passive_scalar ) THEN |
---|
117 | q => q_1; q_p => q_2 |
---|
118 | ENDIF |
---|
119 | |
---|
120 | ELSE |
---|
121 | ! |
---|
122 | !-- Old timelevels are needed for explicit diffusion within leapfrog |
---|
123 | IF ( .NOT. constant_diffusion ) THEN |
---|
124 | kh_m => kh_1; kh => kh_2 |
---|
125 | km_m => km_1; km => km_2 |
---|
126 | IF ( use_surface_fluxes ) THEN |
---|
127 | usws_m => usws_1; usws => usws_2 |
---|
128 | vsws_m => vsws_1; vsws => vsws_2 |
---|
129 | shf_m => shf_1; shf => shf_2 |
---|
130 | IF ( humidity .OR. passive_scalar ) THEN |
---|
131 | qsws_m => qsws_1; qsws => qsws_2 |
---|
132 | ENDIF |
---|
133 | ENDIF |
---|
134 | IF ( prandtl_layer ) THEN |
---|
135 | rif_m => rif_1; rif => rif_2 |
---|
136 | ENDIF |
---|
137 | IF ( use_top_fluxes ) THEN |
---|
138 | tswst_m => tswst_1; tswst => tswst_2 |
---|
139 | IF ( humidity .OR. passive_scalar ) THEN |
---|
140 | qswst_m => qswst_1; qswst => qswst_2 |
---|
141 | ENDIF |
---|
142 | ENDIF |
---|
143 | ENDIF |
---|
144 | |
---|
145 | IF ( humidity ) THEN |
---|
146 | vpt_m => vpt_1; vpt => vpt_2 |
---|
147 | ENDIF |
---|
148 | |
---|
149 | ENDIF |
---|
150 | |
---|
151 | CASE ( 1 ) |
---|
152 | |
---|
153 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
154 | |
---|
155 | u => u_2; u_p => u_1 |
---|
156 | v => v_2; v_p => v_1 |
---|
157 | w => w_2; w_p => w_1 |
---|
158 | pt => pt_2; pt_p => pt_1 |
---|
159 | IF ( .NOT. constant_diffusion ) THEN |
---|
160 | e => e_2; e_p => e_1 |
---|
161 | ENDIF |
---|
162 | IF ( ocean ) THEN |
---|
163 | sa => sa_2; sa_p => sa_1 |
---|
164 | ENDIF |
---|
165 | IF ( humidity .OR. passive_scalar ) THEN |
---|
166 | q => q_2; q_p => q_1 |
---|
167 | ENDIF |
---|
168 | |
---|
169 | ELSE |
---|
170 | |
---|
171 | IF ( .NOT. constant_diffusion ) THEN |
---|
172 | kh_m => kh_2; kh => kh_1 |
---|
173 | km_m => km_2; km => km_1 |
---|
174 | IF ( use_surface_fluxes ) THEN |
---|
175 | usws_m => usws_2; usws => usws_1 |
---|
176 | vsws_m => vsws_2; vsws => vsws_1 |
---|
177 | shf_m => shf_2; shf => shf_1 |
---|
178 | IF ( humidity .OR. passive_scalar ) THEN |
---|
179 | qsws_m => qsws_2; qsws => qsws_1 |
---|
180 | ENDIF |
---|
181 | ENDIF |
---|
182 | IF ( prandtl_layer ) THEN |
---|
183 | rif_m => rif_2; rif => rif_1 |
---|
184 | ENDIF |
---|
185 | IF ( use_top_fluxes ) THEN |
---|
186 | tswst_m => tswst_2; tswst => tswst_1 |
---|
187 | IF ( humidity .OR. passive_scalar ) THEN |
---|
188 | qswst_m => qswst_2; qswst => qswst_1 |
---|
189 | ENDIF |
---|
190 | ENDIF |
---|
191 | ENDIF |
---|
192 | |
---|
193 | IF ( humidity ) THEN |
---|
194 | vpt_m => vpt_2; vpt => vpt_1 |
---|
195 | ENDIF |
---|
196 | |
---|
197 | ENDIF |
---|
198 | |
---|
199 | END SELECT |
---|
200 | |
---|
201 | CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' ) |
---|
202 | |
---|
203 | END SUBROUTINE swap_timelevel |
---|
204 | |
---|
205 | |
---|