Index: /palm/trunk/UTIL/surface_output_processing/surface_output_to_vtk.f90
===================================================================
--- /palm/trunk/UTIL/surface_output_processing/surface_output_to_vtk.f90	(revision 3495)
+++ /palm/trunk/UTIL/surface_output_processing/surface_output_to_vtk.f90	(revision 3496)
@@ -25,8 +25,9 @@
 ! -----------------
 ! $Id$
+! Use subroutine call for fseek instead of function call. gfortran has some
+! problems with this.
+! 
+! 3494 2018-11-06 14:51:27Z suehring
 ! Initial version
-! 
-! 3241 2018-09-12 15:02:00Z raasch
-!
 !
 ! Authors:
@@ -43,5 +44,5 @@
 !> Output is distinguished between instantaneous and time-averaged data. 
 !------------------------------------------------------------------------------!
- PROGRAM surface_output_merge
+ PROGRAM surface_output_to_vtk
 
     IMPLICIT NONE
@@ -59,5 +60,5 @@
     
     INTEGER(4)   ::  ftell                      !< intrinsic function, get current position in file
-    INTEGER(4)   ::  fseek                      !< intrinsic function, go to given position in file
+!     INTEGER(4)   ::  fseek                      !< intrinsic function, go to given position in file
     INTEGER(4)   ::  ndum                       !< return parameter of intrinsic function fseek
     
@@ -67,5 +68,5 @@
     INTEGER(iwp) ::  cycle_number               !< cycle number
     INTEGER(iwp) ::  f                          !< running index over all binary files
-    INTEGER(iwp) ::  file_id_in = 110           !< file unit for input binaray file    
+    INTEGER(iwp) ::  file_id_in = 18            !< file unit for input binaray file    
     INTEGER(iwp) ::  file_id_out = 20           !< file unit for output VTK file        
     INTEGER(iwp) ::  file_id_out_header = 19    !< file unit for temporary header file
@@ -89,8 +90,10 @@
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  points         !< point / vertex data
     REAL(wp), DIMENSION(:,:), ALLOCATABLE ::  polygons       !< polygon data
+    
+    logical :: flag
 
 !
 !-- Read namelist.
-    CALL surface_output_merge_parin
+    CALL surface_output_parin
 !
 !-- Allocate array which contains the file position in each output file,
@@ -124,15 +127,15 @@
 !
 !--    Create filename of the treated binary file.
-       CALL surface_output_merge_create_file_string
+       CALL surface_output_create_file_string
 !
 !--    Open file with surface output for processor f.
-       OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) //            &
-              TRIM( myid_char ), FORM='UNFORMATTED' )
+       OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) //                &
+              TRIM( myid_char ), FORM = 'UNFORMATTED' )
 !
 !--    Read number of vertices / points and surface elements
-       READ ( file_id_in + f )  npoints(f)
-       READ ( file_id_in + f )  npoints_total
-       READ ( file_id_in + f )  ns(f)
-       READ ( file_id_in + f )  ns_total
+       READ ( file_id_in )  npoints(f)
+       READ ( file_id_in )  npoints_total
+       READ ( file_id_in )  ns(f)
+       READ ( file_id_in )  ns_total
 
 !
@@ -142,8 +145,9 @@
 !
 !--    Read polygon data and store them in a temporary file.
-       READ ( file_id_in + f )  points
+       READ ( file_id_in )  points
 !
 !--    Obtain current file position. Will be stored for next file opening.
-       filepos(f) = ftell( file_id_in + f )
+       filepos(f) = ftell( file_id_in )
+!        CALL FTELL( file_id_in, filepos(f) )
 !
 !--    Write header information. Only one time required.
@@ -165,5 +169,5 @@
        DEALLOCATE( points )
        
-       CLOSE ( file_id_in + f )
+       CLOSE ( file_id_in )
     ENDDO
 !
@@ -172,12 +176,13 @@
 !
 !--    Create filename of the treated binary file .   
-       CALL surface_output_merge_create_file_string
+       CALL surface_output_create_file_string
 !
 !--    Open file with surface output for processor f.
-       OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) //            &
-              TRIM( myid_char ), FORM='UNFORMATTED' )
+       OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) //                &
+              TRIM( myid_char ), FORM = 'UNFORMATTED' )
 !
 !--    Move to last postion. 
-       ndum = fseek( file_id_in + f, filepos(f), 0 )
+!        ndum = fseek( file_id_in, filepos(f), 0 )
+       CALL FSEEK( file_id_in, filepos(f), 0, ndum )
 !
 !--    Allocate array for polygon data
@@ -185,9 +190,10 @@
 !
 !--    Read polygon data and store them in a temporary file.
-       READ ( file_id_in + f )  polygons
+       READ ( file_id_in )  polygons
 !
 !--    Obtain current file position after reading the local polygon data. 
 !--    Will be used for next file opening.
-       filepos(f) = ftell( file_id_in + f )
+       filepos(f) = ftell( file_id_in )
+!        CALL FTELL( file_id_in, filepos(f) )
 !
 !--    Write further header information. Only one time required.
@@ -200,5 +206,5 @@
 !--    surface element.
        DO n = 1, ns(f)
-          WRITE ( file_id_out_header, '(8I10)' )  INT (polygons(1:5,n) )
+          WRITE ( file_id_out_header, '(8I10)' )  INT( polygons(1:5,n) )
        ENDDO
 !
@@ -206,10 +212,10 @@
        DEALLOCATE( polygons )
        
-       CLOSE ( file_id_in + f )
+       CLOSE ( file_id_in )
        
     ENDDO
     
     f = 0
-    CALL surface_output_merge_create_file_string
+    CALL surface_output_create_file_string
 !
 !-- Write further header information. Only once required.
@@ -240,16 +246,17 @@
 !
 !--       Create filename of the treated binary file.            
-          CALL surface_output_merge_create_file_string
+          CALL surface_output_create_file_string
 !
 !--       Open binary file with surface output for processor f.
-          OPEN ( file_id_in + f, FILE = TRIM( path ) // TRIM( run ) //         &
-                 TRIM( myid_char ), FORM='UNFORMATTED' )
+          OPEN ( file_id_in, FILE = TRIM( path ) // TRIM( run ) //         &
+                 TRIM( myid_char ), FORM = 'UNFORMATTED' )
 !
 !--       Move to last postion. 
-          ndum = fseek( file_id_in + f, filepos(f), 0 )
+!           ndum = fseek( file_id_in, filepos(f), 0 )
+          CALL FSEEK( file_id_in, filepos(f), 0, ndum )
 !
 !--       Read string length and string indicating the output time step. 
-          READ ( file_id_in + f ) length
-          READ ( file_id_in + f ) char_time(1:length)
+          READ ( file_id_in ) length
+          READ ( file_id_in ) char_time(1:length)
 !
 !--       If string for the output time indicates the end-of-file, set the eof 
@@ -257,12 +264,12 @@
           IF ( char_time(1:length) == 'END' )  THEN
              eof(f) = .TRUE. 
-             CLOSE ( file_id_in + f )
+             CLOSE ( file_id_in )
              CYCLE
           ENDIF
 !
 !--       Read output time, and variable name.
-          READ ( file_id_in + f ) simulated_time
-          READ ( file_id_in + f ) length
-          READ ( file_id_in + f ) variable_name(1:length)
+          READ ( file_id_in ) simulated_time
+          READ ( file_id_in ) length
+          READ ( file_id_in ) variable_name(1:length)
 !
 !--       For first loop index, open the target output file. First create the
@@ -296,5 +303,5 @@
              OPEN ( file_id_out, FILE = TRIM( path ) // TRIM( char_dum ) //    & 
                     's_' // TRIM( variable_name ) // '.vtk', FORM='FORMATTED', &
-                    POSITION='APPEND' )           
+                    POSITION = 'APPEND' )           
           ENDIF
 !
@@ -302,5 +309,5 @@
           ALLOCATE( var(1:ns(f)) )
        
-          READ( file_id_in + f ) var
+          READ( file_id_in ) var
 !
 !--       Write variable data into output VTK file.
@@ -310,7 +317,8 @@
 !
 !--       Remember file position in binary file and close it.
-          filepos(f) = ftell( file_id_in + f )
-       
-          CLOSE ( file_id_in + f )
+          filepos(f) = ftell( file_id_in )
+!           CALL FTELL( file_id_in, filepos(f) )
+       
+          CLOSE ( file_id_in )
 !
 !--       Deallocate temporary array for variable data.
@@ -338,5 +346,5 @@
 !> This subroutine read the namelist file.
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_output_merge_parin
+    SUBROUTINE surface_output_parin
        
        IMPLICIT NONE
@@ -358,5 +366,5 @@
        CLOSE( file_id_parin )
        
-    END SUBROUTINE surface_output_merge_parin
+    END SUBROUTINE surface_output_parin
       
 !------------------------------------------------------------------------------!
@@ -365,5 +373,5 @@
 !> This subroutine creates the filename string of the treated binary file.
 !------------------------------------------------------------------------------!
-    SUBROUTINE surface_output_merge_create_file_string
+    SUBROUTINE surface_output_create_file_string
        
        IMPLICIT NONE
@@ -417,8 +425,8 @@
        ENDIF
        
-    END SUBROUTINE surface_output_merge_create_file_string
-    
- END PROGRAM surface_output_merge
-
-
-
+    END SUBROUTINE surface_output_create_file_string
+    
+ END PROGRAM surface_output_to_vtk
+
+
+
