Index: trunk/LMDZ.MARS/libf/aeronomars/calchim.F90
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/calchim.F90	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/calchim.F90	(revision 2042)
@@ -664,9 +664,8 @@
 
          if (photochem) then
-
             call photochemistry(nlayer,nq,                            &
                            ig,lswitch,zycol,szacol,ptimestep,         &
                            zpress,zlocal,ztemp,zdens,zmmean,dist_sol, &
-                           surfdust1d,surfice1d,jo3,jh2o,taucol,iter)
+                           zday,surfdust1d,surfice1d,jo3,jh2o,taucol,iter)
 
 !        ozone photolysis, for output
@@ -735,4 +734,5 @@
       end do ! of do ig=1,ngrid
 
+!      stop
 !=======================================================================
 !     write outputs
@@ -754,5 +754,5 @@
             call writediagfi(ngrid,'emission_o2',        &
                  'O2 nightglow emission rate','cm-3 s-1',3,emission_o2)
-
+            
             if (callstats) then
                call wstats(ngrid,'jo3','j o3->o1d',       &
Index: trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/chemthermos.F90	(revision 2042)
@@ -91,21 +91,38 @@
 !!! If some value is changed here, the same change has to 
 !!! be made into the other subroutines
-      integer,parameter :: i_co2=1
-      integer,parameter :: i_o2=2
-      integer,parameter :: i_o=3
-      integer,parameter :: i_co=4
-      integer,parameter :: i_h=5
-      integer,parameter :: i_oh=6
-      integer,parameter :: i_ho2=7
-      integer,parameter :: i_h2=8
-      integer,parameter :: i_h2o=9
-      integer,parameter :: i_h2o2=10
-      integer,parameter :: i_o1d=11
-      integer,parameter :: i_o3=12
-      integer,parameter :: i_n2=13
-      integer,parameter :: i_n=14
-      integer,parameter :: i_no=15
-      integer,parameter :: i_n2d=16
-      integer,parameter :: i_no2=17
+      integer,parameter :: i_co2  =  1
+      integer,parameter :: i_co   =  2
+      integer,parameter :: i_o    =  3
+      integer,parameter :: i_o1d  =  4
+      integer,parameter :: i_o2   =  5
+      integer,parameter :: i_o3   =  6
+      integer,parameter :: i_h    =  7
+      integer,parameter :: i_h2   =  8
+      integer,parameter :: i_oh   =  9
+      integer,parameter :: i_ho2  = 10
+      integer,parameter :: i_h2o2 = 11
+      integer,parameter :: i_h2o  = 12
+      integer,parameter :: i_n    = 13
+      integer,parameter :: i_n2d  = 14
+      integer,parameter :: i_no   = 15
+      integer,parameter :: i_no2  = 16
+      integer,parameter :: i_n2   = 17
+!      integer,parameter :: i_co2=1
+!      integer,parameter :: i_o2=2
+!      integer,parameter :: i_o=3
+!      integer,parameter :: i_co=4
+!      integer,parameter :: i_h=5
+!      integer,parameter :: i_oh=6
+!      integer,parameter :: i_ho2=7
+!      integer,parameter :: i_h2=8
+!      integer,parameter :: i_h2o=9
+!      integer,parameter :: i_h2o2=10
+!      integer,parameter :: i_o1d=11
+!      integer,parameter :: i_o3=12
+!      integer,parameter :: i_n2=13
+!      integer,parameter :: i_n=14
+!      integer,parameter :: i_no=15
+!      integer,parameter :: i_n2d=16
+!      integer,parameter :: i_no2=17
       integer,parameter :: i_co2plus=18
       integer,parameter :: i_oplus=19
@@ -471,5 +488,4 @@
       !Photoabsorption coefficients
       call jthermcalc_e107(ig,nlayer,chemthermod,rm,nesptherm,ztemp,zlocal,zenit,zday)
-         
 
       !Chemistry
Index: trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/euvheat.F90	(revision 2042)
@@ -71,21 +71,38 @@
 !!! ATTENTION. These values have to be identical to those in chemthermos.F90
 !!! If the values are changed there, the same has to be done here  !!!
-      integer,parameter :: i_co2=1
-      integer,parameter :: i_o2=2
-      integer,parameter :: i_o=3
-      integer,parameter :: i_co=4
-      integer,parameter :: i_h=5
-      integer,parameter :: i_oh=6
-      integer,parameter :: i_ho2=7
-      integer,parameter :: i_h2=8
-      integer,parameter :: i_h2o=9
-      integer,parameter :: i_h2o2=10
-      integer,parameter :: i_o1d=11
-      integer,parameter :: i_o3=12
-      integer,parameter :: i_n2=13
-      integer,parameter :: i_n=14
-      integer,parameter :: i_no=15
-      integer,parameter :: i_n2d=16
-      integer,parameter :: i_no2=17
+      integer,parameter :: i_co2  =  1
+      integer,parameter :: i_co   =  2
+      integer,parameter :: i_o    =  3
+      integer,parameter :: i_o1d  =  4
+      integer,parameter :: i_o2   =  5
+      integer,parameter :: i_o3   =  6
+      integer,parameter :: i_h    =  7
+      integer,parameter :: i_h2   =  8
+      integer,parameter :: i_oh   =  9
+      integer,parameter :: i_ho2  = 10
+      integer,parameter :: i_h2o2 = 11
+      integer,parameter :: i_h2o  = 12
+      integer,parameter :: i_n    = 13
+      integer,parameter :: i_n2d  = 14
+      integer,parameter :: i_no   = 15
+      integer,parameter :: i_no2  = 16
+      integer,parameter :: i_n2   = 17
+!      integer,parameter :: i_co2=1
+!      integer,parameter :: i_o2=2
+!      integer,parameter :: i_o=3
+!      integer,parameter :: i_co=4
+!      integer,parameter :: i_h=5
+!      integer,parameter :: i_oh=6
+!      integer,parameter :: i_ho2=7
+!      integer,parameter :: i_h2=8
+!      integer,parameter :: i_h2o=9
+!      integer,parameter :: i_h2o2=10
+!      integer,parameter :: i_o1d=11
+!      integer,parameter :: i_o3=12
+!      integer,parameter :: i_n2=13
+!      integer,parameter :: i_n=14
+!      integer,parameter :: i_no=15
+!      integer,parameter :: i_n2d=16
+!      integer,parameter :: i_no2=17
 
       
Index: trunk/LMDZ.MARS/libf/aeronomars/hrtherm.F
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/hrtherm.F	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/hrtherm.F	(revision 2042)
@@ -41,17 +41,34 @@
 !!! ATTENTION. These values have to be identical to those in chemthermos.F90
 !!! If the values are changed there, the same has to be done here  !!!
-      integer,parameter :: i_co2=1
-      integer,parameter :: i_o2=2
-      integer,parameter :: i_o=3
-      integer,parameter :: i_co=4
-      integer,parameter :: i_h=5
-      integer,parameter :: i_h2=8
-      integer,parameter :: i_h2o=9
-      integer,parameter :: i_h2o2=10
-      integer,parameter :: i_o3=12
-      integer,parameter :: i_n2=13
-      integer,parameter :: i_n=14
-      integer,parameter :: i_no=15
-      integer,parameter :: i_no2=17
+      integer,parameter :: i_co2  =  1
+      integer,parameter :: i_co   =  2
+      integer,parameter :: i_o    =  3
+      integer,parameter :: i_o1d  =  4
+      integer,parameter :: i_o2   =  5
+      integer,parameter :: i_o3   =  6
+      integer,parameter :: i_h    =  7
+      integer,parameter :: i_h2   =  8
+      integer,parameter :: i_oh   =  9
+      integer,parameter :: i_ho2  = 10
+      integer,parameter :: i_h2o2 = 11
+      integer,parameter :: i_h2o  = 12
+      integer,parameter :: i_n    = 13
+      integer,parameter :: i_n2d  = 14
+      integer,parameter :: i_no   = 15
+      integer,parameter :: i_no2  = 16
+      integer,parameter :: i_n2   = 17
+!      integer,parameter :: i_co2=1
+!      integer,parameter :: i_o2=2
+!      integer,parameter :: i_o=3
+!      integer,parameter :: i_co=4
+!      integer,parameter :: i_h=5
+!      integer,parameter :: i_h2=8
+!      integer,parameter :: i_h2o=9
+!      integer,parameter :: i_h2o2=10
+!      integer,parameter :: i_o3=12
+!      integer,parameter :: i_n2=13
+!      integer,parameter :: i_n=14
+!      integer,parameter :: i_no=15
+!      integer,parameter :: i_no2=17
 
 c*************************PROGRAM STARTS*******************************
Index: trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/jthermcalc.F	(revision 2042)
@@ -1128,17 +1128,34 @@
       !!! ATTENTION. These values have to be identical to those in chemthermos.F90
       !!! If the values are changed there, the same has to be done here  !!!
-      integer,parameter :: i_co2=1
-      integer,parameter :: i_o2=2
-      integer,parameter :: i_o=3
-      integer,parameter :: i_co=4
-      integer,parameter :: i_h=5
-      integer,parameter :: i_h2=8
-      integer,parameter :: i_h2o=9
-      integer,parameter :: i_h2o2=10
-      integer,parameter :: i_o3=12
-      integer,parameter :: i_n2=13
-      integer,parameter :: i_n=14
-      integer,parameter :: i_no=15
-      integer,parameter :: i_no2=17
+      integer,parameter :: i_co2  =  1
+      integer,parameter :: i_co   =  2
+      integer,parameter :: i_o    =  3
+      integer,parameter :: i_o1d  =  4
+      integer,parameter :: i_o2   =  5
+      integer,parameter :: i_o3   =  6
+      integer,parameter :: i_h    =  7
+      integer,parameter :: i_h2   =  8
+      integer,parameter :: i_oh   =  9
+      integer,parameter :: i_ho2  = 10
+      integer,parameter :: i_h2o2 = 11
+      integer,parameter :: i_h2o  = 12
+      integer,parameter :: i_n    = 13
+      integer,parameter :: i_n2d  = 14
+      integer,parameter :: i_no   = 15
+      integer,parameter :: i_no2  = 16
+      integer,parameter :: i_n2   = 17
+!      integer,parameter :: i_co2=1
+!      integer,parameter :: i_o2=2
+!      integer,parameter :: i_o=3
+!      integer,parameter :: i_co=4
+!      integer,parameter :: i_h=5
+!      integer,parameter :: i_h2=8
+!      integer,parameter :: i_h2o=9
+!      integer,parameter :: i_h2o2=10
+!      integer,parameter :: i_o3=12
+!      integer,parameter :: i_n2=13
+!      integer,parameter :: i_n=14
+!      integer,parameter :: i_no=15
+!      integer,parameter :: i_no2=17
 
 
@@ -1343,5 +1360,4 @@
       enddo           !Of do i=nlayer,1,-1
 
-
       return
 
Index: trunk/LMDZ.MARS/libf/aeronomars/paramfoto_compact.F
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/paramfoto_compact.F	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/paramfoto_compact.F	(revision 2042)
@@ -86,21 +86,38 @@
 !!! ATTENTION. These values have to be identical to those in chemthermos.F90
 !!! If the values are changed there, the same has to be done here  !!!
-      integer,parameter :: i_co2=1
-      integer,parameter :: i_o2=2
-      integer,parameter :: i_o=3
-      integer,parameter :: i_co=4
-      integer,parameter :: i_h=5
-      integer,parameter :: i_oh=6
-      integer,parameter :: i_ho2=7
-      integer,parameter :: i_h2=8
-      integer,parameter :: i_h2o=9
-      integer,parameter :: i_h2o2=10
-      integer,parameter :: i_o1d=11
-      integer,parameter :: i_o3=12
-      integer,parameter :: i_n2=13
-      integer,parameter :: i_n=14
-      integer,parameter :: i_no=15
-      integer,parameter :: i_n2d=16
-      integer,parameter :: i_no2=17
+!      integer,parameter :: i_co2=1
+!      integer,parameter :: i_o2=2
+!      integer,parameter :: i_o=3
+!      integer,parameter :: i_co=4
+!      integer,parameter :: i_h=5
+!      integer,parameter :: i_oh=6
+!      integer,parameter :: i_ho2=7
+!      integer,parameter :: i_h2=8
+!      integer,parameter :: i_h2o=9
+!      integer,parameter :: i_h2o2=10
+!      integer,parameter :: i_o1d=11
+!      integer,parameter :: i_o3=12
+!      integer,parameter :: i_n2=13
+!      integer,parameter :: i_n=14
+!      integer,parameter :: i_no=15
+!      integer,parameter :: i_n2d=16
+!      integer,parameter :: i_no2=17
+      integer,parameter :: i_co2  =  1
+      integer,parameter :: i_co   =  2
+      integer,parameter :: i_o    =  3
+      integer,parameter :: i_o1d  =  4
+      integer,parameter :: i_o2   =  5
+      integer,parameter :: i_o3   =  6
+      integer,parameter :: i_h    =  7
+      integer,parameter :: i_h2   =  8
+      integer,parameter :: i_oh   =  9
+      integer,parameter :: i_ho2  = 10
+      integer,parameter :: i_h2o2 = 11
+      integer,parameter :: i_h2o  = 12
+      integer,parameter :: i_n    = 13
+      integer,parameter :: i_n2d  = 14
+      integer,parameter :: i_no   = 15
+      integer,parameter :: i_no2  = 16
+      integer,parameter :: i_n2   = 17
       integer,parameter :: i_co2plus=18
       integer,parameter :: i_oplus=19
@@ -175,5 +192,4 @@
             enddo
          end do
-         
 
          !Reaction rates
Index: trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F90
===================================================================
--- trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F90	(revision 2041)
+++ trunk/LMDZ.MARS/libf/aeronomars/photochemistry.F90	(revision 2042)
@@ -15,10 +15,13 @@
 subroutine photochemistry(nlayer, nq,                                   &
                           ig, lswitch, zycol, sza, ptimestep, press,    &
-                          alt, temp, dens, zmmean, dist_sol, surfdust1d,&
-                          surfice1d, jo3, jh2o, tau, iter)
+                          alt, temp, dens, zmmean, dist_sol, zday,      &
+                          surfdust1d, surfice1d, jo3, jh2o,tau, iter)
 
 use photolysis_mod, only : nb_phot_max,       &
                            nb_reaction_3_max, &
                            nb_reaction_4_max
+
+use param_v4_h, only: jdistot, jdistot_b
+
 implicit none
 
@@ -41,4 +44,5 @@
 real :: zmmean(nlayer)        ! mean molar mass (g/mole)
 real :: dist_sol              ! sun distance (au) 
+real :: zday                  ! date (time since Ls=0, in martian days)
 real :: surfdust1d(nlayer)    ! dust surface area (cm2/cm3)
 real :: surfice1d(nlayer)     ! ice surface area (cm2/cm3)
@@ -70,4 +74,5 @@
 logical, save :: firstcall = .true.
 logical :: jonline               ! switch for online photolysis
+logical :: jparam                ! switch for J parameterization
 
 ! tracer indexes in the chemistry:
@@ -91,4 +96,7 @@
 integer,parameter :: i_n2   = 17
 
+
+integer :: ilay
+
 real :: ctimestep           ! standard timestep for the chemistry (s) 
 real :: dt_guess            ! first-guess timestep (s) 
@@ -144,4 +152,5 @@
 
 jonline = .false.
+jparam= .false.
 
 if (jonline) then
@@ -155,4 +164,22 @@
       v_phot(:,:) = 0.
    end if
+else if(jparam) then
+   call jthermcalc_e107(ig,nlayer,2,c,nesp,temp,alt,sza,zday)
+   
+   do ilay=1,lswitch-1
+      call phdisrate(ig,nlayer,2,sza,ilay)
+   enddo
+   v_phot(:,1)=jdistot(2,:)
+   v_phot(:,2)=jdistot_b(2,:)
+   v_phot(:,3)=jdistot(1,:)
+   v_phot(:,4)=jdistot_b(1,:)
+   v_phot(:,5)=jdistot(7,:)
+   v_phot(:,6)=jdistot_b(7,:)
+   v_phot(:,7)=jdistot(4,:)
+   v_phot(:,8)=jdistot(6,:)
+   v_phot(:,10)=jdistot(5,:)
+   v_phot(:,11)=jdistot(10,:)
+   v_phot(:,12)=jdistot(13,:)
+   v_phot(:,13)=jdistot(8,:)
 else
    tau = tau*7./press(1) ! dust in the lookup table is at 7 hpa
@@ -1863,5 +1890,5 @@
 
       do iesp = 1,nesp
-         do l = 1,lswitch-1
+         do l = 1,nlayer!-1!lswitch-1
             c(l,iesp) = rm(l,iesp)*dens(l)
          end do
