Index: palm/trunk/SOURCE/salsa_mod.f90
===================================================================
--- palm/trunk/SOURCE/salsa_mod.f90	(revision 4784)
+++ palm/trunk/SOURCE/salsa_mod.f90	(revision 4785)
@@ -26,4 +26,7 @@
 ! -----------------
 ! $Id$
+! Fixing a segmentation fault in initialising aerosol and gas emissions
+!
+! 4768 2020-11-02 19:11:23Z suehring
 ! Enable 3D data output also with 64-bit precision
 !
@@ -9816,19 +9819,32 @@
 !--          If the chemical component is not activated, set its mass fraction to 0 to avoid
 !--          inbalance between number and mass flux
-             cc_i2m = aero_emission_att%cc_in2mod
-             IF ( index_so4 < 0  .AND.  cc_i2m(1) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(1)) = 0.0_wp
-             IF ( index_oc  < 0  .AND.  cc_i2m(2) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(2)) = 0.0_wp
-             IF ( index_bc  < 0  .AND.  cc_i2m(3) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(3)) = 0.0_wp
-             IF ( index_du  < 0  .AND.  cc_i2m(4) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(4)) = 0.0_wp
-             IF ( index_ss  < 0  .AND.  cc_i2m(5) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(5)) = 0.0_wp
-             IF ( index_no  < 0  .AND.  cc_i2m(6) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(6)) = 0.0_wp
-             IF ( index_nh  < 0  .AND.  cc_i2m(7) > 0 )                                            &
-                aero_emission%mass_fracs(:,cc_i2m(7)) = 0.0_wp
+             IF ( index_so4 < 0  .AND.  aero_emission_att%cc_in2mod(1) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(1)) = 0.0_wp
+                aero_emission_att%cc_in2mod(1) = 0
+             ENDIF
+             IF ( index_oc  < 0  .AND.  aero_emission_att%cc_in2mod(2) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(2)) = 0.0_wp
+                aero_emission_att%cc_in2mod(2) = 0
+             ENDIF
+             IF ( index_bc  < 0  .AND.  aero_emission_att%cc_in2mod(3) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(3)) = 0.0_wp
+                aero_emission_att%cc_in2mod(3) = 0
+             ENDIF
+             IF ( index_du  < 0  .AND.  aero_emission_att%cc_in2mod(4) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(4)) = 0.0_wp
+                aero_emission_att%cc_in2mod(4) = 0
+             ENDIF
+             IF ( index_ss  < 0  .AND.  aero_emission_att%cc_in2mod(5) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(5)) = 0.0_wp
+                aero_emission_att%cc_in2mod(5) = 0
+             ENDIF
+             IF ( index_no  < 0  .AND.  aero_emission_att%cc_in2mod(6) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(6)) = 0.0_wp
+                aero_emission_att%cc_in2mod(6) = 0
+             ENDIF
+             IF ( index_nh  < 0  .AND.  aero_emission_att%cc_in2mod(7) > 0 )  THEN
+                aero_emission%mass_fracs(:,aero_emission_att%cc_in2mod(7)) = 0.0_wp
+                aero_emission_att%cc_in2mod(7) = 0
+             ENDIF
 !
 !--          Then normalise the mass fraction so that SUM = 1
@@ -10251,5 +10267,5 @@
 !
 !--             Sulphate
-                IF ( index_so4 > 0 )  THEN
+                IF ( cc_i_mod(1) > 0 )  THEN
                    ic = cc_i_mod(1)
                    CALL set_mass_flux( surface, m, ib, index_so4, mass_fracs(ic), arhoh2so4,       &
@@ -10258,5 +10274,5 @@
 !
 !--             Organic carbon
-                IF ( index_oc > 0 )  THEN
+                IF ( cc_i_mod(2) > 0 )  THEN
                    ic = cc_i_mod(2)
                    CALL set_mass_flux( surface, m, ib, index_oc, mass_fracs(ic),arhooc,            &
@@ -10265,5 +10281,5 @@
 !
 !--             Black carbon
-                IF ( index_bc > 0 )  THEN
+                IF ( cc_i_mod(3) > 0 )  THEN
                    ic = cc_i_mod(3)
                    CALL set_mass_flux( surface, m, ib, index_bc, mass_fracs(ic), arhobc,           &
@@ -10272,5 +10288,5 @@
 !
 !--             Dust
-                IF ( index_du > 0 )  THEN
+                IF ( cc_i_mod(4) > 0 )  THEN
                    ic = cc_i_mod(4)
                    CALL set_mass_flux( surface, m, ib, index_du, mass_fracs(ic), arhodu,           &
@@ -10279,5 +10295,5 @@
 !
 !--             Sea salt
-                IF ( index_ss > 0 )  THEN
+                IF ( cc_i_mod(5) > 0 )  THEN
                    ic = cc_i_mod(5)
                    CALL set_mass_flux( surface, m, ib, index_ss, mass_fracs(ic), arhoss,           &
@@ -10286,5 +10302,5 @@
 !
 !--             Nitric acid
-                IF ( index_no > 0 )  THEN
+                IF ( cc_i_mod(6) > 0 )  THEN
                     ic = cc_i_mod(6)
                    CALL set_mass_flux( surface, m, ib, index_no, mass_fracs(ic), arhohno3,         &
@@ -10293,5 +10309,5 @@
 !
 !--             Ammonia
-                IF ( index_nh > 0 )  THEN
+                IF ( cc_i_mod(7) > 0 )  THEN
                     ic = cc_i_mod(7)
                    CALL set_mass_flux( surface, m, ib, index_nh, mass_fracs(ic), arhonh3,          &
@@ -10741,4 +10757,5 @@
 
           DO  ig = 1, ngases_salsa
+             IF (cc_i_mod(ig) < 1) CYCLE
              IF ( use_time_fac )  THEN
                 surface%gtsws(m,ig) = surface%gtsws(m,ig) + rho_air_zw(k-1) * conv(ig) * time_fac  &
