Changeset 3744 for palm


Ignore:
Timestamp:
Feb 15, 2019 6:38:58 PM (5 years ago)
Author:
suehring
Message:

Coupling of indoor model to atmosphere; output of indoor temperatures and waste heat; enable restarts with indoor model; bugfix plant transpiration; bugfix - missing calculation of 10cm temperature

Location:
palm/trunk/SOURCE
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/Makefile

    r3737 r3744  
    2020# Current revisions:
    2121# ------------------
    22 #
     22# Add Netcdf data output for indoor model
     23# Remove some dependencies
    2324#
    2425# Former revisions:
     
    3334# 3700 2019-01-26 17:03:42Z knoop
    3435# Rename surface_output_mod into surface_data_output_mod
    35 #
     36# 
    3637# 3637 2018-12-20 01:51:36Z knoop
    3738# Implementation of the PALM module interface
    38 #
     39# 
    3940# 3634 2018-12-18 12:31:28Z knoop
    4041# OpenACC port for SPEC
    41 #
     42# 
    4243# 3579 2018-11-29 15:32:39Z suehring
    4344# Dependency for check_parameters on nesting_offl_mod added
    44 #
     45# 
    4546# 3569 2018-11-27 17:03:40Z kanani
    4647# dom_dwd_user, Schrempf:
     
    5051# 3525 2018-11-14 16:06:14Z kanani
    5152# Changes related to clean-up of biometeorology (dom_dwd_user)
    52 #
     53# 
    5354# 3522 2018-11-13 12:14:36Z suehring
    5455# Dependencies for virtual measurement module added
    55 #
     56# 
    5657# 3494 2018-11-06 14:51:27Z suehring
    5758# Surface output revised
    58 #
     59# 
    5960# 3474 2018-10-30 21:07:39Z kanani
    6061# Add virtual measurement module
    61 #
     62# 
    6263# 3472 2018-10-30 20:43:50Z suehring
    6364# Add indoor model (kanani, srissman, tlang),
    6465# minor formatting
    65 #
     66# 
    6667# 3467 2018-10-30 19:05:21Z suehring
    6768# Implementation of a new aerosol module salsa.
    68 #
    69 #
     69# 
     70# 
    7071# 3458 2018-10-30 14:51:23Z kanani
    7172# from chemistry branch r3443, banzhafs, Russo, forkel, basit:
     
    7475# Added chemistry emission module
    7576# chemistry_model_mod added to flow_statistics
    76 #
     77# 
    7778# 3448 2018-10-29 18:14:31Z kanani
    7879# Adjustment of biometeorology dependencies
    79 #
     80# 
    8081# 3436 2018-10-26 18:35:15Z gronemeier
    8182# Add surface_mod to user_data_output_mask
    82 #
     83# 
    8384# 3435 2018-10-26 18:25:44Z gronemeier
    8485# - Add surface_mod to data_output_mask
    8586# - Add chemistry_model_mod and surface_mod to init_masks
    86 #
     87# 
    8788# 3421 2018-10-24 18:39:32Z gronemeier
    8889# Add netcdf_data_input_mod to netcdf_interface_mod
    8990# bugfix: add dependencies to chemistry_model_mod
    9091# Add module for surface data output
    91 #
     92# 
    9293# 3381 2018-10-19 13:09:06Z raasch
    9394# dependencies for ocean_mod fixed
    94 #
     95# 
    9596# 3355 2018-10-16 14:03:34Z knoop
    9697# Add module for offline nesting;
     
    9899# Bugfix, missing dependency for turbulence generator in init_3d_model;
    99100# Some formatting ajdustments
    100 #
     101# 
    101102# 3343 2018-10-15 10:38:52Z suehring
    102103# (from branch resler)
    103104# Add biometeorology
    104 #
    105 #
     105# 
     106# 
    106107# 3322 2018-10-09 10:02:39Z kanani
    107108# Formatting and cleanup
    108 #
     109# 
    109110# 3298 2018-10-02 12:21:11Z kanani
    110111# Added missing dependencies and replaced blanks with tabs (forkel)
     
    115116# changes related to modularization of the ocean mode,
    116117# bugfix: dependency to advec_ws was missed in chemistry_model_mod
    117 #
     118# 
    118119# 3274 2018-09-24 15:42:55Z knoop
    119120# Added palm dependency of multi_agent_system_mod, because of mas_last_actions
    120121# call at the end of palm run
    121 #
     122# 
    122123# 3167 2018-07-24 18:17:30Z suehring
    123124# Bugfix, add missing dependencies for multi-agent system
    124 #
     125# 
    125126# 3159 2018-07-20 11:20:01Z sward
    126127# Added multi agent system
    127 #
     128# 
    128129# 3130 2018-07-16 11:08:55Z gronemeier
    129130# add surface_layer_fluxes_mod to turbulence_closure_mod
    130 #
     131# 
    131132# 3129 2018-07-16 07:45:13Z gronemeier
    132133# add turbulence_closure_mod to parin
    133 #
     134# 
    134135# 2963 2018-04-12 14:47:44Z suehring
    135 # Introduce index for vegetation/wall, pavement/green-wall and water/window
     136# Introduce index for vegetation/wall, pavement/green-wall and water/window 
    136137# surfaces, for clearer access of surface fraction, albedo, emissivity, etc. .
    137 #
     138# 
    138139# 2955 2018-04-09 15:14:01Z suehring
    139140# Add log-points to measure CPU time of NetCDF data input.
    140 #
     141# 
    141142# 2938 2018-03-27 15:52:42Z suehring
    142143# No initialization of child domains via dynamic input file, except for soil
    143144# moisture and temperature
    144145# Apply turbulence generator at non-cyclic lateral boundary in nesting case
    145 #
     146# 
    146147# 2936 2018-03-27 14:49:27Z suehring
    147148# Added dependencies for parent and child synchronization
    148 #
     149# 
    149150# 2921 2018-03-22 15:05:23Z Giersch
    150151# date_and_time_mod dependency has been added to read/write_restart_data_mod
    151 #
     152# 
    152153# 2918 2018-03-21 15:52:14Z gronemeier
    153 # read/write_3d_binary and read/write_var_list has been removed,
     154# read/write_3d_binary and read/write_var_list has been removed, 
    154155# read/write_restart_data_mod, wrd_write_string and
    155 # user_read/write_restart_data_mod has been added, dependencies with respect to
     156# user_read/write_restart_data_mod has been added, dependencies with respect to 
    156157# the aforementioned routines have been added/removed
    157158#
    158159# 2847 2018-03-02 21:45:58Z suehring
    159160# Changed format and enforced sorting
    160 #
     161# 
    161162# 2817 2018-02-19 16:32:21Z knoop
    162163# Preliminary gust module interface implemented
    163 #
     164# 
    164165# 2802 2018-02-14 16:21:39Z thiele
    165166# Changed lpm from subroutine to module.
    166167# Introduce particle transfer in nested models.
    167 #
     168# 
    168169# 2773 2018-01-30 14:12:54Z suehring
    169170# Nesting of chemical species
    170 #
     171# 
    171172# 2718 2018-01-02 08:49:38Z maronga
    172173# Corrected "Former revisions" section
    173 #
     174# 
    174175# 2697 2017-12-14 17:57:20Z kanani
    175176# Bugfix, missing dependencies
    176 #
     177# 
    177178# 2696 2017-12-14 17:12:51Z kanani
    178179# Change in file header (GPL part)
    179180# Implementation of uv exposure model (FK)
    180 # Bugfix, removed loop dependcy for vertical_nesting_mod and
     181# Bugfix, removed loop dependcy for vertical_nesting_mod and 
    181182# turbulence_closure_mod, added depencies for vertical_nesting_mod (TG)
    182183# implemented turbulence_closure_mod (TG)
     
    186187# For LSM, add dependency on calc_mean_profile (??)
    187188# poismg_noopt modularized and renamed into poismg_noopt_mod
    188 # add dependencies for netcdf_data_input_mod, calc_mean_profile,
     189# add dependencies for netcdf_data_input_mod, calc_mean_profile, 
    189190# radiation_module_mod, land_surface_model_mod (MS)
    190 #
     191# 
    191192# 2608 2017-11-13 14:04:26Z schwenkel
    192 # Added diagnostic_quantities_mod
    193 #
     193# Added diagnostic_quantities_mod 
     194# 
    194195# 2600 2017-11-01 14:11:20Z raasch
    195196# comment line concerning bound checks removed
    196 #
     197# 
    197198# 2599 2017-11-01 13:18:45Z hellstea
    198199# virtual_flight_mod, synthetic_turbulence_generator_mod and
     
    201202# 2563 2017-10-19 15:36:10Z Giersch
    202203# wind_turbine_model_mod and synthetic_turbulence_generator_mod were added to
    203 # write_var_list and virtual_flight_mod was deleted from read_var_list
     204# write_var_list and virtual_flight_mod was deleted from read_var_list 
    204205#
    205206# 2544 2017-10-13 18:09:32Z maronga
    206 # Added date_and_time_mod
    207 #
     207# Added date_and_time_mod 
     208# 
    208209# 2371 2017-08-24 13:01:17Z kanani
    209210# Corrected dependencies for vertical_nesting_mod
    210 #
     211# 
    211212# 2370 2017-08-23 06:11:43Z raasch
    212213# dependency bugfix for synthetic_turbulence_generator
    213 #
     214# 
    214215# 2365 2017-08-21 14:59:59Z kanani
    215216# Added dependencies for vertical_nesting_mod
    216 #
     217# 
    217218# 2339 2017-08-07 13:55:26Z gronemeier
    218219# corrected timestamp in header
    219 #
     220# 
    220221# 2338 2017-08-07 12:15:38Z gronemeier
    221222# Modularize 1D model
    222 #
     223# 
    223224# 2320 2017-07-21 12:47:43Z suehring
    224225# -ls_forcing nudging
    225226# +large_scale_forcing_nudging
    226 #
     227# 
    227228# 2318 2017-07-20 17:27:44Z suehring
    228229# Add further dependencies on surface_mod
    229 #
     230# 
    230231# 2317 2017-07-20 17:27:19Z suehring
    231232# Added time_integration_spinup
    232 #
     233# 
    233234# 2269 2017-06-09 11:57:32Z suehring
    234235# Add dependency in read_3d_binary
    235 #
     236# 
    236237# 2263 2017-06-08 14:59:01Z schwenkel
    237238# Implemented splitting and merging algorithm
    238 #
     239# 
    239240# 2259 2017-06-08 09:09:11Z gronemeier
    240241# Implemented synthetic turbulence generator
     
    242243# 2256 2017-06-07 13:58:08Z suehring
    243244# Remove ring dependency in init_pegrid
    244 #
     245# 
    245246# 2238 2017-05-31 16:49:16Z suehring
    246247# Bugfix, further missing dependency on surface_mod
    247 #
     248# 
    248249# 2237 2017-05-31 10:34:53Z suehring
    249 # Bugfix, add dependencies on surface_mod for surface_coupler,
    250 # plant_canopy_model_mod and ls_forcing_mod
    251 #
     250# Bugfix, add dependencies on surface_mod for surface_coupler, 
     251# plant_canopy_model_mod and ls_forcing_mod 
     252# 
    252253# 2233 2017-05-30 18:08:54Z suehring
    253254#
     
    255256# +dependencies for surface_mod
    256257# -wall_fluxes
    257 #
     258# 
    258259# 2130 2017-01-24 16:25:39Z raasch
    259260# dependency for timestep updated
     
    261262# 2118 2017-01-17 16:38:49Z raasch
    262263# -cuda_fft_interfaces_mod
    263 #
     264# 
    264265# 2050 2016-11-08 15:00:55Z gronemeier
    265266# Implement turbulent outflow method
    266 #
     267# 
    267268# 2007 2016-08-24 15:47:17Z kanani
    268269# urban surface module added,
    269270# cleaned up some lines (compiler flags/options), which were accidentally
    270271# added in rev1938
    271 #
     272# 
    272273# 1998 2016-08-20 18:45:34Z knoop
    273274# Bugfix: added netcdf_interface to dependency list for user_init_land_surface
     
    275276# 1986 2016-08-10 14:07:17Z gronemeier
    276277# POSIX-calls module added
    277 #
     278# 
    278279# 1972 2016-07-26 07:52:02Z maronga
    279280# Removed some dependencies due to further modularization of land surface model
    280 #
     281# 
    281282# 1957 2016-07-07 10:43:48Z suehring
    282283# flight module added
     
    286287#
    287288# 1938 2016-06-13 15:26:05Z hellstea
    288 # Some dependency errors corrected
    289 #
     289# Some dependency errors corrected 
     290# 
    290291# 1934 2016-06-13 09:46:57Z hellstea
    291292# poismg renamed poismg_noopt, poismg_fast_mod renamed poismg_mod
    292 #
     293# 
    293294# 1914 2016-05-26 14:44:07Z witha
    294295# Added wind_turbine_model_mod
     
    301302#
    302303# 1850 2016-04-08 13:29:27Z maronga
    303 # Adapted for modularization of microphysics
     304# Adapted for modularization of microphysics 
    304305# Several files renamed --> _mod
    305306# Bugfix for previous commit
     
    316317# 1833 2016-04-07 14:23:03Z raasch
    317318# spectrum renamed spectra_mod, depencies for spectra changed
    318 #
     319# 
    319320# 1826 2016-04-07 12:01:39Z maronga
    320321# Renamed radiation_model to radiation_model_mod.
    321322# Renamed plant_canopy_model to plant_canopy_model_mod.
    322 #
     323# 
    323324# 1822 2016-04-07 07:49:42Z hoffmann
    324325# Tails removed. lpm_release_set removed. calc_precipitation, impact_of_latent_heat
    325 # removed.
     326# removed. 
    326327#
    327328# 1817 2016-04-06 15:44:20Z maronga
    328329# Renamed land_surface_model to land_surface_model_mod.
    329 #
     330# 
    330331# 1808 2016-04-05 19:44:00Z raasch
    331332# -local_flush, -local_getenv
     
    353354#
    354355# 1762 2016-02-25 12:31:13Z hellstea
    355 # +pmc_interface, +pmc routines
     356# +pmc_interface, +pmc routines 
    356357#
    357358# 1747 2016-02-08 12:25:53Z raasch
     
    359360#
    360361# 1691 2015-10-26 16:17:44Z maronga
    361 # Replaced prandtl_fluxes with surface_layer_fluxes. Added radiation_model to
     362# Replaced prandtl_fluxes with surface_layer_fluxes. Added radiation_model to 
    362363# prognostic_equations
    363 #
     364# 
    364365# 1585 2015-04-30 07:05:52Z maronga
    365366# Added user_init_radiation.f90
    366 #
     367# 
    367368# 1575 2015-03-27 09:56:27Z raasch
    368369# +poismg_fast
     
    370371# 1551 2015-03-03 14:18:16Z maronga
    371372# Bugfix: further adjustments for the land surface model and radiation model
    372 #
     373# 
    373374# 1517 2015-01-07 19:12:25Z hoffmann
    374375# advec_s_bc added to prognostic_equations
     
    376377# 1500 2014-12-03 17:42:41Z maronga
    377378# Bugfix: missing adjustments for land surface model and radiation model
    378 #
     379# 
    379380# 1496 2014-12-02 17:25:50Z maronga
    380 # Added land surface model and radiation model files: land_surface_model,
     381# Added land surface model and radiation model files: land_surface_model, 
    381382# radiation_model, user_init_land_surface
    382 #
     383# 
    383384# 1484 2014-10-21 10:53:05Z kanani
    384385# plant_canopy_model-dependency added for check_parameters, header, init_3d_model,
    385386# package_parin, read_var_list, user_init_plant_canopy, write_var_list
    386 #
     387# 
    387388# 1444 2014-08-02 20:10:32Z letzel
    388389# bugfix: cpulog added to lpm_advec
    389 #
     390# 
    390391# 1404 2014-05-14 09:01:39Z keck
    391392# bugfix: dependencies added for progress_bar
     
    393394# 1402 2014-05-09 14:25:13Z raasch
    394395# progress_bar added
    395 #
     396# 
    396397# 1400 2014-05-09 14:03:54Z knoop
    397398# Added new module random_generator_parallel
    398 #
     399# 
    399400# 1380 2014-04-28 12:40:45Z heinze
    400401# bugfix: mod_particle_attributes  added to check_open
    401 # nudging added to time_integration
     402# nudging added to time_integration 
    402403#
    403404# 1374 2014-04-25 12:55:07Z raasch
     
    407408# Added new module calc_mean_profile, previously in module buoyancy,
    408409# removed buoyancy dependency from nudging
    409 #
     410# 
    410411# 1363 2014-04-17 12:28:49Z keck
    411412# bugfix: cpulog added to lpm_pack_arrays
     
    413414# 1361 2014-04-16 15:17:48Z hoffmann
    414415# cpulog added to microphysics
    415 #
     416# 
    416417# 1359 2014-04-11 17:15:14Z hoffmann
    417 # mod_particle_attributes added, lpm_sort_arrays removed,
     418# mod_particle_attributes added, lpm_sort_arrays removed, 
    418419# lpm_extend_particle_array removed
    419420#
     
    722723
    723724CC = cc
    724 CFLAGS = -O
     725CFLAGS = -O 
    725726
    726727F90 =
     
    13491350        chemistry_model_mod.o \
    13501351        gust_mod.o \
     1352        indoor_model_mod.o \
    13511353        land_surface_model_mod.o \
    13521354        mod_kinds.o \
     
    17501752        modules.o \
    17511753        netcdf_data_input_mod.o \
    1752         plant_canopy_model_mod.o \
    17531754        radiation_model_mod.o \
    17541755        surface_mod.o
  • palm/trunk/SOURCE/indoor_model_mod.f90

    r3685 r3744  
    2121! Current revisions:
    2222! -----------------
    23 !
     23! - remove building_type from module
     24! - initialize parameters for each building individually instead of a bulk
     25!   initializaion with  identical building type for all
     26! - output revised
     27! - add missing _wp
     28! - some restructuring of variables in building data structure
    2429!
    2530! Former revisions:
     
    7681
    7782    USE kinds
     83   
     84    USE netcdf_data_input_mod,                                                 &
     85        ONLY:  building_id_f, building_type_f
    7886
    7987    USE surface_mod,                                                           &
     
    105113       INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  num_facade_v   !< number of vertical facades elements per buidling
    106114                                                                  !< and height level
     115                                                                 
     116       INTEGER(iwp) ::  ventilation_int_loads
    107117
    108118       LOGICAL ::  on_pe = .FALSE.   !< flag indicating whether a building with certain ID is on local subdomain
     119       
     120       
     121       REAL(wp) ::  lambda_layer3     !< [W/(m*K)] Thermal conductivity of the inner layer 
     122       REAL(wp) ::  s_layer3          !< [m] half thickness of the inner layer (layer_3)
     123       REAL(wp) ::  f_c_win           !< [-] shading factor
     124       REAL(wp) ::  g_value_win       !< [-] SHGC factor
     125       REAL(wp) ::  u_value_win       !< [W/(m2*K)] transmittance
     126       REAL(wp) ::  air_change_low    !< [1/h] air changes per time_utc_hour
     127       REAL(wp) ::  air_change_high   !< [1/h] air changes per time_utc_hour
     128       REAL(wp) ::  eta_ve            !< [-] heat recovery efficiency
     129       REAL(wp) ::  factor_a          !< [-] Dynamic parameters specific effective surface according to Table 12; 2.5
     130                                      !< (very light, light and medium), 3.0 (heavy), 3.5 (very heavy)
     131       REAL(wp) ::  factor_c          !< [J/(m2 K)] Dynamic parameters inner heatstorage according to Table 12; 80000
     132                                      !< (very light), 110000 (light), 165000 (medium), 260000 (heavy), 370000 (very heavy)
     133       REAL(wp) ::  lambda_at         !< [-] ratio internal surface/floor area chap. 7.2.2.2.
     134       REAL(wp) ::  theta_int_h_set   !< [degree_C] Max. Setpoint temperature (winter)
     135       REAL(wp) ::  theta_int_c_set   !< [degree_C] Max. Setpoint temperature (summer)
     136       REAL(wp) ::  phi_h_max         !< [W] Max. Heating capacity (negative)
     137       REAL(wp) ::  phi_c_max         !< [W] Max. Cooling capacity (negative)
     138       REAL(wp) ::  qint_high         !< [W/m2] internal heat gains, option Database qint_0-23
     139       REAL(wp) ::  qint_low          !< [W/m2] internal heat gains, option Database qint_0-23
     140       REAL(wp) ::  height_storey     !< [m] storey heigth
     141       REAL(wp) ::  height_cei_con    !< [m] ceiling construction heigth
    109142
    110143       REAL(wp), DIMENSION(:), ALLOCATABLE ::  t_in       !< mean building indoor temperature, height dependent
     
    113146       REAL(wp), DIMENSION(:), ALLOCATABLE ::  vol_frac   !< fraction of local on total building volume, height dependent
    114147       REAL(wp), DIMENSION(:), ALLOCATABLE ::  vpf        !< building volume volume per facade element, height dependent
    115 
     148       
    116149    END TYPE build
    117150
     
    130163!-- Declare all global variables within the module
    131164
    132     INTEGER(iwp) ::  building_type = 1       !< namelist parameter with
     165!     INTEGER(iwp) ::  building_type = 1       !< namelist parameter with
    133166                                             !< X1=construction year (cy) 1950, X2=cy 2000, X3=cy 2050
    134167                                             !< R=Residental building, O=Office, RW=Enlarged Windows, P=Panel type (Plattenbau) WBS 70, H=Hospital (in progress), I=Industrial halls (in progress), S=Special Building (in progress)
     
    139172    INTEGER(iwp) ::  solar_protection_on     !< Solar protection on
    140173
    141     REAL(wp) ::  air_change_high             !< [1/h] air changes per time_utc_hour
    142     REAL(wp) ::  air_change_low              !< [1/h] air changes per time_utc_hour
    143     REAL(wp) ::  eff_mass_area               !< [m²] the effective mass-related area
    144     REAL(wp) ::  floor_area_per_facade       !< [m²] net floor area (Sum of all floors)
    145     REAL(wp) ::  total_area                  !<! [m²] area of all surfaces pointing to zone
     174    REAL(wp) ::  eff_mass_area               !< [m2] the effective mass-related area
     175    REAL(wp) ::  floor_area_per_facade       !< [m2] net floor area (Sum of all floors)
     176    REAL(wp) ::  total_area                  !<! [m2] area of all surfaces pointing to zone
    146177    REAL(wp) ::  window_area_per_facade      !< [m2] window area per facade element
    147178    REAL(wp) ::  air_change                  !< [1/h] Airflow
    148     REAL(wp) ::  bldg_part_surf_i    = 4     !< [m²_surf,i] part building surface, from Palm, das mÃŒsste mittlerweile "facade_element_area" sein!
    149     REAL(wp) ::  facade_element_area         !< [m²_facade] building surface facade
    150     REAL(wp) ::  indoor_volume_per_facade    !< [m³] indoor air volume per facade element
     179    REAL(wp) ::  facade_element_area         !< [m2_facade] building surface facade
     180    REAL(wp) ::  indoor_volume_per_facade    !< [m3] indoor air volume per facade element
    151181    REAL(wp) ::  c_m                         !< [J/K] internal heat storage capacity
    152182    REAL(wp) ::  dt_indoor = 3600.0_wp       !< [s] namelist parameter: time interval for indoor-model application
    153     REAL(wp) ::  eta_ve                      !< [-] heat recovery efficiency
    154     REAL(wp) ::  f_c_win                     !< [-] shading factor
    155     REAL(wp) ::  factor_a                    !< [-] Dynamic parameters specific effective surface according to Table 12; 2.5 (very light, light and medium), 3.0 (heavy), 3.5 (very heavy)
    156     REAL(wp) ::  factor_c                    !< [J/(m2 K)] Dynamic parameters inner heatstorage according to Table 12; 80000 (very light), 110000 (light), 165000 (medium), 260000 (heavy), 370000 (very heavy)
    157     REAL(wp) ::  g_value_win                 !< [-] SHGC factor
    158183    REAL(wp) ::  h_tr_1                      !<! [W/K] Heat transfer coefficient auxiliary variable 1
    159184    REAL(wp) ::  h_tr_2                      !<! [W/K] Heat transfer coefficient auxiliary variable 2
     
    165190    REAL(wp) ::  h_tr_w                      !<! [W/K] heat transfer coefficient of doors, windows, curtain walls and glazed walls (assumption: thermal mass=0)
    166191    REAL(wp) ::  h_ve                        !<! [W/K] heat transfer of ventilation
    167     REAL(wp) ::  height_storey               !< [m] storey heigth
    168     REAL(wp) ::  height_cei_con              !< [m] ceiling construction heigth   
    169192    REAL(wp) ::  initial_indoor_temperature  !< namelist parameter
    170     REAL(wp) ::  lambda_at                   !< [-] ratio internal surface/floor area chap. 7.2.2.2.
    171     REAL(wp) ::  lambda_layer3               !< [W/(m*K)] Thermal conductivity of the inner layer 
    172193    REAL(wp) ::  net_sw_in                   !< net short-wave radiation (in - out; was i_global --> CORRECT?)
    173     REAL(wp) ::  qint_high                   !< [W/m2] internal heat gains, option Database qint_0-23
    174     REAL(wp) ::  qint_low                    !< [W/m2] internal heat gains, option Database qint_0-23
    175     REAL(wp) ::  phi_c_max                   !< [W] Max. Cooling capacity (negative)
    176     REAL(wp) ::  phi_h_max                   !< [W] Max. Heating capacity (negative)
    177194    REAL(wp) ::  phi_hc_nd                   !<! [W] heating demand and/or cooling demand
    178195    REAL(wp) ::  phi_hc_nd_10                !<! [W] heating demand and/or cooling demand for heating or cooling
     
    185202    REAL(wp) ::  phi_st                      !<! [W] mass specific thermal load implied non thermal mass
    186203    REAL(wp) ::  q_emission                  !< emissions, in first version = 0, option for second part of the project
    187     REAL(wp) ::  q_wall_win               !< heat flux from indoor into wall/window
     204    REAL(wp) ::  q_wall_win                  !< heat flux from indoor into wall/window
    188205    REAL(wp) ::  q_waste_heat                !< waste heat, sum of waste heat over the roof to Palm
    189206    REAL(wp) ::  q_waste_heat_bldg           !< [W/building] waste heat of the complete building, in Palm sum of all indoor_model-calculations
    190     REAL(wp) ::  s_layer3                    !< [m] half thickness of the inner layer (layer_3)
    191207    REAL(wp) ::  schedule_d                  !< activation for internal loads (low or high + low)
    192208    REAL(wp) ::  skip_time_do_indoor = 0.0_wp  !< [s] Indoor model is not called before this time
    193209    REAL(wp) ::  theta_air                   !<! [degree_C] air temperature of the RC-node
    194210    REAL(wp) ::  theta_air_0                 !<! [degree_C] air temperature of the RC-node in equilibrium
    195     REAL(wp) ::  theta_air_10                !<! [degree_C] air temperature of the RC-node from a heating capacity of 10 W/m²
     211    REAL(wp) ::  theta_air_10                !<! [degree_C] air temperature of the RC-node from a heating capacity of 10 W/m2
    196212    REAL(wp) ::  theta_air_ac                !< [degree_C] actual room temperature after heating/cooling
    197213    REAL(wp) ::  theta_air_set               !< [degree_C] Setpoint_temperature for the room
    198     REAL(wp) ::  theta_int_c_set             !< [degree_C] Max. Setpoint temperature (summer)
    199     REAL(wp) ::  theta_int_h_set             !< [degree_C] Max. Setpoint temperature (winter)
    200214    REAL(wp) ::  theta_m                     !<! [degree_C} inner temperature of the RC-node
    201215    REAL(wp) ::  theta_m_t                   !<! [degree_C] (Fictive) component temperature timestep
     
    205219    REAL(wp) ::  time_indoor = 0.0_wp        !< [s] time since last call of indoor model
    206220    REAL(wp) ::  time_utc_hour               !< Time in hours per day (UTC)
    207     REAL(wp) ::  u_value_win                 !< [W/(m2*K)] transmittance
    208221    REAL(wp) ::  ventilation_int_loads       !< Zuteilung der GebÀude fÃŒr Verlauf/AktivitÀt der LÃŒftung und internen Lasten
    209 
    210 !
    211 !-- Declare all global parameters within the module   
     222   
     223    REAL(wp) ::  f_sr                        !< [-] factor surface reduction
     224    REAL(wp) ::  f_cei                       !< [-] ceiling reduction factor
     225    REAL(wp) ::  ngs                         !< [m2] netto ground surface
     226    REAL(wp) ::  building_height
     227   
    212228    REAL(wp), PARAMETER ::  params_f_f               = 0.3_wp      !< [-] frame ratio chap. 8.3.2.1.1 for buildings with mostly cooling 2.0_wp
    213229    REAL(wp), PARAMETER ::  params_f_w               = 0.9_wp      !< [-] correction factor (fuer nicht senkrechten Stahlungseinfall DIN 4108-2 chap.8, (hier konstant, keine WinkelabhÀngigkeit)
     
    218234    REAL(wp), PARAMETER ::  h_is                     = 3.45_wp     !< [W/(m^2 K)]  h_is = 3.45 between surface and air (chap. 7.2.2.2)
    219235    REAL(wp), PARAMETER ::  h_ms                     = 9.1_wp      !< [W/K] h_ms = 9.10 W / (m2 K) between component and surface (chap. 12.2.2)
    220  
     236
     237   
     238   
    221239    SAVE
    222240
     
    226244!
    227245!-- Add INTERFACES that must be available to other modules
    228     PUBLIC im_init, im_main_heatcool, im_parin
     246    PUBLIC im_init, im_main_heatcool, im_parin, im_define_netcdf_grid,          &
     247           im_check_data_output, im_data_output_3d, im_check_parameters
     248   
    229249
    230250!
     
    232252    PUBLIC dt_indoor, skip_time_do_indoor, time_indoor
    233253
     254!
     255!-- PALM interfaces:
     256!-- Data output checks for 2D/3D data to be done in check_parameters
     257     INTERFACE im_check_data_output
     258        MODULE PROCEDURE im_check_data_output
     259     END INTERFACE im_check_data_output
     260!
     261!-- Input parameter checks to be done in check_parameters
     262     INTERFACE im_check_parameters
     263        MODULE PROCEDURE im_check_parameters
     264     END INTERFACE im_check_parameters
     265!
     266!-- Data output of 3D data
     267     INTERFACE im_data_output_3d
     268        MODULE PROCEDURE im_data_output_3d
     269     END INTERFACE im_data_output_3d
     270
     271!
     272!-- Definition of data output quantities
     273     INTERFACE im_define_netcdf_grid
     274        MODULE PROCEDURE im_define_netcdf_grid
     275     END INTERFACE im_define_netcdf_grid
     276!
     277! !
     278! !-- Output of information to the header file
     279!     INTERFACE im_header
     280!        MODULE PROCEDURE im_header
     281!     END INTERFACE im_header
     282
     283!-- Data Output
     284!    INTERFACE im_data_output
     285!       MODULE PROCEDURE im_data_output
     286!    END INTERFACE im_data_output
    234287!
    235288!-- Calculations for indoor temperatures 
     
    242295       MODULE PROCEDURE im_init
    243296    END INTERFACE im_init
    244  
    245297!
    246298!-- Main part of indoor model 
     
    268320    USE arrays_3d,                                                             &
    269321        ONLY:  pt
    270 
    271 
     322   
     323   
    272324    IMPLICIT NONE
    273325   
     
    280332    REAL(wp) ::  near_facade_temperature
    281333    REAL(wp) ::  phi_hc_nd_dummy
     334   
    282335
    283336    !< Calculation of total mass specific thermal load (internal and external)
     
    292345    !< Calculation of component temperature at factual timestep
    293346    theta_m_t = ( ( theta_m_t_prev                                               &
    294                     * ( ( c_m / 3600 ) - 0.5 * ( h_tr_3 + h_tr_em ) ) + phi_mtot &
     347                    * ( ( c_m / 3600.0_wp ) - 0.5_wp * ( h_tr_3 + h_tr_em ) ) + phi_mtot &
    295348                  )                                                              &
    296                   /   ( ( c_m / 3600 ) + 0.5 * ( h_tr_3 + h_tr_em ) )            &
     349                  /   ( ( c_m / 3600.0_wp ) + 0.5_wp * ( h_tr_3 + h_tr_em ) )            &
    297350                )                                                               !< [degree_C] Eq. (C.4)
    298351
    299352    !< Calculation of mean inner temperature for the RC-node in actual timestep
    300     theta_m = ( theta_m_t + theta_m_t_prev ) * 0.5                              !< [degree_C] Eq. (C.9)
     353    theta_m = ( theta_m_t + theta_m_t_prev ) * 0.5_wp                              !< [degree_C] Eq. (C.9)
    301354   
    302355    !< Calculation of mean surface temperature of the RC-node in actual timestep
     
    343396        ONLY:  dx, dy
    344397
    345     USE netcdf_data_input_mod,                                                 &
    346         ONLY:  building_id_f
    347 
    348398    USE pegrid
    349399
     
    356406    IMPLICIT NONE
    357407
     408    INTEGER(iwp) ::  bt   !< local building type
    358409    INTEGER(iwp) ::  fa   !< running index for facade elements of each building
    359410    INTEGER(iwp) ::  i    !< running index along x-direction
     
    384435    INTEGER(iwp), DIMENSION(0:numprocs-1) ::  num_buildings         !< number of buildings with different ID on entire model domain
    385436    INTEGER(iwp), DIMENSION(0:numprocs-1) ::  num_buildings_l       !< number of buildings with different ID on local subdomain
    386 
     437   
    387438    REAL(wp), DIMENSION(:), ALLOCATABLE ::  local_weight   !< dummy representing fraction of local on total building volume,
    388439                                                           !< height dependent
     
    503554!-- the respective building is present (in order to reduce memory demands).
    504555    ALLOCATE( buildings(1:num_build) )
     556
    505557!
    506558!-- Store building IDs and check if building with certain ID is present on
     
    792844
    793845!
    794 !-- Building parameters by type of building. Assigned in urban_surface_mod.f90
    795 
    796     lambda_layer3            = building_pars(63, building_type)
    797     s_layer3                 = building_pars(57, building_type)
    798     f_c_win                  = building_pars(119, building_type)
    799     g_value_win              = building_pars(120, building_type)   
    800     u_value_win              = building_pars(121, building_type)   
    801     air_change_low           = building_pars(122, building_type)   
    802     air_change_high          = building_pars(123, building_type)   
    803     eta_ve                   = building_pars(124, building_type)   
    804     factor_a                 = building_pars(125, building_type)   
    805     factor_c                 = building_pars(126, building_type)
    806     lambda_at                = building_pars(127, building_type)   
    807     theta_int_h_set          = building_pars(118, building_type)   
    808     theta_int_c_set          = building_pars(117, building_type)
    809     phi_h_max                = building_pars(128, building_type)   
    810     phi_c_max                = building_pars(129, building_type)         
    811     qint_high                = building_pars(130, building_type)
    812     qint_low                 = building_pars(131, building_type)
    813     height_storey            = building_pars(132, building_type)
    814     height_cei_con           = building_pars(133, building_type)
    815 
    816 !
    817 !-- Setting of initial room temperature [K]
     846!-- Initialize building parameters, first by mean building type. Note,
     847!-- in this case all buildings have the same type.
     848!-- In a second step initialize with building tpyes from static input file,
     849!-- where building types can be individual for each building.
     850    buildings(:)%lambda_layer3    = building_pars(63,building_type)
     851    buildings(:)%s_layer3         = building_pars(57,building_type)
     852    buildings(:)%f_c_win          = building_pars(119,building_type)
     853    buildings(:)%g_value_win      = building_pars(120,building_type)   
     854    buildings(:)%u_value_win      = building_pars(121,building_type)   
     855    buildings(:)%air_change_low   = building_pars(122,building_type)   
     856    buildings(:)%air_change_high  = building_pars(123,building_type)   
     857    buildings(:)%eta_ve           = building_pars(124,building_type)   
     858    buildings(:)%factor_a         = building_pars(125,building_type)   
     859    buildings(:)%factor_c         = building_pars(126,building_type)
     860    buildings(:)%lambda_at        = building_pars(127,building_type)   
     861    buildings(:)%theta_int_h_set  = building_pars(118,building_type)   
     862    buildings(:)%theta_int_c_set  = building_pars(117,building_type)
     863    buildings(:)%phi_h_max        = building_pars(128,building_type)   
     864    buildings(:)%phi_c_max        = building_pars(129,building_type)         
     865    buildings(:)%qint_high        = building_pars(130,building_type)
     866    buildings(:)%qint_low         = building_pars(131,building_type)
     867    buildings(:)%height_storey    = building_pars(132,building_type)
     868    buildings(:)%height_cei_con   = building_pars(133,building_type)
     869!
     870!-- Initialize ventilaation load. Please note, building types > 7 are actually
     871!-- not allowed (check already in urban_surface_mod and netcdf_data_input_mod.
     872!-- However, the building data base may be later extended.
     873    IF ( building_type ==  1  .OR.  building_type ==  2  .OR.                  &
     874         building_type ==  3  .OR.  building_type == 10  .OR.                  &
     875         building_type == 11  .OR.  building_type == 12 )  THEN
     876       buildings(nb)%ventilation_int_loads = 1
     877!
     878!-- Office, building with large windows
     879    ELSEIF ( building_type ==  4  .OR.  building_type ==  5  .OR.              &
     880             building_type ==  6  .OR.  building_type ==  7  .OR.              &
     881             building_type ==  8  .OR.  building_type ==  9)  THEN
     882       buildings(nb)%ventilation_int_loads = 2
     883!
     884!-- Industry, hospitals
     885    ELSEIF ( building_type == 13  .OR.  building_type == 14  .OR.              &
     886             building_type == 15  .OR.  building_type == 16  .OR.              &
     887             building_type == 17  .OR.  building_type == 18 )  THEN
     888       buildings(nb)%ventilation_int_loads = 3
     889    ENDIF
     890!
     891!-- Initialization of building parameters - level 2
     892    IF ( building_type_f%from_file )  THEN
     893       DO  i = nxl, nxr
     894          DO  j = nys, nyn
     895              IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
     896                 nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ),    &
     897                              DIM = 1 )
     898                 bt = building_type_f%var(j,i)
     899                 
     900                 buildings(nb)%lambda_layer3    = building_pars(63,bt)
     901                 buildings(nb)%s_layer3         = building_pars(57,bt)
     902                 buildings(nb)%f_c_win          = building_pars(119,bt)
     903                 buildings(nb)%g_value_win      = building_pars(120,bt)   
     904                 buildings(nb)%u_value_win      = building_pars(121,bt)   
     905                 buildings(nb)%air_change_low   = building_pars(122,bt)   
     906                 buildings(nb)%air_change_high  = building_pars(123,bt)   
     907                 buildings(nb)%eta_ve           = building_pars(124,bt)   
     908                 buildings(nb)%factor_a         = building_pars(125,bt)   
     909                 buildings(nb)%factor_c         = building_pars(126,bt)
     910                 buildings(nb)%lambda_at        = building_pars(127,bt)   
     911                 buildings(nb)%theta_int_h_set  = building_pars(118,bt)   
     912                 buildings(nb)%theta_int_c_set  = building_pars(117,bt)
     913                 buildings(nb)%phi_h_max        = building_pars(128,bt)   
     914                 buildings(nb)%phi_c_max        = building_pars(129,bt)         
     915                 buildings(nb)%qint_high        = building_pars(130,bt)
     916                 buildings(nb)%qint_low         = building_pars(131,bt)
     917                 buildings(nb)%height_storey    = building_pars(132,bt)
     918                 buildings(nb)%height_cei_con   = building_pars(133,bt)                 
     919!
     920!--              Initialize ventilaation load. Please note, building types > 7
     921!--              are actually not allowed (check already in urban_surface_mod 
     922!--              and netcdf_data_input_mod. However, the building data base may
     923!--              be later extended.
     924                 IF ( bt ==  1  .OR.  bt ==  2  .OR.                           &
     925                      bt ==  3  .OR.  bt == 10  .OR.                           &
     926                      bt == 11  .OR.  bt == 12 )  THEN
     927                    buildings(nb)%ventilation_int_loads = 1
     928!                   
     929!--              Office, building with large windows
     930                 ELSEIF ( bt ==  4  .OR.  bt ==  5  .OR.                       &
     931                          bt ==  6  .OR.  bt ==  7  .OR.                       &
     932                          bt ==  8  .OR.  bt ==  9)  THEN
     933                    buildings(nb)%ventilation_int_loads = 2
     934!
     935!--              Industry, hospitals
     936                 ELSEIF ( bt == 13  .OR.  bt == 14  .OR.                       &
     937                          bt == 15  .OR.  bt == 16  .OR.                       &
     938                          bt == 17  .OR.  bt == 18 )  THEN
     939                    buildings(nb)%ventilation_int_loads = 3
     940                 ENDIF
     941              ENDIF
     942           ENDDO
     943        ENDDO
     944    ENDIF
     945!
     946!-- Initial room temperature [K]
    818947!-- (after first loop, use theta_m_t as theta_m_t_prev)
    819948    theta_m_t_prev = initial_indoor_temperature
     949!
     950!-- Initialize indoor temperature. Actually only for output at initial state.
     951    DO  nb = 1, num_build
     952       buildings(nb)%t_in(:) = initial_indoor_temperature
     953    ENDDO
    820954
    821955    CALL location_message( 'finished', .TRUE. )
     
    8741008    REAL(wp), DIMENSION(:), ALLOCATABLE ::  t_in_l_send   !< dummy send buffer used for summing-up indoor temperature per kk-level
    8751009    REAL(wp), DIMENSION(:), ALLOCATABLE ::  t_in_recv     !< dummy recv buffer used for summing-up indoor temperature per kk-level
    876 
    877 !
    878 !-- Daily schedule, here for 08:00-18:00 = 1, other hours = 0.
    879 !-- time_utc_hour is calculated here based on time_utc [s] from
    880 !-- date_and_time_mod.
    881 !-- (kanani: Does this schedule not depend on if it's an office or resident
    882 !-- building?)
     1010!
     1011!-- Determine time of day in hours.
    8831012    time_utc_hour = time_utc / 3600.0_wp
    884 
    885 !
    886 !-- Allocation of the load profiles to the building types
    887 !-- Residental Building, panel WBS 70
    888     if      (building_type ==  1 .OR. &
    889              building_type ==  2 .OR. &
    890              building_type ==  3 .OR. &
    891              building_type == 10 .OR. &
    892              building_type == 11 .OR. &
    893              building_type == 12) then
    894                                         ventilation_int_loads = 1
    895 !-- Office, building with large windows
    896     else if (building_type ==  4 .OR. &
    897              building_type ==  5 .OR. &
    898              building_type ==  6 .OR. &
    899              building_type ==  7 .OR. &
    900              building_type ==  8 .OR. &
    901              building_type ==  9) then
    902                                         ventilation_int_loads = 2
    903 !-- Industry, hospitals
    904     else if (building_type == 13 .OR. &
    905              building_type == 14 .OR. &
    906              building_type == 15 .OR. &
    907              building_type == 16 .OR. &
    908              building_type == 17 .OR. &
    909              building_type == 18) then
    910                                         ventilation_int_loads = 3
    911 
    912     end if
    913 
    914 !-- Residental Building, panel WBS 70
    915    
    916     if (ventilation_int_loads == 1) THEN
    917        if ( time_utc_hour >= 6.0_wp .AND. time_utc_hour <= 8.0_wp )  THEN
    918           schedule_d = 1
    919        else if ( time_utc_hour >= 18.0_wp .AND. time_utc_hour <= 23.0_wp )  THEN
    920           schedule_d = 1
    921        else
    922           schedule_d = 0
    923        end if
    924     end if
    925 
    926 !-- Office, building with large windows
    927 
    928     if (ventilation_int_loads == 2) THEN
    929        if ( time_utc_hour >= 8.0_wp  .AND.  time_utc_hour <= 18.0_wp )  THEN
    930           schedule_d = 1
    931        else
    932           schedule_d = 0
    933        end if
    934     end if
    935        
    936 !-- Industry, hospitals
    937     if (ventilation_int_loads == 3) THEN
    938        if ( time_utc_hour >= 6.0_wp  .AND.  time_utc_hour <= 22.0_wp )  THEN
    939           schedule_d = 1
    940        else
    941           schedule_d = 0
    942        end if
    943     end if
    944 
    945 
    9461013!
    9471014!-- Following calculations must be done for each facade element.
     
    9511018       IF ( buildings(nb)%on_pe )  THEN
    9521019!
     1020!--       Determine daily schedule. 08:00-18:00 = 1, other hours = 0.
     1021!--       Residental Building, panel WBS 70   
     1022          IF ( buildings(nb)%ventilation_int_loads == 1 )  THEN
     1023             IF ( time_utc_hour >= 6.0_wp  .AND.  time_utc_hour <= 8.0_wp )  THEN
     1024                schedule_d = 1
     1025             ELSEIF ( time_utc_hour >= 18.0_wp  .AND.  time_utc_hour <= 23.0_wp )  THEN
     1026                schedule_d = 1
     1027             ELSE
     1028                schedule_d = 0
     1029             ENDIF
     1030          ENDIF
     1031!
     1032!--       Office, building with large windows
     1033          IF ( buildings(nb)%ventilation_int_loads == 2 )  THEN
     1034             IF ( time_utc_hour >= 8.0_wp  .AND.  time_utc_hour <= 18.0_wp )  THEN
     1035                schedule_d = 1
     1036             ELSE
     1037                schedule_d = 0
     1038             ENDIF
     1039          ENDIF
     1040!       
     1041!--       Industry, hospitals
     1042          IF ( buildings(nb)%ventilation_int_loads == 3 )  THEN
     1043             IF ( time_utc_hour >= 6.0_wp  .AND.  time_utc_hour <= 22.0_wp )  THEN
     1044                schedule_d = 1
     1045             ELSE
     1046                schedule_d = 0
     1047             ENDIF
     1048          ENDIF
     1049!
    9531050!--       Initialize/reset indoor temperature
    954           buildings(nb)%t_in   = 0.0_wp
    9551051          buildings(nb)%t_in_l = 0.0_wp
    9561052!
     
    9701066             indoor_volume_per_facade = buildings(nb)%vpf(kk)               !< [m3] indoor air volume per facade element           
    9711067             window_area_per_facade   = surf_usm_h%frac(ind_wat_win,m)  * facade_element_area  !< [m2] window area per facade element
    972              eff_mass_area            = factor_a * floor_area_per_facade    !< [m2] standard values according to Table 12 section 12.3.1.2  (calculate over Eq. (65) according to section 12.3.1.2)
    973              c_m                      = factor_c * floor_area_per_facade    !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2)
    974              total_area               = lambda_at * floor_area_per_facade   !< [m2] area of all surfaces pointing to zone  Eq. (9) according to section 7.2.2.2
     1068             
     1069!              building_height          = buildings(nb)%num_facades_per_building_v_l * 0.1 * dzw(kk)
     1070             building_height          = buildings(nb)%kb_max * dzw(kk)
     1071             
     1072! print*, "building_height", building_height
     1073! print*, "num_facades_v_l", buildings(nb)%num_facades_per_building_v_l
     1074! print*, "num_facades_v", buildings(nb)%num_facades_per_building_v
     1075! print*, "kb_min_max", buildings(nb)%kb_min, buildings(nb)%kb_max
     1076! print*, "dzw kk", dzw(kk), kk
     1077
     1078             f_cei                    = building_height/(buildings(nb)%height_storey-buildings(nb)%height_cei_con) !< [-] factor for ceiling redcution
     1079             ngs                      = buildings(nb)%vpf(kk)/f_cei                    !< [m2] calculation of netto ground surface
     1080             f_sr                     = ngs/floor_area_per_facade                      !< [-] factor for surface reduction
     1081             eff_mass_area            = buildings(nb)%factor_a * ngs    !< [m2] standard values according to Table 12 section 12.3.1.2  (calculate over Eq. (65) according to section 12.3.1.2)
     1082             c_m                      = buildings(nb)%factor_c * ngs    !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2)
     1083             total_area               = buildings(nb)%lambda_at * floor_area_per_facade   !< [m2] area of all surfaces pointing to zone  Eq. (9) according to section 7.2.2.2
    9751084
    9761085!--          Calculation of heat transfer coefficient for transmission --> not time-dependent
    977              h_tr_w   = window_area_per_facade * u_value_win   !< [W/K] only for windows
     1086             h_tr_w   = window_area_per_facade * buildings(nb)%u_value_win   !< [W/K] only for windows
    9781087             h_tr_is  = total_area * h_is                      !< [W/K] with h_is = 3.45 W / (m2 K) between surface and air, Eq. (9)
    9791088             h_tr_ms  = eff_mass_area * h_ms                    !< [W/K] with h_ms = 9.10 W / (m2 K) between component and surface, Eq. (64)
    980              h_tr_op  = 1 / ( 1 / ( ( facade_element_area - window_area_per_facade ) &
    981                                     * lambda_layer3 / s_layer3 * 0.5 ) + 1 / h_tr_ms )
    982              h_tr_em  = 1 / ( 1 / h_tr_op - 1 / h_tr_ms )      !< [W/K] Eq. (63), Section 12.2.2
     1089             h_tr_op  = 1.0_wp / ( 1.0_wp / ( ( facade_element_area - window_area_per_facade ) &
     1090                                    * buildings(nb)%lambda_layer3 / buildings(nb)%s_layer3 * 0.5_wp ) + 1.0_wp / h_tr_ms )
     1091             h_tr_em  = 1.0_wp / ( 1.0_wp / h_tr_op - 1.0_wp / h_tr_ms )      !< [W/K] Eq. (63), Section 12.2.2
    9831092!
    9841093!--          internal air loads dependent on the occupacy of the room
    9851094!--          basical internal heat gains (qint_low) with additional internal heat gains by occupancy (qint_high) (0,5*phi_int)
    986              phi_ia = 0.5 * ( ( qint_high * schedule_d + qint_low )            &
    987                               * floor_area_per_facade )         !< [W] Eq. (C.1)
     1095             phi_ia = 0.5_wp * ( ( buildings(nb)%qint_high * schedule_d + buildings(nb)%qint_low )            &
     1096                              * ngs )         !< [W] Eq. (C.1)
    9881097!
    9891098!--          Airflow dependent on the occupacy of the room
    9901099!--          basical airflow (air_change_low) with additional airflow gains by occupancy (air_change_high)
    991              air_change = ( air_change_high * schedule_d + air_change_low )  !< [1/h]?
     1100             air_change = ( buildings(nb)%air_change_high * schedule_d + buildings(nb)%air_change_low )  !< [1/h]?
    9921101!
    9931102!--          Heat transfer of ventilation
     
    9951104!--          with heat capacity of air 0.33 Wh/m2K
    9961105             h_ve   = MAX( 0.01_wp , ( air_change * indoor_volume_per_facade *      &
    997                                     0.33_wp * (1 - eta_ve ) ) )    !< [W/K] from ISO 13789 Eq.(10)
     1106                                    0.33_wp * (1.0_wp - buildings(nb)%eta_ve ) ) )    !< [W/K] from ISO 13789 Eq.(10)
    9981107
    9991108!--          Heat transfer coefficient auxiliary variables
    1000              h_tr_1 = 1 / ( ( 1 / h_ve )   + ( 1 / h_tr_is ) )  !< [W/K] Eq. (C.6)
     1109             h_tr_1 = 1.0_wp / ( ( 1.0_wp / h_ve )   + ( 1.0_wp / h_tr_is ) )  !< [W/K] Eq. (C.6)
    10011110             h_tr_2 = h_tr_1 + h_tr_w                           !< [W/K] Eq. (C.7)
    1002              h_tr_3 = 1 / ( ( 1 / h_tr_2 ) + ( 1 / h_tr_ms ) )  !< [W/K] Eq. (C.8)
     1111             h_tr_3 = 1.0_wp / ( ( 1.0_wp / h_tr_2 ) + ( 1.0_wp / h_tr_ms ) )  !< [W/K] Eq. (C.8)
    10031112!
    10041113!--          Net short-wave radiation through window area (was i_global)
     
    10281137!--          DIN 4108 - 2 chap.8
    10291138             phi_sol = (   window_area_per_facade * net_sw_in * solar_protection_off               &
    1030                          + window_area_per_facade * net_sw_in * f_c_win * solar_protection_on )    &
    1031                        * g_value_win * ( 1 - params_f_f ) * params_f_w              !< [W]
     1139                         + window_area_per_facade * net_sw_in * buildings(nb)%f_c_win * solar_protection_on )    &
     1140                       * buildings(nb)%g_value_win * ( 1.0_wp - params_f_f ) * params_f_w              !< [W]
    10321141!
    10331142!--          Calculation of the mass specific thermal load for internal and external heatsources of the inner node
     
    10351144!
    10361145!--          Calculation mass specific thermal load implied non thermal mass
    1037              phi_st  =   ( 1 - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1 * total_area ) ) ) &
     1146             phi_st  =   ( 1.0_wp - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1_wp * total_area ) ) ) &
    10381147                       * ( phi_ia + phi_sol )                                       !< [W] Eq. (C.3) with phi_ia=0,5*phi_int
    10391148!
     
    10411150!--          Step 1: Indoor temperature without heating and cooling
    10421151!--          section C.4.1 Picture C.2 zone 3)
    1043              phi_hc_nd = 0
     1152             phi_hc_nd = 0.0_wp
    10441153             
    10451154             CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, &
     
    10471156!
    10481157!--          If air temperature between border temperatures of heating and cooling, assign output variable, then ready   
    1049              IF ( theta_int_h_set <= theta_air  .AND.  theta_air <= theta_int_c_set )  THEN
    1050                 phi_hc_nd_ac = 0
     1158             IF ( buildings(nb)%theta_int_h_set <= theta_air  .AND.  theta_air <= buildings(nb)%theta_int_c_set )  THEN
     1159                phi_hc_nd_ac = 0.0_wp
    10511160                phi_hc_nd    = phi_hc_nd_ac
    10521161                theta_air_ac = theta_air
    10531162!
    1054 !--          Step 2: Else, apply 10 W/m² heating/cooling power and calculate indoor temperature
     1163!--          Step 2: Else, apply 10 W/m2 heating/cooling power and calculate indoor temperature
    10551164!--          again.
    10561165             ELSE
     
    10601169
    10611170!--             Heating or cooling?
    1062                 IF ( theta_air > theta_int_c_set )  THEN
    1063                    theta_air_set = theta_int_c_set
     1171                IF ( theta_air > buildings(nb)%theta_int_c_set )  THEN
     1172                   theta_air_set = buildings(nb)%theta_int_c_set
    10641173                ELSE
    1065                    theta_air_set = theta_int_h_set
     1174                   theta_air_set = buildings(nb)%theta_int_h_set
    10661175                ENDIF
    10671176
     
    10791188                                            / (theta_air_10  - theta_air_0)            !< Eq. (C.13)
    10801189                                           
    1081                                            
    1082                                        
    10831190!--             Step 3: With temperature ratio to determine the heating or cooling capacity   
    10841191!--             If necessary, limit the power to maximum power
    10851192!--             section C.4.1 Picture C.2 zone 2) and 4)
    1086                 IF ( phi_c_max < phi_hc_nd_un  .AND.  phi_hc_nd_un < phi_h_max )  THEN
     1193                IF ( buildings(nb)%phi_c_max < phi_hc_nd_un  .AND.  phi_hc_nd_un < buildings(nb)%phi_h_max )  THEN
    10871194                   phi_hc_nd_ac = phi_hc_nd_un
    10881195                   phi_hc_nd = phi_hc_nd_un   
     
    10901197!--             Step 4: Inner temperature with maximum heating (phi_hc_nd_un positive) or cooling (phi_hc_nd_un negative)
    10911198!--             section C.4.1 Picture C.2 zone 1) and 5)
    1092                    IF ( phi_hc_nd_un > 0 )  THEN
    1093                       phi_hc_nd_ac = phi_h_max                                         !< Limit heating
     1199                   IF ( phi_hc_nd_un > 0.0_wp )  THEN
     1200                      phi_hc_nd_ac = buildings(nb)%phi_h_max                                         !< Limit heating
    10941201                   ELSE
    1095                       phi_hc_nd_ac = phi_c_max                                         !< Limit cooling
     1202                      phi_hc_nd_ac = buildings(nb)%phi_c_max                                         !< Limit cooling
    10961203                   ENDIF
    10971204                ENDIF
     
    11121219!--          Calculate the operating temperature with weighted mean temperature of air and mean solar temperature
    11131220!--          Will be used for thermal comfort calculations
    1114              theta_op     = 0.3 * theta_air_ac + 0.7 * theta_s          !< [degree_C] operative Temperature Eq. (C.12)
     1221             theta_op     = 0.3_wp * theta_air_ac + 0.7_wp * theta_s          !< [degree_C] operative Temperature Eq. (C.12)
    11151222!
    11161223!--          Heat flux into the wall. Value needed in urban_surface_mod to
     
    11321239!--          Calculation of waste heat
    11331240!--          Anthropogenic heat output
    1134               IF ( phi_hc_nd_ac > 0 )  THEN
    1135                    heating_on = 1
    1136                    cooling_on = 0
    1137               ELSE
    1138                    heating_on = 0
    1139                    cooling_on = 1
    1140               ENDIF
    1141 
    1142              q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on))  !< [W/m2]  anthropogenic heat output
    1143 !              surf_usm_h%shf(m)=q_waste_heat
     1241             IF ( phi_hc_nd_ac > 0.0_wp )  THEN
     1242                heating_on = 1
     1243                cooling_on = 0
     1244             ELSE
     1245                heating_on = 0
     1246                cooling_on = 1
     1247             ENDIF
     1248
     1249             q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on))!< [W/GebÀudemodell] , observe the directional convention in PALM!
     1250             surf_usm_h%waste_heat(m) = q_waste_heat
    11441251             
    11451252          ENDDO !< Horizontal surfaces loop
     
    11561263             kk = surf_usm_v(l)%k(m) + surf_usm_v(l)%koff
    11571264!
     1265!--          (SOME OF THE FOLLOWING (not time-dependent COULD PROBABLY GO INTO A FUNCTION
     1266!--          EXCEPT facade_element_area, EVERYTHING IS CALCULATED EQUALLY)
    11581267!--          Building geometries  --> not time-dependent
    11591268             IF ( l == 0  .OR. l == 1 ) facade_element_area = dx * dzw(kk)  !< [m2] surface area per facade element
     
    11621271             indoor_volume_per_facade = buildings(nb)%vpf(kk)               !< [m3] indoor air volume per facade element           
    11631272             window_area_per_facade   = surf_usm_v(l)%frac(ind_wat_win,m)  * facade_element_area  !< [m2] window area per facade element
    1164              eff_mass_area            = factor_a * floor_area_per_facade    !< [m2] standard values according to Table 12 section 12.3.1.2  (calculate over Eq. (65) according to section 12.3.1.2)
    1165              c_m                      = factor_c * floor_area_per_facade    !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2)
    1166              total_area               = lambda_at * floor_area_per_facade   !< [m2] area of all surfaces pointing to zone Eq. (9) according to section 7.2.2.2
     1273             
     1274             building_height          = buildings(nb)%kb_max * dzw(kk)
     1275             f_cei                    = building_height/(buildings(nb)%height_storey-buildings(nb)%height_cei_con) !< [-] factor for ceiling redcution
     1276             ngs                      = buildings(nb)%vpf(kk)/f_cei                    !< [m2] calculation of netto ground surface
     1277             f_sr                     = ngs/floor_area_per_facade                      !< [-] factor for surface reduction
     1278             eff_mass_area            = buildings(nb)%factor_a * ngs    !< [m2] standard values according to Table 12 section 12.3.1.2  (calculate over Eq. (65) according to section 12.3.1.2)
     1279             c_m                      = buildings(nb)%factor_c * ngs    !< [J/K] standard values according to table 12 section 12.3.1.2 (calculate over Eq. (66) according to section 12.3.1.2)
     1280             total_area               = buildings(nb)%lambda_at * floor_area_per_facade   !< [m2] area of all surfaces pointing to zone  Eq. (9) according to section 7.2.2.2
    11671281!
    11681282!--          Calculation of heat transfer coefficient for transmission --> not time-dependent
    1169              h_tr_w   = window_area_per_facade * u_value_win   !< [W/K] only for windows
     1283             h_tr_w   = window_area_per_facade * buildings(nb)%u_value_win   !< [W/K] only for windows
    11701284             h_tr_is  = total_area * h_is                      !< [W/K] with h_is = 3.45 W / (m2 K) between surface and air, Eq. (9)
    11711285             h_tr_ms  = eff_mass_area * h_ms                   !< [W/K] with h_ms = 9.10 W / (m2 K) between component and surface, Eq. (64)
    1172              h_tr_op  = 1 / ( 1 / ( ( facade_element_area - window_area_per_facade ) &
    1173                                     * lambda_layer3 / s_layer3 * 0.5 ) + 1 / h_tr_ms )
    1174              h_tr_em  = 1 / ( 1 / h_tr_op - 1 / h_tr_ms )      !< [W/K] Eq. (63), Section 12.2.2
     1286             h_tr_op  = 1.0_wp / ( 1.0_wp / ( ( facade_element_area - window_area_per_facade ) &
     1287                                    * buildings(nb)%lambda_layer3 / buildings(nb)%s_layer3 * 0.5_wp ) + 1.0_wp / h_tr_ms )
     1288             h_tr_em  = 1.0_wp / ( 1.0_wp / h_tr_op - 1.0_wp / h_tr_ms )      !< [W/K] Eq. (63), Section 12.2.2
    11751289!
    11761290!--          internal air loads dependent on the occupacy of the room
    11771291!--          basical internal heat gains (qint_low) with additional internal heat gains by occupancy (qint_high) (0,5*phi_int)
    1178              phi_ia = 0.5 * ( ( qint_high * schedule_d + qint_low )            &
    1179                               * floor_area_per_facade )                      !< [W] Eq. (C.1)
     1292             phi_ia = 0.5_wp * ( ( buildings(nb)%qint_high * schedule_d + buildings(nb)%qint_low )            &
     1293                              * ngs )                      !< [W] Eq. (C.1)
    11801294!
    11811295!--          Airflow dependent on the occupacy of the room
    11821296!--          basical airflow (air_change_low) with additional airflow gains by occupancy (air_change_high)
    1183              air_change = ( air_change_high * schedule_d + air_change_low ) 
     1297             air_change = ( buildings(nb)%air_change_high * schedule_d + buildings(nb)%air_change_low ) 
    11841298!
    11851299!--          Heat transfer of ventilation
     
    11871301!--          with heat capacity of air 0.33 Wh/m2K
    11881302             h_ve   = MAX( 0.01_wp , ( air_change * indoor_volume_per_facade *      &
    1189                                     0.33_wp * (1 - eta_ve ) ) )                    !< [W/K] from ISO 13789 Eq.(10)
     1303                                    0.33_wp * (1 - buildings(nb)%eta_ve ) ) )                    !< [W/K] from ISO 13789 Eq.(10)
    11901304                                   
    11911305!--          Heat transfer coefficient auxiliary variables
    1192              h_tr_1 = 1 / ( ( 1 / h_ve )   + ( 1 / h_tr_is ) )                  !< [W/K] Eq. (C.6)
     1306             h_tr_1 = 1.0_wp / ( ( 1.0_wp / h_ve )   + ( 1.0_wp / h_tr_is ) )                  !< [W/K] Eq. (C.6)
    11931307             h_tr_2 = h_tr_1 + h_tr_w                                           !< [W/K] Eq. (C.7)
    1194              h_tr_3 = 1 / ( ( 1 / h_tr_2 ) + ( 1 / h_tr_ms ) )                  !< [W/K] Eq. (C.8)
     1308             h_tr_3 = 1.0_wp / ( ( 1.0_wp / h_tr_2 ) + ( 1.0_wp / h_tr_ms ) )                  !< [W/K] Eq. (C.8)
    11951309!
    11961310!--          Net short-wave radiation through window area (was i_global)
     
    12201334!--          DIN 4108 - 2 chap.8
    12211335             phi_sol = (   window_area_per_facade * net_sw_in * solar_protection_off               &
    1222                          + window_area_per_facade * net_sw_in * f_c_win * solar_protection_on )    &
    1223                        * g_value_win * ( 1 - params_f_f ) * params_f_w
     1336                         + window_area_per_facade * net_sw_in * buildings(nb)%f_c_win * solar_protection_on )    &
     1337                       * buildings(nb)%g_value_win * ( 1.0_wp - params_f_f ) * params_f_w
    12241338!
    12251339!--          Calculation of the mass specific thermal load for internal and external heatsources
     
    12271341!
    12281342!--          Calculation mass specific thermal load implied non thermal mass
    1229              phi_st  =   ( 1 - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1 * total_area ) ) ) &
     1343             phi_st  =   ( 1.0_wp - ( eff_mass_area / total_area ) - ( h_tr_w / ( 9.1_wp * total_area ) ) ) &
    12301344                       * ( phi_ia + phi_sol )                                       !< [W] Eq. (C.3) with phi_ia=0,5*phi_int
    12311345!
     
    12331347!--          Step 1: Indoor temperature without heating and cooling
    12341348!--          section C.4.1 Picture C.2 zone 3)
    1235              phi_hc_nd = 0
    1236              
     1349             phi_hc_nd = 0.0_wp
    12371350             CALL im_calc_temperatures ( i, j, k, indoor_wall_window_temperature, &
    12381351                                         near_facade_temperature, phi_hc_nd )
    12391352!
    12401353!--          If air temperature between border temperatures of heating and cooling, assign output variable, then ready 
    1241              IF ( theta_int_h_set <= theta_air  .AND.  theta_air <= theta_int_c_set )  THEN
    1242                 phi_hc_nd_ac = 0
     1354             IF ( buildings(nb)%theta_int_h_set <= theta_air  .AND.  theta_air <= buildings(nb)%theta_int_c_set )  THEN
     1355                phi_hc_nd_ac = 0.0_wp
    12431356                phi_hc_nd    = phi_hc_nd_ac
    12441357                theta_air_ac = theta_air
    12451358!
    1246 !--          Step 2: Else, apply 10 W/m² heating/cooling power and calculate indoor temperature
     1359!--          Step 2: Else, apply 10 W/m2 heating/cooling power and calculate indoor temperature
    12471360!--          again.
    12481361             ELSE
     
    12521365
    12531366!--             Heating or cooling?
    1254                 IF ( theta_air > theta_int_c_set )  THEN
    1255                    theta_air_set = theta_int_c_set
     1367                IF ( theta_air > buildings(nb)%theta_int_c_set )  THEN
     1368                   theta_air_set = buildings(nb)%theta_int_c_set
    12561369                ELSE
    1257                    theta_air_set = theta_int_h_set
     1370                   theta_air_set = buildings(nb)%theta_int_h_set
    12581371                ENDIF
    12591372
     
    12741387!--             If necessary, limit the power to maximum power
    12751388!--             section C.4.1 Picture C.2 zone 2) and 4)
    1276                 IF ( phi_c_max < phi_hc_nd_un  .AND.  phi_hc_nd_un < phi_h_max )  THEN
     1389                IF ( buildings(nb)%phi_c_max < phi_hc_nd_un  .AND.  phi_hc_nd_un < buildings(nb)%phi_h_max )  THEN
    12771390                   phi_hc_nd_ac = phi_hc_nd_un
    12781391                   phi_hc_nd = phi_hc_nd_un
     
    12801393!--             Step 4: Inner temperature with maximum heating (phi_hc_nd_un positive) or cooling (phi_hc_nd_un negative)
    12811394!--             section C.4.1 Picture C.2 zone 1) and 5)
    1282                    IF ( phi_hc_nd_un > 0 )  THEN
    1283                       phi_hc_nd_ac = phi_h_max                                         !< Limit heating
     1395                   IF ( phi_hc_nd_un > 0.0_wp )  THEN
     1396                      phi_hc_nd_ac = buildings(nb)%phi_h_max                                         !< Limit heating
    12841397                   ELSE
    1285                       phi_hc_nd_ac = phi_c_max                                         !< Limit cooling
     1398                      phi_hc_nd_ac = buildings(nb)%phi_c_max                                         !< Limit cooling
    12861399                   ENDIF
    12871400                ENDIF
     
    13021415!--          Calculate the operating temperature with weighted mean of temperature of air and mean
    13031416!--          Will be used for thermal comfort calculations
    1304              theta_op     = 0.3 * theta_air_ac + 0.7 * theta_s
     1417             theta_op     = 0.3_wp * theta_air_ac + 0.7_wp * theta_s
    13051418!
    13061419!--          Heat flux into the wall. Value needed in urban_surface_mod to
     
    13221435!--          Calculation of waste heat
    13231436!--          Anthropogenic heat output
    1324               IF ( phi_hc_nd_ac > 0 )  THEN
    1325                    heating_on = 1
    1326                    cooling_on = 0
    1327               ELSE
    1328                    heating_on = 0
    1329                    cooling_on = 1
    1330               ENDIF
    1331 
    1332              q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on))   !< [W/m2] , anthropogenic heat output
    1333 !              surf_usm_v(l)%waste_heat(m)=q_waste_heat
    1334              
     1437             IF ( phi_hc_nd_ac > 0.0_wp )  THEN
     1438                heating_on = 1
     1439                cooling_on = 0
     1440             ELSE
     1441                heating_on = 0
     1442                cooling_on = 1
     1443             ENDIF
     1444
     1445             q_waste_heat = (phi_hc_nd * (params_waste_heat_h * heating_on + params_waste_heat_c * cooling_on))!< [W/GebÀudemodell] , observe the directional convention in PALM!
     1446             surf_usm_v(l)%waste_heat(m) = q_waste_heat
     1447
    13351448          ENDDO !< Vertical surfaces loop
    13361449
     
    13391452
    13401453!
    1341 !-- Determine total number of facade elements per building and assign number to
    1342 !-- building data type.
     1454!-- Determine the mean building temperature.
    13431455    DO  nb = 1, num_build
    13441456!
     
    13831495 END SUBROUTINE im_main_heatcool
    13841496
     1497!-----------------------------------------------------------------------------!
     1498! Description:
     1499!-------------
     1500!> Check data output for plant canopy model
     1501!-----------------------------------------------------------------------------!
     1502 SUBROUTINE im_check_data_output( var, unit )
     1503       
     1504    IMPLICIT NONE
     1505   
     1506    CHARACTER (LEN=*) ::  unit   !<
     1507    CHARACTER (LEN=*) ::  var    !<
     1508       
     1509    SELECT CASE ( TRIM( var ) )
     1510   
     1511   
     1512        CASE ( 'im_hf_roof')
     1513           unit = 'W m-2'
     1514       
     1515        CASE ( 'im_hf_wall_win' )
     1516           unit = 'W m-2'
     1517           
     1518        CASE ( 'im_hf_wall_win_waste' )
     1519           unit = 'W m-2'
     1520           
     1521        CASE ( 'im_hf_roof_waste' )
     1522           unit = 'W m-2'
     1523       
     1524        CASE ( 'im_t_indoor' )
     1525           unit = 'K'
     1526       
     1527        CASE DEFAULT
     1528           unit = 'illegal'
     1529           
     1530    END SELECT
     1531   
     1532 END SUBROUTINE
     1533
     1534
     1535!-----------------------------------------------------------------------------!
     1536! Description:
     1537!-------------
     1538!> Check parameters routine for plant canopy model
     1539!-----------------------------------------------------------------------------!
     1540 SUBROUTINE im_check_parameters
     1541
     1542!!!!   USE control_parameters,
     1543!!!!       ONLY: message_string
     1544       
     1545   IMPLICIT NONE
     1546   
     1547 END SUBROUTINE im_check_parameters
     1548
     1549!-----------------------------------------------------------------------------!
     1550! Description:
     1551!-------------
     1552!> Subroutine defining appropriate grid for netcdf variables.
     1553!> It is called from subroutine netcdf.
     1554!-----------------------------------------------------------------------------!
     1555 SUBROUTINE im_define_netcdf_grid( var, found, grid_x, grid_y, grid_z )
     1556
     1557   IMPLICIT NONE
     1558   
     1559   CHARACTER (LEN=*), INTENT(IN)  ::  var
     1560   LOGICAL, INTENT(OUT)           ::  found
     1561   CHARACTER (LEN=*), INTENT(OUT) ::  grid_x
     1562   CHARACTER (LEN=*), INTENT(OUT) ::  grid_y
     1563   CHARACTER (LEN=*), INTENT(OUT) ::  grid_z
     1564   
     1565   found   = .TRUE.
     1566   
     1567!
     1568!-- Check for the grid
     1569    SELECT CASE ( TRIM( var ) )
     1570
     1571       CASE ( 'im_hf_roof', 'im_hf_roof_waste' )
     1572          grid_x = 'x'
     1573          grid_y = 'y'
     1574          grid_z = 'zw'
     1575!
     1576!--    Heat fluxes at vertical walls are actually defined on stagged grid, i.e. xu, yv.
     1577       CASE ( 'im_hf_wall_win', 'im_hf_wall_win_waste' )
     1578          grid_x = 'x'
     1579          grid_y = 'y'
     1580          grid_z = 'zu'
     1581         
     1582       CASE ( 'im_t_indoor' )
     1583          grid_x = 'x'
     1584          grid_y = 'y'
     1585          grid_z = 'zw'
     1586         
     1587       CASE DEFAULT
     1588          found  = .FALSE.
     1589          grid_x = 'none'
     1590          grid_y = 'none'
     1591          grid_z = 'none'
     1592    END SELECT
     1593   
     1594 END SUBROUTINE im_define_netcdf_grid
     1595
     1596!------------------------------------------------------------------------------!
     1597! Description:
     1598! ------------
     1599!> Subroutine defining 3D output variables
     1600!------------------------------------------------------------------------------!
     1601 SUBROUTINE im_data_output_3d( av, variable, found, local_pf, fill_value,      &
     1602                               nzb_do, nzt_do )
     1603
     1604   USE indices
     1605   
     1606   USE kinds
     1607         
     1608   IMPLICIT NONE
     1609   
     1610    CHARACTER (LEN=*) ::  variable !<
     1611
     1612    INTEGER(iwp) ::  av    !<
     1613    INTEGER(iwp) ::  i     !<
     1614    INTEGER(iwp) ::  j     !<
     1615    INTEGER(iwp) ::  k     !<
     1616    INTEGER(iwp) ::  l     !<
     1617    INTEGER(iwp) ::  m     !<
     1618    INTEGER(iwp) ::  nb    !< index of the building in the building data structure
     1619    INTEGER(iwp) ::  nzb_do !< lower limit of the data output (usually 0)
     1620    INTEGER(iwp) ::  nzt_do !< vertical upper limit of the data output (usually nz_do3d)
     1621
     1622   
     1623    LOGICAL      ::  found !<
     1624
     1625    REAL(wp), INTENT(IN) ::  fill_value !< value for the _FillValue attribute
     1626
     1627    REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do) ::  local_pf !<
     1628   
     1629    local_pf = fill_value
     1630   
     1631    found = .TRUE.
     1632   
     1633    SELECT CASE ( TRIM( variable ) )
     1634!
     1635!--     Output of indoor temperature. All grid points within the building are
     1636!--     filled with values, while atmospheric grid points are set to _FillValues.
     1637        CASE ( 'im_t_indoor' )
     1638           IF ( av == 0 ) THEN
     1639              DO  i = nxl, nxr
     1640                 DO  j = nys, nyn
     1641                    IF ( building_id_f%var(j,i) /= building_id_f%fill )  THEN
     1642!
     1643!--                    Determine index of the building within the building data structure.
     1644                       nb = MINLOC( ABS( buildings(:)%id - building_id_f%var(j,i) ),   &
     1645                                    DIM = 1 )
     1646!
     1647!--                    Write mean building temperature onto output array. Please note,
     1648!--                    in contrast to many other loops in the output, the vertical
     1649!--                    bounds are determined by the lowest and hightest vertical index
     1650!--                    occupied by the building.
     1651                       DO  k = buildings(nb)%kb_min, buildings(nb)%kb_max
     1652                          local_pf(i,j,k) = buildings(nb)%t_in(k)
     1653                       ENDDO
     1654                    ENDIF
     1655                 ENDDO
     1656              ENDDO
     1657           ENDIF 
     1658
     1659        CASE ( 'im_hf_roof' )
     1660           IF ( av == 0 ) THEN
     1661              DO  m = 1, surf_usm_h%ns
     1662                  i = surf_usm_h%i(m) !+ surf_usm_h%ioff
     1663                  j = surf_usm_h%j(m) !+ surf_usm_h%joff
     1664                  k = surf_usm_h%k(m) !+ surf_usm_h%koff
     1665                  local_pf(i,j,k) = surf_usm_h%iwghf_eb(m)
     1666              ENDDO
     1667           ENDIF
     1668   
     1669        CASE ( 'im_hf_roof_waste' )
     1670           IF ( av == 0 ) THEN
     1671              DO m = 1, surf_usm_h%ns
     1672                 i = surf_usm_h%i(m) !+ surf_usm_h%ioff
     1673                 j = surf_usm_h%j(m) !+ surf_usm_h%joff
     1674                 k = surf_usm_h%k(m) !+ surf_usm_h%koff
     1675                 local_pf(i,j,k) = surf_usm_h%waste_heat(m)
     1676              ENDDO
     1677           ENDIF                     
     1678       
     1679       CASE ( 'im_hf_wall_win' )
     1680           IF ( av == 0 ) THEN
     1681              DO l = 0, 3
     1682                 DO m = 1, surf_usm_v(l)%ns
     1683                    i = surf_usm_v(l)%i(m) !+ surf_usm_v(l)%ioff
     1684                    j = surf_usm_v(l)%j(m) !+ surf_usm_v(l)%joff
     1685                    k = surf_usm_v(l)%k(m) !+ surf_usm_v(l)%koff
     1686                    local_pf(i,j,k) = surf_usm_v(l)%iwghf_eb(m)
     1687                 ENDDO
     1688              ENDDO
     1689           ENDIF
     1690           
     1691        CASE ( 'im_hf_wall_win_waste' )
     1692           IF ( av == 0 ) THEN
     1693              DO l = 0, 3
     1694                 DO m = 1, surf_usm_v(l)%ns
     1695                    i = surf_usm_v(l)%i(m) !+ surf_usm_v(l)%ioff
     1696                    j = surf_usm_v(l)%j(m) !+ surf_usm_v(l)%joff
     1697                    k = surf_usm_v(l)%k(m) !+ surf_usm_v(l)%koff
     1698                    local_pf(i,j,k) =  surf_usm_v(l)%waste_heat(m)
     1699                 ENDDO
     1700              ENDDO
     1701           ENDIF     
     1702   
     1703        CASE DEFAULT
     1704           found = .FALSE.
     1705           
     1706    END SELECT   
     1707
     1708 END SUBROUTINE im_data_output_3d         
    13851709!------------------------------------------------------------------------------!
    13861710! Description:
     
    13971721    CHARACTER (LEN=80) ::  line  !< string containing current line of file PARIN
    13981722
    1399    
    1400    
    1401     NAMELIST /indoor_parameters/  building_type, dt_indoor,                           &
    1402                                   initial_indoor_temperature
    1403 
    1404 !    line = ' '
     1723    NAMELIST /indoor_parameters/  dt_indoor, initial_indoor_temperature
    14051724
    14061725!
     
    14101729    DO   WHILE ( INDEX( line, '&indoor_parameters' ) == 0 )
    14111730       READ ( 11, '(A)', END=10 )  line
    1412 !    PRINT*, 'line: ', line
    14131731    ENDDO
    14141732    BACKSPACE ( 11 )
  • palm/trunk/SOURCE/module_interface.f90

    r3739 r3744  
    2020! Current revisions:
    2121! -----------------
    22 !
     22! Add indoor model
    2323!
    2424! Former revisions:
     
    174174   USE indoor_model_mod,                                                       &
    175175       ONLY:  im_parin,                                                        &
     176              im_check_data_output,                                            &
     177              im_check_parameters,                                             &
     178              im_data_output_3d,                                               &
    176179              im_init
    177180
     
    497500   IF ( air_chemistry )        CALL chem_check_parameters
    498501   IF ( gust_module_enabled )  CALL gust_check_parameters
     502   IF ( indoor_model )         CALL im_check_parameters
    499503   IF ( land_surface )         CALL lsm_check_parameters
    500504   IF ( large_scale_forcing  .OR.  nudging )  CALL lsf_nudging_check_parameters ! ToDo: create single module switch
     
    647651   ENDIF
    648652
     653   IF ( unit == 'illegal' .AND. indoor_model ) THEN
     654       CALL im_check_data_output( variable, unit )
     655   ENDIF
     656   
    649657   IF ( unit == 'illegal'  .AND.  urban_surface                      &
    650658        .AND.  variable(1:4) == 'usm_' )  THEN  ! ToDo: remove aditional conditions
     
    10221030   IF ( .NOT. found  .AND.  gust_module_enabled )  THEN
    10231031      CALL gust_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do )
     1032      resorted = .TRUE.
     1033   ENDIF
     1034   
     1035   IF ( .NOT. found  .AND.  indoor_model )  THEN
     1036      CALL im_data_output_3d( av, variable, found, local_pf, fill_value, nzb_do, nzt_do )
    10241037      resorted = .TRUE.
    10251038   ENDIF
  • palm/trunk/SOURCE/netcdf_data_input_mod.f90

    r3737 r3744  
    2020! Current revisions:
    2121! -----------------
    22 !
    2322!
    2423! Former revisions:
  • palm/trunk/SOURCE/netcdf_interface_mod.f90

    r3729 r3744  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Add indoor model
    2323!
    2424! Former revisions:
     
    660660               do2d_yz_time_count, dt_data_output_av, dt_do2d_xy, dt_do2d_xz,  &
    661661               dt_do2d_yz, dt_do3d, dt_write_agent_data, mask_size,            &
    662                do2d_xy_time_count,                                             &
    663                do3d_time_count, domask_time_count, end_time, land_surface,     &
     662               do2d_xy_time_count, do3d_time_count, domask_time_count,         &
     663               end_time, indoor_model, land_surface,                           &
    664664               mask_size_l, mask_i, mask_i_global, mask_j, mask_j_global,      &
    665665               mask_k_global, mask_surface,                                    &
     
    683683    USE kinds
    684684
     685    USE indoor_model_mod,                                                      &
     686        ONLY: im_define_netcdf_grid
     687   
    685688    USE land_surface_model_mod,                                                &
    686689        ONLY: lsm_define_netcdf_grid, nzb_soil, nzt_soil, nzs, zs
     
    19111914                      CALL gust_define_netcdf_grid( do3d(av,i), found, grid_x, &
    19121915                                                    grid_y, grid_z )
     1916                   ENDIF
     1917!
     1918!--                Check for indoor model quantities                   
     1919                   IF ( .NOT. found .AND. indoor_model ) THEN
     1920                      CALL im_define_netcdf_grid( do3d(av,i), found,           &
     1921                                                  grid_x, grid_x, grid_z )
    19131922                   ENDIF
    19141923
  • palm/trunk/SOURCE/plant_canopy_model_mod.f90

    r3685 r3744  
    2222! Current revisions:
    2323! ------------------
    24 !
     24! Bugfix in transpiration, floating invalid when temperature
     25! becomes > 40 degrees
    2526!
    2627! Former revisions:
     
    236237!> 2) Calculation of sinks and sources of momentum, heat and scalar concentration
    237238!> due to canopy elements (subroutine pcm_tendency).
     239!
     240! @todo - precalculate constant terms in pcm_calc_transpiration_rate
    238241!------------------------------------------------------------------------------!
    239242 MODULE plant_canopy_model_mod
     
    422425     sat_press_d = sat_press * 17.27_wp * 237.3_wp / (temp + 237.3_wp)**2
    423426!--  Wind speed
    424      wind_speed = SQRT( ((u(k,j,i) + u(k,j,i+1))/2.0_wp )**2 +           &
    425                         ((v(k,j,i) + v(k,j,i+1))/2.0_wp )**2 +           &
    426                         ((w(k,j,i) + w(k,j,i+1))/2.0_wp )**2 )
     427     wind_speed = SQRT( ( 0.5_wp * ( u(k,j,i) + u(k,j,i+1) ) )**2 +            &
     428                        ( 0.5_wp * ( v(k,j,i) + v(k,j,i+1) ) )**2 +            &
     429                        ( 0.5_wp * ( w(k,j,i) + w(k,j,i+1) ) )**2 )
    427430!--  Aerodynamic conductivity (Daudet et al. (1999) eq. 14
    428431     g_b = 0.01_wp * wind_speed + 0.0071_wp
     
    434437!--  Second function for calculation of stomatal conductivity (temperature dependency)
    435438!--  Stewart (1988; Agric. and Forest. Meteorol. 43) eq. 21
    436      f2 = MAX(t2_min, (temp-t2_min) * (t2_max-temp)**((t2_max-16.9_wp)/(16.9_wp-t2_min)) / &
     439     f2 = MAX(t2_min, (temp-t2_min) * MAX(0.0_wp,t2_max-temp)**((t2_max-16.9_wp)/(16.9_wp-t2_min)) / &
    437440              ((16.9_wp-t2_min) * (t2_max-16.9_wp)**((t2_max-16.9_wp)/(16.9_wp-t2_min))) )
    438441!--  Water pressure deficit
  • palm/trunk/SOURCE/surface_data_output_mod.f90

    r3736 r3744  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Output of waste_heat and innermost wall flux from indoor model
    2323!
    2424! Former revisions:
     
    2828! clean-up coding layout
    2929!
    30 ! 3735 2019-02-12 09:52:40Z dom_dwd_user
     30! 3735 2019-02-12 09:52:40Z suehring
    3131! - Split initialization into initialization of arrays and further initialization
    3232!   in order to enable reading of restart data.
     
    7676! Authors:
    7777! --------
    78 ! @author Klaus Ketelsen, Matthias Suehring
     78! @author Klaus Ketelsen, Matthias Suehring, Tobias Gronemeier
    7979!
    8080! Description:
     
    27782778
    27792779               ENDIF
    2780 
     2780               
    27812781            CASE ( 'uvw1' )
    27822782!
     
    28072807
    28082808               ENDIF
    2809 
     2809!
     2810!--         Waste heat from indoor model
     2811            CASE ( 'waste_heat' )
     2812!
     2813!--            Output of instantaneous data
     2814               IF ( av == 0 )  THEN
     2815                  CALL surface_data_output_collect( surf_def_h(0)%waste_heat,  &
     2816                                               surf_def_h(1)%waste_heat,       &
     2817                                               surf_lsm_h%waste_heat,          &
     2818                                               surf_usm_h%waste_heat,          &
     2819                                               surf_def_v(0)%waste_heat,       &
     2820                                               surf_lsm_v(0)%waste_heat,       &
     2821                                               surf_usm_v(0)%waste_heat,       &
     2822                                               surf_def_v(1)%waste_heat,       &
     2823                                               surf_lsm_v(1)%waste_heat,       &
     2824                                               surf_usm_v(1)%waste_heat,       &
     2825                                               surf_def_v(2)%waste_heat,       &
     2826                                               surf_lsm_v(2)%waste_heat,       &
     2827                                               surf_usm_v(2)%waste_heat,       &
     2828                                               surf_def_v(3)%waste_heat,       &
     2829                                               surf_lsm_v(3)%waste_heat,       &
     2830                                               surf_usm_v(3)%waste_heat )
     2831               ELSE
     2832!
     2833!--               Output of averaged data
     2834                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     2835                                        REAL( average_count_surf, KIND=wp )
     2836                  surfaces%var_av(:,n_out) = 0.0_wp
     2837
     2838               ENDIF
     2839!
     2840!--         Innermost building wall flux from indoor model
     2841            CASE ( 'im_hf' )
     2842!
     2843!--            Output of instantaneous data
     2844               IF ( av == 0 )  THEN
     2845                  CALL surface_data_output_collect( surf_def_h(0)%iwghf_eb,    &
     2846                                               surf_def_h(1)%iwghf_eb,         &
     2847                                               surf_lsm_h%iwghf_eb,            &
     2848                                               surf_usm_h%iwghf_eb,            &
     2849                                               surf_def_v(0)%iwghf_eb,         &
     2850                                               surf_lsm_v(0)%iwghf_eb,         &
     2851                                               surf_usm_v(0)%iwghf_eb,         &
     2852                                               surf_def_v(1)%iwghf_eb,         &
     2853                                               surf_lsm_v(1)%iwghf_eb,         &
     2854                                               surf_usm_v(1)%iwghf_eb,         &
     2855                                               surf_def_v(2)%iwghf_eb,         &
     2856                                               surf_lsm_v(2)%iwghf_eb,         &
     2857                                               surf_usm_v(2)%iwghf_eb,         &
     2858                                               surf_def_v(3)%iwghf_eb,         &
     2859                                               surf_lsm_v(3)%iwghf_eb,         &
     2860                                               surf_usm_v(3)%iwghf_eb )
     2861               ELSE
     2862!
     2863!--               Output of averaged data
     2864                  surfaces%var_out(:) = surfaces%var_av(:,n_out) /             &
     2865                                        REAL( average_count_surf, KIND=wp )
     2866                  surfaces%var_av(:,n_out) = 0.0_wp
     2867
     2868               ENDIF
    28102869!
    28112870!--            Add further variables:
     
    37063765                                           surf_lsm_v(3)%uvw_abs,              &
    37073766                                           surf_usm_v(3)%uvw_abs, n_out )
     3767                                           
     3768            CASE ( 'waste_heat' )
     3769               CALL surface_data_output_sum_up( surf_def_h(0)%waste_heat,      &
     3770                                           surf_def_h(1)%waste_heat,           &
     3771                                           surf_lsm_h%waste_heat,              &
     3772                                           surf_usm_h%waste_heat,              &
     3773                                           surf_def_v(0)%waste_heat,           &
     3774                                           surf_lsm_v(0)%waste_heat,           &
     3775                                           surf_usm_v(0)%waste_heat,           &
     3776                                           surf_def_v(1)%waste_heat,           &
     3777                                           surf_lsm_v(1)%waste_heat,           &
     3778                                           surf_usm_v(1)%waste_heat,           &
     3779                                           surf_def_v(2)%waste_heat,           &
     3780                                           surf_lsm_v(2)%waste_heat,           &
     3781                                           surf_usm_v(2)%waste_heat,           &
     3782                                           surf_def_v(3)%waste_heat,           &
     3783                                           surf_lsm_v(3)%waste_heat,           &
     3784                                           surf_usm_v(3)%waste_heat, n_out )
     3785                                           
     3786            CASE ( 'im_hf' )
     3787               CALL surface_data_output_sum_up( surf_def_h(0)%iwghf_eb,        &
     3788                                           surf_def_h(1)%iwghf_eb,             &
     3789                                           surf_lsm_h%iwghf_eb,                &
     3790                                           surf_usm_h%iwghf_eb,                &
     3791                                           surf_def_v(0)%iwghf_eb,             &
     3792                                           surf_lsm_v(0)%iwghf_eb,             &
     3793                                           surf_usm_v(0)%iwghf_eb,             &
     3794                                           surf_def_v(1)%iwghf_eb,             &
     3795                                           surf_lsm_v(1)%iwghf_eb,             &
     3796                                           surf_usm_v(1)%iwghf_eb,             &
     3797                                           surf_def_v(2)%iwghf_eb,             &
     3798                                           surf_lsm_v(2)%iwghf_eb,             &
     3799                                           surf_usm_v(2)%iwghf_eb,             &
     3800                                           surf_def_v(3)%iwghf_eb,             &
     3801                                           surf_lsm_v(3)%iwghf_eb,             &
     3802                                           surf_usm_v(3)%iwghf_eb, n_out )
    37083803
    37093804         END SELECT
     
    41614256
    41624257       USE control_parameters,                                                 &
    4163            ONLY:  averaging_interval, dt_data_output, initializing_actions,    &
    4164                   message_string
     4258           ONLY:  averaging_interval, dt_data_output, indoor_model,            &
     4259                  initializing_actions, message_string
    41654260
    41664261       USE pegrid,                                                             &
     
    42934388            CASE ( 'r_a', 'r_canopy', 'r_soil', 'r_s' )
    42944389               unit = 's/m'
     4390               
     4391            CASE ( 'waste_heat', 'im_hf' )
     4392               IF ( .NOT. indoor_model )  THEN
     4393                  message_string = TRIM( trimvar ) //                          &
     4394                             ' requires the indoor model'
     4395               CALL message( 'surface_data_output_check_parameters',           &
     4396                             'PA0588', 1, 2, 0, 6, 0 )
     4397               ENDIF
     4398           
     4399               unit = 'W/m2'
    42954400
    42964401            CASE DEFAULT
  • palm/trunk/SOURCE/surface_layer_fluxes_mod.f90

    r3685 r3744  
    2121! Current revisions:
    2222! ------------------
    23 !
     23! Bugfix, missing calculation of 10cm temperature at vertical building walls,
     24! required for indoor model
    2425!
    2526! Former revisions:
     
    443444             CALL calc_pt_near_surface ( '2m' )
    444445          ENDIF
    445           IF ( indoor_model )  THEN
    446              CALL calc_pt_near_surface ( '10cm' )
    447           ENDIF
     446!
     447!--       Calculate 10cm temperature, required in indoor model
     448          IF ( indoor_model )  CALL calc_pt_near_surface ( '10cm' )
    448449       ENDIF
    449450
     
    548549!--          Compute respective surface fluxes for momentum and TKE
    549550             CALL calc_surface_fluxes
     551!
     552!--          Calculate 10cm temperature, required in indoor model
     553             IF ( indoor_model )  CALL calc_pt_near_surface ( '10cm' )
    550554          ENDIF
    551555       ENDDO
     
    566570!--          Compute respective surface fluxes for momentum and TKE
    567571             CALL calc_surface_fluxes
     572             
    568573          ENDIF
    569574       ENDDO
     
    625630!--          Compute respective surface fluxes for momentum and TKE
    626631             CALL calc_surface_fluxes
     632!
     633!--          Calculate 10cm temperature, required in indoor model             
     634             IF ( indoor_model )  CALL calc_pt_near_surface ( '10cm' )
    627635          ENDIF
    628636       ENDDO
     
    20202028                k = surf%k(m)
    20212029
    2022                 surf%pt_10cm(m) = surf%pt_surface(m) + surf%ts(m) / kappa  &
    2023                                    * ( log( 0.1_wp /  surf%z0h(m) )                    &
    2024                                   - psi_h( 0.1_wp / surf%ol(m) )                    &
     2030                surf%pt_10cm(m) = surf%pt_surface(m) + surf%ts(m) / kappa      &
     2031                                   * ( LOG( 0.1_wp /  surf%z0h(m) )            &
     2032                                  - psi_h( 0.1_wp / surf%ol(m) )               &
    20252033                                     + psi_h( surf%z0h(m) / surf%ol(m) ) )
    2026 
     2034                                   
    20272035             ENDDO
    20282036
     
    20362044                k = surf%k(m)
    20372045
    2038                 surf%pt_2m(m) = surf%pt_surface(m) + surf%ts(m) / kappa  &
    2039                                    * ( log( 2.0_wp /  surf%z0h(m) )                    &
    2040                                      - psi_h( 2.0_wp / surf%ol(m) )                    &
     2046                surf%pt_2m(m) = surf%pt_surface(m) + surf%ts(m) / kappa        &
     2047                                   * ( LOG( 2.0_wp /  surf%z0h(m) )            &
     2048                                     - psi_h( 2.0_wp / surf%ol(m) )            &
    20412049                                     + psi_h( surf%z0h(m) / surf%ol(m) ) )
    20422050
  • palm/trunk/SOURCE/surface_mod.f90

    r3655 r3744  
    2121! Current revisions:
    2222! ------------------
    23 !
     23! +waste_heat
    2424!
    2525! Former revisions:
     
    455455       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  rho_c_total       !< volumetric heat capacity of the actual soil matrix (J/m3/K)
    456456       REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  root_fr           !< root fraction within the soil layers
     457       
     458!--    Indoor model variables
     459       REAL(wp), DIMENSION(:), ALLOCATABLE ::  waste_heat          !< waste heat
    457460!
    458461!--    Urban surface variables
     
    12431246!--    Characteristic temperature and surface flux of sensible heat
    12441247       DEALLOCATE ( surfaces%ts )   
    1245        DEALLOCATE ( surfaces%shf )   
     1248       DEALLOCATE ( surfaces%shf )
    12461249!
    12471250!--    surface temperature
     
    13711374!--    Characteristic temperature and surface flux of sensible heat
    13721375       ALLOCATE ( surfaces%ts(1:surfaces%ns)  )   
    1373        ALLOCATE ( surfaces%shf(1:surfaces%ns) )   
     1376       ALLOCATE ( surfaces%shf(1:surfaces%ns) )
    13741377!
    13751378!--    Surface temperature
     
    15371540!
    15381541!--    Sensible heat flux
    1539        DEALLOCATE ( surfaces%shf )   
     1542       DEALLOCATE ( surfaces%shf )
    15401543!
    15411544!--    Latent heat flux
     
    16091612!
    16101613!--    Sensible heat flux
    1611        ALLOCATE ( surfaces%shf(1:surfaces%ns) )   
     1614       ALLOCATE ( surfaces%shf(1:surfaces%ns) )
    16121615!
    16131616!--    Latent heat flux
     
    36373640             CALL wrd_write_string( 'surf_h(' // dum // ')%sasws' )
    36383641             WRITE ( 14 )  surf_h(l)%sasws
    3639           ENDIF     
     3642          ENDIF
    36403643 
    36413644       ENDDO
     
    37813784             WRITE ( 14 )  surf_v(l)%mom_flux_tke
    37823785          ENDIF
    3783 
     3786         
    37843787       ENDDO
    37853788
  • palm/trunk/SOURCE/time_integration.f90

    r3742 r3744  
    2020! Current revisions:
    2121! ------------------
    22 !
     22! Call indoor model after first timestep
    2323!
    2424! Former revisions:
     
    14131413!--    If required, calculate indoor temperature, waste heat, heat flux
    14141414!--    through wall, etc.
    1415 !--    dt_indoor steers the frequency of the indoor model calculations
     1415!--    dt_indoor steers the frequency of the indoor model calculations.
     1416!--    Note, at first timestep indoor model is called, in order to provide
     1417!--    a waste heat flux.
    14161418       IF ( indoor_model )  THEN
    14171419
    14181420          time_indoor = time_indoor + dt_3d
    14191421
    1420           IF ( time_indoor >= dt_indoor )  THEN
     1422          IF ( time_indoor >= dt_indoor  .OR.  current_timestep_number == 0 )  &
     1423          THEN
    14211424
    14221425             time_indoor = time_indoor - dt_indoor
  • palm/trunk/SOURCE/urban_surface_mod.f90

    r3743 r3744  
    2323! Current revisions:
    2424! ------------------
    25 !
     25! - Remove internal flag indoor_model (is a global control parameter)
     26! - add waste heat from buildings to the kinmatic heat flux
     27! - consider waste heat in restart data
     28! - remove unused USE statements
    2629!
    2730! Former revisions:
     
    401404!> @todo Output of _av variables in case of restarts
    402405!> @todo Revise flux conversion in energy-balance solver
    403 !> @todo Bugfixing in nopointer branch
    404406!> @todo Check optimizations for RMA operations
    405407!> @todo Alternatives for MPI_WIN_ALLOCATE? (causes problems with openmpi)
    406408!> @todo Check for load imbalances in CPU measures, e.g. for exchange_horiz_prog
    407409!>       factor 3 between min and max time
    408 !> @todo Move setting of flag indoor_model to indoor_model_mod once available
    409410!> @todo Check divisions in wtend (etc.) calculations for possible division
    410411!>       by zero, e.g. in case fraq(0,m) + fraq(1,m) = 0?!
     
    424425
    425426    USE control_parameters,                                                    &
    426         ONLY:  coupling_start_time, topography, dt_3d, humidity,               &
     427        ONLY:  coupling_start_time, topography, dt_3d, humidity, indoor_model, &
    427428               intermediate_timestep_count, initializing_actions,              &
    428429               intermediate_timestep_count_max, simulated_time, end_time,      &
     
    431432               pt_surface, large_scale_forcing, lsf_surf, spinup,              &
    432433               spinup_pt_mean, spinup_time, time_do3d, dt_do3d,                &
    433                average_count_3d, varnamelength, urban_surface,                 &
    434                plant_canopy, dz
     434               average_count_3d, varnamelength, urban_surface, dz
    435435
    436436    USE bulk_cloud_model_mod,                                                  &
     
    455455             
    456456    USE pegrid
    457    
    458     USE plant_canopy_model_mod,                                                &
    459         ONLY:  pc_heating_rate, pc_transpiration_rate, pc_latent_rate
    460    
     457       
    461458    USE radiation_model_mod,                                                   &
    462459        ONLY:  albedo_type, radiation_interaction, calc_zenith, zenith,        &
     
    535532                                                   !< (e.g.transportation) are used
    536533    LOGICAL ::  force_radiation_call_l = .FALSE.   !< flag parameter for unscheduled radiation model calls
    537     LOGICAL ::  indoor_model = .FALSE.             !< whether to use the indoor model
    538534    LOGICAL ::  read_wall_temp_3d = .FALSE.
    539535    LOGICAL ::  usm_wall_mod = .FALSE.             !< reduces conductivity of the first 2 wall layers by factor 0.1
     
    12571253           ALLOCATE ( surf_usm_v(l)%target_temp_summer(1:surf_usm_v(l)%ns) )
    12581254           ALLOCATE ( surf_usm_v(l)%target_temp_winter(1:surf_usm_v(l)%ns) )
    1259         ENDDO   
     1255        ENDDO
     1256!
     1257!--     In case the indoor model is applied, allocate memory for waste heat
     1258!--     and indoor temperature.
     1259        IF ( indoor_model )  THEN
     1260           ALLOCATE ( surf_usm_h%waste_heat(1:surf_usm_h%ns) )
     1261           surf_usm_h%waste_heat = 0.0_wp
     1262           DO  l = 0, 3
     1263              ALLOCATE ( surf_usm_v(l)%waste_heat(1:surf_usm_v(l)%ns) )
     1264              surf_usm_v(l)%waste_heat = 0.0_wp
     1265           ENDDO
     1266        ENDIF
    12601267!
    12611268!--     Allocate flag indicating ground floor level surface elements
     
    60546061                           usm_material_model,                                 &
    60556062                           wall_category,                                      &
    6056                            indoor_model,                                       &
    60576063                           wall_inner_temperature,                             &
    60586064                           roof_inner_temperature,                             &
     
    60736079                           usm_material_model,                                 &
    60746080                           wall_category,                                      &
    6075                            indoor_model,                                       &
    60766081                           wall_inner_temperature,                             &
    60776082                           roof_inner_temperature,                             &
     
    62646269
    62656270       LOGICAL, INTENT(OUT)  ::  found
     6271!!!    suehring: Why the SAVE attribute?       
     6272       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_wall_h
     6273       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_window_h
     6274       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_green_h
     6275       REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_waste_h
    62666276       
    6267        REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE   ::  tmp_surf_wall_h, tmp_surf_window_h, tmp_surf_green_h
    6268        REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_wall_h, tmp_window_h, tmp_green_h
     6277       REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_wall_h
     6278       REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_window_h
     6279       REAL(wp), DIMENSION(:,:), ALLOCATABLE, SAVE ::  tmp_green_h
    62696280       
    6270        TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_wall_v, tmp_surf_window_v, tmp_surf_green_v
    6271        TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_wall_v, tmp_window_v, tmp_green_v
     6281       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_wall_v
     6282       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_window_v
     6283       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_green_v
     6284       TYPE( t_surf_vertical ), DIMENSION(0:3), SAVE ::  tmp_surf_waste_v
     6285       
     6286       TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_wall_v
     6287       TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_window_v
     6288       TYPE( t_wall_vertical ), DIMENSION(0:3), SAVE ::  tmp_green_v
    62726289
    62736290
     
    62896306                      DEALLOCATE( tmp_surf_green_h )
    62906307                   IF ( ALLOCATED( tmp_green_h) ) DEALLOCATE( tmp_green_h )
     6308                   IF ( ALLOCATED( tmp_surf_waste_h) )                         &
     6309                      DEALLOCATE( tmp_surf_waste_h )
    62916310 
    62926311!
     
    63056324                   ALLOCATE( tmp_green_h(nzb_wall:nzt_wall+1,                  &
    63066325                                         1:ns_h_on_file_usm) )
     6326                   ALLOCATE( tmp_surf_waste_h(1:ns_h_on_file_usm) )
    63076327
    63086328                ENDIF
     
    63256345                      IF ( ALLOCATED( tmp_green_v(l)%t ) )                     &
    63266346                         DEALLOCATE( tmp_green_v(l)%t )
     6347                      IF ( ALLOCATED( tmp_surf_waste_v(l)%t ) )                &
     6348                         DEALLOCATE( tmp_surf_waste_v(l)%t )
    63276349                   ENDDO
    63286350
     
    63436365                      ALLOCATE( tmp_green_v(l)%t(nzb_wall:nzt_wall+1,          &
    63446366                                                 1:ns_v_on_file_usm(l) ) )
     6367                      ALLOCATE( tmp_surf_waste_v(l)%t(1:ns_v_on_file_usm(l)) )
    63456368                   ENDDO
    63466369
     
    66146637                                        t_surf_window_v_1(3)%t,                & 
    66156638                                        tmp_surf_window_v(3)%t,                &
     6639                                        surf_usm_v(3)%start_index,             &
     6640                                        start_index_on_file,                   &
     6641                                        end_index_on_file,                     &
     6642                                        nxlc, nysc,                            &
     6643                                        nxlf, nxrf, nysf, nynf,                &
     6644                                        nys_on_file, nyn_on_file,              &
     6645                                        nxl_on_file,nxr_on_file )
     6646
     6647             CASE ( 'waste_heat_h' )
     6648                IF ( k == 1 )  THEN
     6649                   IF ( .NOT.  ALLOCATED( surf_usm_h%waste_heat ) )            &
     6650                      ALLOCATE( surf_usm_h%waste_heat(1:surf_usm_h%ns) )
     6651                   READ ( 13 )  tmp_surf_waste_h
     6652                ENDIF             
     6653                CALL surface_restore_elements(                                 &
     6654                                        surf_usm_h%waste_heat,                 &
     6655                                        tmp_surf_waste_h,                      &
     6656                                        surf_usm_h%start_index,                &
     6657                                        start_index_on_file,                   &
     6658                                        end_index_on_file,                     &
     6659                                        nxlc, nysc,                            &
     6660                                        nxlf, nxrf, nysf, nynf,                &
     6661                                        nys_on_file, nyn_on_file,              &
     6662                                        nxl_on_file,nxr_on_file )                 
     6663                                       
     6664             CASE ( 'waste_heat_v(0)' )
     6665                IF ( k == 1 )  THEN
     6666                   IF ( .NOT.  ALLOCATED( surf_usm_v(0)%waste_heat ) )         &
     6667                      ALLOCATE( surf_usm_v(0)%waste_heat(1:surf_usm_v(0)%ns) )
     6668                   READ ( 13 )  tmp_surf_waste_v(0)%t
     6669                ENDIF
     6670                CALL surface_restore_elements(                                 &
     6671                                        surf_usm_v(0)%waste_heat,              &
     6672                                        tmp_surf_waste_v(0)%t,                 &
     6673                                        surf_usm_v(0)%start_index,             &
     6674                                        start_index_on_file,                   &
     6675                                        end_index_on_file,                     &
     6676                                        nxlc, nysc,                            &
     6677                                        nxlf, nxrf, nysf, nynf,                &
     6678                                        nys_on_file, nyn_on_file,              &
     6679                                        nxl_on_file,nxr_on_file )
     6680                     
     6681             CASE ( 'waste_heat_v(1)' )
     6682                IF ( k == 1 )  THEN
     6683                   IF ( .NOT.  ALLOCATED( surf_usm_v(1)%waste_heat ) )         &
     6684                      ALLOCATE( surf_usm_v(1)%waste_heat(1:surf_usm_v(1)%ns) )
     6685                   READ ( 13 )  tmp_surf_waste_v(1)%t
     6686                ENDIF
     6687                CALL surface_restore_elements(                                 &
     6688                                        surf_usm_v(1)%waste_heat,              &
     6689                                        tmp_surf_waste_v(1)%t,                 &
     6690                                        surf_usm_v(1)%start_index,             &
     6691                                        start_index_on_file,                   &
     6692                                        end_index_on_file,                     &
     6693                                        nxlc, nysc,                            &
     6694                                        nxlf, nxrf, nysf, nynf,                &
     6695                                        nys_on_file, nyn_on_file,              &
     6696                                        nxl_on_file,nxr_on_file )
     6697
     6698             CASE ( 'waste_heat_v(2)' )
     6699                IF ( k == 1 )  THEN
     6700                   IF ( .NOT.  ALLOCATED( surf_usm_v(2)%waste_heat ) )         &
     6701                      ALLOCATE( surf_usm_v(2)%waste_heat(1:surf_usm_v(2)%ns) )
     6702                   READ ( 13 )  tmp_surf_waste_v(2)%t
     6703                ENDIF
     6704                CALL surface_restore_elements(                                 &
     6705                                        surf_usm_v(2)%waste_heat,              &
     6706                                        tmp_surf_waste_v(2)%t,                 &
     6707                                        surf_usm_v(2)%start_index,             &
     6708                                        start_index_on_file,                   &
     6709                                        end_index_on_file,                     &
     6710                                        nxlc, nysc,                            &
     6711                                        nxlf, nxrf, nysf, nynf,                &
     6712                                        nys_on_file, nyn_on_file,              &
     6713                                        nxl_on_file,nxr_on_file )
     6714                     
     6715             CASE ( 'waste_heat_v(3)' )
     6716                IF ( k == 1 )  THEN
     6717                   IF ( .NOT.  ALLOCATED( surf_usm_v(3)%waste_heat ) )         &
     6718                      ALLOCATE( surf_usm_v(3)%waste_heat(1:surf_usm_v(3)%ns) )
     6719                   READ ( 13 )  tmp_surf_waste_v(3)%t
     6720                ENDIF
     6721                CALL surface_restore_elements(                                 &
     6722                                        surf_usm_v(3)%waste_heat,              &
     6723                                        tmp_surf_waste_v(3)%t,                 &
    66166724                                        surf_usm_v(3)%start_index,             &
    66176725                                        start_index_on_file,                   &
     
    76277735        j_off = surf_usm_h%joff
    76287736        i_off = surf_usm_h%ioff
    7629 
     7737       
    76307738!       
    76317739!--     First, treat horizontal surface elements
     
    79578065!--        diffusion_s, surface_layer_fluxes,...
    79588066           surf_usm_h%shf(m) = surf_usm_h%wshf_eb(m) / c_p
     8067!
     8068!--        If the indoor model is applied, further add waste heat from buildings to the
     8069!--        kinematic flux.
     8070           IF ( indoor_model )  THEN
     8071              surf_usm_h%shf(m) = surf_usm_h%shf(m) + surf_usm_h%waste_heat(m) / rho_cp
     8072           ENDIF
    79598073     
    79608074
     
    83828496!--           diffusion_s, surface_layer_fluxes,...
    83838497              surf_usm_v(l)%shf(m) = surf_usm_v(l)%wshf_eb(m) / c_p
     8498!
     8499!--           If the indoor model is applied, further add waste heat from buildings to the
     8500!--           kinematic flux.
     8501              IF ( indoor_model )  THEN
     8502                 surf_usm_v(l)%shf(m) = surf_usm_v(l)%shf(m) +                       &
     8503                                        surf_usm_v(l)%waste_heat(m) / rho_cp
     8504              ENDIF             
    83848505
    83858506              IF ( surf_usm_v(l)%frac(ind_pav_green,m) > 0.0_wp ) THEN
     
    86858806        CALL wrd_write_string( 't_surf_green_h' )
    86868807        WRITE ( 14 )  t_surf_green_h
    8687  
     8808!
     8809!--     Write restart data which is especially needed for the urban-surface
     8810!--     model. In order to do not fill up the restart routines in
     8811!--     surface_mod.
     8812!--     Output of waste heat from indoor model. Restart data is required in
     8813!--     this special case, because the indoor model where waste heat is
     8814!--     computed is call each hour (current default), so that waste heat would
     8815!--     have zero value until next call of indoor model.
     8816        IF ( indoor_model )  THEN
     8817           CALL wrd_write_string( 'waste_heat_h' )
     8818           WRITE ( 14 )  surf_usm_h%waste_heat
     8819        ENDIF   
     8820           
    86888821        DO  l = 0, 3
    86898822 
     
    87038836 
    87048837           CALL wrd_write_string( 't_surf_green_v(' // dum // ')' )
    8705            WRITE ( 14 ) t_surf_green_v(l)%t   
     8838           WRITE ( 14 ) t_surf_green_v(l)%t 
     8839           
     8840           IF ( indoor_model )  THEN
     8841              CALL wrd_write_string( 'waste_heat_v(' // dum // ')' )
     8842              WRITE ( 14 )  surf_usm_v(l)%waste_heat
     8843           ENDIF
    87068844           
    87078845        ENDDO
     
    87428880       
    87438881        ENDDO
    8744  
    87458882       
    87468883     END SUBROUTINE usm_wrd_local
Note: See TracChangeset for help on using the changeset viewer.