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.
dependfile.c in branches/UKMO/dev_r5107_test_branch/NEMOGCM/EXTERNAL/AGRIF/LIB – NEMO

source: branches/UKMO/dev_r5107_test_branch/NEMOGCM/EXTERNAL/AGRIF/LIB/dependfile.c @ 5274

Last change on this file since 5274 was 5274, checked in by davestorkey, 9 years ago

UKMO test branch: Remove keyword updating.

File size: 50.1 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
41/******************************************************************************/
42/*            Creation and modification of .dependfile                        */
43/******************************************************************************/
44/*  .dependnbxnby            : this file contains tabvars indices of variables*/
45/*                                given in agrif.in as number of cells        */
46/*  .dependuse<module>       : this file contains all modules used in the     */
47/*                                current file                                */
48/*  .dependparameter<module> : this file contains all parmeters defined in    */
49/*                                the current file                            */
50/*  .depend<module name>     : this file contains all globals variables       */
51/*                                informations (name, dim, etc ...)           */
52/*  .dependavailable         : this file contains all tabvars indices which   */
53/*                                are not used.                               */
54/******************************************************************************/
55
56
57/******************************************************************************/
58/*                 Writethedependnbxnbyfile                                   */
59/******************************************************************************/
60/* This subroutine is used to create the .dependnbxnby                        */
61/******************************************************************************/
62/*                                                                            */
63/*                     .dependnbxnby                                          */
64/*                                                                            */
65/*                     nbmaillesX                                             */
66/*                     nbmaillesY                                             */
67/*                     nbmaillesZ                                             */
68/*                                                                            */
69/******************************************************************************/
70void Writethedependnbxnbyfile()
71{
72  FILE *dependfileoutput;
73  listvar *parcours;
74  int out;
75
76  /* We are looking for all the variable of the current filetoparse file      */
77  /*    in the List_Global_Var                                                */
78  parcours =List_Global_Var;
79  out = 0;
80  while (parcours && out == 0 )
81  {
82     if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
83     else parcours = parcours->suiv;
84  }
85  if ( out == 0 )
86  {
87     parcours =List_Common_Var;
88     while (parcours && out == 0 )
89     {
90        if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesX) ) out = 1;
91        else parcours = parcours->suiv;
92     }
93  }
94  NbMailleXDefined = 0;
95  if ( out == 1 )
96  {
97     NbMailleXDefined = 1;
98     dependfileoutput = fopen(".dependnbxnby","w");
99     fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
100     IndicenbmaillesX = parcours->var->v_indicetabvars;
101
102     if ( dimprob > 1 )
103     {
104        parcours =List_Global_Var;
105        out = 0;
106        while (parcours && out == 0 )
107        {
108           if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
109           else parcours = parcours->suiv;
110        }
111        if ( out == 0 )
112        {
113           parcours =List_Common_Var;
114           while (parcours && out == 0 )
115           {
116              if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesY) ) out = 1;
117              else parcours = parcours->suiv;
118           }
119        }
120        if ( out == 1 )
121        {
122           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
123           IndicenbmaillesY = parcours->var->v_indicetabvars;
124        }
125     }
126
127     if ( dimprob > 2 )
128     {
129        parcours =List_Global_Var;
130        out = 0;
131        while (parcours && out == 0 )
132        {
133           if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
134           else parcours = parcours->suiv;
135        }
136        if ( out == 0 )
137        {
138           parcours =List_Common_Var;
139           while (parcours && out == 0 )
140           {
141              if ( !strcasecmp(parcours->var->v_nomvar,nbmaillesZ) ) out = 1;
142              else parcours = parcours->suiv;
143           }
144        }
145        if ( out == 1 )
146        {
147           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
148           IndicenbmaillesZ = parcours->var->v_indicetabvars;
149        }
150     }
151
152     if ( out == 1 ) fclose(dependfileoutput);
153   }
154}
155
156/******************************************************************************/
157/*                 Readthedependnbxnbyfile                                    */
158/******************************************************************************/
159/* This subroutine is used to create the .dependnbxnby                        */
160/******************************************************************************/
161/*                                                                            */
162/*                     .dependnbxnby                                          */
163/*                                                                            */
164/*                     nbmaillesX                                             */
165/*                     nbmaillesY                                             */
166/*                     nbmaillesZ                                             */
167/*                                                                            */
168/******************************************************************************/
169void Readthedependnbxnbyfile()
170{
171  FILE *dependfileoutput;
172
173  if ((dependfileoutput = fopen(".dependnbxnby","r"))!=NULL)
174  {
175     fscanf(dependfileoutput,"%d\n",&IndicenbmaillesX);
176     if ( dimprob > 1 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesY);
177     if ( dimprob > 2 ) fscanf(dependfileoutput,"%d\n",&IndicenbmaillesZ);
178     fclose(dependfileoutput);
179  }
180}
181
182/******************************************************************************/
183/*                     Writethedependlistofmoduleused                         */
184/******************************************************************************/
185/* This subroutine is used to create the .dependuse<module>                   */
186/******************************************************************************/
187/*                                                                            */
188/*               .dependuse<name>                                             */
189/*                                                                            */
190/*               mod1                                                         */
191/*               mod2                                                         */
192/*                                                                            */
193/******************************************************************************/
194void Writethedependlistofmoduleused(char *NameTampon )
195{
196  FILE *dependfileoutput;
197  listusemodule *parcours;
198  char ligne[LONG_C];
199
200
201  if ( List_NameOfModuleUsed )
202  {
203     convert2lower(NameTampon);
204     sprintf(ligne,".dependuse%s",NameTampon);
205     dependfileoutput = fopen(ligne,"w");
206     /*                                                                       */
207     parcours = List_NameOfModuleUsed;
208     while (parcours)
209     {
210        if ( !strcasecmp(NameTampon,parcours->u_modulename) &&
211             !strcasecmp(parcours->u_cursubroutine,"")
212           )
213        {
214           /* We are looking for all the variable of the current              */
215           /*    filetoparse file in the List_Global_Var                      */
216           fprintf(dependfileoutput,"%s\n",parcours->u_usemodule);
217        }
218        parcours = parcours->suiv;
219     }
220     fclose(dependfileoutput);
221  }
222}
223
224/******************************************************************************/
225/*                    Readthedependlistofmoduleused                           */
226/******************************************************************************/
227/* This subroutine is used to create the .dependuse<module>                   */
228/******************************************************************************/
229/*                                                                            */
230/*               .dependuse<name>                                             */
231/*                                                                            */
232/*               mod1                                                         */
233/*               mod2                                                         */
234/*                                                                            */
235/******************************************************************************/
236void Readthedependlistofmoduleused(char *NameTampon)
237{
238  FILE *dependfileoutput;
239  listusemodule *parcours;
240  char ligne[LONG_C];
241
242  convert2lower(NameTampon);
243  sprintf(ligne,".dependuse%s",NameTampon);
244
245  tmpuselocallist = (listusemodule *)NULL;
246  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
247  {
248  }
249  else
250  {
251    /* if the file exist we should verify that this file has changed          */
252      while (!feof(dependfileoutput))
253      {
254         parcours=(listusemodule *)malloc(sizeof(listusemodule));
255         fscanf(dependfileoutput,"%s\n",parcours->u_usemodule);
256
257         parcours->suiv = tmpuselocallist;
258         tmpuselocallist = parcours;
259
260         parcours = NULL;
261      }
262      fclose(dependfileoutput);
263  }
264}
265
266
267/******************************************************************************/
268/*                        WritedependParameterList                            */
269/******************************************************************************/
270/* This subroutine is used to create the .dependparameter<name>               */
271/******************************************************************************/
272/*                                                                            */
273/*               .dependparameter<name>                                       */
274/*                                                                            */
275/*               mod1                                                         */
276/*               mod2                                                         */
277/*                                                                            */
278/******************************************************************************/
279void WritedependParameterList(char *NameTampon )
280{
281  FILE *dependfileoutput;
282  listvar *parcours;
283  char ligne[LONG_C];
284
285  if ( List_GlobalParameter_Var )
286  {
287     convert2lower(NameTampon);
288     sprintf(ligne,".dependparameter%s",NameTampon);
289     dependfileoutput = fopen(ligne,"w");
290     /*                                                                       */
291     parcours = List_GlobalParameter_Var;
292     while (parcours)
293     {
294        if ( !strcasecmp(NameTampon,parcours->var->v_modulename) )
295        {
296           fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
297           fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename);
298        }
299        parcours = parcours->suiv;
300     }
301     fclose(dependfileoutput);
302  }
303}
304
305
306/******************************************************************************/
307/*                         ReaddependParameterList                            */
308/******************************************************************************/
309/* This subroutine is used to create the .dependparameter<name>               */
310/******************************************************************************/
311/*                                                                            */
312/*               .dependparameter<name>                                       */
313/*                                                                            */
314/*               mod1                                                         */
315/*               mod2                                                         */
316/*                                                                            */
317/******************************************************************************/
318listparameter *ReaddependParameterList(char *NameTampon,listparameter *listout)
319{
320  FILE *dependfileoutput;
321  listparameter *parcours;
322  char ligne[LONG_C];
323
324  convert2lower(NameTampon);
325  sprintf(ligne,".dependparameter%s",NameTampon);
326
327  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
328  {
329  }
330  else
331  {
332    /* if the file exist we should verify that this file has changed          */
333      while (!feof(dependfileoutput))
334      {
335         parcours=(listparameter *)malloc(sizeof(listparameter));
336         fscanf(dependfileoutput,"%s\n",parcours->p_name);
337         fscanf(dependfileoutput,"%s\n",parcours->p_modulename);
338
339         parcours->suiv = listout;
340         listout = parcours;
341
342         parcours = NULL;
343      }
344      fclose(dependfileoutput);
345  }
346  return listout;
347}
348
349/******************************************************************************/
350/*                   Writethedependfile                                       */
351/******************************************************************************/
352/* This subroutine is used to create the .depend<name>                        */
353/******************************************************************************/
354/*                                                                            */
355/*                     .depend<name>                                          */
356/*                                                                            */
357/*                      REAL                                                  */
358/*                      Variable                                              */
359/*                      char dimension or T                                   */
360/*                      table dimension                                       */
361/*                      is type given                                         */
362/*                      precision or T                                        */
363/*                      initial value or T                                    */
364/*                      indice in the tabvars                                 */
365/*                      listdimension or T                                    */
366/*                      -------------------------                             */
367/*                                                                            */
368/******************************************************************************/
369void Writethedependfile(char *NameTampon, listvar *input )
370{
371  FILE *dependfileoutput;
372  listvar *parcours;
373  listdim *dims;
374  char ligne[LONG_C];
375  char listdimension[LONG_C];
376  char curname[LONG_C];
377  int out;
378
379  if ( input )
380  {
381  convert2lower(NameTampon);
382
383  sprintf(ligne,".depend%s",NameTampon);
384  dependfileoutput = fopen(ligne,"w");
385  /* We are looking for all the variable of the current filetoparse file      */
386  /*    in the input                                                          */
387  parcours =input;
388  out = 0;
389  strcpy(curname,"");
390  while (parcours && out == 0 )
391  {
392     if ( !strcasecmp(parcours->var->v_modulename,NameTampon) ||
393          !strcasecmp(parcours->var->v_commonname,NameTampon) )
394     {
395        /*                                                                    */
396        if (  strcasecmp(curname,"") &&
397             !strcasecmp(curname,parcours->var->v_nomvar) ) out = 1 ;
398        if ( !strcasecmp(curname,"") ) strcpy(curname,parcours->var->v_nomvar);
399        /*                                                                    */
400        if ( out == 0 )
401        {
402           /********** TYPEVAR ************************************************/
403           fprintf(dependfileoutput,"%s\n",parcours->var->v_typevar);
404           /********** NOMVAR *************************************************/
405           fprintf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
406           /********** DIMCHAR ************************************************/
407           if ( strcasecmp(parcours->var->v_dimchar,"") )
408           {
409              fprintf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
410           }
411           else
412           {
413              fprintf(dependfileoutput,"T\n");
414           }
415           /********** COMMONINFILE *******************************************/
416           if ( strcasecmp(parcours->var->v_commoninfile,"") )
417           {
418              fprintf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
419           }
420           else
421           {
422              fprintf(dependfileoutput,"T\n");
423           }
424           /********** COMMONNAME *********************************************/
425           if ( strcasecmp(parcours->var->v_commonname,"") )
426           {
427              fprintf(dependfileoutput,"%s\n",parcours->var->v_commonname);
428           }
429           else
430           {
431              fprintf(dependfileoutput,"T\n");
432           }
433           /********** MODULENAME *********************************************/
434           if ( strcasecmp(parcours->var->v_modulename,"") )
435           {
436              fprintf(dependfileoutput,"%s\n",parcours->var->v_modulename);
437           }
438           else
439           {
440              fprintf(dependfileoutput,"T\n");
441           }
442           /********** NBDIM **************************************************/
443/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_nbdim);*/
444           /********** DIMENSIONGIVEN *****************************************/
445/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_dimensiongiven);*/
446           /********** ALLOCATABLE ********************************************/
447           fprintf(dependfileoutput,"%d\n",parcours->var->v_allocatable);
448           /********** TARGET ********************************************/
449           fprintf(dependfileoutput,"%d\n",parcours->var->v_target);
450           /********** POINTERDECLARE *****************************************/
451           fprintf(dependfileoutput,"%d\n",parcours->var->v_pointerdeclare);
452           /********** PRECISION **********************************************/
453           if ( strcasecmp(parcours->var->v_precision,"") )
454           {
455              fprintf(dependfileoutput,"%s\n",parcours->var->v_precision);
456           }
457           else
458           {
459              fprintf(dependfileoutput,"T\n");
460           }
461           /********** INITIALVALUE *******************************************/
462/*           if ( strcasecmp(parcours->var->v_initialvalue,"") )
463           {
464              fprintf(dependfileoutput,"%s\n",parcours->var->v_initialvalue);
465           }
466           else
467           {
468              fprintf(dependfileoutput,"T\n");
469           }*/
470           /********** NAMEINTYPENAME *****************************************/
471           if ( strcasecmp(parcours->var->v_nameinttypename,"") )
472           {
473              fprintf(dependfileoutput,"%s\n",parcours->var->v_nameinttypename);
474           }
475           else
476           {
477              fprintf(dependfileoutput,"T\n");
478           }
479           /********** PRIVATE *****************************************/
480           fprintf(dependfileoutput,"%d\n",parcours->var->v_PrivateDeclare);
481             
482           /********** INDICETABVARS ******************************************/
483           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
484           /********** READEDLISTDIMENSION ************************************/
485           if ( parcours->var->v_dimensiongiven == 1 )
486           {
487              dims = parcours->var->v_dimension;
488              strcpy(listdimension,"");
489              while (dims)
490              {
491                 sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
492                 strcat(listdimension,ligne);
493                 if ( dims->suiv )
494                 {
495                    strcat(listdimension,",");
496                 }
497                 dims = dims->suiv;
498              }
499              fprintf(dependfileoutput,"%s\n",listdimension);
500           }
501           else
502           {
503              fprintf(dependfileoutput,"T\n");
504           }
505           /*******************************************************************/
506           fprintf(dependfileoutput,"------------------------\n");
507        }
508     }
509     parcours = parcours->suiv;
510  }
511  fclose(dependfileoutput);
512  }
513}
514
515/******************************************************************************/
516/*                         Readthedependfile                                  */
517/******************************************************************************/
518/* This subroutine is used to read the .dependfile<name> and to insert new    */
519/*    information in the listout list.                                        */
520/******************************************************************************/
521/*                                                                            */
522/*           .dependmodule -------->                      = list of var       */
523/*                                                                            */
524/*        not.dependmodule -------->                                          */
525/*                                                                            */
526/******************************************************************************/
527listvar *Readthedependfile( char *NameTampon , listvar *listout)
528{
529  char ligne[LONG_C];
530  FILE *dependfileoutput;
531  listvar *parcours0;
532  listvar *parcours;
533  listvar *parcoursprec;
534  char nothing[LONG_C];
535  int i;
536
537  parcoursprec = (listvar *)NULL;
538
539  convert2lower(NameTampon);
540  sprintf(ligne,".depend%s",NameTampon);
541  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
542  {
543    /* if the file doesn't exist it means that it is the first time           */
544    /*    we tried to parse this file                                         */
545  }
546  else
547  {
548    /* if the file exist we should verify that this file has changed          */
549      while (!feof(dependfileoutput))
550      {
551         parcours=(listvar *)malloc(sizeof(listvar));
552         parcours->var=(variable *)malloc(sizeof(variable));
553         /*                                                                   */
554         Init_Variable(parcours->var);
555         /*                                                                   */
556           /********** TYPEVAR ************************************************/
557         fscanf(dependfileoutput,"%s\n",parcours->var->v_typevar);
558           /********** NOMVAR *************************************************/
559         fscanf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
560           /********** DIMCHAR ************************************************/
561         fscanf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
562         if ( !strcasecmp(parcours->var->v_dimchar,"T") )
563         {
564            strcpy(parcours->var->v_dimchar,"");
565         }
566           /********** COMMONINFILE *******************************************/
567         fscanf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
568         if ( !strcasecmp(parcours->var->v_commoninfile,"T") )
569         {
570            strcpy(parcours->var->v_commoninfile,"");
571         }
572           /********** COMMONNAME *********************************************/
573         fscanf(dependfileoutput,"%s\n",parcours->var->v_commonname);
574         if ( !strcasecmp(parcours->var->v_commonname,"T") )
575         {
576            strcpy(parcours->var->v_commonname,"");
577         }
578           /********** MODULENAME *********************************************/
579         fscanf(dependfileoutput,"%s\n",parcours->var->v_modulename);
580         
581         printf("MODULENAME = %s %s\n",parcours->var->v_nomvar,parcours->var->v_modulename);
582         
583         if ( !strcasecmp(parcours->var->v_modulename,"T") )
584         {
585            strcpy(parcours->var->v_modulename,"");
586         }
587         
588
589           /********** NBDIM **************************************************/
590/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_nbdim);*/
591           /********** DIMENSIONGIVEN *****************************************/
592/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_dimensiongiven);*/
593           /********** ALLOCATABLE ********************************************/
594         fscanf(dependfileoutput,"%d\n",&parcours->var->v_allocatable);
595         if ( parcours->var->v_allocatable == 1 )
596         {
597            Add_Allocate_Var_1(parcours->var->v_nomvar,
598                               parcours->var->v_commonname);
599         }
600           /********** TARGET ********************************************/
601         fscanf(dependfileoutput,"%d\n",&parcours->var->v_target);
602         
603           /********** POINTERDECLARE *****************************************/
604         fscanf(dependfileoutput,"%d\n",&parcours->var->v_pointerdeclare);
605         if ( parcours->var->v_pointerdeclare == 1 )
606         {
607            Add_Pointer_Var_1(parcours->var->v_nomvar);
608         }
609           /********** PRECISION **********************************************/
610         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_precision);
611         if ( !strcasecmp(parcours->var->v_precision,"T") )
612         {
613            strcpy(parcours->var->v_precision,"");
614         }
615           /********** INITIALVALUE *******************************************/
616/*         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_initialvalue);
617         if ( !strcasecmp(parcours->var->v_initialvalue,"T") )
618         {
619            strcpy(parcours->var->v_initialvalue,"");
620         }*/
621           /********** NAMEINTYPENAME *****************************************/
622         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_nameinttypename);
623         if ( !strcasecmp(parcours->var->v_nameinttypename,"T") )
624         {
625            strcpy(parcours->var->v_nameinttypename,"");
626         }
627           /********** PRIVATE *****************************************/
628         fscanf(dependfileoutput,"%d\n",&parcours->var->v_PrivateDeclare);
629         
630           /********** INDICETABVARS ******************************************/
631         fscanf(dependfileoutput,"%d\n",&parcours->var->v_indicetabvars);
632           /********** READEDLISTDIMENSION ************************************/
633         fscanf(dependfileoutput,"%s\n",parcours->var->v_readedlistdimension);
634         if ( !strcasecmp(parcours->var->v_readedlistdimension,"T") )
635         {
636            strcpy(parcours->var->v_readedlistdimension,"");
637         }
638         else
639         {
640            parcours->var->v_dimensiongiven = 1;
641            parcours->var->v_nbdim = 1;
642            i = 1;
643            /*                                                                */
644            while ( i < strlen(parcours->var->v_readedlistdimension) )
645            {
646               if ( parcours->var->v_readedlistdimension[i] == ',' )
647               {
648                  parcours->var->v_nbdim = parcours->var->v_nbdim + 1 ;
649               }
650               /*                                                             */
651               i=i+1;
652            }
653         }
654           /*******************************************************************/
655         fscanf(dependfileoutput,"%s\n",nothing);
656         parcours->suiv = NULL;
657         if (parcours->var->v_PrivateDeclare == 0)
658         {
659         if ( !listout )
660         {
661            listout = parcours;
662            parcoursprec = parcours;
663         }
664         else
665         {
666            if ( parcoursprec )
667            {
668               parcoursprec->suiv = parcours;
669               parcoursprec = parcours;
670            }
671            else
672            {
673               parcours0 = listout;
674               while ( parcours0->suiv ) parcours0=parcours0->suiv;
675               parcours0->suiv = parcours;
676               parcoursprec = parcours0->suiv;
677            }
678         }
679         }
680         parcours = NULL;
681      }
682      fclose(dependfileoutput);
683  }
684  return listout;
685}
686
687void Write_Subroutine_For_Alloc()
688{
689   FILE *dependfileoutput;
690   listnom *parcours;
691
692   if ( List_Subroutine_For_Alloc )
693   {
694      if ((dependfileoutput=fopen(".dependAllocAgrif","w"))!=NULL)
695      {
696         parcours = List_Subroutine_For_Alloc;
697         while (parcours)
698         {
699            fprintf(dependfileoutput,"%s\n",parcours->o_nom);
700            parcours = parcours->suiv;
701         }
702         fclose(dependfileoutput);
703      }
704   }
705}
706
707void Read_Subroutine_For_Alloc()
708{
709  FILE *dependfileoutput;
710  listnom *parcours;
711  listnom *ref;
712
713  ref = (listnom *)NULL;
714  if ((dependfileoutput=fopen(".dependAllocAgrif","r"))!=NULL)
715  {
716     List_Subroutine_For_Alloc = (listnom *)NULL;
717     while (!feof(dependfileoutput))
718     {
719        parcours=(listnom *)malloc(sizeof(listnom));
720        strcpy(parcours->o_nom,"");
721
722        fscanf(dependfileoutput,"%s\n",&parcours->o_nom);
723        parcours->suiv = NULL;
724
725        if ( !List_Subroutine_For_Alloc )
726        {
727           List_Subroutine_For_Alloc = parcours;
728           ref = parcours;
729        }
730        else
731        {
732            ref->suiv = parcours;
733            ref = parcours;
734        }
735     }
736     fclose(dependfileoutput);
737  }
738}
739
740/******************************************************************************/
741/*                        Writethedependavailablefile                         */
742/******************************************************************************/
743/* This subroutine is used to write the .dependfileavailable file             */
744/******************************************************************************/
745/*                                                                            */
746/*                                  .dependavailable                          */
747/*     tabvars(1) = var1                                                      */
748/*     tabvars(3) = var1                  2                                   */
749/*     tabvars(4) = var1         =====>   5                                   */
750/*     tabvars(6) = var1                                                      */
751/*     tabvars(7) = var1                                                      */
752/*                                                                            */
753/*                                                                            */
754/*                                                                            */
755/******************************************************************************/
756void Writethedependavailablefile()
757{
758  FILE *dependfileoutput;
759  listindice *parcours;
760
761  if ((dependfileoutput=fopen(".dependavailable","w"))!=NULL)
762  {
763     /* We are looking for all the indices of the Listofavailableindices      */
764     parcours = Listofavailableindices;
765     while (parcours)
766     {
767        if ( parcours->i_indice != 0 )
768        {
769           fprintf(dependfileoutput,"%d\n",parcours->i_indice);
770        }
771        parcours = parcours->suiv;
772     }
773     fclose(dependfileoutput);
774  }
775}
776
777/******************************************************************************/
778/*                        Readthedependavailablefile                          */
779/******************************************************************************/
780/* This subroutine is used to read the .dependfileavailable file              */
781/******************************************************************************/
782/*                                                                            */
783/*                                  .dependavailable                          */
784/*     tabvars(1) = var1                                                      */
785/*     tabvars(3) = var1                  2                                   */
786/*     tabvars(4) = var1         =====>   5  ==> Listofavailableindices       */
787/*     tabvars(6) = var1                                                      */
788/*     tabvars(7) = var1                                                      */
789/*                                                                            */
790/*                                                                            */
791/*                                                                            */
792/******************************************************************************/
793void Readthedependavailablefile()
794{
795  FILE *dependfileoutput;
796  listindice *parcours;
797
798  if ((dependfileoutput=fopen(".dependavailable","r"))!=NULL)
799  {
800     /* We are looking for all the indices of the Listofavailableindices      */
801     Listofavailableindices = (listindice *)NULL;
802     while (!feof(dependfileoutput))
803     {
804        parcours=(listindice *)malloc(sizeof(listindice));
805        fscanf(dependfileoutput,"%d\n",&parcours->i_indice);
806        if ( parcours->i_indice != 0 && parcours->i_indice < 10000000 )
807        {
808           parcours -> suiv = Listofavailableindices;
809           Listofavailableindices = parcours;
810        }
811        else
812        {
813           free(parcours);
814        }
815     }
816     fclose(dependfileoutput);
817  }
818}
819
820
821/******************************************************************************/
822/*                      Did_filetoparse_readed                                */
823/******************************************************************************/
824/* This subroutine is used to know if the .depend<NameTampon> exist           */
825/*    it means if the file has been ever parsed                               */
826/******************************************************************************/
827/*                                                                            */
828/******************************************************************************/
829int Did_filetoparse_readed(char *NameTampon)
830{
831  FILE *dependfileoutput;
832  char ligne[LONG_C];
833  int out;
834
835  convert2lower(NameTampon);
836  sprintf(ligne,".depend%s",NameTampon);
837  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
838  {
839      out = 0;
840  }
841  else
842  {
843      out = 1;
844      fclose(dependfileoutput);
845  }
846  return out;
847}
848
849
850/******************************************************************************/
851/*                      Did_module_common_treaded                             */
852/******************************************************************************/
853/* This subroutine is used to know if the .depend<NameTampon> exist           */
854/*    it means if the file has been ever parsed                               */
855/******************************************************************************/
856/*                                                                            */
857/******************************************************************************/
858int Did_module_common_treaded(char *NameTampon)
859{
860  FILE *dependfileoutput;
861  char ligne[LONG_C];
862  int out;
863
864  convert2lower(NameTampon);
865  sprintf(ligne,".depend%s",NameTampon);
866  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
867  {
868      out = 0;
869  }
870  else
871  {
872      out = 1;
873      fclose(dependfileoutput);
874  }
875  return out;
876}
877
878
879
880void Write_val_max()
881{
882  FILE *dependfileoutput;
883
884  if ((dependfileoutput=fopen(".dependvalmax","w"))!=NULL)
885  {
886     fprintf(dependfileoutput,"length_last\n");
887     fprintf(dependfileoutput,"%d\n",length_last);
888     fprintf(dependfileoutput,"length_first\n");
889     fprintf(dependfileoutput,"%d\n",length_first);
890     fprintf(dependfileoutput,"length_v_typevar\n");
891     fprintf(dependfileoutput,"%d\n",length_v_typevar);
892     fprintf(dependfileoutput,"length_v_nomvar\n");
893     fprintf(dependfileoutput,"%d\n",length_v_nomvar);
894     fprintf(dependfileoutput,"length_v_dimchar\n");
895     fprintf(dependfileoutput,"%d\n",length_v_dimchar);
896     fprintf(dependfileoutput,"length_v_modulename\n");
897     fprintf(dependfileoutput,"%d\n",length_v_modulename);
898     fprintf(dependfileoutput,"length_v_commonname\n");
899     fprintf(dependfileoutput,"%d\n",length_v_commonname);
900     fprintf(dependfileoutput,"length_v_vallengspec\n");
901     fprintf(dependfileoutput,"%d\n",length_v_vallengspec);
902     fprintf(dependfileoutput,"length_v_nameinttypename\n");
903     fprintf(dependfileoutput,"%d\n",length_v_nameinttypename);
904     fprintf(dependfileoutput,"length_v_commoninfile\n");
905     fprintf(dependfileoutput,"%d\n",length_v_commoninfile);
906     fprintf(dependfileoutput,"length_v_subroutinename\n");
907     fprintf(dependfileoutput,"%d\n",length_v_subroutinename);
908     fprintf(dependfileoutput,"length_v_precision\n");
909     fprintf(dependfileoutput,"%d\n",length_v_precision);
910     fprintf(dependfileoutput,"length_v_IntentSpec\n");
911     fprintf(dependfileoutput,"%d\n",length_v_IntentSpec);
912     fprintf(dependfileoutput,"length_v_initialvalue\n");
913     fprintf(dependfileoutput,"%d\n",length_v_initialvalue);
914     fprintf(dependfileoutput,"length_v_readedlistdimension\n");
915     fprintf(dependfileoutput,"%d\n",length_v_readedlistdimension);
916     fprintf(dependfileoutput,"length_u_usemodule\n");
917     fprintf(dependfileoutput,"%d\n",length_u_usemodule);
918     fprintf(dependfileoutput,"length_u_charusemodule\n");
919     fprintf(dependfileoutput,"%d\n",length_u_charusemodule);
920     fprintf(dependfileoutput,"length_u_cursubroutine\n");
921     fprintf(dependfileoutput,"%d\n",length_u_cursubroutine);
922     fprintf(dependfileoutput,"length_u_modulename\n");
923     fprintf(dependfileoutput,"%d\n",length_u_modulename);
924     fprintf(dependfileoutput,"length_n_name\n");
925     fprintf(dependfileoutput,"%d\n",length_n_name);
926     fprintf(dependfileoutput,"length_c_namevar\n");
927     fprintf(dependfileoutput,"%d\n",length_c_namevar);
928     fprintf(dependfileoutput,"length_c_namepointedvar\n");
929     fprintf(dependfileoutput,"%d\n",length_c_namepointedvar);
930     fprintf(dependfileoutput,"length_o_nom\n");
931     fprintf(dependfileoutput,"%d\n",length_o_nom);
932     fprintf(dependfileoutput,"length_o_module\n");
933     fprintf(dependfileoutput,"%d\n",length_o_module);
934     fprintf(dependfileoutput,"length_a_nomvar\n");
935     fprintf(dependfileoutput,"%d\n",length_a_nomvar);
936     fprintf(dependfileoutput,"length_a_subroutine\n");
937     fprintf(dependfileoutput,"%d\n",length_a_subroutine);
938     fprintf(dependfileoutput,"length_a_module\n");
939     fprintf(dependfileoutput,"%d\n",length_a_module);
940     fprintf(dependfileoutput,"length_usemodule\n");
941     fprintf(dependfileoutput,"%d\n",length_t_usemodule);
942     fprintf(dependfileoutput,"length_cursubroutine\n");
943     fprintf(dependfileoutput,"%d\n",length_t_cursubroutine);
944     fprintf(dependfileoutput,"length_curfilename\n");
945     fprintf(dependfileoutput,"%d\n",length_curfilename);
946     fprintf(dependfileoutput,"length_nomfileoutput\n");
947     fprintf(dependfileoutput,"%d\n",length_nomfileoutput);
948     fprintf(dependfileoutput,"length_motparse\n");
949     fprintf(dependfileoutput,"%d\n",length_motparse);
950     fprintf(dependfileoutput,"length_mainfile\n");
951     fprintf(dependfileoutput,"%d\n",length_mainfile);
952     fprintf(dependfileoutput,"length_nomdir\n");
953     fprintf(dependfileoutput,"%d\n",length_nomdir);
954     fprintf(dependfileoutput,"length_commondirout\n");
955     fprintf(dependfileoutput,"%d\n",length_commondirout);
956     fprintf(dependfileoutput,"length_commondirin\n");
957     fprintf(dependfileoutput,"%d\n",length_commondirin);
958     fprintf(dependfileoutput,"length_filetoparse\n");
959     fprintf(dependfileoutput,"%d\n",length_filetoparse);
960     fprintf(dependfileoutput,"length_curbuf\n");
961     fprintf(dependfileoutput,"%d\n",length_curbuf);
962     fprintf(dependfileoutput,"length_toprintglob\n");
963     fprintf(dependfileoutput,"%d\n",length_toprintglob);
964     fprintf(dependfileoutput,"Size_char0d\n");
965     fprintf(dependfileoutput,"%d\n",value_char_size);
966     fprintf(dependfileoutput,"Size_char1d\n");
967     fprintf(dependfileoutput,"%d\n",value_char_size1);
968     fprintf(dependfileoutput,"Size_char2d\n");
969     fprintf(dependfileoutput,"%d\n",value_char_size2);
970     fprintf(dependfileoutput,"Size_char3d\n");
971     fprintf(dependfileoutput,"%d\n",value_char_size3);
972     fprintf(dependfileoutput,"length_tmpvargridname\n");
973     fprintf(dependfileoutput,"%d\n",length_tmpvargridname);
974     fprintf(dependfileoutput,"length_ligne_Subloop\n");
975     fprintf(dependfileoutput,"%d\n",length_ligne_Subloop);
976     fprintf(dependfileoutput,"length_lvargridname_toamr\n");
977     fprintf(dependfileoutput,"%d\n",length_lvargridname_toamr);
978     fprintf(dependfileoutput,"length_toprint_toamr\n");
979     fprintf(dependfileoutput,"%d\n",length_toprint_utilagrif);
980     fprintf(dependfileoutput,"length_toprinttmp_utilchar\n");
981     fprintf(dependfileoutput,"%d\n",length_toprinttmp_utilchar);
982     fprintf(dependfileoutput,"length_ligne_writedecl\n");
983     fprintf(dependfileoutput,"%d\n",length_ligne_writedecl);
984     fprintf(dependfileoutput,"length_newname_toamr\n");
985     fprintf(dependfileoutput,"%d\n",length_newname_toamr);
986     fprintf(dependfileoutput,"length_newname_writedecl\n");
987     fprintf(dependfileoutput,"%d\n",length_newname_writedecl);
988     fprintf(dependfileoutput,"length_ligne_toamr\n");
989     fprintf(dependfileoutput,"%d\n",length_ligne_toamr);
990     fprintf(dependfileoutput,"length_tmpligne_writedecl\n");
991     fprintf(dependfileoutput,"%d\n",length_tmpligne_writedecl);
992/*     fprintf(dependfileoutput,"\n");
993     fprintf(dependfileoutput,"%d\n",);
994     fprintf(dependfileoutput,"\n");
995     fprintf(dependfileoutput,"%d\n",);
996     fprintf(dependfileoutput,"\n");
997     fprintf(dependfileoutput,"%d\n",);
998     fprintf(dependfileoutput,"\n");
999     fprintf(dependfileoutput,"%d\n",);
1000     fprintf(dependfileoutput,"\n");
1001     fprintf(dependfileoutput,"%d\n",);
1002     fprintf(dependfileoutput,"\n");
1003     fprintf(dependfileoutput,"%d\n",);
1004     fprintf(dependfileoutput,"\n");
1005     fprintf(dependfileoutput,"%d\n",);
1006     fprintf(dependfileoutput,"\n");
1007     fprintf(dependfileoutput,"%d\n",);
1008     fprintf(dependfileoutput,"\n");
1009     fprintf(dependfileoutput,"%d\n",);*/
1010
1011     fclose(dependfileoutput);
1012  }
1013}
1014
1015
1016void Read_val_max()
1017{
1018  char nothing[LONG_C];
1019  FILE *dependfileoutput;
1020
1021  if ((dependfileoutput=fopen(".dependvalmax","r"))!=NULL)
1022  {
1023     fscanf(dependfileoutput,"%s\n",nothing);
1024     fscanf(dependfileoutput,"%d\n",&length_last);
1025     fscanf(dependfileoutput,"%s\n",nothing);
1026     fscanf(dependfileoutput,"%d\n",&length_first);
1027     fscanf(dependfileoutput,"%s\n",nothing);
1028     fscanf(dependfileoutput,"%d\n",&length_v_typevar);
1029     fscanf(dependfileoutput,"%s\n",nothing);
1030     fscanf(dependfileoutput,"%d\n",&length_v_nomvar);
1031     fscanf(dependfileoutput,"%s\n",nothing);
1032     fscanf(dependfileoutput,"%d\n",&length_v_dimchar);
1033     fscanf(dependfileoutput,"%s\n",nothing);
1034     fscanf(dependfileoutput,"%d\n",&length_v_modulename);
1035     fscanf(dependfileoutput,"%s\n",nothing);
1036     fscanf(dependfileoutput,"%d\n",&length_v_commonname);
1037     fscanf(dependfileoutput,"%s\n",nothing);
1038     fscanf(dependfileoutput,"%d\n",&length_v_vallengspec);
1039     fscanf(dependfileoutput,"%s\n",nothing);
1040     fscanf(dependfileoutput,"%d\n",&length_v_nameinttypename);
1041     fscanf(dependfileoutput,"%s\n",nothing);
1042     fscanf(dependfileoutput,"%d\n",&length_v_commoninfile);
1043     fscanf(dependfileoutput,"%s\n",nothing);
1044     fscanf(dependfileoutput,"%d\n",&length_v_subroutinename);
1045     fscanf(dependfileoutput,"%s\n",nothing);
1046     fscanf(dependfileoutput,"%d\n",&length_v_precision);
1047     fscanf(dependfileoutput,"%s\n",nothing);
1048     fscanf(dependfileoutput,"%d\n",&length_v_IntentSpec);
1049     fscanf(dependfileoutput,"%s\n",nothing);
1050     fscanf(dependfileoutput,"%d\n",&length_v_initialvalue);
1051     fscanf(dependfileoutput,"%s\n",nothing);
1052     fscanf(dependfileoutput,"%d\n",&length_v_readedlistdimension);
1053     fscanf(dependfileoutput,"%s\n",nothing);
1054     fscanf(dependfileoutput,"%d\n",&length_u_usemodule);
1055     fscanf(dependfileoutput,"%s\n",nothing);
1056     fscanf(dependfileoutput,"%d\n",&length_u_charusemodule);
1057     fscanf(dependfileoutput,"%s\n",nothing);
1058     fscanf(dependfileoutput,"%d\n",&length_u_cursubroutine);
1059     fscanf(dependfileoutput,"%s\n",nothing);
1060     fscanf(dependfileoutput,"%d\n",&length_u_modulename);
1061     fscanf(dependfileoutput,"%s\n",nothing);
1062     fscanf(dependfileoutput,"%d\n",&length_n_name);
1063     fscanf(dependfileoutput,"%s\n",nothing);
1064     fscanf(dependfileoutput,"%d\n",&length_c_namevar);
1065     fscanf(dependfileoutput,"%s\n",nothing);
1066     fscanf(dependfileoutput,"%d\n",&length_c_namepointedvar);
1067     fscanf(dependfileoutput,"%s\n",nothing);
1068     fscanf(dependfileoutput,"%d\n",&length_o_nom);
1069     fscanf(dependfileoutput,"%s\n",nothing);
1070     fscanf(dependfileoutput,"%d\n",&length_o_module);
1071     fscanf(dependfileoutput,"%s\n",nothing);
1072     fscanf(dependfileoutput,"%d\n",&length_a_nomvar);
1073     fscanf(dependfileoutput,"%s\n",nothing);
1074     fscanf(dependfileoutput,"%d\n",&length_a_subroutine);
1075     fscanf(dependfileoutput,"%s\n",nothing);
1076     fscanf(dependfileoutput,"%d\n",&length_a_module);
1077     fscanf(dependfileoutput,"%s\n",nothing);
1078     fscanf(dependfileoutput,"%d\n",&length_t_usemodule);
1079     fscanf(dependfileoutput,"%s\n",nothing);
1080     fscanf(dependfileoutput,"%d\n",&length_t_cursubroutine);
1081     fscanf(dependfileoutput,"%s\n",nothing);
1082     fscanf(dependfileoutput,"%d\n",&length_curfilename);
1083     fscanf(dependfileoutput,"%s\n",nothing);
1084     fscanf(dependfileoutput,"%d\n",&length_nomfileoutput);
1085     fscanf(dependfileoutput,"%s\n",nothing);
1086     fscanf(dependfileoutput,"%d\n",&length_motparse);
1087     fscanf(dependfileoutput,"%s\n",nothing);
1088     fscanf(dependfileoutput,"%d\n",&length_mainfile);
1089     fscanf(dependfileoutput,"%s\n",nothing);
1090     fscanf(dependfileoutput,"%d\n",&length_nomdir);
1091     fscanf(dependfileoutput,"%s\n",nothing);
1092     fscanf(dependfileoutput,"%d\n",&length_commondirout);
1093     fscanf(dependfileoutput,"%s\n",nothing);
1094     fscanf(dependfileoutput,"%d\n",&length_commondirin);
1095     fscanf(dependfileoutput,"%s\n",nothing);
1096     fscanf(dependfileoutput,"%d\n",&length_filetoparse);
1097     fscanf(dependfileoutput,"%s\n",nothing);
1098     fscanf(dependfileoutput,"%d\n",&length_curbuf);
1099     fscanf(dependfileoutput,"%s\n",nothing);
1100     fscanf(dependfileoutput,"%d\n",&length_toprintglob);
1101     fscanf(dependfileoutput,"%s\n",nothing);
1102     fscanf(dependfileoutput,"%d\n",&value_char_size);
1103     fscanf(dependfileoutput,"%s\n",nothing);
1104     fscanf(dependfileoutput,"%d\n",&value_char_size1);
1105     fscanf(dependfileoutput,"%s\n",nothing);
1106     fscanf(dependfileoutput,"%d\n",&value_char_size2);
1107     fscanf(dependfileoutput,"%s\n",nothing);
1108     fscanf(dependfileoutput,"%d\n",&value_char_size3);
1109     fscanf(dependfileoutput,"%s\n",nothing);
1110     fscanf(dependfileoutput,"%d\n",&length_tmpvargridname);
1111     fscanf(dependfileoutput,"%s\n",nothing);
1112     fscanf(dependfileoutput,"%d\n",&length_ligne_Subloop);
1113     fscanf(dependfileoutput,"%s\n",nothing);
1114     fscanf(dependfileoutput,"%d\n",&length_lvargridname_toamr);
1115     fscanf(dependfileoutput,"%s\n",nothing);
1116     fscanf(dependfileoutput,"%d\n",&length_toprint_utilagrif);
1117     fscanf(dependfileoutput,"%s\n",nothing);
1118     fscanf(dependfileoutput,"%d\n",&length_toprinttmp_utilchar);
1119     fscanf(dependfileoutput,"%s\n",nothing);
1120     fscanf(dependfileoutput,"%d\n",&length_ligne_writedecl);
1121     fscanf(dependfileoutput,"%s\n",nothing);
1122     fscanf(dependfileoutput,"%d\n",&length_newname_toamr);
1123     fscanf(dependfileoutput,"%s\n",nothing);
1124     fscanf(dependfileoutput,"%d\n",&length_newname_writedecl);
1125     fscanf(dependfileoutput,"%s\n",nothing);
1126     fscanf(dependfileoutput,"%d\n",&length_ligne_toamr);
1127     fscanf(dependfileoutput,"%s\n",nothing);
1128     fscanf(dependfileoutput,"%d\n",&length_tmpligne_writedecl);
1129/*     fscanf(dependfileoutput,"%s\n",nothing);
1130     fscanf(dependfileoutput,"%d\n",&);
1131     fscanf(dependfileoutput,"%s\n",nothing);
1132     fscanf(dependfileoutput,"%d\n",&);
1133     fscanf(dependfileoutput,"%s\n",nothing);
1134     fscanf(dependfileoutput,"%d\n",&);
1135     fscanf(dependfileoutput,"%s\n",nothing);
1136     fscanf(dependfileoutput,"%d\n",&);
1137     fscanf(dependfileoutput,"%s\n",nothing);
1138     fscanf(dependfileoutput,"%d\n",&);
1139     fscanf(dependfileoutput,"%s\n",nothing);
1140     fscanf(dependfileoutput,"%d\n",&);
1141     fscanf(dependfileoutput,"%s\n",nothing);
1142     fscanf(dependfileoutput,"%d\n",&);
1143     fscanf(dependfileoutput,"%s\n",nothing);
1144     fscanf(dependfileoutput,"%d\n",&);
1145     fscanf(dependfileoutput,"%s\n",nothing);
1146     fscanf(dependfileoutput,"%d\n",&);*/
1147
1148     fclose(dependfileoutput);
1149  }
1150}
Note: See TracBrowser for help on using the repository browser.