UtilAgrif.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  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. /* Vartonumber */
  41. /******************************************************************************/
  42. /* This subroutine is used to know if Agrif_ is locate in the char */
  43. /* tokname */
  44. /******************************************************************************/
  45. /* */
  46. /******************************************************************************/
  47. int Vartonumber(const char *tokname)
  48. {
  49. int agrifintheword;
  50. agrifintheword = 0;
  51. if ( !strcasecmp(tokname,"Agrif_parent") ) agrifintheword = 1;
  52. else if ( !strcasecmp(tokname,"Agrif_set_type") ) agrifintheword = 1;
  53. else if ( !strcasecmp(tokname,"Agrif_set_raf") ) agrifintheword = 1;
  54. else if ( !strcasecmp(tokname,"Agrif_set_bc") ) agrifintheword = 1;
  55. else if ( !strcasecmp(tokname,"Agrif_set_bcinterp") ) agrifintheword = 1;
  56. else if ( !strcasecmp(tokname,"Agrif_Root") ) agrifintheword = 1;
  57. else if ( !strcasecmp(tokname,"Agrif_CFixed") ) agrifintheword = 1;
  58. else if ( !strcasecmp(tokname,"Agrif_Fixed") ) agrifintheword = 1;
  59. else if ( !strcasecmp(tokname,"Agrif_bc_variable") ) agrifintheword = 1;
  60. else if ( !strcasecmp(tokname,"Agrif_set_parent") ) agrifintheword = 1;
  61. else if ( !strcasecmp(tokname,"Agrif_interp_variable")) agrifintheword = 1;
  62. else if ( !strcasecmp(tokname,"Agrif_init_variable") ) agrifintheword = 1;
  63. else if ( !strcasecmp(tokname,"Agrif_update_variable")) agrifintheword = 1;
  64. else if ( !strcasecmp(tokname,"Agrif_Set_interp") ) agrifintheword = 1;
  65. else if ( !strcasecmp(tokname,"Agrif_Set_Update") ) agrifintheword = 1;
  66. else if ( !strcasecmp(tokname,"Agrif_Set_UpdateType") ) agrifintheword = 1;
  67. else if ( !strcasecmp(tokname,"Agrif_Set_restore") ) agrifintheword = 1;
  68. else if ( !strcasecmp(tokname,"Agrif_Save_Forrestore")) agrifintheword = 1;
  69. else if ( !strcasecmp(tokname,"Agrif_init_grids") ) agrifintheword = 1;
  70. else if ( !strcasecmp(tokname,"Agrif_step") ) agrifintheword = 1;
  71. /**************************************************/
  72. /* adding specific adjoint agrif subroutine names */
  73. /**************************************************/
  74. else if ( !strcasecmp(tokname,"Agrif_bc_variable_adj") ) agrifintheword = 1;
  75. else if ( !strcasecmp(tokname,"Agrif_update_variable_adj")) agrifintheword = 1;
  76. return agrifintheword;
  77. }
  78. /******************************************************************************/
  79. /* Agrif_in_Tok_NAME */
  80. /******************************************************************************/
  81. /* This subroutine is used to know if Agrif_ is locate in the char */
  82. /* tokname */
  83. /******************************************************************************/
  84. /* */
  85. /* Agrif_name --------------> Agrif_in_Tok_NAME = 1 */
  86. /* name --------------> Agrif_in_Tok_NAME = 0 */
  87. /* */
  88. /******************************************************************************/
  89. int Agrif_in_Tok_NAME(const char *tokname)
  90. {
  91. return ( strncasecmp(tokname,"Agrif_",6) == 0 );
  92. }
  93. /******************************************************************************/
  94. /* ModifyTheVariableName_0 */
  95. /******************************************************************************/
  96. /* Firstpass 0 */
  97. /******************************************************************************/
  98. /* */
  99. /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */
  100. /* */
  101. /******************************************************************************/
  102. void ModifyTheVariableName_0(const char *ident, int lengthname)
  103. {
  104. listvar *newvar;
  105. int out;
  106. if ( firstpass ) return;
  107. newvar = List_Global_Var;
  108. out = 0;
  109. while ( newvar && out == 0 )
  110. {
  111. if ( !strcasecmp(newvar->var->v_nomvar, ident) ) out = 1;
  112. else newvar = newvar->suiv;
  113. }
  114. if ( out == 0 )
  115. {
  116. newvar = List_ModuleUsed_Var;
  117. while ( newvar && out == 0 )
  118. {
  119. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  120. else newvar = newvar->suiv;
  121. }
  122. }
  123. if ( out && !strcasecmp(newvar->var->v_typevar,"type")) return;
  124. if ( out == 0 )
  125. {
  126. newvar = List_Common_Var;
  127. while ( newvar && out == 0 )
  128. {
  129. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  130. else newvar = newvar->suiv;
  131. }
  132. }
  133. if ( out == 0 )
  134. {
  135. newvar = List_ModuleUsedInModuleUsed_Var;
  136. while ( newvar && out == 0 )
  137. {
  138. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  139. else newvar = newvar->suiv;
  140. }
  141. }
  142. if ( out == 1 && strcasecmp(newvar->var->v_typevar,"type"))
  143. {
  144. // remove the variable
  145. RemoveWordCUR_0(fortran_out,lengthname);
  146. // then write the new name
  147. if ( inagrifcallargument == 1 && agrif_parentcall == 0 )
  148. fprintf(fortran_out,"%d",newvar->var->v_indicetabvars);
  149. else
  150. {
  151. if ( retour77 == 0 )
  152. fprintf(fortran_out,"Agrif_%s & \n ", tabvarsname(newvar->var));
  153. else
  154. {
  155. fprintf(fortran_out,"Agrif_%s", tabvarsname(newvar->var));
  156. fprintf(fortran_out," \n & ");
  157. }
  158. fprintf(fortran_out,"%s",vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
  159. }
  160. }
  161. else
  162. {
  163. // we should look in the List_ModuleUsed_Var
  164. if ( inagrifcallargument != 1 )
  165. {
  166. newvar = List_ModuleUsed_Var;
  167. while ( newvar && out == 0 )
  168. {
  169. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  170. else newvar = newvar->suiv;
  171. }
  172. if ( out == 1 && strcasecmp(newvar->var->v_typevar, "type"))
  173. {
  174. // remove the variable
  175. RemoveWordCUR_0(fortran_out,lengthname);
  176. // then write the new name
  177. if ( retour77 == 0 )
  178. fprintf(fortran_out,"Agrif_%s & \n ",tabvarsname(newvar->var));
  179. else
  180. {
  181. fprintf(fortran_out," \n &Agrif_%s",tabvarsname(newvar->var));
  182. }
  183. fprintf(fortran_out,"%s",vargridcurgridtabvarswithoutAgrif_Gr(newvar->var));
  184. }
  185. }
  186. }
  187. }
  188. /******************************************************************************/
  189. /* Add_SubroutineWhereAgrifUsed_1 */
  190. /******************************************************************************/
  191. /* This subroutine is used to add a record to */
  192. /* List_SubroutineWhereAgrifUsed */
  193. /******************************************************************************/
  194. /* */
  195. /* subroutine sub ... Agrif_<something> */
  196. /* */
  197. /* _______ _______ _______ _______ _______ */
  198. /* + + + + + + + + + + */
  199. /* + list +--->+ list +--->+ list +--->+ list +--->+ sub + */
  200. /* +______+ +______+ +______+ +______+ +______+ */
  201. /* */
  202. /* list = List_SubroutineWhereAgrifUsed */
  203. /* */
  204. /******************************************************************************/
  205. void Add_SubroutineWhereAgrifUsed_1(const char *sub, const char *mod)
  206. {
  207. listnom *listnomtmp;
  208. listnom *parcours;
  209. if ( firstpass == 1 )
  210. {
  211. if ( !List_SubroutineWhereAgrifUsed )
  212. {
  213. listnomtmp = (listnom*) calloc(1, sizeof(listnom));
  214. strcpy(listnomtmp->o_nom, sub);
  215. strcpy(listnomtmp->o_module, mod);
  216. listnomtmp->suiv = NULL;
  217. List_SubroutineWhereAgrifUsed = listnomtmp;
  218. }
  219. else
  220. {
  221. parcours = List_SubroutineWhereAgrifUsed;
  222. while ( parcours && strcasecmp(parcours->o_nom,sub) )
  223. {
  224. parcours = parcours->suiv;
  225. }
  226. if ( !parcours )
  227. {
  228. listnomtmp = (listnom*) calloc(1, sizeof(listnom));
  229. strcpy(listnomtmp->o_nom, sub);
  230. strcpy(listnomtmp->o_module, mod);
  231. listnomtmp->suiv = List_SubroutineWhereAgrifUsed;
  232. List_SubroutineWhereAgrifUsed = listnomtmp;
  233. }
  234. }
  235. }
  236. }
  237. /******************************************************************************/
  238. /* AddUseAgrifUtil_0 */
  239. /******************************************************************************/
  240. /* Add use Agrif_Util at the beginning of the subroutine definition */
  241. /* if it is necessary */
  242. /******************************************************************************/
  243. /* */
  244. /* subroutine sub | subroutine sub */
  245. /* | USE Agrif_Util */
  246. /* implicit none | implicit none */
  247. /* ... | ... */
  248. /* ... Agrif_<something> | ... Agrif_<something> */
  249. /* ... | ... */
  250. /* end | end */
  251. /* */
  252. /* */
  253. /******************************************************************************/
  254. void AddUseAgrifUtil_0(FILE *fileout)
  255. {
  256. listnom *parcours;
  257. if ( firstpass == 0 )
  258. {
  259. parcours = List_SubroutineWhereAgrifUsed;
  260. while ( parcours && strcasecmp(parcours->o_nom,subroutinename) )
  261. {
  262. parcours = parcours -> suiv;
  263. }
  264. if ( parcours && parcours->o_val != 0 )
  265. fprintf(fileout,"\n use Agrif_Util\n");
  266. else
  267. fprintf(fileout,"\n use Agrif_Types, only : Agrif_tabvars\n");
  268. }
  269. }
  270. void AddUseAgrifUtilBeforeCall_0(FILE *fileout)
  271. {
  272. listusemodule *parcours;
  273. int out;
  274. if ( firstpass == 0 )
  275. {
  276. parcours = List_NameOfModuleUsed;
  277. out = 0 ;
  278. while ( parcours && out == 0 )
  279. {
  280. if ( !strcasecmp(parcours->u_usemodule, "Agrif_Util") &&
  281. !strcasecmp(parcours->u_modulename, curmodulename) &&
  282. !strcasecmp(parcours->u_cursubroutine, subroutinename) )
  283. out = 1;
  284. else
  285. parcours = parcours->suiv;
  286. }
  287. if ( out == 0 )
  288. {
  289. fprintf(fileout,"\n use Agrif_Util\n");
  290. }
  291. }
  292. }
  293. /******************************************************************************/
  294. /* NotifyAgrifFunction_0 */
  295. /******************************************************************************/
  296. /* Firstpass 0 */
  297. /******************************************************************************/
  298. /* */
  299. /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */
  300. /* */
  301. /******************************************************************************/
  302. void NotifyAgrifFunction_0(const char *ident)
  303. {
  304. if ( firstpass == 1 ) return;
  305. if ( !strcasecmp(ident,"Agrif_parent") )
  306. {
  307. InAgrifParentDef = 1;
  308. pos_curagrifparent = setposcur()-12;
  309. }
  310. else if ( !strcasecmp(ident,"Agrif_Get_Coarse_grid") )
  311. {
  312. InAgrifParentDef = 2;
  313. pos_curagrifparent = setposcur()-21;
  314. }
  315. else if ( !strcasecmp(ident,"Agrif_Rhox") )
  316. {
  317. InAgrifParentDef = 3;
  318. pos_curagrifparent = setposcur()-10;
  319. }
  320. else if ( !strcasecmp(ident,"Agrif_Parent_Rhox") )
  321. {
  322. InAgrifParentDef = 4;
  323. pos_curagrifparent = setposcur()-17;
  324. }
  325. else if ( !strcasecmp(ident,"Agrif_IRhox") )
  326. {
  327. InAgrifParentDef = 5;
  328. pos_curagrifparent = setposcur()-11;
  329. }
  330. else if ( !strcasecmp(ident,"Agrif_Parent_IRhox") )
  331. {
  332. InAgrifParentDef = 6;
  333. pos_curagrifparent = setposcur()-18;
  334. }
  335. else if ( !strcasecmp(ident,"Agrif_Rhoy") )
  336. {
  337. InAgrifParentDef = 7;
  338. pos_curagrifparent = setposcur()-10;
  339. }
  340. else if ( !strcasecmp(ident,"Agrif_Parent_Rhoy") )
  341. {
  342. InAgrifParentDef = 8;
  343. pos_curagrifparent = setposcur()-17;
  344. }
  345. else if ( !strcasecmp(ident,"Agrif_IRhoy") )
  346. {
  347. InAgrifParentDef = 9;
  348. pos_curagrifparent = setposcur()-11;
  349. }
  350. else if ( !strcasecmp(ident,"Agrif_Parent_IRhoy") )
  351. {
  352. InAgrifParentDef = 10;
  353. pos_curagrifparent = setposcur()-18;
  354. }
  355. else if ( !strcasecmp(ident,"Agrif_Rhoz") )
  356. {
  357. InAgrifParentDef = 11;
  358. pos_curagrifparent = setposcur()-10;
  359. }
  360. else if ( !strcasecmp(ident,"Agrif_Parent_Rhoz") )
  361. {
  362. InAgrifParentDef = 12;
  363. pos_curagrifparent = setposcur()-17;
  364. }
  365. else if ( !strcasecmp(ident,"Agrif_IRhoz") )
  366. {
  367. InAgrifParentDef = 13;
  368. pos_curagrifparent = setposcur()-11;
  369. }
  370. else if ( !strcasecmp(ident,"Agrif_Parent_IRhoz") )
  371. {
  372. InAgrifParentDef = 14;
  373. pos_curagrifparent = setposcur()-18;
  374. }
  375. else if ( !strcasecmp(ident,"Agrif_NearCommonBorderX") )
  376. {
  377. InAgrifParentDef = 15;
  378. pos_curagrifparent = setposcur()-23;
  379. }
  380. else if ( !strcasecmp(ident,"Agrif_NearCommonBorderY") )
  381. {
  382. InAgrifParentDef = 16;
  383. pos_curagrifparent = setposcur()-23;
  384. }
  385. else if ( !strcasecmp(ident,"Agrif_NearCommonBorderZ") )
  386. {
  387. InAgrifParentDef = 17;
  388. pos_curagrifparent = setposcur()-23;
  389. }
  390. else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderX") )
  391. {
  392. InAgrifParentDef = 18;
  393. pos_curagrifparent = setposcur()-26;
  394. }
  395. else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderY") )
  396. {
  397. InAgrifParentDef = 19;
  398. pos_curagrifparent = setposcur()-26;
  399. }
  400. else if ( !strcasecmp(ident,"Agrif_DistantCommonBorderZ") )
  401. {
  402. InAgrifParentDef = 20;
  403. pos_curagrifparent = setposcur()-26;
  404. }
  405. else if ( !strcasecmp(ident,"Agrif_Get_parent_id") )
  406. {
  407. InAgrifParentDef = 21;
  408. pos_curagrifparent = setposcur()-19;
  409. }
  410. else if ( !strcasecmp(ident,"Agrif_Get_grid_id") )
  411. {
  412. InAgrifParentDef = 22;
  413. pos_curagrifparent = setposcur()-17;
  414. }
  415. else if ( !strcasecmp(ident,"Agrif_Parent_Iz") )
  416. {
  417. InAgrifParentDef = 23;
  418. pos_curagrifparent = setposcur()-15;
  419. }
  420. else if ( !strcasecmp(ident,"Agrif_Parent_Iy") )
  421. {
  422. InAgrifParentDef = 24;
  423. pos_curagrifparent = setposcur()-15;
  424. }
  425. else if ( !strcasecmp(ident,"Agrif_Parent_Ix") )
  426. {
  427. InAgrifParentDef = 25;
  428. pos_curagrifparent = setposcur()-15;
  429. }
  430. else if ( !strcasecmp(ident,"Agrif_Iz") )
  431. {
  432. InAgrifParentDef = 26;
  433. pos_curagrifparent = setposcur()-8;
  434. }
  435. else if ( !strcasecmp(ident,"Agrif_Iy") )
  436. {
  437. InAgrifParentDef = 27;
  438. pos_curagrifparent = setposcur()-8;
  439. }
  440. else if ( !strcasecmp(ident,"Agrif_Ix") )
  441. {
  442. InAgrifParentDef = 28;
  443. pos_curagrifparent = setposcur()-8;
  444. }
  445. else if ( !strcasecmp(ident,"Agrif_Nb_Fixed_Grids") )
  446. {
  447. InAgrifParentDef = 29;
  448. pos_curagrifparent = setposcur()-20;
  449. }
  450. else if ( !strcasecmp(ident,"Agrif_Nb_Fine_Grids") )
  451. {
  452. InAgrifParentDef = 29;
  453. pos_curagrifparent = setposcur()-19;
  454. }
  455. else if ( !strcasecmp(ident,"AGRIF_Nb_Step") )
  456. {
  457. InAgrifParentDef = 30;
  458. pos_curagrifparent = setposcur()-13;
  459. }
  460. }
  461. /******************************************************************************/
  462. /* ModifyTheAgrifFunction_0 */
  463. /******************************************************************************/
  464. /* Firstpass 0 */
  465. /******************************************************************************/
  466. /* */
  467. /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */
  468. /* */
  469. /******************************************************************************/
  470. void ModifyTheAgrifFunction_0(const char *ident)
  471. {
  472. if ( InAgrifParentDef != 0 )
  473. AgriffunctionModify_0(ident,InAgrifParentDef);
  474. InAgrifParentDef = 0;
  475. }
  476. /******************************************************************************/
  477. /* AgriffunctionModify_0 */
  478. /******************************************************************************/
  479. /* Firstpass 0 */
  480. /******************************************************************************/
  481. /* if whichone = 1 Agrif_parent ===> */
  482. /* */
  483. /* if whichone = 2 Agrif_Get_coarse_grid ===> */
  484. /* */
  485. /* if whichone = 3 Agrif_Rhox ===> */
  486. /* */
  487. /* if whichone = 4 Agrif_Parent_Rhox ===> */
  488. /* */
  489. /* if whichone = 5 Agrif_IRhox ===> */
  490. /* */
  491. /* if whichone = 6 Agrif_Parent_IRhox ===> */
  492. /* */
  493. /* if whichone = 7 Agrif_Rhoy ===> */
  494. /* */
  495. /* if whichone = 8 Agrif_Parent_Rhoy ===> */
  496. /* */
  497. /* if whichone = 9 Agrif_IRhoy ===> */
  498. /* */
  499. /* if whichone = 10 Agrif_Parent_IRhoy ===> */
  500. /* */
  501. /* if whichone = 11 Agrif_Rhoz ===> */
  502. /* */
  503. /* if whichone = 12 Agrif_Parent_Rhoz ===> */
  504. /* */
  505. /* if whichone = 13 Agrif_IRhoz ===> */
  506. /* */
  507. /* if whichone = 14 Agrif_Parent_IRhoz ===> */
  508. /* */
  509. /* if whichone = 15 Agrif_NearCommonBorderX ===> */
  510. /* */
  511. /* if whichone = 16 Agrif_NearCommonBorderX ===> */
  512. /* */
  513. /* if whichone = 17 Agrif_NearCommonBorderX ===> */
  514. /* */
  515. /* if whichone = 18 Agrif_DistantCommonBorderX ===> */
  516. /* */
  517. /* if whichone = 19 Agrif_DistantCommonBorderY ===> */
  518. /* */
  519. /* if whichone = 20 Agrif_DistantCommonBorderZ ===> */
  520. /* */
  521. /* if whichone = 21 Agrif_Get_parent_id ===> */
  522. /* */
  523. /* if whichone = 22 Agrif_Get_grid_id ===> */
  524. /* */
  525. /* if whichone = 23 Agrif_Parent_Iz ===> */
  526. /* */
  527. /* if whichone = 24 Agrif_Parent_Iy ===> */
  528. /* */
  529. /* if whichone = 25 Agrif_Parent_Ix ===> */
  530. /* */
  531. /* if whichone = 26 Agrif_Iz ===> */
  532. /* */
  533. /* if whichone = 27 Agrif_Iy ===> */
  534. /* */
  535. /* if whichone = 28 Agrif_Ix ===> */
  536. /* */
  537. /* if whichone = 29 Agrif_Nb_Fixed_Grids ===> */
  538. /* */
  539. /* if whichone = 29 Agrif_Nb_Fine_Grids ===> */
  540. /* */
  541. /* if whichone = 30 AGRIF_Nb_Step ===> */
  542. /* */
  543. /* */
  544. /******************************************************************************/
  545. void AgriffunctionModify_0(const char *ident,int whichone)
  546. {
  547. char toprint[LONG_M];
  548. if ( firstpass == 0 )
  549. {
  550. strcpy(toprint,"");
  551. pos_end = setposcur();
  552. fseek(fortran_out,pos_curagrifparent,SEEK_SET);
  553. if ( whichone == 1 || whichone == 2 )
  554. {
  555. FindAndChangeNameToTabvars(ident,toprint,List_Global_Var,1);
  556. if ( !strcasecmp(ident,toprint) )
  557. {
  558. /* la liste des use de cette subroutine */
  559. strcpy(toprint,"");
  560. FindAndChangeNameToTabvars(ident,toprint,List_Common_Var,whichone);
  561. }
  562. if ( !strcasecmp(ident,toprint) )
  563. {
  564. /* la liste des use de cette subroutine */
  565. strcpy(toprint,"");
  566. FindAndChangeNameToTabvars(ident,toprint,List_ModuleUsed_Var,whichone);
  567. }
  568. }
  569. else if ( whichone == 3 ) /* Agrif_Rhox */
  570. {
  571. sprintf(toprint,"REAL(");
  572. if( retour77 == 0 ) strcat(toprint," & \n");
  573. else strcat(toprint,"\n & ");
  574. strcat(toprint,"Agrif_Curgrid % spaceref(1))");
  575. }
  576. else if ( whichone == 4 ) /* Agrif_Parent_Rhox */
  577. {
  578. sprintf(toprint,"REAL(");
  579. if( retour77 == 0 ) strcat(toprint," & \n");
  580. else strcat(toprint,"\n & ");
  581. strcat(toprint,"Agrif_Curgrid % parent % spaceref(1))");
  582. }
  583. else if ( whichone == 5 ) /* Agrif_Rhox */
  584. {
  585. sprintf(toprint,"Agrif_Curgrid");
  586. if( retour77 == 0 ) strcat(toprint," & \n");
  587. else strcat(toprint,"\n & ");
  588. strcat(toprint,"% spaceref(1)");
  589. }
  590. else if ( whichone == 6 ) /* Agrif_Parent_Rhox */
  591. {
  592. sprintf(toprint,"Agrif_Curgrid");
  593. if( retour77 == 0 ) strcat(toprint," & \n");
  594. else strcat(toprint,"\n & ");
  595. strcat(toprint,"% parent % spaceref(1)");
  596. }
  597. else if ( whichone == 7 ) /* Agrif_Rhoy */
  598. {
  599. sprintf(toprint,"REAL(Agrif_Curgrid");
  600. if( retour77 == 0 ) strcat(toprint," & \n");
  601. else strcat(toprint,"\n & ");
  602. strcat(toprint,"% spaceref(2))");
  603. }
  604. else if ( whichone == 8 ) /* Agrif_Parent_Rhoy */
  605. {
  606. sprintf(toprint,"REAL(Agrif_Curgrid");
  607. if( retour77 == 0 ) strcat(toprint," & \n");
  608. else strcat(toprint,"\n & ");
  609. strcat(toprint,"% parent % spaceref(2))");
  610. }
  611. else if ( whichone == 9 ) /* Agrif_Rhoy */
  612. {
  613. sprintf(toprint,"Agrif_Curgrid");
  614. if( retour77 == 0 ) strcat(toprint," & \n");
  615. else strcat(toprint,"\n & ");
  616. strcat(toprint,"% spaceref(2)");
  617. }
  618. else if ( whichone == 10 ) /* Agrif_Parent_Rhoy */
  619. {
  620. sprintf(toprint,"Agrif_Curgrid");
  621. if( retour77 == 0 ) strcat(toprint," & \n");
  622. else strcat(toprint,"\n & ");
  623. strcat(toprint,"% parent % spaceref(2)");
  624. }
  625. else if ( whichone == 11 ) /* Agrif_Rhoz */
  626. {
  627. sprintf(toprint,"REAL(Agrif_Curgrid");
  628. if( retour77 == 0 ) strcat(toprint," & \n");
  629. else strcat(toprint,"\n & ");
  630. strcat(toprint,"% spaceref(3))");
  631. }
  632. else if ( whichone == 12 ) /* Agrif_Parent_Rhoz */
  633. {
  634. sprintf(toprint,"REAL(Agrif_Curgrid");
  635. if( retour77 == 0 ) strcat(toprint," & \n");
  636. else strcat(toprint,"\n & ");
  637. strcat(toprint,"% parent % spaceref(3))");
  638. }
  639. else if ( whichone == 13 ) /* Agrif_Rhoz */
  640. {
  641. sprintf(toprint,"Agrif_Curgrid");
  642. if( retour77 == 0 ) strcat(toprint," & \n");
  643. else strcat(toprint,"\n & ");
  644. strcat(toprint,"% spaceref(3)");
  645. }
  646. else if ( whichone == 14 ) /* Agrif_Parent_Rhoz */
  647. {
  648. sprintf(toprint,"Agrif_Curgrid");
  649. if( retour77 == 0 ) strcat(toprint," & \n");
  650. else strcat(toprint,"\n & ");
  651. strcat(toprint,"% parent % spaceref(3)");
  652. }
  653. else if ( whichone == 15 ) /* Agrif_NearCommonBorderX */
  654. {
  655. sprintf(toprint,"Agrif_Curgrid");
  656. if( retour77 == 0 ) strcat(toprint," & \n");
  657. else strcat(toprint,"\n & ");
  658. strcat(toprint,"% NearRootBorder(1)");
  659. }
  660. else if ( whichone == 16 ) /* Agrif_NearCommonBorderY */
  661. {
  662. sprintf(toprint,"Agrif_Curgrid");
  663. if( retour77 == 0 ) strcat(toprint," & \n");
  664. else strcat(toprint,"\n & ");
  665. strcat(toprint,"% NearRootBorder(2)");
  666. }
  667. else if ( whichone == 17 ) /* Agrif_NearCommonBorderZ */
  668. {
  669. sprintf(toprint,"Agrif_Curgrid");
  670. if( retour77 == 0 ) strcat(toprint," & \n");
  671. else strcat(toprint,"\n & ");
  672. strcat(toprint,"% NearRootBorder(3)");
  673. }
  674. else if ( whichone == 18 ) /* Agrif_NearCommonBorderX */
  675. {
  676. sprintf(toprint,"Agrif_Curgrid");
  677. if( retour77 == 0 ) strcat(toprint," & \n");
  678. else strcat(toprint,"\n & ");
  679. strcat(toprint,"% DistantRootBorder(1)");
  680. }
  681. else if ( whichone == 19 ) /* Agrif_NearCommonBorderY */
  682. {
  683. sprintf(toprint,"Agrif_Curgrid");
  684. if( retour77 == 0 ) strcat(toprint," & \n");
  685. else strcat(toprint,"\n & ");
  686. strcat(toprint,"% DistantRootBorder(2)");
  687. }
  688. else if ( whichone == 20 ) /* Agrif_NearCommonBorderZ */
  689. {
  690. sprintf(toprint,"Agrif_Curgrid");
  691. if( retour77 == 0 ) strcat(toprint," & \n");
  692. else strcat(toprint,"\n & ");
  693. strcat(toprint,"% DistantRootBorder(3)");
  694. }
  695. else if ( whichone == 21 ) /* Agrif_Get_parent_id */
  696. {
  697. sprintf(toprint,"Agrif_Curgrid");
  698. if( retour77 == 0 ) strcat(toprint," & \n");
  699. else strcat(toprint,"\n & ");
  700. strcat(toprint,"% parent % grid_id");
  701. }
  702. else if ( whichone == 22 ) /* Agrif_Get_grid_id */
  703. {
  704. sprintf(toprint,"Agrif_Curgrid");
  705. if( retour77 == 0 ) strcat(toprint," & \n");
  706. else strcat(toprint,"\n & ");
  707. strcat(toprint,"% grid_id");
  708. }
  709. else if ( whichone == 23 ) /* Agrif_Parent_Iz */
  710. {
  711. sprintf(toprint,"Agrif_Curgrid");
  712. if( retour77 == 0 ) strcat(toprint," & \n");
  713. else strcat(toprint,"\n & ");
  714. strcat(toprint,"% parent % ix(3)");
  715. }
  716. else if ( whichone == 24 ) /* Agrif_Parent_Iy */
  717. {
  718. sprintf(toprint,"Agrif_Curgrid");
  719. if( retour77 == 0 ) strcat(toprint," & \n");
  720. else strcat(toprint,"\n & ");
  721. strcat(toprint,"% parent % ix(2)");
  722. }
  723. else if ( whichone == 25 ) /* Agrif_Parent_Ix */
  724. {
  725. sprintf(toprint,"Agrif_Curgrid");
  726. if( retour77 == 0 ) strcat(toprint," & \n");
  727. else strcat(toprint,"\n & ");
  728. strcat(toprint,"% parent % ix(1)");
  729. }
  730. else if ( whichone == 26 ) /* Agrif_Iz */
  731. {
  732. sprintf(toprint,"Agrif_Curgrid");
  733. if( retour77 == 0 ) strcat(toprint," & \n");
  734. else strcat(toprint,"\n & ");
  735. strcat(toprint," % ix(3)");
  736. }
  737. else if ( whichone == 27 ) /* Agrif_Iy */
  738. {
  739. sprintf(toprint,"Agrif_Curgrid");
  740. if( retour77 == 0 ) strcat(toprint," & \n");
  741. else strcat(toprint,"\n & ");
  742. strcat(toprint,"% ix(2)");
  743. }
  744. else if ( whichone == 28 ) /* Agrif_Ix */
  745. {
  746. sprintf(toprint,"Agrif_Curgrid");
  747. if( retour77 == 0 ) strcat(toprint," & \n");
  748. else strcat(toprint,"\n & ");
  749. strcat(toprint,"% ix(1)");
  750. }
  751. else if ( whichone == 29 ) /* Agrif_Nb_Fixed_Grids */
  752. {
  753. sprintf(toprint,"Agrif_nbfixedgrids");
  754. }
  755. else if ( whichone == 30 ) /* AGRIF_Nb_Step */
  756. {
  757. sprintf(toprint,"Agrif_Curgrid");
  758. if( retour77 == 0 ) strcat(toprint," & \n");
  759. else strcat(toprint,"\n & ");
  760. strcat(toprint,"% ngridstep");
  761. }
  762. Save_Length(toprint,43);
  763. if ( whichone == 1 || whichone == 2 ) tofich(fortran_out,toprint,0);
  764. else fprintf(fortran_out,"%s",toprint);
  765. }
  766. }
  767. /******************************************************************************/
  768. /* Instanciation_0 */
  769. /******************************************************************************/
  770. /* Firstpass 0 */
  771. /******************************************************************************/
  772. /* */
  773. /* Agrif_<toto>(variable) ====> Agrif_<toto>(variable) */
  774. /* */
  775. /******************************************************************************/
  776. void Instanciation_0(const char *ident)
  777. {
  778. listvar *newvar;
  779. int out;
  780. if ( firstpass == 0 && sameagrifargument == 1 )
  781. {
  782. newvar = List_Global_Var;
  783. out = 0;
  784. while ( newvar && out == 0 )
  785. {
  786. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  787. else newvar = newvar->suiv;
  788. }
  789. if ( out == 0 )
  790. {
  791. newvar = List_Common_Var;
  792. while ( newvar && out == 0 )
  793. {
  794. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  795. else newvar = newvar->suiv;
  796. }
  797. }
  798. if ( out == 0 )
  799. {
  800. newvar = List_ModuleUsed_Var;
  801. while ( newvar && out == 0 )
  802. {
  803. if ( !strcasecmp(newvar->var->v_nomvar,ident) ) out = 1;
  804. else newvar = newvar->suiv;
  805. }
  806. }
  807. // if ( out == 1 )
  808. // {
  809. // /* then write the instanciation */
  810. // fprintf(fortran_out,"\n %s = %s",ident,vargridcurgridtabvars(newvar->var,3));
  811. // printf("#\n# Instanciation_0: |%s = %s|\n#\n", ident,vargridcurgridtabvars(newvar->var,3));
  812. // }
  813. }
  814. sameagrifargument = 0;
  815. }