Index: palm/trunk/SOURCE/biometeorology_mod.f90
===================================================================
--- palm/trunk/SOURCE/biometeorology_mod.f90	(revision 4493)
+++ palm/trunk/SOURCE/biometeorology_mod.f90	(revision 4495)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! restart data handling with MPI-IO added
+! 
+! 4493 2020-04-10 09:49:43Z pavelkrc
 ! Revise bad formatting
 ! 
@@ -144,5 +147,5 @@
                dz, dz_stretch_factor,                                          &
                dz_stretch_level, humidity, initializing_actions, nz_do3d,      &
-               surface_pressure
+               restart_data_format_output, surface_pressure
 
     USE grid_variables,                                                        &
@@ -168,4 +171,8 @@
                radiation_interactions, rad_sw_in,                              &
                rad_sw_out, rad_lw_in, rad_lw_out
+
+    USE restart_data_mpi_io_mod,                                                                   &
+        ONLY:  rrd_mpi_io, wrd_mpi_io
+
 
     IMPLICIT NONE
@@ -352,5 +359,6 @@
 !-- Read global restart parameters
     INTERFACE bio_rrd_global
-       MODULE PROCEDURE bio_rrd_global
+       MODULE PROCEDURE bio_rrd_global_ftn
+       MODULE PROCEDURE bio_rrd_global_mpi
     END INTERFACE bio_rrd_global
 !
@@ -1330,7 +1338,7 @@
 ! Description:
 ! ------------
-!> Soubroutine reads global biometeorology configuration from restart file(s)
-!------------------------------------------------------------------------------!
- SUBROUTINE bio_rrd_global( found )
+!> Read module-specific global restart data (Fortran binary format).
+!------------------------------------------------------------------------------!
+ SUBROUTINE bio_rrd_global_ftn( found )
 
     USE control_parameters,                                                    &
@@ -1389,5 +1397,31 @@
 
 
- END SUBROUTINE bio_rrd_global
+ END SUBROUTINE bio_rrd_global_ftn
+
+
+!------------------------------------------------------------------------------!
+! Description:
+! ------------
+!> Read module-specific global restart data (MPI-IO).
+!------------------------------------------------------------------------------!
+ SUBROUTINE bio_rrd_global_mpi
+
+
+!
+!--  Read control flags to determine if input grids need to be averaged
+     CALL rrd_mpi_io( 'do_average_theta', do_average_theta )
+     CALL rrd_mpi_io( 'do_average_q', do_average_q )
+     CALL rrd_mpi_io( 'do_average_u', do_average_u )
+     CALL rrd_mpi_io( 'do_average_v', do_average_v )
+     CALL rrd_mpi_io( 'do_average_w', do_average_w )
+     CALL rrd_mpi_io( 'do_average_mrt', do_average_mrt )
+!
+!--  Rad control flags to determine which thermal index needs to trigger averaging
+     CALL rrd_mpi_io( 'average_trigger_perct', average_trigger_perct )
+     CALL rrd_mpi_io( 'average_trigger_utci', average_trigger_utci )
+     CALL rrd_mpi_io( 'average_trigger_pet', average_trigger_pet )
+     CALL rrd_mpi_io( 'average_trigger_mrt', average_trigger_mrt )
+
+ END SUBROUTINE bio_rrd_global_mpi
 
 
@@ -1442,24 +1476,40 @@
     IMPLICIT NONE
 
-    CALL wrd_write_string( 'do_average_theta' )
-    WRITE ( 14 )  do_average_theta
-    CALL wrd_write_string( 'do_average_q' )
-    WRITE ( 14 )  do_average_q
-    CALL wrd_write_string( 'do_average_u' )
-    WRITE ( 14 )  do_average_u
-    CALL wrd_write_string( 'do_average_v' )
-    WRITE ( 14 )  do_average_v
-    CALL wrd_write_string( 'do_average_w' )
-    WRITE ( 14 )  do_average_w
-    CALL wrd_write_string( 'do_average_mrt' )
-    WRITE ( 14 )  do_average_mrt
-    CALL wrd_write_string( 'average_trigger_perct' )
-    WRITE ( 14 )  average_trigger_perct
-    CALL wrd_write_string( 'average_trigger_utci' )
-    WRITE ( 14 )  average_trigger_utci
-    CALL wrd_write_string( 'average_trigger_pet' )
-    WRITE ( 14 )  average_trigger_pet
-    CALL wrd_write_string( 'average_trigger_mrt' )
-    WRITE ( 14 )  average_trigger_mrt
+    IF ( TRIM( restart_data_format_output ) == 'fortran_binary' )  THEN
+
+       CALL wrd_write_string( 'do_average_theta' )
+       WRITE ( 14 )  do_average_theta
+       CALL wrd_write_string( 'do_average_q' )
+       WRITE ( 14 )  do_average_q
+       CALL wrd_write_string( 'do_average_u' )
+       WRITE ( 14 )  do_average_u
+       CALL wrd_write_string( 'do_average_v' )
+       WRITE ( 14 )  do_average_v
+       CALL wrd_write_string( 'do_average_w' )
+       WRITE ( 14 )  do_average_w
+       CALL wrd_write_string( 'do_average_mrt' )
+       WRITE ( 14 )  do_average_mrt
+       CALL wrd_write_string( 'average_trigger_perct' )
+       WRITE ( 14 )  average_trigger_perct
+       CALL wrd_write_string( 'average_trigger_utci' )
+       WRITE ( 14 )  average_trigger_utci
+       CALL wrd_write_string( 'average_trigger_pet' )
+       WRITE ( 14 )  average_trigger_pet
+       CALL wrd_write_string( 'average_trigger_mrt' )
+       WRITE ( 14 )  average_trigger_mrt
+
+    ELSEIF ( TRIM( restart_data_format_output ) == 'mpi' )  THEN
+
+       CALL wrd_mpi_io( 'do_average_theta', do_average_theta )
+       CALL wrd_mpi_io( 'do_average_q', do_average_q )
+       CALL wrd_mpi_io( 'do_average_u', do_average_u )
+       CALL wrd_mpi_io( 'do_average_v', do_average_v )
+       CALL wrd_mpi_io( 'do_average_w', do_average_w )
+       CALL wrd_mpi_io( 'do_average_mrt', do_average_mrt )
+       CALL wrd_mpi_io( 'average_trigger_perct', average_trigger_perct )
+       CALL wrd_mpi_io( 'average_trigger_utci', average_trigger_utci )
+       CALL wrd_mpi_io( 'average_trigger_pet', average_trigger_pet )
+       CALL wrd_mpi_io( 'average_trigger_mrt', average_trigger_mrt )
+    ENDIF
 
  END SUBROUTINE bio_wrd_global
@@ -1475,14 +1525,29 @@
     IMPLICIT NONE
 
-!
-!-- 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
-       CALL wrd_write_string( 'mrt_av_grid' )
-       WRITE ( 14 )  mrt_av_grid
-    ENDIF
-
+
+    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
+          CALL wrd_write_string( 'mrt_av_grid' )
+          WRITE ( 14 )  mrt_av_grid
+       ENDIF
+
+    ELSEIF ( TRIM( restart_data_format_output ) == '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
+
+    ENDIF
 
  END SUBROUTINE bio_wrd_local
