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