Index: trunk/LMDZ.MARS/makegcm_g95
===================================================================
--- trunk/LMDZ.MARS/makegcm_g95	(revision 1246)
+++ trunk/LMDZ.MARS/makegcm_g95	(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,25 +14,28 @@
 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
 ########################################################################
 
-##### If you want you can set environment variables here (instead of
-#####  relying on the C-shell environment variables)
-## default LMDGCM to where makegcm script is located:
-#set scriptdir=`dirname $0`
-#setenv LMDGCM `readlink -f $scriptdir`
-## You may set LIBOGCM to something else; otherwise we default to:
-#setenv LIBOGCM $LMDGCM/libo
-### NetCDF Libraries: what follows is OK for LMD 32 and 64bit Linux Machines
-##if ( `uname -m` == "x86_64" ) then
-### 64 bit machines
-#  setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_g95/lib
-#  setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_g95/include
-##else
-##  setenv NCDFLIB /donnees/emlmd/netcdf-4.0.1_g95/lib
-##  setenv NCDFINC /donnees/emlmd/netcdf-4.0.1_g95/include
-##endif
-#####
+#### If you want you can set environment variables here (instead of
+####  relying on the C-shell environment variables)
+# default LMDGCM to where makegcm script is located:
+set scriptdir=`dirname $0`
+setenv LMDGCM `readlink -f $scriptdir`
+# You may set LIBOGCM to something else; otherwise we default to:
+setenv LIBOGCM $LMDGCM/libo
+## NetCDF Libraries: what follows is OK for LMD 32 and 64bit Linux Machines
+#if ( `uname -m` == "x86_64" ) then
+# 64 bit machines
+  setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_g95/lib
+  setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_g95/include
+#else
+#  setenv NCDFLIB /donnees/emlmd/netcdf-4.0.1_g95/lib
+#  setenv NCDFINC /donnees/emlmd/netcdf-4.0.1_g95/include
+#endif
+####
 
 setenv localdir "`pwd`"
@@ -183,9 +186,7 @@
 # Ehouarn 'g95' compiler
    set optim="-O3 -fstatic -funroll-loops "
-   set optim90=" -O3 -fstatic -funroll-loops "
-   set optimtru90=" -O3 -fstatic -funroll-loops "
-#   set opt_link=" -Mfree -L/usr/local/pgi/linux86/lib -lpgf90 -lpgftnrtl -lpghpf -lpghpf2 -L$NCDFLIB -lnetcdf -Wl,-Bstatic "
-# Ehouarn: there is no /usr/local/pgi/linux86/lib, but it doesn't matter
-#          also changed -Wl,-Bstatic to -Bstatic
+   set optim90="-O3 -fstatic -funroll-loops "
+   set optimtru90="-O3 -fstatic -funroll-loops "
+#
    set opt_link=" -L$NCDFLIB -lnetcdf "
    set mod_loc_dir=$localdir
@@ -217,5 +218,5 @@
 endif
 
-# Ehouarn: add 'g95' string to pathname
+# Ehouarn: add 'g9fortran' string to pathname
 set nomlib=${machine}_g95
 
@@ -405,6 +406,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,
@@ -488,10 +493,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
@@ -532,5 +542,4 @@
 cat $libf/grid/dimensions.h
 
-#
 cd $LMDGCM
 # set path to objects directory
@@ -553,5 +562,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
@@ -593,6 +607,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"
@@ -636,9 +655,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."
@@ -721,7 +737,7 @@
 else if $LINUX then
 # Ehouarn : adapt to g95
- set optim="$optim -fmod=$libo"
- set optim90="$optim90 -fmod=$libo"
- set optimtru90="$optimtru90 -fmod=$libo"
+ set optim="$optim -fmod=${libo}"
+ set optim90="$optim90 -fmod=${libo}"
+ set optimtru90="$optimtru90 -fmod=${libo}"
 # Ehouarn: remove set mod_loc_dir def below; mod_loc_dir=$localdir (set above)
 # set mod_loc_dir=$libo
@@ -741,25 +757,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
 
@@ -772,8 +789,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"  \
@@ -786,4 +804,5 @@
 MOD_SUFFIX=$mod_suffix \
 AR=$ar \
+DIRMAIN=$dirmain \
 SOURCE=$source_code \
 PROG=$code
@@ -798,8 +817,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"  \
@@ -812,7 +832,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
