- Timestamp:
- 2011-03-08T17:44:21+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dev_r2586_dynamic_mem/NEMOGCM/EXTERNAL/AGRIF/LIB/fortran.y
r2528 r2673 33 33 /* version 1.7 */ 34 34 /******************************************************************************/ 35 35 36 %{ 37 #define YYMAXDEPTH 1000 36 38 #include <stdlib.h> 37 39 #include <stdio.h> … … 318 320 %type <na> opt_expr 319 321 %type <na> optexpr 320 %type <na> datavallist 322 %type <lnn> datavallist 323 %type <lnn> datanamelist 321 324 %type <na> after_slash 322 325 %type <na> after_equal … … 392 395 ; 393 396 opt_recursive : 397 {isrecursive = 0;} 394 398 | TOK_RECURSIVE 399 {isrecursive = 1;} 395 400 ; 396 401 entry : 397 402 | opt_recursive TOK_SUBROUTINE name_routine arglist 398 403 { 399 if ( couldaddvariable == 1 404 if ( couldaddvariable == 1) 400 405 { 401 406 /* open param file */ … … 618 623 { 619 624 if ( insubroutinedeclare == 0 ) 625 { 620 626 Add_GlobalParameter_Var_1($3); 627 } 621 628 else Add_Parameter_Var_1($3); 622 629 pos_end = setposcur(); … … 675 682 VariableIsParameter = 0 ; 676 683 Allocatabledeclare = 0 ; 684 Targetdeclare = 0 ; 677 685 SaveDeclare = 0; 678 686 pointerdeclare = 0; … … 708 716 { 709 717 /* we should remove the data declaration */ 710 if ( couldaddvariable == 1 && aftercontainsdeclare == 0)718 if ( couldaddvariable == 1 && aftercontainsdeclare != 2 ) 711 719 { 712 720 pos_end = setposcur(); 713 721 RemoveWordSET_0(fortranout,pos_curdata, 714 722 pos_end-pos_curdata); 723 } 724 if ( couldaddvariable == 1 && aftercontainsdeclare == 1 ) 725 { 726 if (firstpass == 0) 727 { 728 ReWriteDataStatement_0(fortranout); 729 pos_end = setposcur(); 730 } 715 731 } 716 732 } … … 792 808 insubroutinedeclare == 0 ) 793 809 { 810 794 811 sprintf(ligne,"\n#include \"Module_Declar_%s.h\"\n" 795 812 ,curmodulename); … … 800 817 tofich (module_declar, ligne,1); 801 818 GlobalDeclaration = 1 ; 819 pos_cur_decl = setposcur(); 820 802 821 } 803 822 $$ = $1; … … 839 858 VariableIsParameter = 0 ; 840 859 Allocatabledeclare = 0 ; 860 Targetdeclare = 0 ; 841 861 SaveDeclare = 0; 842 862 pointerdeclare = 0; … … 898 918 { 899 919 pos_curdata = setposcur()-strlen($1); 920 Init_List_Data_Var(); 900 921 } 901 922 data : TOK_NAME TOK_SLASH datavallist TOK_SLASH … … 903 924 if ( couldaddvariable == 1 ) 904 925 { 905 if ( aftercontainsdeclare == 1 ) strcpy(ligne,""); 906 else sprintf(ligne,"(/ %s /)",$3); 907 Add_Data_Var_1($1,ligne); 926 /* if ( aftercontainsdeclare == 1 ) strcpy(ligne,""); 927 else */ 928 /* sprintf(ligne,"%s",$3);*/ 929 createstringfromlistname(ligne,$3); 930 if (firstpass == 1) 931 Add_Data_Var_1(&List_Data_Var,$1,ligne); 932 else 933 Add_Data_Var_1(&List_Data_Var_Cur,$1,ligne); 908 934 } 909 935 } … … 912 938 if ( couldaddvariable == 1 ) 913 939 { 914 if ( aftercontainsdeclare == 1 ) strcpy(ligne,""); 915 else sprintf(ligne,"(/ %s /)",$5); 916 Add_Data_Var_1($3,ligne); 940 /*if ( aftercontainsdeclare == 1 ) strcpy(ligne,""); 941 else */ 942 /*sprintf(ligne,"%s",$5); */ 943 createstringfromlistname(ligne,$5); 944 if (firstpass == 1) 945 Add_Data_Var_1(&List_Data_Var,$3,ligne); 946 else 947 Add_Data_Var_1(&List_Data_Var_Cur,$3,ligne); 917 948 } 918 949 } … … 926 957 /*******************************************************/ 927 958 /*******************************************************/ 959 if (firstpass == 1) 960 Add_Data_Var_Names_01(&List_Data_Var,$1,$3); 961 else 962 Add_Data_Var_Names_01(&List_Data_Var_Cur,$1,$3); 928 963 } 929 964 ; … … 932 967 if ( couldaddvariable == 1 ) 933 968 { 934 strcpy($$,$1);969 $$ = Insertname(NULL,$1,0); 935 970 } 936 971 } … … 939 974 if ( couldaddvariable == 1 ) 940 975 { 941 sprintf($$,"%s,%s",$1,$3);976 $$ = Insertname($3,$1,1); 942 977 } 943 978 } … … 961 996 ; 962 997 datanamelist : TOK_NAME 998 { 999 $$=Insertname(NULL,$1,0); 1000 } 963 1001 | TOK_NAME '(' expr ')' 1002 { 1003 printf("INSTRUCTION NON TRAITEE : INITIALISATION DE DATA AVEC EXPRESSION\n"); 1004 exit(0); 1005 } 964 1006 | datanamelist ',' datanamelist 1007 { 1008 $$ = concat_listname($1,$3); 1009 } 965 1010 ; 966 1011 expr_data : opt_signe simple_const … … 990 1035 ; 991 1036 interface : TOK_INTERFACE opt_name 1037 { 1038 ininterfacedeclare = 1 ; 1039 printf("INTEFACE entree\n"); 1040 } 992 1041 | TOK_ENDINTERFACE opt_name 1042 { 1043 ininterfacedeclare = 0; 1044 } 993 1045 ; 994 1046 before_dimension : TOK_DIMENSION … … 1045 1097 use_name_list : TOK_NAME 1046 1098 { 1047 $$ = Insertname(NULL,$1 );1099 $$ = Insertname(NULL,$1,0); 1048 1100 } 1049 1101 | use_name_list ',' TOK_NAME 1050 1102 { 1051 $$ = Insertname($1,$3 );1103 $$ = Insertname($1,$3,0); 1052 1104 } 1053 1105 ; … … 1063 1115 { 1064 1116 sprintf(charusemodule,"%s",$2); 1065 Add_NameOfCommon_1($2 );1117 Add_NameOfCommon_1($2,subroutinename); 1066 1118 pos_end = setposcur(); 1067 1119 RemoveWordSET_0(fortranout,pos_curcommon, … … 1074 1126 { 1075 1127 sprintf(charusemodule,"%s",$3); 1076 Add_NameOfCommon_1($3 );1128 Add_NameOfCommon_1($3,subroutinename); 1077 1129 pos_end = setposcur(); 1078 1130 RemoveWordSET_0(fortranout,pos_curcommon, … … 1393 1445 } 1394 1446 | TOK_TARGET 1447 {Targetdeclare = 1;} 1395 1448 ; 1396 1449 intent_spec : TOK_IN {strcpy($$,$1);} … … 1587 1640 ; 1588 1641 1589 lhs : ident {if ( couldaddvariable == 1 ) strcpy($$,$1);} 1642 lhs : ident {if ( couldaddvariable == 1 ) 1643 { 1644 printf("ident = %s\n",$1); 1645 strcpy($$,$1);} 1646 } 1590 1647 | structure_component 1591 {if ( couldaddvariable == 1 ) strcpy($$,$1);} 1648 {if ( couldaddvariable == 1 ) { 1649 printf("struct = %s\n",$1); 1650 strcpy($$,$1);} 1651 } 1592 1652 | array_ele_substring_func_ref 1593 {if ( couldaddvariable == 1 ) strcpy($$,$1);} 1653 {if ( couldaddvariable == 1 ) { 1654 printf("arrayref = %s\n",$1); 1655 strcpy($$,$1); 1656 }} 1594 1657 ; 1595 1658 beforefunctionuse : { … … 1662 1725 ; 1663 1726 ident : TOK_NAME { 1664 if ( couldaddvariable == 1 )1727 if ( couldaddvariable == 1 && afterpercent == 0) 1665 1728 { 1666 1729 if ( Vartonumber($1) == 1 ) … … 1673 1736 if ( VariableIsNotFunction($1) == 0 ) 1674 1737 { 1738 printf("var = %s\n",$1); 1675 1739 if ( inagrifcallargument == 1 ) 1676 1740 { … … 1685 1749 strcpy(truename,$1); 1686 1750 if (variscoupled_0($1)) strcpy(truename,getcoupledname_0($1)); 1687 /* 1688 if ( VarIsNonGridDepend($1) == 0 && 1689 Variableshouldberemove($1) == 0 ) 1690 { 1691 if ( inagrifcallargument == 1 || 1692 varisallocatable_0($1) == 1 || 1693 varispointer_0($1) == 1 ) 1694 { 1695 if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1)) 1696 { 1697 if (varistyped_0($1) == 0) 1698 { 1699 ModifyTheVariableName_0($1); 1700 } 1701 } 1702 else 1703 { 1704 } 1705 } 1706 if (variscoupled_0($1) == 1) 1707 { 1708 printf("mla variable %s est couplee %s\n",$1,getcoupledname_0($1)); 1709 ModifyTheVariableNamecoupled_0($1,getcoupledname_0($1)); 1710 } 1711 if ( inagrifcallargument != 1 || 1712 sameagrifargument ==1 ) 1713 Add_UsedInSubroutine_Var_1($1); 1714 } 1715 NotifyAgrifFunction_0($1); 1716 */ 1751 1717 1752 if ( VarIsNonGridDepend(truename) == 0 && 1718 1753 Variableshouldberemove(truename) == 0 ) 1719 { 1754 { 1720 1755 if ( inagrifcallargument == 1 || 1721 varisallocatable_0(truename) == 1 ||1722 1756 varispointer_0(truename) == 1 ) 1723 1757 { 1758 printf("var2 = %s\n",$1); 1724 1759 if ((IsinListe(List_UsedInSubroutine_Var,$1) == 1) || (inagrifcallargument == 1)) 1725 1760 { … … 1730 1765 } 1731 1766 } 1767 printf("ici3\n"); 1732 1768 if ( inagrifcallargument != 1 || 1733 1769 sameagrifargument ==1 ) 1770 { 1771 printf("ici5 %s\n",truename); 1734 1772 Add_UsedInSubroutine_Var_1(truename); 1773 } 1735 1774 } 1736 1775 NotifyAgrifFunction_0(truename); 1737 1776 } 1738 1777 } 1778 else 1779 { 1780 afterpercent = 0; 1781 } 1739 1782 } 1740 1783 ; … … 2162 2205 else 2163 2206 { 2207 incontainssubroutine = 1; 2208 strcpy(previoussubroutinename,subroutinename); 2164 2209 if ( couldaddvariable == 1 ) 2165 2210 { … … 2426 2471 | '*' 2427 2472 | TOK_DASTER 2428 | TOK_NAMEexpr2429 | TOK_NAMEexpr '%' ident_dims2430 | TOK_NAME'(' triplet ')'2431 | TOK_NAME'*'2432 | TOK_NAMETOK_DASTER2473 | ident expr 2474 | ident expr '%' ident_dims 2475 | ident '(' triplet ')' 2476 | ident '*' 2477 | ident TOK_DASTER 2433 2478 ; 2434 2479 iofctl : TOK_OPEN … … 2574 2619 int confirmyes; 2575 2620 2576 /*fortrandebug = 1;*/2621 /* fortrandebug = 1;*/ 2577 2622 if ( mark == 1 ) printf("Firstpass == %d \n",firstpass); 2578 2623 /******************************************************************************/ … … 2638 2683 VarTypepar = 0; 2639 2684 Allocatabledeclare = 0 ; 2685 Targetdeclare = 0 ; 2640 2686 strcpy(NamePrecision," "); 2641 2687 VariableIsParameter = 0 ; … … 2644 2690 functiondeclarationisdone = 0; 2645 2691 insubroutinedeclare = 0 ; 2692 ininterfacedeclare = 0 ; 2646 2693 strcpy(subroutinename," "); 2694 isrecursive = 0; 2647 2695 InitialValueGiven = 0 ; 2648 2696 strcpy(EmptyChar," "); 2649 2697 inmoduledeclare = 0; 2698 incontainssubroutine = 0; 2650 2699 colnum=0; 2651 2700 incom=0; 2652 2701 couldaddvariable=1; 2702 afterpercent = 0; 2653 2703 aftercontainsdeclare = 1; 2654 2704 strcpy(nameinttypename,""); … … 2664 2714 fortranout=fopen(nomfileoutput,"w"); 2665 2715 2666 NewModule_Creation_0(); 2716 /* NewModule_Creation_0();*/ 2667 2717 } 2668 2718 2669 2719 fortranparse(); 2670 2720 2721 if (firstpass == 0 ) 2722 { 2723 NewModule_Creation_0(); 2724 } 2725 2671 2726 strcpy(curfile,mainfile); 2672 2727 2673 if (firstpass == 0 ) fclose(fortranout); 2728 if (firstpass == 0 ) 2729 { 2730 fclose(fortranout); 2731 } 2674 2732 }
Note: See TracChangeset
for help on using the changeset viewer.