New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
UtilAgrif.c in branches/UKMO/dev_r5518_GC3p0_package/NEMOGCM/EXTERNAL/AGRIF/LIB – NEMO

source: branches/UKMO/dev_r5518_GC3p0_package/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilAgrif.c @ 6440

Last change on this file since 6440 was 6440, checked in by dancopsey, 8 years ago

Merged in nemo_v3_6_STABLE_copy up to revision 6436.

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