Index: trunk/MagicSoft/Simulation/Corsika/Mmcs/main.f
===================================================================
--- trunk/MagicSoft/Simulation/Corsika/Mmcs/main.f	(revision 687)
+++ trunk/MagicSoft/Simulation/Corsika/Mmcs/main.f	(revision 688)
@@ -739,7 +739,16 @@
 c And then, RE-calculate the GLOBAL direction in CORSIKA
 c We use formulae for spherical triangles
-        theprim = acos( cos(THETAP)*cos(spinthe)+
+
+        if ( THETAP .EQ. 0.0 ) then                   
+           theprim = spinthe 
+           phiprim = spinphi
+        elseif ( spinthe .eq. 0.0 ) then 
+           theprim = THETAP 
+           phiprim = 0.0
+        else 
+           theprim = acos( cos(THETAP)*cos(spinthe)+
      $                  sin(THETAP)*sin(spinthe)*cos(spinphi) )
-        phiprim = asin( sin(spinthe)*sin(spinphi)/sin(theprim) )
+           phiprim = asin( sin(spinthe)*sin(spinphi)/sin(theprim) )
+        endif 
         THETAP = theprim
         EVTH(140) = spinthe
