Index: trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/compile_pgf
===================================================================
--- trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/compile_pgf	(revision 317)
+++ trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/compile_pgf	(revision 324)
@@ -8,10 +8,10 @@
 -L$NETCDF/lib -lnetcdf \
 -I$NETCDF/include \
--o readmeteo.exe
+-o readmeteo.exe #-DPHOTOCHEM
 
 pgf90 create_readmeteo.F90 \
 -L$NETCDF/lib -lnetcdf \
 -I$NETCDF/include \
--o create_readmeteo.exe
+-o create_readmeteo.exe #-DPHOTOCHEM \
 
 \rm fix_no_info.inc 2> /dev/null
Index: trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/readmeteo.F90
===================================================================
--- trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/readmeteo.F90	(revision 317)
+++ trunk/MESOSCALE/LMD_MM_MARS/SRC/PREP_MARS/readmeteo.F90	(revision 324)
@@ -98,4 +98,12 @@
 character*13, dimension(:), allocatable :: date_out
 character*19, dimension(:), allocatable :: date_out2
+
+#ifdef PHOTOCHEM
+real, dimension(:,:,:,:,:), allocatable :: chemtrac
+integer :: nchemtrac,i
+CHARACTER*20,DIMENSION(:),ALLOCATABLE :: wtnom
+#endif
+
+
 !***************************************************************************
 !***************************************************************************
@@ -230,9 +238,29 @@
 allocate(interm(lonlen,latlen))
 allocate(gwparam(lonlen,latlen,5))
-allocate(ghtsfile(lonlen,latlen))	!! no scan axis
+allocate(ghtsfile(lonlen,latlen))    !! no scan axis
 allocate(vide(lonlen,latlen))
 allocate(ones(lonlen,latlen))
 allocate(lat(latlen), lon(lonlen), alt(altlen), time(timelen))
 allocate(aps(altlen),bps(altlen),levels(altlen))
+#ifdef PHOTOCHEM
+nchemtrac = 14
+allocate(wtnom(nchemtrac))
+wtnom(1)  = "c_co2"
+wtnom(2)  = "c_co"
+wtnom(3)  = "c_o"
+wtnom(4)  = "c_o1d"
+wtnom(5)  = "c_o2"
+wtnom(6)  = "c_o3"
+wtnom(7)  = "c_h"
+wtnom(8)  = "c_h2"
+wtnom(9)  = "c_oh"
+wtnom(10) = "c_ho2"
+wtnom(11) = "c_h2o2"
+wtnom(12) = "c_ch4"
+wtnom(13) = "c_n2"
+wtnom(14) = "c_ar"
+allocate(chemtrac(lonlen,latlen,altlen,timelen,nchemtrac))
+chemtrac(:,:,:,:,:)=0
+#endif
 
 tfile(:,:,:,:)=0
@@ -523,8 +551,8 @@
    IF (ierr .NE. NF_NOERR) THEN
       ierr = NF_INQ_VARID (nid,"t",nvarid)
-	IF (ierr .NE. NF_NOERR) THEN
+        IF (ierr .NE. NF_NOERR) THEN
           PRINT *, "Error: Readmeteo <t> not found"
           stop
-	ENDIF
+        ENDIF
    ENDIF
 #ifdef NC_DOUBLE
@@ -627,5 +655,4 @@
 !! special dust stuff
 !!------------------------
-
 
 !SELECT CASE(ident)
@@ -677,4 +704,24 @@
 !!!!!!!!
 !!!!!!!! new physics
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
+!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
+#ifdef PHOTOCHEM
+    print *,'photochem'
+    DO i=1,nchemtrac
+     print *,wtnom(i)
+     ierr=NF_INQ_VARID(nid,wtnom(i),nvarid)
+     if (ierr.ne.NF_NOERR) then
+       write(*,*) "...No ",wtnom(i), " - set to 0"
+       chemtrac(:,:,:,:,i)=0.
+     else
+       ierr=NF_GET_VAR_REAL(nid,nvarid,chemtrac(:,:,:,:,i))
+     endif
+    ENDDO
+#endif
+!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
+!!!!!!!!!!!!!!!!!!!!!!!!NEW PHYSICS + PHOTOCHEM
+
 
 
@@ -1192,4 +1239,24 @@
 !print *,'The field '//DESC//' was written to '//output
 
+!------------------------!
+! >>> Write a variable   !
+!     PHOTOCHEMISTRY     !
+!------------------------!
+#ifdef PHOTOCHEM
+    DO i=1,nchemtrac
+       FIELD=wtnom(i)
+       UNITS='units'
+       DESC='desc'
+       XLVL=200100.
+       SLAB=chemtrac(:,:,1,time_out(l),i)
+       ! And now put everything in the destination file
+       ! ... Header
+       write(1) IFV
+       write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
+       write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
+       ! ... Data
+       write(1) SLAB
+    ENDDO
+#endif
 
 !!----------------------------------------------------
@@ -1455,4 +1522,28 @@
 END DO
 !print *,'The field '//DESC//' was written to '//output
+
+
+!------------------------!
+! >>> Write a variable   !
+!     PHOTOCHEMISTRY     !
+!------------------------!
+#ifdef PHOTOCHEM
+    DO i=1,nchemtrac
+       FIELD=wtnom(i)
+       UNITS='units'
+       DESC='desc'
+       DO k = 1,altlen
+         XLVL=levels(k)
+         SLAB=chemtrac(:,:,k,time_out(l),i)
+         ! And now put everything in the destination file
+         ! ... Header
+         write(1) IFV
+         write(1) HDATE,XFCST,SOURCE,FIELD,UNITS,DESC,XLVL,NX,NY,IPROJ
+         write(1) STARTLOC,STARTLAT,STARTLON,DELTALAT,DELTALON
+         ! ... Data
+         write(1) SLAB
+       END DO
+    ENDDO
+#endif
 
 print *,'****done file '//output, int(100.*float(l)/float(FILES)), ' % '
@@ -1498,4 +1589,8 @@
 deallocate(aps,bps,levels)
 
+#ifdef PHOTOCHEM
+deallocate(chemtrac)
+deallocate(wtnom)
+#endif
 
 print *, '------------------------'
Index: trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM
===================================================================
--- trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM	(revision 317)
+++ trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/Registry/Registry.EM	(revision 324)
@@ -130,4 +130,17 @@
 state  real  qdustn    ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "QDUSTN"        "Dust_number mixing ratio"   "kg kg-1"
 state  real  qco2      ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "QCO2"          "CO2 mixing ratio"           "kg kg-1"
+state  real  chem_co   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_co"     ""   ""
+state  real  chem_o    ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_o"      ""   ""
+state  real  chem_o1d  ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_o1d"    ""   ""
+state  real  chem_o2   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_o2"     ""   ""
+state  real  chem_o3   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_o3"     ""   ""
+state  real  chem_h    ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_h"      ""   ""
+state  real  chem_h2   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_h2"     ""   ""
+state  real  chem_oh   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_oh"     ""   ""
+state  real  chem_ho2  ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_ho2"    ""   ""
+state  real  chem_h2o2 ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_h2o2"   ""   ""
+state  real  chem_ch4  ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_ch4"    ""   ""
+state  real  chem_n2   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_n2"     ""   ""
+state  real  chem_ar   ikjftb  scalar  1  -  i01rusdf=(bdy_interp:dt)  "chem_ar"     ""   ""
 ####
 ####
@@ -1353,4 +1366,5 @@
 package   dust2eq      mars==3                      -              scalar:qdust,qdustn
 package   newwater     mars==11                     -              scalar:qh2o,qh2o_ice,qdust,qdustn
+package   photochem    mars==42                     -              scalar:qco2,chem_co,chem_o,chem_o1d,chem_o2,chem_o3,chem_h,chem_h2,chem_oh,chem_ho2,chem_h2o2,chem_ch4,chem_n2,chem_ar,qh2o_ice,qh2o,qdust,qdustn
 ##### MARS OPTIONS
 ##### MARS OPTIONS
Index: trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F
===================================================================
--- trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 317)
+++ trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/phys/module_lmd_driver.F	(revision 324)
@@ -650,5 +650,5 @@
 
 SELECT CASE (MARS_MODE) !! ONLY ALLOW FOR MODES DEFINED IN Registry.EM
-   CASE(4-10,12-19,22:)      !! -- CHANGE THIS if YOU ADDED CASES in REGISTRY.EM
+   CASE(4-10,12-19,22-41,43:)      !! -- CHANGE THIS if YOU ADDED CASES in REGISTRY.EM
    PRINT *, 'NOT SUPPORTED, to be done'
    STOP
@@ -662,4 +662,5 @@
 !package   radioac      mars==20                     -              scalar:qtrac1
 !package   radioac2     mars==21                     -              scalar:upward,downward
+!package   photochem    mars==42                     -              scalar:qco2,chem_co,chem_o,chem_o1d,chem_o2,chem_o3,chem_h,chem_h2,chem_oh,chem_ho2,chem_h2o2,chem_ch4,chem_n2,chem_ar,qh2o_ice,qh2o,qdust,qdustn
 !!!!!!!!!!!!!!!!!!! FOR REFERENCE
 
@@ -672,14 +673,14 @@
       wtnom(nq) = 'co2'
     CASE(1)
-      wtnom(1)  = 'h2o_vap'     
-      wtnom(2)  = 'h2o_ice'     
+      wtnom(1)  = 'h2o_vap'
+      wtnom(2)  = 'h2o_ice' 
     CASE(2)
       wtnom(1)  = 'dust01'      
     CASE(3)
       wtnom(1)  = 'dust_mass'
-      wtnom(2)  = 'dust_number'
+      wtnom(2)  = 'dust_number' 
     CASE(11) 
       wtnom(1)  = 'h2o_vap'
-      wtnom(2)  = 'h2o_ice'
+      wtnom(2)  = 'h2o_ice' 
       wtnom(3)  = 'dust_mass'
       wtnom(4)  = 'dust_number'
@@ -688,5 +689,24 @@
     CASE(21)
       wtnom(1) = 'upward'
-      wtnom(2) = 'downward'
+      wtnom(2) = 'downward' 
+    CASE(42)
+      wtnom(1)  = 'co2'
+      wtnom(2)  = 'co'
+      wtnom(3)  = 'o'
+      wtnom(4)  = 'o1d'
+      wtnom(5)  = 'o2'
+      wtnom(6)  = 'o3'
+      wtnom(7)  = 'h'
+      wtnom(8)  = 'h2'
+      wtnom(9)  = 'oh'
+      wtnom(10)  = 'ho2'
+      wtnom(11)  = 'h2o2'
+      wtnom(12)  = 'ch4'
+      wtnom(13)  = 'n2'
+      wtnom(14)  = 'ar'
+      wtnom(15)  = 'h2o_ice'
+      wtnom(16)  = 'h2o_vap'
+      wtnom(17)  = 'dust_mass'
+      wtnom(18)  = 'dust_number'
 END SELECT
 #endif
@@ -729,14 +749,12 @@
 q_prof(:,1:nq) = SCALAR(i,kps:kpe,j,2:nq+1)  !! the names were set above !! one dummy tracer in WRF
   !!! CAS DU CO2
-DO iii=1,nq 
- IF ( wtnom(iii) .eq. 'co2' ) q_prof(:,iii) = 0.95
-ENDDO
-
-IF ((MARS_MODE .EQ. 20) .OR. (MARS_MODE .EQ. 21)) THEN
+  DO iii=1,nq 
+   IF ( wtnom(iii) .eq. 'co2' ) q_prof(:,iii) = 0.95
+  ENDDO
+  IF ((MARS_MODE .EQ. 20) .OR. (MARS_MODE .EQ. 21)) THEN
    IF (firstcall .EQV. .true.) THEN
       q_prof(:,:) = 0.95
    ENDIF
-ENDIF
-
+  ENDIF
 #else
 SELECT CASE (MARS_MODE)
@@ -841,5 +859,5 @@
 !!!! ADDITIONAL SECURITY. THIS MIGHT HAPPEN WITH OLD INIT FILES.
 IF (z0_val == 0.) THEN
-   PRINT *, 'WELL, z0 is 0, this is no good. Setting to old defaults value 0.01 m'
+   IF ( (i == ips) .AND. (j == jps) ) PRINT *, 'WELL, z0 is 0, this is no good. Setting to old defaults value 0.01 m'
    z0_val = 0.01
 ENDIF
