Index: palm/trunk/SOURCE/multi_agent_system_mod.f90
===================================================================
--- palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4346)
+++ palm/trunk/SOURCE/multi_agent_system_mod.f90	(revision 4444)
@@ -25,4 +25,7 @@
 ! -----------------
 ! $Id$
+! bugfix: cpp-directives for serial mode added
+! 
+! 4346 2019-12-18 11:55:56Z motisi
 ! Removed wall_flags_static_0 from USE statements as it's not used within
 ! the module
@@ -115,11 +118,13 @@
     INTEGER(iwp) ::  iran_agent = -1234567             !< number for random generator
     INTEGER(iwp) ::  min_nr_agent = 2                  !< namelist parameter (see documentation)
+#if defined( __parallel )
     INTEGER(iwp) ::  ghla_count_recv                   !< number of agents in left ghost layer
     INTEGER(iwp) ::  ghna_count_recv                   !< number of agents in north ghost layer
     INTEGER(iwp) ::  ghra_count_recv                   !< number of agents in right ghost layer
     INTEGER(iwp) ::  ghsa_count_recv                   !< number of agents in south ghost layer
-    INTEGER(iwp) ::  maximum_number_of_agents = 0      !< maximum number of agents during run
     INTEGER(iwp) ::  nr_move_north                     !< number of agts to move north during exchange_horiz
     INTEGER(iwp) ::  nr_move_south                     !< number of agts to move south during exchange_horiz
+#endif
+    INTEGER(iwp) ::  maximum_number_of_agents = 0      !< maximum number of agents during run
     INTEGER(iwp) ::  number_of_agents = 0              !< number of agents for each grid box (3d array is saved on agt_count)
     INTEGER(iwp) ::  number_of_agent_groups = 1        !< namelist parameter (see documentation)
@@ -239,4 +244,5 @@
     TYPE(agent_type), DIMENSION(:), POINTER ::  agents               !< Agent array for this grid cell
     TYPE(agent_type)                        ::  zero_agent           !< zero agent to avoid weird thing
+#if defined( __parallel )
     TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  move_also_north  !< for agent exchange between PEs
     TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  move_also_south  !< for agent exchange between PEs
@@ -245,4 +251,5 @@
     TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  agt_gh_r         !< ghost layer right of pe domain
     TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  agt_gh_s         !< ghost layer south of pe domain
+#endif
 !
 !-- Type for 2D grid on which agents are stored
@@ -1216,19 +1223,25 @@
        IMPLICIT NONE
 
+#if defined( __parallel )
        INTEGER(iwp) ::  agt_size !< Agent size in bytes
+       INTEGER(iwp) ::  n        !< counter (number of PEs)
+       INTEGER(iwp) ::  noa_rcv  !< received number of agents
+#endif
        INTEGER(iwp) ::  dummy    !< dummy
        INTEGER(iwp) ::  ii       !< counter (x)
        INTEGER(iwp) ::  ip       !< counter (x)
        INTEGER(iwp) ::  jp       !< counter (y)
-       INTEGER(iwp) ::  n        !< counter (number of PEs)
        INTEGER(iwp) ::  noa      !< number of agents
-       INTEGER(iwp) ::  noa_rcv  !< received number of agents
        INTEGER(iwp) ::  out_noa  !< number of agents for output
 
+#if defined( __parallel )
        INTEGER(iwp), DIMENSION(0:numprocs-1) ::  noa_arr !< number of agents on each PE
+#endif
 !
 !--    SAVE attribute required to avoid compiler warning about pointer outlive the pointer target
        TYPE(agent_type), DIMENSION(:), ALLOCATABLE, TARGET, SAVE ::  trf_agents !< all agents on current PE
+#if defined( __parallel )
        TYPE(agent_type), DIMENSION(:), ALLOCATABLE, TARGET, SAVE ::  out_agents !< all agents in entire domain
+#endif
 
        LOGICAL, INTENT (INOUT) :: ftest
@@ -1454,4 +1467,5 @@
     END SUBROUTINE mas_data_output_agents
 
+#if defined( __parallel )
 !------------------------------------------------------------------------------!
 ! Description:
@@ -1596,5 +1610,8 @@
 
     END SUBROUTINE mas_eh_add_agents_to_gridcell
-
+#endif
+
+
+#if defined( __parallel )
 !------------------------------------------------------------------------------!
 ! Description:
@@ -1648,4 +1665,5 @@
        ENDDO
     END SUBROUTINE mas_eh_add_ghost_agents_to_gridcell
+#endif
 
 !------------------------------------------------------------------------------!
@@ -1742,10 +1760,14 @@
        IMPLICIT NONE
 
+       INTEGER(iwp) ::  ip               !< index variable along x
+       INTEGER(iwp) ::  jp               !< index variable along y
+       INTEGER(iwp) ::  n                !< agent index variable
+
+#if defined( __parallel )
+
        INTEGER(iwp) ::  i                !< grid index (x) of agent positition
-       INTEGER(iwp) ::  ip               !< index variable along x
        INTEGER(iwp) ::  j                !< grid index (y) of agent positition
-       INTEGER(iwp) ::  jp               !< index variable along y
-       INTEGER(iwp) ::  n                !< agent index variable 
        INTEGER(iwp) ::  par_size         !< Agent size in bytes
+
        INTEGER(iwp) ::  trla_count       !< number of agents send to left PE
        INTEGER(iwp) ::  trla_count_recv  !< number of agents receive from right PE
@@ -1765,6 +1787,4 @@
        TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  trra  !< agents send to right PE
        TYPE(agent_type), DIMENSION(:), ALLOCATABLE ::  trsa  !< agents send to south PE
-
-#if defined( __parallel )
 
 !
@@ -2228,4 +2248,8 @@
        DEALLOCATE( move_also_south )
 
+!
+!--    Accumulate the number of agents transferred between the subdomains)
+       CALL mas_eh_ghost_exchange
+
 #else
 
@@ -2316,10 +2340,8 @@
 #endif
 
-!
-!--    Accumulate the number of agents transferred between the subdomains)
-       CALL mas_eh_ghost_exchange
-
     END SUBROUTINE mas_eh_exchange_horiz
 
+
+#if defined( __parallel )
 !------------------------------------------------------------------------------!
 ! Description:
@@ -2332,6 +2354,4 @@
 
        IMPLICIT NONE
-
-#if defined( __parallel )
 
        INTEGER(iwp) ::  ip          !< index variable along x
@@ -2617,7 +2637,6 @@
        ENDIF
 
+    END SUBROUTINE mas_eh_ghost_exchange
 #endif
-
-    END SUBROUTINE mas_eh_ghost_exchange
 
 !------------------------------------------------------------------------------!
@@ -3922,4 +3941,5 @@
     END SUBROUTINE mas_ps_sort_in_subboxes
 
+#if defined( __parallel )
 !------------------------------------------------------------------------------!
 ! Description:
@@ -3962,5 +3982,6 @@
        number_of_agents = nn
 
-    END SUBROUTINE mas_ps_pack 
+    END SUBROUTINE mas_ps_pack
+#endif
 
 !------------------------------------------------------------------------------!
