Index: /palm/trunk/SOURCE/biometeorology_mod.f90
===================================================================
--- /palm/trunk/SOURCE/biometeorology_mod.f90	(revision 4589)
+++ /palm/trunk/SOURCE/biometeorology_mod.f90	(revision 4590)
@@ -21,9 +21,13 @@
 ! Current revisions:
 ! ------------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Enable restart via mpi-IO. Therefore, allocated array mrt_av_grid as 3D array instead of an
+! 1D array.
+! 
+! 4577 2020-06-25 09:53:58Z raasch
 ! further re-formatting concerning Fortran parameter variables
 !
@@ -183,5 +187,7 @@
 
     USE restart_data_mpi_io_mod,                                                                   &
-        ONLY:  rrd_mpi_io, wrd_mpi_io
+        ONLY:  rrd_mpi_io,                                                                         &
+               rd_mpi_io_check_array,                                                              &
+               wrd_mpi_io
 
 
@@ -217,6 +223,4 @@
     REAL(wp)    ::  bio_output_height  !< height output is calculated in m
 
-    REAL(wp), DIMENSION(:), ALLOCATABLE   ::  mrt_av_grid   !< time average mean
-
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  perct      !< PT results   (degree_C)
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  pet        !< PET results  (degree_C)
@@ -229,4 +233,6 @@
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  tmrt_av_grid  !< tmrt results (degree_C)
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  utci_av       !< UTCI results (aver. input) (degree_C)
+
+    REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::  mrt_av_grid   !< time average mean radiant temperature
 
 !
@@ -410,7 +416,8 @@
     CHARACTER (LEN=*) ::  variable !< The variable in question
 
-    INTEGER(iwp) ::  i        !< Running index, x-dir
-    INTEGER(iwp) ::  j        !< Running index, y-dir
-    INTEGER(iwp) ::  k        !< Running index, z-dir
+    INTEGER(iwp) ::  i        !< Running index, x-direction
+    INTEGER(iwp) ::  j        !< Running index, y-direction
+    INTEGER(iwp) ::  k        !< Running index, z-direction
+    INTEGER(iwp) ::  l        !< index used to link radiation arrays to 3d grid arrays
 
 
@@ -422,5 +429,5 @@
 
                 IF ( .NOT. ALLOCATED( mrt_av_grid ) )  THEN
-                   ALLOCATE( mrt_av_grid(nmrtbl) )
+                   ALLOCATE( mrt_av_grid(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
                 ENDIF
                 mrt_av_grid = 0.0_wp
@@ -486,10 +493,20 @@
 
                 IF ( mrt_include_sw )  THEN
-                   mrt_av_grid(:) = mrt_av_grid(:)  +                                              &
-                                    ( ( human_absorb * mrtinsw(:) +                                &
-                                    mrtinlw(:) ) / ( human_emiss * sigma_sb ) )**.25_wp - degc_to_k
+                   DO  l = 1, nmrtbl
+                      i = mrtbl(ix,l)
+                      j = mrtbl(iy,l)
+                      k = mrtbl(iz,l)
+                      mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i)  +                                   &
+                                    ( ( human_absorb * mrtinsw(l) +                                &
+                                    mrtinlw(l) ) / ( human_emiss * sigma_sb ) )**0.25_wp - degc_to_k
+                   ENDDO
                 ELSE
-                   mrt_av_grid(:) = mrt_av_grid(:) +                                               &
-                                    ( mrtinlw(:) / ( human_emiss * sigma_sb ) )**.25_wp - degc_to_k
+                   DO  l = 1, nmrtbl
+                      i = mrtbl(ix,l)
+                      j = mrtbl(iy,l)
+                      k = mrtbl(iz,l)
+                      mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i)  +                                   &
+                                    ( mrtinlw(l) / ( human_emiss * sigma_sb ) )**0.25_wp - degc_to_k
+                   ENDDO
                 ENDIF
              ENDIF
@@ -584,5 +601,5 @@
 
              IF ( .NOT. ALLOCATED( mrt_av_grid ) )  THEN
-                ALLOCATE( mrt_av_grid(nmrtbl) )
+                ALLOCATE( mrt_av_grid(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
                 do_average_mrt = .TRUE.
                 mrt_av_grid = 0.0_wp
@@ -591,12 +608,22 @@
 
                 IF ( mrt_include_sw )  THEN
-                   mrt_av_grid(:) = mrt_av_grid(:) +                                               &
-                                    ( ( human_absorb * mrtinsw(:) +                                &
-                                    mrtinlw(:) ) /                                                 &
+                   DO  l = 1, nmrtbl
+                      i = mrtbl(ix,l)
+                      j = mrtbl(iy,l)
+                      k = mrtbl(iz,l)
+                      mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i)  +                                   &
+                                    ( ( human_absorb * mrtinsw(l) +                                &
+                                    mrtinlw(l) ) /                                                 &
                                       ( human_emiss  * sigma_sb ) )**0.25_wp - degc_to_k
-               ELSE
-                   mrt_av_grid(:) = mrt_av_grid(:) +                                               &
-                                    ( mrtinlw(:) /                                                 &
+                   ENDDO
+                ELSE
+                   DO  l = 1, nmrtbl
+                      i = mrtbl(ix,l)
+                      j = mrtbl(iy,l)
+                      k = mrtbl(iz,l)
+                      mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i) +                                    &
+                                    ( mrtinlw(l) /                                                 &
                                     ( human_emiss * sigma_sb ) )**0.25_wp - degc_to_k
+                   ENDDO
                 ENDIF
              ENDIF
@@ -626,5 +653,11 @@
 !--          do_average_mrt will be .TRUE. leading to a double-averaging.
              IF ( .NOT. do_average_mrt  .AND.  ALLOCATED( mrt_av_grid ) )  THEN
-                mrt_av_grid(:) = mrt_av_grid(:) / REAL( average_count_3d, KIND=wp )
+                DO  i = nxl, nxr
+                   DO  j = nys, nyn
+                      DO  k = nzb, nzt+1
+                         mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i) / REAL( average_count_3d, KIND=wp )
+                      ENDDO
+                   ENDDO
+                ENDDO
              ENDIF
 
@@ -692,5 +725,11 @@
 
              IF ( ALLOCATED( mrt_av_grid )  .AND.  do_average_mrt )  THEN
-                mrt_av_grid(:) = mrt_av_grid(:) / REAL( average_count_3d, KIND = wp )
+                DO  i = nxl, nxr
+                   DO  j = nys, nyn
+                      DO  k = nzb, nzt+1
+                         mrt_av_grid(k,j,i) = mrt_av_grid(k,j,i) / REAL( average_count_3d, KIND=wp )
+                      ENDDO
+                   ENDDO
+                ENDDO
              ENDIF
 
@@ -942,5 +981,5 @@
                  ENDIF
               ELSE
-                 local_pf(i,j,k) = mrt_av_grid(l)
+                 local_pf(i,j,k) = mrt_av_grid(k,j,i)
               ENDIF
            ENDDO
@@ -1115,5 +1154,5 @@
                   ENDIF
                ELSE
-                  local_pf(i,j,k) = REAL( mrt_av_grid(l), KIND = sp )
+                  local_pf(i,j,k) = REAL( mrt_av_grid(k,j,i), KIND = sp )
                ENDIF
             ENDDO
@@ -1435,13 +1474,10 @@
     SELECT CASE ( restart_string(1:length) )
 
-       CASE ( 'nmrtbl' )
-          READ ( 13 )  bio_nmrtbl
-
        CASE ( 'mrt_av_grid' )
           IF ( .NOT. ALLOCATED( mrt_av_grid ) )  THEN
-             ALLOCATE( mrt_av_grid(bio_nmrtbl) )
+             ALLOCATE( mrt_av_grid(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+             mrt_av_grid = 0.0_wp
           ENDIF
           READ ( 13 )  mrt_av_grid
-
 
        CASE DEFAULT
@@ -1462,5 +1498,20 @@
  SUBROUTINE bio_rrd_local_mpi
 
-    STOP '+++ reading restart data with MPI-IO not implemented for bio_rrd_local_mpi'
+    USE control_parameters
+
+    USE indices
+
+    USE kinds
+
+
+    IMPLICIT NONE
+
+    LOGICAL      ::  array_found  !<
+
+    CALL rd_mpi_io_check_array( 'mrt_av_grid' , found = array_found )
+    IF ( array_found )  THEN
+       IF ( .NOT. ALLOCATED( mrt_av_grid ) )  ALLOCATE( mrt_av_grid(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
+       CALL rrd_mpi_io( 'mrt_av_grid', mrt_av_grid )
+    ENDIF
 
  END SUBROUTINE bio_rrd_local_mpi
@@ -1473,6 +1524,4 @@
 !--------------------------------------------------------------------------------------------------!
  SUBROUTINE bio_wrd_global
-
-    IMPLICIT NONE
 
     IF ( TRIM( restart_data_format_output ) == 'fortran_binary' )  THEN
@@ -1524,13 +1573,5 @@
  SUBROUTINE bio_wrd_local
 
-    IMPLICIT NONE
-
-
     IF ( TRIM( restart_data_format_output ) == 'fortran_binary' )  THEN
-
-!
-!--    First nmrtbl has to be written/read, because it is the dimension of mrt_av_grid
-       CALL wrd_write_string( 'nmrtbl' )
-       WRITE ( 14 )  nmrtbl
 
        IF ( ALLOCATED( mrt_av_grid ) )  THEN
@@ -1541,12 +1582,5 @@
     ELSEIF ( TRIM( restart_data_format_output(1:3) ) == 'mpi' )  THEN
 
-!
-!--   TODO: the mrt_av_grid is a 1-d array and its size depends on subdomain features. This does
-!--         not work with the MPI-IO concept (nor with the restart I/O concept in general.
-!--         I am not sure, if this data needs to be written to the restart file at all (Siggi, 13.4.20)
-!       CALL wrd_mpi_io( 'nmrtbl', nmrtbl )
-!       CALL wrd_mpi_io_..... 'mrt_av_grid'
-       WRITE (6,*) '+++ biometeorology module does not work with MPI-IO for restart_data'
-       STOP
+       IF ( ALLOCATED( mrt_av_grid ) )  CALL wrd_mpi_io( 'mrt_av_grid', mrt_av_grid )
 
     ENDIF
@@ -1576,12 +1610,12 @@
     IF ( av )  THEN
 !
-!-- Make sure tmrt_av_grid is present and initialize with the fill value
+!--    Make sure tmrt_av_grid is present and initialize with the fill value
        IF ( .NOT. ALLOCATED( tmrt_av_grid ) )  THEN
-          ALLOCATE( tmrt_av_grid (nys:nyn,nxl:nxr) )
+          ALLOCATE( tmrt_av_grid(nys:nyn,nxl:nxr) )
        ENDIF
        tmrt_av_grid = REAL( bio_fill_value, KIND = wp )
 
 !
-!-- mrt_av_grid should always be allcoated here, but better make sure ist actually is.
+!--    mrt_av_grid should always be allcoated here, but better make sure ist actually is.
        IF ( ALLOCATED( mrt_av_grid ) )  THEN
 !
@@ -1596,5 +1630,5 @@
 !
 !--             Averaging was done before, so we can just copy the result here.
-                tmrt_av_grid(j,i) = mrt_av_grid(l)
+                tmrt_av_grid(j,i) = mrt_av_grid(k,j,i)
 
              ENDIF
Index: /palm/trunk/SOURCE/module_interface.f90
===================================================================
--- /palm/trunk/SOURCE/module_interface.f90	(revision 4589)
+++ /palm/trunk/SOURCE/module_interface.f90	(revision 4590)
@@ -20,9 +20,12 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Enable mpi-io for biomet
+! 
+! 4525 2020-05-10 17:05:07Z raasch
 ! added restart I/O for global salsa data,
 ! added restart with MPI-IO for salsa
@@ -2003,5 +2006,5 @@
     CALL dynamics_rrd_local
 
-!    IF ( biometeorology )       CALL bio_rrd_local
+    IF ( biometeorology )       CALL bio_rrd_local
     IF ( bulk_cloud_model )     CALL bcm_rrd_local
     IF ( air_chemistry )        CALL chem_rrd_local
Index: /palm/trunk/SOURCE/read_restart_data_mod.f90
===================================================================
--- /palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4589)
+++ /palm/trunk/SOURCE/read_restart_data_mod.f90	(revision 4590)
@@ -20,9 +20,13 @@
 ! Current revisions:
 ! -----------------
-! 
-! 
+!
+!
 ! Former revisions:
 ! -----------------
 ! $Id$
+! Bugfix in allocation of hom and hom_sum in case of mpi-io restart when
+! chemistry or salsa are employed
+! 
+! 4580 2020-06-29 07:54:21Z raasch
 ! data handling with MPI-IO for cyclic-fill added (so far only for global data)
 ! 
@@ -880,6 +884,6 @@
                      v_init(0:nz+1), pt_init(0:nz+1), q_init(0:nz+1),                              &
                      ref_state(0:nz+1), s_init(0:nz+1), sa_init(0:nz+1),                           &
-                     hom(0:nz+1,2,pr_palm+max_pr_user,0:statistic_regions),                        &
-                     hom_sum(0:nz+1,pr_palm+max_pr_user,0:statistic_regions) )
+                     hom(0:nz+1,2,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions), &
+                     hom_sum(0:nz+1,pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0:statistic_regions) )
        ENDIF
 
