Index: palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3274)
+++ palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 3448)
@@ -25,4 +25,8 @@
 ! -----------------
 ! $Id$
+! Adjustment of biometeorology calls,
+! implement some agent biometeorology
+! 
+! 3274 2018-09-24 15:42:55Z knoop
 ! Modularization of all bulk cloud physics code components
 ! 
@@ -84,5 +88,6 @@
 
     USE control_parameters,                                                    &
-        ONLY:  dt_3d, message_string, time_since_reference_point, dt_write_agent_data
+        ONLY:  biometeorology, dt_3d, dt_write_agent_data, message_string,     &
+               time_since_reference_point
 
     USE cpulog,                                                                &
@@ -206,4 +211,11 @@
         REAL(wp)     ::  clo                  !< clothing index
         REAL(wp)     ::  energy_storage       !< energy stored by agent
+        REAL(wp)     ::  clothing_temp        !< energy stored by agent
+        REAL(wp)     ::  actlev               !< metabolic + work energy of the person
+        REAL(wp)     ::  age_years            !< physical age of the person
+        REAL(wp)     ::  weight               !< total weight of the person (kg)
+        REAL(wp)     ::  height               !< height of the person (m)
+        REAL(wp)     ::  work                 !< workload of the agent (W)
+        INTEGER(iwp) ::  sex                  !< agents gender: 1 = male, 2 = female
         REAL(wp)     ::  force_x              !< force term x-direction
         REAL(wp)     ::  force_y              !< force term y-direction
@@ -218,5 +230,5 @@
         REAL(wp)     ::  speed_x              !< speed of agent in x
         REAL(wp)     ::  speed_y              !< speed of agent in y
-        REAL(wp)     ::  thermal_index        !< the dynamic thermal index
+        REAL(wp)     ::  ipt                  !< instationary thermal index iPT (Â°C)
         REAL(wp)     ::  windspeed            !< absolute value of windspeed at agent position
         REAL(wp)     ::  x                    !< x-position
@@ -329,6 +341,7 @@
  SUBROUTINE multi_agent_system
 
-!     USE htcm_mod,                                                              &
-!         ONLY:  htcm_dynamic
+    USE biometeorology_mod,                                                   &
+        ONLY:  biom_calc_ipt, biom_determine_input_at
+
 
     IMPLICIT NONE
@@ -341,4 +354,12 @@
     INTEGER(iwp)       ::  js                 !< counter
     INTEGER(iwp), SAVE ::  mas_count = 0      !< counts the mas-calls
+    INTEGER(iwp)                :: a     !< agent iterator
+    !-- local meteorological conditions
+    REAL(wp)                    :: tmrt  !< mean radiant temperature        (Â°C)
+    REAL(wp)                    :: ta    !< air temperature                 (Â°C)
+    REAL(wp)                    :: vp    !< vapour pressure                 (hPa)
+    REAL(wp)                    :: v     !< wind speed    (local level)     (m/s)
+    REAL(wp)                    :: pair  !< air pressure                    (hPa)
+
 
     LOGICAL       ::  first_loop_stride   !< flag for first loop stride of agent sub-timesteps
@@ -502,20 +523,45 @@
        deleted_agents = 0
 !
-!--    to be included here: call of human thermal comfort mod (and UV exposure)
-!        DO  i = nxl, nxr
-!           DO  j = nys, nyn
-! 
-!              number_of_agents = agt_count(j,i)
-! !
-! !--          If grid cell gets empty, cycle
-!              IF ( number_of_agents <= 0 ) CYCLE
-! 
-!              agents => grid_agents(j,i)%agents(1:number_of_agents)
-! !
-! !--          Evaluation of social forces
-!              CALL htcm_dynamic(i,j)
-! 
-!           ENDDO
-!        ENDDO
+       IF ( biometeorology )  THEN
+!
+!--       Call of human thermal comfort mod (and UV exposure)
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+
+                number_of_agents = agt_count(j,i)
+!
+!--             If grid cell gets empty, cycle
+                IF ( number_of_agents <= 0 )  CYCLE
+
+                agents => grid_agents(j,i)%agents(1:number_of_agents)
+!
+!--             Evaluation of social forces
+!                CALL biom_dynamic(i,j)
+!
+!--             Determine local meteorological conditions
+                CALL biom_determine_input_at ( .FALSE., i, j, ta, vp, v,      &
+                                               pair, tmrt )
+
+                DO  a = 1, number_of_agents
+!
+!--                Calculate instationary thermal indices based on local tmrt
+
+                   CALL biom_calc_ipt ( ta, vp, v, pair, tmrt,                &
+                                        agents(a)%dt_sum,                     &
+                                        agents(a)%energy_storage,             &
+                                        agents(a)%clothing_temp,              &
+                                        agents(a)%clo,                        &
+                                        agents(a)%actlev,                     &
+                                        agents(a)%age_years,                  &
+                                        agents(a)%weight,                     &
+                                        agents(a)%height,                     &
+                                        agents(a)%work,                       &
+                                        agents(a)%sex,                        &
+                                        agents(a)%ipt )
+                END DO
+
+             ENDDO
+          ENDDO
+       ENDIF
 
        IF ( dt_3d_reached_mas )  EXIT
@@ -799,6 +845,14 @@
                          tmp_agent%age_m         = 0.0_wp
                          tmp_agent%dt_sum        = 0.0_wp
-                         tmp_agent%clo           = 99999.0_wp
+                         tmp_agent%clo           = -999.0_wp
                          tmp_agent%energy_storage= 0.0_wp
+                         tmp_agent%ipt           = 99999.0_wp
+                         tmp_agent%clothing_temp = -999._wp      !< energy stored by agent (W)
+                         tmp_agent%actlev        = 134.6862_wp   !< metabolic + work energy of the person
+                         tmp_agent%age_years     = 35._wp        !< physical age of the person
+                         tmp_agent%weight        = 75._wp        !< total weight of the person (kg)
+                         tmp_agent%height        = 1.75_wp       !< height of the person (m)
+                         tmp_agent%work          = 134.6862_wp   !< workload of the agent (W)
+                         tmp_agent%sex           = 1             !< agents gender: 1 = male, 2 = female
                          tmp_agent%force_x       = 0.0_wp
                          tmp_agent%force_y       = 0.0_wp
@@ -812,5 +866,4 @@
                          tmp_agent%speed_x       = 0.0_wp
                          tmp_agent%speed_y       = 0.0_wp
-                         tmp_agent%thermal_index = 99999.0_wp
                          tmp_agent%x             = pos_x
                          tmp_agent%y             = pos_y
@@ -3185,5 +3238,5 @@
           zero_agent%speed_x       = 0.0_wp
           zero_agent%speed_y       = 0.0_wp
-          zero_agent%thermal_index = 0.0_wp
+          zero_agent%ipt           = 0.0_wp
           zero_agent%x             = 0.0_wp
           zero_agent%y             = 0.0_wp
