Index: palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- palm/trunk/SOURCE/check_parameters.f90	(revision 1812)
+++ palm/trunk/SOURCE/check_parameters.f90	(revision 1817)
@@ -19,5 +19,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! Moved checks for land_surface model to the respective module
 ! 
 ! Former revisions:
@@ -330,5 +330,7 @@
     USE grid_variables
     USE indices
-    USE land_surface_model_mod
+    USE land_surface_model_mod,                                                &
+        ONLY: land_surface, lsm_check_data_output, lsm_check_data_output_pr,   &
+              lsm_check_parameters, nzs, zs
     USE kinds
     USE model_1d
@@ -1035,179 +1037,8 @@
     ENDIF
 
-
-    IF ( land_surface )  THEN
- 
-!
-!--    Dirichlet boundary conditions are required as the surface fluxes are
-!--    calculated from the temperature/humidity gradients in the land surface
-!--    model
-       IF ( bc_pt_b == 'neumann'  .OR.  bc_q_b == 'neumann' )  THEN
-          message_string = 'lsm requires setting of'//                         &
-                           'bc_pt_b = "dirichlet" and '//                      &
-                           'bc_q_b  = "dirichlet"'
-          CALL message( 'check_parameters', 'PA0399', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF (  .NOT.  constant_flux_layer )  THEN
-          message_string = 'lsm requires '//                                   &
-                           'constant_flux_layer = .T.'
-          CALL message( 'check_parameters', 'PA0400', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( topography /= 'flat' )  THEN
-          message_string = 'lsm cannot be used ' //                            & 
-                           'in combination with  topography /= "flat"'
-          CALL message( 'check_parameters', 'PA0415', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( ( veg_type == 14  .OR.  veg_type == 15 ) .AND.                       &
-              most_method == 'lookup' )  THEN
-           WRITE( message_string, * ) 'veg_type = ', veg_type, ' is not ',     &
-                                      'allowed in combination with ',          &
-                                      'most_method = ', most_method
-          CALL message( 'check_parameters', 'PA0417', 1, 2, 0, 6, 0 )
-       ENDIF
-
-       IF ( veg_type == 0 )  THEN
-          IF ( SUM( root_fraction ) /= 1.0_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of root_fraction(0:3)'//       &
-                              '/= 9999999.9 and SUM(root_fraction) = 1'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
- 
-          IF ( min_canopy_resistance == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user defined)'//                  &
-                              'requires setting of min_canopy_resistance'//    &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( leaf_area_index == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of leaf_area_index'//          &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( vegetation_coverage == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of vegetation_coverage'//      &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( canopy_resistance_coefficient == 9999999.9_wp)  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of'//                          &
-                              'canopy_resistance_coefficient /= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( lambda_surface_stable == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of lambda_surface_stable'//    &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( lambda_surface_unstable == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of lambda_surface_unstable'//  &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( f_shortwave_incoming == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of f_shortwave_incoming'//     &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( z0_eb == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of z0_eb'//                   &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( z0h_eb == 9999999.9_wp )  THEN
-             message_string = 'veg_type = 0 (user_defined)'//                  &
-                              'requires setting of z0h_eb'//                  &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-          ENDIF
-
-
-       ENDIF
-
-       IF ( soil_type == 0 )  THEN
-
-          IF ( alpha_vangenuchten == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of alpha_vangenuchten'//       &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( l_vangenuchten == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of l_vangenuchten'//           &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( n_vangenuchten == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of n_vangenuchten'//           &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( hydraulic_conductivity == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of hydraulic_conductivity'//   &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( saturation_moisture == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of saturation_moisture'//      &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( field_capacity == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of field_capacity'//           &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( wilting_point == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of wilting_point'//            &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-          IF ( residual_moisture == 9999999.9_wp )  THEN
-             message_string = 'soil_type = 0 (user_defined)'//                 &
-                              'requires setting of residual_moisture'//        &
-                              '/= 9999999.9'
-             CALL message( 'check_parameters', 'PA0403', 1, 2, 0, 6, 0 )
-          ENDIF
-
-       ENDIF
-
-       IF (  .NOT.  radiation )  THEN
-          message_string = 'lsm requires '//                                   &
-                           'radiation = .T.'
-          CALL message( 'check_parameters', 'PA0400', 1, 2, 0, 6, 0 )
-       ENDIF
-
-    END IF 
+!
+!-- When land surface model is used, peform addtional checks
+    IF ( land_surface )  CALL lsm_check_parameters
+
 
     IF ( radiation )  THEN
@@ -3144,38 +2975,4 @@
              ENDIF
 
-          CASE ( 't_soil', '#t_soil' )
-             IF (  .NOT.  land_surface )  THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
-                                 'lemented for land_surface = .FALSE.'
-                CALL message( 'check_parameters', 'PA0402', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 89
-                dopr_unit(i)  = 'K'
-                hom(0:nzs-1,2,89,:)  = SPREAD( - zs, 2, statistic_regions+1 )
-                IF ( data_output_pr(i)(1:1) == '#' )  THEN
-                   dopr_initial_index(i) = 90
-                   hom(0:nzs-1,2,90,:)   = SPREAD( - zs, 2, statistic_regions+1 )
-                   data_output_pr(i)     = data_output_pr(i)(2:)
-                ENDIF
-             ENDIF
-
-          CASE ( 'm_soil', '#m_soil' )
-             IF (  .NOT.  land_surface )  THEN
-                message_string = 'data_output_pr = ' //                        &
-                                 TRIM( data_output_pr(i) ) // ' is not imp' // &
-                                 'lemented for land_surface = .FALSE.'
-                CALL message( 'check_parameters', 'PA0402', 1, 2, 0, 6, 0 )
-             ELSE
-                dopr_index(i) = 91
-                dopr_unit(i)  = 'm3/m3'
-                hom(0:nzs-1,2,91,:)  = SPREAD( - zs, 2, statistic_regions+1 )
-                IF ( data_output_pr(i)(1:1) == '#' )  THEN
-                   dopr_initial_index(i) = 92
-                   hom(0:nzs-1,2,92,:)   = SPREAD( - zs, 2, statistic_regions+1 )
-                   data_output_pr(i)     = data_output_pr(i)(2:)
-                ENDIF
-             ENDIF
-
           CASE ( 'rad_net' )
              IF ( (  .NOT.  radiation )  .OR.  radiation_scheme == 'constant' )&
@@ -3306,5 +3103,9 @@
           CASE DEFAULT
 
-             CALL user_check_data_output_pr( data_output_pr(i), i, unit )
+             CALL lsm_check_data_output_pr( data_output_pr(i), i, unit, dopr_unit(i) )
+
+             IF ( unit == 'illegal' )  THEN
+                CALL user_check_data_output_pr( data_output_pr(i), i, unit )
+             ENDIF
 
              IF ( unit == 'illegal' )  THEN
@@ -3394,12 +3195,4 @@
              unit = 'K'
 
-          CASE ( 'm_soil' )
-             IF (  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                         'land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             unit = 'm3/m3'
-
           CASE ( 'nr' )
              IF (  .NOT.  cloud_physics )  THEN
@@ -3536,19 +3329,15 @@
              unit = 'psu'
 
-          CASE ( 't_soil' )
-             IF (  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                         'land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             unit = 'K'
-
-
-          CASE ( 'c_liq*', 'c_soil*', 'c_veg*', 'ghf_eb*', 'lai*', 'lwp*',     &
-                 'm_liq_eb*', 'ol*', 'pra*', 'prr*', 'qsws*', 'qsws_eb*',      &
-                 'qsws_liq_eb*', 'qsws_soil_eb*', 'qsws_veg_eb*', 'rad_net*',  &
+          CASE ( 'p', 'pt', 'u', 'v', 'w' )
+             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
+             IF ( TRIM( var ) == 'pt' )  unit = 'K'
+             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
+             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
+             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
+             CONTINUE
+
+          CASE ( 'lai*', 'lwp*', 'ol*', 'pra*', 'prr*', 'qsws*', 'rad_net*',   &
                  'rrtm_aldif*', 'rrtm_aldir*', 'rrtm_asdif*', 'rrtm_asdir*',   &
-                 'r_a*', 'r_s*', 'shf*', 'shf_eb*', 't*', 'u*', 'z0*', 'z0h*', &
-                 'z0q*' )
+                 'shf*', 't*', 'u*', 'z0*', 'z0h*', 'z0q*' )
              IF ( k == 0  .OR.  data_output(i)(ilen-2:ilen) /= '_xy' )  THEN
                 message_string = 'illegal value for data_output: "' //         &
@@ -3569,25 +3358,4 @@
                 ENDIF
              ENDIF
-
-             IF ( TRIM( var ) == 'c_liq*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'c_soil*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'c_veg*'  .AND.  .NOT. land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0401', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'ghf_eb*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
              IF ( TRIM( var ) == 'lai*'  .AND.  .NOT.  land_surface )  THEN
                 message_string = 'output of "' // TRIM( var ) // '" requi' //  &
@@ -3600,9 +3368,4 @@
                 CALL message( 'check_parameters', 'PA0108', 1, 2, 0, 6, 0 )
              ENDIF
-             IF ( TRIM( var ) == 'm_liq_eb*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
              IF ( TRIM( var ) == 'pra*'  .AND.  .NOT. precipitation )  THEN
                 message_string = 'output of "' // TRIM( var ) // '" requi' //  &
@@ -3625,55 +3388,11 @@
                 CALL message( 'check_parameters', 'PA0322', 1, 2, 0, 6, 0 )
              ENDIF
-             IF ( TRIM( var ) == 'qsws_eb*'  .AND.  .NOT.  land_surface )  THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'qsws_liq_eb*'  .AND.  .NOT. land_surface )   &
-             THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'qsws_soil_eb*'  .AND.  .NOT.  land_surface ) &
-             THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'qsws_veg_eb*'  .AND.  .NOT. land_surface )   &
-             THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'r_a*'  .AND.  .NOT.  land_surface ) &
-             THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-             IF ( TRIM( var ) == 'r_s*'  .AND.  .NOT.  land_surface ) &
-             THEN
-                message_string = 'output of "' // TRIM( var ) // '" requi' //  &
-                                 'res land_surface = .TRUE.'
-                CALL message( 'check_parameters', 'PA0404', 1, 2, 0, 6, 0 )
-             ENDIF
-
-             IF ( TRIM( var ) == 'c_liq*' )  unit = 'none'
-             IF ( TRIM( var ) == 'c_soil*')  unit = 'none'
-             IF ( TRIM( var ) == 'c_veg*' )  unit = 'none'
-             IF ( TRIM( var ) == 'ghf_eb*')  unit = 'W/m2'
+
              IF ( TRIM( var ) == 'lai*'   )  unit = 'none'
              IF ( TRIM( var ) == 'lwp*'   )  unit = 'kg/m2'
-             IF ( TRIM( var ) == 'm_liq_eb*'     )  unit = 'm'
              IF ( TRIM( var ) == 'ol*'   )   unit = 'm'
              IF ( TRIM( var ) == 'pra*'   )  unit = 'mm'
              IF ( TRIM( var ) == 'prr*'   )  unit = 'mm/s'
              IF ( TRIM( var ) == 'qsws*'  )  unit = 'kgm/kgs'
-             IF ( TRIM( var ) == 'qsws_eb*'      ) unit = 'W/m2'
-             IF ( TRIM( var ) == 'qsws_liq_eb*'  ) unit = 'W/m2'
-             IF ( TRIM( var ) == 'qsws_soil_eb*' ) unit = 'W/m2'
-             IF ( TRIM( var ) == 'qsws_veg_eb*'  ) unit = 'W/m2'
              IF ( TRIM( var ) == 'rad_net*'      ) unit = 'W/m2'   
              IF ( TRIM( var ) == 'rrtm_aldif*'   ) unit = ''   
@@ -3681,25 +3400,17 @@
              IF ( TRIM( var ) == 'rrtm_asdif*'   ) unit = '' 
              IF ( TRIM( var ) == 'rrtm_asdir*'   ) unit = '' 
-             IF ( TRIM( var ) == 'r_a*')     unit = 's/m'     
-             IF ( TRIM( var ) == 'r_s*')     unit = 's/m' 
              IF ( TRIM( var ) == 'shf*'   )  unit = 'K*m/s'
-             IF ( TRIM( var ) == 'shf_eb*')  unit = 'W/m2'
              IF ( TRIM( var ) == 't*'     )  unit = 'K'
              IF ( TRIM( var ) == 'u*'     )  unit = 'm/s'
              IF ( TRIM( var ) == 'z0*'    )  unit = 'm'
-             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm'
-
-
-          CASE ( 'p', 'pt', 'u', 'v', 'w' )
-             IF ( TRIM( var ) == 'p'  )  unit = 'Pa'
-             IF ( TRIM( var ) == 'pt' )  unit = 'K'
-             IF ( TRIM( var ) == 'u'  )  unit = 'm/s'
-             IF ( TRIM( var ) == 'v'  )  unit = 'm/s'
-             IF ( TRIM( var ) == 'w'  )  unit = 'm/s'
-             CONTINUE
-
+             IF ( TRIM( var ) == 'z0h*'   )  unit = 'm' 
+             
           CASE DEFAULT
 
-             CALL user_check_data_output( var, unit )
+             CALL lsm_check_data_output ( var, unit, i, ilen, k )
+             
+             IF ( unit == 'illegal' )  THEN
+                CALL user_check_data_output( var, unit )
+             ENDIF
 
              IF ( unit == 'illegal' )  THEN
