Index: /palm/trunk/SOURCE/Makefile
===================================================================
--- /palm/trunk/SOURCE/Makefile	(revision 1985)
+++ /palm/trunk/SOURCE/Makefile	(revision 1986)
@@ -20,5 +20,5 @@
 # Current revisions:
 # ------------------
-# 
+# POSIX-calls module added
 # 
 # Former revisions:
@@ -326,5 +326,5 @@
 	pmc_child_mod.f90 pmc_general_mod.f90 pmc_handle_communicator_mod.f90 \
 	pmc_mpi_wrapper_mod.f90 pmc_parent_mod.f90 poisfft_mod.f90 poismg_mod.f90 \
-	poismg_noopt.f90 pres.f90 print_1d.f90 production_e.f90 \
+	poismg_noopt.f90 posix_calls_from_fortran.f90 pres.f90 print_1d.f90 production_e.f90 \
 	prognostic_equations.f90 progress_bar_mod.f90 radiation_model_mod.f90 \
 	random_function_mod.f90 random_gauss.f90 random_generator_parallel_mod.f90 \
@@ -408,5 +408,6 @@
 calc_radiation.o: modules.o mod_kinds.o
 check_for_restart.o: modules.o mod_kinds.o pmc_interface_mod.o
-check_open.o: modules.o mod_kinds.o mod_particle_attributes.o netcdf_interface_mod.o
+check_open.o: modules.o mod_kinds.o mod_particle_attributes.o \
+	netcdf_interface_mod.o posix_calls_from_fortran.o
 check_parameters.o: modules.o mod_kinds.o land_surface_model_mod.o \
 	netcdf_interface_mod.o plant_canopy_model_mod.o pmc_interface_mod.o radiation_model_mod.o \
@@ -529,4 +530,5 @@
 poismg_mod.o: modules.o cpulog_mod.o mod_kinds.o
 poismg_noopt.o: modules.o cpulog_mod.o mod_kinds.o
+posix_calls_from_fortran.o: posix_calls_from_fortran.f90
 pres.o: modules.o cpulog_mod.o mod_kinds.o poisfft_mod.o poismg_mod.o pmc_interface_mod.o
 print_1d.o: modules.o cpulog_mod.o mod_kinds.o
Index: /palm/trunk/SOURCE/check_open.f90
===================================================================
--- /palm/trunk/SOURCE/check_open.f90	(revision 1985)
+++ /palm/trunk/SOURCE/check_open.f90	(revision 1986)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: check if output can be opened in newly created directory. If not
+! wait one second and try again.
 ! 
 ! Former revisions:
@@ -146,4 +147,7 @@
     USE pegrid
 
+    USE posix_calls_from_fortran,                                              &
+        ONLY:  fortran_sleep
+
     USE profil_parameter,                                                      &
         ONLY:  cross_ts_numbers, cross_ts_number_count
@@ -175,4 +179,5 @@
     INTEGER(iwp) ::  i           !<
     INTEGER(iwp) ::  iaddres     !<
+    INTEGER(iwp) ::  ioerr       !< IOSTAT flag for IO-commands ( 0 = no error )
     INTEGER(iwp) ::  iusern      !<
     INTEGER(iwp) ::  j           !<
@@ -327,6 +332,11 @@
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
-             OPEN ( 14, FILE='BINOUT'//TRIM(coupling_char)//'/'//myid_char,    &
-                        FORM='UNFORMATTED' )
+             ioerr = 1
+             DO WHILE ( ioerr /= 0 )
+                OPEN ( 14, FILE='BINOUT'//TRIM(coupling_char)//'/'//myid_char, &
+                           FORM='UNFORMATTED', IOSTAT=ioerr )
+                IF ( ioerr /= 0 )  CALL fortran_sleep( 1 )
+             ENDDO
+
           ENDIF
 
@@ -370,6 +380,12 @@
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
-             OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/'//          &
-                        myid_char, FORM='UNFORMATTED', POSITION='APPEND' )
+             ioerr = 1
+             DO WHILE ( ioerr /= 0 )
+                OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/'//       &
+                           myid_char, FORM='UNFORMATTED', POSITION='APPEND',   &
+                           IOSTAT=ioerr )
+                IF ( ioerr /= 0 )  CALL fortran_sleep( 1 )
+             ENDDO
+
           ENDIF
 
@@ -614,7 +630,12 @@
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
-             OPEN ( 85, FILE='PARTICLE_DATA'//TRIM( coupling_char )//'/'//     &
-                        myid_char,                                             &
-                        FORM='UNFORMATTED', POSITION='APPEND' )
+             ioerr = 1
+             DO WHILE ( ioerr /= 0 )
+                OPEN ( 85, FILE='PARTICLE_DATA'//TRIM( coupling_char )//'/'//  &
+                           myid_char,                                          &
+                           FORM='UNFORMATTED', POSITION='APPEND', IOSTAT=ioerr )
+                IF ( ioerr /= 0 )  CALL fortran_sleep( 1 )
+             ENDDO
+
           ENDIF
 
