Index: /palm/trunk/SOURCE/radiation_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4873)
+++ /palm/trunk/SOURCE/radiation_model_mod.f90	(revision 4874)
@@ -27,4 +27,7 @@
 ! -----------------
 ! $Id$
+! bugfix for writing restart radiation arrays with MPI-IO
+!
+! 4867 2021-02-06 09:28:31Z moh.hefny
 ! bugfix in allocating rad_lw_out_av
 !
@@ -12395,4 +12398,6 @@
     IMPLICIT NONE
 
+    REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) ::  tmp  !< temporary array for reading from file
+
 
     IF ( TRIM( restart_data_format_output ) == 'fortran_binary' )  THEN
@@ -12510,16 +12515,58 @@
        IF ( ALLOCATED( rad_sw_in_xy_av ) )  CALL wrd_mpi_io( 'rad_sw_in_xy_av', rad_sw_in_xy_av )
        IF ( ALLOCATED( rad_sw_out_xy_av ) )  CALL wrd_mpi_io( 'rad_sw_out_xy_av', rad_sw_out_xy_av )
-       IF ( ALLOCATED( rad_lw_in ) )  CALL wrd_mpi_io( 'rad_lw_in', rad_lw_in )
-       IF ( ALLOCATED( rad_lw_in_av ) )  CALL wrd_mpi_io( 'rad_lw_in_av', rad_lw_in_av )
-       IF ( ALLOCATED( rad_lw_out ) )  CALL wrd_mpi_io( 'rad_lw_out', rad_lw_out )
-       IF ( ALLOCATED( rad_lw_out_av) )  CALL wrd_mpi_io( 'rad_lw_out_av', rad_lw_out_av )
+       IF ( radiation_scheme == 'clear-sky'  .OR.  radiation_scheme == 'constant'  .OR.            &
+            radiation_scheme == 'external' )                                                       &
+       THEN
+          IF ( ALLOCATED( rad_lw_in ) )  THEN
+             tmp = rad_lw_in(0,:,:)
+             CALL wrd_mpi_io( 'rad_lw_in', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_lw_in_av ) )  THEN
+             tmp = rad_lw_in_av(0,:,:)
+             CALL wrd_mpi_io( 'rad_lw_in_av', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_lw_out ) )  THEN
+             tmp = rad_lw_out(0,:,:)
+             CALL wrd_mpi_io( 'rad_lw_out', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_lw_out_av ) )  THEN
+             tmp = rad_lw_out_av(0,:,:)
+             CALL wrd_mpi_io( 'rad_lw_out_av', tmp )
+          ENDIF
+       ELSE
+          IF ( ALLOCATED( rad_lw_in ) )  CALL wrd_mpi_io( 'rad_lw_in', rad_lw_in )
+          IF ( ALLOCATED( rad_lw_in_av ) )  CALL wrd_mpi_io( 'rad_lw_in_av', rad_lw_in_av )
+          IF ( ALLOCATED( rad_lw_out ) )  CALL wrd_mpi_io( 'rad_lw_out', rad_lw_out )
+          IF ( ALLOCATED( rad_lw_out_av) )  CALL wrd_mpi_io( 'rad_lw_out_av', rad_lw_out_av )
+       ENDIF
        IF ( ALLOCATED( rad_lw_cs_hr) )  CALL wrd_mpi_io( 'rad_lw_cs_hr', rad_lw_cs_hr )
        IF ( ALLOCATED( rad_lw_cs_hr_av) )  CALL wrd_mpi_io( 'rad_lw_cs_hr_av', rad_lw_cs_hr_av )
        IF ( ALLOCATED( rad_lw_hr) )  CALL wrd_mpi_io( 'rad_lw_hr', rad_lw_hr )
        IF ( ALLOCATED( rad_lw_hr_av) )  CALL wrd_mpi_io( 'rad_lw_hr_av', rad_lw_hr_av )
-       IF ( ALLOCATED( rad_sw_in) )  CALL wrd_mpi_io( 'rad_sw_in', rad_sw_in )
-       IF ( ALLOCATED( rad_sw_in_av) )  CALL wrd_mpi_io( 'rad_sw_in_av', rad_sw_in_av )
-       IF ( ALLOCATED( rad_sw_out) )  CALL wrd_mpi_io( 'rad_sw_out', rad_sw_out )
-       IF ( ALLOCATED( rad_sw_out_av) )  CALL wrd_mpi_io( 'rad_sw_out_av', rad_sw_out_av )
+       IF ( radiation_scheme == 'clear-sky'  .OR.  radiation_scheme == 'constant'  .OR.            &
+            radiation_scheme == 'external' )                                                       &
+       THEN
+          IF ( ALLOCATED( rad_sw_in ) )  THEN
+             tmp = rad_sw_in(0,:,:)
+             CALL wrd_mpi_io( 'rad_sw_in', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_sw_in_av ) )  THEN
+             tmp = rad_sw_in_av(0,:,:)
+             CALL wrd_mpi_io( 'rad_sw_in_av', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_sw_out ) )  THEN
+             tmp = rad_sw_out(0,:,:)
+             CALL wrd_mpi_io( 'rad_sw_out', tmp )
+          ENDIF
+          IF ( ALLOCATED( rad_sw_out_av ) )  THEN
+             tmp = rad_sw_out_av(0,:,:)
+             CALL wrd_mpi_io( 'rad_sw_out_av', tmp )
+          ENDIF
+       ELSE
+          IF ( ALLOCATED( rad_sw_in) )  CALL wrd_mpi_io( 'rad_sw_in', rad_sw_in )
+          IF ( ALLOCATED( rad_sw_in_av) )  CALL wrd_mpi_io( 'rad_sw_in_av', rad_sw_in_av )
+          IF ( ALLOCATED( rad_sw_out) )  CALL wrd_mpi_io( 'rad_sw_out', rad_sw_out )
+          IF ( ALLOCATED( rad_sw_out_av) )  CALL wrd_mpi_io( 'rad_sw_out_av', rad_sw_out_av )
+       ENDIF
        IF ( ALLOCATED( rad_sw_cs_hr) )  CALL wrd_mpi_io( 'rad_sw_cs_hr', rad_sw_cs_hr )
        IF ( ALLOCATED( rad_sw_cs_hr_av) )  CALL wrd_mpi_io( 'rad_sw_cs_hr_av', rad_sw_cs_hr_av )
