Index: /palm/trunk/SOURCE/wind_turbine_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 4422)
+++ /palm/trunk/SOURCE/wind_turbine_model_mod.f90	(revision 4423)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Switched to serial output as data is aggerated before anyway.
+! 
+! 4420 2020-02-24 14:13:56Z maronga
 ! Added output control for wind turbine model
 ! 
@@ -1282,26 +1285,27 @@
 
     
-    SUBROUTINE wtm_init_output
-    
-    
-        INTEGER(iwp) ::  ntimesteps               !< number of timesteps defined in NetCDF output file
-        INTEGER(iwp) ::  ntimesteps_max = 80000   !< number of maximum timesteps defined in NetCDF output file
-        INTEGER(iwp) ::  return_value             !< returned status value of called function
-       
-        INTEGER(iwp) ::  n  !< running index       
+SUBROUTINE wtm_init_output
+    
+    
+    INTEGER(iwp) ::  ntimesteps               !< number of timesteps defined in NetCDF output file
+    INTEGER(iwp) ::  ntimesteps_max = 80000   !< number of maximum timesteps defined in NetCDF output file
+    INTEGER(iwp) ::  return_value             !< returned status value of called function
+    
+    INTEGER(iwp) ::  n  !< running index       
       
-        INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ndim !< dummy to write dimension   
-       
-       
-!
-!--    Create NetCDF output file
-       nc_filename = 'DATA_1D_TS_WTM_NETCDF' // TRIM( coupling_char )      
-       return_value = dom_def_file( nc_filename, 'netcdf4-parallel' )
+    INTEGER(iwp), DIMENSION(:), ALLOCATABLE ::  ndim !< dummy to write dimension   
+       
+       
+!
+!-- Create NetCDF output file
+    nc_filename = 'DATA_1D_TS_WTM_NETCDF' // TRIM( coupling_char )      
+    return_value = dom_def_file( nc_filename, 'netcdf4-serial' )
                                                                           
-       ntimesteps = MIN( CEILING(                                                 &
-                     ( end_time - MAX( time_turbine_on, time_since_reference_point )&
-                     ) / MAX( 0.1_wp, dt_data_output_wtm ) ), ntimesteps_max )
-
-       
+    ntimesteps = MIN( CEILING(                                                      &
+                    ( end_time - MAX( time_turbine_on, time_since_reference_point ) &
+                    ) / MAX( 0.1_wp, dt_data_output_wtm ) ), ntimesteps_max )
+
+      
+    IF ( myid == 0 )  THEN
 !
 !--    Define dimensions in output file
@@ -1522,6 +1526,7 @@
                                    attribute_name = 'units',           &
                                    value = 'degrees' )  
-                                   
-    END SUBROUTINE
+
+   ENDIF    
+END SUBROUTINE
     
 !------------------------------------------------------------------------------!
@@ -3110,145 +3115,148 @@
     
     
-       INTEGER(iwp)       ::  t_ind = 0       !< time index
+       INTEGER(iwp) ::  t_ind = 0       !< time index
    
        INTEGER(iwp) ::  return_value             !< returned status value of called function
     
-!
-!--    At the first call of this routine write the spatial coordinates.
-       IF ( .NOT. initial_write_coordinates )  THEN
+       IF ( myid == 0 ) THEN
+       
+!
+!--       At the first call of this routine write the spatial coordinates.
+          IF ( .NOT. initial_write_coordinates )  THEN
+             ALLOCATE ( output_values_1d_target(1:nturbines) )
+             output_values_1d_target = rcx(1:nturbines)
+             output_values_1d_pointer => output_values_1d_target      
+             return_value = dom_write_var( nc_filename,                              &
+                                        'x',                                         &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1/),                        &
+                                        bounds_end   = (/nturbines/) )
+
+             output_values_1d_target = rcy(1:nturbines)
+             output_values_1d_pointer => output_values_1d_target      
+             return_value = dom_write_var( nc_filename,                              &
+                                        'y',                                         &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1/),                        &
+                                        bounds_end   = (/nturbines/) )
+
+             output_values_1d_target = rcz(1:nturbines)
+             output_values_1d_pointer => output_values_1d_target      
+             return_value = dom_write_var( nc_filename,                              &
+                                        'z',                                         &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1/),                        &
+                                        bounds_end   = (/nturbines/) )                                       
+                                        
+             initial_write_coordinates = .TRUE.
+             DEALLOCATE ( output_values_1d_target )
+          ENDIF
+          
+          t_ind = t_ind + 1
+          
           ALLOCATE ( output_values_1d_target(1:nturbines) )
-          output_values_1d_target = rcx(1:nturbines)
-          output_values_1d_pointer => output_values_1d_target      
-          return_value = dom_write_var( nc_filename,                              &
-                                     'x',                                         &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1/),                        &
-                                     bounds_end   = (/nturbines/) )
-
-          output_values_1d_target = rcy(1:nturbines)
-          output_values_1d_pointer => output_values_1d_target      
-          return_value = dom_write_var( nc_filename,                              &
-                                     'y',                                         &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1/),                        &
-                                     bounds_end   = (/nturbines/) )
-
-          output_values_1d_target = rcz(1:nturbines)
-          output_values_1d_pointer => output_values_1d_target      
-          return_value = dom_write_var( nc_filename,                              &
-                                     'z',                                         &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1/),                        &
-                                     bounds_end   = (/nturbines/) )                                       
+          output_values_1d_target = omega_rot(:)
+          output_values_1d_pointer => output_values_1d_target
+          
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'rotor_speed',                               &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = omega_gen(:)
+          output_values_1d_pointer => output_values_1d_target    
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'generator_speed',                           &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = torque_gen_old(:)
+          output_values_1d_pointer => output_values_1d_target    
+
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'generator_torque',                          &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = torque_total(:)
+          output_values_1d_pointer => output_values_1d_target    
+    
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'rotor_torque',                              &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = pitch_add(:)
+          output_values_1d_pointer => output_values_1d_target    
+
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'pitch_angle',                               &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = torque_gen_old(:)*omega_gen(:)*gen_eff
+          output_values_1d_pointer => output_values_1d_target    
+    
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'generator_power',                           &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          DO inot = 1, nturbines
+             output_values_1d_target(inot) = torque_total(inot)*omega_rot(inot)*air_dens
+          ENDDO
+          output_values_1d_pointer => output_values_1d_target    
                                         
-          initial_write_coordinates = .TRUE.
-          DEALLOCATE ( output_values_1d_target )
-       ENDIF
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'rotor_power',                               &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = thrust_rotor(:)
+          output_values_1d_pointer => output_values_1d_target    
+    
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'rotor_thrust',                              &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = wdir(:)*180.0_wp/pi
+          output_values_1d_pointer => output_values_1d_target    
           
-       t_ind = t_ind + 1
-          
-       ALLOCATE ( output_values_1d_target(1:nturbines) )
-       output_values_1d_target = omega_rot(:)
-       output_values_1d_pointer => output_values_1d_target
-          
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'rotor_speed',                               &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = omega_gen(:)
-       output_values_1d_pointer => output_values_1d_target    
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'generator_speed',                           &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = torque_gen_old(:)
-       output_values_1d_pointer => output_values_1d_target    
-
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'generator_torque',                          &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = torque_total(:)
-       output_values_1d_pointer => output_values_1d_target    
-    
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'rotor_torque',                              &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = pitch_add(:)
-       output_values_1d_pointer => output_values_1d_target    
-
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'pitch_angle',                               &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = torque_gen_old(:)*omega_gen(:)*gen_eff
-       output_values_1d_pointer => output_values_1d_target    
-    
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'generator_power',                           &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       DO inot = 1, nturbines
-          output_values_1d_target(inot) = torque_total(inot)*omega_rot(inot)*air_dens
-       ENDDO
-       output_values_1d_pointer => output_values_1d_target    
-                                        
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'rotor_power',                               &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = thrust_rotor(:)
-       output_values_1d_pointer => output_values_1d_target    
-    
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'rotor_thrust',                              &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = wdir(:)*180.0_wp/pi
-       output_values_1d_pointer => output_values_1d_target    
-          
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'wind_direction',                            &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_1d_target = (phi_yaw(:))*180.0_wp/pi
-       output_values_1d_pointer => output_values_1d_target    
-
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'yaw_angle',                                 &
-                                     values_realwp_1d = output_values_1d_pointer, &
-                                     bounds_start = (/1, t_ind/),                 &
-                                     bounds_end   = (/nturbines, t_ind /) )
-
-       output_values_0d_target = time_since_reference_point
-       output_values_0d_pointer => output_values_0d_target
-    
-       return_value = dom_write_var( nc_filename,                                 &
-                                     'time',                                      &
-                                     values_realwp_0d = output_values_0d_pointer, &
-                                     bounds_start = (/t_ind/),                    &
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'wind_direction',                            &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_1d_target = (phi_yaw(:))*180.0_wp/pi
+          output_values_1d_pointer => output_values_1d_target    
+
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'yaw_angle',                                 &
+                                        values_realwp_1d = output_values_1d_pointer, &
+                                        bounds_start = (/1, t_ind/),                 &
+                                        bounds_end   = (/nturbines, t_ind /) )
+
+          output_values_0d_target = time_since_reference_point
+          output_values_0d_pointer => output_values_0d_target
+    
+          return_value = dom_write_var( nc_filename,                                 &
+                                        'time',                                      &
+                                        values_realwp_0d = output_values_0d_pointer, &
+                                           bounds_start = (/t_ind/),                    &
                                      bounds_end   = (/t_ind/) )         
           
-       DEALLOCATE ( output_values_1d_target )
-       
+          DEALLOCATE ( output_values_1d_target )
+       
+       ENDIF
     
     END SUBROUTINE wtm_data_output
