Index: palm/trunk/SCRIPTS/mbuild
===================================================================
--- palm/trunk/SCRIPTS/mbuild	(revision 806)
+++ palm/trunk/SCRIPTS/mbuild	(revision 807)
@@ -123,4 +123,7 @@
      # 27/11/11 - Siggi - Bugfix for make options setting (-j) 
      # 12/12/11 - BjornM- added mrun GUI to ulitity programs
+     # 25/01/12 - BjornM- compilation of check_namelist_files (namelist file 
+     #                    check program) has been added to the utility branch),
+     #                    modfified the compilation of mrungui
 
 
@@ -336,5 +339,10 @@
  done < $tmp_mbuild
 
-
+ if [[ $found = false ]]
+ then
+    printf "\n  +++ no \%depository_path found in" 
+    printf "\n                            $config_file"
+    locat=depository_path; exit
+  fi
 
     # CHECK, IF A MAIN PROGRAM HAS BEEN DEFINED IN THE CONFIG-FILE
@@ -398,4 +406,21 @@
     printf "\n\n  *** tar of makefile and source files in $local_source_path"  
     tar -cf  ${mainprog}_sources.tar  Makefile  *.$suf
+    printf "\n"
+
+ else
+    cd  $local_source_path
+    printf "\n\n  *** tar of makefile and source files in $local_source_path"  
+ 
+    cat Makefile_check|while read line
+    do
+       line=$(echo $line|grep RCS)
+       if [[ $line == *"RCS"* ]]
+       then
+          line=$(echo $line|sed 's/RCS = //g')
+          break
+       fi
+    done
+
+    tar -cf  ${mainprog}_sources_check.tar  Makefile_check  $line
     printf "\n"
 
@@ -1364,5 +1389,7 @@
           make  $make_options  BLOCK=$block  F90=$compiler_name  F90_SER=$compiler_name_ser  COPT="$cpp_options"  F90FLAGS="$compiler_options"  LDFLAGS="$loader_options"
 
-             # check if qmake is available and compile mrungui in that case
+             # CHECK IF QMAKE IS AVAILABLE AND COMPILE MRUNGUI
+          printf "\n\n"
+          echo "  *** compiling the mrun GUI"
           if which qmake >/dev/null; then
              cd mrungui
@@ -1374,13 +1401,30 @@
              cd ..
           else
-             echo "  +++ no qmake found. The mrun GUI (optional) cannot be compiled."
-          fi
-
-
-          cd  -  > /dev/null
-       fi
-
-    fi
-
+             echo "  +++ no qmake found. The (optional) GUI will not be compiled."
+          fi
+
+             # COMPILE CHECK_NAMELIST_FILES
+          printf "\n\n"
+          echo "  *** compiling check_namelist_files ..."
+
+          check_depository_path=${local_source_path}/../UTIL
+          cd $check_depository_path
+          mkdir check_tmp
+          mv ${local_source_path}/${mainprog}_sources_check.tar ./check_tmp
+          cd check_tmp
+          tar -xf  ${mainprog}_sources_check.tar
+          rm -rf ${mainprog}_sources_check.tar
+
+          copts_check="-cpp -D_parallel -D__check"
+          make  -f Makefile_check $make_options F90=$compiler_name_ser  COPT="$copts_check"
+
+          tar -cf  check_namelist_files.tar Makefile_check check_namelist_files.x *.f90 *.o *.mod
+          mv check_namelist_files.tar $check_depository_path
+          mv check_namelist_files.x $PALM_BIN
+          cd $check_depository_path
+          rm -rf check_tmp
+
+       fi
+    fi
  done
 
Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 806)
+++ palm/trunk/SCRIPTS/mrun	(revision 807)
@@ -234,4 +234,7 @@
      # 15/09/11 - Siggi  - new option -w tp set the maximum number of parallel
      #                     io streams, option -T is obligatory from now on
+     # 25/01/12 - BjornM - a namelist file check prior to the model run has
+     #                     been implemented (check_namelist_files). 
+     #                     New option -z can be used to skip the check
 
  
@@ -248,4 +251,5 @@
  archive_save=true
  archive_system=none
+ check_namelist_files=true
  compiler_name=""
  cond1=""
@@ -311,4 +315,5 @@
  package_list=""
  punkte="..........................................................."
+ p3d_suffix=""
  queue=none
  read_from_config=""
@@ -449,4 +454,5 @@
     # BEI TERMINAL-BREAK:
  trap 'rm -rf  $working_directory/tmp_mrun
+       rm -rf  $working_directory/tmp_check_namelist_files
        [[ $tmpcreate = true ]]  &&  (cd; rm -rf $TEMPDIR)
        if [[ -f ~/job_queue/JOBINFO.$QSUB_REQID ]]
@@ -479,5 +485,5 @@
     # SHELLSCRIPT-OPTIONEN EINLESEN UND KOMMANDO NEU ZUSAMMENSETZEN, FALLS ES
     # FUER FOLGEJOBS BENOETIGT WIRD
- while  getopts  :a:AbBc:Cd:D:Fg:G:h:H:i:IkK:m:M:n:o:O:p:P:q:r:R:s:St:T:u:U:vw:xX:yY: option
+ while  getopts  :a:AbBc:Cd:D:Fg:G:h:H:i:IkK:m:M:n:o:O:p:P:q:r:R:s:St:T:u:U:vw:xX:yY:z option
  do
    case  $option  in
@@ -521,4 +527,5 @@
        (y)   ocean_file_appendix=true; mc="$mc -y";;
        (Y)   run_coupled_model=true; coupled_dist=$OPTARG; mc="$mc -Y'$OPTARG'";;
+       (z)   check_namelist_files=false; mc="$mc -z";;
        (\?)  printf "\n  +++ unknown option $OPTARG \n"
              printf "\n  --> type \"$0 ?\" for available options \n"
@@ -2394,10 +2401,280 @@
     fi
  fi
- 
-
-
-
-     # FALLS AUF DIESER MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
-     # CHENDE AKTIONEN DURCHGEFUEHRT
+
+#### PERFORM PARAMETER FILE CHECK (COUPLED RUNS ARE NOT SUPPORTED YET)
+ if [[ $check_namelist_files == true && $fromhost == $localhost && $run_coupled_model == false ]]
+ then
+    if [[ $ocean_file_appendix == true ]]
+    then
+       d3par_string="d3o#"
+       d3fpar_string="d3of"
+    else
+       d3par_string="d3#"
+       d3fpar_string="d3f"
+    fi
+
+    tmp_check=${working_directory}/tmp_check
+
+#   GET PARAMETER FILE SUFFIX (USUALLY "_P3D")
+    line=""
+    found=false
+    grep  "$d3par_string" $config_file | grep "PARIN"  >  $tmp_check
+    while read line1
+    do
+       line="$line1"
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+             # EVENTUELLE DOPPELPUNKTE AUS OPTIONSSTRING ENTFERNEN
+          p3d_suffix=`echo $line | tr -s " " | cut -d" " -s -f5`
+          found=true
+       fi
+    done < $tmp_check
+
+    if [[ $found = false ]]
+    then
+       printf "\n  +++ no PARIN list entry found for $d3par_string in the configuration file."
+
+       locat=check_namelist; exit
+    fi
+
+#   GET RESTART PARAMETER FILE SUFFIX (USUALLY "_P3DF"). THIS FILE MIGHT IS
+#   NOT NECESSARILY REQUIRED
+    line=""
+    found=false
+    grep  "d3f" $config_file | grep "PARIN"  >  $tmp_check
+    while read line1
+    do
+       line="$line1"
+       if [[ "$line" != ""  &&  $(echo $line | cut -c1) != "#" ]]
+       then
+          p3df_suffix=`echo $line | tr -s " " | cut -d" " -s -f5`
+          found=true
+       fi
+    done < $tmp_check
+
+    if [[ $found = false ]]
+    then
+       printf "\n  +++ no PARIN list entry found for d3f in the configuration file."
+    fi
+
+    rm -rf ${working_directory}/tmp_check
+
+#   DEFINE VARIABLES FOR FREQUENTLY USED DIRECTORIES
+    check_depository="${working_directory}/trunk/UTIL"
+    check_sources="${working_directory}/tmp_check_namelist_files"
+
+#   CHECK IF THE A P3DF FILE MUST BE CHECKED
+    for  item  in  $input_list
+    do
+       if [[ "$item" == "restart" || "$item" == d3f || "$item" == d3of ]]
+       then
+          check_restart=1
+       else
+          check_restart=0
+       fi
+    done
+
+#   ERROR IF NO PARAMETER FILE WAS FOUND, OTHERWISE PROCEED
+    if [[ ! -f $working_directory/JOBS/$fname/INPUT/${fname}${p3d_suffix} ]]
+    then
+       printf "\n\n  +++ ERROR: parameter file (${fname}${p3d_suffix}) not found." 
+       locat=check_namelist; exit
+    fi
+   
+#   CHECK IF THE RESTART PARAMETER FILE EXISTS (IF NECESSARY)
+    if  [[ $check_restart == 1 ]]
+    then
+       if [[ ! -f $working_directory/JOBS/$fname/INPUT/${fname}${p3df_suffix} ]]
+       then
+          printf "\n\n  +++ WARNING: restart parameter file (${fname}${p3df_suffix}) is missing."  
+          check_restart=0
+          answer=dummy
+          printf "\n\n"
+
+          while [[ "$answer" != c  &&  "$answer" != C  && "$answer" != a  &&  "$answer" != A ]]
+          do
+             printf " >>> continue anyway (c(ontinue)/a(bort)) ?  "
+             read  answer
+          done
+          if [[ $answer = a  ||  $answer = A ]]
+          then
+             printf "\n  +++ Aborting...."
+             locat=normal; exit
+          fi
+       else
+          check_restart=1
+       fi
+    fi
+
+#   CREATE TEMPORARY SOURCES_FOR_CHECK PATH
+    mkdir $check_sources
+    cd $check_sources
+
+#   CHECK FOR USER CODE, OTHERWISE USE THE PRECOMPILED CHECK_NAMELIST_FILES.X
+    if [[ -d $working_directory/USER_CODE/$fname ]]
+    then
+       printf "\n\n  *** copying files from $check_depository" 
+       cp $check_depository/check_namelist_files.tar ./
+
+       printf "\n\n  *** untar of makefile and source files in $check_sources"
+       tar -xf check_namelist_files.tar  >  /dev/null  2>&1
+
+       printf "\n\n  *** adding user code." 
+       cp $working_directory/USER_CODE/$fname/* ./
+       touch check_namelist_files.f90
+
+#      GET COMPILER OPTIONS AND PERFORM MAKE
+       printf "\n\n  *** compiling code if necessary...\n"
+       copts_check="-cpp -D_parallel -D__check"
+       make -f Makefile_check F90=$compiler_name_ser  COPT="$copts_check"
+
+#      GET MAKE OUTPUT
+       if [[ $? != 0 ]]
+       then
+          rm -rf  $check_sources
+          locat=check_namelist; exit
+       fi
+    else
+       cp $PALM_BIN/check_namelist_files.x ./
+    fi
+
+    cp $working_directory/JOBS/$fname/INPUT/${fname}${p3d_suffix} ./PARIN
+    if [[ $check_restart == 1 ]] 
+    then
+       cp $working_directory/JOBS/$fname/INPUT/${fname}${p3df_suffix} ./PARINF   
+    fi
+
+#   CREATE ENVPAR FILE, WHICH IS NEEDED BY CHECK_NAMELIST_FILES.X
+    cat  >  ENVPAR  <<  %%END%%
+ &envpar  run_identifier = '$fname', host = '$localhost',
+	    write_binary = '$write_binary', tasks_per_node = $tasks_per_node,
+	    maximum_parallel_io_streams = $maximum_parallel_io_streams,
+	    maximum_cpu_time_allowed = ${cpumax}.,
+	    revision = '$global_revision',
+	    local_dvrserver_running = $local_dvrserver_running /
+
+%%END%%
+
+#   SAFETY CHECK: ONLY PROCEED IF THE PARAMETER CHECK PROGRAM WAS PROPERLY COMPILED
+    if [[ ! -f check_namelist_files.x ]] then
+       printf "\n  +++ WARNING: check_namelist_files.x not found."
+       answer=dummy
+       printf "\n\n"
+       while [[ "$answer" != c  &&  "$answer" != C  && "$answer" != a  &&  "$answer" != A ]]
+       do
+          printf " >>> continue anyway (c(ontinue)/a(bort)) ?  "
+          read  answer
+       done
+       if [[ $answer = a  ||  $answer = A ]]
+       then
+          printf "\n  +++ Aborting..."
+          rm -rf  $check_sources
+          locat=normal; exit
+       else
+          printf "\n  *** Skipping parameter file check."
+       fi       
+    else
+#      STARTING THE PARAMETER FILE CHECK
+       printf "\n\n  *** starting parameter file check..."
+
+#      CHECKING THE P3D FILE
+       printf "\n\n      (1) checking $fname$p3d_suffix"  
+       echo "$numprocs 0" > VARIN
+       errors=`./check_namelist_files.x < VARIN 2>&1`
+
+       check_error=false
+       if [[ "$errors" == "" ]]
+       then
+          printf " --> o.k."
+       else
+          printf " --> failed."
+          check_error=true
+          printf "\n\n  $errors"
+       fi
+
+#      CHECKING THE PD3F FILE IF NECESSARY
+       if [[ $check_restart == 1 && $check_error == false ]]
+       then
+          printf "\n\n      (2) checking $fname$p3df_suffix"  
+
+#         FIRST CHECK IF INITIALIZING_ACTIONS="READ_RESTART_DATA" IS SET IN &INIPAR LIST
+          found=false
+          cat PARINF|while read line
+          do
+             line=$(echo $line|sed 's/ //g')
+             if [[ $line == *"&inipar"* ]]
+             then
+                start_search=true
+             fi 
+
+             if [[ $start_search == true ]]
+             then
+                if [[ $line == *"initializing_actions='read_restart_data'"* ]]
+                then
+                   found=true
+                   break
+                fi
+             fi
+
+             if [[ $line == *"/"* ]]
+             then
+                start_search=false
+             fi 
+
+          done
+
+          if [[ $found = false ]]
+          then
+             printf "\n\n  +++ ERROR: initializing_actions = 'read_restart_data' not found"
+             printf "\n      in &inipar list in $fname$p3df_suffix."
+             rm -rf  $check_sources
+             locat=check_namelist; exit
+          fi
+
+          echo "$numprocs 1" > VARIN
+          errors=`./check_namelist_files.x < VARIN 2>&1`
+
+          if [[ "$errors" == "" ]]
+          then
+             printf " --> o.k."
+          else
+             printf " --> failed."
+             check_error=true
+             printf "\n\n  $errors"
+          fi
+       fi
+    
+#      REPORT ERRORS AND CONTINUE/EXIT
+       if [[ $check_error == true ]]
+       then
+          printf "\n  +++ errors found in the parameter file!\n"
+          answer=dummy
+          printf "\n\n"
+
+          while [[ "$answer" != c  &&  "$answer" != C  && "$answer" != a  &&  "$answer" != A ]]
+          do
+          printf " >>> continue anyway (c(ontinue)/a(bort)) ?  "
+          read  answer
+          done
+
+          if [[ $answer = a  ||  $answer = A ]]
+          then
+             printf "\n  +++ Aborting..."
+             rm -rf  $check_sources
+             locat=normal; exit
+          fi
+        else
+          printf "\n\n  *** parameter file(s) seem(s) to be o.k.\n"
+        fi
+        rm -rf $check_sources
+    fi
+ else
+    printf "\n\n  +++ skipping parameter file check\n" 
+ fi
+
+ cd $working_directory
+
+    # FALLS AUF DIESER MASCHINE GERECHNET WERDEN SOLL, WERDEN JETZT ENTSPRE-
+    # CHENDE AKTIONEN DURCHGEFUEHRT
  if [[ $do_batch = false ]]
  then
@@ -2588,4 +2865,5 @@
           [[ "$module_calls" != "" ]]  &&  eval $module_calls
           make $mopts -f Makefile PROG=a.out  F90=$compiler_name  COPT="$cpp_options"  F90FLAGS="$fopts"  LDFLAGS="$lopts"
+
        fi
 
Index: palm/trunk/SOURCE/Makefile_check
===================================================================
--- palm/trunk/SOURCE/Makefile_check	(revision 807)
+++ palm/trunk/SOURCE/Makefile_check	(revision 807)
@@ -0,0 +1,96 @@
+#------------------------------------------------------------------------------!
+# WARNING: don't write filenames with extension .f90 in this header!!!!
+#
+# Current revisions:
+# ------------------
+# Initial revision
+#
+# Former revisions:
+# -----------------
+# $Id$
+#
+# Description:
+# ------------
+# Makefile for the parameter file check program check_namelist_files to be used
+# by the shell script "mrun"
+#------------------------------------------------------------------------------!
+
+
+PROG = check_namelist_files.x
+
+RCS = check_open.f90 check_namelist_files.f90 check_parameters.f90 \
+      close_file.f90 cpu_log.f90 fft_xy.f90 init_grid.f90 init_masks.f90 \
+      init_pegrid.f90 local_flush.f90 local_stop.f90 local_system.f90 \
+      message.f90 modules.f90 package_parin.f90 parin.f90 poisfft.f90 \
+      poisfft_hybrid.f90 singleton.f90 subsidence.f90 temperton_fft.f90 \
+      user_check_data_output.f90 user_check_data_output_pr.f90 \
+      user_check_parameters.f90 user_init.f90 user_init_3d_model.f90 \
+      user_init_grid.f90 user_init_particles.f90 user_init_plant_canopy.f90 \
+      user_module.f90 user_parin.f90  \
+
+
+OBJS = check_open.o check_namelist_files.o check_parameters.o close_file.o \
+      cpu_log.o fft_xy.o init_grid.o init_masks.o init_pegrid.o \
+      local_flush.o local_stop.o local_system.o message.o \
+      modules.o package_parin.o parin.o poisfft.o \
+      poisfft_hybrid.o singleton.o subsidence.o temperton_fft.o \
+      user_check_data_output.o user_check_data_output_pr.o \
+      user_check_parameters.o user_init.o user_init_3d_model.o \
+      user_init_grid.o user_init_particles.o user_init_plant_canopy.o \
+      user_module.o user_parin.o  \
+
+CC = cc
+CFLAGS = -O
+
+F90 = 
+COPT =
+F90FLAGS = 
+LDFLAGS =
+
+#to_be_replaced_by_include
+
+.SUFFIXES:
+.SUFFIXES: .o .f90
+
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+	$(F90) -o $(PROG) $(OBJS) $(LDFLAGS)
+
+clean:
+	rm -f $(PROG) $(OBJS) *.mod *.i *.lst
+
+.f90.o:
+	$(F90) $(F90FLAGS) $(COPT) -c $<
+
+
+check_open.o: modules.o
+check_namelist_files.o: modules.o
+check_parameters.o: modules.o subsidence.o
+close_file.o: modules.o
+cpu_log.o: modules.o
+fft_xy.o: modules.o singleton.o temperton_fft.o
+init_grid.o: modules.o
+init_masks.o: modules.o
+init_pegrid.o: modules.o fft_xy.o poisfft.o poisfft_hybrid.o
+local_stop.o: modules.o
+message.o: modules.o
+modules.o: modules.f90
+package_parin.o: modules.o
+parin.o: modules.o
+poisfft.o: modules.o fft_xy.o
+poisfft_hybrid.o: modules.o fft_xy.o
+singleton.o: singleton.f90
+subsidence.o: modules.o
+temperton_fft.o: modules.o
+user_init.o: modules.o user_module.o
+user_init_3d_model.o: modules.o user_module.o
+user_init_grid.o: modules.o user_module.o
+user_init_particles.o: modules.o user_module.o
+user_init_plant_canopy.o: modules.o user_module.o
+user_module.o: user_module.f90
+user_parin.o: modules.o user_module.o
+user_check_parameters.o: modules.o user_module.o
+user_check_data_output.o: modules.o user_module.o
+user_check_data_output_pr.o: modules.o user_module.o
Index: palm/trunk/SOURCE/check_namelist_files.f90
===================================================================
--- palm/trunk/SOURCE/check_namelist_files.f90	(revision 807)
+++ palm/trunk/SOURCE/check_namelist_files.f90	(revision 807)
@@ -0,0 +1,52 @@
+!------------------------------------------------------------------------------!
+! Current revisions:
+! -----------------
+! Initial revision
+!
+! Former revisions:
+! -----------------
+! $Id$
+!
+! Description:
+! ------------
+! Perform namelist file check. The program is independent from PALM and used by 
+! the shell script "mrun" to check the parameter files (e.g. p3d, p3df...) b
+! efore the job is submitted/started. Source code from the PALM model in used in 
+! check_namelist_files by means of the cpp directive "__check". The compiled
+! program resides in the SCRIPTS folder as check_namelist_files.x.
+!------------------------------------------------------------------------------!
+
+ PROGRAM check_namelist_files
+
+
+    USE pegrid
+    USE control_parameters
+
+    IMPLICIT NONE
+
+
+!
+!-- Read number of processors and variable check_restart, which gives 
+!-- information whether the p3d or the pd3f file shall be checked
+    READ (*,*,ERR=10,END=10)  numprocs, check_restart
+10  CONTINUE
+
+!
+!-- Read control parameters from NAMELIST files and read environment-variables1
+    CALL parin
+
+!
+!-- Determine processor topology and local array indices
+    CALL init_pegrid
+
+!
+!-- Generate grid parameters
+    CALL init_grid
+
+
+!
+!-- Check control parameters and deduce further quantities    
+    CALL check_parameters
+
+
+ END PROGRAM check_namelist_files
Index: palm/trunk/SOURCE/check_open.f90
===================================================================
--- palm/trunk/SOURCE/check_open.f90	(revision 806)
+++ palm/trunk/SOURCE/check_open.f90	(revision 807)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! New cpp directive "__check" implemented which is used by check_namelist_files
+!
 !
 ! Former revisions:
@@ -116,4 +117,5 @@
     IF ( openfile(file_id)%opened )  RETURN
 
+#if .NOT. defined ( __check )
 !
 !-- Only certain files are allowed to be re-opened
@@ -138,4 +140,5 @@
        END SELECT
     ENDIF
+#endif
 
 !
@@ -189,6 +192,21 @@
        CASE ( 11 )
 
+#if defined ( __check )
+!
+!--       In case of a prior parameter file check, the p3d data is stored in 
+!--       PARIN, while the p3df is stored in PARINF. This only applies to
+!--       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', &
+                        STATUS='OLD' )
+          END IF
+#else
+
           OPEN ( 11, FILE='PARIN'//coupling_char, FORM='FORMATTED', &
                      STATUS='OLD' )
+#endif
 
        CASE ( 13 )
@@ -219,5 +237,5 @@
                 CALL local_system( 'mkdir  BINOUT' // coupling_char )
              ENDIF
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !--          Set a barrier in order to allow that all other processors in the 
@@ -258,5 +276,5 @@
                         FORM='UNFORMATTED', POSITION='APPEND' )
           ELSE
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !--          Set a barrier in order to allow that all other processors in the 
@@ -639,5 +657,5 @@
                 CALL local_system( 'mkdir  PARTICLE_INFOS' // coupling_char )
              ENDIF
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !--          Set a barrier in order to allow that thereafter all other
@@ -688,5 +706,5 @@
                 CALL local_system( 'mkdir  PARTICLE_DATA' // coupling_char )
              ENDIF
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !--          Set a barrier in order to allow that thereafter all other
@@ -1291,6 +1309,6 @@
                                        TRIM( coupling_char ) // '/' )
                 ENDIF
-#if defined( __parallel )
-!
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
+! 
 !--             Set a barrier in order to allow that all other processors in the
 !--             directory created by PE0 can open their file
Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 806)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 807)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! Former revisions:
@@ -217,4 +217,22 @@
 
 #if defined( __parallel )
+
+#if defined( __check )
+
+!
+!--    NOTE: coupled runs have not been implemented in the check_namelist_files
+!--    program.
+!--    check_namelist_files will need the following information of the other 
+!--    model (atmosphere/ocean).
+       dt_coupling = remote
+       dt_max = remote
+       restart_time = remote
+       dt_restart= remote
+       simulation_time_since_reference = remote
+       dx = remote
+
+#endif
+
+#if .NOT. defined( __check )
        IF ( myid == 0 ) THEN
           CALL MPI_SEND( dt_coupling, 1, MPI_REAL, target_id, 11, comm_inter, &
@@ -224,5 +242,5 @@
        ENDIF
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-       
+#endif      
        IF ( dt_coupling /= remote )  THEN
           WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
@@ -232,4 +250,5 @@
        ENDIF
        IF ( dt_coupling <= 0.0 )  THEN
+#if .NOT. defined( __check )
           IF ( myid == 0  ) THEN
              CALL MPI_SEND( dt_max, 1, MPI_REAL, target_id, 19, comm_inter, ierr )
@@ -238,5 +257,5 @@
           ENDIF   
           CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-          
+#endif          
           dt_coupling = MAX( dt_max, remote )
           WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
@@ -245,4 +264,5 @@
           CALL message( 'check_parameters', 'PA0005', 0, 1, 0, 6, 0 )
        ENDIF
+#if .NOT. defined( __check )
        IF ( myid == 0 ) THEN
           CALL MPI_SEND( restart_time, 1, MPI_REAL, target_id, 12, comm_inter, &
@@ -252,5 +272,5 @@
        ENDIF 
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-      
+#endif      
        IF ( restart_time /= remote )  THEN
           WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
@@ -259,4 +279,5 @@
           CALL message( 'check_parameters', 'PA0006', 1, 2, 0, 6, 0 )
        ENDIF
+#if .NOT. defined( __check )
        IF ( myid == 0 ) THEN
           CALL MPI_SEND( dt_restart, 1, MPI_REAL, target_id, 13, comm_inter, &
@@ -266,5 +287,5 @@
        ENDIF   
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-      
+#endif      
        IF ( dt_restart /= remote )  THEN
           WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
@@ -275,4 +296,5 @@
 
        simulation_time_since_reference = end_time - coupling_start_time
+#if .NOT. defined( __check )
        IF  ( myid == 0 ) THEN
           CALL MPI_SEND( simulation_time_since_reference, 1, MPI_REAL, target_id, &
@@ -282,5 +304,5 @@
        ENDIF 
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-      
+#endif      
        IF ( simulation_time_since_reference /= remote )  THEN
           WRITE( message_string, * ) 'coupling mode "', TRIM( coupling_mode ), &
@@ -291,5 +313,5 @@
        ENDIF
 
-  
+#if .NOT. defined( __check )
        IF ( myid == 0 ) THEN
           CALL MPI_SEND( dx, 1, MPI_REAL, target_id, 15, comm_inter, ierr )
@@ -299,5 +321,5 @@
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
 
-
+#endif
        IF ( coupling_mode == 'atmosphere_to_ocean') THEN
 
@@ -318,4 +340,5 @@
        ENDIF
 
+#if .NOT. defined( __check )
        IF ( myid == 0) THEN
           CALL MPI_SEND( dy, 1, MPI_REAL, target_id, 16, comm_inter, ierr )
@@ -324,5 +347,5 @@
        ENDIF
        CALL MPI_BCAST( remote, 1, MPI_REAL, 0, comm2d, ierr)
-
+#endif
        IF ( coupling_mode == 'atmosphere_to_ocean') THEN
 
@@ -365,5 +388,5 @@
     ENDIF
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !-- Exchange via intercommunicator
@@ -2933,8 +2956,9 @@
 !
 
+#if .NOT. defined( __check )
 !-- Check netcdf precison
     ldum = .FALSE.
     CALL define_netcdf_header( 'ch', ldum, 0 )
-
+#endif
 !
 !-- Check, whether a constant diffusion coefficient shall be used
Index: palm/trunk/SOURCE/init_grid.f90
===================================================================
--- palm/trunk/SOURCE/init_grid.f90	(revision 806)
+++ palm/trunk/SOURCE/init_grid.f90	(revision 807)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! Former revisions:
@@ -534,5 +534,5 @@
 
              ENDIF
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
              CALL MPI_BARRIER( comm2d, ierr )
 #endif
@@ -739,5 +739,5 @@
           ENDIF
        ENDDO
-
+#if .NOT. defined ( __check )
 !
 !--    Exchange of lateral boundary values (parallel computers) and cyclic
@@ -766,7 +766,8 @@
           
        ENDIF
-
+#endif
     ENDIF
 
+#if .NOT. defined ( __check )
 !
 !-- Preliminary: to be removed after completion of the topography code!
@@ -1160,4 +1161,5 @@
                 nzb_tmp, vertical_influence, wall_l, wall_n, wall_r, wall_s )
 
+#endif
 
  END SUBROUTINE init_grid
Index: palm/trunk/SOURCE/init_masks.f90
===================================================================
--- palm/trunk/SOURCE/init_masks.f90	(revision 806)
+++ palm/trunk/SOURCE/init_masks.f90	(revision 807)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! Former revisions:
@@ -346,9 +347,10 @@
 !--    Set global masks along all three dimensions (required by
 !--    define_netcdf_header).
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !--    PE0 receives partial arrays from all processors of the respective mask
 !--    and outputs them. Here a barrier has to be set, because otherwise 
 !--    "-MPI- FATAL: Remote protocol queue full" may occur.
+
        CALL MPI_BARRIER( comm2d, ierr )
 
@@ -438,5 +440,5 @@
        ENDIF
 
-#else
+#elif .NOT. defined ( __parallel )
 !
 !--    Local arrays can be relocated directly.
Index: palm/trunk/SOURCE/init_pegrid.f90
===================================================================
--- palm/trunk/SOURCE/init_pegrid.f90	(revision 806)
+++ palm/trunk/SOURCE/init_pegrid.f90	(revision 807)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! ATTENTION: nnz_x undefined problem still has to be solved!!!!!!!!
@@ -215,4 +215,6 @@
     IF ( bc_ns /= 'cyclic' )  cyclic(2) = .FALSE.
 
+
+#if .NOT. defined( __check)
 !
 !-- Create the virtual processor grid
@@ -240,4 +242,5 @@
     CALL MPI_COMM_RANK( comm1dy, myidy, ierr )
 
+#endif
 
 !
@@ -525,4 +528,6 @@
     DEALLOCATE( nxlf , nxrf , nynf , nysf )
 
+
+#if .NOT. defined( __check)
 !
 !-- Collect index bounds from other PEs (to be written to restart file later)
@@ -554,4 +559,6 @@
 
     ENDIF
+
+#endif
 
 #if defined( __print )
@@ -589,5 +596,5 @@
 #endif
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined( __check)
 #if defined( __mpi2 )
 !
@@ -933,5 +940,5 @@
 
           IF ( i == mg_switch_to_pe0_level )  THEN
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined( __check )
 !
 !--          Save the grid size of the subdomain at the switch level, because
@@ -966,5 +973,5 @@
                               ( nzt_l - nzb + 2 )
 
-#else
+#elif .NOT. defined ( __parallel )
              message_string = 'multigrid gather/scatter impossible ' // &
                           'in non parallel mode'
@@ -1008,5 +1015,5 @@
     grid_level = 0
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !-- Gridpoint number for the exchange of ghost points (y-line for 2D-arrays)
@@ -1091,5 +1098,5 @@
 #endif
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 !
 !-- Setting of flags for inflow/outflow conditions in case of non-cyclic
@@ -1151,5 +1158,5 @@
                         comm1dx, ierr )
 
-#else
+#elif .NOT. defined ( __parallel )
     IF ( bc_lr == 'dirichlet/radiation' )  THEN
        inflow_l  = .TRUE.
@@ -1168,4 +1175,5 @@
     ENDIF
 #endif
+
 !
 !-- At the outflow, u or v, respectively, have to be calculated for one more
Index: palm/trunk/SOURCE/local_stop.f90
===================================================================
--- palm/trunk/SOURCE/local_stop.f90	(revision 806)
+++ palm/trunk/SOURCE/local_stop.f90	(revision 807)
@@ -4,4 +4,5 @@
 ! Current revisions:
 ! -----------------
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! Former revisions:
@@ -41,5 +42,5 @@
 
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
     IF ( coupling_mode == 'uncoupled' )  THEN
        IF ( abort_mode == 1 )  THEN
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 806)
+++ palm/trunk/SOURCE/modules.f90	(revision 807)
@@ -5,5 +5,7 @@
 ! Current revisions:
 ! -----------------
-!
+! New cpp directive "__check" implemented which is used by check_namelist_files.
+! New parameter check_restart has been defined which is needed by 
+! check_namelist_files only.
 !
 ! Former revisions:
@@ -351,5 +353,4 @@
           w_av
  END MODULE averaging
-
 
 
@@ -520,4 +521,8 @@
                 vg_vertical_gradient_level_ind(10) = -9999, &
                 subs_vertical_gradient_level_i(10) = -9999
+
+#if defined ( __check )
+    INTEGER :: check_restart = 0
+#endif
 
     INTEGER, DIMENSION(:), ALLOCATABLE ::  grid_level_count
@@ -1255,5 +1260,5 @@
 !------------------------------------------------------------------------------!
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
 #if defined( __lc )
     USE MPI
@@ -1285,5 +1290,10 @@
                 type_x, type_x_int, type_xy, type_y, type_y_int
 
-    INTEGER ::  ibuf(12), pcoord(2), pdims(2), status(MPI_STATUS_SIZE)
+    INTEGER ::  ibuf(12), pcoord(2), pdims(2)
+
+#if .NOT. defined ( __check )
+    INTEGER ::  status(MPI_STATUS_SIZE)
+#endif
+
 
     INTEGER, DIMENSION(:), ALLOCATABLE ::  ngp_yz, type_xz, type_yz
Index: palm/trunk/SOURCE/parin.f90
===================================================================
--- palm/trunk/SOURCE/parin.f90	(revision 806)
+++ palm/trunk/SOURCE/parin.f90	(revision 807)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! New cpp directive "__check" implemented which is used by check_namelist_files
 !
 ! Former revisions:
@@ -255,6 +255,20 @@
 !--       machines one can not distinguish between errors produced by a wrong
 !--       "inipar" namelist or because this namelist is totally missing.
-          READ ( 11, inipar, ERR=10, END=11 )
-          GOTO 12
+           READ ( 11, inipar, ERR=10, END=11 )
+
+#if defined ( __check )
+!
+!--       In case of a namelist file check, &inipar from the p3d file is
+!--       used. The p3d file here must be closed and the p3df file for reading 
+!--       3dpar is opened.
+          IF ( check_restart == 1 ) THEN
+             CALL close_file( 11 )
+             check_restart = 2
+             CALL check_open( 11 )             
+             initializing_actions = 'read_restart_data'
+          END IF
+#endif
+           GOTO 12
+
  10       message_string = 'errors in \$inipar &or no \$inipar-namelist ' // &
                            'found (CRAY-machines only)'
@@ -268,6 +282,8 @@
 !--       a prior run). All PEs are reading from file created by PE0 (see
 !--       check_open)
+
+
  12       IF ( TRIM( initializing_actions ) == 'read_restart_data' )  THEN
-
+#if .NOT. defined ( __check )
              CALL read_var_list
 !
@@ -278,5 +294,5 @@
 !--          Increment the run count
              runnr = runnr + 1
-
+#endif
           ENDIF
 
@@ -342,5 +358,5 @@
 
        ENDIF
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. ( __check )
        CALL MPI_BARRIER( MPI_COMM_WORLD, ierr )
 #endif
Index: palm/trunk/SOURCE/poisfft.f90
===================================================================
--- palm/trunk/SOURCE/poisfft.f90	(revision 806)
+++ palm/trunk/SOURCE/poisfft.f90	(revision 807)
@@ -4,5 +4,7 @@
 ! Current revisions:
 ! -----------------
-!
+! New cpp directive "__check" implemented which is used by check_namelist_files
+! (most of the code is unneeded by check_namelist_files).
+! 
 !
 ! Former revisions:
@@ -106,4 +108,6 @@
 
     PRIVATE
+
+#if .NOT. defined ( __check )
     PUBLIC  poisfft, poisfft_init
 
@@ -115,4 +119,11 @@
        MODULE PROCEDURE poisfft_init
     END INTERFACE poisfft_init
+#else
+    PUBLIC  poisfft_init
+
+    INTERFACE poisfft_init
+       MODULE PROCEDURE poisfft_init
+    END INTERFACE poisfft_init
+#endif
 
  CONTAINS
@@ -124,5 +135,5 @@
     END SUBROUTINE poisfft_init
 
-
+#if .NOT. defined ( __check )
     SUBROUTINE poisfft( ar, work )
 
@@ -1581,4 +1592,4 @@
 
 #endif
-
+#endif
  END MODULE poisfft_mod
Index: palm/trunk/SOURCE/poisfft_hybrid.f90
===================================================================
--- palm/trunk/SOURCE/poisfft_hybrid.f90	(revision 806)
+++ palm/trunk/SOURCE/poisfft_hybrid.f90	(revision 807)
@@ -4,4 +4,6 @@
 ! Current revisions: 
 ! ----------------- 
+! New cpp directive "__check" implemented which is used by check_namelist_files
+! (most of the code is unneeded by check_namelist_files).
 !
 ! Former revisions: 
@@ -13,5 +15,5 @@
 !
 ! 415 2009-12-15 10:26:23Z raasch
-! Dimension of array stat in cascade change to prevent type problems with
+! Dimension of array stat in cascade change to prevent type problems with___
 ! mpi2 libraries
 !
@@ -60,7 +62,4 @@
     IMPLICIT NONE
 
-    PRIVATE
-    PUBLIC poisfft_hybrid, poisfft_hybrid_ini
-
     INTEGER, PARAMETER ::  switch_per_lpar = 2
 
@@ -84,5 +83,12 @@
                      nodes,               & ! number of nodes
                      tasks_per_logical_node = -1    ! default no cluster
-                      
+
+
+    PRIVATE
+
+
+#if .NOT. defined ( __check )
+    PUBLIC poisfft_hybrid, poisfft_hybrid_ini
+
 
 !
@@ -117,8 +123,17 @@
        MODULE PROCEDURE cascade
     END INTERFACE cascade
+#else
+    PUBLIC poisfft_hybrid_ini
+
+!
+!-- Public interfaces
+    INTERFACE poisfft_hybrid_ini
+       MODULE PROCEDURE poisfft_hybrid_ini
+    END INTERFACE poisfft_hybrid_ini
+#endif
 
  CONTAINS
  
- 
+
     SUBROUTINE poisfft_hybrid_ini
 
@@ -153,5 +168,5 @@
        nwords = ( nxr_p-nxl_p+1 ) * nz * ( nyn_p-nys_p+1 )
 
-#if defined( __KKMP )
+#if defined( __KKMP ) .AND. .NOT. defined ( __check )
        CALL LOCAL_GETENV( 'OMP_NUM_THREADS', 15, cdummy, idummy )
        READ ( cdummy, '(I8)' )  n_omp_threads
@@ -209,5 +224,5 @@
        IF ( tasks_per_logical_node >= 2 )  THEN
 
-#if defined( __parallel )
+#if defined( __parallel ) .AND. .NOT. defined ( __check )
           nodes   = ( numprocs + tasks_per_logical_node - 1 ) / &
                     tasks_per_logical_node
@@ -231,5 +246,5 @@
 !          write(0,*) 'who am i',myid,me,me_node,me_task,nodes,&
 !                     tasks_per_logical_node
-#else
+#elif .NOT. defined( __parallel ) 
           message_string = 'parallel environment (MPI) required'
           CALL message( 'poisfft_hybrid_ini', 'PA0282', 1, 2, 0, 6, 0 )
@@ -239,5 +254,5 @@
     END SUBROUTINE poisfft_hybrid_ini
 
-
+#if .NOT. defined ( __check )
     SUBROUTINE poisfft_hybrid( ar )
 
@@ -1063,4 +1078,4 @@
 
     END SUBROUTINE cascade
-
+#endif
  END MODULE poisfft_hybrid_mod
Index: palm/trunk/UTIL/mrungui/mainwindow.ui
===================================================================
--- palm/trunk/UTIL/mrungui/mainwindow.ui	(revision 806)
+++ palm/trunk/UTIL/mrungui/mainwindow.ui	(revision 807)
@@ -925,5 +925,5 @@
      </property>
      <property name="text">
-      <string>-A  archiving when using file-attribute fl</string>
+      <string>-A  (archiving when using file-attribute fl)</string>
      </property>
     </widget>
