Index: trunk/LMDZ.MARS/makegcm_pgf
===================================================================
--- trunk/LMDZ.MARS/makegcm_pgf	(revision 1246)
+++ trunk/LMDZ.MARS/makegcm_pgf	(revision 1403)
@@ -8,5 +8,5 @@
 set physique=mars
 set phys="PHYS=$physique"
-set include='-I$(LIBF)/grid -I$(LIBF)/bibio -I. -I$(LIBF)/aeronomars'
+set include='-I$(LIBF)/grid -I$(LIBF)/misc -I. -I$(LIBF)/dynlonlat_phylonlat'
 set ntrac = 1
 set filtre=filtrez
@@ -14,4 +14,7 @@
 set dyntype="dyn"
 set full=""
+#src_dirs: directories containing source files 
+set src_dirs="grid misc" 
+
 ########################################################################
 # path a changer contenant les sources et les objets du modele
@@ -27,5 +30,5 @@
 ## NetCDF Libraries: what follows is OK for LMD 32 and 64bit Linux Machines
 #if ( `uname -m` == "x86_64" ) then
-## 64 bit machines
+# 64 bit machines
   setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_pgi/lib
   setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_pgi/include
@@ -35,5 +38,4 @@
 #endif
 ####
-
 
 setenv localdir "`pwd`"
@@ -221,9 +223,10 @@
 endif
 
-set nomlib=$machine
+# Ehouarn: add 'g9fortran' string to pathname
+set nomlib=${machine}
 
 # Impose distinct name for 64 bit Linux machines (to avoid mixing 32 and 64)
 if (`uname` == Linux && `uname -m` == "x86_64") then
-  set nomlib=${machine}64
+  set nomlib=${machine}
 endif
 
@@ -407,6 +410,10 @@
 if ( "$physique" == 'nophys' ) then
    set phys="L_PHY= LIBPHY="
-endif
-
+else
+   set src_dirs="$src_dirs aerono$physique phy$physique"
+   set include="$include "'-I$(LIBF)/aerono'"$physique"' -I$(LIBF)/phy'"$physique"
+endif
+set libdyn_phy=""
+set LIBDYN_PHYS=""
 ########################################################################
 # choix du nombre de traceur par defaut si il n'a pas ete choisi,
@@ -490,10 +497,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
@@ -554,5 +566,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
@@ -594,6 +611,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"
@@ -637,9 +659,6 @@
         \cp tmp90 liste_des_sources_f90
         echo "On recree le makefile"
-        if ("$dyntype" == "olddyn") then
-          ./create_make_gcm olddyn3d grid bibio aeronomars phy$physique >! tmp
-        else
-          ./create_make_gcm dyn3d grid bibio aeronomars phy$physique >! tmp
-        endif
+        echo "src_dirs: $src_dirs"
+        create_make_gcm $src_dirs >! tmp
         \mv tmp makefile
         echo "Nouveau makefile cree."
@@ -739,25 +758,26 @@
 cd $localdir
 
-## locate main program (could be in dyn3d or phy$physique
-##                      and could be .F or .F90)
+## locate main program (could be in dyn3d or dynlonlat_phylonlat/phy$physique
+##  or phy$physique/dyn1d   and could be .F or .F90)
 set source_code=${code}.F
+set dirmain=dyn${dimc}d
 if ( -f $LMDGCM/libf/dyn3d/${code}.F90 ) then
   set source_code=${code}.F90
 endif
-if ( -f $LMDGCM/libf/phy${physique}/${code}.F ) then
+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}/${code}.F90 ) then
+if ( -f $LMDGCM/libf/phy${physique}/dyn1d/${code}.F90 ) then
+  set dirmain=phy${physique}/dyn1d
   set source_code=${code}.F90
 endif
-
-## locate directory where main program is located
-if ( $dimension == 3 ) then
-  if ( -f $LMDGCM/libf/dyn3d/${source_code} ) then
-    set dyn="DIRMAIN=dyn3d "
-  endif
-  if ( -f $LMDGCM/libf/phy${physique}/${source_code} ) then
-    set dyn="DIRMAIN=phy${physique} "
-  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
 
@@ -770,8 +790,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"  \
@@ -784,4 +805,5 @@
 MOD_SUFFIX=$mod_suffix \
 AR=$ar \
+DIRMAIN=$dirmain \
 SOURCE=$source_code \
 PROG=$code
@@ -796,8 +818,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"  \
@@ -810,7 +833,8 @@
 MOD_SUFFIX=$mod_suffix \
 AR=$ar \
+DIRMAIN=$dirmain \
 SOURCE=$source_code \
 PROG=$code
 
-# cleanup, remove dimensions.h 
+# cleanup, remove dimensions.h
 \rm -f $libf/grid/dimensions.h
