source: palm/trunk/SOURCE/init_1d_model.f90 @ 667

Last change on this file since 667 was 667, checked in by suehring, 13 years ago

summary:


Gryschka:

  • Coupling with different resolution and different numbers of PEs in ocean and atmosphere is available
  • Exchange of u and v from ocean surface to atmosphere surface
  • Mirror boundary condition for u and v at the bottom are replaced by dirichlet boundary conditions
  • Inflow turbulence is now defined by flucuations around spanwise mean
  • Bugfixes for cyclic_fill and constant_volume_flow

Suehring:

  • New advection added ( Wicker and Skamarock 5th order ), therefore:
    • New module advec_ws.f90
    • Modified exchange of ghost boundaries.
    • Modified evaluation of turbulent fluxes
    • New index bounds nxlg, nxrg, nysg, nyng

advec_ws.f90


Advection scheme for scalars and momentum using the flux formulation of
Wicker and Skamarock 5th order.
Additionally the module contains of a routine using for initialisation and
steering of the statical evaluation. The computation of turbulent fluxes takes
place inside the advection routines.
In case of vector architectures Dirichlet and Radiation boundary conditions are
outstanding and not available. Furthermore simulations within topography are
not possible so far. A further routine local_diss_ij is available and is used
if a control of dissipative fluxes is desired.

check_parameters.f90


Exchange of parameters between ocean and atmosphere via PE0
Check for illegal combination of ws-scheme and timestep scheme.
Check for topography and ws-scheme.
Check for not cyclic boundary conditions in combination with ws-scheme and
loop_optimization = 'vector'.
Check for call_psolver_at_all_substeps and ws-scheme for momentum_advec.

Different processor/grid topology in atmosphere and ocean is now allowed!
Bugfixes in checking for conserve_volume_flow_mode.

exchange_horiz.f90


Dynamic exchange of ghost points with nbgp_local to ensure that no useless
ghost points exchanged in case of multigrid. type_yz(0) and type_xz(0) used for
normal grid, the remaining types used for the several grid levels.
Exchange is done via MPI-Vectors with a dynamic value of ghost points which
depend on the advection scheme. Exchange of left and right PEs is 10% faster
with MPI-Vectors than without.

flow_statistics.f90


When advection is computed with ws-scheme, turbulent fluxes are already
computed in the respective advection routines and buffered in arrays
sums_xxxx_ws_l(). This is due to a consistent treatment of statistics
with the numerics and to avoid unphysical kinks near the surface. So some if-
requests has to be done to dicern between fluxes from ws-scheme other advection
schemes. Furthermore the computation of z_i is only done if the heat flux
exceeds a minimum value. This affects only simulations of a neutral boundary
layer and is due to reasons of computations in the advection scheme.

inflow_turbulence.f90


Using nbgp recycling planes for a better resolution of the turbulent flow near
the inflow.

init_grid.f90


Definition of new array bounds nxlg, nxrg, nysg, nyng on each PE.
Furthermore the allocation of arrays and steering of loops is done with these
parameters. Call of exchange_horiz are modified.
In case of dirichlet bounday condition at the bottom zu(0)=0.0
dzu_mg has to be set explicitly for a equally spaced grid near bottom.
ddzu_pres added to use a equally spaced grid near bottom.

init_pegrid.f90


Moved determination of target_id's from init_coupling
Determination of parameters needed for coupling (coupling_topology, ngp_a, ngp_o)
with different grid/processor-topology in ocean and atmosphere

Adaption of ngp_xy, ngp_y to a dynamic number of ghost points.
The maximum_grid_level changed from 1 to 0. 0 is the normal grid, 1 to
maximum_grid_level the grids for multigrid, in which 0 and 1 are normal grids.
This distinction is due to reasons of data exchange and performance for the
normal grid and grids in poismg.
The definition of MPI-Vectors adapted to a dynamic numer of ghost points.
New MPI-Vectors for data exchange between left and right boundaries added.
This is due to reasons of performance (10% faster).

ATTENTION: nnz_x undefined problem still has to be solved!!!!!!!!
TEST OUTPUT (TO BE REMOVED) logging mpi2 ierr values

parin.f90


Steering parameter dissipation_control added in inipar.

Makefile


Module advec_ws added.

Modules


Removed u_nzb_p1_for_vfc and v_nzb_p1_for_vfc

For coupling with different resolution in ocean and atmophere:
+nx_a, +nx_o, ny_a, +ny_o, ngp_a, ngp_o, +total_2d_o, +total_2d_a,
+coupling_topology

Buffer arrays for the left sided advective fluxes added in arrays_3d.
+flux_s_u, +flux_s_v, +flux_s_w, +diss_s_u, +diss_s_v, +diss_s_w,
+flux_s_pt, +diss_s_pt, +flux_s_e, +diss_s_e, +flux_s_q, +diss_s_q,
+flux_s_sa, +diss_s_sa
3d arrays for dissipation control added. (only necessary for vector arch.)
+var_x, +var_y, +var_z, +gamma_x, +gamma_y, +gamma_z
Default of momentum_advec and scalar_advec changed to 'ws-scheme' .
+exchange_mg added in control_parameters to steer the data exchange.
Parameters +nbgp, +nxlg, +nxrg, +nysg, +nyng added in indices.
flag array +boundary_flags added in indices to steer the degradation of order
of the advective fluxes when non-cyclic boundaries are used.
MPI-datatypes +type_y, +type_y_int and +type_yz for data_exchange added in
pegrid.
+sums_wsus_ws_l, +sums_wsvs_ws_l, +sums_us2_ws_l, +sums_vs2_ws_l,
+sums_ws2_ws_l, +sums_wspts_ws_l, +sums_wssas_ws_l, +sums_wsqs_ws_l
and +weight_substep added in statistics to steer the statistical evaluation
of turbulent fluxes in the advection routines.
LOGICALS +ws_scheme_sca and +ws_scheme_mom added to get a better performance
in prognostic_equations.
LOGICAL +dissipation_control control added to steer numerical dissipation
in ws-scheme.

Changed length of string run_description_header

pres.f90


New allocation of tend when ws-scheme and multigrid is used. This is due to
reasons of perforance of the data_exchange. The same is done with p after
poismg is called.
nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng when no
multigrid is used. Calls of exchange_horiz are modified.

bugfix: After pressure correction no volume flow correction in case of
non-cyclic boundary conditions
(has to be done only before pressure correction)

Call of SOR routine is referenced with ddzu_pres.

prognostic_equations.f90


Calls of the advection routines with WS5 added.
Calls of ws_statistics added to set the statistical arrays to zero after each
time step.

advec_particles.f90


Declaration of de_dx, de_dy, de_dz adapted to additional ghost points.
Furthermore the calls of exchange_horiz were modified.

asselin_filter.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

average_3d_data.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

boundary_conds.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng
Removed mirror boundary conditions for u and v at the bottom in case of
ibc_uv_b == 0. Instead, dirichelt boundary conditions (u=v=0) are set
in init_3d_model

calc_liquid_water_content.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

calc_spectra.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng for
allocation of tend.

check_open.f90


Output of total array size was adapted to nbgp.

data_output_2d.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays local_2d and total_2d.
Calls of exchange_horiz are modified.

data_output_2d.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays. Calls of exchange_horiz are modified.
Skip-value skip_do_avs changed to a dynamic adaption of ghost points.

data_output_mask.f90


Calls of exchange_horiz are modified.

diffusion_e.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_s.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_u.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_v.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusion_w.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusivities.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

diffusivities.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Calls of exchange_horiz are modified.

exchange_horiz_2d.f90


Dynamic exchange of ghost points with nbgp, which depends on the advection
scheme. Exchange between left and right PEs is now done with MPI-vectors.

global_min_max.f90


Adapting of the index arrays, because MINLOC assumes lowerbound
at 1 and not at nbgp.

init_3d_model.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in loops and
allocation of arrays. Calls of exchange_horiz are modified.
Call ws_init to initialize arrays needed for statistical evaluation and
optimization when ws-scheme is used.
Initial volume flow is now calculated by using the variable hom_sum.
Therefore the correction of initial volume flow for non-flat topography
removed (removed u_nzb_p1_for_vfc and v_nzb_p1_for_vfc)
Changed surface boundary conditions for u and v in case of ibc_uv_b == 0 from
mirror bc to dirichlet boundary conditions (u=v=0), so that k=nzb is
representative for the height z0

Bugfix: type conversion of '1' to 64bit for the MAX function (ngp_3d_inner)

init_coupling.f90


determination of target_id's moved to init_pegrid

init_pt_anomaly.f90


Call of exchange_horiz are modified.

init_rankine.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Calls of exchange_horiz are modified.

init_slope.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

header.f90


Output of advection scheme.

poismg.f90


Calls of exchange_horiz are modified.

prandtl_fluxes.f90


Changed surface boundary conditions for u and v from mirror bc to dirichelt bc,
therefore u(uzb,:,:) and v(nzb,:,:) is now representative for the height z0
nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

production_e.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng

read_3d_binary.f90


+/- 1 replaced with +/- nbgp when swapping and allocating variables.

sor.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.
Call of exchange_horiz are modified.
bug removed in declaration of ddzw(), nz replaced by nzt+1

subsidence.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

sum_up_3d_data.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

surface_coupler.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng in
MPI_SEND() and MPI_RECV.
additional case for nonequivalent processor and grid topopolgy in ocean and
atmosphere added (coupling_topology = 1)

Added exchange of u and v from Ocean to Atmosphere

time_integration.f90


Calls of exchange_horiz are modified.
Adaption to slooping surface.

timestep.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

user_3d_data_averaging.f90, user_data_output_2d.f90, user_data_output_3d.f90,
user_actions.f90, user_init.f90, user_init_plant_canopy.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

user_read_restart_data.f90


Allocation with nbgp.

wall_fluxes.f90


nxl-1, nxr+1, nys-1, nyn+1 replaced by nxlg, nxrg, nysg, nyng.

write_compressed.f90


Array bounds and nx, ny adapted with nbgp.

sor.f90


bug removed in declaration of ddzw(), nz replaced by nzt+1

  • Property svn:keywords set to Id
File size: 34.1 KB
Line 
1 SUBROUTINE init_1d_model
2
3!------------------------------------------------------------------------------!
4! Current revisions:
5! -----------------
6!
7!
8! Former revisions:
9! -----------------
10! $Id: init_1d_model.f90 667 2010-12-23 12:06:00Z suehring $
11!
12! 254 2009-03-05 15:33:42Z heinze
13! Output of messages replaced by message handling routine.
14!
15! 184 2008-08-04 15:53:39Z letzel
16! provisional solution for run_control_1d output: add 'CALL check_open( 15 )'
17!
18! 135 2007-11-22 12:24:23Z raasch
19! Bugfix: absolute value of f must be used when calculating the Blackadar
20! mixing length
21!
22! 82 2007-04-16 15:40:52Z raasch
23! Preprocessor strings for different linux clusters changed to "lc",
24! routine local_flush is used for buffer flushing
25!
26! 75 2007-03-22 09:54:05Z raasch
27! Bugfix: preset of tendencies te_em, te_um, te_vm,
28! moisture renamed humidity
29!
30! RCS Log replace by Id keyword, revision history cleaned up
31!
32! Revision 1.21  2006/06/02 15:19:57  raasch
33! cpp-directives extended for lctit
34!
35! Revision 1.1  1998/03/09 16:22:10  raasch
36! Initial revision
37!
38!
39! Description:
40! ------------
41! 1D-model to initialize the 3D-arrays.
42! The temperature profile is set as steady and a corresponding steady solution
43! of the wind profile is being computed.
44! All subroutines required can be found within this file.
45!------------------------------------------------------------------------------!
46
47    USE arrays_3d
48    USE indices
49    USE model_1d
50    USE control_parameters
51
52    IMPLICIT NONE
53
54    CHARACTER (LEN=9) ::  time_to_string
55    INTEGER ::  k
56    REAL    ::  lambda
57
58!
59!-- Allocate required 1D-arrays
60    ALLOCATE( e1d(nzb:nzt+1),    e1d_m(nzb:nzt+1),   e1d_p(nzb:nzt+1), &
61              kh1d(nzb:nzt+1),   kh1d_m(nzb:nzt+1),  km1d(nzb:nzt+1),  &
62              km1d_m(nzb:nzt+1), l_black(nzb:nzt+1), l1d(nzb:nzt+1),   &
63              l1d_m(nzb:nzt+1),  rif1d(nzb:nzt+1),   te_e(nzb:nzt+1),  &
64              te_em(nzb:nzt+1),  te_u(nzb:nzt+1),    te_um(nzb:nzt+1), &
65              te_v(nzb:nzt+1),   te_vm(nzb:nzt+1),    u1d(nzb:nzt+1),   &
66              u1d_m(nzb:nzt+1),  u1d_p(nzb:nzt+1),   v1d(nzb:nzt+1),   &
67              v1d_m(nzb:nzt+1),  v1d_p(nzb:nzt+1) )
68
69!
70!-- Initialize arrays
71    IF ( constant_diffusion )  THEN
72       km1d   = km_constant
73       km1d_m = km_constant
74       kh1d   = km_constant / prandtl_number
75       kh1d_m = km_constant / prandtl_number
76    ELSE
77       e1d = 0.0; e1d_m = 0.0; e1d_p = 0.0
78       kh1d = 0.0; kh1d_m = 0.0; km1d = 0.0; km1d_m = 0.0
79       rif1d = 0.0
80!
81!--    Compute the mixing length
82       l_black(nzb) = 0.0
83
84       IF ( TRIM( mixing_length_1d ) == 'blackadar' )  THEN
85!
86!--       Blackadar mixing length
87          IF ( f /= 0.0 )  THEN
88             lambda = 2.7E-4 * SQRT( ug(nzt+1)**2 + vg(nzt+1)**2 ) / &
89                               ABS( f ) + 1E-10
90          ELSE
91             lambda = 30.0
92          ENDIF
93
94          DO  k = nzb+1, nzt+1
95             l_black(k) = kappa * zu(k) / ( 1.0 + kappa * zu(k) / lambda )
96          ENDDO
97
98       ELSEIF ( TRIM( mixing_length_1d ) == 'as_in_3d_model' )  THEN
99!
100!--       Use the same mixing length as in 3D model
101          l_black(1:nzt) = l_grid
102          l_black(nzt+1) = l_black(nzt)
103
104       ENDIF
105
106!
107!--    Adjust mixing length to the prandtl mixing length (within the prandtl
108!--    layer)
109       IF ( adjust_mixing_length  .AND.  prandtl_layer )  THEN
110          k = nzb+1
111          l_black(k) = MIN( l_black(k), kappa * zu(k) )
112       ENDIF
113    ENDIF
114    l1d   = l_black
115    l1d_m = l_black
116    u1d   = u_init
117    u1d_m = u_init
118    u1d_p = u_init
119    v1d   = v_init
120    v1d_m = v_init
121    v1d_p = v_init
122
123!
124!-- Set initial horizontal velocities at the lowest grid levels to a very small
125!-- value in order to avoid too small time steps caused by the diffusion limit
126!-- in the initial phase of a run (at k=1, dz/2 occurs in the limiting formula!)
127    u1d(0:1)   = 0.1
128    u1d_m(0:1) = 0.1
129    u1d_p(0:1) = 0.1
130    v1d(0:1)   = 0.1
131    v1d_m(0:1) = 0.1
132    v1d_p(0:1) = 0.1
133
134!
135!-- For u*, theta* and the momentum fluxes plausible values are set
136    IF ( prandtl_layer )  THEN
137       us1d = 0.1   ! without initial friction the flow would not change
138    ELSE
139       e1d(nzb+1)  = 1.0
140       km1d(nzb+1) = 1.0
141       us1d = 0.0
142    ENDIF
143    ts1d = 0.0
144    usws1d = 0.0; usws1d_m = 0.0
145    vsws1d = 0.0; vsws1d_m = 0.0
146    z01d = roughness_length
147    IF ( humidity .OR. passive_scalar )  qs1d = 0.0
148
149!
150!-- Tendencies must be preset in order to avoid runtime errors within the
151!-- first Runge-Kutta step
152    te_em = 0.0
153    te_um = 0.0
154    te_vm = 0.0
155
156!
157!-- Set start time in hh:mm:ss - format
158    simulated_time_chr = time_to_string( simulated_time_1d )
159
160!
161!-- Integrate the 1D-model equations using the leap-frog scheme
162    CALL time_integration_1d
163
164
165 END SUBROUTINE init_1d_model
166
167
168
169 SUBROUTINE time_integration_1d
170
171!------------------------------------------------------------------------------!
172! Description:
173! ------------
174! Leap-frog time differencing scheme for the 1D-model.
175!------------------------------------------------------------------------------!
176
177    USE arrays_3d
178    USE control_parameters
179    USE indices
180    USE model_1d
181    USE pegrid
182
183    IMPLICIT NONE
184
185    CHARACTER (LEN=9) ::  time_to_string
186    INTEGER ::  k
187    REAL    ::  a, b, dissipation, dpt_dz, flux, kmzm, kmzp, l_stable, pt_0, &
188                uv_total
189
190!
191!-- Determine the time step at the start of a 1D-simulation and
192!-- determine and printout quantities used for run control
193    CALL timestep_1d
194    CALL run_control_1d
195
196!
197!-- Start of time loop
198    DO  WHILE ( simulated_time_1d < end_time_1d  .AND.  .NOT. stop_dt_1d )
199
200!
201!--    Depending on the timestep scheme, carry out one or more intermediate
202!--    timesteps
203
204       intermediate_timestep_count = 0
205       DO  WHILE ( intermediate_timestep_count < &
206                   intermediate_timestep_count_max )
207
208          intermediate_timestep_count = intermediate_timestep_count + 1
209
210          CALL timestep_scheme_steering
211
212!
213!--       Compute all tendency terms. If a Prandtl-layer is simulated, k starts
214!--       at nzb+2.
215          DO  k = nzb_diff, nzt
216
217             kmzm = 0.5 * ( km1d_m(k-1) + km1d_m(k) )
218             kmzp = 0.5 * ( km1d_m(k) + km1d_m(k+1) )
219!
220!--          u-component
221             te_u(k) =  f * ( v1d(k) - vg(k) ) + ( &
222                              kmzp * ( u1d_m(k+1) - u1d_m(k) ) * ddzu(k+1) &
223                            - kmzm * ( u1d_m(k) - u1d_m(k-1) ) * ddzu(k)   &
224                                              ) * ddzw(k)
225!
226!--          v-component
227             te_v(k) = -f * ( u1d(k) - ug(k) ) + ( &
228                              kmzp * ( v1d_m(k+1) - v1d_m(k) ) * ddzu(k+1) &
229                            - kmzm * ( v1d_m(k) - v1d_m(k-1) ) * ddzu(k)   &
230                                              ) * ddzw(k)
231          ENDDO
232          IF ( .NOT. constant_diffusion )  THEN
233             DO  k = nzb_diff, nzt
234!
235!--             TKE
236                kmzm = 0.5 * ( km1d_m(k-1) + km1d_m(k) )
237                kmzp = 0.5 * ( km1d_m(k) + km1d_m(k+1) )
238                IF ( .NOT. humidity )  THEN
239                   pt_0 = pt_init(k)
240                   flux =  ( pt_init(k+1)-pt_init(k-1) ) * dd2zu(k)
241                ELSE
242                   pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) )
243                   flux = ( ( pt_init(k+1) - pt_init(k-1) ) +                 &
244                            0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) ) &
245                          ) * dd2zu(k)
246                ENDIF
247
248                IF ( dissipation_1d == 'detering' )  THEN
249!
250!--                According to Detering, c_e=0.064
251                   dissipation = 0.064 * e1d_m(k) * SQRT( e1d_m(k) ) / l1d_m(k)
252                ELSEIF ( dissipation_1d == 'as_in_3d_model' )  THEN
253                   dissipation = ( 0.19 + 0.74 * l1d_m(k) / l_grid(k) ) &
254                                 * e1d_m(k) * SQRT( e1d_m(k) ) / l1d_m(k)
255                ENDIF
256
257                te_e(k) = km1d(k) * ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2&
258                                    + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2&
259                                    )                                          &
260                                    - g / pt_0 * kh1d(k) * flux                &
261                                    +            (                             &
262                                 kmzp * ( e1d_m(k+1) - e1d_m(k) ) * ddzu(k+1)  &
263                               - kmzm * ( e1d_m(k) - e1d_m(k-1) ) * ddzu(k)    &
264                                                 ) * ddzw(k)                   &
265                               - dissipation
266             ENDDO
267          ENDIF
268
269!
270!--       Tendency terms at the top of the Prandtl-layer.
271!--       Finite differences of the momentum fluxes are computed using half the
272!--       normal grid length (2.0*ddzw(k)) for the sake of enhanced accuracy
273          IF ( prandtl_layer )  THEN
274
275             k = nzb+1
276             kmzm = 0.5 * ( km1d_m(k-1) + km1d_m(k) )
277             kmzp = 0.5 * ( km1d_m(k) + km1d_m(k+1) )
278             IF ( .NOT. humidity )  THEN
279                pt_0 = pt_init(k)
280                flux =  ( pt_init(k+1)-pt_init(k-1) ) * dd2zu(k)
281             ELSE
282                pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) )
283                flux = ( ( pt_init(k+1) - pt_init(k-1) ) +                 &
284                         0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) ) &
285                       ) * dd2zu(k)
286             ENDIF
287
288             IF ( dissipation_1d == 'detering' )  THEN
289!
290!--             According to Detering, c_e=0.064
291                dissipation = 0.064 * e1d_m(k) * SQRT( e1d_m(k) ) / l1d_m(k)
292             ELSEIF ( dissipation_1d == 'as_in_3d_model' )  THEN
293                dissipation = ( 0.19 + 0.74 * l1d_m(k) / l_grid(k) ) &
294                              * e1d_m(k) * SQRT( e1d_m(k) ) / l1d_m(k)
295             ENDIF
296
297!
298!--          u-component
299             te_u(k) = f * ( v1d(k) - vg(k) ) + ( &
300                       kmzp * ( u1d_m(k+1) - u1d_m(k) ) * ddzu(k+1) + usws1d_m &
301                                               ) * 2.0 * ddzw(k)
302!
303!--          v-component
304             te_v(k) = -f * ( u1d(k) - ug(k) ) + ( &
305                       kmzp * ( v1d_m(k+1) - v1d_m(k) ) * ddzu(k+1) + vsws1d_m &
306                                           ) * 2.0 * ddzw(k)
307!
308!--          TKE
309             te_e(k) = km1d(k) * ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2   &
310                                 + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2   &
311                                 )                                             &
312                                 - g / pt_0 * kh1d(k) * flux                   &
313                                 +           (                                 &
314                              kmzp * ( e1d_m(k+1) - e1d_m(k) ) * ddzu(k+1)     &
315                            - kmzm * ( e1d_m(k) - e1d_m(k-1) ) * ddzu(k)       &
316                                              ) * ddzw(k)                      &
317                            - dissipation
318          ENDIF
319
320!
321!--       Prognostic equations for all 1D variables
322          DO  k = nzb+1, nzt
323
324             u1d_p(k) = ( 1. - tsc(1) ) * u1d_m(k) + &
325                        tsc(1) * u1d(k) + dt_1d * ( tsc(2) * te_u(k) + &
326                                                    tsc(3) * te_um(k) ) 
327             v1d_p(k) = ( 1. - tsc(1) ) * v1d_m(k) + &
328                        tsc(1) * v1d(k) + dt_1d * ( tsc(2) * te_v(k) + &
329                                                    tsc(3) * te_vm(k) ) 
330
331          ENDDO
332          IF ( .NOT. constant_diffusion )  THEN
333             DO  k = nzb+1, nzt
334
335                e1d_p(k) = ( 1. - tsc(1) ) * e1d_m(k) + &
336                           tsc(1) * e1d(k) + dt_1d * ( tsc(2) * te_e(k) + &
337                                                       tsc(3) * te_em(k) ) 
338
339             ENDDO
340!
341!--          Eliminate negative TKE values, which can result from the
342!--          integration due to numerical inaccuracies. In such cases the TKE
343!--          value is reduced to 10 percent of its old value.
344             WHERE ( e1d_p < 0.0 )  e1d_p = 0.1 * e1d
345          ENDIF
346
347!
348!--       Calculate tendencies for the next Runge-Kutta step
349          IF ( timestep_scheme(1:5) == 'runge' ) THEN
350             IF ( intermediate_timestep_count == 1 )  THEN
351
352                DO  k = nzb+1, nzt
353                   te_um(k) = te_u(k)
354                   te_vm(k) = te_v(k)
355                ENDDO
356
357                IF ( .NOT. constant_diffusion )  THEN
358                   DO k = nzb+1, nzt
359                      te_em(k) = te_e(k)
360                   ENDDO
361                ENDIF
362
363             ELSEIF ( intermediate_timestep_count < &
364                         intermediate_timestep_count_max )  THEN
365
366                DO  k = nzb+1, nzt
367                   te_um(k) = -9.5625 * te_u(k) + 5.3125 * te_um(k)
368                   te_vm(k) = -9.5625 * te_v(k) + 5.3125 * te_vm(k)
369                ENDDO
370
371                IF ( .NOT. constant_diffusion )  THEN
372                   DO k = nzb+1, nzt
373                      te_em(k) = -9.5625 * te_e(k) + 5.3125 * te_em(k)
374                   ENDDO
375                ENDIF
376
377             ENDIF
378          ENDIF
379
380
381!
382!--       Boundary conditions for the prognostic variables.
383!--       At the top boundary (nzt+1) u,v and e keep their initial values
384!--       (ug(nzt+1), vg(nzt+1), 0), at the bottom boundary the mirror
385!--       boundary condition applies to u and v.
386!--       The boundary condition for e is set further below ( (u*/cm)**2 ).
387         ! u1d_p(nzb) = -u1d_p(nzb+1)
388         ! v1d_p(nzb) = -v1d_p(nzb+1)
389
390          u1d_p(nzb) = 0.0
391          v1d_p(nzb) = 0.0
392
393!
394!--       If necessary, apply the time filter
395          IF ( asselin_filter_factor /= 0.0  .AND. &
396               timestep_scheme(1:5) /= 'runge' )  THEN
397
398             u1d = u1d + asselin_filter_factor * ( u1d_p - 2.0 * u1d + u1d_m )
399             v1d = v1d + asselin_filter_factor * ( v1d_p - 2.0 * v1d + v1d_m )
400
401             IF ( .NOT. constant_diffusion )  THEN
402                e1d = e1d + asselin_filter_factor * &
403                            ( e1d_p - 2.0 * e1d + e1d_m )
404             ENDIF
405
406          ENDIF
407
408!
409!--       Swap the time levels in preparation for the next time step.
410          IF ( timestep_scheme(1:4) == 'leap' )  THEN
411             u1d_m  = u1d
412             v1d_m  = v1d
413             IF ( .NOT. constant_diffusion )  THEN
414                e1d_m  = e1d
415                kh1d_m = kh1d  ! The old diffusion quantities are required for
416                km1d_m = km1d  ! explicit diffusion in the leap-frog scheme.
417                l1d_m  = l1d
418                IF ( prandtl_layer )  THEN
419                   usws1d_m = usws1d
420                   vsws1d_m = vsws1d
421                ENDIF
422             ENDIF
423          ENDIF
424          u1d  = u1d_p
425          v1d  = v1d_p
426          IF ( .NOT. constant_diffusion )  THEN
427             e1d  = e1d_p
428          ENDIF
429
430!
431!--       Compute diffusion quantities
432          IF ( .NOT. constant_diffusion )  THEN
433
434!
435!--          First compute the vertical fluxes in the Prandtl-layer
436             IF ( prandtl_layer )  THEN
437!
438!--             Compute theta* using Rif numbers of the previous time step
439                IF ( rif1d(1) >= 0.0 )  THEN
440!
441!--                Stable stratification
442                   ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) /      &
443                          ( LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) * &
444                                          ( zu(nzb+1) - z01d ) / zu(nzb+1) &
445                          )
446                ELSE
447!
448!--                Unstable stratification
449                   a = SQRT( 1.0 - 16.0 * rif1d(nzb+1) )
450                   b = SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) * z01d )
451!
452!--                In the borderline case the formula for stable stratification
453!--                must be applied, because otherwise a zero division would
454!--                occur in the argument of the logarithm.
455                   IF ( a == 0.0  .OR.  b == 0.0 )  THEN
456                      ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) /      &
457                             ( LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) * &
458                                             ( zu(nzb+1) - z01d ) / zu(nzb+1) &
459                             )
460                   ELSE
461                      ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) / &
462                             LOG( (a-1.0) / (a+1.0) * (b+1.0) / (b-1.0) )
463                   ENDIF
464                ENDIF
465
466             ENDIF    ! prandtl_layer
467
468!
469!--          Compute the Richardson-flux numbers,
470!--          first at the top of the Prandtl-layer using u* of the previous
471!--          time step (+1E-30, if u* = 0), then in the remaining area. There
472!--          the rif-numbers of the previous time step are used.
473
474             IF ( prandtl_layer )  THEN
475                IF ( .NOT. humidity )  THEN
476                   pt_0 = pt_init(nzb+1)
477                   flux = ts1d
478                ELSE
479                   pt_0 = pt_init(nzb+1) * ( 1.0 + 0.61 * q_init(nzb+1) )
480                   flux = ts1d + 0.61 * pt_init(k) * qs1d
481                ENDIF
482                rif1d(nzb+1) = zu(nzb+1) * kappa * g * flux / &
483                               ( pt_0 * ( us1d**2 + 1E-30 ) )
484             ENDIF
485
486             DO  k = nzb_diff, nzt
487                IF ( .NOT. humidity )  THEN
488                   pt_0 = pt_init(k)
489                   flux = ( pt_init(k+1) - pt_init(k-1) ) * dd2zu(k)
490                ELSE
491                   pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) )
492                   flux = ( ( pt_init(k+1) - pt_init(k-1) )                    &
493                            + 0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) )&
494                          ) * dd2zu(k)
495                ENDIF
496                IF ( rif1d(k) >= 0.0 )  THEN
497                   rif1d(k) = g / pt_0 * flux /                              &
498                              (  ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2   &
499                               + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2   &
500                               + 1E-30                                       &
501                              )
502                ELSE
503                   rif1d(k) = g / pt_0 * flux /                              &
504                              (  ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2   &
505                               + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2   &
506                               + 1E-30                                       &
507                              ) * ( 1.0 - 16.0 * rif1d(k) )**0.25
508                ENDIF
509             ENDDO
510!
511!--          Richardson-numbers must remain restricted to a realistic value
512!--          range. It is exceeded excessively for very small velocities
513!--          (u,v --> 0).
514             WHERE ( rif1d < rif_min )  rif1d = rif_min
515             WHERE ( rif1d > rif_max )  rif1d = rif_max
516
517!
518!--          Compute u* from the absolute velocity value
519             IF ( prandtl_layer )  THEN
520                uv_total = SQRT( u1d(nzb+1)**2 + v1d(nzb+1)**2 )
521
522                IF ( rif1d(nzb+1) >= 0.0 )  THEN
523!
524!--                Stable stratification
525                   us1d = kappa * uv_total / (                                 &
526                             LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) *    &
527                                              ( zu(nzb+1) - z01d ) / zu(nzb+1) &
528                                             )
529                ELSE
530!
531!--                Unstable stratification
532                   a = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif1d(nzb+1) ) )
533                   b = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) &
534                                                    * z01d ) )
535!
536!--                In the borderline case the formula for stable stratification
537!--                must be applied, because otherwise a zero division would
538!--                occur in the argument of the logarithm.
539                   IF ( a == 1.0  .OR.  b == 1.0 )  THEN
540                      us1d = kappa * uv_total / (                            &
541                             LOG( zu(nzb+1) / z01d ) +                       &
542                             5.0 * rif1d(nzb+1) * ( zu(nzb+1) - z01d ) /     &
543                                                  zu(nzb+1) )
544                   ELSE
545                      us1d = kappa * uv_total / (                              &
546                                 LOG( (1.0+b) / (1.0-b) * (1.0-a) / (1.0+a) ) +&
547                                 2.0 * ( ATAN( b ) - ATAN( a ) )               &
548                                                )
549                   ENDIF
550                ENDIF
551
552!
553!--             Compute the momentum fluxes for the diffusion terms
554                usws1d  = - u1d(nzb+1) / uv_total * us1d**2
555                vsws1d  = - v1d(nzb+1) / uv_total * us1d**2
556
557!
558!--             Boundary condition for the turbulent kinetic energy at the top
559!--             of the Prandtl-layer. c_m = 0.4 according to Detering.
560!--             Additional Neumann condition de/dz = 0 at nzb is set to ensure
561!--             compatibility with the 3D model.
562                IF ( ibc_e_b == 2 )  THEN
563                   e1d(nzb+1) = ( us1d / 0.1 )**2
564!                  e1d(nzb+1) = ( us1d / 0.4 )**2  !not used so far, see also
565                                                   !prandtl_fluxes
566                ENDIF
567                e1d(nzb) = e1d(nzb+1)
568
569                IF ( humidity .OR. passive_scalar ) THEN
570!
571!--                Compute q*
572                   IF ( rif1d(1) >= 0.0 )  THEN
573!
574!--                Stable stratification
575                   qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) /        &
576                          ( LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) * &
577                                          ( zu(nzb+1) - z01d ) / zu(nzb+1) &
578                          )
579                ELSE
580!
581!--                Unstable stratification
582                   a = SQRT( 1.0 - 16.0 * rif1d(nzb+1) )
583                   b = SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) * z01d )
584!
585!--                In the borderline case the formula for stable stratification
586!--                must be applied, because otherwise a zero division would
587!--                occur in the argument of the logarithm.
588                   IF ( a == 1.0  .OR.  b == 1.0 )  THEN
589                      qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) /        &
590                             ( LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) * &
591                                             ( zu(nzb+1) - z01d ) / zu(nzb+1) &
592                             )
593                   ELSE
594                      qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) / &
595                             LOG( (a-1.0) / (a+1.0) * (b+1.0) / (b-1.0) )
596                   ENDIF
597                ENDIF               
598                ELSE
599                   qs1d = 0.0
600                ENDIF             
601
602             ENDIF   !  prandtl_layer
603
604!
605!--          Compute the diabatic mixing length
606             IF ( mixing_length_1d == 'blackadar' )  THEN
607                DO  k = nzb+1, nzt
608                   IF ( rif1d(k) >= 0.0 )  THEN
609                      l1d(k) = l_black(k) / ( 1.0 + 5.0 * rif1d(k) )
610                   ELSE
611                      l1d(k) = l_black(k) * ( 1.0 - 16.0 * rif1d(k) )**0.25
612                   ENDIF
613                   l1d(k) = l_black(k)
614                ENDDO
615
616             ELSEIF ( mixing_length_1d == 'as_in_3d_model' )  THEN
617                DO  k = nzb+1, nzt
618                   dpt_dz = ( pt_init(k+1) - pt_init(k-1) ) * dd2zu(k)
619                   IF ( dpt_dz > 0.0 )  THEN
620                      l_stable = 0.76 * SQRT( e1d(k) ) / &
621                                     SQRT( g / pt_init(k) * dpt_dz ) + 1E-5
622                   ELSE
623                      l_stable = l_grid(k)
624                   ENDIF
625                   l1d(k) = MIN( l_grid(k), l_stable )
626                ENDDO
627             ENDIF
628
629!
630!--          Adjust mixing length to the prandtl mixing length
631             IF ( adjust_mixing_length  .AND.  prandtl_layer )  THEN
632                k = nzb+1
633                IF ( rif1d(k) >= 0.0 )  THEN
634                   l1d(k) = MIN( l1d(k), kappa * zu(k) / ( 1.0 + 5.0 * &
635                                                           rif1d(k) ) )
636                ELSE
637                   l1d(k) = MIN( l1d(k), kappa * zu(k) *          &
638                                  SQRT( SQRT( 1.0 - 16.0 * rif1d(k) ) ) )
639                ENDIF
640             ENDIF
641
642!
643!--          Compute the diffusion coefficients for momentum via the
644!--          corresponding Prandtl-layer relationship and according to
645!--          Prandtl-Kolmogorov, respectively. The unstable stratification is
646!--          computed via the adiabatic mixing length, for the unstability has
647!--          already been taken account of via the TKE (cf. also Diss.).
648             IF ( prandtl_layer )  THEN
649                IF ( rif1d(nzb+1) >= 0.0 )  THEN
650                   km1d(nzb+1) = us1d * kappa * zu(nzb+1) / &
651                                 ( 1.0 + 5.0 * rif1d(nzb+1) )
652                ELSE
653                   km1d(nzb+1) = us1d * kappa * zu(nzb+1) * &
654                                 ( 1.0 - 16.0 * rif1d(nzb+1) )**0.25
655                ENDIF
656             ENDIF
657             DO  k = nzb_diff, nzt
658!                km1d(k) = 0.4 * SQRT( e1d(k) ) !changed: adjustment to 3D-model
659                km1d(k) = 0.1 * SQRT( e1d(k) )
660                IF ( rif1d(k) >= 0.0 )  THEN
661                   km1d(k) = km1d(k) * l1d(k)
662                ELSE
663                   km1d(k) = km1d(k) * l_black(k)
664                ENDIF
665             ENDDO
666
667!
668!--          Add damping layer
669             DO  k = damp_level_ind_1d+1, nzt+1
670                km1d(k) = 1.1 * km1d(k-1)
671                km1d(k) = MIN( km1d(k), 10.0 )
672             ENDDO
673
674!
675!--          Compute the diffusion coefficient for heat via the relationship
676!--          kh = phim / phih * km
677             DO  k = nzb+1, nzt
678                IF ( rif1d(k) >= 0.0 )  THEN
679                   kh1d(k) = km1d(k)
680                ELSE
681                   kh1d(k) = km1d(k) * ( 1.0 - 16.0 * rif1d(k) )**0.25
682                ENDIF
683             ENDDO
684
685          ENDIF   ! .NOT. constant_diffusion
686
687!
688!--       The Runge-Kutta scheme needs the recent diffusion quantities
689          IF ( timestep_scheme(1:5) == 'runge' )  THEN
690             u1d_m  = u1d
691             v1d_m  = v1d
692             IF ( .NOT. constant_diffusion )  THEN
693                e1d_m  = e1d
694                kh1d_m = kh1d
695                km1d_m = km1d
696                l1d_m  = l1d
697                IF ( prandtl_layer )  THEN
698                   usws1d_m = usws1d
699                   vsws1d_m = vsws1d
700                ENDIF
701             ENDIF
702          ENDIF
703
704
705       ENDDO   ! intermediate step loop
706
707!
708!--    Increment simulated time and output times
709       current_timestep_number_1d = current_timestep_number_1d + 1
710       simulated_time_1d          = simulated_time_1d + dt_1d
711       simulated_time_chr         = time_to_string( simulated_time_1d )
712       time_pr_1d                 = time_pr_1d          + dt_1d
713       time_run_control_1d        = time_run_control_1d + dt_1d
714
715!
716!--    Determine and print out quantities for run control
717       IF ( time_run_control_1d >= dt_run_control_1d )  THEN
718          CALL run_control_1d
719          time_run_control_1d = time_run_control_1d - dt_run_control_1d
720       ENDIF
721
722!
723!--    Profile output on file
724       IF ( time_pr_1d >= dt_pr_1d )  THEN
725          CALL print_1d_model
726          time_pr_1d = time_pr_1d - dt_pr_1d
727       ENDIF
728
729!
730!--    Determine size of next time step
731       CALL timestep_1d
732
733    ENDDO   ! time loop
734
735
736 END SUBROUTINE time_integration_1d
737
738
739 SUBROUTINE run_control_1d
740
741!------------------------------------------------------------------------------!
742! Description:
743! ------------
744! Compute and print out quantities for run control of the 1D model.
745!------------------------------------------------------------------------------!
746
747    USE constants
748    USE indices
749    USE model_1d
750    USE pegrid
751    USE control_parameters
752
753    IMPLICIT NONE
754
755    INTEGER ::  k
756    REAL    ::  alpha, energy, umax, uv_total, vmax
757
758!
759!-- Output
760    IF ( myid == 0 )  THEN
761!
762!--    If necessary, write header
763       IF ( .NOT. run_control_header_1d )  THEN
764          CALL check_open( 15 )
765          WRITE ( 15, 100 )
766          run_control_header_1d = .TRUE.
767       ENDIF
768
769!
770!--    Compute control quantities
771!--    grid level nzp is excluded due to mirror boundary condition
772       umax = 0.0; vmax = 0.0; energy = 0.0
773       DO  k = nzb+1, nzt+1
774          umax = MAX( ABS( umax ), ABS( u1d(k) ) )
775          vmax = MAX( ABS( vmax ), ABS( v1d(k) ) )
776          energy = energy + 0.5 * ( u1d(k)**2 + v1d(k)**2 )
777       ENDDO
778       energy = energy / REAL( nzt - nzb + 1 )
779
780       uv_total = SQRT( u1d(nzb+1)**2 + v1d(nzb+1)**2 )
781       IF ( ABS( v1d(nzb+1) ) .LT. 1.0E-5 )  THEN
782          alpha = ACOS( SIGN( 1.0 , u1d(nzb+1) ) )
783       ELSE
784          alpha = ACOS( u1d(nzb+1) / uv_total )
785          IF ( v1d(nzb+1) <= 0.0 )  alpha = 2.0 * pi - alpha
786       ENDIF
787       alpha = alpha / ( 2.0 * pi ) * 360.0
788
789       WRITE ( 15, 101 )  current_timestep_number_1d, simulated_time_chr, &
790                          dt_1d, umax, vmax, us1d, alpha, energy
791!
792!--    Write buffer contents to disc immediately
793       CALL local_flush( 15 )
794
795    ENDIF
796
797!
798!-- formats
799100 FORMAT (///'1D-Zeitschrittkontrollausgaben:'/ &
800              &'------------------------------'// &
801           &'ITER.  HH:MM:SS    DT      UMAX   VMAX    U*   ALPHA   ENERG.'/ &
802           &'-------------------------------------------------------------')
803101 FORMAT (I5,2X,A9,1X,F6.2,2X,F6.2,1X,F6.2,2X,F5.3,2X,F5.1,2X,F7.2)
804
805
806 END SUBROUTINE run_control_1d
807
808
809
810 SUBROUTINE timestep_1d
811
812!------------------------------------------------------------------------------!
813! Description:
814! ------------
815! Compute the time step w.r.t. the diffusion criterion
816!------------------------------------------------------------------------------!
817
818    USE arrays_3d
819    USE indices
820    USE model_1d
821    USE pegrid
822    USE control_parameters
823
824    IMPLICIT NONE
825
826    INTEGER ::  k
827    REAL    ::  div, dt_diff, fac, percent_change, value
828
829
830!
831!-- Compute the currently feasible time step according to the diffusion
832!-- criterion. At nzb+1 the half grid length is used.
833    IF ( timestep_scheme(1:4) == 'leap' )  THEN
834       fac = 0.25
835    ELSE
836       fac = 0.35
837    ENDIF
838    dt_diff = dt_max_1d
839    DO  k = nzb+2, nzt
840       value   = fac * dzu(k) * dzu(k) / ( km1d(k) + 1E-20 )
841       dt_diff = MIN( value, dt_diff )
842    ENDDO
843    value   = fac * zu(nzb+1) * zu(nzb+1) / ( km1d(nzb+1) + 1E-20 )
844    dt_1d = MIN( value, dt_diff )
845
846!
847!-- Set flag when the time step becomes too small
848    IF ( dt_1d < ( 0.00001 * dt_max_1d ) )  THEN
849       stop_dt_1d = .TRUE.
850
851       WRITE( message_string, * ) 'timestep has exceeded the lower limit &', &
852                                  'dt_1d = ',dt_1d,' s   simulation stopped!'
853       CALL message( 'timestep_1d', 'PA0192', 1, 2, 0, 6, 0 )
854       
855    ENDIF
856
857    IF ( timestep_scheme(1:4) == 'leap' )  THEN
858
859!
860!--    The current time step will only be changed if the new time step exceeds
861!--    its previous value by 5 % or falls 2 % below. After a time step
862!--    reduction at least 30 iterations must be done with this value before a
863!--    new reduction will be allowed again.
864!--    The control parameters for application of Euler- or leap-frog schemes are
865!--    set accordingly.
866       percent_change = dt_1d / old_dt_1d - 1.0
867       IF ( percent_change > 0.05  .OR.  percent_change < -0.02 )  THEN
868
869!
870!--       Each time step increase is by at most 2 %
871          IF ( percent_change > 0.0  .AND.  simulated_time_1d /= 0.0 )  THEN
872             dt_1d = 1.02 * old_dt_1d
873          ENDIF
874
875!
876!--       A more or less simple new time step value is obtained taking only the
877!--       first two significant digits
878          div = 1000.0
879          DO  WHILE ( dt_1d < div )
880             div = div / 10.0
881          ENDDO
882          dt_1d = NINT( dt_1d * 100.0 / div ) * div / 100.0
883
884!
885!--       Now the time step can be changed.
886          IF ( percent_change < 0.0 )  THEN
887!
888!--          Time step reduction
889             old_dt_1d = dt_1d
890             last_dt_change_1d = current_timestep_number_1d
891          ELSE
892!
893!--          Time step will only be increased if at least 30 iterations have
894!--          been done since the previous time step change, and of course at
895!--          simulation start, respectively.
896             IF ( current_timestep_number_1d >= last_dt_change_1d + 30  .OR. &
897                     simulated_time_1d == 0.0 )  THEN
898                old_dt_1d = dt_1d
899                last_dt_change_1d = current_timestep_number_1d
900             ELSE
901                dt_1d = old_dt_1d
902             ENDIF
903          ENDIF
904       ELSE
905!
906!--       No time step change since the difference is too small
907          dt_1d = old_dt_1d
908       ENDIF
909
910    ELSE    ! Runge-Kutta
911
912!--    A more or less simple new time step value is obtained taking only the
913!--    first two significant digits
914       div = 1000.0
915       DO  WHILE ( dt_1d < div )
916          div = div / 10.0
917       ENDDO
918       dt_1d = NINT( dt_1d * 100.0 / div ) * div / 100.0
919
920       old_dt_1d = dt_1d
921       last_dt_change_1d = current_timestep_number_1d
922
923    ENDIF
924
925 END SUBROUTINE timestep_1d
926
927
928
929 SUBROUTINE print_1d_model
930
931!------------------------------------------------------------------------------!
932! Description:
933! ------------
934! List output of profiles from the 1D-model
935!------------------------------------------------------------------------------!
936
937    USE arrays_3d
938    USE indices
939    USE model_1d
940    USE pegrid
941    USE control_parameters
942
943    IMPLICIT NONE
944
945
946    INTEGER ::  k
947
948
949    IF ( myid == 0 )  THEN
950!
951!--    Open list output file for profiles from the 1D-model
952       CALL check_open( 17 )
953
954!
955!--    Write Header
956       WRITE ( 17, 100 )  TRIM( run_description_header ), &
957                          TRIM( simulated_time_chr )
958       WRITE ( 17, 101 )
959
960!
961!--    Write the values
962       WRITE ( 17, 102 )
963       WRITE ( 17, 101 )
964       DO  k = nzt+1, nzb, -1
965          WRITE ( 17, 103)  k, zu(k), u1d(k), v1d(k), pt_init(k), e1d(k), &
966                            rif1d(k), km1d(k), kh1d(k), l1d(k), zu(k), k
967       ENDDO
968       WRITE ( 17, 101 )
969       WRITE ( 17, 102 )
970       WRITE ( 17, 101 )
971
972!
973!--    Write buffer contents to disc immediately
974       CALL local_flush( 17 )
975
976    ENDIF
977
978!
979!-- Formats
980100 FORMAT (//1X,A/1X,10('-')/' 1d-model profiles'/ &
981            ' Time: ',A)
982101 FORMAT (1X,79('-'))
983102 FORMAT ('   k     zu      u      v     pt      e    rif    Km    Kh     ', &
984            'l      zu      k')
985103 FORMAT (1X,I4,1X,F7.1,1X,F6.2,1X,F6.2,1X,F6.2,1X,F6.2,1X,F5.2,1X,F5.2, &
986            1X,F5.2,1X,F6.2,1X,F7.1,2X,I4)
987
988
989 END SUBROUTINE print_1d_model
Note: See TracBrowser for help on using the repository browser.