Index: palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- palm/trunk/SOURCE/init_3d_model.f90	(revision 3648)
+++ palm/trunk/SOURCE/init_3d_model.f90	(revision 3685)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Some interface calls moved to module_interface + cleanup
+! 
+! 3648 2019-01-02 16:35:46Z suehring
 ! Rename subroutines for surface-data output
 ! 
@@ -583,36 +586,18 @@
                ideal_gas_law_rho, ideal_gas_law_rho_pt, barometric_formula
 
-    USE biometeorology_mod,                                                    &
-        ONLY:  bio_init
-
     USE bulk_cloud_model_mod,                                                  &
-        ONLY:  bulk_cloud_model, bcm_init, bcm_init_arrays
-
-    USE chem_emissions_mod,                                                    &
-        ONLY:  chem_emissions_init
+        ONLY:  bulk_cloud_model
 
     USE chem_modules,                                                          &
-        ONLY:  do_emis, max_pr_cs, nspec_out
+        ONLY:  max_pr_cs ! ToDo: this dependency needs to be removed cause it is ugly #new_dom
 
     USE control_parameters
-
-    USE flight_mod,                                                            &
-        ONLY:  flight_init
 
     USE grid_variables,                                                        &
         ONLY:  dx, dy, ddx2_mg, ddy2_mg
 
-    USE gust_mod,                                                              &
-        ONLY:  gust_init, gust_init_arrays, gust_module_enabled
-
     USE indices
 
-    USE indoor_model_mod,                                                      &
-        ONLY:  im_init
-
     USE kinds
-
-    USE land_surface_model_mod,                                                &
-        ONLY:  lsm_init, lsm_init_arrays
 
     USE lpm_init_mod,                                                          &
@@ -620,8 +605,11 @@
   
     USE lsf_nudging_mod,                                                       &
-        ONLY:  lsf_init, ls_forcing_surf, nudge_init
+        ONLY:  ls_forcing_surf
 
     USE model_1d_mod,                                                          &
         ONLY:  init_1d_model, l1d, u1d, v1d
+
+    USE module_interface,                                                      &
+        ONLY:  module_interface_init_arrays, module_interface_init
 
     USE multi_agent_system_mod,                                                &
@@ -638,14 +626,8 @@
         ONLY:  nesting_offl_init
 
-    USE ocean_mod,                                                             &
-        ONLY:  ocean_init, ocean_init_arrays
-
     USE particle_attributes,                                                   &
         ONLY:  particle_advection
 
     USE pegrid
-
-    USE plant_canopy_model_mod,                                                &
-        ONLY:  pcm_init
 
 #if defined( __parallel )
@@ -655,22 +637,14 @@
 
     USE radiation_model_mod,                                                   &
-        ONLY:  average_radiation,                                              &
-               radiation_init, radiation, radiation_scheme,                    &
-               radiation_calc_svf, radiation_write_svf,                        &
-               radiation_interaction, radiation_interactions,                  &
-               radiation_interaction_init, radiation_read_svf,                 &
-               radiation_presimulate_solar_pos, radiation_interactions_on
-    
+        ONLY:  radiation, radiation_scheme
+
     USE random_function_mod 
-    
+
     USE random_generator_parallel,                                             &
         ONLY:  init_parallel_random_generator
-        
+
     USE read_restart_data_mod,                                                 &
-        ONLY:  rrd_read_parts_of_global, rrd_local    
-             
-    USE salsa_mod,                                                             &
-        ONLY:  salsa_init, salsa_init_arrays      
-    
+        ONLY:  rrd_read_parts_of_global, rrd_local
+
     USE statistics,                                                            &
         ONLY:  hom, hom_sum, mean_surface_level_height, pr_palm, rmask,        &
@@ -682,5 +656,5 @@
         ONLY:  parametrize_inflow_turbulence, stg_adjust, stg_init,            &
                use_syn_turb_gen
-               
+
     USE surface_layer_fluxes_mod,                                              &
         ONLY:  init_surface_layer_fluxes
@@ -689,21 +663,12 @@
         ONLY :  init_surface_arrays, init_surfaces, surf_def_h, surf_lsm_h,    &
                 surf_usm_h, get_topography_top_index_ji, vertical_surfaces_exist
-   
+
     USE surface_data_output_mod,                                               &
         ONLY:  surface_data_output_init
-   
+
     USE transpose_indices
 
     USE turbulence_closure_mod,                                                &
         ONLY:  tcm_init_arrays, tcm_init
-
-    USE urban_surface_mod,                                                     &
-        ONLY:  usm_init_urban_surface, usm_allocate_surface
-
-    USE virtual_measurement_mod,                                               &
-        ONLY:  vm_init
-
-    USE wind_turbine_model_mod,                                                &
-        ONLY:  wtm_init, wtm_init_arrays
 
     IMPLICIT NONE
@@ -1076,16 +1041,5 @@
 !
 !-- Allocate arrays for other modules
-    IF ( bulk_cloud_model    )  CALL bcm_init_arrays
-    IF ( gust_module_enabled )  CALL gust_init_arrays
-    IF ( land_surface        )  CALL lsm_init_arrays
-    IF ( ocean_mode          )  CALL ocean_init_arrays
-    IF ( salsa               )  CALL salsa_init_arrays
-    IF ( wind_turbine        )  CALL wtm_init_arrays
-
-!
-!-- Initialize virtual flight measurements
-    IF ( virtual_flight )  THEN
-       CALL flight_init
-    ENDIF
+    CALL module_interface_init_arrays
 
 
@@ -2098,7 +2052,4 @@
        ENDIF
     ENDIF
-!
-!-- User-defined initializing actions
-    CALL user_init
 !
 !-- To do: New concept for these non-topography grid points!
@@ -2205,12 +2156,4 @@
     DEALLOCATE( mean_surface_level_height_l, ngp_2dh_l, ngp_2dh_outer_l,       &
                 ngp_3d_inner_l, ngp_3d_inner_tmp )
-
-!
-!-- Initialize nudging if required
-    IF ( nudging )  CALL nudge_init
-!
-!-- Initialize 1D large-scale forcing and nudging and read data from external
-!-- ASCII file
-    IF ( large_scale_forcing )  CALL lsf_init
 !
 !-- Initialize surface forcing corresponding to large-scale forcing. Therein, 
@@ -2250,18 +2193,6 @@
 
 !
-!-- If required, initialize quantities needed for the plant canopy model
-    IF ( plant_canopy )  THEN
-       CALL location_message( 'initializing plant canopy model', .FALSE. )    
-       CALL pcm_init
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
 !-- If required, initialize dvrp-software
     IF ( dt_dvrp /= 9999999.9_wp )  CALL init_dvrp
-
-!
-!-- Initialize quantities needed for the ocean model
-    IF ( ocean_mode )  CALL ocean_init
 
 !
@@ -2281,5 +2212,5 @@
              WRITE( message_string, * )  'absolute temperature < 0.0 at zu(', k, &
                                          ') = ', zu(k)
-             CALL message( 'init_bulk_cloud_model', 'PA0142', 1, 2, 0, 6, 0 )
+             CALL message( 'init_3d_model', 'PA0142', 1, 2, 0, 6, 0 )
           ENDIF
        ENDDO
@@ -2296,49 +2227,11 @@
 
     ENDIF
-!
-!-- If required, initialize quantities needed for the microphysics module
-    IF ( bulk_cloud_model )  THEN
-       CALL bcm_init
-    ENDIF
 
 !
 !-- If required, initialize particles
     IF ( particle_advection )  CALL lpm_init
-
 !
 !-- If required, initialize particles
     IF ( agents_active )  CALL mas_init
-
-!
-!-- If required, initialize quantities needed for the LSM
-    IF ( land_surface )  THEN
-       CALL location_message( 'initializing land surface model', .FALSE. )
-       CALL lsm_init
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
-!-- If required, allocate USM and LSM surfaces
-    IF ( urban_surface )  THEN
-       CALL location_message( 'initializing and allocating urban surfaces', .FALSE. )
-       CALL usm_allocate_surface
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-!
-!-- If required, initialize urban surface model
-    IF ( urban_surface )  THEN
-       CALL location_message( 'initializing urban surface model', .FALSE. )
-       CALL usm_init_urban_surface
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
-!-- Initialize surface layer (done after LSM as roughness length are required
-!-- for initialization
-    IF ( constant_flux_layer )  THEN
-       CALL location_message( 'initializing surface layer', .FALSE. )
-       CALL init_surface_layer_fluxes
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
 !
 !-- In case the synthetic turbulence generator does not have any information
@@ -2347,130 +2240,17 @@
 !-- Please note, within pre-determined time intervals these turbulence 
 !-- information can be updated if desired. 
-    IF ( use_syn_turb_gen  .AND.  parametrize_inflow_turbulence )              &
+    IF ( use_syn_turb_gen  .AND.  parametrize_inflow_turbulence )  THEN
        CALL stg_adjust
-!
-!-- If required, set chemical emissions
-!-- Initialize values of cssws according to chemistry emission values
-    IF ( air_chemistry  .AND.  do_emis )  THEN
-       CALL chem_emissions_init( chem_emis_att, chem_emis, nspec_out )
-    ENDIF
-!
-!-- Initialize radiation processes
-    IF ( radiation )  THEN
-!
-!--    Activate radiation_interactions according to the existence of vertical surfaces and/or trees.
-!--    The namelist parameter radiation_interactions_on can override this behavior.
-!--    (This check cannot be performed in check_parameters, because vertical_surfaces_exist is first set in 
-!--    init_surface_arrays.)
-       IF ( radiation_interactions_on )  THEN
-          IF ( vertical_surfaces_exist  .OR.  plant_canopy )  THEN
-             radiation_interactions    = .TRUE.
-             average_radiation         = .TRUE.
-          ELSE
-             radiation_interactions_on = .FALSE.   !< reset namelist parameter: no interactions 
-                                                   !< calculations necessary in case of flat surface
-          ENDIF
-       ELSEIF ( vertical_surfaces_exist  .OR.  plant_canopy )  THEN
-          message_string = 'radiation_interactions_on is set to .FALSE. although '     // &
-                           'vertical surfaces and/or trees exist. The model will run ' // &
-                           'without RTM (no shadows, no radiation reflections)'
-          CALL message( 'init_3d_model', 'PA0348', 0, 1, 0, 6, 0 )
-       ENDIF
-!
-!--    If required, initialize radiation interactions between surfaces 
-!--    via sky-view factors. This must be done before radiation is initialized.
-       IF ( radiation_interactions )  CALL radiation_interaction_init
-
-!
-!--    Initialize radiation model
-       CALL location_message( 'initializing radiation model', .FALSE. )
-       CALL radiation_init
-       CALL location_message( 'finished', .TRUE. )
-
-!
-!--    Find all discretized apparent solar positions for radiation interaction.
-!--    This must be done after radiation_init.
-       IF ( radiation_interactions )  CALL radiation_presimulate_solar_pos
-
-!
-!--    If required, read or calculate and write out the SVF 
-       IF ( radiation_interactions .AND. read_svf)  THEN
-!
-!--       Read sky-view factors and further required data from file
-          CALL location_message( '    Start reading SVF from file', .FALSE. )
-          CALL radiation_read_svf()
-          CALL location_message( '    Reading SVF from file has finished', .TRUE. )
-
-       ELSEIF ( radiation_interactions .AND. .NOT. read_svf)  THEN
-!
-!--       calculate SFV and CSF
-          CALL location_message( '    Start calculation of SVF', .FALSE. )
-          CALL radiation_calc_svf()
-          CALL location_message( '    Calculation of SVF has finished', .TRUE. )
-       ENDIF
-
-       IF ( radiation_interactions .AND. write_svf)  THEN
-!
-!--       Write svf, csf svfsurf and csfsurf data to file
-          CALL location_message( '    Start writing SVF in file', .FALSE. )
-          CALL radiation_write_svf()
-          CALL location_message( '    Writing SVF in file has finished', .TRUE. )
-       ENDIF
-
-!
-!--    Adjust radiative fluxes. In case of urban and land surfaces, also 
-!--    call an initial interaction.
-       IF ( radiation_interactions )  THEN
-          CALL radiation_interaction
-       ENDIF
-    ENDIF
-  
-!
-!-- If required, initialize quantities needed for the wind turbine model
-    IF ( wind_turbine )  THEN
-       CALL location_message( 'initializing wind turbine model', .FALSE. )
-       CALL wtm_init
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
-!-- If required, initialize quantities needed in SALSA 
-    IF ( salsa )  THEN
-       CALL location_message( 'initializing SALSA model', .TRUE. )
-       CALL salsa_init 
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
-!-- If required, initialize quantities needed for the gust module
-    IF ( gust_module_enabled )  THEN
-       CALL gust_init( dots_label, dots_unit, dots_num, dots_max )
-    ENDIF
+    ENDIF
+!
+!-- Initializing actions for all other modules
+    CALL module_interface_init
+!
+!-- Initialize surface layer (done after LSM as roughness length are required
+!-- for initialization
+    IF ( constant_flux_layer )  CALL init_surface_layer_fluxes
 !
 !-- Initialize surface data output
-    IF ( surface_output )  THEN
-       CALL surface_data_output_init
-    ENDIF
-!
-!-- If virtual measurements should be taken, initialize all relevant 
-!-- arrays and quantities.
-    IF ( virtual_measurement )  CALL vm_init
-
-!
-!-- If required initialize biometeorology module
-    IF ( biometeorology )  THEN
-        CALL location_message( 'initializing biometeorology module', .FALSE. )
-        CALL bio_init
-        CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
-!
-!-- If required, initialize indoor model
-    IF ( indoor_model )  THEN
-       CALL location_message( 'initializing indoor model', .FALSE. )
-       CALL im_init
-       CALL location_message( 'finished', .TRUE. )
-    ENDIF
-
+    IF ( surface_output )  CALL surface_data_output_init
 !
 !-- Initialize the ws-scheme.    
