[1901] | 1 | /******************************************************************************/ |
---|
| 2 | /* */ |
---|
| 3 | /* CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran) */ |
---|
| 4 | /* */ |
---|
| 5 | /* Copyright or or Copr. Laurent Debreu (Laurent.Debreu@imag.fr) */ |
---|
| 6 | /* Cyril Mazauric (Cyril_Mazauric@yahoo.fr) */ |
---|
| 7 | /* This software is governed by the CeCILL-C license under French law and */ |
---|
| 8 | /* abiding by the rules of distribution of free software. You can use, */ |
---|
| 9 | /* modify and/ or redistribute the software under the terms of the CeCILL-C */ |
---|
| 10 | /* license as circulated by CEA, CNRS and INRIA at the following URL */ |
---|
| 11 | /* "http://www.cecill.info". */ |
---|
| 12 | /* */ |
---|
| 13 | /* As a counterpart to the access to the source code and rights to copy, */ |
---|
| 14 | /* modify and redistribute granted by the license, users are provided only */ |
---|
| 15 | /* with a limited warranty and the software's author, the holder of the */ |
---|
| 16 | /* economic rights, and the successive licensors have only limited */ |
---|
| 17 | /* liability. */ |
---|
| 18 | /* */ |
---|
| 19 | /* In this respect, the user's attention is drawn to the risks associated */ |
---|
| 20 | /* with loading, using, modifying and/or developing or reproducing the */ |
---|
| 21 | /* software by the user in light of its specific status of free software, */ |
---|
| 22 | /* that may mean that it is complicated to manipulate, and that also */ |
---|
| 23 | /* therefore means that it is reserved for developers and experienced */ |
---|
| 24 | /* professionals having in-depth computer knowledge. Users are therefore */ |
---|
| 25 | /* encouraged to load and test the software's suitability as regards their */ |
---|
| 26 | /* requirements in conditions enabling the security of their systems and/or */ |
---|
| 27 | /* data to be ensured and, more generally, to use and operate it in the */ |
---|
| 28 | /* same conditions as regards security. */ |
---|
| 29 | /* */ |
---|
| 30 | /* The fact that you are presently reading this means that you have had */ |
---|
| 31 | /* knowledge of the CeCILL-C license and that you accept its terms. */ |
---|
| 32 | /******************************************************************************/ |
---|
| 33 | /* version 1.7 */ |
---|
| 34 | /******************************************************************************/ |
---|
| 35 | #include <stdio.h> |
---|
| 36 | #include <stdlib.h> |
---|
| 37 | #include <string.h> |
---|
| 38 | #include "decl.h" |
---|
| 39 | /******************************************************************************/ |
---|
| 40 | /* Add_Data_Var_1 */ |
---|
| 41 | /******************************************************************************/ |
---|
| 42 | /* This subroutine is used to add a record to List_Data_Var */ |
---|
| 43 | /******************************************************************************/ |
---|
| 44 | /* _______ _______ _______ _______ _______ */ |
---|
| 45 | /* + + + + + + + + + + */ |
---|
| 46 | /* + NEW +--->+ data +--->+ data +--->+ data +--->+ data+ */ |
---|
| 47 | /* +______+ +______+ +______+ +______+ +______+ */ |
---|
| 48 | /* */ |
---|
| 49 | /******************************************************************************/ |
---|
[2715] | 50 | void Add_Data_Var_1 (listvar **curlist,char *name,char *values) |
---|
[1901] | 51 | { |
---|
| 52 | listvar *newvar; |
---|
[5656] | 53 | char ligne[LONG_M]; |
---|
[1901] | 54 | |
---|
[2715] | 55 | // if ( firstpass == 1 ) |
---|
| 56 | // { |
---|
[5656] | 57 | newvar=(listvar *)calloc(1,sizeof(listvar)); |
---|
| 58 | newvar->var=(variable *)calloc(1,sizeof(variable)); |
---|
[1901] | 59 | /* */ |
---|
| 60 | Init_Variable(newvar->var); |
---|
| 61 | /* */ |
---|
| 62 | if ( inmoduledeclare == 1 ) newvar->var->v_module=1; |
---|
| 63 | strcpy(newvar->var->v_nomvar,name); |
---|
| 64 | strcpy(newvar->var->v_subroutinename,subroutinename); |
---|
| 65 | strcpy(newvar->var->v_modulename,curmodulename); |
---|
[5656] | 66 | strcpy(newvar->var->v_commoninfile,cur_filename); |
---|
[2715] | 67 | if (strchr(values,',') && strncasecmp(values,"'",1)) |
---|
[5656] | 68 | sprintf(ligne,"(/%s/)",values); |
---|
[2715] | 69 | else |
---|
[5656] | 70 | strcpy(ligne,values); |
---|
[2715] | 71 | |
---|
[13027] | 72 | newvar->var->v_initialvalue=Insertname(newvar->var->v_initialvalue,ligne,0); |
---|
| 73 | |
---|
| 74 | // strcpy(newvar->var->v_initialvalue,ligne); |
---|
[2715] | 75 | Save_Length(ligne,14); |
---|
[1901] | 76 | newvar->suiv = NULL; |
---|
[2715] | 77 | if ( ! (*curlist) ) |
---|
| 78 | { |
---|
| 79 | *curlist = newvar ; |
---|
| 80 | } |
---|
| 81 | else |
---|
| 82 | { |
---|
| 83 | newvar->suiv = *curlist; |
---|
| 84 | *curlist = newvar; |
---|
| 85 | } |
---|
| 86 | // } |
---|
| 87 | } |
---|
[1901] | 88 | |
---|
[13027] | 89 | void Add_Data_Var_Names_01 (listvar **curlist,listvar *l1,listname *l2) |
---|
[2715] | 90 | { |
---|
[5656] | 91 | listvar *newvar; |
---|
| 92 | listvar *tmpvar; |
---|
[13027] | 93 | listvar *tmpvar1; |
---|
| 94 | listname *tmpvar2; |
---|
| 95 | char tempname[LONG_M]; |
---|
[5656] | 96 | variable *found_var = NULL; |
---|
[13027] | 97 | int out; |
---|
| 98 | size_t i = 0; |
---|
| 99 | char chartmp[2]; |
---|
[5656] | 100 | |
---|
| 101 | tmpvar1 = l1; |
---|
| 102 | tmpvar2 = l2; |
---|
[2715] | 103 | |
---|
[5656] | 104 | while (tmpvar1) |
---|
| 105 | { |
---|
[13027] | 106 | // printf("TMPVAR 1 nomvar = %s, initialvaluearra = %s\n",tmpvar1->var->v_nomvar,tmpvar1->var->v_initialvalue_array->n_name); |
---|
| 107 | strcpy(tempname,tmpvar1->var->v_nomvar); |
---|
| 108 | // while ( i < strlen(tmpvar1->var->v_nomvar) ) |
---|
| 109 | // { |
---|
| 110 | // if (tmpvar1->var->v_nomvar[i]=='(') break; |
---|
| 111 | // sprintf(chartmp,"%c",tmpvar1->var->v_nomvar[i]); |
---|
| 112 | // strcat(tempname,chartmp); |
---|
| 113 | // i++; |
---|
| 114 | // } |
---|
| 115 | found_var = get_variable_in_list_from_name(List_Common_Var, tempname); |
---|
| 116 | if ( ! found_var ) found_var = get_variable_in_list_from_name(List_Global_Var,tempname); |
---|
| 117 | if ( ! found_var ) found_var = get_variable_in_list_from_name(List_SubroutineDeclaration_Var,tempname); |
---|
[5656] | 118 | |
---|
[13027] | 119 | if ( found_var && found_var->v_nbdim > 1000 ) |
---|
[5656] | 120 | { |
---|
| 121 | printf("##############################################################################################################\n"); |
---|
| 122 | printf("## CONV Error : arrays in data_stmt_object lists not yet supported. Please complain to the proper authorities.\n"); |
---|
| 123 | printf("## variable name : %s (in %s:%s:%s)\n", found_var->v_nomvar, found_var->v_modulename, |
---|
| 124 | found_var->v_subroutinename, found_var->v_commonname); |
---|
| 125 | exit(1); |
---|
| 126 | } |
---|
| 127 | |
---|
[13027] | 128 | if (tmpvar1->var->v_initialvalue_array) |
---|
| 129 | { |
---|
| 130 | if ((firstpass == 1) && strcmp(tmpvar1->var->v_initialvalue_array->n_name,"")) |
---|
| 131 | { |
---|
| 132 | DecomposeTheName(tmpvar1->var->v_initialvalue_array->n_name); |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | // Search for existing newvar |
---|
| 137 | |
---|
| 138 | tmpvar = *curlist; |
---|
| 139 | out = 0; |
---|
| 140 | while (tmpvar) |
---|
| 141 | { |
---|
| 142 | if (!strcasecmp(tempname,tmpvar->var->v_nomvar) && !strcasecmp(subroutinename,tmpvar->var->v_subroutinename) && !strcasecmp(curmodulename,tmpvar->var->v_modulename) && !strcasecmp(cur_filename,tmpvar->var->v_commoninfile) ) |
---|
| 143 | { |
---|
| 144 | out = 1; |
---|
| 145 | break; |
---|
| 146 | } |
---|
| 147 | tmpvar=tmpvar->suiv; |
---|
| 148 | } |
---|
| 149 | if (out == 0) |
---|
| 150 | { |
---|
| 151 | newvar = (listvar *) calloc(1,sizeof(listvar)); |
---|
| 152 | newvar->var = (variable *) calloc(1,sizeof(variable)); |
---|
| 153 | |
---|
| 154 | Init_Variable(newvar->var); |
---|
| 155 | |
---|
| 156 | if ( inmoduledeclare == 1 ) newvar->var->v_module=1; |
---|
| 157 | |
---|
| 158 | strcpy(newvar->var->v_nomvar,tempname); |
---|
[5656] | 159 | strcpy(newvar->var->v_subroutinename,subroutinename); |
---|
| 160 | strcpy(newvar->var->v_modulename,curmodulename); |
---|
| 161 | strcpy(newvar->var->v_commoninfile,cur_filename); |
---|
[13027] | 162 | /*printf("TMPVAR 2 nomvar = %s\n",tmpvar2->n_name);*/ |
---|
| 163 | newvar->var->v_initialvalue=Insertname(newvar->var->v_initialvalue,tmpvar2->n_name,0); |
---|
| 164 | |
---|
| 165 | if (tmpvar1->var->v_initialvalue_array) |
---|
| 166 | { |
---|
| 167 | if (strcmp(tmpvar1->var->v_initialvalue_array->n_name,"")) |
---|
| 168 | { |
---|
| 169 | newvar->var->v_initialvalue_array=Insertname(newvar->var->v_initialvalue_array,tmpvar1->var->v_initialvalue_array->n_name,0); |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | newvar->var->v_do_loop=tmpvar1->var->v_do_loop; |
---|
| 173 | // strcpy(newvar->var->v_initialvalue,tmpvar2->n_name); |
---|
| 174 | // strcpy(newvar->var->v_initialvalue_array,tmpvar1->var->v_initialvalue_array); |
---|
| 175 | |
---|
| 176 | newvar->var->v_dimension=tmpvar1->var->v_dimension; |
---|
[2715] | 177 | |
---|
[5656] | 178 | Save_Length(tmpvar2->n_name,14); |
---|
[2715] | 179 | |
---|
[5656] | 180 | newvar->suiv = NULL; |
---|
| 181 | |
---|
| 182 | if ( *curlist != NULL ) |
---|
| 183 | { |
---|
| 184 | tmpvar = *curlist; |
---|
| 185 | while (tmpvar->suiv) |
---|
| 186 | tmpvar = tmpvar->suiv; |
---|
| 187 | tmpvar->suiv = newvar; |
---|
| 188 | } |
---|
| 189 | else |
---|
| 190 | { |
---|
| 191 | *curlist = newvar ; |
---|
| 192 | } |
---|
[13027] | 193 | tmpvar=newvar; |
---|
| 194 | } |
---|
| 195 | else // out = 1 |
---|
| 196 | { |
---|
| 197 | tmpvar->var->v_initialvalue=Insertname(tmpvar->var->v_initialvalue,tmpvar2->n_name,0); |
---|
| 198 | if (strcmp(tmpvar1->var->v_initialvalue_array->n_name,"")) |
---|
| 199 | { |
---|
| 200 | tmpvar->var->v_initialvalue_array=Insertname(tmpvar->var->v_initialvalue_array,tmpvar1->var->v_initialvalue_array->n_name,0); |
---|
| 201 | } |
---|
| 202 | tmpvar->var->v_do_loop=tmpvar1->var->v_do_loop; |
---|
| 203 | } |
---|
[5656] | 204 | |
---|
| 205 | tmpvar1 = tmpvar1->suiv; |
---|
[13027] | 206 | tmpvar2 = tmpvar2->suiv; |
---|
[5656] | 207 | } |
---|
[13027] | 208 | |
---|
| 209 | while (tmpvar2) |
---|
| 210 | { |
---|
| 211 | strcpy(tempname,tmpvar2->n_name); |
---|
| 212 | tmpvar->var->v_initialvalue = Insertname(tmpvar->var->v_initialvalue,tempname,1); |
---|
| 213 | tmpvar2 = tmpvar2->suiv; |
---|
| 214 | } |
---|
| 215 | |
---|
[1901] | 216 | } |
---|