Index: palm/trunk/SOURCE/biometeorology_mod.f90
===================================================================
--- palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3474)
+++ palm/trunk/SOURCE/biometeorology_mod.f90	(revision 3475)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! Add option for using MRT from RTM instead of simplified global value
+! 
+! 3464 2018-10-30 18:08:55Z kanani
 ! From branch resler@3462, pavelkrc:
 ! make use of basic_constants_and_equations_mod
@@ -91,5 +94,6 @@
     USE radiation_model_mod,                                                   &
        ONLY: ix, iy, iz, id, mrt_nlevels, mrt_include_sw,                      &
-             mrtinsw, mrtinlw, mrtbl, nmrtbl, radiation, rad_sw_in,            &
+             mrtinsw, mrtinlw, mrtbl, nmrtbl, radiation,                       &
+             radiation_interactions, rad_sw_in,                                &
              rad_sw_out, rad_lw_in, rad_lw_out
 
@@ -130,4 +134,5 @@
     LOGICAL ::  average_trigger_pet  = .FALSE.  !< update averaged input on call to biom_pet?
 
+    LOGICAL ::  mrt_from_rtm   = .TRUE.   !< switch: use mrt calculated by RTM for calculation of thermal indices
     LOGICAL ::  biom_pt        = .TRUE.   !< Turn index PT (instant. input) on or off
     LOGICAL ::  biom_pt_av     = .TRUE.   !< Turn index PT (averaged input) on or off
@@ -539,5 +544,4 @@
        ENDIF
 
-
  END SUBROUTINE biom_check_parameters
 
@@ -871,4 +875,7 @@
  SUBROUTINE biom_init
 
+    USE control_parameters,                                                 &
+        ONLY: message_string
+
     IMPLICIT NONE
 
@@ -888,4 +895,12 @@
     biom_cell_level = INT ( 1.099_wp / dz(1) )
     biom_output_height = biom_output_height + biom_cell_level * dz(1)
+
+    IF ( .NOT. radiation_interactions .AND. mrt_from_rtm ) THEN
+       message_string = 'The mrt_from_rtm switch require ' // &
+                        'enabled radiation_interactions but it ' // &
+                        'is disabled! Set mrt_from_rtm to .F.'
+       CALL message( 'check_parameters', 'PAHU03', 0, 0, -1, 6, 0 )
+       mrt_from_rtm = .FALSE.
+    ENDIF
 
  END SUBROUTINE biom_init
@@ -961,5 +976,6 @@
     CHARACTER (LEN=80) ::  line  !< Dummy string for current line in parameter file 
 
-    NAMELIST /biometeorology_parameters/  biom_pet,                            &
+    NAMELIST /biometeorology_parameters/  mrt_from_rtm,                        &
+                                          biom_pet,                            &
                                           biom_pet_av,                         &
                                           biom_pt,                             &
@@ -1257,7 +1273,11 @@
     tmrt = ta
     IF ( radiation ) THEN
-       CALL calculate_tmrt_2_directions (rad_sw_in(0, j, i),                   &
-          rad_sw_out(0, j, i), rad_lw_in(0, j, i), rad_lw_out(0, j, i), ta,    &
-          tmrt )
+       IF ( mrt_from_rtm ) THEN
+          tmrt = tmrt_grid(j, i)
+       ELSE
+          CALL calculate_tmrt_2_directions (rad_sw_in(0, j, i),                &
+             rad_sw_out(0, j, i), rad_lw_in(0, j, i), rad_lw_out(0, j, i), ta, &
+             tmrt )
+       ENDIF
     ENDIF
 
@@ -1279,5 +1299,5 @@
 
 !-- Internal variables
-    INTEGER(iwp) ::  i, j      !< Running index
+    INTEGER(iwp) ::  i, j, k, l   !< Running index
 
     REAL(wp) ::  ta            !< Air temperature                  (Â°C)
@@ -1293,9 +1313,27 @@
     CALL biom_init_arrays
 
+    IF ( mrt_from_rtm ) THEN
+       tmrt_grid = -999._wp
+       DO  l = 1, nmrtbl
+           i = mrtbl(ix,l)
+           j = mrtbl(iy,l)
+           k = mrtbl(iz,l)
+           IF ( k - get_topography_top_index_ji( j, i, 's' ) == 1  ) THEN
+              IF ( mrt_include_sw )  THEN
+                  tmrt_tmp = ((human_absorb*mrtinsw(l) + human_emiss*mrtinlw(l)) &
+                             / (human_emiss*sigma_sb)) ** .25_wp
+              ELSE
+                  tmrt_tmp = (human_emiss*mrtinlw(l) / sigma_sb) ** .25_wp
+              ENDIF
+              tmrt_grid(j, i) = tmrt_tmp - degc_to_k
+           ENDIF
+       ENDDO
+    ENDIF
+
     DO i = nxl, nxr
        DO j = nys, nyn
 !--       Determine local input conditions
           CALL biom_determine_input_at ( average_input, i, j, ta, vp, ws,      &
-             pair, tmrt_tmp ) 
+               pair, tmrt_tmp )
           tmrt_grid(j, i) = tmrt_tmp
 
