Index: palm/trunk/SCRIPTS/.palm.iofiles
===================================================================
--- palm/trunk/SCRIPTS/.palm.iofiles	(revision 3811)
+++ palm/trunk/SCRIPTS/.palm.iofiles	(revision 3812)
@@ -57,6 +57,6 @@
 LIST_PROFIL*               out:tr   *         $base_data/$run_identifier/MONITORING     _list_pr
 #
-SURFACE_DATA_BIN*          out:tr   *         $base_data/$run_identifier/OUTPUT         _surf      bin
-SURFACE_DATA_AV_BIN*       out:tr   *         $base_data/$run_identifier/OUTPUT         _av_surf   bin
+SURFACE_DATA_BIN*          out:lnpe *         $base_data/$run_identifier/OUTPUT         _surf
+SURFACE_DATA_AV_BIN*       out:lnpe *         $base_data/$run_identifier/OUTPUT         _av_surf
 SURFACE_DATA_NETCDF*       out:tr   *         $base_data/$run_identifier/OUTPUT         _surf      nc
 SURFACE_DATA_AV_NETCDF*    out:tr   *         $base_data/$run_identifier/OUTPUT         _av_surf   nc
Index: palm/trunk/SOURCE/check_open.f90
===================================================================
--- palm/trunk/SOURCE/check_open.f90	(revision 3811)
+++ palm/trunk/SOURCE/check_open.f90	(revision 3812)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Open binary surface output data within separate folder
+! 
+! 3705 2019-01-29 19:56:39Z suehring
 ! Open binary files for virtual measurements
 ! 
@@ -465,13 +468,71 @@
 !
 !--       Binary files for surface data
-          OPEN ( 25, FILE='SURFACE_DATA_BIN'//TRIM( coupling_char )//myid_char,  &
-                 FORM='UNFORMATTED', POSITION='APPEND' )
+          ! OPEN ( 25, FILE='SURFACE_DATA_BIN'//TRIM( coupling_char )//          &
+          !                 myid_char, FORM='UNFORMATTED', POSITION='APPEND' )
+
+          IF ( myid_char == '' )  THEN
+             OPEN ( 25, FILE='SURFACE_DATA_BIN'//TRIM( coupling_char )//       &
+                             myid_char, FORM='UNFORMATTED', POSITION='APPEND' )
+          ELSE
+             IF ( myid == 0  .AND. .NOT. openfile(file_id)%opened_before )  THEN
+                CALL local_system( 'mkdir  SURFACE_DATA_BIN' //                &
+                                   TRIM( coupling_char ) )
+             ENDIF
+#if defined( __parallel )
+!
+!--          Set a barrier in order to allow that all other processors in the 
+!--          directory created by PE0 can open their file
+             CALL MPI_BARRIER( comm2d, ierr )
+#endif
+             ioerr = 1
+             DO WHILE ( ioerr /= 0 )
+                OPEN ( 25, FILE='SURFACE_DATA_BIN'//TRIM(coupling_char)//      &
+                                '/'//myid_char,                                &
+                           FORM='UNFORMATTED', IOSTAT=ioerr )
+                IF ( ioerr /= 0 )  THEN
+                   WRITE( 9, * )  '*** could not open "SURFACE_DATA_BIN'//     &
+                                  TRIM(coupling_char)//'/'//myid_char//        &
+                                  '"! Trying again in 1 sec.'
+                   CALL fortran_sleep( 1 )
+                ENDIF
+             ENDDO
+
+          ENDIF
 
        CASE ( 26 )
 !
 !--       Binary files for averaged surface data
-          OPEN ( 26, FILE='SURFACE_DATA_AV_BIN'//TRIM( coupling_char )//myid_char,  &
-                 FORM='UNFORMATTED', POSITION='APPEND' )
-                 
+          ! OPEN ( 26, FILE='SURFACE_DATA_AV_BIN'//TRIM( coupling_char )//myid_char,  &
+          !        FORM='UNFORMATTED', POSITION='APPEND' )
+
+          IF ( myid_char == '' )  THEN
+             OPEN ( 26, FILE='SURFACE_DATA_AV_BIN'//TRIM( coupling_char )//    &
+                             myid_char, FORM='UNFORMATTED', POSITION='APPEND' )
+          ELSE
+             IF ( myid == 0  .AND. .NOT. openfile(file_id)%opened_before )  THEN
+                CALL local_system( 'mkdir  SURFACE_DATA_AV_BIN' //             &
+                                   TRIM( coupling_char ) )
+             ENDIF
+#if defined( __parallel )
+!
+!--          Set a barrier in order to allow that all other processors in the 
+!--          directory created by PE0 can open their file
+             CALL MPI_BARRIER( comm2d, ierr )
+#endif
+             ioerr = 1
+             DO WHILE ( ioerr /= 0 )
+                OPEN ( 26, FILE='SURFACE_DATA_AV_BIN'//TRIM(coupling_char)//   &
+                                '/'//myid_char,                                &
+                           FORM='UNFORMATTED', IOSTAT=ioerr )
+                IF ( ioerr /= 0 )  THEN
+                   WRITE( 9, * )  '*** could not open "SURFACE_DATA_AV_BIN'//  &
+                                  TRIM(coupling_char)//'/'//myid_char//        &
+                                  '"! Trying again in 1 sec.'
+                   CALL fortran_sleep( 1 )
+                ENDIF
+             ENDDO
+
+          ENDIF
+
        CASE ( 27 )
 !
