dependfile.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  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. /* Creation and modification of .dependfile */
  41. /******************************************************************************/
  42. /* .dependnbxnby : this file contains tabvars indices of variables*/
  43. /* given in agrif.in as number of cells */
  44. /* .dependuse<module> : this file contains all modules used in the */
  45. /* current file */
  46. /* .dependparameter<module> : this file contains all parmeters defined in */
  47. /* the current file */
  48. /* .depend<module name> : this file contains all globals variables */
  49. /* informations (name, dim, etc ...) */
  50. /* .dependavailable : this file contains all tabvars indices which */
  51. /* are not used. */
  52. /******************************************************************************/
  53. /******************************************************************************/
  54. /* Writethedependnbxnbyfile */
  55. /******************************************************************************/
  56. /* This subroutine is used to create the .dependnbxnby */
  57. /******************************************************************************/
  58. /* */
  59. /* .dependnbxnby */
  60. /* */
  61. /* nbmaillesX */
  62. /* nbmaillesY */
  63. /* nbmaillesZ */
  64. /* */
  65. /******************************************************************************/
  66. void Writethedependnbxnbyfile()
  67. {
  68. FILE *dependfileoutput;
  69. listvar *parcours;
  70. int out;
  71. // We look in 'List_Global_Var' for all the variables of the current file to parse
  72. parcours = List_Global_Var;
  73. out = 0;
  74. while (parcours && out == 0 )
  75. {
  76. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
  77. else parcours = parcours->suiv;
  78. }
  79. if ( out == 0 )
  80. {
  81. parcours =List_Common_Var;
  82. while (parcours && out == 0 )
  83. {
  84. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
  85. else parcours = parcours->suiv;
  86. }
  87. }
  88. NbMailleXDefined = 0;
  89. if ( out == 1 )
  90. {
  91. NbMailleXDefined = 1;
  92. sprintf(dependfilename, "%s/.dependnbxnby", work_dir);
  93. dependfileoutput = fopen(dependfilename, "w");
  94. fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
  95. IndicenbmaillesX = parcours->var->v_indicetabvars;
  96. if ( dimprob > 1 )
  97. {
  98. parcours =List_Global_Var;
  99. out = 0;
  100. while (parcours && out == 0 )
  101. {
  102. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
  103. else parcours = parcours->suiv;
  104. }
  105. if ( out == 0 )
  106. {
  107. parcours =List_Common_Var;
  108. while (parcours && out == 0 )
  109. {
  110. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
  111. else parcours = parcours->suiv;
  112. }
  113. }
  114. if ( out == 1 )
  115. {
  116. fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
  117. IndicenbmaillesY = parcours->var->v_indicetabvars;
  118. }
  119. }
  120. if ( dimprob > 2 )
  121. {
  122. parcours =List_Global_Var;
  123. out = 0;
  124. while (parcours && out == 0 )
  125. {
  126. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
  127. else parcours = parcours->suiv;
  128. }
  129. if ( out == 0 )
  130. {
  131. parcours =List_Common_Var;
  132. while (parcours && out == 0 )
  133. {
  134. if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
  135. else parcours = parcours->suiv;
  136. }
  137. }
  138. if ( out == 1 )
  139. {
  140. fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
  141. IndicenbmaillesZ = parcours->var->v_indicetabvars;
  142. }
  143. }
  144. if ( out == 1 ) fclose(dependfileoutput);
  145. }
  146. }
  147. /******************************************************************************/
  148. /* Readthedependnbxnbyfile */
  149. /******************************************************************************/
  150. /* This subroutine is used to create the .dependnbxnby */
  151. /******************************************************************************/
  152. /* */
  153. /* .dependnbxnby */
  154. /* */
  155. /* nbmaillesX */
  156. /* nbmaillesY */
  157. /* nbmaillesZ */
  158. /* */
  159. /******************************************************************************/
  160. void Readthedependnbxnbyfile()
  161. {
  162. FILE *dependfileoutput;
  163. sprintf(dependfilename, "%s/.dependnbxnby", work_dir);
  164. if ((dependfileoutput = fopen(dependfilename, "r"))!=NULL)
  165. {
  166. fscanf(dependfileoutput,"%d\n",&IndicenbmaillesX);
  167. if ( dimprob > 1 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesY);
  168. if ( dimprob > 2 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesZ);
  169. fclose(dependfileoutput);
  170. }
  171. }
  172. /******************************************************************************/
  173. /* Writethedependlistofmoduleused */
  174. /******************************************************************************/
  175. /* This subroutine is used to create the .dependuse<module> */
  176. /******************************************************************************/
  177. /* */
  178. /* .dependuse<name> */
  179. /* */
  180. /* mod1 */
  181. /* mod2 */
  182. /* */
  183. /******************************************************************************/
  184. void Writethedependlistofmoduleused(const char *NameTampon )
  185. {
  186. FILE *dependfileoutput;
  187. listusemodule *parcours;
  188. char lowername[LONG_VNAME];
  189. if ( ! List_NameOfModuleUsed ) return;
  190. convert2lower(lowername, NameTampon);
  191. sprintf(dependfilename, "%s/.depend_use%s", work_dir, lowername);
  192. dependfileoutput = fopen(dependfilename, "w");
  193. parcours = List_NameOfModuleUsed;
  194. while (parcours)
  195. {
  196. if ( !strcasecmp(lowername,parcours->u_modulename) &&
  197. !strcasecmp(parcours->u_cursubroutine,"") )
  198. {
  199. // We look in 'List_NameOfModuleUsed' for all the variables of the current file to parse
  200. fprintf(dependfileoutput,"%s\n",parcours->u_usemodule);
  201. }
  202. parcours = parcours->suiv;
  203. }
  204. fclose(dependfileoutput);
  205. }
  206. /******************************************************************************/
  207. /* Readthedependlistofmoduleused */
  208. /******************************************************************************/
  209. /* This subroutine is used to create the .dependuse<module> */
  210. /******************************************************************************/
  211. /* */
  212. /* .dependuse<name> */
  213. /* */
  214. /* mod1 */
  215. /* mod2 */
  216. /* */
  217. /******************************************************************************/
  218. void Readthedependlistofmoduleused(const char *NameTampon)
  219. {
  220. FILE *dependfileoutput;
  221. listusemodule *parcours;
  222. char lowername[LONG_VNAME];
  223. tmpuselocallist = (listusemodule *)NULL;
  224. convert2lower(lowername, NameTampon);
  225. sprintf(dependfilename, "%s/.depend_use%s", work_dir, lowername);
  226. if ((dependfileoutput = fopen(dependfilename, "r"))!=NULL)
  227. {
  228. /* if the file exist we should verify that this file has changed */
  229. while (!feof(dependfileoutput))
  230. {
  231. parcours=(listusemodule *)calloc(1,sizeof(listusemodule));
  232. fscanf(dependfileoutput,"%s\n",parcours->u_usemodule);
  233. parcours->suiv = tmpuselocallist;
  234. tmpuselocallist = parcours;
  235. parcours = NULL;
  236. }
  237. fclose(dependfileoutput);
  238. }
  239. }
  240. /******************************************************************************/
  241. /* WritedependParameterList */
  242. /******************************************************************************/
  243. /* This subroutine is used to create the .dependparameter<name> */
  244. /******************************************************************************/
  245. /* */
  246. /* .dependparameter<name> */
  247. /* */
  248. /* mod1 */
  249. /* mod2 */
  250. /* */
  251. /******************************************************************************/
  252. void WritedependParameterList(const char *NameTampon )
  253. {
  254. FILE *dependfileoutput;
  255. listvar *parcours;
  256. char lowername[LONG_VNAME];
  257. if ( List_GlobalParameter_Var )
  258. {
  259. convert2lower(lowername, NameTampon);
  260. sprintf(dependfilename, "%s/.depend_paramater_%s", work_dir, lowername);
  261. dependfileoutput = fopen(dependfilename, "w");
  262. parcours = List_GlobalParameter_Var;
  263. while (parcours)
  264. {
  265. if ( !strcasecmp(lowername, parcours->var->v_modulename) )
  266. {
  267. fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
  268. fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename);
  269. }
  270. parcours = parcours->suiv;
  271. }
  272. fclose(dependfileoutput);
  273. }
  274. }
  275. /******************************************************************************/
  276. /* ReaddependParameterList */
  277. /******************************************************************************/
  278. /* This subroutine is used to create the .dependparameter<name> */
  279. /******************************************************************************/
  280. /* */
  281. /* .dependparameter<name> */
  282. /* */
  283. /* mod1 */
  284. /* mod2 */
  285. /* */
  286. /******************************************************************************/
  287. listparameter *ReaddependParameterList(const char *NameTampon,listparameter *listout)
  288. {
  289. FILE *dependfileoutput;
  290. listparameter *parcours;
  291. char lowername[LONG_VNAME];
  292. convert2lower(lowername, NameTampon);
  293. sprintf(dependfilename, "%s/.depend_paramater_%s", work_dir, lowername);
  294. if ((dependfileoutput = fopen(dependfilename,"r"))!=NULL)
  295. {
  296. /* if the file exist we should verify that this file has changed */
  297. while (!feof(dependfileoutput))
  298. {
  299. parcours=(listparameter *)calloc(1,sizeof(listparameter));
  300. fscanf(dependfileoutput,"%s\n",parcours->p_name);
  301. fscanf(dependfileoutput,"%s\n",parcours->p_modulename);
  302. parcours->suiv = listout;
  303. listout = parcours;
  304. parcours = NULL;
  305. }
  306. fclose(dependfileoutput);
  307. }
  308. return listout;
  309. }
  310. /******************************************************************************/
  311. /* Writethedependfile */
  312. /******************************************************************************/
  313. /* This subroutine is used to create the .depend<name> */
  314. /******************************************************************************/
  315. /* */
  316. /* .depend<name> */
  317. /* */
  318. /* REAL */
  319. /* Variable */
  320. /* char dimension or T */
  321. /* table dimension */
  322. /* is type given */
  323. /* precision or T */
  324. /* initial value or T */
  325. /* indice in the tabvars */
  326. /* listdimension or T */
  327. /* ------------------------- */
  328. /* */
  329. /******************************************************************************/
  330. void Writethedependfile(const char *NameTampon, listvar *input )
  331. {
  332. FILE *dependfileoutput;
  333. listvar *parcours;
  334. listdim *dims;
  335. char ligne[LONG_M];
  336. char listdimension[LONG_M];
  337. char curname[LONG_M];
  338. char lowername[LONG_VNAME];
  339. int out;
  340. if ( input )
  341. {
  342. convert2lower(lowername, NameTampon);
  343. sprintf(dependfilename, "%s/.depend_%s", work_dir, lowername);
  344. dependfileoutput = fopen(dependfilename,"w");
  345. // We look in 'input' for all the variables of the current file to parse
  346. parcours =input;
  347. out = 0;
  348. strcpy(curname,"");
  349. while (parcours && out == 0 )
  350. {
  351. if ( !strcasecmp(parcours->var->v_modulename, lowername) ||
  352. !strcasecmp(parcours->var->v_commonname, lowername) )
  353. {
  354. /* */
  355. if ( strcasecmp(curname,"") &&
  356. !strcasecmp(curname,parcours->var->v_nomvar) ) out = 1 ;
  357. if ( !strcasecmp(curname,"") ) strcpy(curname,parcours->var->v_nomvar);
  358. /* */
  359. if ( out == 0 )
  360. {
  361. /********** TYPEVAR ************************************************/
  362. fprintf(dependfileoutput,"%s\n",parcours->var->v_typevar);
  363. /********** CATVAR ************************************************/
  364. fprintf(dependfileoutput,"%d\n",parcours->var->v_catvar);
  365. /********** NOMVAR *************************************************/
  366. fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
  367. /********** DIMCHAR ************************************************/
  368. if ( strcasecmp(parcours->var->v_dimchar, "") )
  369. {
  370. fprintf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
  371. }
  372. else
  373. {
  374. fprintf(dependfileoutput,"T\n");
  375. }
  376. /********** COMMONINFILE *******************************************/
  377. if ( strcasecmp(parcours->var->v_commoninfile,"") )
  378. {
  379. fprintf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
  380. }
  381. else
  382. {
  383. fprintf(dependfileoutput,"T\n");
  384. }
  385. /********** COMMONNAME *********************************************/
  386. if ( strcasecmp(parcours->var->v_commonname,"") )
  387. {
  388. fprintf(dependfileoutput,"%s\n",parcours->var->v_commonname);
  389. }
  390. else
  391. {
  392. fprintf(dependfileoutput,"T\n");
  393. }
  394. /********** MODULENAME *********************************************/
  395. if ( strcasecmp(parcours->var->v_modulename,"") )
  396. {
  397. fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename);
  398. }
  399. else
  400. {
  401. fprintf(dependfileoutput,"T\n");
  402. }
  403. /********** NBDIM **************************************************/
  404. /* fprintf(dependfileoutput,"%d\n",parcours->var->v_nbdim);*/
  405. /********** DIMENSIONGIVEN *****************************************/
  406. /* fprintf(dependfileoutput,"%d\n",parcours->var->v_dimensiongiven);*/
  407. /********** ALLOCATABLE ********************************************/
  408. fprintf(dependfileoutput,"%d\n",parcours->var->v_allocatable);
  409. /********** TARGET ********************************************/
  410. fprintf(dependfileoutput,"%d\n",parcours->var->v_target);
  411. /********** POINTERDECLARE *****************************************/
  412. fprintf(dependfileoutput,"%d\n",parcours->var->v_pointerdeclare);
  413. /********** PRECISION **********************************************/
  414. if ( strcasecmp(parcours->var->v_precision,"") )
  415. {
  416. fprintf(dependfileoutput,"%s\n",parcours->var->v_precision);
  417. }
  418. else
  419. {
  420. fprintf(dependfileoutput,"T\n");
  421. }
  422. /********** INITIALVALUE *******************************************/
  423. /* if ( strcasecmp(parcours->var->v_initialvalue,"") )
  424. {
  425. fprintf(dependfileoutput,"%s\n",parcours->var->v_initialvalue);
  426. }
  427. else
  428. {
  429. fprintf(dependfileoutput,"T\n");
  430. }*/
  431. /********** NAMEINTYPENAME *****************************************/
  432. if ( strcasecmp(parcours->var->v_nameinttypename,"") )
  433. {
  434. fprintf(dependfileoutput,"%s\n",parcours->var->v_nameinttypename);
  435. }
  436. else
  437. {
  438. fprintf(dependfileoutput,"T\n");
  439. }
  440. /********** PRIVATE *****************************************/
  441. fprintf(dependfileoutput,"%d\n",parcours->var->v_PrivateDeclare);
  442. /********** INDICETABVARS ******************************************/
  443. fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
  444. /********** READEDLISTDIMENSION ************************************/
  445. if ( parcours->var->v_dimensiongiven == 1 )
  446. {
  447. dims = parcours->var->v_dimension;
  448. strcpy(listdimension,"");
  449. while (dims)
  450. {
  451. sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
  452. strcat(listdimension,ligne);
  453. if ( dims->suiv )
  454. {
  455. strcat(listdimension,",");
  456. }
  457. dims = dims->suiv;
  458. }
  459. Save_Length(listdimension,15);
  460. fprintf(dependfileoutput,"%s\n",listdimension);
  461. }
  462. else
  463. {
  464. fprintf(dependfileoutput,"T\n");
  465. }
  466. /*******************************************************************/
  467. fprintf(dependfileoutput,"------------------------\n");
  468. }
  469. }
  470. parcours = parcours->suiv;
  471. }
  472. fclose(dependfileoutput);
  473. }
  474. }
  475. /******************************************************************************/
  476. /* Readthedependfile */
  477. /******************************************************************************/
  478. /* This subroutine is used to read the .dependfile<name> and to insert new */
  479. /* information in the listout list. */
  480. /******************************************************************************/
  481. /* */
  482. /* .dependmodule --------> = list of var */
  483. /* */
  484. /* not.dependmodule --------> */
  485. /* */
  486. /******************************************************************************/
  487. listvar *Readthedependfile(const char *NameTampon , listvar *listout)
  488. {
  489. FILE *dependfileoutput;
  490. listvar *parcours0;
  491. listvar *parcours;
  492. listvar *parcoursprec;
  493. char nothing[LONG_M];
  494. char lowername[LONG_VNAME];
  495. size_t i;
  496. parcoursprec = (listvar *)NULL;
  497. convert2lower(lowername, NameTampon);
  498. sprintf(dependfilename, "%s/.depend_%s", work_dir, lowername);
  499. if ((dependfileoutput = fopen(dependfilename, "r"))==NULL)
  500. {
  501. /* if the file doesn't exist it means that it is the first time */
  502. /* we tried to parse this file */
  503. }
  504. else
  505. {
  506. /* if the file exist we should verify that this file has changed */
  507. while (!feof(dependfileoutput))
  508. {
  509. parcours=(listvar *)calloc(1,sizeof(listvar));
  510. parcours->var=(variable *)calloc(1,sizeof(variable));
  511. /* */
  512. Init_Variable(parcours->var);
  513. /* */
  514. /********** TYPEVAR ************************************************/
  515. fscanf(dependfileoutput,"%s\n",parcours->var->v_typevar);
  516. /********** CATVAR ************************************************/
  517. fscanf(dependfileoutput,"%d\n",&parcours->var->v_catvar);
  518. /********** NOMVAR *************************************************/
  519. fscanf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
  520. /********** DIMCHAR ************************************************/
  521. fscanf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
  522. if ( !strcasecmp(parcours->var->v_dimchar,"T") )
  523. {
  524. strcpy(parcours->var->v_dimchar,"");
  525. }
  526. /********** COMMONINFILE *******************************************/
  527. fscanf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
  528. if ( !strcasecmp(parcours->var->v_commoninfile,"T") )
  529. {
  530. strcpy(parcours->var->v_commoninfile,"");
  531. }
  532. /********** COMMONNAME *********************************************/
  533. fscanf(dependfileoutput,"%s\n",parcours->var->v_commonname);
  534. if ( !strcasecmp(parcours->var->v_commonname,"T") )
  535. {
  536. strcpy(parcours->var->v_commonname,"");
  537. }
  538. /********** MODULENAME *********************************************/
  539. fscanf(dependfileoutput,"%s\n",parcours->var->v_modulename);
  540. if ( !strcasecmp(parcours->var->v_modulename,"T") )
  541. {
  542. strcpy(parcours->var->v_modulename,"");
  543. }
  544. /********** NBDIM **************************************************/
  545. /* fscanf(dependfileoutput,"%d\n",&parcours->var->v_nbdim);*/
  546. /********** DIMENSIONGIVEN *****************************************/
  547. /* fscanf(dependfileoutput,"%d\n",&parcours->var->v_dimensiongiven);*/
  548. /********** ALLOCATABLE ********************************************/
  549. fscanf(dependfileoutput,"%d\n",&parcours->var->v_allocatable);
  550. if ( parcours->var->v_allocatable == 1 )
  551. {
  552. Add_Allocate_Var_1(parcours->var->v_nomvar, parcours->var->v_commonname);
  553. }
  554. /********** TARGET ********************************************/
  555. fscanf(dependfileoutput,"%d\n",&parcours->var->v_target);
  556. /********** POINTERDECLARE *****************************************/
  557. fscanf(dependfileoutput,"%d\n",&parcours->var->v_pointerdeclare);
  558. if ( parcours->var->v_pointerdeclare == 1 )
  559. {
  560. Add_Pointer_Var_1(parcours->var->v_nomvar);
  561. }
  562. /********** PRECISION **********************************************/
  563. fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_precision);
  564. if ( !strcasecmp(parcours->var->v_precision,"T") )
  565. {
  566. strcpy(parcours->var->v_precision,"");
  567. }
  568. /********** INITIALVALUE *******************************************/
  569. /* fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_initialvalue);
  570. if ( !strcasecmp(parcours->var->v_initialvalue,"T") )
  571. {
  572. strcpy(parcours->var->v_initialvalue,"");
  573. }*/
  574. /********** NAMEINTYPENAME *****************************************/
  575. fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_nameinttypename);
  576. if ( !strcasecmp(parcours->var->v_nameinttypename,"T") )
  577. {
  578. strcpy(parcours->var->v_nameinttypename,"");
  579. }
  580. /********** PRIVATE *****************************************/
  581. fscanf(dependfileoutput,"%d\n",&parcours->var->v_PrivateDeclare);
  582. /********** INDICETABVARS ******************************************/
  583. fscanf(dependfileoutput,"%d\n",&parcours->var->v_indicetabvars);
  584. /********** READEDLISTDIMENSION ************************************/
  585. fscanf(dependfileoutput,"%s\n",parcours->var->v_readedlistdimension);
  586. if ( !strcasecmp(parcours->var->v_readedlistdimension,"T") )
  587. {
  588. strcpy(parcours->var->v_readedlistdimension,"");
  589. }
  590. else
  591. {
  592. parcours->var->v_dimensiongiven = 1;
  593. parcours->var->v_nbdim = 1;
  594. i = 1;
  595. /* */
  596. while ( i < strlen(parcours->var->v_readedlistdimension) )
  597. {
  598. if ( parcours->var->v_readedlistdimension[i] == ',' )
  599. {
  600. parcours->var->v_nbdim = parcours->var->v_nbdim + 1 ;
  601. }
  602. /* */
  603. i=i+1;
  604. }
  605. }
  606. /*******************************************************************/
  607. fscanf(dependfileoutput,"%s\n",nothing);
  608. parcours->suiv = NULL;
  609. if (parcours->var->v_PrivateDeclare == 0)
  610. {
  611. if ( !listout )
  612. {
  613. listout = parcours;
  614. parcoursprec = parcours;
  615. }
  616. else
  617. {
  618. if ( parcoursprec )
  619. {
  620. parcoursprec->suiv = parcours;
  621. parcoursprec = parcours;
  622. }
  623. else
  624. {
  625. parcours0 = listout;
  626. while ( parcours0->suiv ) parcours0=parcours0->suiv;
  627. parcours0->suiv = parcours;
  628. parcoursprec = parcours0->suiv;
  629. }
  630. }
  631. }
  632. parcours = NULL;
  633. }
  634. fclose(dependfileoutput);
  635. }
  636. return listout;
  637. }
  638. void Write_Subroutine_For_Alloc()
  639. {
  640. FILE *dependfileoutput;
  641. listnom *parcours;
  642. if ( List_Subroutine_For_Alloc )
  643. {
  644. sprintf(dependfilename, "%s/.dependAllocAgrif", work_dir);
  645. if ((dependfileoutput=fopen(dependfilename, "w"))!=NULL)
  646. {
  647. parcours = List_Subroutine_For_Alloc;
  648. while (parcours)
  649. {
  650. fprintf(dependfileoutput,"%s\n",parcours->o_nom);
  651. parcours = parcours->suiv;
  652. }
  653. fclose(dependfileoutput);
  654. }
  655. }
  656. }
  657. void Read_Subroutine_For_Alloc()
  658. {
  659. FILE *dependfileoutput;
  660. listnom *parcours;
  661. listnom *ref;
  662. ref = (listnom*) NULL;
  663. sprintf(dependfilename, "%s/.dependAllocAgrif", work_dir);
  664. if ( (dependfileoutput=fopen(dependfilename, "r")) != NULL )
  665. {
  666. List_Subroutine_For_Alloc = (listnom*) NULL;
  667. while ( !feof(dependfileoutput) )
  668. {
  669. parcours = (listnom*) calloc(1,sizeof(listnom));
  670. strcpy(parcours->o_nom,"");
  671. fscanf(dependfileoutput,"%s\n",parcours->o_nom);
  672. parcours->suiv = NULL;
  673. if ( !List_Subroutine_For_Alloc )
  674. {
  675. List_Subroutine_For_Alloc = parcours;
  676. }
  677. else
  678. {
  679. ref->suiv = parcours;
  680. }
  681. ref = parcours;
  682. }
  683. fclose(dependfileoutput);
  684. }
  685. }
  686. /******************************************************************************/
  687. /* Writethedependavailablefile */
  688. /******************************************************************************/
  689. /* This subroutine is used to write the .dependfileavailable file */
  690. /******************************************************************************/
  691. /* */
  692. /* .dependavailable */
  693. /* tabvars(1) = var1 */
  694. /* tabvars(3) = var1 2 */
  695. /* tabvars(4) = var1 =====> 5 */
  696. /* tabvars(6) = var1 */
  697. /* tabvars(7) = var1 */
  698. /* */
  699. /* */
  700. /* */
  701. /******************************************************************************/
  702. void Writethedependavailablefile()
  703. {
  704. FILE *dependfileoutput;
  705. listindice *parcours;
  706. int i;
  707. sprintf(dependfilename, "%s/.dependavailable", work_dir);
  708. if ((dependfileoutput=fopen(dependfilename, "w"))!=NULL)
  709. {
  710. /* We are looking for all the indices of the Listofavailableindices */
  711. for (i=0;i<NB_CAT_VARIABLES;i++)
  712. {
  713. parcours = Listofavailableindices_glob[i];
  714. while (parcours)
  715. {
  716. if ( parcours->i_indice != 0 )
  717. {
  718. fprintf(dependfileoutput,"%d %d\n",i,parcours->i_indice);
  719. }
  720. parcours = parcours->suiv;
  721. }
  722. }
  723. fclose(dependfileoutput);
  724. }
  725. }
  726. /******************************************************************************/
  727. /* Readthedependavailablefile */
  728. /******************************************************************************/
  729. /* This subroutine is used to read the .dependfileavailable file */
  730. /******************************************************************************/
  731. /* */
  732. /* .dependavailable */
  733. /* tabvars(1) = var1 */
  734. /* tabvars(3) = var1 2 */
  735. /* tabvars(4) = var1 =====> 5 ==> Listofavailableindices */
  736. /* tabvars(6) = var1 */
  737. /* tabvars(7) = var1 */
  738. /* */
  739. /* */
  740. /* */
  741. /******************************************************************************/
  742. void Readthedependavailablefile()
  743. {
  744. FILE *dependfileoutput;
  745. listindice *parcours;
  746. int current_cat;
  747. sprintf(dependfilename, "%s/.dependavailable", work_dir);
  748. if ((dependfileoutput=fopen(dependfilename, "r"))!=NULL)
  749. {
  750. /* We are looking for all the indices of the Listofavailableindices */
  751. Listofavailableindices_glob = (listindice **) calloc(NB_CAT_VARIABLES,sizeof(listindice *));
  752. while (!feof(dependfileoutput))
  753. {
  754. parcours=(listindice *)calloc(1,sizeof(listindice));
  755. fscanf(dependfileoutput,"%d %d\n",&current_cat,&parcours->i_indice);
  756. if ( parcours->i_indice != 0 && parcours->i_indice < 10000000 )
  757. {
  758. parcours -> suiv = Listofavailableindices_glob[current_cat];
  759. Listofavailableindices_glob[current_cat] = parcours;
  760. }
  761. else
  762. {
  763. free(parcours);
  764. }
  765. }
  766. fclose(dependfileoutput);
  767. }
  768. }
  769. /******************************************************************************/
  770. /* is_dependfile_created */
  771. /******************************************************************************/
  772. /* This subroutine is used to know if the .depend<NameTampon> exist */
  773. /* it means if the file has been ever parsed */
  774. /******************************************************************************/
  775. /* */
  776. /******************************************************************************/
  777. int is_dependfile_created(const char *NameTampon)
  778. {
  779. FILE *dependfileoutput;
  780. char lowername[LONG_VNAME];
  781. convert2lower(lowername, NameTampon);
  782. sprintf(dependfilename, "%s/.depend_%s", work_dir, lowername);
  783. dependfileoutput = fopen(dependfilename, "r");
  784. if ( (dependfileoutput = fopen(dependfilename, "r")) != NULL )
  785. {
  786. fclose(dependfileoutput);
  787. return 1;
  788. }
  789. else
  790. return 0;
  791. }
  792. void Write_val_max()
  793. {
  794. FILE *dependfileoutput;
  795. sprintf(dependfilename, "%s/.dependvalmax", work_dir);
  796. if ((dependfileoutput=fopen(dependfilename, "w"))!=NULL)
  797. {
  798. fprintf(dependfileoutput,"length_last\n");
  799. fprintf(dependfileoutput,"%lu\n", length_last);
  800. fprintf(dependfileoutput,"length_first\n");
  801. fprintf(dependfileoutput,"%lu\n", length_first);
  802. fprintf(dependfileoutput,"length_v_vallengspec\n");
  803. fprintf(dependfileoutput,"%lu\n", length_v_vallengspec);
  804. fprintf(dependfileoutput,"length_v_commoninfile\n");
  805. fprintf(dependfileoutput,"%lu\n", length_v_commoninfile);
  806. fprintf(dependfileoutput,"length_v_precision\n");
  807. fprintf(dependfileoutput,"%lu\n", length_v_precision);
  808. fprintf(dependfileoutput,"length_v_IntentSpec\n");
  809. fprintf(dependfileoutput,"%lu\n", length_v_IntentSpec);
  810. fprintf(dependfileoutput,"length_v_initialvalue\n");
  811. fprintf(dependfileoutput,"%lu\n", length_v_initialvalue);
  812. fprintf(dependfileoutput,"length_v_readedlistdimension\n");
  813. fprintf(dependfileoutput,"%lu\n", length_v_readedlistdimension);
  814. fprintf(dependfileoutput,"length_a_nomvar\n");
  815. fprintf(dependfileoutput,"%lu\n", length_a_nomvar);
  816. fprintf(dependfileoutput,"length_toprintglob\n");
  817. fprintf(dependfileoutput,"%lu\n", length_toprintglob);
  818. fprintf(dependfileoutput,"Size_char0d\n");
  819. fprintf(dependfileoutput,"%d\n",value_char_size);
  820. fprintf(dependfileoutput,"Size_char1d\n");
  821. fprintf(dependfileoutput,"%d\n",value_char_size1);
  822. fprintf(dependfileoutput,"Size_char2d\n");
  823. fprintf(dependfileoutput,"%d\n",value_char_size2);
  824. fprintf(dependfileoutput,"Size_char3d\n");
  825. fprintf(dependfileoutput,"%d\n",value_char_size3);
  826. fprintf(dependfileoutput,"length_tmpvargridname\n");
  827. fprintf(dependfileoutput,"%lu\n", length_tmpvargridname);
  828. fprintf(dependfileoutput,"length_ligne_Subloop\n");
  829. fprintf(dependfileoutput,"%lu\n", length_ligne_Subloop);
  830. fprintf(dependfileoutput,"length_toprint_toamr\n");
  831. fprintf(dependfileoutput,"%lu\n", length_toprint_utilagrif);
  832. fprintf(dependfileoutput,"length_toprinttmp_utilchar\n");
  833. fprintf(dependfileoutput,"%lu\n", length_toprinttmp_utilchar);
  834. fprintf(dependfileoutput,"length_ligne_writedecl\n");
  835. fprintf(dependfileoutput,"%lu\n", length_ligne_writedecl);
  836. fprintf(dependfileoutput,"length_newname_toamr\n");
  837. fprintf(dependfileoutput,"%lu\n", length_newname_toamr);
  838. fprintf(dependfileoutput,"length_newname_writedecl\n");
  839. fprintf(dependfileoutput,"%lu\n", length_newname_writedecl);
  840. fprintf(dependfileoutput,"length_ligne_toamr\n");
  841. fprintf(dependfileoutput,"%lu\n", length_ligne_toamr);
  842. fprintf(dependfileoutput,"length_tmpligne_writedecl\n");
  843. fprintf(dependfileoutput,"%lu\n", length_tmpligne_writedecl);
  844. fclose(dependfileoutput);
  845. }
  846. }
  847. void Read_val_max()
  848. {
  849. char nothing[LONG_M];
  850. FILE *dependfileoutput;
  851. sprintf(dependfilename, "%s/.dependvalmax", work_dir);
  852. if ((dependfileoutput=fopen(".dependvalmax","r"))!=NULL)
  853. {
  854. fscanf(dependfileoutput,"%s\n",nothing);
  855. fscanf(dependfileoutput,"%lu\n", &length_last);
  856. fscanf(dependfileoutput,"%s\n",nothing);
  857. fscanf(dependfileoutput,"%lu\n", &length_first);
  858. fscanf(dependfileoutput,"%s\n",nothing);
  859. fscanf(dependfileoutput,"%lu\n", &length_v_vallengspec);
  860. fscanf(dependfileoutput,"%s\n",nothing);
  861. fscanf(dependfileoutput,"%lu\n", &length_v_commoninfile);
  862. fscanf(dependfileoutput,"%s\n",nothing);
  863. fscanf(dependfileoutput,"%lu\n", &length_v_precision);
  864. fscanf(dependfileoutput,"%s\n",nothing);
  865. fscanf(dependfileoutput,"%lu\n", &length_v_IntentSpec);
  866. fscanf(dependfileoutput,"%s\n",nothing);
  867. fscanf(dependfileoutput,"%lu\n", &length_v_initialvalue);
  868. fscanf(dependfileoutput,"%s\n",nothing);
  869. fscanf(dependfileoutput,"%lu\n", &length_v_readedlistdimension);
  870. fscanf(dependfileoutput,"%s\n",nothing);
  871. fscanf(dependfileoutput,"%lu\n", &length_a_nomvar);
  872. fscanf(dependfileoutput,"%s\n",nothing);
  873. fscanf(dependfileoutput,"%lu\n", &length_toprintglob);
  874. fscanf(dependfileoutput,"%s\n",nothing);
  875. fscanf(dependfileoutput,"%d\n", &value_char_size);
  876. fscanf(dependfileoutput,"%s\n", nothing);
  877. fscanf(dependfileoutput,"%d\n", &value_char_size1);
  878. fscanf(dependfileoutput,"%s\n", nothing);
  879. fscanf(dependfileoutput,"%d\n", &value_char_size2);
  880. fscanf(dependfileoutput,"%s\n", nothing);
  881. fscanf(dependfileoutput,"%d\n", &value_char_size3);
  882. fscanf(dependfileoutput,"%s\n",nothing);
  883. fscanf(dependfileoutput,"%lu\n", &length_tmpvargridname);
  884. fscanf(dependfileoutput,"%s\n",nothing);
  885. fscanf(dependfileoutput,"%lu\n", &length_ligne_Subloop);
  886. fscanf(dependfileoutput,"%s\n",nothing);
  887. fscanf(dependfileoutput,"%lu\n", &length_toprint_utilagrif);
  888. fscanf(dependfileoutput,"%s\n",nothing);
  889. fscanf(dependfileoutput,"%lu\n", &length_toprinttmp_utilchar);
  890. fscanf(dependfileoutput,"%s\n",nothing);
  891. fscanf(dependfileoutput,"%lu\n", &length_ligne_writedecl);
  892. fscanf(dependfileoutput,"%s\n",nothing);
  893. fscanf(dependfileoutput,"%lu\n", &length_newname_toamr);
  894. fscanf(dependfileoutput,"%s\n",nothing);
  895. fscanf(dependfileoutput,"%lu\n", &length_newname_writedecl);
  896. fscanf(dependfileoutput,"%s\n",nothing);
  897. fscanf(dependfileoutput,"%lu\n", &length_ligne_toamr);
  898. fscanf(dependfileoutput,"%s\n",nothing);
  899. fscanf(dependfileoutput,"%lu\n", &length_tmpligne_writedecl);
  900. fclose(dependfileoutput);
  901. }
  902. }