#if defined( __ibmy_special ) @PROCESS NOOPTimize #endif SUBROUTINE init_3d_model !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: init_3d_model.f90 4 2007-02-13 11:33:16Z raasch $ ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.49 2006/08/22 15:59:07 raasch ! No optimization of this file on the ibmy (Yonsei Univ.) ! ! Revision 1.1 1998/03/09 16:22:22 raasch ! Initial revision ! ! ! Description: ! ------------ ! Allocation of arrays and initialization of the 3D model via ! a) pre-run the 1D model ! or ! b) pre-set constant linear profiles ! or ! c) read values of a previous run !------------------------------------------------------------------------------! USE arrays_3d USE averaging USE constants USE control_parameters USE cpulog USE indices USE interfaces USE model_1d USE particle_attributes USE pegrid USE profil_parameter USE random_function_mod USE statistics IMPLICIT NONE INTEGER :: i, j, k, sr INTEGER, DIMENSION(:), ALLOCATABLE :: ngp_2dh_l, ngp_3d_inner_l INTEGER, DIMENSION(:,:), ALLOCATABLE :: ngp_2dh_outer_l REAL, DIMENSION(1:2) :: volume_flow_area_l, volume_flow_initial_l ! !-- Allocate arrays ALLOCATE( ngp_2dh(0:statistic_regions), ngp_2dh_l(0:statistic_regions), & ngp_3d(0:statistic_regions), & ngp_3d_inner(0:statistic_regions), & ngp_3d_inner_l(0:statistic_regions), & sums_divnew_l(0:statistic_regions), & sums_divold_l(0:statistic_regions) ) ALLOCATE( rdf(nzb+1:nzt), uvmean_outflow(nzb:nzt+1), & uvmean_outflow_l(nzb:nzt+1) ) ALLOCATE( hom_sum(nzb:nzt+1,var_hom,0:statistic_regions), & ngp_2dh_outer(nzb:nzt+1,0:statistic_regions), & ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions), & rmask(nys-1:nyn+1,nxl-1:nxr+1,0:statistic_regions), & sums(nzb:nzt+1,var_sum), & sums_l(nzb:nzt+1,var_sum,0:threads_per_task-1), & sums_l_l(nzb:nzt+1,0:statistic_regions,0:threads_per_task-1), & sums_up_fraction_l(10,3,0:statistic_regions), & sums_wsts_bc_l(nzb:nzt+1,0:statistic_regions) ) ALLOCATE( km_damp_x(nxl-1:nxr+1), km_damp_y(nys-1:nyn+1) ) ALLOCATE( rif_1(nys-1:nyn+1,nxl-1:nxr+1), shf_1(nys-1:nyn+1,nxl-1:nxr+1), & ts(nys-1:nyn+1,nxl-1:nxr+1), us(nys-1:nyn+1,nxl-1:nxr+1), & usws_1(nys-1:nyn+1,nxl-1:nxr+1), vsws_1(nys-1:nyn+1,nxl-1:nxr+1),& z0(nys-1:nyn+1,nxl-1:nxr+1) ) IF ( timestep_scheme(1:5) /= 'runge' ) THEN ! !-- Leapfrog scheme needs two timelevels of diffusion quantities ALLOCATE( rif_2(nys-1:nyn+1,nxl-1:nxr+1), & shf_2(nys-1:nyn+1,nxl-1:nxr+1), & usws_2(nys-1:nyn+1,nxl-1:nxr+1), & vsws_2(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF ALLOCATE( d(nzb+1:nzta,nys:nyna,nxl:nxra), & e_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & e_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & e_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & kh_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & km_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & p(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & pt_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & pt_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & pt_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & u_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1+uxrp), & u_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1+uxrp), & u_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1+uxrp), & v_1(nzb:nzt+1,nys-1:nyn+1+vynp,nxl-1:nxr+1), & v_2(nzb:nzt+1,nys-1:nyn+1+vynp,nxl-1:nxr+1), & v_3(nzb:nzt+1,nys-1:nyn+1+vynp,nxl-1:nxr+1), & w_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & w_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & w_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) IF ( timestep_scheme(1:5) /= 'runge' ) THEN ALLOCATE( kh_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & km_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( moisture .OR. passive_scalar ) THEN ! !-- 2D-moisture/scalar arrays ALLOCATE ( qs(nys-1:nyn+1,nxl-1:nxr+1), & qsws_1(nys-1:nyn+1,nxl-1:nxr+1) ) IF ( timestep_scheme(1:5) /= 'runge' ) THEN ALLOCATE( qsws_2(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF ! !-- 3D-moisture/scalar arrays ALLOCATE( q_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & q_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & q_3(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ! !-- 3D-arrays needed for moisture only IF ( moisture ) THEN ALLOCATE( vpt_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) IF ( timestep_scheme(1:5) /= 'runge' ) THEN ALLOCATE( vpt_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( cloud_physics ) THEN ! !-- Liquid water content ALLOCATE ( ql_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( cloud_droplets ) THEN ! !-- Liquid water content, change in liquid water content, !-- real volume of particles (with weighting), volume of particles ALLOCATE ( ql_1(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & ql_2(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & ql_v(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1), & ql_vp(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF ENDIF ENDIF ! !-- 3D-array for storing the dissipation, needed for calculating the sgs !-- particle velocities IF ( use_sgs_for_particles ) THEN ALLOCATE ( diss(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( dt_dosp /= 9999999.9 ) THEN ALLOCATE( spectrum_x( 1:nx/2, 1:10, 1:10 ), & spectrum_y( 1:ny/2, 1:10, 1:10 ) ) ENDIF ! !-- Initial assignment of the pointers IF ( timestep_scheme(1:5) /= 'runge' ) THEN rif_m => rif_1; rif => rif_2 shf_m => shf_1; shf => shf_2 usws_m => usws_1; usws => usws_2 vsws_m => vsws_1; vsws => vsws_2 e_m => e_1; e => e_2; e_p => e_3; te_m => e_3 kh_m => kh_1; kh => kh_2 km_m => km_1; km => km_2 pt_m => pt_1; pt => pt_2; pt_p => pt_3; tpt_m => pt_3 u_m => u_1; u => u_2; u_p => u_3; tu_m => u_3 v_m => v_1; v => v_2; v_p => v_3; tv_m => v_3 w_m => w_1; w => w_2; w_p => w_3; tw_m => w_3 IF ( moisture .OR. passive_scalar ) THEN qsws_m => qsws_1; qsws => qsws_2 q_m => q_1; q => q_2; q_p => q_3; tq_m => q_3 IF ( moisture ) vpt_m => vpt_1; vpt => vpt_2 IF ( cloud_physics ) ql => ql_1 IF ( cloud_droplets ) THEN ql => ql_1 ql_c => ql_2 ENDIF ENDIF ELSE rif => rif_1 shf => shf_1 usws => usws_1 vsws => vsws_1 e => e_1; e_p => e_2; te_m => e_3; e_m => e_3 kh => kh_1 km => km_1 pt => pt_1; pt_p => pt_2; tpt_m => pt_3; pt_m => pt_3 u => u_1; u_p => u_2; tu_m => u_3; u_m => u_3 v => v_1; v_p => v_2; tv_m => v_3; v_m => v_3 w => w_1; w_p => w_2; tw_m => w_3; w_m => w_3 IF ( moisture .OR. passive_scalar ) THEN qsws => qsws_1 q => q_1; q_p => q_2; tq_m => q_3; q_m => q_3 IF ( moisture ) vpt => vpt_1 IF ( cloud_physics ) ql => ql_1 IF ( cloud_droplets ) THEN ql => ql_1 ql_c => ql_2 ENDIF ENDIF ENDIF ! !-- Initialize model variables IF ( TRIM( initializing_actions ) /= 'read_restart_data' ) THEN ! !-- First model run of a possible job queue. !-- Initial profiles of the variables must be computes. IF ( INDEX( initializing_actions, 'set_1d-model_profiles' ) /= 0 ) THEN ! !-- Use solutions of the 1D model as initial profiles, !-- start 1D model CALL init_1d_model ! !-- Transfer initial profiles to the arrays of the 3D model DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 e(:,j,i) = e1d kh(:,j,i) = kh1d km(:,j,i) = km1d pt(:,j,i) = pt_init ENDDO ENDDO DO i = nxl-1, nxr+uxrp+1 DO j = nys-1, nyn+1 u(:,j,i) = u1d ENDDO ENDDO DO i = nxl-1, nxr+1 DO j = nys-1, nyn+vynp+1 v(:,j,i) = v1d ENDDO ENDDO IF ( moisture .OR. passive_scalar ) THEN DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 q(:,j,i) = q_init ENDDO ENDDO ENDIF IF ( .NOT. constant_diffusion ) THEN DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 e(:,j,i) = e1d ENDDO ENDDO ! !-- Store initial profiles for output purposes etc. hom(:,1,25,:) = SPREAD( l1d, 2, statistic_regions+1 ) IF ( prandtl_layer ) THEN rif = rif1d(nzb+1) ts = 0.0 ! could actually be computed more accurately in the ! 1D model. Update when opportunity arises. us = us1d usws = usws1d vsws = vsws1d ELSE ts = 0.0 ! must be set, because used in rif = 0.0 ! flowste us = 0.0 usws = 0.0 vsws = 0.0 ENDIF ELSE e = 0.0 ! must be set, because used in rif = 0.0 ! flowste ts = 0.0 us = 0.0 usws = 0.0 vsws = 0.0 ENDIF ! !-- In every case qs = 0.0 (see also pt) !-- This could actually be computed more accurately in the 1D model. !-- Update when opportunity arises! IF ( moisture .OR. passive_scalar ) qs = 0.0 ! !-- inside buildings set velocities back to zero IF ( topography /= 'flat' ) THEN DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 u(nzb:nzb_u_inner(j,i),j,i) = 0.0 v(nzb:nzb_v_inner(j,i),j,i) = 0.0 ENDDO ENDDO ! !-- WARNING: The extra boundary conditions set after running the !-- ------- 1D model impose an error on the divergence one layer !-- below the topography; need to correct later !-- ATTENTION: Provisional correction for Piacsek & Williams !-- --------- advection scheme: keep u and v zero one layer below !-- the topography. IF ( ibc_uv_b == 0 ) THEN ! !-- Satisfying the Dirichlet condition with an extra layer below !-- the surface where the u and v component change their sign. DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = -u(1,j,i) IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = -v(1,j,i) ENDDO ENDDO ELSE ! !-- Neumann condition DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 IF ( nzb_u_inner(j,i) == 0 ) u(0,j,i) = u(1,j,i) IF ( nzb_v_inner(j,i) == 0 ) v(0,j,i) = v(1,j,i) ENDDO ENDDO ENDIF ENDIF ELSEIF ( INDEX(initializing_actions, 'set_constant_profiles') /= 0 ) & THEN ! !-- Use constructed initial profiles (velocity constant with height, !-- temperature profile with constant gradient) DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 pt(:,j,i) = pt_init ENDDO ENDDO DO i = nxl-1, nxr+uxrp+1 DO j = nys-1, nyn+1 u(:,j,i) = u_init ENDDO ENDDO DO i = nxl-1, nxr+1 DO j = nys-1, nyn+vynp+1 v(:,j,i) = v_init ENDDO ENDDO ! !-- Set initial horizontal velocities at the lowest grid levels to zero !-- in order to avoid too small time steps caused by the diffusion !-- limit in the initial phase of a run (at k=1, dz/2 occurs in the !-- limiting formula!) DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 u(nzb:nzb_u_inner(j,i)+1,j,i) = 0.0 v(nzb:nzb_v_inner(j,i)+1,j,i) = 0.0 ENDDO ENDDO IF ( moisture .OR. passive_scalar ) THEN DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 q(:,j,i) = q_init ENDDO ENDDO ENDIF IF ( constant_diffusion ) THEN km = km_constant kh = km / prandtl_number ELSE kh = 0.01 ! there must exist an initial diffusion, because km = 0.01 ! otherwise no TKE would be produced by the ! production terms, as long as not yet ! e = (u*/cm)**2 at k=nzb+1 ENDIF e = 0.0 rif = 0.0 ts = 0.0 us = 0.0 usws = 0.0 vsws = 0.0 IF ( moisture .OR. passive_scalar ) qs = 0.0 ! !-- Compute initial temperature field and other constants used in case !-- of a sloping surface IF ( sloping_surface ) CALL init_slope ENDIF ! !-- Calculate virtual potential temperature IF ( moisture ) vpt = pt * ( 1.0 + 0.61 * q ) ! !-- Store initial profiles for output purposes etc. hom(:,1,5,:) = SPREAD( u(:,nys,nxl), 2, statistic_regions+1 ) hom(:,1,6,:) = SPREAD( v(:,nys,nxl), 2, statistic_regions+1 ) IF ( ibc_uv_b == 0 ) THEN hom(nzb,1,5,:) = -hom(nzb+1,1,5,:) ! due to satisfying the Dirichlet hom(nzb,1,6,:) = -hom(nzb+1,1,6,:) ! condition with an extra layer ! below the surface where the u and v component change their sign ENDIF hom(:,1,7,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) hom(:,1,23,:) = SPREAD( km(:,nys,nxl), 2, statistic_regions+1 ) hom(:,1,24,:) = SPREAD( kh(:,nys,nxl), 2, statistic_regions+1 ) IF ( moisture ) THEN ! !-- Store initial profile of total water content, virtual potential !-- temperature hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) hom(:,1,29,:) = SPREAD( vpt(:,nys,nxl), 2, statistic_regions+1 ) IF ( cloud_physics .OR. cloud_droplets ) THEN ! !-- Store initial profile of specific humidity and potential !-- temperature hom(:,1,27,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) hom(:,1,28,:) = SPREAD( pt(:,nys,nxl), 2, statistic_regions+1 ) ENDIF ENDIF IF ( passive_scalar ) THEN ! !-- Store initial scalar profile hom(:,1,26,:) = SPREAD( q(:,nys,nxl), 2, statistic_regions+1 ) ENDIF ! !-- Initialize surface fluxes IF ( use_surface_fluxes ) THEN IF ( constant_heatflux ) THEN ! !-- Heat flux is prescribed IF ( random_heatflux ) THEN CALL disturb_heatflux ELSE shf = surface_heatflux ! !-- Over topography surface_heatflux is replaced by wall_heatflux(0) IF ( TRIM( topography ) /= 'flat' ) THEN DO i = nxl-1, nxr+1 DO j = nys-1, nyn+1 IF ( nzb_s_inner(j,i) /= 0 ) THEN shf(j,i) = wall_heatflux(0) ENDIF ENDDO ENDDO ENDIF ENDIF IF ( ASSOCIATED( shf_m ) ) shf_m = shf ENDIF ! !-- Determine the near-surface water flux IF ( moisture .OR. passive_scalar ) THEN IF ( constant_waterflux ) THEN qsws = surface_waterflux IF ( ASSOCIATED( qsws_m ) ) qsws_m = qsws ENDIF ENDIF ENDIF ! !-- Initialize Prandtl layer quantities IF ( prandtl_layer ) THEN z0 = roughness_length IF ( .NOT. constant_heatflux ) THEN ! !-- Surface temperature is prescribed. Here the heat flux cannot be !-- simply estimated, because therefore rif, u* and theta* would have !-- to be computed by iteration. This is why the heat flux is assumed !-- to be zero before the first time step. It approaches its correct !-- value in the course of the first few time steps. shf = 0.0 IF ( ASSOCIATED( shf_m ) ) shf_m = 0.0 ENDIF IF ( moisture .OR. passive_scalar ) THEN IF ( .NOT. constant_waterflux ) THEN qsws = 0.0 IF ( ASSOCIATED( qsws_m ) ) qsws_m = 0.0 ENDIF ENDIF ENDIF ! !-- Calculate the initial volume flow at the right and north boundary IF ( conserve_volume_flow ) THEN volume_flow_initial_l = 0.0 volume_flow_area_l = 0.0 IF ( nxr == nx ) THEN DO j = nys, nyn DO k = nzb_2d(j,nx) + 1, nzt volume_flow_initial_l(1) = volume_flow_initial_l(1) + & u(k,j,nx) * dzu(k) volume_flow_area_l(1) = volume_flow_area_l(1) + dzu(k) ENDDO ENDDO ENDIF IF ( nyn == ny ) THEN DO i = nxl, nxr DO k = nzb_2d(ny,i) + 1, nzt volume_flow_initial_l(2) = volume_flow_initial_l(2) + & v(k,ny,i) * dzu(k) volume_flow_area_l(2) = volume_flow_area_l(2) + dzu(k) ENDDO ENDDO ENDIF #if defined( __parallel ) CALL MPI_ALLREDUCE( volume_flow_initial_l(1), volume_flow_initial(1),& 2, MPI_REAL, MPI_SUM, comm2d, ierr ) CALL MPI_ALLREDUCE( volume_flow_area_l(1), volume_flow_area(1), & 2, MPI_REAL, MPI_SUM, comm2d, ierr ) #else volume_flow_initial = volume_flow_initial_l volume_flow_area = volume_flow_area_l #endif ENDIF ! !-- For the moment, perturbation pressure and vertical velocity are zero p = 0.0; w = 0.0 ! !-- Initialize array sums (must be defined in first call of pres) sums = 0.0 ! !-- Treating cloud physics, liquid water content is zero at beginning of !-- the simulation IF ( cloud_physics ) ql = 0.0 ! !-- Initialize spectra IF ( dt_dosp /= 9999999.9 ) THEN spectrum_x = 0.0 spectrum_y = 0.0 ENDIF ! !-- Impose vortex with vertical axis on the initial velocity profile IF ( INDEX( initializing_actions, 'initialize_vortex' ) /= 0 ) THEN CALL init_rankine ENDIF ! !-- Impose temperature anomaly (advection test only) IF ( INDEX( initializing_actions, 'initialize_ptanom' ) /= 0 ) THEN CALL init_pt_anomaly ENDIF ! !-- If required, change the surface temperature at the start of the 3D run IF ( pt_surface_initial_change /= 0.0 ) THEN pt(nzb,:,:) = pt(nzb,:,:) + pt_surface_initial_change ENDIF ! !-- If required, change the surface humidity/scalar at the start of the 3D !-- run IF ( ( moisture .OR. passive_scalar ) .AND. & q_surface_initial_change /= 0.0 ) THEN q(nzb,:,:) = q(nzb,:,:) + q_surface_initial_change ENDIF ! !-- Initialize the random number generator (from numerical recipes) CALL random_function_ini ! !-- Impose random perturbation on the horizontal velocity field and then !-- remove the divergences from the velocity field IF ( create_disturbances ) THEN CALL disturb_field( nzb_u_inner, tend, u, uxrp, 0 ) CALL disturb_field( nzb_v_inner, tend, v, 0, vynp ) n_sor = nsor_ini CALL pres n_sor = nsor ENDIF ! !-- Once again set the perturbation pressure explicitly to zero in order to !-- assure that it does not generate any divergences in the first time step. !-- At t=0 the velocity field is free of divergence (as constructed above). !-- Divergences being created during a time step are not yet known and thus !-- cannot be corrected during the time step yet. p = 0.0 ! !-- Initialize old and new time levels. IF ( timestep_scheme(1:5) /= 'runge' ) THEN e_m = e; pt_m = pt; u_m = u; v_m = v; w_m = w; kh_m = kh; km_m = km ELSE te_m = 0.0; tpt_m = 0.0; tu_m = 0.0; tv_m = 0.0; tw_m = 0.0 ENDIF e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w IF ( moisture .OR. passive_scalar ) THEN IF ( ASSOCIATED( q_m ) ) q_m = q IF ( timestep_scheme(1:5) == 'runge' ) tq_m = 0.0 q_p = q IF ( moisture .AND. ASSOCIATED( vpt_m ) ) vpt_m = vpt ENDIF ELSEIF ( TRIM( initializing_actions ) == 'read_restart_data' ) & THEN ! !-- Read binary data from restart file CALL read_3d_binary ! !-- Calculate initial temperature field and other constants used in case !-- of a sloping surface IF ( sloping_surface ) CALL init_slope ! !-- Initialize new time levels (only done in order to set boundary values !-- including ghost points) e_p = e; pt_p = pt; u_p = u; v_p = v; w_p = w IF ( moisture .OR. passive_scalar ) q_p = q ELSE ! !-- Actually this part of the programm should not be reached IF ( myid == 0 ) PRINT*,'+++ init_3d_model: unknown initializing ', & 'problem' CALL local_stop ENDIF ! !-- If required, initialize dvrp-software ! WRITE ( 9, * ) '*** myid=', myid, ' vor init_dvrp' ! CALL FLUSH_( 9 ) IF ( dt_dvrp /= 9999999.9 ) CALL init_dvrp ! WRITE ( 9, * ) '*** myid=', myid, ' nach init_dvrp' ! CALL FLUSH_( 9 ) ! !-- If required, initialize quantities for handling cloud physics !-- This routine must be called before init_particles, because !-- otherwise, array pt_d_t, needed in data_output_dvrp (called by !-- init_particles) is not defined. CALL init_cloud_physics ! !-- If required, initialize particles ! WRITE ( 9, * ) '*** myid=', myid, ' vor init_particles' ! CALL FLUSH_( 9 ) CALL init_particles ! WRITE ( 9, * ) '*** myid=', myid, ' nach init_particles' ! CALL FLUSH_( 9 ) ! !-- Initialize quantities for special advections schemes CALL init_advec ! !-- Initialize Rayleigh damping factors rdf = 0.0 IF ( rayleigh_damping_factor /= 0.0 ) THEN DO k = nzb+1, nzt IF ( zu(k) >= rayleigh_damping_height ) THEN rdf(k) = rayleigh_damping_factor * & ( SIN( pi * 0.5 * ( zu(k) - rayleigh_damping_height ) & / ( zu(nzt) - rayleigh_damping_height ) )& )**2 ENDIF ENDDO ENDIF ! !-- Initialize diffusivities used within the outflow damping layer in case of !-- non-cyclic lateral boundaries. A linear increase is assumed over the first !-- half of the width of the damping layer IF ( bc_lr /= 'cyclic' ) THEN DO i = nxl-1, nxr+1 IF ( outflow_r ) THEN IF ( i >= nx - outflow_damping_width ) THEN km_damp_x(i) = km_damp_max * MIN( 1.0, & ( i - ( nx - outflow_damping_width ) ) / & REAL( outflow_damping_width/2 ) & ) ELSE km_damp_x(i) = 0.0 ENDIF ELSEIF ( outflow_l ) THEN IF ( i <= outflow_damping_width ) THEN km_damp_x(i) = km_damp_max * MIN( 1.0, & ( outflow_damping_width - i ) / & REAL( outflow_damping_width/2 ) & ) ELSE km_damp_x(i) = 0.0 ENDIF ENDIF ENDDO ENDIF IF ( bc_ns /= 'cyclic' ) THEN DO j = nys-1, nyn+1 IF ( outflow_n ) THEN IF ( j >= ny - outflow_damping_width ) THEN km_damp_y(j) = km_damp_max * MIN( 1.0, & ( j - ( ny - outflow_damping_width ) ) / & REAL( outflow_damping_width/2 ) & ) ELSE km_damp_y(j) = 0.0 ENDIF ELSEIF ( outflow_s ) THEN IF ( j <= outflow_damping_width ) THEN km_damp_y(j) = km_damp_max * MIN( 1.0, & ( outflow_damping_width - j ) / & REAL( outflow_damping_width/2 ) & ) ELSE km_damp_y(j) = 0.0 ENDIF ENDIF ENDDO ENDIF ! !-- Initialize local summation arrays for UP flow_statistics. This is necessary !-- because they may not yet have been initialized when they are called from !-- flow_statistics (or - depending on the chosen model run - are never !-- initialized) sums_divnew_l = 0.0 sums_divold_l = 0.0 sums_l_l = 0.0 sums_up_fraction_l = 0.0 sums_wsts_bc_l = 0.0 ! !-- Pre-set masks for regional statistics. Default is the total model domain. rmask = 1.0 ! !-- User-defined initializing actions CALL user_init ! !-- Input binary data file is not needed anymore. This line must be placed !-- after call of user_init! CALL close_file( 13 ) ! !-- Compute total sum of active mask grid points !-- ngp_2dh: number of grid points of a horizontal cross section through the !-- total domain !-- ngp_3d: number of grid points of the total domain !-- Note: The lower vertical index nzb_s_outer imposes a small error on the 2D !-- ---- averages of staggered variables such as u and v due to the topography !-- arrangement on the staggered grid. Maybe revise later. ngp_2dh_outer_l = 0 ngp_2dh_outer = 0 ngp_2dh_l = 0 ngp_2dh = 0 ngp_3d_inner_l = 0 ngp_3d_inner = 0 ngp_3d = 0 ngp_sums = ( nz + 2 ) * var_sum DO sr = 0, statistic_regions DO i = nxl, nxr DO j = nys, nyn IF ( rmask(j,i,sr) == 1.0 ) THEN ! !-- All xy-grid points ngp_2dh_l(sr) = ngp_2dh_l(sr) + 1 ! !-- xy-grid points above topography DO k = nzb_s_outer(j,i), nz + 1 ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + 1 ENDDO ! !-- All grid points of the total domain above topography ngp_3d_inner_l(sr) = ngp_3d_inner_l(sr) + & ( nz - nzb_s_inner(j,i) + 2 ) ENDIF ENDDO ENDDO ENDDO sr = statistic_regions + 1 #if defined( __parallel ) CALL MPI_ALLREDUCE( ngp_2dh_l(0), ngp_2dh(0), sr, MPI_INTEGER, MPI_SUM, & comm2d, ierr ) CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, & MPI_INTEGER, MPI_SUM, comm2d, ierr ) CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner(0), sr, MPI_INTEGER, & MPI_SUM, comm2d, ierr ) #else ngp_2dh = ngp_2dh_l ngp_2dh_outer = ngp_2dh_outer_l ngp_3d_inner = ngp_3d_inner_l #endif ngp_3d = ngp_2dh * ( nz + 2 ) ! !-- Set a lower limit of 1 in order to avoid zero divisions in flow_statistics, !-- buoyancy, etc. A zero value will occur for cases where all grid points of !-- the respective subdomain lie below the surface topography ngp_2dh_outer = MAX( 1, ngp_2dh_outer(:,:) ) ngp_3d_inner = MAX( 1, ngp_3d_inner(:) ) DEALLOCATE( ngp_2dh_l, ngp_2dh_outer_l, ngp_3d_inner_l ) END SUBROUTINE init_3d_model