Index: trunk/AGRIF/LIB/fortran.y
===================================================================
--- trunk/AGRIF/LIB/fortran.y	(revision 396)
+++ trunk/AGRIF/LIB/fortran.y	(revision 530)
@@ -3,15 +3,33 @@
 /*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
 /*                                                                            */
-/*     Copyright (C) 2005 Laurent Debreu (Laurent.Debreu@imag.fr)             */
+/* Copyright or © or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
 /*                        Cyril Mazauric (Cyril.Mazauric@imag.fr)             */
+/* This software is governed by the CeCILL-C license under French law and     */
+/* abiding by the rules of distribution of free software.  You can  use,      */
+/* modify and/ or redistribute the software under the terms of the CeCILL-C   */
+/* license as circulated by CEA, CNRS and INRIA at the following URL          */
+/* "http://www.cecill.info".                                                  */
 /*                                                                            */
-/*     This program is free software; you can redistribute it and/or modify   */
-/*    it                                                                      */
+/* As a counterpart to the access to the source code and  rights to copy,     */
+/* modify and redistribute granted by the license, users are provided only    */
+/* with a limited warranty  and the software's author,  the holder of the     */
+/* economic rights,  and the successive licensors  have only  limited         */
+/* liability.                                                                 */
 /*                                                                            */
-/*    This program is distributed in the hope that it will be useful,         */
-/*     but WITHOUT ANY WARRANTY; without even the implied warranty of         */
-/*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
-/*    GNU General Public License for more details.                            */
+/* In this respect, the user's attention is drawn to the risks associated     */
+/* with loading,  using,  modifying and/or developing or reproducing the      */
+/* software by the user in light of its specific status of free software,     */
+/* that may mean  that it is complicated to manipulate,  and  that  also      */
+/* therefore means  that it is reserved for developers  and  experienced      */
+/* professionals having in-depth computer knowledge. Users are therefore      */
+/* encouraged to load and test the software's suitability as regards their    */
+/* requirements in conditions enabling the security of their systems and/or   */
+/* data to be ensured and,  more generally, to use and operate it in the      */
+/* same conditions as regards security.                                       */
 /*                                                                            */
+/* The fact that you are presently reading this means that you have had       */
+/* knowledge of the CeCILL-C license and that you accept its terms.           */
+/******************************************************************************/
+/* version 1.0                                                                */
 /******************************************************************************/
 %{
@@ -40,5 +58,4 @@
        listvarcommon *lcom;
        listnom  *ln;
-       listvarpointtovar  *lp;
        listcouple  *lc;
        typedim   dim1;
@@ -97,8 +114,10 @@
 %token TOK_ACOS
 %token TOK_NINT
+%token TOK_CYCLE
 %token TOK_SIN
 %token TOK_SINH
 %token TOK_ASIN
 %token TOK_EQUIVALENCE
+%token TOK_BACKSPACE
 %token TOK_LOG
 %token TOK_TAN
@@ -156,5 +175,4 @@
 %token TOK_SAVE
 %token TOK_TARGET
-%token TOK_USE
 %token TOK_POINT
 %token TOK_DATA 
@@ -166,4 +184,5 @@
 %token TOK_POINT_TO
 %token TOK_COMMON
+%token TOK_GLOBAL
 %token TOK_INTERFACE 
 %token TOK_ENDINTERFACE 
@@ -174,4 +193,6 @@
 %token TOK_STOP
 %token TOK_NAMEEQ
+%token TOK_REAL8
+%token <na> TOK_USE
 %token <na> TOK_DSLASH
 %token <na> TOK_DASTER
@@ -235,4 +256,5 @@
 %token '>' 
 %type <l> dcl
+%type <l> dimension
 %type <l> paramlist
 %type <l> args  
@@ -244,4 +266,8 @@
 %type <lcom> var_common
 %type <lcom> var_common_list
+%type <d> dims
+%type <d> dimlist
+%type <dim1> dim
+%type <v> paramitem
 %type <na> comblock
 %type <na> name_routine
@@ -286,5 +312,4 @@
 %type <na> intent_spec
 %type <na> ubound
-%type <na> after_ident_dims
 %type <na> signe
 %type <na> opt_signe
@@ -292,8 +317,4 @@
 %type <na> filename
 %type <na> proper_lengspec
-%type <d> dims
-%type <d> dimlist
-%type <dim1> dim
-%type <v> paramitem
 
 %left TOK_OP
@@ -303,5 +324,5 @@
       ;
 line :  '\n' position
-      | thislabel suite_line
+      | thislabel suite_line_list
       | TOK_COMMENT
       | keyword cmnt writedeclar
@@ -309,14 +330,16 @@
                    {yyerrok;yyclearin;}    
       ;
+suite_line_list : suite_line
+      |   suite_line ';' suite_line_list
+      ;
 suite_line : entry fin_line/* subroutine, function, module                    */
       | spec fin_line      /* declaration                                     */
       | before_include filename fin_line
                   {
-                     if (firstpass == 0 && 
-                         inmoduledeclare == 0 && 
+                     if (inmoduledeclare == 0 && 
                          couldaddvariable == 1 )
                      {
                         pos_end = setposcur();
-                        RemoveWordSET(fortranout,pos_curinclude,
+                        RemoveWordSET_0(fortranout,pos_curinclude,
                                               pos_end-pos_curinclude);
                      }
@@ -334,21 +357,15 @@
             /*    TOK_ENDDONOTTREAT                                 */
             couldaddvariable = 0 ;
-            if ( firstpass == 0 ) 
-            {
-               RemoveWordCUR(fortranout,-20,20);
-            }
+            RemoveWordCUR_0(fortranout,-20,20);
          }
       | TOK_ENDDONOTTREAT 
          {
              couldaddvariable = 1 ;
-             if ( firstpass == 0 ) 
-             {
-                 RemoveWordCUR(fortranout,-24,24);
-             }
+             RemoveWordCUR_0(fortranout,-24,24);
           }
       | TOK_OMP
       | TOK_DOLLAR
       ;
-position: {if ( firstpass == 0 ) pos_cur = setposcur();}
+position: {pos_cur = setposcur();}
       ;
 thislabel: 
@@ -374,12 +391,8 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforsub();
+                         writeheadnewsub_0(1);
                          adduseagrifutil = 0 ; 
                       }
@@ -389,10 +402,6 @@
                             paramdeclaration_everdone = 0;
                             insubroutinedeclare = 1;
-                            if ( firstpass == 0 ) 
-                            {
-                               adduseagrifutil = 0 ;
-                               AGRIF_n_AddUseAgrifUtil();
-                            }
-                            OPTI_0_writeheadnewsubforsub();
+                            AddUseAgrifUtil_0();
+                            writeheadnewsub_0(1);
                             adduseagrifutil = 0 ; 
                       }
@@ -406,12 +415,8 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforsub();
+                         writeheadnewsub_0(1);
                          adduseagrifutil = 0 ;                       
                    }
@@ -425,9 +430,5 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* we should to list of the subroutine argument the  */
                          /*    name of the function which has to be defined   */
@@ -440,5 +441,5 @@
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforfunc();
+                         writeheadnewsub_0(2);
                          adduseagrifutil = 0 ; 
                       }
@@ -446,11 +447,7 @@
                       {
                             tmpdeclaration_everdone = 0;
-                         paramdeclaration_everdone = 0;
+                            paramdeclaration_everdone = 0;
                             insubroutinedeclare = 1;
-                            if ( firstpass == 0 ) 
-                            {
-                               adduseagrifutil = 0 ;
-                               AGRIF_n_AddUseAgrifUtil();
-                            }
+                            AddUseAgrifUtil_0();
                             /* we should to list of the subroutine argument   */
                             /* name of the function which has to be defined   */
@@ -462,5 +459,5 @@
                                                (curlistvar,listargsubroutine,1);
                             }
-                            OPTI_0_writeheadnewsubforfunc();
+                            writeheadnewsub_0(2);
                             adduseagrifutil = 0 ; 
                       }
@@ -475,9 +472,5 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* we should to list of the subroutine argument the  */
                          /*    name of the function which has to be defined   */
@@ -491,5 +484,5 @@
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforfunc();
+                         writeheadnewsub_0(2);
                          adduseagrifutil = 0 ; 
                       }
@@ -497,11 +490,7 @@
                       {
                             tmpdeclaration_everdone = 0;
-                         paramdeclaration_everdone = 0;
+                            paramdeclaration_everdone = 0;
                             insubroutinedeclare = 1;
-                            if ( firstpass == 0 ) 
-                            {
-                               adduseagrifutil = 0 ;
-                               AGRIF_n_AddUseAgrifUtil();
-                            }
+                            AddUseAgrifUtil_0();
                             /* we should to list of the subroutine argument   */
                             /* name of the function which has to be defined   */
@@ -513,5 +502,5 @@
                                                (curlistvar,listargsubroutine,1);
                             }
-                            OPTI_0_writeheadnewsubforfunc();
+                            writeheadnewsub_0(2);
                             adduseagrifutil = 0 ; 
                       }
@@ -520,9 +509,9 @@
                    {
                       strcpy(curmodulename,$2);
-                      if ( firstpass == 1 ) Add_ModuleTo_Modulelist($2);
+                      Add_ModuleTo_Modulelist_1($2);
                       if ( inmoduledeclare == 0 )
                       { 
-                         /* instance and back instance should be create ?     */
-                         MOD_1_FillInlistmodule();   
+                         /* Alloc should be create ?                          */
+                         FillInlistmodule_1();   
                          /* To know if there are in the module declaration    */
                          inmoduledeclare = 1;
@@ -533,5 +522,5 @@
                       }      
                       /* WE should use Agrif_Util if it is necessary          */
-                      AGRIF_0_AddUseAgrifInModuleDeclaration();
+                      AddUseAgrifInModuleDeclaration_0();
                    }
       ;
@@ -541,14 +530,11 @@
 before_include : TOK_INCLUDE
                    {
-                      if (firstpass == 0 )
-                      {
-                         pos_curinclude = setposcur()-9;
-                      }
+                      pos_curinclude = setposcur()-9;
                    }      
 filename: TOK_CHAR_CONSTANT
                    {
-                      if ( firstpass == 1 && couldaddvariable == 1 )
-                      {
-                         Addincludetothelist($1);
+                      if ( couldaddvariable == 1 )
+                      {
+                         Addincludetothelist_1($1);
                       }                   
                    }
@@ -595,12 +581,11 @@
                       /* remove declaration                                   */
                       if ( fortran77 == 1                       && 
-                           firstpass == 0                       && 
                            infunctiondeclare == 0               && 
                            commonlist                           && 
-                           OPTI_0_IsTabvarsUseInArgument() == 1 &&
+                           IsTabvarsUseInArgument_0() == 1      &&
                            couldaddvariable == 1 ) 
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_cur_decl,
+                         RemoveWordSET_0(fortranout,pos_cur_decl,
                                                pos_end-pos_cur_decl);
                       }
@@ -608,17 +593,35 @@
                    }
       | TOK_TYPE opt_name
+/*      {
+         couldaddvariable = 0;
+      }*/
       | TOK_ENDTYPE opt_name
+/*      {
+         couldaddvariable = 1;
+      }*/
       | TOK_POINTER list_couple
       | before_parameter  '(' paramlist ')' 
                    {
-                      COM_1_AddvartoParamlist($3);
+                      AddvartoParamlist_1($3);
                       if ( fortran77 == 1  && 
-                           firstpass == 0  && 
                            commonlist      && 
                            listvarindoloop && 
-                           OPTI_0_IsTabvarsUseInArgument() == 1 )
+                           IsTabvarsUseInArgument_0() == 1 )
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_curparameter,
+                         RemoveWordSET_0(fortranout,pos_curparameter,
+                                               pos_end-pos_curparameter);
+                      }
+                   }
+      | before_parameter  paramlist 
+                   {
+                      AddvartoParamlist_1($2);
+                      if ( fortran77 == 1  && 
+                           commonlist      && 
+                           listvarindoloop && 
+                           IsTabvarsUseInArgument_0() == 1 )
+                      {
+                         pos_end = setposcur();
+                         RemoveWordSET_0(fortranout,pos_curparameter,
                                                pos_end-pos_curparameter);
                       }
@@ -628,4 +631,37 @@
       | implicit
       | dimension
+                  {
+                   /* if the variable is a parameter we can suppose that is   */
+                   /*    value is the same on each grid. It is not useless to */
+                   /*    create a copy of it on each grid                     */
+                      if ( couldaddvariable == 1 )
+                      {
+                         ajoutevar_1($1);
+                         NonGridDepDeclaration_0($1);
+                         /* if variables has been declared in a subroutine    */
+                         if ( insubroutinedeclare == 1 )
+                         {
+                           ajoutvarofsubroutine_1($1);
+                           writesubroutinedeclaration_0($1);
+                         }
+                      }
+                      /* Case of common block                                 */
+                      indeclarationvar=0;
+                      PublicDeclare = 0;  
+                      PrivateDeclare = 0; 
+                      ExternalDeclare = 0; 
+                      strcpy(NamePrecision,"");  
+                      c_star = 0;
+                      InitialValueGiven = 0 ;
+                      strcpy(IntentSpec,"");
+                      VariableIsParameter =  0 ; 
+                      Allocatabledeclare = 0 ;
+                      SaveDeclare = 0;
+                      pointerdeclare = 0;
+                      optionaldeclare = 0 ;
+                      dimsgiven=0;
+                      c_selectorgiven=0;
+                      strcpy(nameinttypename,"");  
+                   }
       | public
       | private
@@ -634,17 +670,46 @@
       | interface 
       | namelist
+      | TOK_BACKSPACE '(' expr ')'
       | TOK_EXTERNAL opt_sep use_name_list
+      | TOK_INTRINSIC opt_sep use_intrinsic_list
       | TOK_EQUIVALENCE '(' list_expr ')'
       | before_data data '\n'
                    {
                       /* we should remove the data declaration                */
-                     if (firstpass == 0 && aftercontainsdeclare == 0 )
+                     if ( aftercontainsdeclare == 0 )
                      {
                         pos_end = setposcur();
-                        RemoveWordSET(fortranout,pos_curdata,
+                        RemoveWordSET_0(fortranout,pos_curdata,
                                               pos_end-pos_curdata);
                      }
                   }
       ;
+name_intrinsic : TOK_SUM
+      | TOK_TANH
+      | TOK_MAXVAL
+      | TOK_MIN
+      | TOK_MINVAL
+      | TOK_TRIM
+      | TOK_SQRT
+      | TOK_NINT
+      | TOK_FLOAT
+      | TOK_EXP
+      | TOK_COS
+      | TOK_COSH
+      | TOK_ACOS
+      | TOK_SIN
+      | TOK_SINH
+      | TOK_ASIN
+      | TOK_LOG
+      | TOK_TAN
+      | TOK_ATAN
+      | TOK_MOD
+      | TOK_SIGN
+      | TOK_MINLOC
+      | TOK_MAXLOC
+      | TOK_NAME
+      ;
+use_intrinsic_list : name_intrinsic
+      | use_intrinsic_list ',' name_intrinsic
 list_couple : '(' list_expr ')' 
       | list_couple ',' '(' list_expr ')' 
@@ -661,13 +726,13 @@
                       if ( couldaddvariable == 1 )
                       {
-                         decl_1_ajoutevar($1);
+                         ajoutevar_1($1);
                          if ( VariableIsParameter == 1 ) globparam =
                                             AddListvarToListvar($1,globparam,1);
-                         DECL_0_NonGridDepDeclaration($1);
+                         NonGridDepDeclaration_0($1);
                          /* if variables has been declared in a subroutine    */
                          if ( insubroutinedeclare == 1 )
                          {
-                           OPTI_1_ajoutvarofsubroutine($1);
-                           OPTI_0_writesubroutinedeclaration($1);
+                           ajoutvarofsubroutine_1($1);
+                           writesubroutinedeclaration_0($1);
                          }
                          /* If there are a SAVE declarations in module's      */
@@ -677,6 +742,11 @@
                          if ( aftercontainsdeclare == 1 ) 
                          {
-                            decl_1_ajoutevarsave($1);
-                            decl_0_modifdeclarationssave($1);
+                            ajoutevarsave_1($1);
+                            if ( VariableIsParameter == 0 && SaveDeclare == 1) 
+                            {
+                               pos_end = setposcur();
+                               RemoveWordSET_0(fortranout,pos_cur,
+                                               pos_end-pos_cur);
+                            }
                          }
                       }
@@ -686,10 +756,8 @@
                       PrivateDeclare = 0; 
                       ExternalDeclare = 0; 
-                      lengspecgiven=0;
-                      PrecisionGiven = 0; 
+                      strcpy(NamePrecision,"");  
                       c_star = 0;
-                      CharacterSizeGiven = 0 ; 
                       InitialValueGiven = 0 ;
-                      IntentDeclare = 0; 
+                      strcpy(IntentSpec,"");
                       VariableIsParameter =  0 ; 
                       Allocatabledeclare = 0 ;
@@ -699,5 +767,5 @@
                       dimsgiven=0;
                       c_selectorgiven=0;
-                      inttypename=0;
+                      strcpy(nameinttypename,"");  
                    }
       | TOK_FUNCTION TOK_NAME arglist
@@ -711,9 +779,5 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* we should to list of the subroutine argument the  */
                          /*    name of the function which has to be defined   */
@@ -740,5 +804,5 @@
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforfunc();
+                         writeheadnewsub_0(2);
                          adduseagrifutil = 0 ; 
                       }
@@ -748,9 +812,5 @@
                          paramdeclaration_everdone = 0;
                          insubroutinedeclare = 1;
-                         if ( firstpass == 0 ) 
-                         {
-                            adduseagrifutil = 0 ;
-                            AGRIF_n_AddUseAgrifUtil();
-                         }
+                         AddUseAgrifUtil_0();
                          /* we should to list of the subroutine argument the  */
                          /*    name of the function which has to be defined   */
@@ -771,5 +831,5 @@
                          /* in the second step we should write the head of    */
                          /*    the subroutine sub_loop_<subroutinename>       */
-                         OPTI_0_writeheadnewsubforfunc();
+                         writeheadnewsub_0(2);
                          adduseagrifutil = 0 ; 
                       }
@@ -778,23 +838,33 @@
 before_parameter : TOK_PARAMETER
                    {
-                      if (firstpass == 0 )
-                      {
-                         pos_curparameter = setposcur()-9;
-                      }
+                      pos_curparameter = setposcur()-9;
                    }      
 before_data : TOK_DATA
                    {
-                      if (firstpass == 0 ) pos_curdata = setposcur()-4;
+                      pos_curdata = setposcur()-4;
                    }
 data: TOK_NAME TOK_SLASH datavallist TOK_SLASH
                    {
                       sprintf(ligne,"(/ %s /)",$3);
-                      DATA_n_CompleteDataList($1,ligne);
+                      CompleteDataList($1,ligne);
                    }
       | data opt_comma TOK_NAME TOK_SLASH datavallist TOK_SLASH
                    {
                       sprintf(ligne,"(/ %s /)",$5);
-                      DATA_n_CompleteDataList($3,ligne);
-                   }
+                      CompleteDataList($3,ligne);
+                   }
+      | datanamelist TOK_SLASH datavallist TOK_SLASH
+                   {
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                       /*******************************************************/
+                   }
+      ;
+datanamelist : TOK_NAME
+      | datanamelist ',' TOK_NAME
       ;
 datavallist : expr_data
@@ -812,9 +882,9 @@
                    {sprintf($$,"%s+%s",$1,$3);}
       | expr_data '-' expr_data
-                   {sprintf($$,"%s+%s",$1,$3);}
+                   {sprintf($$,"%s-%s",$1,$3);}
       | expr_data '*' expr_data
-                   {sprintf($$,"%s+%s",$1,$3);}
+                   {sprintf($$,"%s*%s",$1,$3);}
       | expr_data '/' expr_data
-                   {sprintf($$,"%s+%s",$1,$3);}
+                   {sprintf($$,"%s/%s",$1,$3);}
       ;
 opt_signe : 
@@ -828,9 +898,9 @@
       | TOK_NAMELIST  comblock ident
       {
-         if ( firstpass == 1 ) AddNameToListNamelist($2);
+         AddNameToListNamelist_1($2);
       }
       | namelist_action opt_comma comblock opt_comma ident
       {
-         if ( firstpass == 1 ) AddNameToListNamelist($3);
+         AddNameToListNamelist_1($3);
       }
       | namelist_action ',' ident
@@ -842,11 +912,80 @@
       ;
 dimension: TOK_DIMENSION  opt_comma TOK_NAME dims lengspec
+      {
+         if ( couldaddvariable == 1 )
+         {
+            if ( inmoduledeclare == 1 || SaveDeclare == 1 )
+            {
+               if ( AllocShouldMadeInModule() == 1 ) 
+               {
+                 AllocTo1InModule_1();
+               }
+            }      
+            /*                                                                */
+            curvar=createvar($3,$4);
+            /*                                                                */
+            if ( IsVariableReal($3) == 1 )
+            {
+               /*                                                             */
+               CreateAndFillin_Curvar("REAL",$3,$4,curvar);
+               /*                                                             */
+               curlistvar=insertvar(NULL,curvar);
+               /*                                                             */
+               $$=settype("REAL",curlistvar);
+            }
+            else
+            {
+               /*                                                             */
+               CreateAndFillin_Curvar("INTEGER",$3,$4,curvar);
+               /*                                                             */
+               curlistvar=insertvar(NULL,curvar);
+               /*                                                             */
+               $$=settype("INTEGER",curlistvar);
+            }
+            strcpy(vallengspec,"");
+         }
+         else
+         {
+            /* mazauric*/
+         }
+      }
       | dimension ',' TOK_NAME dims lengspec
+      {
+         if ( couldaddvariable == 1 )
+         {
+            /*                                                                */
+            curvar=createvar($3,$4);
+            /*                                                                */
+            if ( IsVariableReal($3) == 1 )
+            {
+               /*                                                             */
+               CreateAndFillin_Curvar("REAL",$3,$4,curvar);
+               /*                                                             */
+               curlistvar=insertvar($1,curvar);
+               /*                                                             */
+               $$=curlistvar;
+            }
+            else
+            {
+               /*                                                             */
+               CreateAndFillin_Curvar("INTEGER",$3,$4,curvar);
+               /*                                                             */
+               curlistvar=insertvar($1,curvar);
+               /*                                                             */
+               $$=curlistvar;
+            }
+            strcpy(vallengspec,"");
+         }         
+         else
+         {
+            /* mazauric*/
+         }
+      }
       ;
 private: TOK_PRIVATE '\n'
-      | TOK_PRIVATE  use_name_list
+      | TOK_PRIVATE opt_sep use_name_list
       ;
 public: TOK_PUBLIC '\n'
-      | TOK_PUBLIC  use_name_list 
+      | TOK_PUBLIC opt_sep use_name_list 
       ;
 use_name_list: TOK_NAME 
@@ -855,9 +994,9 @@
 common: before_common var_common_list
                    {
-                         if (firstpass == 0 && fortran77 == 1 &&
+                         if (fortran77 == 1 &&
                              couldaddvariable == 1 )
                          {
                             pos_end = setposcur();
-                            RemoveWordSET(fortranout,pos_curcommon,
+                            RemoveWordSET_0(fortranout,pos_curcommon,
                                                   pos_end-pos_curcommon);
                          }
@@ -867,13 +1006,10 @@
                          if ( couldaddvariable == 1 )
                          {
-                            if (firstpass == 1 ) 
-                            {
-                               sprintf(charusemodule,"%s",$2);
-                               Add_ModuleTo_Modulelist($2);
-                            }
-                            if (firstpass == 0 && fortran77 == 1 )
+                            sprintf(charusemodule,"%s",$2);
+                            Add_ModuleTo_Modulelist_1($2);
+                            if ( fortran77 == 1 )
                             {
                                pos_end = setposcur();
-                               RemoveWordSET(fortranout,pos_curcommon,
+                               RemoveWordSET_0(fortranout,pos_curcommon,
                                                      pos_end-pos_curcommon);
                             }
@@ -884,13 +1020,10 @@
                          if ( couldaddvariable == 1 )
                          {
-                            if (firstpass == 1 ) 
-                            {
-                               sprintf(charusemodule,"%s",$3);
-                               Add_ModuleTo_Modulelist($3);
-                            }
-                            if (firstpass == 0 && fortran77 == 1 )
+                            sprintf(charusemodule,"%s",$3);
+                            Add_ModuleTo_Modulelist_1($3);
+                            if ( fortran77 == 1 )
                             {
                                pos_end = setposcur();
-                               RemoveWordSET(fortranout,pos_curcommon,
+                               RemoveWordSET_0(fortranout,pos_curcommon,
                                                      pos_end-pos_curcommon);
                             }
@@ -901,14 +1034,20 @@
                    {
                       positioninblock=0;
-                      if (firstpass == 0 ) pos_curcommon = setposcur()-6;
-                   }
+                      pos_curcommon = setposcur()-6;
+                   }
+      | TOK_GLOBAL TOK_COMMON
+                   {
+                      positioninblock=0;
+                      pos_curcommon = setposcur()-6-7;
+                   }
+      ;
 var_common_list : var_common
                    {
-                      if ( couldaddvariable == 1 ) COM_1_AddCommonvartolist();
+                      if ( couldaddvariable == 1 ) Addtolistvarcommon();
                    }
 
      | var_common_list ',' var_common
                    {
-                      if ( couldaddvariable == 1 ) COM_1_AddCommonvartolist();
+                      if ( couldaddvariable == 1 ) Addtolistvarcommon();
                    }
 var_common: TOK_NAME dims  
@@ -947,5 +1086,6 @@
       ;
 varsave: 
-      | TOK_NAME dims 
+      | TOK_NAME before_dims dims 
+      {created_dimensionlist = 1;}
       ;
       
@@ -970,5 +1110,4 @@
                          strcpy(curvar->subroutinename,subroutinename);
                          strcpy(curvar->modulename,subroutinename);
-                         curvar->isparameter=1;
                          strcpy(curvar->initialvalue,$3);
                          $$=curvar;
@@ -985,16 +1124,16 @@
                        if ( firstpass == 1 && insubroutinedeclare == 1 )
                        {
-                           listimplicitnone = Add_listname
+                           listimplicitnone = Addtolistname
                                               (subroutinename,listimplicitnone);
                        }
-                       if ( firstpass == 0               && 
-                            tmpdeclaration_everdone == 1 && 
+                       if ( tmpdeclaration_everdone == 1 && 
                             inmoduledeclare == 0 )
                        {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_end-13,
+                         RemoveWordSET_0(fortranout,pos_end-13,
                                                13);
                        }
                     }
+      | TOK_IMPLICIT TOK_REAL8
       ;
 opt_retour :
@@ -1006,7 +1145,7 @@
                          if ( inmoduledeclare == 1 || SaveDeclare == 1 )
                          {
-                            if ( MOD_n_InstanceShouldMadeInModule() == 1 ) 
+                            if ( AllocShouldMadeInModule() == 1 ) 
                             {
-                               MOD_1_InstanceTo1InModule();
+                               AllocTo1InModule_1();
                             }
                          }      
@@ -1036,5 +1175,8 @@
                          $$=settype(DeclType,curlistvar);
                       }
-                      lengspecgiven=0;
+                      else
+                      {
+                         /* mazauric*/
+                      }
                       strcpy(vallengspec,"");
                    }
@@ -1054,5 +1196,4 @@
                          CreateAndFillin_Curvar($1->var->typevar,$4,$5,curvar);
                          /*                                                   */
-                         curvar->typegiven=1;
                          strcpy(curvar->typevar,($1->var->typevar));
                          /*                                                   */
@@ -1070,5 +1211,8 @@
                          $$=curlistvar;
                       }
-                      lengspecgiven=0;
+                      else
+                      {
+                         /* mazauric*/
+                      }
                       strcpy(vallengspec,"");
                    }
@@ -1084,5 +1228,5 @@
                       if (inmoduledeclare == 1 ) 
                       {
-                         MOD_1_InstanceShouldMadeTo1InModule();
+                         AllocShouldMadeTo1InModule_1();
                       }
                    }
@@ -1091,5 +1235,4 @@
                       indeclarationvar=1;
                       strcpy(DeclType,$1);
-                      inttypename=1;
                       strcpy(nameinttypename,$3);
                    }
@@ -1107,9 +1250,5 @@
 before_character : TOK_CHARACTER
                    {
-                      if ( firstpass == 0 ) 
-                      {
-                         pos_cur_decl = setposcur();
-                         pos_cur_decl = pos_cur_decl-9;
-                      }
+                      pos_cur_decl = setposcur()-9;
                    }
       ;
@@ -1119,24 +1258,16 @@
                    {
                       strcpy($$,"INTEGER");
-                      if ( firstpass == 0 ) 
-                      {
-                         pos_cur_decl = setposcur();
-                         pos_cur_decl = pos_cur_decl-7;
-                      }
+                      pos_cur_decl = setposcur()-7;
                       if (inmoduledeclare == 1 ) 
                       {
-                         MOD_1_InstanceShouldMadeTo1InModule();
+                         AllocShouldMadeTo1InModule_1();
                        }
                    }
       | TOK_REAL   {
                       strcpy($$,"REAL"); 
-                      if ( firstpass == 0 ) 
-                      {
-                         pos_cur_decl = setposcur();
-                         pos_cur_decl = pos_cur_decl-4;
-                      }
+                      pos_cur_decl = setposcur()-4;
                       if (inmoduledeclare == 1 ) 
                       {
-                         MOD_1_InstanceShouldMadeTo1InModule();
+                         AllocShouldMadeTo1InModule_1();
                       }
                    }
@@ -1150,26 +1281,18 @@
                    {
                       strcpy($$,"LOGICAL");
-                      if ( firstpass == 0 ) 
-                      {
-                         pos_cur_decl = setposcur();
-                         pos_cur_decl = pos_cur_decl-7;
-                      }
+                      pos_cur_decl = setposcur()-7;
                       if (inmoduledeclare == 1 ) 
                       {
-                         MOD_1_InstanceShouldMadeTo1InModule();
+                         AllocShouldMadeTo1InModule_1();
                       }
                    }
       | TOK_TYPE      
                    {
-                      if ( firstpass == 0 ) 
-                      {
-                         pos_cur_decl = setposcur();
-                         pos_cur_decl = pos_cur_decl-5;
-                      }
+                      pos_cur_decl = setposcur()-5;
                       strcpy($$,"TYPE");
                    }
       ;
 lengspec:
-      | '*' proper_lengspec {lengspecgiven=1;strcpy(vallengspec,$2);}
+      | '*' proper_lengspec {strcpy(vallengspec,$2);}
       ;
 proper_lengspec: expr {sprintf($$,"*%s",$1);}
@@ -1186,17 +1309,19 @@
       | TOK_NAME '=' clause  
                    {
-                      PrecisionGiven = 1; 
                       sprintf(NamePrecision,"%s = %s",$1,$3);  
                    }
       | TOK_NAME
                    {
-                      PrecisionGiven = 1; 
                       strcpy(NamePrecision,$1);  
                    }
+      | TOK_CSTINT
+                   {
+                      strcpy(NamePrecision,$1);  
+                   }
       ;
 clause: expr       {strcpy(CharacterSize,$1);
-                    CharacterSizeGiven = 1;strcpy($$,$1);}
+                    strcpy($$,$1);}
       | '*'        {strcpy(CharacterSize,"*");
-                    CharacterSizeGiven = 1;strcpy($$,"*");} 
+                    strcpy($$,"*");} 
       ;
 opt_clause: 
@@ -1215,5 +1340,5 @@
                       if (inmoduledeclare == 1 ) 
                       {
-                         MOD_1_InstanceShouldMadeTo0InModule();
+                         AllocShouldMadeTo0InModule_1();
                       }
                    }
@@ -1228,6 +1353,6 @@
       | TOK_EXTERNAL  
                    {ExternalDeclare = 1;} 
-      | TOK_INTENT '(' intent_spec ')' 
-                   {IntentDeclare = 1; strcpy(IntentSpec,$3);}
+      | TOK_INTENT intent_spec
+                   {strcpy(IntentSpec,$2);}
       | TOK_INTRINSIC
       | TOK_OPTIONAL{optionaldeclare = 1 ;}
@@ -1238,5 +1363,5 @@
                           SaveDeclare = 1 ;
                           Savemeet = 1;
-                          MOD_1_InstanceShouldMadeTo1InModule();
+                          AllocShouldMadeTo1InModule_1();
                        }
                     }
@@ -1252,11 +1377,11 @@
                    {PrivateDeclare = 1;} 
       ;
-dims:              {$$=(listdim *)NULL;}
+dims:              {if ( created_dimensionlist == 1 ) $$=(listdim *)NULL;}
       | '(' dimlist ')'  
-                   {$$=reverse($2);}
-      ;
-dimlist:   dim     {$$=insertdim(NULL,$1);}
+                   {if ( created_dimensionlist == 1 ) $$=$2;}
+      ;
+dimlist:   dim     {if ( created_dimensionlist == 1 ) $$=insertdim(NULL,$1);}
       | dimlist ',' dim 
-                   {$$=insertdim($1,$3);}
+                   {if ( created_dimensionlist == 1 ) $$=insertdim($1,$3);}
       ;
 dim:ubound         {strcpy($$.first,"1");strcpy($$.last,$1);}
@@ -1280,6 +1405,6 @@
 predefinedfunction : TOK_SUM minmaxlist ')' 
                    {sprintf($$,"SUM(%s)",$2);}
-      | TOK_MAX '(' minmaxlist ')'
-                   {sprintf($$,"MAX(%s)",$3);}
+      | TOK_MAX minmaxlist ')'
+                   {sprintf($$,"MAX(%s)",$2);}
       | TOK_TANH '(' minmaxlist ')'
                    {sprintf($$,"TANH(%s)",$3);}
@@ -1292,7 +1417,7 @@
       | TOK_TRIM '(' expr ')'
                    {sprintf($$,"TRIM(%s)",$3);}
-      | TOK_SQRT '(' expr ')'
-                   {sprintf($$,"SQRT(%s)",$3);}
-      | TOK_REAL '(' expr ')'
+      | TOK_SQRT expr ')'
+                   {sprintf($$,"SQRT(%s)",$2);}
+      | TOK_REAL '(' minmaxlist ')'
                    {sprintf($$,"REAL(%s)",$3);}
       | TOK_INT '(' expr ')'
@@ -1322,6 +1447,6 @@
       | TOK_ATAN '(' expr ')'
                    {sprintf($$,"ATAN(%s)",$3);}
-      | TOK_ABS '(' expr ')'
-                   {sprintf($$,"ABS(%s)",$3);}
+      | TOK_ABS expr ')'
+                   {sprintf($$,"ABS(%s)",$2);}
       | TOK_MOD '(' minmaxlist ')'
                    {sprintf($$,"MOD(%s)",$3);}
@@ -1391,8 +1516,9 @@
                    {sprintf($$,"%s",$2);}
 
-after_slash : expr 
+after_slash : {strcpy($$,"");}
+      | expr 
                    {sprintf($$,"/%s",$1);}
       | '=' expr %prec TOK_EQ 
-                   {sprintf($$,"== %s",$2);}
+                   {sprintf($$,"/= %s",$2);}
       | TOK_SLASH expr
                    {sprintf($$,"//%s",$2);}
@@ -1414,8 +1540,8 @@
                       if (!strcasecmp(identcopy,"Agrif_Parent") )
                                                             agrif_parentcall =1;
-                      if ( AGRIF_n_Agrif_in_Tok_NAME(identcopy) == 1 )
+                      if ( Agrif_in_Tok_NAME(identcopy) == 1 )
                       { 
                          inagrifcallargument = 1;
-                         AGRIF_n_AddsubroutineTolistsubwhereagrifused();
+                         AddsubroutineTolistsubwhereagrifused();
                       }
                    }
@@ -1436,5 +1562,5 @@
                    {
                       sprintf($$," %s ( %s )",$1,$3);
-                      AGRIF_0_ModifyTheAgrifFunction($3);
+                      ModifyTheAgrifFunction_0($3);
                      agrif_parentcall =0; 
                    }
@@ -1472,21 +1598,32 @@
       ;
 ident : TOK_NAME    {  
-                       strcpy(identcopy,$1);
-                       pointedvar=0;
-                       if ( VarIsNonGridDepend($1) == 0 &&
-                            formatdeclare == 0 
-                          )
+                       if ( VariableIsNotFunction($1) == 0 )
                        {
-                          if ( inagrifcallargument == 1 ||
-                               OPTI_0_varisallocatable($1) == 1 ||
-			       OPTI_0_varispointer($1) == 1 )
+                          if ( inagrifcallargument == 1 )
                           {
-                             AGRIF_0_ModifyTheVariableName($1);
+                             if ( !strcasecmp($1,identcopy) )
+                             {
+                                strcpy(sameagrifname,identcopy);
+                                sameagrifargument = 1;
+                             }
                           }
-                          if ( inagrifcallargument != 1 )
-                               OPTI_1_ajoutevarindoloop($1);
+                          strcpy(identcopy,$1);
+                          pointedvar=0;
+                          if ( VarIsNonGridDepend($1) == 0 &&
+                               formatdeclare == 0 
+                             )
+                          {
+                             if ( inagrifcallargument == 1 ||
+                                  varisallocatable_0($1) == 1 ||
+                                  varispointer_0($1) == 1 )
+                             {
+                                ModifyTheVariableName_0($1);
+                             }
+                             if ( inagrifcallargument != 1 || sameagrifargument ==1 )
+                                  ajoutevarindoloop_1($1);
+                          }
+                          NotifyAgrifFunction_0($1);
                        }
-                       AGRIF_0_NotifyAgrifFunction($1);
-                    }       
+		    }
       ;
 simple_const: TOK_TRUE 
@@ -1528,5 +1665,5 @@
                     } 
       ;
-before_initial : {if ( firstpass == 0 ) pos_curinit = setposcur();}
+before_initial : {pos_curinit = setposcur();}
       ;
 complex_const: '(' uexpr ',' uexpr ')' 
@@ -1538,15 +1675,13 @@
                       if (insubroutinedeclare == 1)
                       {
-                         OPTI_0_copyuse($2);
-                      }
-                      if (firstpass == 1 ) 
-                      {
-                         sprintf(charusemodule,"%s",$2);
-                         Addmoduletothelist($2);
-                      }
-                      if ( firstpass == 0 && inmoduledeclare == 0 )
+                         copyuse_0($2);
+                      }
+                      sprintf(charusemodule,"%s",$2);
+                      Addmoduletothelist_1($2);
+
+                      if ( inmoduledeclare == 0 )
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_curuse,
+                         RemoveWordSET_0(fortranout,pos_curuse,
                                                pos_end-pos_curuse);
                       }
@@ -1556,5 +1691,5 @@
                       if (insubroutinedeclare == 1)
                       {
-                         OPTI_1_completelistvarpointtovar($2,$4);
+                         completelistvarpointtovar_1($2,$4);
                       }
                       if ( firstpass == 1 ) 
@@ -1574,10 +1709,10 @@
                             sprintf(charusemodule,"%s",$2);
                          }
-                         Addmoduletothelist($2);
-                      }
-                      if ( firstpass == 0  && inmoduledeclare == 0 )
+                         Addmoduletothelist_1($2);
+                      }
+                      if ( inmoduledeclare == 0 )
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_curuse,
+                         RemoveWordSET_0(fortranout,pos_curuse,
                                                pos_end-pos_curuse);
                       }
@@ -1588,15 +1723,13 @@
                       if (insubroutinedeclare == 1)
                       {
-                         OPTI_0_copyuseonly($2);
-                      }
-                      if (firstpass == 1 ) 
-                      {
-                         sprintf(charusemodule,"%s",$2);
-                         Addmoduletothelist($2);
-                      }
-                       if ( firstpass == 0  && inmoduledeclare == 0 )
+                         copyuseonly_0($2);
+                      }
+                      sprintf(charusemodule,"%s",$2);
+                      Addmoduletothelist_1($2);
+
+                       if ( inmoduledeclare == 0 )
                        {
                           pos_end = setposcur();
-                          RemoveWordSET(fortranout,pos_curuse,
+                          RemoveWordSET_0(fortranout,pos_curuse,
                                                 pos_end-pos_curuse);
                        }
@@ -1607,5 +1740,5 @@
                        if (insubroutinedeclare == 1)
                        {
-                          OPTI_1_completelistvarpointtovar($2,$6);
+                          completelistvarpointtovar_1($2,$6);
                        }
                        if ( firstpass == 1 ) 
@@ -1626,11 +1759,20 @@
                              sprintf(charusemodule,"%s",$2);
                           }
-                          Addmoduletothelist($2);
+                          Addmoduletothelist_1($2);
                        }
-                       if ( firstpass == 0  && inmoduledeclare == 0 )
-                       {
-                          pos_end = setposcur();
-                          RemoveWordSET(fortranout,pos_curuse,
-                                                pos_end-pos_curuse);
+                       if ( firstpass == 0 )
+		       {
+                          if ( inmoduledeclare == 0 )
+                          {
+                             pos_end = setposcur();
+                             RemoveWordSET_0(fortranout,pos_curuse,
+                                                   pos_end-pos_curuse);
+                          }
+		          else
+		          {
+   		             /* if we are in the module declare and if the    */
+	   	             /* onlylist is a list of global variable         */
+		             variableisglobalinmodule($6, $2, fortranout);
+		          }
                        }
                     }    
@@ -1638,5 +1780,5 @@
 word_use : TOK_USE
                    {
-                      if ( firstpass == 0 ) pos_curuse = setposcur()-3;
+                      pos_curuse = setposcur()-strlen($1);
                    }
       ;
@@ -1683,5 +1825,5 @@
                        $$ = coupletmp;
                        pointedvar=1;
-                       OPTI_1_ajoutevarindoloop($1);
+                       ajoutevarindoloop_1($1);
                     }
       | TOK_NAME    {
@@ -1709,10 +1851,10 @@
                             tmpdeclaration_everdone = 0;
                             /*                                                */
-                            OPTI_0_closeandcallsubloopandincludeit(1,$1,"");
-                            /* at the end of the firstpass we should remove   */
+                            closeandcallsubloopandincludeit_0(1,$1,"");
+                            /* at the end of the firstpas  we should remove   */
                             /*    from the listvarindoloop all variables      */
                             /*    which has not been declared as table in the */
                             /*    globliste                                   */
-                            OPTI_1_cleanlistvarfordoloop(1);
+                            cleanlistvarfordoloop_1(1);
                          }
                          else
@@ -1723,7 +1865,6 @@
                                if ( aftercontainsdeclare == 0 )
                                {
-                                  if ( firstpass == 1) 
-                                         DATA_1_CompleteGlobListeWithDatalist();
-                                 addi_0_addsubroutine_inst_back_alloc(1);
+                                 CompleteGlobListeWithDatalist_1();
+                                 addsubroutine_alloc_0(1);
                                }
                             }
@@ -1739,12 +1880,12 @@
                           insubroutinedeclare = 0;
                           /*                                                  */
-                          OPTI_0_closeandcallsubloopandincludeit(2,$1,"");
+                          closeandcallsubloopandincludeit_0(2,$1,"");
                           /* it is like end subroutine or end program         */
                           /*  Common case                                     */
-                          /* at the end of the firstpass we should remove     */
+                          /* at the end of the firstpas  we should remove     */
                           /*    from the listvarindoloop all variables which  */
                           /*    has not been declared as table in the         */
                           /*    globliste                                     */
-                          OPTI_1_cleanlistvarfordoloop(1);
+                          cleanlistvarfordoloop_1(1);
                        }
                     }
@@ -1755,10 +1896,10 @@
                        insubroutinedeclare = 0;
                        /*                                                     */
-                       OPTI_0_closeandcallsubloopandincludeit(3,$1,$2);
+                       closeandcallsubloopandincludeit_0(3,$1,$2);
                        /*  Common case                                        */
-                       /* at the end of the firstpass we should remove from   */
+                       /* at the end of the firstpas  we should remove from   */
                        /*    the listvarindoloop all variables which has not  */
                        /*    been declared as table in the globliste          */
-                       OPTI_1_cleanlistvarfordoloop(3);
+                       cleanlistvarfordoloop_1(3);
                     }
       | TOK_ENDSUBROUTINE opt_name
@@ -1768,10 +1909,10 @@
                        insubroutinedeclare = 0;
                        /*                                                     */
-                       OPTI_0_closeandcallsubloopandincludeit(1,$1,$2);
+                       closeandcallsubloopandincludeit_0(1,$1,$2);
                        /*  Common case                                        */
-                       /* at the end of the firstpass we should remove from   */
+                       /* at the end of the firstpas  we should remove from   */
                        /*    the listvarindoloop all variables which has not  */
                        /*    been declared as table in the globliste          */
-                       OPTI_1_cleanlistvarfordoloop(1);
+                       cleanlistvarfordoloop_1(1);
                     }
       | TOK_ENDFUNCTION opt_name
@@ -1781,10 +1922,10 @@
                        insubroutinedeclare = 0;
                        /*                                                     */
-                       OPTI_0_closeandcallsubloopandincludeit(0,$1,$2);
+                       closeandcallsubloopandincludeit_0(0,$1,$2);
                        /*  Common case                                        */
-                       /* at the end of the firstpass we should remove from   */
+                       /* at the end of the firstpas  we should remove from   */
                        /*    the listvarindoloop all variables which has not  */
                        /*    been declared as table in the globliste          */
-                       OPTI_1_cleanlistvarfordoloop(0);
+                       cleanlistvarfordoloop_1(0);
                     }
       | TOK_ENDMODULE opt_name
@@ -1795,7 +1936,6 @@
                           if ( aftercontainsdeclare == 0 )
                           {
-                             if ( firstpass == 1) 
-                                         DATA_1_CompleteGlobListeWithDatalist();
-                             addi_0_addsubroutine_inst_back_alloc(1);
+                             CompleteGlobListeWithDatalist_1();
+                             addsubroutine_alloc_0(1);
                           }
                        }
@@ -1820,7 +1960,6 @@
                       if (inmoduledeclare == 1 )
                       {
-                         if ( firstpass == 1) 
-                                         DATA_1_CompleteGlobListeWithDatalist();
-                         addi_0_addsubroutine_inst_back_alloc(0);
+                         CompleteGlobListeWithDatalist_1();
+                         addsubroutine_alloc_0(0);
                       }
                       inmoduledeclare = 0 ; 
@@ -1833,8 +1972,11 @@
       | caselist ':' expr
       ;
-boucledo : worddo do_var '=' expr ',' expr
-      | worddo do_var '=' expr ',' expr ',' expr
+boucledo : worddo opt_int do_var '=' expr ',' expr
+      | worddo opt_int do_var '=' expr ',' expr ',' expr
       | wordwhile expr
       | TOK_ENDDO optname
+      ;
+opt_int : 
+      | TOK_CSTINT
       ;
 opt_name : '\n'  {strcpy($$,"");}
@@ -1854,17 +1996,26 @@
 
 iffable: TOK_CONTINUE
-      | ident dims dims after_ident_dims
-      | structure_component after_ident_dims
+      | ident_dims after_ident_dims
       | goto
       | io
       | call 
-      | TOK_EXIT opt_name
-      | TOK_RETURN optexpr
+      | TOK_ALLOCATE '(' allocation_list opt_stat_spec ')'
+      | TOK_DEALLOCATE '(' allocate_object_list opt_stat_spec ')'
+      | TOK_EXIT optexpr
+      | TOK_RETURN opt_expr
+      | TOK_CYCLE opt_expr
       | stop opt_expr
+      | int_list
+      ;
+before_dims : {if ( couldaddvariable == 1 ) created_dimensionlist = 0;}
+ident_dims : ident before_dims dims dims
+      {created_dimensionlist = 1;}
+      | ident_dims '%' ident before_dims dims dims
+      {created_dimensionlist = 1;}
+int_list : TOK_CSTINT
+      | int_list ',' TOK_CSTINT
       ;
 after_ident_dims : '=' expr 
-                   {sprintf($$,"=%s",$2);}
       | TOK_POINT_TO expr 
-                   {sprintf($$,"=>%s",$2);}
       ;
 call: keywordcall opt_call 
@@ -1873,10 +2024,10 @@
                       incalldeclare=0;
                       if ( oldfortranout && 
-                           !strcmp(meetagrifinitgrids,subroutinename) && 
+                           !strcasecmp(meetagrifinitgrids,subroutinename) && 
                            firstpass == 0 &&
                            callmpiinit == 1)
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_curcall,
+                         RemoveWordSET_0(fortranout,pos_curcall,
                                                pos_end-pos_curcall);
                          fprintf(oldfortranout,"      Call MPI_Init (%s) \n"
@@ -1888,5 +2039,5 @@
                       {
                          pos_end = setposcur();
-                         RemoveWordSET(fortranout,pos_curcall,
+                         RemoveWordSET_0(fortranout,pos_curcall,
                                                pos_end-pos_curcall);
                          fprintf(oldfortranout,
@@ -1894,4 +2045,5 @@
                          strcpy(subofagrifinitgrids,subroutinename);
                       }
+                      Instanciation_0(sameagrifname);
                    }
       ;
@@ -1919,14 +2071,14 @@
                        }
                        else callagrifinitgrids = 0;
-                       if ( AGRIF_n_Vartonumber($2) == 1 ) 
+                       if ( Vartonumber($2) == 1 ) 
                        {
                           incalldeclare=1;
                           inagrifcallargument = 1 ;
-                          AGRIF_n_AddsubroutineTolistsubwhereagrifused();
+                          AddsubroutineTolistsubwhereagrifused();
                        }
                     }
       ;
 before_call : TOK_CALL
-                    {if ( firstpass == 0 ) pos_curcall=setposcur()-4;}
+                    {pos_curcall=setposcur()-4;}
 callarglist:  callarg
       | callarglist ',' callarg
@@ -1955,6 +2107,4 @@
 io: iofctl ioctl
       | read option_read
-      | write '(' idfile  opt_ioctl_format ')' opt_outlist
-                    {formatdeclare = 0;}
       | TOK_REWIND after_rewind
       | print option_print
@@ -1964,4 +2114,7 @@
 wordformat : TOK_FORMAT
                     {formatdeclare = 1;}
+opt_ioctlformat : 
+      | ioctl_format
+      ;
 opt_ioctl_format : 
       | ',' ioctl_format
@@ -1974,9 +2127,14 @@
       |   ioctl_format ',' format_expr
       ;
-format_expr : uexpr
+format_expr : 
+      | uexpr
       | TOK_CSTINT TOK_CHAR_INT
       | TOK_CSTINT debut_format ioctl_format fin_format
       | TOK_SLASH opt_CHAR_INT
+      | TOK_CHAR_INT TOK_SLASH format_expr
+      | TOK_SLASH TOK_SLASH
       | TOK_CHAR_INT
+      | '(' format_expr ')'
+      | '(' uexpr ')'
       ;
 opt_CHAR_INT : 
@@ -2018,13 +2176,10 @@
       | TOK_DASTER
       | TOK_NAME expr 
+      | TOK_NAME expr '%' ident_dims
       | TOK_NAME '(' triplet ')'
       | TOK_NAME '*' 
       | TOK_NAME TOK_DASTER 
-/*      | TOK_REC '=' ident*/
-      ;
-iofctl:  ctlkwd
-      ;
-ctlkwd: TOK_INQUIRE
-      | TOK_OPEN
+      ;
+iofctl: TOK_OPEN
       | TOK_CLOSE
       ;
@@ -2034,8 +2189,8 @@
 
 read:TOK_READ
-      ;
-write: TOK_WRITE
-      ;
-print:TOK_PRINT fexpr
+      | TOK_INQUIRE
+      | TOK_WRITE
+      ;
+print: TOK_PRINT fexpr
       | TOK_PRINT '*'
       ;
@@ -2061,7 +2216,17 @@
       | inlist ',' inelt
       ;
-inelt: lhs
+opt_lhs : 
+      | lhs
+      ;
+inelt: opt_lhs opt_operation
+      | '(' inlist ')' opt_operation
+      | predefinedfunction opt_operation
+      | simple_const opt_operation 
       | '(' inlist ',' dospec ')'
       ;
+opt_operation :
+      | operation
+      | opt_operation operation
+      ;      
 outlist: other      {strcpy($$,$1);} 
       | out2       {strcpy($$,$1);} 
@@ -2107,13 +2272,14 @@
       ;
 allocation_list: allocate_object
+      | ident_dims
       | allocation_list ',' allocate_object
       ;
 allocate_object: ident
-                   {OPTI_1_AddIdentToTheAllocateList($1);}
+                   {AddIdentToTheAllocateList_1($1);}
       | structure_component
       | array_element
       ;
 array_element: ident '(' funargs ')' 
-                   {OPTI_1_AddIdentToTheAllocateList($1);}
+                   {AddIdentToTheAllocateList_1($1);}
       ;
 subscript_list: expr 
@@ -2136,5 +2302,5 @@
       | TOK_CONSTRUCTID ':'
       ;
-logif: TOK_LOGICALIF '(' expr ')'
+logif: TOK_LOGICALIF expr ')'
       ;
 do_var: ident {strcpy($$,$1);}
@@ -2196,5 +2362,4 @@
       }
    }  
-   strcpy(commonfile,fichier_entree);
 
 /******************************************************************************/
@@ -2217,10 +2382,8 @@
    strcpy(NamePrecision," "); 
    VariableIsParameter =  0 ; 
-   PrecisionGiven = 0 ; 
-   lengspecgiven =0;
+   strcpy(NamePrecision,"");  
    c_star = 0 ; 
    insubroutinedeclare = 0 ;
    strcpy(subroutinename," "); 
-   CharacterSizeGiven = 0 ; 
    InitialValueGiven = 0 ; 
    strcpy(EmptyChar," "); 
@@ -2236,8 +2399,11 @@
 /*  2-  Parsing of the input file (1 time)                                    */
 /******************************************************************************/
-   if (firstpass == 0 ) fortranout=fopen(nomfileoutput,"w");
-   /* we should add the new module comes from common block                    */
-   if (firstpass == 0 && fortran77 == 1 ) fprintf
+   if (firstpass == 0 ) 
+   {
+      fortranout=fopen(nomfileoutput,"w");
+      /* we should add the new module comes from common block                 */
+      if (fortran77 == 1 ) fprintf
                       (fortranout,"#include \"NewModule_%s.h\" \n",curfilename);
+   }
 
    fortranparse();
@@ -2245,4 +2411,4 @@
    strcpy(curfile,mainfile);
 
-   if (firstpass ==0) fclose(fortranout);
+   if (firstpass == 0 ) fclose(fortranout);
 }
