Index: /palm/trunk/SOURCE/chemistry_model_mod.f90
===================================================================
--- /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4003)
+++ /palm/trunk/SOURCE/chemistry_model_mod.f90	(revision 4004)
@@ -27,4 +27,8 @@
 ! -----------------
 ! $Id$
+! in subroutine chem_parin check emiss_lod / mod_emis only
+! when emissions_anthropogenic is activated in namelist (E.C. Chan)
+! 
+! 3968 2019-05-13 11:04:01Z suehring
 ! - added "emiss_lod" which serves the same function as "mode_emis"
 !   both will be synchronized with emiss_lod having pirority over
@@ -2282,23 +2286,29 @@
 
  20 CONTINUE
+
+!
+!-- synchronize emiss_lod and mod_emis only if emissions_anthropogenic
+!-- is activated in the namelist.  Otherwise their values are "don't care"
+    IF ( emissions_anthropogenic )  THEN
 !
 !--    check for emission mode for chem species
 
-    IF ( emiss_lod < 0 )  THEN   !- if LOD not defined in namelist
-       IF ( ( mode_emis /= 'PARAMETERIZED'  )    .AND.      &
-            ( mode_emis /= 'DEFAULT'        )    .AND.      &
-            ( mode_emis /= 'PRE-PROCESSED'  ) )  THEN
-          message_string = 'Incorrect mode_emiss  option select. Please check spelling'
-          CALL message( 'chem_check_parameters', 'CM0436', 1, 2, 0, 6, 0 )
+       IF ( emiss_lod < 0 )  THEN   !- if LOD not defined in namelist
+          IF ( ( mode_emis /= 'PARAMETERIZED'  )    .AND.      &
+               ( mode_emis /= 'DEFAULT'        )    .AND.      &
+               ( mode_emis /= 'PRE-PROCESSED'  ) )  THEN
+             message_string = 'Incorrect mode_emiss  option select. Please check spelling'
+             CALL message( 'chem_check_parameters', 'CM0436', 1, 2, 0, 6, 0 )
+          ENDIF
+       ELSE
+          IF ( ( emiss_lod /= 0 )    .AND.         &
+               ( emiss_lod /= 1 )    .AND.         &
+               ( emiss_lod /= 2 ) )  THEN
+             message_string = 'Invalid value for emiss_lod (0, 1, or 2)'
+             CALL message( 'chem_check_parameters', 'CM0436', 1, 2, 0, 6, 0 )
+          ENDIF
        ENDIF
-    ELSE
-       IF ( ( emiss_lod /= 0 )    .AND.         &
-            ( emiss_lod /= 1 )    .AND.         &
-            ( emiss_lod /= 2 ) )  THEN
-          message_string = 'Invalid value for emiss_lod (0, 1, or 2)'
-          CALL message( 'chem_check_parameters', 'CM0436', 1, 2, 0, 6, 0 )
-       ENDIF
-    ENDIF
-
+
+!
 ! for reference (ecc)
 !    IF ( (mode_emis /= 'PARAMETERIZED')  .AND. ( mode_emis /= 'DEFAULT' ) .AND. ( mode_emis /= 'PRE-PROCESSED'  ) )  THEN
@@ -2313,39 +2323,46 @@
 !-- this check is in place to retain backward compatibility with salsa until the
 !-- code is migrated completed to emiss_lod
-    IF  ( emiss_lod >= 0 ) THEN
-       SELECT CASE  ( emiss_lod )
-          CASE (0)  !- parameterized mode
-             mode_emis = 'PARAMETERIZED'
-          CASE (1)  !- default mode
-             mode_emis = 'DEFAULT'
-          CASE (2)  !- preprocessed mode
-             mode_emis = 'PRE-PROCESSED'
-       END SELECT
+!-- note that 
+
+       IF  ( emiss_lod >= 0 ) THEN
+
+          SELECT CASE  ( emiss_lod )
+             CASE (0)  !- parameterized mode
+                mode_emis = 'PARAMETERIZED'
+             CASE (1)  !- default mode
+                mode_emis = 'DEFAULT'
+             CASE (2)  !- preprocessed mode
+                mode_emis = 'PRE-PROCESSED'
+          END SELECT
        
-       message_string = 'Synchronizing mode_emis to defined emiss_lod'               //  &
-                        CHAR(10)  //  '          '                                   //  &
-                        'NOTE - mode_emis will be depreciated in future releases'    //  &
-                        CHAR(10)  //  '          '                                   //  &
-                        'please use emiss_lod to define emission mode'
-
-       CALL message ( 'parin_chem', 'CM0463', 0, 0, 0, 6, 0 )
-    ELSE  ! if emiss_lod is not set
-       SELECT CASE ( mode_emis )
-          CASE ('PARAMETERIZED')
-             emiss_lod = 0
-          CASE ('DEFAULT')
-             emiss_lod = 1
-          CASE ('PRE-PROCESSED')
-             emiss_lod = 2
-       END SELECT
-
-       message_string = 'emiss_lod undefined.  Using existing mod_emiss setting'     //  &
-                        CHAR(10)  //  '          '                                   //  &
-                        'NOTE - mode_emis will be depreciated in future releases'    //  &
-                        CHAR(10)  //  '          '                                   //  &
-                        '       please use emiss_lod to define emission mode'
-
-       CALL message ( 'parin_chem', 'CM0464', 0, 0, 0, 6, 0 )
-    ENDIF
+          message_string = 'Synchronizing mode_emis to defined emiss_lod'               //  &
+                           CHAR(10)  //  '          '                                   //  &
+                           'NOTE - mode_emis will be depreciated in future releases'    //  &
+                           CHAR(10)  //  '          '                                   //  &
+                           'please use emiss_lod to define emission mode'
+ 
+          CALL message ( 'parin_chem', 'CM0463', 0, 0, 0, 6, 0 )
+
+       ELSE ! if emiss_lod is not set
+
+          SELECT CASE ( mode_emis )
+             CASE ('PARAMETERIZED')
+                emiss_lod = 0
+             CASE ('DEFAULT')
+                emiss_lod = 1
+             CASE ('PRE-PROCESSED')
+                emiss_lod = 2
+          END SELECT
+
+          message_string = 'emiss_lod undefined.  Using existing mod_emiss setting'     //  &
+                           CHAR(10)  //  '          '                                   //  &
+                           'NOTE - mode_emis will be depreciated in future releases'    //  &
+                           CHAR(10)  //  '          '                                   //  &
+                           '       please use emiss_lod to define emission mode'
+
+          CALL message ( 'parin_chem', 'CM0464', 0, 0, 0, 6, 0 )
+       ENDIF
+
+    ENDIF  ! if emissions_anthropengic
 
     t_steps = my_steps          
Index: /palm/trunk/SOURCE/module_interface.f90
===================================================================
--- /palm/trunk/SOURCE/module_interface.f90	(revision 4003)
+++ /palm/trunk/SOURCE/module_interface.f90	(revision 4004)
@@ -25,4 +25,10 @@
 ! -----------------
 ! $Id$
+! local_pf need INTENT(INOUT) attribute rather than INTENT(OUT). This is 
+! because INTENT(OUT) sets the array to not-defined. Especially for outputs that
+! are not defined everywhere, e.g. land-surface outputs, this will be 
+! problematic as NaN will be output.   
+! 
+! 3987 2019-05-22 09:52:13Z kanani
 ! Introduce switchable DEBUG file output via debug_message routine
 ! 
@@ -1184,5 +1190,5 @@
     REAL(wp),          INTENT(IN)    ::  fill_value !< to be removed
 
-    REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(OUT) ::  local_pf !< ToDo: can also be kind=sp
+    REAL(wp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(INOUT) ::  local_pf !< ToDo: can also be kind=sp
 
 
@@ -1267,5 +1273,5 @@
     INTEGER(iwp),      INTENT(IN)    ::  nzt_do     !< vertical output index (top) (usually nz_do3d)
 
-    REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(OUT) ::  local_pf
+    REAL(sp), DIMENSION(nxl:nxr,nys:nyn,nzb_do:nzt_do), INTENT(INOUT) ::  local_pf
 
 
Index: /palm/trunk/SOURCE/virtual_flight_mod.f90
===================================================================
--- /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 4003)
+++ /palm/trunk/SOURCE/virtual_flight_mod.f90	(revision 4004)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! Allow variable start- and end locations also in return mode
+! 
+! 3885 2019-04-11 11:29:34Z kanani
 ! Changes related to global restructuring of location messages and introduction 
 ! of additional debug messages
@@ -601,25 +604,55 @@
 !--          Carry out horizontal reflection if required.
              IF ( .NOT. cyclic_leg(l) )  THEN
-!
-!--             Outward flight, i.e. from start to end
-                IF ( u_agl(l) >= 0.0_wp  .AND.  x_pos(l) > x_end(l)      )  THEN
-                   x_pos(l) = 2.0_wp * x_end(l)   - x_pos(l)
-                   u_agl(l) = - u_agl(l)
-!
-!--             Return flight, i.e. from end to start
-                ELSEIF ( u_agl(l) < 0.0_wp  .AND.  x_pos(l) < x_start(l) )  THEN 
-                   x_pos(l) = 2.0_wp * x_start(l) - x_pos(l)
-                   u_agl(l) = - u_agl(l)
+
+                IF ( x_start(l) <= x_end(l) )  THEN
+!
+!--                Outward flight, i.e. from start to end
+                   IF ( u_agl(l) >= 0.0_wp  .AND.  x_pos(l) > x_end(l)      )  THEN
+                      x_pos(l) = 2.0_wp * x_end(l)   - x_pos(l)
+                      u_agl(l) = - u_agl(l)
+!                  
+!--                Return flight, i.e. from end to start
+                   ELSEIF ( u_agl(l) < 0.0_wp  .AND.  x_pos(l) < x_start(l) )  THEN 
+                      x_pos(l) = 2.0_wp * x_start(l) - x_pos(l)
+                      u_agl(l) = - u_agl(l)
+                   ENDIF
+                ELSE
+!
+!--                Outward flight, i.e. from start to end
+                   IF ( u_agl(l) < 0.0_wp  .AND.  x_pos(l) < x_end(l)      )  THEN
+                      x_pos(l) = 2.0_wp * x_end(l)   - x_pos(l)
+                      u_agl(l) = - u_agl(l)
+!                  
+!--                Return flight, i.e. from end to start
+                   ELSEIF ( u_agl(l) >= 0.0_wp  .AND.  x_pos(l) > x_start(l) )  THEN 
+                      x_pos(l) = 2.0_wp * x_start(l) - x_pos(l)
+                      u_agl(l) = - u_agl(l)
+                   ENDIF
                 ENDIF
-!
-!--             Outward flight, i.e. from start to end
-                IF ( v_agl(l) >= 0.0_wp  .AND.  y_pos(l) > y_end(l)      )  THEN
-                   y_pos(l) = 2.0_wp * y_end(l)   - y_pos(l)
-                   v_agl(l) = - v_agl(l)
-!
-!--             Return flight, i.e. from end to start                  
-                ELSEIF ( v_agl(l) < 0.0_wp  .AND.  y_pos(l) < y_start(l) )  THEN 
-                   y_pos(l) = 2.0_wp * y_start(l) - y_pos(l)
-                   v_agl(l) = - v_agl(l)
+                
+                IF ( y_start(l) <= y_end(l) )  THEN
+!
+!--                Outward flight, i.e. from start to end
+                   IF ( v_agl(l) >= 0.0_wp  .AND.  y_pos(l) > y_end(l)      )  THEN
+                      y_pos(l) = 2.0_wp * y_end(l)   - y_pos(l)
+                      v_agl(l) = - v_agl(l)
+!                  
+!--                Return flight, i.e. from end to start                  
+                   ELSEIF ( v_agl(l) < 0.0_wp  .AND.  y_pos(l) < y_start(l) )  THEN 
+                      y_pos(l) = 2.0_wp * y_start(l) - y_pos(l)
+                      v_agl(l) = - v_agl(l)
+                   ENDIF
+                ELSE
+!
+!--                Outward flight, i.e. from start to end
+                   IF ( v_agl(l) < 0.0_wp  .AND.  y_pos(l) < y_end(l)      )  THEN
+                      y_pos(l) = 2.0_wp * y_end(l)   - y_pos(l)
+                      v_agl(l) = - v_agl(l)
+!                  
+!--                Return flight, i.e. from end to start                  
+                   ELSEIF ( v_agl(l) >= 0.0_wp  .AND.  y_pos(l) > y_start(l) )  THEN 
+                      y_pos(l) = 2.0_wp * y_start(l) - y_pos(l)
+                      v_agl(l) = - v_agl(l)
+                   ENDIF
                 ENDIF
 !
@@ -924,19 +957,4 @@
 
        ENDDO          
-!
-!--    Check if start and end positions are properly set in case of return legs.
-       DO l=1, num_leg
-
-          IF ( x_start(l) > x_end(l) .AND. leg_mode(l) == 'return' )  THEN
-             message_string = 'x_start position must be <= x_end ' //          &
-                              'position for return legs'
-             CALL message( 'flight_check_parameters', 'PA0436', 1, 2, 0, 6, 0 )
-          ENDIF 
-          IF ( y_start(l) > y_end(l) .AND. leg_mode(l) == 'return' )  THEN
-             message_string = 'y_start position must be <= y_end ' //          &
-                              'position for return legs'
-             CALL message( 'flight_check_parameters', 'PA0437', 1, 2, 0, 6, 0 )
-          ENDIF 
-       ENDDO
 !
 !--    Check if given flight object remains inside model domain if a rate of 
