Index: /palm/trunk/SOURCE/biometeorology_mod.f90
===================================================================
--- /palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3734)
+++ /palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3735)
@@ -27,4 +27,10 @@
 ! -----------------
 ! $Id$
+! - Fixed auto-setting of thermal index calculation flags by output
+!  as originally proposed by resler.
+! - removed bio_pet and outher configuration variables.
+! - Updated namelist.
+! 
+! 3711 2019-01-31 13:44:26Z knoop
 ! Introduced interface routine bio_init_checks + small error message changes
 ! 
@@ -184,10 +190,10 @@
 
     LOGICAL ::  thermal_comfort = .FALSE.  !< Turn all thermal indices on or off
-    LOGICAL ::  bio_perct     = .TRUE.   !< Turn index PT (instant. input) on or off
-    LOGICAL ::  bio_perct_av  = .TRUE.   !< Turn index PT (averaged input) on or off
-    LOGICAL ::  bio_pet       = .TRUE.   !< Turn index PET (instant. input) on or off
-    LOGICAL ::  bio_pet_av    = .TRUE.   !< Turn index PET (averaged input) on or off
-    LOGICAL ::  bio_utci      = .TRUE.   !< Turn index UTCI (instant. input) on or off
-    LOGICAL ::  bio_utci_av   = .TRUE.   !< Turn index UTCI (averaged input) on or off
+    LOGICAL ::  bio_perct     = .FALSE.   !< Turn index PT (instant. input) on or off
+    LOGICAL ::  bio_perct_av  = .FALSE.   !< Turn index PT (averaged input) on or off
+    LOGICAL ::  bio_pet       = .FALSE.   !< Turn index PET (instant. input) on or off
+    LOGICAL ::  bio_pet_av    = .FALSE.   !< Turn index PET (averaged input) on or off
+    LOGICAL ::  bio_utci      = .FALSE.   !< Turn index UTCI (instant. input) on or off
+    LOGICAL ::  bio_utci_av   = .FALSE.   !< Turn index UTCI (averaged input) on or off
 
 !
@@ -248,6 +254,5 @@
     bio_check_parameters, bio_data_output_3d, bio_data_output_2d,              &
     bio_define_netcdf_grid, bio_get_thermal_index_input_ij, bio_header,        &
-    bio_init, bio_init_checks, bio_parin, bio_perct, bio_perct_av, bio_pet,    &
-    bio_pet_av, bio_utci, bio_utci_av, thermal_comfort, time_bio_results,      &
+    bio_init, bio_init_checks, bio_parin, thermal_comfort, time_bio_results,   &
     bio_nmrtbl, bio_wrd_local, bio_rrd_local, bio_wrd_global, bio_rrd_global
 !
@@ -678,5 +683,5 @@
 !> Check data output for biometeorology model
 !------------------------------------------------------------------------------!
- SUBROUTINE bio_check_data_output( var, unit, i, ilen, k )
+ SUBROUTINE bio_check_data_output( var, unit, i, j, ilen, k )
 
     USE control_parameters,                                                    &
@@ -689,4 +694,5 @@
 
     INTEGER(iwp) ::  i      !<
+    INTEGER(iwp), INTENT(IN)  :: j   !< average quantity? 0 = no, 1 = yes
     INTEGER(iwp) ::  ilen   !<   
     INTEGER(iwp) ::  k      !<
@@ -708,33 +714,48 @@
        CASE ( 'bio_perct*' )
           unit = 'degree_C'
-          IF ( .NOT. ALLOCATED( perct ) )  THEN
-             ALLOCATE( perct (nys:nyn,nxl:nxr) )
-             perct = REAL( bio_fill_value, KIND = wp )
-          ENDIF
-          IF ( .NOT. ALLOCATED( perct_av ) )  THEN
-             ALLOCATE( perct_av (nys:nyn,nxl:nxr) )
-             perct_av = REAL( bio_fill_value, KIND = wp )
+          IF ( j == 0 ) THEN                !< if instantaneous input
+             bio_perct = .TRUE.
+             IF ( .NOT. ALLOCATED( perct ) )  THEN
+                ALLOCATE( perct (nys:nyn,nxl:nxr) )
+                perct = REAL( bio_fill_value, KIND = wp )
+             ENDIF
+          ELSE                              !< if averaged input
+             bio_perct_av = .TRUE.
+             IF ( .NOT. ALLOCATED( perct_av ) )  THEN
+                ALLOCATE( perct_av (nys:nyn,nxl:nxr) )
+                perct_av = REAL( bio_fill_value, KIND = wp )
+             ENDIF
           ENDIF
 
        CASE ( 'bio_utci*' )
           unit = 'degree_C'
-          IF ( .NOT. ALLOCATED( utci ) )  THEN
-             ALLOCATE( utci (nys:nyn,nxl:nxr) )
-             utci = REAL( bio_fill_value, KIND = wp )
-          ENDIF
-          IF ( .NOT. ALLOCATED( utci_av ) )  THEN
-             ALLOCATE( utci_av (nys:nyn,nxl:nxr) )
-             utci_av = REAL( bio_fill_value, KIND = wp )
+          IF ( j == 0 ) THEN
+             bio_utci = .TRUE.
+             IF ( .NOT. ALLOCATED( utci ) )  THEN
+                ALLOCATE( utci (nys:nyn,nxl:nxr) )
+                utci = REAL( bio_fill_value, KIND = wp )
+             ENDIF
+          ELSE
+             bio_utci_av = .TRUE.
+             IF ( .NOT. ALLOCATED( utci_av ) )  THEN
+                ALLOCATE( utci_av (nys:nyn,nxl:nxr) )
+                utci_av = REAL( bio_fill_value, KIND = wp )
+             ENDIF
           ENDIF
 
        CASE ( 'bio_pet*' )
           unit = 'degree_C'
-          IF ( .NOT. ALLOCATED( pet ) )  THEN
-             ALLOCATE( pet (nys:nyn,nxl:nxr) )
-             pet = REAL( bio_fill_value, KIND = wp )
-          ENDIF
-          IF ( .NOT. ALLOCATED( pet_av ) )  THEN
-             ALLOCATE( pet_av (nys:nyn,nxl:nxr) )
-             pet_av = REAL( bio_fill_value, KIND = wp )
+          IF ( j == 0 ) THEN
+             bio_pet = .TRUE.
+             IF ( .NOT. ALLOCATED( pet ) )  THEN
+                ALLOCATE( pet (nys:nyn,nxl:nxr) )
+                pet = REAL( bio_fill_value, KIND = wp )
+             ENDIF
+          ELSE
+             bio_pet_av = .TRUE.
+             IF ( .NOT. ALLOCATED( pet_av ) )  THEN
+                ALLOCATE( pet_av (nys:nyn,nxl:nxr) )
+                pet_av = REAL( bio_fill_value, KIND = wp )
+             ENDIF
           ENDIF
 
@@ -1034,14 +1055,15 @@
                IF ( av == 0 )  THEN
                   IF ( mrt_include_sw )  THEN
-                     local_pf(i,j,k) = REAL(((human_absorb * mrtinsw(l) +      &
-                                    human_emiss * mrtinlw(l)) /                &
-                                    (human_emiss * sigma_sb)) ** .25_wp -      &
-                                    degc_to_k, kind=sp )
+                     local_pf(i,j,k) = REAL( ( ( human_absorb * mrtinsw(l) +   &
+                                    human_emiss * mrtinlw(l) ) /               &
+                                    ( human_emiss * sigma_sb ) ) ** .25_wp -   &
+                                    degc_to_k, KIND = sp )
                   ELSE
-                     local_pf(i,j,k) = REAL((human_emiss * mrtinlw(l) /        &
-                                    sigma_sb) ** .25_wp - degc_to_k, kind=sp )  !< why not (human_emiss * sigma_sb) as above?
+                     local_pf(i,j,k) = REAL( ( ( human_emiss * mrtinlw(l) ) /  &
+                                    ( human_emiss * sigma_sb ) ) ** .25_wp -   &
+                                    degc_to_k, KIND = sp )
                   ENDIF
                ELSE
-                  local_pf(i,j,k) = REAL(mrt_av_grid(l), kind=sp)
+                  local_pf(i,j,k) = REAL( mrt_av_grid(l), KIND = sp )
                ENDIF
             ENDDO
@@ -1168,5 +1190,5 @@
 !-- Init UVEM and load lookup tables
     IF ( uv_exposure )  CALL netcdf_data_input_uvem
-    
+
     CALL location_message( 'finished', .TRUE. )
 
@@ -1208,11 +1230,6 @@
     CHARACTER (LEN=80) ::  line  !< Dummy string for current line in parameter file 
 
-    NAMELIST /biometeorology_parameters/  bio_pet,                             &
-                                          bio_pet_av,                          &
-                                          bio_perct,                           &
-                                          bio_perct_av,                        &
-                                          bio_utci,                            &
-                                          bio_utci_av,                         &
-                                          thermal_comfort,                     &
+    NAMELIST /biometeorology_parameters/  thermal_comfort,                     &
+
 !
 !-- UVEM namelist parameters
@@ -1435,4 +1452,5 @@
           ALLOCATE( tmrt_av_grid (nys:nyn,nxl:nxr) )
        ENDIF
+       tmrt_av_grid = REAL( bio_fill_value, KIND = wp )
 
        DO  l = 1, nmrtbl
@@ -1463,13 +1481,15 @@
           j = mrtbl(iy,l)
           k = mrtbl(iz,l)
-          IF ( k - get_topography_top_index_ji( j, i, 's' ) == bio_cell_level +   &
-                1_iwp) THEN
+          IF ( k - get_topography_top_index_ji( j, i, 's' ) ==                 &
+                bio_cell_level + 1_iwp) THEN
              IF ( mrt_include_sw )  THEN
-                 tmrt_grid(j,i) = ((human_absorb*mrtinsw(l) +                     &
-                                   human_emiss*mrtinlw(l))  /                     &
-                                  (human_emiss*sigma_sb)) ** .25_wp - degc_to_k
+                 tmrt_grid(j,i) = ( ( human_absorb * mrtinsw(l) +              &
+                                  human_emiss * mrtinlw(l) )  /                &
+                                  ( human_emiss * sigma_sb ) ) ** .25_wp -     &
+                                  degc_to_k
              ELSE
-                 tmrt_grid(j,i) = (human_emiss*mrtinlw(l) / sigma_sb) ** .25_wp   &
-                                    - degc_to_k
+                 tmrt_grid(j,i) = ( ( human_emiss * mrtinlw(l) )  /            &
+                                  ( human_emiss * sigma_sb ) ) ** .25_wp -     &
+                                  degc_to_k
              ENDIF
           ENDIF
@@ -1617,5 +1637,5 @@
 !
 !--       Determine input only if 
-          CALL bio_get_thermal_index_input_ij ( av, i, j, ta, vp,           &
+          CALL bio_get_thermal_index_input_ij ( av, i, j, ta, vp,              &
                                                 ws, pair, tmrt_ij )
 !
@@ -1629,5 +1649,5 @@
              clo = bio_fill_value
 
-             IF ( bio_perct ) THEN
+             IF ( bio_perct .OR. bio_perct_av ) THEN
 !
 !--          Estimate local perceived temperature
@@ -1636,5 +1656,5 @@
              ENDIF
 
-             IF ( bio_utci ) THEN
+             IF ( bio_utci  .OR. bio_utci_av ) THEN
 !
 !--          Estimate local universal thermal climate index
@@ -1643,5 +1663,5 @@
              ENDIF
 
-             IF ( bio_pet ) THEN
+             IF ( bio_pet .OR. bio_pet_av ) THEN
 !
 !--          Estimate local physiologically equivalent temperature
Index: /palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- /palm/trunk/SOURCE/check_parameters.f90	(revision 3734)
+++ /palm/trunk/SOURCE/check_parameters.f90	(revision 3735)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Passing variable j (averaged output?) to 
+! module_interface.f90:chem_check_data_output.
+! 
+! 3705 2019-01-29 19:56:39Z suehring
 ! bugfix: renamed thetav_t to vtheta_t
 ! 
@@ -3141,5 +3145,5 @@
 !
 !--          Check for other modules
-             CALL module_interface_check_data_output( var, unit, i, ilen, k )
+             CALL module_interface_check_data_output( var, unit, i, j, ilen, k )
 
              IF ( unit == 'illegal' )  THEN
Index: /palm/trunk/SOURCE/module_interface.f90
===================================================================
--- /palm/trunk/SOURCE/module_interface.f90	(revision 3734)
+++ /palm/trunk/SOURCE/module_interface.f90	(revision 3735)
@@ -20,9 +20,14 @@
 ! Current revisions:
 ! -----------------
-! Add required restart data for surface output module
+! 
 ! 
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Accepting variable j from check_parameters and passing it to 
+! bio_check_data_output
+! Add required restart data for surface output module
+! 
+! 3731 2019-02-11 13:06:27Z suehring
 ! Add check_parameters routine for virtual measurements
 ! 
@@ -592,5 +597,5 @@
 !> Check module-specific 2D and 3D data output
 !------------------------------------------------------------------------------!
-SUBROUTINE module_interface_check_data_output( variable, unit, i, ilen, k )
+SUBROUTINE module_interface_check_data_output( variable, unit, i, j, ilen, k )
 
 
@@ -599,9 +604,10 @@
 
    INTEGER(iwp),      INTENT(IN)    :: i         !< ToDo: remove dummy argument, instead pass string from data_output
+   INTEGER(iwp),      INTENT(IN)    :: j         !< average quantity? 0 = no, 1 = yes
    INTEGER(iwp),      INTENT(IN)    :: ilen      !< ToDo: remove dummy argument, instead pass string from data_output
    INTEGER(iwp),      INTENT(IN)    :: k         !< ToDo: remove dummy argument, instead pass string from data_output
 
    IF ( unit == 'illegal'  .AND.  biometeorology )  THEN
-      CALL bio_check_data_output( variable, unit, i, ilen, k )
+      CALL bio_check_data_output( variable, unit, i, j, ilen, k )
    ENDIF
 
Index: /palm/trunk/SOURCE/surface_data_output_mod.f90
===================================================================
--- /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 3734)
+++ /palm/trunk/SOURCE/surface_data_output_mod.f90	(revision 3735)
@@ -20,4 +20,9 @@
 ! Current revisions:
 ! ------------------
+! 
+! 
+! Former revisions:
+! -----------------
+! $Id$
 ! - Split initialization into initialization of arrays and further initialization
 !   in order to enable reading of restart data.
@@ -25,7 +30,5 @@
 ! - Correct error message numbers
 ! 
-! Former revisions:
-! -----------------
-! $Id$
+! 3731 2019-02-11 13:06:27Z suehring
 ! Bugfix: add cpp options
 ! 
