Index: palm/trunk/SOURCE/check_open.f90
===================================================================
--- palm/trunk/SOURCE/check_open.f90	(revision 1746)
+++ palm/trunk/SOURCE/check_open.f90	(revision 1779)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! coupling_char is trimmed at every place it occurs, because it can have
+! different length now
 ! 
 ! Former revisions:
@@ -274,13 +275,13 @@
 !--       check_namelist_files!
           IF ( check_restart == 2 ) THEN
-             OPEN ( 11, FILE='PARINF'//coupling_char, FORM='FORMATTED',        &
-                        STATUS='OLD' )
-          ELSE
-             OPEN ( 11, FILE='PARIN'//coupling_char, FORM='FORMATTED',         &
+             OPEN ( 11, FILE='PARINF'//TRIM( coupling_char ),                  &
+                        FORM='FORMATTED', STATUS='OLD' )
+          ELSE
+             OPEN ( 11, FILE='PARIN'//TRIM( coupling_char ), FORM='FORMATTED', &
                         STATUS='OLD' )
           END IF
 #else
 
-          OPEN ( 11, FILE='PARIN'//coupling_char, FORM='FORMATTED',            &
+          OPEN ( 11, FILE='PARIN'//TRIM( coupling_char ), FORM='FORMATTED',    &
                      STATUS='OLD' )
 #endif
@@ -289,5 +290,5 @@
 
           IF ( myid_char == '' )  THEN
-             OPEN ( 13, FILE='BININ'//coupling_char//myid_char,                &
+             OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//myid_char,        &
                         FORM='UNFORMATTED', STATUS='OLD' )
           ELSE
@@ -296,9 +297,9 @@
 !--          only this file contains the global variables
              IF ( .NOT. openfile(file_id)%opened_before )  THEN
-                OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/_000000',      &
+                OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/_000000',    &
                            FORM='UNFORMATTED', STATUS='OLD' )
              ELSE
-                OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/'//myid_char,&
-                           FORM='UNFORMATTED', STATUS='OLD' )
+                OPEN ( 13, FILE='BININ'//TRIM( coupling_char )//'/'//          &
+                           myid_char, FORM='UNFORMATTED', STATUS='OLD' )
              ENDIF
           ENDIF
@@ -307,9 +308,9 @@
 
           IF ( myid_char == '' )  THEN
-             OPEN ( 14, FILE='BINOUT'//coupling_char//myid_char,               &
+             OPEN ( 14, FILE='BINOUT'//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  BINOUT' // coupling_char )
+                CALL local_system( 'mkdir  BINOUT' // TRIM( coupling_char ) )
              ENDIF
 #if defined( __parallel ) && ! defined ( __check )
@@ -325,29 +326,33 @@
        CASE ( 15 )
 
-          OPEN ( 15, FILE='RUN_CONTROL'//coupling_char, FORM='FORMATTED' )
+          OPEN ( 15, FILE='RUN_CONTROL'//TRIM( coupling_char ),                &
+                     FORM='FORMATTED' )
 
        CASE ( 16 )
 
-          OPEN ( 16, FILE='LIST_PROFIL'//coupling_char, FORM='FORMATTED' )
+          OPEN ( 16, FILE='LIST_PROFIL'//TRIM( coupling_char ),                &
+                     FORM='FORMATTED' )
 
        CASE ( 17 )
 
-          OPEN ( 17, FILE='LIST_PROFIL_1D'//coupling_char, FORM='FORMATTED' )
+          OPEN ( 17, FILE='LIST_PROFIL_1D'//TRIM( coupling_char ),             &
+                     FORM='FORMATTED' )
 
        CASE ( 18 )
 
-          OPEN ( 18, FILE='CPU_MEASURES'//coupling_char, FORM='FORMATTED' )
+          OPEN ( 18, FILE='CPU_MEASURES'//TRIM( coupling_char ),               &
+                     FORM='FORMATTED' )
 
        CASE ( 19 )
 
-          OPEN ( 19, FILE='HEADER'//coupling_char, FORM='FORMATTED' )
+          OPEN ( 19, FILE='HEADER'//TRIM( coupling_char ), FORM='FORMATTED' )
 
        CASE ( 20 )
 
           IF ( myid == 0  .AND. .NOT. openfile(file_id)%opened_before )  THEN
-             CALL local_system( 'mkdir  DATA_LOG' // coupling_char )
+             CALL local_system( 'mkdir  DATA_LOG' // TRIM( coupling_char ) )
           ENDIF
           IF ( myid_char == '' )  THEN
-             OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/_000000',      &
+             OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/_000000',    &
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ELSE
@@ -358,6 +363,6 @@
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
-             OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/'//myid_char,&
-                        FORM='UNFORMATTED', POSITION='APPEND' )
+             OPEN ( 20, FILE='DATA_LOG'//TRIM( coupling_char )//'/'//          &
+                        myid_char, FORM='UNFORMATTED', POSITION='APPEND' )
           ENDIF
 
@@ -368,5 +373,5 @@
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ELSE
-             OPEN ( 21, FILE='PLOT2D_XY'//coupling_char,                       &
+             OPEN ( 21, FILE='PLOT2D_XY'//TRIM( coupling_char ),                       &
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ENDIF
@@ -401,6 +406,6 @@
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ELSE
-             OPEN ( 22, FILE='PLOT2D_XZ'//coupling_char, FORM='UNFORMATTED',   &
-                        POSITION='APPEND' )
+             OPEN ( 22, FILE='PLOT2D_XZ'//TRIM( coupling_char ),               &
+                        FORM='UNFORMATTED', POSITION='APPEND' )
           ENDIF
 
@@ -434,6 +439,6 @@
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ELSE
-             OPEN ( 23, FILE='PLOT2D_YZ'//coupling_char, FORM='UNFORMATTED',   &
-                        POSITION='APPEND' )
+             OPEN ( 23, FILE='PLOT2D_YZ'//TRIM( coupling_char ),               &
+                        FORM='UNFORMATTED', POSITION='APPEND' )
           ENDIF
 
@@ -541,5 +546,6 @@
           ELSE
              IF ( myid == 0  .AND.  .NOT. openfile(80)%opened_before )  THEN
-                CALL local_system( 'mkdir  PARTICLE_INFOS' // coupling_char )
+                CALL local_system( 'mkdir  PARTICLE_INFOS' //                  &
+                                   TRIM( coupling_char ) )
              ENDIF
 #if defined( __parallel ) && ! defined ( __check )
@@ -565,21 +571,23 @@
        CASE ( 81 )
 
-             OPEN ( 81, FILE='PLOTSP_X_PAR'//coupling_char, FORM='FORMATTED',  &
-                        DELIM='APOSTROPHE', RECL=1500, POSITION='APPEND' )
+             OPEN ( 81, FILE='PLOTSP_X_PAR'//TRIM( coupling_char ),            &
+                        FORM='FORMATTED', DELIM='APOSTROPHE', RECL=1500,       &
+                        POSITION='APPEND' )
 
        CASE ( 82 )
 
-             OPEN ( 82, FILE='PLOTSP_X_DATA'//coupling_char, FORM='FORMATTED', &
-                        POSITION = 'APPEND' )
+             OPEN ( 82, FILE='PLOTSP_X_DATA'//TRIM( coupling_char ),           &
+                        FORM='FORMATTED', POSITION = 'APPEND' )
 
        CASE ( 83 )
 
-             OPEN ( 83, FILE='PLOTSP_Y_PAR'//coupling_char, FORM='FORMATTED',  &
-                        DELIM='APOSTROPHE', RECL=1500, POSITION='APPEND' )
+             OPEN ( 83, FILE='PLOTSP_Y_PAR'//TRIM( coupling_char ),            &
+                        FORM='FORMATTED', DELIM='APOSTROPHE', RECL=1500,       &
+                        POSITION='APPEND' )
 
        CASE ( 84 )
 
-             OPEN ( 84, FILE='PLOTSP_Y_DATA'//coupling_char, FORM='FORMATTED', &
-                        POSITION='APPEND' )
+             OPEN ( 84, FILE='PLOTSP_Y_DATA'//TRIM( coupling_char ),           &
+                        FORM='FORMATTED', POSITION='APPEND' )
 
        CASE ( 85 )
@@ -590,5 +598,6 @@
           ELSE
              IF ( myid == 0  .AND.  .NOT. openfile(85)%opened_before )  THEN
-                CALL local_system( 'mkdir  PARTICLE_DATA' // coupling_char )
+                CALL local_system( 'mkdir  PARTICLE_DATA' //                   &
+                                   TRIM( coupling_char ) )
              ENDIF
 #if defined( __parallel ) && ! defined ( __check )
@@ -622,8 +631,8 @@
 !--       Set filename depending on unit number
           IF ( file_id == 101 )  THEN
-             filename = 'DATA_2D_XY_NETCDF' // coupling_char
+             filename = 'DATA_2D_XY_NETCDF' // TRIM( coupling_char )
              av = 0
           ELSE
-             filename = 'DATA_2D_XY_AV_NETCDF' // coupling_char
+             filename = 'DATA_2D_XY_AV_NETCDF' // TRIM( coupling_char )
              av = 1
           ENDIF
@@ -684,8 +693,8 @@
 !--       Set filename depending on unit number
           IF ( file_id == 102 )  THEN
-             filename = 'DATA_2D_XZ_NETCDF' // coupling_char
+             filename = 'DATA_2D_XZ_NETCDF' // TRIM( coupling_char )
              av = 0
           ELSE
-             filename = 'DATA_2D_XZ_AV_NETCDF' // coupling_char
+             filename = 'DATA_2D_XZ_AV_NETCDF' // TRIM( coupling_char )
              av = 1
           ENDIF
@@ -746,8 +755,8 @@
 !--       Set filename depending on unit number
           IF ( file_id == 103 )  THEN
-             filename = 'DATA_2D_YZ_NETCDF' // coupling_char
+             filename = 'DATA_2D_YZ_NETCDF' // TRIM( coupling_char )
              av = 0
           ELSE
-             filename = 'DATA_2D_YZ_AV_NETCDF' // coupling_char
+             filename = 'DATA_2D_YZ_AV_NETCDF' // TRIM( coupling_char )
              av = 1
           ENDIF
@@ -807,5 +816,5 @@
 !
 !--       Set filename
-          filename = 'DATA_1D_PR_NETCDF' // coupling_char
+          filename = 'DATA_1D_PR_NETCDF' // TRIM( coupling_char )
 
 !
@@ -847,5 +856,5 @@
 !
 !--       Set filename
-          filename = 'DATA_1D_TS_NETCDF' // coupling_char
+          filename = 'DATA_1D_TS_NETCDF' // TRIM( coupling_char )
 
 !
@@ -889,8 +898,8 @@
 !--       Set filename depending on unit number
           IF ( file_id == 106 )  THEN
-             filename = 'DATA_3D_NETCDF' // coupling_char
+             filename = 'DATA_3D_NETCDF' // TRIM( coupling_char )
              av = 0
           ELSE
-             filename = 'DATA_3D_AV_NETCDF' // coupling_char
+             filename = 'DATA_3D_AV_NETCDF' // TRIM( coupling_char )
              av = 1
           ENDIF
@@ -952,5 +961,5 @@
 !
 !--       Set filename
-          filename = 'DATA_1D_SP_NETCDF' // coupling_char
+          filename = 'DATA_1D_SP_NETCDF' // TRIM( coupling_char )
 
 !
@@ -994,5 +1003,5 @@
 
           IF ( myid_char == '' )  THEN
-             filename = 'DATA_PRT_NETCDF' // coupling_char
+             filename = 'DATA_PRT_NETCDF' // TRIM( coupling_char )
           ELSE
              filename = 'DATA_PRT_NETCDF' // TRIM( coupling_char ) // '/' //   &
@@ -1055,5 +1064,5 @@
 !
 !--       Set filename
-          filename = 'DATA_1D_PTS_NETCDF' // coupling_char
+          filename = 'DATA_1D_PTS_NETCDF' // TRIM( coupling_char )
 
 !
@@ -1097,5 +1106,6 @@
        CASE ( 117 )
 
-          OPEN ( 117, FILE='PROGRESS'//coupling_char, STATUS='REPLACE', FORM='FORMATTED' )
+          OPEN ( 117, FILE='PROGRESS'//TRIM( coupling_char ),                  &
+                      STATUS='REPLACE', FORM='FORMATTED' )
 
 
@@ -1106,5 +1116,6 @@
              mid = file_id - 200
              WRITE ( mask_char,'(I2.2)')  mid
-             filename = 'DATA_MASK_' // mask_char // '_NETCDF' // coupling_char
+             filename = 'DATA_MASK_' // mask_char // '_NETCDF' //              &
+                        TRIM( coupling_char )
              av = 0
           ELSE
@@ -1112,5 +1123,5 @@
              WRITE ( mask_char,'(I2.2)')  mid
              filename = 'DATA_MASK_' // mask_char // '_AV_NETCDF' //           &
-                  coupling_char
+                        TRIM( coupling_char )
              av = 1
           ENDIF
