Index: trunk/LMDZ.GENERIC/makegcm_gfortran
===================================================================
--- trunk/LMDZ.GENERIC/makegcm_gfortran	(revision 1255)
+++ trunk/LMDZ.GENERIC/makegcm_gfortran	(revision 1403)
@@ -8,5 +8,5 @@
 set physique=std
 set phys="PHYS=$physique"
-set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I.'
+set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynlonlat_phylonlat'
 set ntrac = 1
 set filtre=filtrez
@@ -16,4 +16,7 @@
 set scatterers="1"
 set full=""
+#src_dirs: directories containing source files 
+set src_dirs="grid misc" 
+
 ########################################################################
 # path a changer contenant les sources et les objets du modele
@@ -405,6 +408,10 @@
 if ( "$physique" == 'nophys' ) then
    set phys="L_PHY= LIBPHY="
-endif
-
+else
+   set src_dirs="$src_dirs phy$physique"
+   set include="$include "' -I$(LIBF)/phy'"$physique"
+endif
+set libdyn_phy=""
+set LIBDYN_PHYS=""
 ########################################################################
 #subtilites sur le nom de la librairie
@@ -484,10 +491,15 @@
   set include="$include "'-I$(LIBF)/dyn2d '
   set dimh=$dim
-else
+endif
+if ( "$dimc" == "3" ) then
   if ( "$dyntype" == "olddyn" ) then
     set include="$include "'-I$(LIBF)/olddyn3d '
+    set src_dirs="$src_dirs olddyn3d dynlonlat_phylonlat dynlonlat_phylonlat/phy$physique"
   else
     set include="$include "'-I$(LIBF)/dyn3d '
+    set src_dirs="$src_dirs dyn3d dynlonlat_phylonlat dynlonlat_phylonlat/phy$physique"
   endif
+  set libdyn_phy="-ldynlonlat_phylonlat"
+  set LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a'
   set dimh=`echo $dim | awk ' { print $1 "." $2 } '`
 endif
@@ -562,5 +574,10 @@
 ## NB: we still need to have L_DYN=libdyn3d to reach routines and module
 ## objects which are located in dyn3d
-  set dyn="L_DYN=-ldyn3d DYN= L_FILTRE= DIRMAIN=phy$physique "
+  set dyntype=""
+  set filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
+  set dyn="L_DYN= DYN= L_FILTRE= "
+  set dirmain="phy$physique/dyn1d"
+  set src_dirs="$src_dirs phy$physique/dyn1d "
+  set include="$include "' -I$(LIBF)/phy'"$physique"'/dyn1d'
 endif
 endif
@@ -584,6 +601,11 @@
 if ( `expr $dimc \> 2` == 1 ) then
    set filtre="FILTRE=$filtre"
+   if ( "$dyntype" == "olddyn" ) then
+     set src_dirs="$src_dirs oldfiltrez"
+   else
+     set src_dirs="$src_dirs filtrez"
+   endif
 else
-   set filtre="FILTRE= L_FILTRE= "
+   set filtre="FILTRE= L_FILTRE= L_DYN= "
 endif
 echo "MACRO FILTRE $filtre"
@@ -627,9 +649,6 @@
         \cp tmp90 liste_des_sources_f90
         echo "Remaking the makefile!"
-        if ("$dyntype" == "olddyn") then
-          ./create_make_gcm olddyn3d grid bibio phy$physique >! tmp
-        else
-          ./create_make_gcm dyn3d grid bibio phy$physique >! tmp
-        endif
+        echo "src_dirs: $src_dirs"
+        create_make_gcm $src_dirs >! tmp
         \mv tmp makefile
         echo "New makefile created."
@@ -744,10 +763,23 @@
 set source_code=${code}.F
 # handle cases when the main program is in the physics directory
-if (-f $LMDGCM/libf/phy${physique}/${code}.F) then
-  set dyn="$dyn DIRMAIN=phy$physique "
-endif
-if (-f $LMDGCM/libf/phy${physique}/${code}.F90) then
+set dirmain=dyn${dimc}d
+if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then
   set source_code=${code}.F90
-  set dyn="$dyn DIRMAIN=phy$physique "
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then
+  set dirmain=phy${physique}/dyn1d
+  set source_code=${code}.F90
+endif
+if ( -f $LMDGCM/libf/dynlonlat_phylonlat/phy${physique}/${code}.F ) then
+  set dirmain=dynlonlat_phylonlat/phy${physique}
+  set source_code=${code}.F
+endif
+if ( -f $LMDGCM/libf/dynlonlat_phylonlat/phy${physique}/${code}.F90 ) then
+  set dirmain=dynlonlat_phylonlat/phy${physique}
+  set source_code=${code}.F90
 endif
 
@@ -760,8 +792,9 @@
 $filtre \
 LIBO=$libo \
-$dyn \
 $phys \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
 DIM=$dimc \
 DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
 L_ADJNT="$adjnt" \
 LOCAL_DIR="$localdir"  \
@@ -774,4 +807,5 @@
 MOD_SUFFIX=$mod_suffix \
 AR=$ar \
+DIRMAIN=$dirmain \
 SOURCE=$source_code \
 PROG=$code
@@ -786,8 +820,9 @@
 $filtre \
 LIBO=$libo \
-$dyn \
 $phys \
+LIBDYN_PHYS=${LIBDYN_PHYS} \
 DIM=$dimc \
 DYNTYPE="$dyntype" \
+L_DYN_PHY="$libdyn_phy" \
 L_ADJNT="$adjnt" \
 LOCAL_DIR="$localdir"  \
@@ -800,4 +835,5 @@
 MOD_SUFFIX=$mod_suffix \
 AR=$ar \
+DIRMAIN=$dirmain \
 SOURCE=$source_code \
 PROG=$code
