Index: /trunk/LMDZ.GENERIC/README
===================================================================
--- /trunk/LMDZ.GENERIC/README	(revision 373)
+++ /trunk/LMDZ.GENERIC/README	(revision 374)
@@ -541,2 +541,7 @@
   'create_make_gcm'.
  
+== 10/11/2011 == EM
+- Upgrade: The location of the 'datagcm' directory can now be given in the
+  callphys.def file ( datadir = /absolute/path/to/datagcm ). Changed
+  "datafile.h" into a F90 module "datafile_mod.F90" and spread this change
+  to all routines that used to use "datafile.h".
Index: /trunk/LMDZ.GENERIC/libf/dyn3d/newstart.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/dyn3d/newstart.F	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/dyn3d/newstart.F	(revision 374)
@@ -1836,4 +1836,5 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       subroutine load_MONS_data(MONS_Hdn,MONS_d21)
+      use datafile_mod, only: datadir
       implicit none
       ! routine to load Benedicte Diez MONS dataset, fill in date in southern
@@ -1841,5 +1842,4 @@
 #include"dimensions.h"
 #include"paramet.h"
-#include"datafile.h"
 #include"comgeom.h"
       ! arguments:
@@ -1871,13 +1871,14 @@
 
       ! Open MONS datafile:
-      open(42,file=trim(datafile)//"/"//trim(filename),
+      open(42,file=trim(datadir)//"/"//trim(filename),
      &     status="old",iostat=ierr)
       if (ierr/=0) then
         write(*,*) "Error in load_MONS_data:"
         write(*,*) "Failed opening file ",
-     &             trim(datafile)//"/"//trim(filename)
-        write(*,*)'1) You can change the path to the file in '
-        write(*,*)'   file phymars/datafile.h'
-        write(*,*)'2) If necessary ',trim(filename),
+     &             trim(datadir)//"/"//trim(filename)
+        write(*,*)'Check that your path to datagcm:',trim(datadir)
+        write(*,*)' is correct. You can change it in callphys.def with:'
+        write(*,*)' datadir = /absolute/path/to/datagcm'
+        write(*,*)'If necessary ',trim(filename),
      &                 ' (and other datafiles)'
         write(*,*)'   can be obtained online at:'
Index: /trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/ave_stelspec.F90	(revision 374)
@@ -24,8 +24,8 @@
       use radinc_h, only: L_NSPECTV
       use radcommon_h, only: BWNV, DWNV, tstellar
+      use datafile_mod, only: datadir
 
       implicit none
 
-#include "datafile.h"
 #include "callkeys.h"
 
@@ -47,4 +47,6 @@
       real lam_temp
       double precision stel_temp
+      
+      integer :: ios ! file opening/reading status
 
       STELLAR(:)=0.0
@@ -52,11 +54,21 @@
       ! load high resolution wavenumber data
       file_id='/stellar_spectra/lam.txt'
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_path=TRIM(datadir)//TRIM(file_id)
 
-      open(110,file=file_path,form='formatted')
-      do ifine=1,Nfine
-         read(110,*) lam(ifine)
-      enddo
-      close(110)
+      open(110,file=file_path,form='formatted',status='old',iostat=ios)
+      if (ios.ne.0) then        ! file not found
+        write(*,*) 'Error from ave_stelspec'
+        write(*,*) 'Data file ',trim(file_id),' not found.'
+        write(*,*)'Check that your path to datagcm:',trim(datadir)
+        write(*,*)' is correct. You can change it in callphys.def with:'
+        write(*,*)' datadir = /absolute/path/to/datagcm'
+        write(*,*)' Also check that there is a ',trim(file_id),' there.'
+        call abort
+      else
+        do ifine=1,Nfine
+          read(110,*) lam(ifine)
+        enddo
+        close(110)
+      endif
 
       dl=lam(2)-lam(1)
@@ -92,11 +104,21 @@
             call abort
          endif
-         file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
-
-         open(111,file=file_path,form='formatted')
-         do ifine=1,Nfine
-            read(111,*) stel_f(ifine)
-         enddo
-         close(111)
+         
+         file_path=TRIM(datadir)//TRIM(file_id)
+         open(111,file=file_path,form='formatted',status='old',iostat=ios)
+         if (ios.ne.0) then        ! file not found
+           write(*,*) 'Error from ave_stelspec'
+           write(*,*) 'Data file ',trim(file_id),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a ',trim(file_id),' there.'
+           call abort
+         else
+           do ifine=1,Nfine
+             read(111,*) stel_f(ifine)
+           enddo
+           close(111)
+         endif
       endif
 
Index: /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/callcorrk.F90	(revision 374)
@@ -11,4 +11,5 @@
       use radcommon_h
       use watercommon_h
+      use datafile_mod, only: datadir
       use ioipsl_getincom 
 
@@ -31,5 +32,4 @@
 
 #include "dimphys.h"
-#include "datafile.h"
 #include "comcstfi.h"
 #include "callkeys.h"
@@ -233,5 +233,5 @@
          endif
 
-         print*, "Correlated-k data base folder:",datafile
+         print*, "callcorrk: Correlated-k data base folder:",trim(datadir)
          call getin("corrkdir",corrkdir)
          print*, "corrkdir = ",corrkdir
Index: unk/LMDZ.GENERIC/libf/phystd/datafile.h
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/datafile.h	(revision 373)
+++ 	(revision )
@@ -1,10 +1,0 @@
-!-----------------------------------------------------------------------
-! INCLUDE datafile.h
-
-!  Address of the directory containing tables of data needed by the UCM
-
-      character (len=300) :: datafile
-!      data datafile /'/home/rdword/gcm/datagcm_lite'/  ! laptop
-      data datafile /'/san/home/rdword/gcm/datagcm'/  ! gnome iDataPlex
-!      data datafile /'/u/rwlmd/datagcm'/  ! planetary cluster
-!-----------------------------------------------------------------------
Index: /trunk/LMDZ.GENERIC/libf/phystd/datafile_mod.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/datafile_mod.F90	(revision 374)
+++ /trunk/LMDZ.GENERIC/libf/phystd/datafile_mod.F90	(revision 374)
@@ -0,0 +1,12 @@
+!-----------------------------------------------------------------------
+      module datafile_mod
+!  Address of the directory containing tables of data needed by the UCM
+      implicit none
+
+      ! Default for Gnome Idataplex:
+      character(len=300) :: datadir='/san/home/rdword/gcm/datagcm'
+      ! Default for LMD machines:
+!      character(len=300) :: datadir='/u/rwlmd/datagcm'
+
+      end module datafile_mod
+!-----------------------------------------------------------------------
Index: /trunk/LMDZ.GENERIC/libf/phystd/datareadnc.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/datareadnc.F	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/datareadnc.F	(revision 374)
@@ -42,4 +42,5 @@
 c=======================================================================
 
+      use datafile_mod, only: datadir
       implicit none
 
@@ -49,5 +50,4 @@
 #include "comconst.h"
 #include "netcdf.inc"
-#include "datafile.h"
 
 c=======================================================================
@@ -112,5 +112,5 @@
 
       write(*,*) 'Choice of surface data is:'
-      filestring='ls '//datafile(1:lnblnk(datafile))//'/*.nc'
+      filestring='ls '//trim(datadir)//'/*.nc'
       call system(filestring)
 
@@ -120,16 +120,15 @@
       read(*,fmt='(a20)') filename
 
-!      ierr = NF_OPEN (datafile(1:lnblnk(datafile))//'/surface.nc',
-!     &  NF_NOWRITE,unit)
-      ierr = NF_OPEN (datafile(1:lnblnk(datafile))//'/'//filename,
+      ierr = NF_OPEN (trim(datadir)//'/'//trim(adjustl(filename)),
      &  NF_NOWRITE,unit)
       IF (ierr.NE.NF_NOERR) THEN
-        write(*,*)'Error : cannot open file '//filename
+        write(*,*)'Error : cannot open file '//trim(filename)
         write(*,*)'(in phystd/datareadnc.F)'
-        write(*,*)'It should be in :',datafile(1:lnblnk(datafile)),'/'
-        write(*,*)'1) You can change this directory address in '
-        write(*,*)'   file phystd/datafile.h'
-        write(*,*)'2) If necessary surface.nc (and other datafiles)'
-        write(*,*)'   can be obtained online on:'
+        write(*,*)'It should be in :',trim(datadir),'/'
+        write(*,*)'Check that your path to datagcm:',trim(datadir)
+        write(*,*)' is correct. You can change it in callphys.def with:'
+        write(*,*)' datadir = /absolute/path/to/datagcm'
+        write(*,*)'If necessary surface.nc (and other datafiles)'
+        write(*,*)' can be obtained online on:'
         write(*,*)' http://www.lmd.jussieu.fr/~forget/datagcm/datafile'
         CALL ABORT
Index: /trunk/LMDZ.GENERIC/libf/phystd/inifis.F
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/inifis.F	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/inifis.F	(revision 374)
@@ -5,5 +5,5 @@
 
       use radinc_h, only : naerkind
-
+      use datafile_mod, only: datadir
 
 !=======================================================================
@@ -42,4 +42,5 @@
 !   declarations:
 !   -------------
+      use datafile_mod, only: datadir
 ! to use  'getin'
       USE ioipsl_getincom 
@@ -121,4 +122,9 @@
          PRINT*,'--------------------------------------------'
 
+         write(*,*) "Directory where external input files are:"
+         ! default 'datadir' is set in "datadir_mod"
+         call getin("datadir",datadir) ! default path
+         write(*,*) " datadir = ",trim(datadir)
+
          write(*,*) "Run with or without tracer transport ?"
          tracer=.false. ! default value
Index: /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2H2.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2H2.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2H2.F90	(revision 374)
@@ -1,4 +1,3 @@
      subroutine interpolateH2H2(wn,temp,pres,abcoef,firstcall)
-      implicit none
 
 !==================================================================
@@ -15,5 +14,6 @@
 !==================================================================
 
-#include "datafile.h"
+      use datafile_mod, only: datadir
+      implicit none
 
       ! input
@@ -50,11 +50,14 @@
 
          ! cold
-         dt_file=datafile(1:LEN_TRIM(datafile))//'/continuum_data/H2H2_CIA_LT.dat'
+         dt_file=TRIM(datadir)//'/continuum_data/H2H2_CIA_LT.dat'
          open(33,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
-            write(*,*) 'Error from interpolateH2H2.for'
-            write(*,*) 'Data file could not be found:'
-            write(*,*) dt_file
-            call abort
+           write(*,*) 'Error from interpolateH2H2'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2H2_CIA_LT.dat there.'
+           call abort
          else
             do k=1,nS
@@ -67,11 +70,14 @@
 
          ! hot
-         dt_file=datafile(1:LEN_TRIM(datafile))//'/continuum_data/H2H2_CIA_HT.dat'
+         dt_file=TRIM(datadir)//'/continuum_data/H2H2_CIA_HT.dat'
          open(34,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
-            write(*,*) 'Error from interpolateH2H2.for'
-            write(*,*) 'Data file could not be found:'
-            write(*,*) dt_file
-            call abort
+           write(*,*) 'Error from interpolateH2H2'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2H2_CIA_HT.dat there.'
+           call abort
          else
             do k=1,nS
@@ -100,5 +106,5 @@
 
 
-         print*,'At wavenumber ',wn,' cm^-1'
+         print*,'interpolateH2H2: At wavenumber ',wn,' cm^-1'
          print*,'   temperature ',temp,' K'
          print*,'   pressure ',pres,' Pa'
@@ -172,5 +178,5 @@
       
       if ((y.lt.y_arr(1)).or.(y.gt.y_arr(nY))) then
-         write(*,*) 'Warning from bilinear.for:'
+         write(*,*) 'Warning from bilinearH2H2:'
          write(*,*) 'Outside continuum temperature range!'
          if(y.lt.y_arr(1))then
Index: /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2Ocont.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2Ocont.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/interpolateH2Ocont.F90	(revision 374)
@@ -1,4 +1,3 @@
      subroutine interpolateH2Ocont(wn,temp,presS,presF,abcoef,firstcall)
-      implicit none
 
 !==================================================================
@@ -15,5 +14,6 @@
 !==================================================================
 
-#include "datafile.h"
+      use datafile_mod, only: datadir
+      implicit none
 
       ! input
@@ -56,11 +56,14 @@
 
          ! nu array
-         dt_file=datafile(1:LEN_TRIM(datafile))//'/continuum_data/H2O_CONT_NU.dat'
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_NU.dat'
          open(33,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
-            write(*,*) 'Error from interpolateH2O_cont.for'
-            write(*,*) 'Data file could not be found:'
-            write(*,*) dt_file
-            call abort
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_NU.dat there.'
+           call abort
          else
             do k=1,nS
@@ -71,11 +74,14 @@
 
          ! self broadening
-         dt_file=datafile(1:LEN_TRIM(datafile))//'/continuum_data/H2O_CONT_SELF.dat'
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_SELF.dat'
          open(34,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
-            write(*,*) 'Error from interpolateH2O_cont.for'
-            write(*,*) 'Data file could not be found:'
-            write(*,*) dt_file
-            call abort
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_SELF.dat there.'
+           call abort
          else
             do k=1,nS
@@ -87,11 +93,14 @@
 
          ! foreign (N2+O2+Ar) broadening
-         dt_file=datafile(1:LEN_TRIM(datafile))//'/continuum_data/H2O_CONT_FOREIGN.dat'
+         dt_file=TRIM(datadir)//'/continuum_data/H2O_CONT_FOREIGN.dat'
          open(35,file=dt_file,form='formatted',status='old',iostat=ios)
          if (ios.ne.0) then        ! file not found
-            write(*,*) 'Error from interpolateH2O_cont.for'
-            write(*,*) 'Data file could not be found:'
-            write(*,*) dt_file
-            call abort
+           write(*,*) 'Error from interpolateH2O_cont'
+           write(*,*) 'Data file ',trim(dt_file),' not found.'
+           write(*,*)'Check that your path to datagcm:',trim(datadir)
+           write(*,*)' is correct. You can change it in callphys.def with:'
+           write(*,*)' datadir = /absolute/path/to/datagcm'
+           write(*,*)' Also check that there is a continuum_data/H2O_CONT_FOREIGN.dat there.'
+           call abort
          else
             do k=1,nS
@@ -114,5 +123,5 @@
          temp_arr(11) = 700.
 
-         print*,'At wavenumber ',wn,' cm^-1'
+         print*,'interpolateH2Ocont: At wavenumber ',wn,' cm^-1'
          print*,'   temperature ',temp,' K'
          print*,'   H2O pressure ',presS,' Pa'
@@ -210,5 +219,5 @@
       
       if ((y.lt.y_arr(1)).or.(y.gt.y_arr(nY))) then
-         write(*,*) 'Warning from bilinear.for:'
+         write(*,*) 'Warning from bilinearH2Ocont:'
          write(*,*) 'Outside continuum temperature range!'
          if(y.lt.y_arr(1))then
Index: /trunk/LMDZ.GENERIC/libf/phystd/setspi.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/setspi.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/setspi.F90	(revision 374)
@@ -24,4 +24,5 @@
       use radinc_h,    only: L_NSPECTI,corrkdir,banddir,NTstar,NTstop
       use radcommon_h, only: BWNI,BLAMI,WNOI,DWNI,WAVEI,planckir,sigma
+      use datafile_mod, only: datadir
 
       implicit none
@@ -29,5 +30,4 @@
 #include "callkeys.h"
 #include "comcstfi.h"
-#include "datafile.h"
 
       logical file_ok
@@ -74,11 +74,15 @@
       !file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/narrowbands_IR.in'
       file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_IR.in' 
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_path=TRIM(datadir)//TRIM(file_id)
 
       ! check that the file exists
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by setspi.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
@@ -92,7 +96,7 @@
 
       if(file_entries-1.ne.L_NSPECTI) then
-         write(*,*) 'L_NSPECTI = ',L_NSPECTI, 'in the model, but there are '
+         write(*,*) 'setspi: L_NSPECTI = ',L_NSPECTI, 'in the model, but there are '
          write(*,*) file_entries-1,'entries in ', &
-              file_path(1:LEN_TRIM(file_path)),', exiting.'
+              TRIM(file_path),', exiting.'
          call abort
       endif
@@ -110,5 +114,5 @@
 
       print*,''
-      print*,'IR band limits:'
+      print*,'setspi: IR band limits:'
       do M=1,L_NSPECTI+1
          print*,m,'-->',BWNI(M),' cm^-1'
@@ -134,5 +138,5 @@
 
       print*,''
-      print*,'Current Planck integration range:'
+      print*,'setspi: Current Planck integration range:'
       print*,'T = ',dble(NTstar)/1.0D+1, ' to ',dble(NTstop)/1.0D+1,' K.'
 
@@ -157,5 +161,5 @@
       ! force planck=sigma*eps*T^4 for each temperature in array
       if(forceEC)then
-         print*,'Force F=sigma*eps*T^4 for all values of T!'
+         print*,'setspi: Force F=sigma*eps*T^4 for all values of T!'
          do nt=NTstar,NTstop
             plancksum=0.0
@@ -182,5 +186,5 @@
             plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
          end do
-         print*,'At lower limit:'
+         print*,'setspi: At lower limit:'
          print*,'in model sig*T^4 = ',plancksum,' W m^-2'
          print*,'actual sig*T^4   = ',sigma*(dble(nt)/1.0D+1)**4,' W m^-2'
@@ -192,5 +196,5 @@
             plancksum=plancksum+planckir(NW,nt-NTstar+1)*DWNI(NW)*pi
          end do
-         print*,'At upper limit:'
+         print*,'setspi: At upper limit:'
          print*,'in model sig*T^4 = ',plancksum,' W m^-2'
          print*,'actual sig*T^4   = ',sigma*(dble(nt)/1.0D+1)**4,' W m^-2'
Index: /trunk/LMDZ.GENERIC/libf/phystd/setspv.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/setspv.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/setspv.F90	(revision 374)
@@ -26,4 +26,5 @@
       use radcommon_h, only: BWNV,BLAMV,WNOV,DWNV,WAVEV, &
                              STELLARF,TAURAY,gastype
+      use datafile_mod, only: datadir
 
       implicit none
@@ -31,5 +32,4 @@
 #include "comcstfi.h"
 #include "callkeys.h"
-#include "datafile.h"
 
       logical file_ok
@@ -52,11 +52,15 @@
       write(temp1,'(i2.2)') L_NSPECTV
       file_id='/corrk_data/'//trim(adjustl(banddir))//'/narrowbands_VI.in' 
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_path=TRIM(datadir)//TRIM(file_id)
 
       ! check that the file exists
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by setspv.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
@@ -70,7 +74,7 @@
 
       if(file_entries-1.ne.L_NSPECTV) then
-         write(*,*) 'L_NSPECTV = ',L_NSPECTV, 'in the model, but there are '
+         write(*,*) 'setspv: L_NSPECTV = ',L_NSPECTV, 'in the model, but there are '
          write(*,*) file_entries-1,'entries in ', &
-              file_path(1:LEN_TRIM(file_path)),', exiting.'
+              TRIM(file_path),', exiting.'
          call abort
       endif
@@ -88,5 +92,5 @@
 
 
-      print*,'VI band limits:'
+      print*,'setspv: VI band limits:'
       do M=1,L_NSPECTV+1
          print*,m,'-->',BWNV(M),' cm^-1'
@@ -109,5 +113,5 @@
 !     Set up stellar spectrum
 
-      write(*,*)'Interpolating stellar spectrum from the hires data...'
+      write(*,*)'setspv: Interpolating stellar spectrum from the hires data...'
       call ave_stelspec(STELLAR)
 
@@ -118,5 +122,5 @@
          sum         = sum+STELLARF(N)
       end do
-      write(6,'(" Stellar flux at 1 AU = ",f7.2," W m-2")') sum
+      write(6,'("setspv: Stellar flux at 1 AU = ",f7.2," W m-2")') sum
       print*,' '
 
@@ -130,5 +134,5 @@
          call calc_rayleigh
       else
-         print*,'No Rayleigh scattering, check for NaN in output!'
+         print*,'setspv: No Rayleigh scattering, check for NaN in output!'
          do N=1,L_NSPECTV
             TAURAY(N) = 1E-16
Index: /trunk/LMDZ.GENERIC/libf/phystd/suaer_corrk.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/suaer_corrk.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/suaer_corrk.F90	(revision 374)
@@ -4,4 +4,5 @@
       use radinc_h,    only: L_NSPECTI,L_NSPECTV,naerkind,nsizemax,iim,jjm
       use radcommon_h, only: blamv,blami,lamrefir,lamrefvis
+      use datafile_mod, only: datadir
 
       ! outputs
@@ -43,5 +44,4 @@
 
 #include "callkeys.h"
-#include "datafile.h"
 
 !     Optical properties (read in external ASCII files)
@@ -173,28 +173,25 @@
 !     1.1 Open the ASCII file
 
-            INQUIRE(FILE=datafile(1:LEN_TRIM(datafile))//&
-         '/'//file_id(iaer,idomain)(1:LEN_TRIM(file_id(iaer,idomain))),&
+            INQUIRE(FILE=TRIM(datadir)//&
+         '/'//TRIM(file_id(iaer,idomain)),&
             EXIST=file_ok)
             IF(.NOT.file_ok) THEN
-               write(*,*)'Problem opening ',&
-               file_id(iaer,idomain)(1:LEN_TRIM(file_id(iaer,idomain)))
-               write(*,*)'It should be in: ',&
-               datafile(1:LEN_TRIM(datafile))
-               write(*,*)'1) You can change this directory address in '
-               write(*,*)' file phymars/datafile.h'
+               write(*,*)'suaer_corrk: Problem opening ',&
+               TRIM(file_id(iaer,idomain))
+               write(*,*)'It should be in: ',TRIM(datadir)
+               write(*,*)'1) You can set this directory address ',&
+               'in callphys.def with:'
+               write(*,*)' datadir = /absolute/path/to/datagcm'
                write(*,*)'2) If ',&
-              file_id(iaer,idomain)(1:LEN_TRIM(file_id(iaer,idomain))),&
+              TRIM(file_id(iaer,idomain)),&
                ' is a LMD reference datafile, it'
                write(*,*)' can be obtained online at:'
                write(*,*)' http://www.lmd.jussieu.fr/',&
                '~forget/datagcm/datafile'
-               write(*,*)'3) If the name of the file is wrong, you can'
-               write(*,*)' change it in file phyuniv/suaer_corrk.F90. Just'
-               write(*,*)' modify the variable called file_id.'
                CALL ABORT 
             ENDIF
             OPEN(UNIT=file_unit,&
-            FILE=datafile(1:LEN_TRIM(datafile))//&
-         '/'//file_id(iaer,idomain)(1:LEN_TRIM(file_id(iaer,idomain))),&
+            FILE=TRIM(datadir)//&
+         '/'//TRIM(file_id(iaer,idomain)),&
             FORM='formatted')
 
Index: /trunk/LMDZ.GENERIC/libf/phystd/sugas_corrk.F90
===================================================================
--- /trunk/LMDZ.GENERIC/libf/phystd/sugas_corrk.F90	(revision 373)
+++ /trunk/LMDZ.GENERIC/libf/phystd/sugas_corrk.F90	(revision 374)
@@ -23,8 +23,7 @@
       use radcommon_h, only : gasv,gasi,FZEROI,FZEROV,gweight
       use radcommon_h, only : wrefvar,gastype
-
+      use datafile_mod, only: datadir
       implicit none
 
-#include "datafile.h"
 #include "callkeys.h"
 #include "gases.h"
@@ -38,5 +37,5 @@
 
       character(len=100) :: file_id
-      character(len=100) :: file_path
+      character(len=300) :: file_path
 
       real*8 gasi8(L_NTREF,L_NPREF,L_REFVAR,L_NSPECTI,L_NGAUSS)
@@ -51,6 +50,6 @@
 !=======================================================================
 !     Load variable species data, exit if we have wrong database
-      file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/Q.dat'
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/Q.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
 
 
@@ -58,13 +57,15 @@
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by sugas_corrk.F90, exiting.'
-         write(*,*)'Check that your path to datagcm in datafile.h is correct and that'
-         write(*,*)'the corrkdir you chose in callphys.def exists.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
 
       ! check that database matches varactive toggle
-      open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+      open(111,file=TRIM(file_path),form='formatted')
       read(111,*) ngas
 
@@ -139,19 +140,21 @@
 !     Set the weighting in g-space
 
-      file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/g.dat'
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/g.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
 
       ! check that the file exists
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by sugas_corrk.F90, exiting.'
-         write(*,*)'Check that your path to datagcm in datafile.h is correct and that'
-         write(*,*)'the corrkdir you chose in callphys.def exists.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
       
       ! check the array size is correct, load the coefficients
-      open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+      open(111,file=TRIM(file_path),form='formatted')
       read(111,*) L_NGAUSScheck
       if(.not.(L_NGAUSScheck.eq.L_NGAUSS)) then
@@ -177,17 +180,21 @@
 ! pressure
 
-      file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/p.dat'
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/p.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
 
       ! check that the file exists
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
       
       ! check the array size is correct, load the coefficients
-      open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+      open(111,file=TRIM(file_path),form='formatted')
       read(111,*) L_NPREFcheck
       if(.not.(L_NPREFcheck.eq.L_NPREF)) then
@@ -222,17 +229,21 @@
 ! temperature
 
-      file_id='/corrk_data/' // corrkdir(1:LEN_TRIM(corrkdir)) // '/T.dat'
-      file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+      file_id='/corrk_data/' // TRIM(corrkdir) // '/T.dat'
+      file_path=TRIM(datadir)//TRIM(file_id)
 
       ! check that the file exists
       inquire(FILE=file_path,EXIST=file_ok)
       if(.not.file_ok) then
-         write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+         write(*,*)'The file ',TRIM(file_path)
          write(*,*)'was not found by sugas_corrk.F90, exiting.'
+         write(*,*)'Check that your path to datagcm:',trim(datadir)
+         write(*,*)' is correct. You can change it in callphys.def with:'
+         write(*,*)' datadir = /absolute/path/to/datagcm'
+         write(*,*)'Also check that the corrkdir you chose in callphys.def exists.'
          call abort
       endif
 
       ! check the array size is correct, load the coefficients
-      open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+      open(111,file=TRIM(file_path),form='formatted')
       read(111,*) L_NTREFcheck
       if(.not.(L_NTREFcheck.eq.L_NTREF)) then
@@ -258,12 +269,12 @@
 
       ! VISIBLE
-      if (callgasvis.and..not.corrkdir(1:LEN_TRIM(corrkdir)).eq.'null') then
+      if (callgasvis.and..not.TRIM(corrkdir).eq.'null') then
          file_id='/corrk_data/'//trim(adjustl(banddir))//'/corrk_gcm_VI.dat' 
-         file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+         file_path=TRIM(datadir)//TRIM(file_id)
          
          ! check that the file exists
          inquire(FILE=file_path,EXIST=file_ok)
          if(.not.file_ok) then
-            write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+            write(*,*)'The file ',TRIM(file_path)
             write(*,*)'was not found by sugas_corrk.F90.'
             write(*,*)'Are you sure you have absorption data for these bands?'
@@ -271,5 +282,5 @@
          endif
          
-         open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+         open(111,file=TRIM(file_path),form='formatted')
          read(111,*) gasv8
          close(111)
@@ -281,12 +292,12 @@
 
       ! INFRA-RED
-      if (.not.corrkdir(1:LEN_TRIM(corrkdir)).eq.'null') then
+      if (.not.TRIM(corrkdir).eq.'null') then
          file_id='/corrk_data/'//trim(adjustl(banddir))//'/corrk_gcm_IR.dat' 
-         file_path=datafile(1:LEN_TRIM(datafile))//file_id(1:LEN_TRIM(file_id))
+         file_path=TRIM(datadir)//TRIM(file_id)
       
          ! check that the file exists
          inquire(FILE=file_path,EXIST=file_ok)
          if(.not.file_ok) then
-            write(*,*)'The file ',file_path(1:LEN_TRIM(file_path))
+            write(*,*)'The file ',TRIM(file_path)
             write(*,*)'was not found by sugas_corrk.F90.'
             write(*,*)'Are you sure you have absorption data for these bands?'
@@ -294,5 +305,5 @@
          endif
          
-         open(111,file=file_path(1:LEN_TRIM(file_path)),form='formatted')
+         open(111,file=TRIM(file_path),form='formatted')
          read(111,*) gasi8
          close(111)
Index: /trunk/LMDZ.GENERIC/tmp
===================================================================
--- /trunk/LMDZ.GENERIC/tmp	(revision 373)
+++ /trunk/LMDZ.GENERIC/tmp	(revision 374)
@@ -3,3 +3,4 @@
 mklsequential
 align
-common
+all
+static
