Writedeclarations.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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. /* WriteBeginDeclaration */
  41. /******************************************************************************/
  42. /* This subroutine is used to write the begin of a declaration */
  43. /* taken in a variable record */
  44. /* */
  45. /******************************************************************************/
  46. /* */
  47. /* integer variable -----------> INTEGER */
  48. /* */
  49. /******************************************************************************/
  50. void WriteBeginDeclaration(variable *v, char line[LONG_M], int visibility)
  51. {
  52. char tmpligne[LONG_M];
  53. int precision_given ;
  54. if ( !strcasecmp(v->v_typevar,"") )
  55. {
  56. printf("# WARNING : The type of the variable %s is unknown.\n", v->v_nomvar);
  57. printf("# CONV should define a type\n");
  58. }
  59. sprintf(line, "%s", v->v_typevar);
  60. if ( v->v_c_star == 1 ) strcat(line, "*");
  61. /* We should give the precision of the variable if it has been given */
  62. precision_given = 0;
  63. if ( strcasecmp(v->v_precision,"") )
  64. {
  65. sprintf(tmpligne, "(%s)", v->v_precision);
  66. Save_Length(tmpligne, 49);
  67. strcat(line, tmpligne);
  68. precision_given = 1;
  69. }
  70. if (strcasecmp(v->v_dimchar,""))
  71. {
  72. sprintf(tmpligne,"(%s)",v->v_dimchar);
  73. Save_Length(tmpligne, 49);
  74. strcat(line,tmpligne);
  75. }
  76. if ((precision_given == 0) && ( strcasecmp(v->v_nameinttypename,"") ))
  77. {
  78. sprintf(tmpligne,"*%s",v->v_nameinttypename);
  79. Save_Length(tmpligne, 49);
  80. strcat(line,tmpligne);
  81. }
  82. if (strcasecmp (v->v_IntentSpec, ""))
  83. {
  84. sprintf(tmpligne,", intent(%s)", v->v_IntentSpec);
  85. Save_Length(tmpligne, 49);
  86. strcat(line,tmpligne);
  87. }
  88. if ( v->v_VariableIsParameter ) strcat(line, ", parameter");
  89. if ( visibility )
  90. {
  91. if ( v->v_PublicDeclare ) strcat(line, ", public");
  92. if ( v->v_PrivateDeclare ) strcat(line, ", private");
  93. }
  94. if ( v->v_ExternalDeclare ) strcat(line, ", external");
  95. if ( v->v_allocatable ) strcat(line, ", allocatable");
  96. if ( v->v_target ) strcat(line, ", target");
  97. if ( v->v_optionaldeclare ) strcat(line, ", optional");
  98. if ( v->v_pointerdeclare ) strcat(line, ", pointer");
  99. Save_Length(line, 45);
  100. }
  101. /******************************************************************************/
  102. /* WriteScalarDeclaration */
  103. /******************************************************************************/
  104. /* This subroutine is used to write a scalar declaration */
  105. /* taken in a variable record */
  106. /* */
  107. /******************************************************************************/
  108. /* */
  109. /* integer variable -----------> INTEGER :: VARIABLE */
  110. /* */
  111. /******************************************************************************/
  112. void WriteScalarDeclaration( variable *v, char line[LONG_M])
  113. {
  114. strcat(line, " :: ");
  115. strcat(line, v->v_nomvar);
  116. if ( strcasecmp(v->v_vallengspec, "") ) strcat(line,v->v_vallengspec);
  117. if ( v->v_VariableIsParameter )
  118. {
  119. strcat(line," = ");
  120. strcat(line, v->v_initialvalue);
  121. }
  122. Save_Length(line, 45);
  123. }
  124. /******************************************************************************/
  125. /* WriteTableDeclaration */
  126. /******************************************************************************/
  127. /* This subroutine is used to write a Table declaration */
  128. /* taken in a variable record */
  129. /* */
  130. /******************************************************************************/
  131. /* */
  132. /* integer variable(nb) -----------> */
  133. /* INTEGER, DIMENSION(1:nb) :: variable */
  134. /* */
  135. /******************************************************************************/
  136. void WriteTableDeclaration(variable * v,char ligne[LONG_M],int tmpok)
  137. {
  138. char newname[LONG_M];
  139. strcat (ligne, ", dimension(");
  140. if ( v->v_dimensiongiven == 1 && tmpok == 1 ) strcat(ligne,v->v_readedlistdimension);
  141. if ( v->v_dimensiongiven == 1 && tmpok == 0 )
  142. {
  143. strcpy(newname,ChangeTheInitalvaluebyTabvarsName(v->v_readedlistdimension,List_Global_Var));
  144. if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension);
  145. strcpy(newname,ChangeTheInitalvaluebyTabvarsName(newname,List_Common_Var));
  146. if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension);
  147. strcpy(newname,ChangeTheInitalvaluebyTabvarsName(newname,List_ModuleUsed_Var));
  148. if ( !strcasecmp(newname,"") ) strcat(newname,v->v_readedlistdimension);
  149. Save_Length(newname,47);
  150. strcat(ligne,newname);
  151. }
  152. strcat(ligne, ") :: ");
  153. strcat(ligne, v->v_nomvar);
  154. if ( strcasecmp(vallengspec,"") ) strcat(ligne,v->v_vallengspec);
  155. if ( v->v_VariableIsParameter == 1 )
  156. {
  157. strcat(ligne," = ");
  158. strcat(ligne,v->v_initialvalue);
  159. }
  160. Save_Length(ligne,45);
  161. }
  162. /******************************************************************************/
  163. /* WriteVarDeclaration */
  164. /******************************************************************************/
  165. /* This subroutine is used to write the initial declaration in the file */
  166. /* fileout of a variable */
  167. /* */
  168. /******************************************************************************/
  169. /* */
  170. /* integer variable(nb) -----------> */
  171. /* INTEGER, DIMENSION(1:nb),Pointer :: variable */
  172. /* */
  173. /******************************************************************************/
  174. void WriteVarDeclaration( variable *v, FILE *fileout, int value, int visibility )
  175. {
  176. FILE *filecommon;
  177. char ligne[LONG_M];
  178. filecommon = fileout;
  179. if ( v->v_save == 0 || inmodulemeet == 0 )
  180. {
  181. WriteBeginDeclaration(v, ligne, visibility);
  182. if ( v->v_nbdim == 0 )
  183. WriteScalarDeclaration(v, ligne);
  184. else
  185. WriteTableDeclaration(v, ligne, value);
  186. if ( v->v_VariableIsParameter != 1 && strcasecmp(v->v_initialvalue,"") )
  187. {
  188. strcat(ligne," = ");
  189. strcat(ligne,v->v_initialvalue);
  190. }
  191. tofich(filecommon, ligne, 1);
  192. }
  193. else
  194. printf("-- in writevardeclaration : |%s| -- MHCHECK\n", v->v_nomvar);
  195. Save_Length(ligne,45);
  196. }
  197. void WriteLocalParamDeclaration(FILE* tofile)
  198. {
  199. listvar *parcours;
  200. parcours = List_Parameter_Var;
  201. while ( parcours )
  202. {
  203. if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) )
  204. {
  205. WriteVarDeclaration(parcours->var, tofile, 0, 1);
  206. }
  207. parcours = parcours -> suiv;
  208. }
  209. }
  210. void WriteFunctionDeclaration(FILE* tofile, int value)
  211. {
  212. listvar *parcours;
  213. parcours = List_FunctionType_Var;
  214. while ( parcours )
  215. {
  216. if ( !strcasecmp(parcours->var->v_subroutinename, subroutinename) &&
  217. strcasecmp(parcours->var->v_typevar, "") )
  218. {
  219. WriteVarDeclaration(parcours->var, tofile, value, 1);
  220. }
  221. parcours = parcours -> suiv;
  222. }
  223. }
  224. void WriteSubroutineDeclaration(int value)
  225. {
  226. listvar *parcours;
  227. variable *v;
  228. parcours = List_SubroutineDeclaration_Var;
  229. while ( parcours )
  230. {
  231. v = parcours->var;
  232. if ( !strcasecmp(v->v_subroutinename, subroutinename) &&
  233. (v->v_save == 0) &&
  234. (v->v_pointerdeclare == 0) &&
  235. (v->v_VariableIsParameter == 0) &&
  236. (v->v_common == 0) )
  237. {
  238. WriteVarDeclaration(v, fortran_out, value, 1);
  239. }
  240. else if ( !strcasecmp(v->v_subroutinename, subroutinename) &&
  241. (v->v_save == 0) &&
  242. (v->v_VariableIsParameter == 0) &&
  243. (v->v_common == 0) )
  244. {
  245. WriteVarDeclaration(v, fortran_out, value, 1);
  246. }
  247. parcours = parcours -> suiv;
  248. }
  249. }
  250. void WriteArgumentDeclaration_beforecall()
  251. {
  252. int position;
  253. listnom *neededparameter;
  254. FILE *paramtoamr;
  255. listvar *parcours;
  256. variable *v;
  257. char ligne[LONG_M];
  258. fprintf(fortran_out,"#include \"Param_BeforeCall_%s.h\"\n",subroutinename);
  259. sprintf(ligne,"Param_BeforeCall_%s.h",subroutinename);
  260. paramtoamr = open_for_write(ligne);
  261. neededparameter = (listnom * )NULL;
  262. position = 1;
  263. parcours = List_SubroutineArgument_Var;
  264. while ( parcours )
  265. {
  266. v = parcours->var;
  267. if ( !strcasecmp(v->v_subroutinename, subroutinename) && (v->v_positioninblock == position) )
  268. {
  269. position++;
  270. WriteVarDeclaration(v, fortran_out, 0, 1);
  271. neededparameter = writedeclarationintoamr(List_Parameter_Var, paramtoamr,
  272. v, v->v_subroutinename, neededparameter, subroutinename);
  273. parcours = List_SubroutineArgument_Var;
  274. }
  275. else parcours = parcours -> suiv;
  276. }
  277. Save_Length(ligne,45);
  278. // Write interface for 'Sub_Loop_machin' in 'Param_BeforeCall_machin.h' when outside a module
  279. if ( IsTabvarsUseInArgument_0() && (inmodulemeet == 0) && (inprogramdeclare == 0) )
  280. {
  281. fprintf(paramtoamr, " interface\n");
  282. if (isrecursive) sprintf(ligne," recursive subroutine Sub_Loop_%s(", subroutinename);
  283. else sprintf(ligne," subroutine Sub_Loop_%s(", subroutinename);
  284. WriteVariablelist_subloop(ligne);
  285. WriteVariablelist_subloop_Def(ligne);
  286. strcat(ligne,")");
  287. Save_Length(ligne,45);
  288. tofich(paramtoamr,ligne,1);
  289. listusemodule *parcours_mod;
  290. parcours_mod = List_NameOfModuleUsed;
  291. while ( parcours_mod )
  292. {
  293. if ( !strcasecmp(parcours_mod->u_cursubroutine, subroutinename) )
  294. {
  295. fprintf(paramtoamr, " use %s\n", parcours_mod->u_usemodule);
  296. }
  297. parcours_mod = parcours_mod->suiv;
  298. }
  299. fprintf(paramtoamr, " implicit none\n");
  300. WriteLocalParamDeclaration(paramtoamr);
  301. writesub_loopdeclaration_scalar(List_UsedInSubroutine_Var, paramtoamr);
  302. writesub_loopdeclaration_tab(List_UsedInSubroutine_Var, paramtoamr);
  303. WriteArgumentDeclaration_Sort(paramtoamr);
  304. WriteFunctionDeclaration(paramtoamr, 1);
  305. sprintf(ligne," end subroutine Sub_Loop_%s\n", subroutinename);
  306. tofich(paramtoamr, ligne, 1);
  307. fprintf(paramtoamr, " end interface\n");
  308. }
  309. fclose(paramtoamr);
  310. }
  311. void WriteArgumentDeclaration_Sort(FILE* tofile)
  312. {
  313. int position = 1;
  314. listvar *parcours;
  315. parcours = List_SubroutineArgument_Var;
  316. while ( parcours )
  317. {
  318. if ( !strcasecmp(parcours->var->v_subroutinename, subroutinename) &&
  319. parcours->var->v_positioninblock == position )
  320. {
  321. position = position + 1;
  322. WriteVarDeclaration(parcours->var, tofile, 1, 1);
  323. parcours = List_SubroutineArgument_Var;
  324. }
  325. else parcours = parcours -> suiv;
  326. }
  327. parcours = List_SubroutineArgument_Var;
  328. while ( parcours )
  329. {
  330. if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) &&
  331. parcours->var->v_positioninblock == 0 &&
  332. parcours->var->v_nbdim == 0 )
  333. {
  334. WriteVarDeclaration(parcours->var,tofile,1,1);
  335. }
  336. parcours = parcours -> suiv;
  337. }
  338. parcours = List_SubroutineArgument_Var;
  339. while ( parcours )
  340. {
  341. if ( !strcasecmp(parcours->var->v_subroutinename,subroutinename) &&
  342. parcours->var->v_positioninblock == 0 &&
  343. parcours->var->v_nbdim != 0 )
  344. {
  345. WriteVarDeclaration(parcours->var, tofile, 1, 1);
  346. }
  347. parcours = parcours -> suiv;
  348. }
  349. }
  350. /******************************************************************************/
  351. /* writedeclarationintoamr */
  352. /******************************************************************************/
  353. /* This subroutine is used to write the declaration of parameters needed in */
  354. /* allocation subroutines creates in toamr.c */
  355. /******************************************************************************/
  356. /* */
  357. /* */
  358. /******************************************************************************/
  359. listnom *writedeclarationintoamr (listvar * deb_common, FILE *fileout,
  360. variable *var , const char *commonname,
  361. listnom *neededparameter, const char *name_common)
  362. {
  363. listvar *newvar;
  364. variable *v;
  365. char ligne[LONG_M];
  366. int changeval;
  367. int out;
  368. int writeit;
  369. listnom *parcours;
  370. /* we should list the needed parameter */
  371. if ( !strcasecmp(name_common,commonname) )
  372. neededparameter = DecomposeTheNameinlistnom(var->v_readedlistdimension,neededparameter);
  373. /* */
  374. parcours = neededparameter;
  375. while (parcours)
  376. {
  377. newvar = deb_common;
  378. out = 0 ;
  379. while ( newvar && out == 0 )
  380. {
  381. if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) && !strcasecmp(var->v_subroutinename,newvar->var->v_subroutinename))
  382. {
  383. out=1;
  384. /* add the name to the list of needed parameter */
  385. neededparameter = DecomposeTheNameinlistnom(
  386. newvar->var->v_initialvalue,
  387. neededparameter );
  388. }
  389. else newvar=newvar->suiv;
  390. }
  391. parcours=parcours->suiv;
  392. }
  393. /* */
  394. parcours = neededparameter;
  395. while (parcours)
  396. {
  397. newvar = deb_common;
  398. out = 0 ;
  399. while ( newvar && out == 0 )
  400. {
  401. if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) && !strcasecmp(var->v_subroutinename,newvar->var->v_subroutinename))
  402. {
  403. out=1;
  404. /* add the name to the list of needed parameter */
  405. neededparameter = DecomposeTheNameinlistnom(
  406. newvar->var->v_initialvalue,
  407. neededparameter );
  408. }
  409. else newvar=newvar->suiv;
  410. }
  411. parcours=parcours->suiv;
  412. }
  413. parcours = neededparameter;
  414. while (parcours)
  415. {
  416. writeit = 0;
  417. newvar = deb_common;
  418. while ( newvar && writeit == 0 )
  419. {
  420. if ( !strcasecmp(parcours->o_nom,newvar->var->v_nomvar) &&
  421. !strcasecmp(var->v_subroutinename,newvar->var->v_subroutinename) && parcours->o_val == 0 )
  422. {
  423. writeit=1;
  424. parcours->o_val = 1;
  425. }
  426. else newvar = newvar->suiv;
  427. }
  428. if ( writeit == 1 )
  429. {
  430. changeval = 0;
  431. v = newvar->var;
  432. // if ( v->v_allocatable == 1 && strcasecmp(v->v_typevar,"type") )
  433. // {
  434. // changeval = 1;
  435. // v->v_allocatable = 0;
  436. // }
  437. WriteBeginDeclaration(v, ligne, 1);
  438. if ( v->v_nbdim == 0 ) WriteScalarDeclaration(v,ligne);
  439. else WriteTableDeclaration(v, ligne, 1);
  440. tofich(fileout, ligne, 1);
  441. if ( changeval == 1 )
  442. {
  443. v->v_allocatable = 1;
  444. }
  445. }
  446. else
  447. {
  448. if ( strncasecmp(parcours->o_nom,"mpi_",4) == 0 &&
  449. shouldincludempif == 1 )
  450. {
  451. shouldincludempif = 0;
  452. fprintf(fileout," include \'mpif.h\'\n");
  453. }
  454. }
  455. parcours=parcours->suiv;
  456. }
  457. Save_Length(ligne,45);
  458. return neededparameter;
  459. }
  460. /******************************************************************************/
  461. /* writesub_loopdeclaration_scalar */
  462. /******************************************************************************/
  463. /* This subroutine is used to write the declaration part of subloop */
  464. /* subroutines */
  465. /******************************************************************************/
  466. /* */
  467. /* integer variable(nb) -----------> */
  468. /* */
  469. /* INTEGER, DIMENSION(1:nb) :: variable */
  470. /* */
  471. /******************************************************************************/
  472. void writesub_loopdeclaration_scalar (listvar * deb_common, FILE *fileout)
  473. {
  474. listvar *newvar;
  475. variable *v;
  476. char ligne[LONG_M];
  477. // tofich (fileout, "",1);
  478. newvar = deb_common;
  479. while (newvar)
  480. {
  481. if ( newvar->var->v_nbdim == 0 &&
  482. !strcasecmp(newvar->var->v_subroutinename,subroutinename) &&
  483. (newvar->var->v_pointerdeclare == 0 || !strcasecmp(newvar->var->v_typevar,"type")) )
  484. {
  485. v = newvar->var;
  486. WriteBeginDeclaration(v,ligne,1);
  487. WriteScalarDeclaration(v,ligne);
  488. tofich (fileout, ligne,1);
  489. }
  490. newvar = newvar->suiv;
  491. }
  492. Save_Length(ligne,45);
  493. }
  494. /******************************************************************************/
  495. /* writesub_loopdeclaration_tab */
  496. /******************************************************************************/
  497. /* This subroutine is used to write the declaration part of subloop */
  498. /* subroutines */
  499. /******************************************************************************/
  500. /* */
  501. /* integer variable(nb) -----------> */
  502. /* */
  503. /* INTEGER, DIMENSION(1:nb) :: variable */
  504. /* */
  505. /******************************************************************************/
  506. void writesub_loopdeclaration_tab (listvar * deb_common, FILE *fileout)
  507. {
  508. listvar *newvar;
  509. variable *v;
  510. char ligne[LONG_M];
  511. int changeval;
  512. newvar = deb_common;
  513. while (newvar)
  514. {
  515. v = newvar->var;
  516. // printf("newvar = %s %d %s\n",newvar->var->v_nomvar,newvar->var->v_pointerdeclare,newvar->var->v_typevar);
  517. if ( (v->v_nbdim != 0) && !strcasecmp(v->v_subroutinename, subroutinename) &&
  518. (v->v_pointerdeclare == 0 || !strcasecmp(v->v_typevar,"type")) )
  519. {
  520. changeval = 0;
  521. if ( v->v_allocatable == 1)
  522. {
  523. if (strcasecmp(v->v_typevar,"type"))
  524. {
  525. // changeval = 1;
  526. // v->v_allocatable = 0;
  527. }
  528. else
  529. {
  530. changeval = 2;
  531. v->v_allocatable = 0;
  532. v->v_pointerdeclare = 1;
  533. }
  534. }
  535. WriteBeginDeclaration(v, ligne, 1);
  536. WriteTableDeclaration(v, ligne, 1);
  537. tofich (fileout, ligne,1);
  538. if ( changeval >= 1 ) v->v_allocatable = 1;
  539. if ( changeval == 2 ) v->v_pointerdeclare = 0;
  540. }
  541. newvar = newvar->suiv;
  542. }
  543. Save_Length(ligne,45);
  544. }
  545. void ReWriteDeclarationAndAddTosubroutine_01(listvar *listdecl)
  546. {
  547. listvar *parcours;
  548. variable *v;
  549. int out;
  550. if ( insubroutinedeclare )
  551. {
  552. parcours = listdecl;
  553. while ( parcours )
  554. {
  555. v = parcours->var;
  556. out = LookingForVariableInList(List_SubroutineArgument_Var, v);
  557. if (out == 0) out = VariableIsInListCommon(parcours, List_Common_Var);
  558. if (out == 0) out = LookingForVariableInList(List_Parameter_Var, v);
  559. if (out == 0) out = LookingForVariableInList(List_FunctionType_Var, v);
  560. if (out == 0) out = LookingForVariableInListGlobal(List_Global_Var, v);
  561. if (firstpass == 0 && out == 0 && VariableIsParameter == 0 && SaveDeclare == 0)
  562. {
  563. WriteVarDeclaration(v, fortran_out, 1, 1);
  564. }
  565. if (firstpass == 1)
  566. {
  567. if (VariableIsParameter == 0 && SaveDeclare == 0)
  568. {
  569. List_SubroutineDeclaration_Var = insertvar(List_SubroutineDeclaration_Var, v);
  570. }
  571. }
  572. parcours = parcours->suiv;
  573. }
  574. }
  575. }
  576. void ReWriteDataStatement_0(FILE * filout)
  577. {
  578. listvar *parcours;
  579. int out;
  580. char ligne[LONG_M];
  581. char initialvalue[LONG_M];
  582. if (insubroutinedeclare == 1)
  583. {
  584. parcours = List_Data_Var_Cur ;
  585. while (parcours)
  586. {
  587. out = VariableIsInListCommon(parcours,List_Common_Var);
  588. if (out) break;
  589. out = LookingForVariableInListGlobal(List_Global_Var,parcours->var);
  590. if (out) break;
  591. if (strncasecmp(parcours->var->v_initialvalue,"(/",2))
  592. {
  593. strcpy(initialvalue,parcours->var->v_initialvalue);
  594. }
  595. else
  596. {
  597. strncpy(initialvalue,&parcours->var->v_initialvalue[2],strlen(parcours->var->v_initialvalue)-4);
  598. strcpy(&initialvalue[strlen(parcours->var->v_initialvalue)-4],"\0");
  599. }
  600. sprintf(ligne,"data %s/%s/",parcours->var->v_nomvar,initialvalue);
  601. tofich(filout,ligne,1);
  602. parcours = parcours->suiv;
  603. }
  604. }
  605. }