Index: /trunk/LMDZ.COMMON/create_make_gcm
===================================================================
--- /trunk/LMDZ.COMMON/create_make_gcm	(revision 633)
+++ /trunk/LMDZ.COMMON/create_make_gcm	(revision 634)
@@ -141,6 +141,9 @@
       do
          fili=`basename $i .F`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e: look for the "program" keword preceeded by leading spaces
+         test=` (  head $i | grep -i '^ *program' ) `
          if [ "$test" = "" ] ; then 
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi
@@ -149,6 +152,9 @@
       do
          fili=`basename $i .F90`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e. look for "program" keyword (with possibly some leading spaces)
+         test=` (  head $i | grep -i '^ \{0,\}program' ) `
          if [ "$test" = "" ] ; then
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi 
@@ -249,6 +255,9 @@
       do
          fili=`basename $i .c`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a function or main program
+         # i.e. look for "int main" keywords (with possibly some leading spaces)
+         test=` (  head $i | grep '^ \{0,\}int main' ) `
          if [ "$test" = "" ] ; then 
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi
Index: /trunk/LMDZ.GENERIC/create_make_gcm
===================================================================
--- /trunk/LMDZ.GENERIC/create_make_gcm	(revision 633)
+++ /trunk/LMDZ.GENERIC/create_make_gcm	(revision 634)
@@ -153,6 +153,9 @@
       do
          fili=`basename $i .F`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e: look for the "program" keword preceeded by leading spaces
+         test=` (  head $i | grep -i '^ *program' ) `
          if [ "$test" = "" ] ; then 
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi
@@ -161,6 +164,9 @@
       do
          fili=`basename $i .F90`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e. look for "program" keyword (with possibly some leading spaces)
+         test=` (  head $i | grep -i '^ \{0,\}program' ) `
          if [ "$test" = "" ] ; then
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi 
@@ -238,4 +244,5 @@
               echo '	$(COMPILE90) $(LIBF)/'$diri'/'$trufile' ; \'
            fi
+           ## If a module, handle created module descriptor file
            MODU=0; egrep -i '^ *module ' $trufile> /dev/null 2>&1 && MODU=1
             if [ "$MODU" -eq '1' -a "$CRAY" != '1' ] ; then
Index: /trunk/LMDZ.MARS/create_make_gcm
===================================================================
--- /trunk/LMDZ.MARS/create_make_gcm	(revision 633)
+++ /trunk/LMDZ.MARS/create_make_gcm	(revision 634)
@@ -150,6 +150,9 @@
       do
          fili=`basename $i .F`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e: look for the "program" keword preceeded by leading spaces
+         test=` (  head $i | grep -i '^ *program' ) `
          if [ "$test" = "" ] ; then 
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi
@@ -158,6 +161,9 @@
       do
          fili=`basename $i .F90`
-         test=` (  head $i | grep '      PROGRAM' ) `
+         # Check if file is a routine or main program
+         # i.e. look for "program" keyword (with possibly some leading spaces)
+         test=` (  head $i | grep -i '^ \{0,\}program' ) `
          if [ "$test" = "" ] ; then
+            # if it is not a main program, add it to the list
             listlib=$listlib" "$fili
          fi 
@@ -228,5 +234,4 @@
 	 else
          ## Fortran 90
-           echo '	cd $(LOCAL_DIR); \'
            if [ -f $fili.F90 ] ; then
 	   ## Free Form Fortran 90
