Index: trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F
===================================================================
--- trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 2909)
+++ trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/newstart.F	(revision 2910)
@@ -55,4 +55,6 @@
       use comslope_mod, ONLY: nslope,def_slope,def_slope_mean,
      &             subslope_dist,end_comslope_h,ini_comslope_h
+      USE subslope_mola_mod, ONLY: subslope_mola
+      
       implicit none
 
Index: trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/subslope_mola.F90
===================================================================
--- trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/subslope_mola.F90	(revision 2909)
+++ trunk/LMDZ.MARS/libf/dynphy_lonlat/phymars/subslope_mola.F90	(revision 2910)
@@ -1,2 +1,8 @@
+MODULE subslope_mola_mod
+
+IMPLICIT NONE
+
+CONTAINS
+
 SUBROUTINE subslope_mola(ngridmx,nslope,def_slope,subslope_dist)
 
@@ -6,4 +12,5 @@
                                  north_east, north_west, &
                                  south_west, south_east
+USE datafile_mod, ONLY: datadir
 
 IMPLICIT NONE
@@ -15,11 +22,9 @@
       integer :: jjm_mola, iim_mola 
       parameter(jjm_mola=180*resol, iim_mola=2*jjm_mola)
-      character*(*) dset ! Path to MCD datafiles 
-      parameter(dset ='/ccc/scratch/cont003/gen10391/vandemer/test_pem2_watercap/datadir/')
       integer :: ierr 
 ! returned status code (==0 if OK)
-      real :: theta_mola(iim_mola,jjm_mola) 
+      real,allocatable :: theta_mola(:,:) !theta_mola(iim_mola,jjm_mola) 
 !ED18 : slopes inclination (see getslope.F90)
-      real :: psi_mola(iim_mola,jjm_mola) 
+      real,allocatable :: psi_mola(:,:) !psi_mola(iim_mola,jjm_mola) 
 !ED18 : slopes orientation (idem)     
       REAL :: lon1, lon2, lat1, lat2 !bounds of the square
@@ -39,7 +44,22 @@
       LOGICAL,PARAMETER :: rfz = .false.
       INTEGER,PARAMETER :: igps = 1000 !first ig for RFZ location
-
+      
+      ! allocate big arrays
+      allocate(theta_mola(iim_mola,jjm_mola),stat=ierr)
+      if (ierr/=0) then
+        write(*,*)"subslope_mola: allocation of theta_mola(:,:) failed!"
+        stop
+      endif
+      allocate(psi_mola(iim_mola,jjm_mola),stat=ierr)
+      if (ierr/=0) then
+        write(*,*)"subslope_mola: allocation of psi_mola(:,:) failed!"
+        stop
+      endif
+      
+  
 !-------------Building of theta_mola and psi_mola 
-      CALL mola(dset,ierr,theta_mola,psi_mola,resol,iim_mola,jjm_mola)
+      ! Assume that the mola file is to ben found in "datadir"
+      CALL mola(trim(datadir)//"/",&
+                ierr,theta_mola,psi_mola,resol,iim_mola,jjm_mola)
 
 !-------------Building of distribution
@@ -83,4 +103,7 @@
               max_crit,max_lon,max_lat
 
+     ! deallocate big arrays (this routine is only called once)
+     deallocate(theta_mola,psi_mola)
+     
 END SUBROUTINE subslope_mola
 
@@ -159,6 +182,5 @@
                        trim(molafile)
             endif
-            ierr=15 !set appropriate error code
-            return
+            stop
          endif
 
@@ -174,6 +196,5 @@
             write(*,*)"Error in mola: <alt> not found"
            endif
-           ierr=16 ! set appropriate error code
-           return
+           stop
          endif
 
@@ -364,5 +385,5 @@
       INTEGER :: i_lon1, i_lon2
       INTEGER :: j_lat1, j_lat2
-      REAL :: crit !function
+!      REAL :: crit !function
       REAL :: val_crit !intermediate for evaluating the criterium
       REAL :: max_crit !indicator for maximum slope criterium computed
@@ -531,6 +552,5 @@
 
 
-END SUBROUTINE slopes_stat
-
+      CONTAINS
 
 !***********************************************************************
@@ -543,5 +563,5 @@
 
       REAL crit
-      REAL theta, psi
+      REAL,INTENT(IN) :: theta, psi
       real, parameter :: pi = acos(-1.)
 
@@ -553,2 +573,7 @@
 
 
+END SUBROUTINE slopes_stat
+
+
+
+END MODULE subslope_mola_mod
