Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 1209)
+++ palm/trunk/SCRIPTS/mbuild	(revision 1210)
@@ -22,9 +22,12 @@
 # Current revisions:
 # ------------------
-# adjustments for CSC Helsinki (lccrayf)
+# fftw support added
 #
 # Former revisions:
 # -----------------
 # $Id$
+#
+# 1197 2013-07-04 06:19:45Z raasch
+# adjustments for CSC Helsinki (lccrayf)
 #
 # 1099 2013-02-10 01:47:43Z raasch
@@ -450,4 +453,6 @@
     fi
 
+    fftw_inc=""
+    fftw_lib=""
     modules=""
     netcdf_inc=""
@@ -705,5 +710,5 @@
 
 
-       # NETCDF-OPTIONEN ERMITTELN
+       # get netCDF options
     line=""
     grep  "$remote_host_string" $config_file | grep "%netcdf_inc"  >  $tmp_mbuild
@@ -738,4 +743,43 @@
              # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
           netcdf_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+       fi
+
+    done < $tmp_mbuild
+
+
+
+       # get fftw options
+    line=""
+    grep  "$remote_host_string" $config_file | grep "%fftw_inc"  >  $tmp_mbuild
+    while read line1
+    do
+
+       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
+       then
+          line="$line1"
+       fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          fftw_inc=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
+       fi
+
+    done < $tmp_mbuild
+
+    line=""
+    grep  "$remote_host_string" $config_file | grep "%fftw_lib"  >  $tmp_mbuild
+    while read line1
+    do
+
+       if [[ $(echo $line1 | cut -d" " -s -f3-) = "$remote_host_string" ]]
+       then
+          line="$line1"
+       fi
+
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          fftw_lib=`echo $line | cut -d" " -s -f2 | sed 's/::/%DUM%/g' | sed 's/:/ /g' | sed 's/%DUM%/:/g'`
        fi
 
@@ -785,6 +829,6 @@
           found=true
 
-             # NETCDF-INCLUDEVERZEICHNIS HINZUFUEGEN
-          compiler_options="$compiler_options $netcdf_inc"
+             # add include paths for netCDF and fftw
+          compiler_options="$compiler_options $netcdf_inc $fftw_inc"
        fi
 
@@ -857,6 +901,6 @@
           found=true
 
-             # NETCDF-LIBRARY HINZUFUEGEN
-          loader_options="$loader_options $netcdf_lib"
+             # add netCDF- and fftw-library
+          loader_options="$loader_options $netcdf_lib $fftw_lib"
        fi
 
@@ -1303,4 +1347,5 @@
           echo "  *** execute \"make\" on local host"
 
+          echo "make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"  2>&1 | tee ${remote_host}_last_make_protokoll"
           make  $make_options  PROG=$mainprog  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"  2>&1 | tee ${remote_host}_last_make_protokoll
 
Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 1209)
+++ palm/trunk/SCRIPTS/mrun	(revision 1210)
@@ -22,5 +22,5 @@
 # Current revisions:
 # ------------------
-#
+# fftw support added
 #
 # Former revisions:
@@ -143,4 +143,7 @@
  executable=""
  execution_error=false
+ fftw_inc=""
+ fftw_lib=""
+ fftw_support=false
  fimm=false
  fname=test
@@ -1917,6 +1920,6 @@
 
     # COMPILE- UND LINK-OPTIONEN BESTIMMEN
- fopts="$fopts $netcdf_inc $dvr_inc"
- lopts="$lopts $netcdf_lib $dvr_lib"
+ fopts="$fopts $netcdf_inc $fftw_inc $dvr_inc"
+ lopts="$lopts $netcdf_lib $fftw_lib $dvr_lib"
  ROPTS="$ropts"
 # if [[ ( $(echo $host | cut -c1-3) = nec  ||  $(echo $host | cut -c1-3) = ibm  ||  $host = lckyoto  ||  $host = lcsgih  ||  $host = lcsgib  ||  $host = lctit  ||  $host = lcfimm  ||  $host = lcflow  ||  $host = lcxe6 ||  $host = lcxt5m || $host = lck || $host = lckiaps || $host = lckordi || $host = lcsb || $host )  &&  -n $numprocs ]]
Index: palm/trunk/SOURCE/Makefile
===================================================================
--- palm/trunk/SOURCE/Makefile	(revision 1209)
+++ palm/trunk/SOURCE/Makefile	(revision 1210)
@@ -20,5 +20,5 @@
 # Current revisions:
 # ------------------
-# 
+# object file list replaced by one line statement
 #
 # Former revisions:
@@ -121,5 +121,5 @@
 PROG =  palm
 
-RCS =   advec_s_bc.f90 advec_s_pw.f90 advec_s_up.f90 advec_ws.f90 \
+SOURCES = advec_s_bc.f90 advec_s_pw.f90 advec_s_up.f90 advec_ws.f90 \
 	advec_u_pw.f90 advec_u_up.f90 advec_v_pw.f90 advec_v_up.f90 \
 	advec_w_pw.f90 advec_w_up.f90 average_3d_data.f90 boundary_conds.f90 \
@@ -175,49 +175,5 @@
 	write_3d_binary.f90 write_compressed.f90 write_var_list.f90
 
-OBJS =  advec_s_bc.o advec_s_pw.o advec_s_up.o advec_u_pw.o advec_u_up.o \
-	advec_ws.o advec_v_pw.o advec_v_up.o advec_w_pw.o advec_w_up.o \
-	average_3d_data.o boundary_conds.o buoyancy.o \
-	calc_liquid_water_content.o calc_precipitation.o calc_radiation.o \
-	calc_spectra.o check_for_restart.o check_open.o check_parameters.o \
-	close_file.o compute_vpt.o coriolis.o cpu_log.o cpu_statistics.o \
-	cuda_fft_interfaces.o data_log.o data_output_dvrp.o data_output_mask.o \
-	data_output_profiles.o data_output_ptseries.o \
-	data_output_spectra.o data_output_tseries.o data_output_2d.o \
-	data_output_3d.o diffusion_e.o diffusion_s.o diffusion_u.o \
-	diffusion_v.o diffusion_w.o diffusivities.o disturb_field.o \
-	disturb_heatflux.o eqn_state_seawater.o exchange_horiz.o \
-	exchange_horiz_2d.o fft_xy.o flow_statistics.o global_min_max.o \
-	header.o impact_of_latent_heat.o inflow_turbulence.o init_1d_model.o \
-	init_3d_model.o init_advec.o init_cloud_physics.o init_coupling.o \
-	init_dvrp.o init_grid.o init_masks.o init_ocean.o init_pegrid.o \
-	init_pt_anomaly.o init_rankine.o init_slope.o \
-	interaction_droplets_ptq.o local_flush.o local_getenv.o local_stop.o \
-	local_system.o local_tremain.o local_tremain_ini.o lpm.o lpm_advec.o \
-	lpm_boundary_conds.o lpm_calc_liquid_water_content.o \
-	lpm_collision_kernels.o lpm_data_output_particles.o \
-	lpm_droplet_collision.o lpm_droplet_condensation.o \
-	lpm_exchange_horiz.o lpm_extend_particle_array.o lpm_extend_tails.o \
-	lpm_extend_tail_array.o lpm_init.o lpm_init_sgs_tke.o \
-	lpm_pack_arrays.o lpm_read_restart_file.o lpm_release_set.o \
-	lpm_set_attributes.o lpm_sort_arrays.o lpm_write_exchange_statistics.o \
-	lpm_write_restart_file.o message.o microphysics.o modules.o netcdf.o \
-	package_parin.o palm.o parin.o plant_canopy_model.o poisfft.o \
-	poisfft_hybrid.o poismg.o prandtl_fluxes.o pres.o print_1d.o \
-	production_e.o prognostic_equations.o random_function.o random_gauss.o \
-	read_3d_binary.o read_var_list.o run_control.o \
-	set_slicer_attributes_dvrp.o singleton.o sor.o \
-	subsidence.o sum_up_3d_data.o surface_coupler.o \
-	swap_timelevel.o temperton_fft.o time_integration.o time_to_string.o \
-	timestep.o timestep_scheme_steering.o transpose.o \
-	user_3d_data_averaging.o user_actions.o user_additional_routines.o \
-	user_check_data_output.o user_check_data_output_pr.o \
-	user_check_parameters.o user_data_output_2d.o user_data_output_3d.o \
-	user_data_output_mask.o user_data_output_dvrp.o \
-	user_define_netcdf_grid.o user_dvrp_coltab.o user_header.o \
-	user_init.o user_init_3d_model.o user_init_grid.o \
-	user_init_plant_canopy.o user_last_actions.o user_lpm_advec.o \
-	user_lpm_init.o user_lpm_set_attributes.o user_module.o user_parin.o \
-	user_read_restart_data.o user_spectra.o user_statistics.o \
-	wall_fluxes.o write_3d_binary.o write_compressed.o write_var_list.o
+OBJS=$(SOURCES:.f90=.o)
 
 CC = cc
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 1209)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 1210)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-!
+! check for fftw
 !
 ! Former revisions:
@@ -707,4 +707,5 @@
     IF ( fft_method /= 'singleton-algorithm'  .AND.  &
          fft_method /= 'temperton-algorithm'  .AND.  &
+         fft_method /= 'fftw'                 .AND.  &
          fft_method /= 'system-specific' )  THEN
        message_string = 'unknown fft-algorithm: fft_method = "' // &
Index: palm/trunk/SOURCE/fft_xy.f90
===================================================================
--- palm/trunk/SOURCE/fft_xy.f90	(revision 1209)
+++ palm/trunk/SOURCE/fft_xy.f90	(revision 1210)
@@ -20,5 +20,5 @@
 ! Current revisions:
 ! -----------------
-!
+! fftw added
 !
 ! Former revisions:
@@ -82,4 +82,6 @@
 #if defined( __cuda_fft )
     USE ISO_C_BINDING
+#elif defined( __fftw )
+    USE, INTRINSIC ::  ISO_C_BINDING
 #endif
     USE precision_kind
@@ -113,4 +115,10 @@
     INTEGER(C_INT), SAVE ::  plan_xf, plan_xi, plan_yf, plan_yi
     INTEGER, SAVE        ::  total_points_x_transpo, total_points_y_transpo
+#elif defined( __fftw )
+    INCLUDE  'fftw3.f03'
+    INTEGER(KIND=C_INT) ::  nx_c, ny_c
+    COMPLEX(KIND=C_DOUBLE_COMPLEX), DIMENSION(:), ALLOCATABLE, SAVE ::  x_out, y_out
+    REAL(KIND=C_DOUBLE), DIMENSION(:), ALLOCATABLE, SAVE            ::  x_in, y_in
+    TYPE(C_PTR), SAVE ::  plan_xf, plan_xi, plan_yf, plan_yi
 #endif
 
@@ -244,4 +252,21 @@
           CALL set99( trigs_y, ifax_y, ny+1 )
 
+       ELSEIF ( fft_method == 'fftw' )  THEN
+!
+!--       FFTW
+#if defined( __fftw )
+          nx_c = nx+1
+          ny_c = ny+1
+          ALLOCATE( x_in(0:nx+2), y_in(0:ny+2), x_out(0:(nx+1)/2), &
+                    y_out(0:(ny+1)/2) )
+          plan_xf = FFTW_PLAN_DFT_R2C_1D( nx_c, x_in, x_out, FFTW_ESTIMATE )
+          plan_xi = FFTW_PLAN_DFT_C2R_1D( nx_c, x_out, x_in, FFTW_ESTIMATE )
+          plan_yf = FFTW_PLAN_DFT_R2C_1D( ny_c, y_in, y_out, FFTW_ESTIMATE )
+          plan_yi = FFTW_PLAN_DFT_C2R_1D( ny_c, y_out, y_in, FFTW_ESTIMATE )
+#else
+          message_string = 'preprocessor switch for fftw is missing'
+          CALL message( 'fft_init', 'PA0080', 1, 2, 0, 6, 0 )
+#endif
+
        ELSEIF ( fft_method == 'singleton-algorithm' )  THEN
 
@@ -413,4 +438,50 @@
           ENDIF
 
+       ELSEIF ( fft_method == 'fftw' )  THEN
+
+#if defined( __fftw )
+          IF ( forward_fft )  THEN
+
+             !$OMP PARALLEL PRIVATE ( work, i, j, k )
+             !$OMP DO
+             DO  k = nzb_x, nzt_x
+                DO  j = nys_x, nyn_x
+
+                   x_in(0:nx) = ar(0:nx,j,k)
+                   CALL FFTW_EXECUTE_DFT_R2C( plan_xf, x_in, x_out )
+
+                   DO  i = 0, (nx+1)/2
+                      ar(i,j,k) = REAL( x_out(i) ) / ( nx+1 )
+                   ENDDO
+                   DO  i = 1, (nx+1)/2 - 1
+                      ar(nx+1-i,j,k) = AIMAG( x_out(i) ) / ( nx+1 )
+                   ENDDO
+
+                ENDDO
+             ENDDO
+             !$OMP END PARALLEL
+
+         ELSE
+             !$OMP PARALLEL PRIVATE ( work, i, j, k )
+             !$OMP DO
+             DO  k = nzb_x, nzt_x
+                DO  j = nys_x, nyn_x
+
+                   x_out(0) = CMPLX( ar(0,j,k), 0.0 )
+                   DO  i = 1, (nx+1)/2 - 1
+                      x_out(i)   = CMPLX( ar(i,j,k), ar(nx+1-i,j,k) )
+                   ENDDO
+                   x_out((nx+1)/2) = CMPLX( ar((nx+1)/2,j,k), 0.0 )
+
+                   CALL FFTW_EXECUTE_DFT_C2R( plan_xi, x_out, x_in)
+                   ar(0:nx,j,k) = x_in(0:nx)
+
+                ENDDO
+             ENDDO
+             !$OMP END PARALLEL
+
+         ENDIF
+#endif
+
        ELSEIF ( fft_method == 'system-specific' )  THEN
 
@@ -924,4 +995,51 @@
           ENDIF
 
+       ELSEIF ( fft_method == 'fftw' )  THEN
+
+#if defined( __fftw )
+          IF ( forward_fft )  THEN
+
+             !$OMP PARALLEL PRIVATE ( work, i, j, k )
+             !$OMP DO
+             DO  k = nzb_y, nzt_y
+                DO  i = nxl_y, nxr_y
+
+                   y_in(0:ny) = ar(0:ny,i,k)
+                   CALL FFTW_EXECUTE_DFT_R2C( plan_yf, y_in, y_out )
+
+                   DO  j = 0, (ny+1)/2
+                      ar(j,i,k) = REAL( y_out(j) )  /(ny+1)
+                   ENDDO
+                   DO  j = 1, (ny+1)/2 - 1
+                      ar(ny+1-j,i,k) = AIMAG( y_out(j) )  /(ny+1)
+                   ENDDO
+
+                ENDDO
+             ENDDO
+             !$OMP END PARALLEL
+
+          ELSE
+
+             !$OMP PARALLEL PRIVATE ( work, i, j, k )
+             !$OMP DO
+             DO  k = nzb_y, nzt_y
+                DO  i = nxl_y, nxr_y
+
+                   y_out(0) = CMPLX( ar(0,i,k), 0.0 )
+                   DO  j = 1, (ny+1)/2 - 1
+                      y_out(j) = CMPLX( ar(j,i,k), ar(ny+1-j,i,k) )
+                   ENDDO
+                   y_out((ny+1)/2) = CMPLX( ar((ny+1)/2,i,k), 0.0 )
+
+                   CALL FFTW_EXECUTE_DFT_C2R( plan_yi, y_out, y_in )
+                   ar(0:ny,i,k) = y_in(0:ny)
+
+                ENDDO
+             ENDDO
+             !$OMP END PARALLEL
+
+          ENDIF
+#endif
+
        ELSEIF ( fft_method == 'system-specific' )  THEN
 
