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 tags/nemo_v3_2/nemo_v3_2/AGRIF/LIB – NEMO

source: tags/nemo_v3_2/nemo_v3_2/AGRIF/LIB/dependfile.c @ 1878

Last change on this file since 1878 was 1878, checked in by flavoni, 14 years ago

initial test for nemogcm

  • Property svn:eol-style set to native
File size: 48.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
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           /********** NBDIM **************************************************/
434/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_nbdim);*/
435           /********** DIMENSIONGIVEN *****************************************/
436/*           fprintf(dependfileoutput,"%d\n",parcours->var->v_dimensiongiven);*/
437           /********** ALLOCATABLE ********************************************/
438           fprintf(dependfileoutput,"%d\n",parcours->var->v_allocatable);
439           /********** POINTERDECLARE *****************************************/
440           fprintf(dependfileoutput,"%d\n",parcours->var->v_pointerdeclare);
441           /********** PRECISION **********************************************/
442           if ( strcasecmp(parcours->var->v_precision,"") )
443           {
444              fprintf(dependfileoutput,"%s\n",parcours->var->v_precision);
445           }
446           else
447           {
448              fprintf(dependfileoutput,"T\n");
449           }
450           /********** INITIALVALUE *******************************************/
451/*           if ( strcasecmp(parcours->var->v_initialvalue,"") )
452           {
453              fprintf(dependfileoutput,"%s\n",parcours->var->v_initialvalue);
454           }
455           else
456           {
457              fprintf(dependfileoutput,"T\n");
458           }*/
459           /********** NAMEINTYPENAME *****************************************/
460           if ( strcasecmp(parcours->var->v_nameinttypename,"") )
461           {
462              fprintf(dependfileoutput,"%s\n",parcours->var->v_nameinttypename);
463           }
464           else
465           {
466              fprintf(dependfileoutput,"T\n");
467           }
468           /********** INDICETABVARS ******************************************/
469           fprintf(dependfileoutput,"%d\n",parcours->var->v_indicetabvars);
470           /********** READEDLISTDIMENSION ************************************/
471           if ( parcours->var->v_dimensiongiven == 1 )
472           {
473              dims = parcours->var->v_dimension;
474              strcpy(listdimension,"");
475              while (dims)
476              {
477                 sprintf(ligne,"%s:%s",dims->dim.first,dims->dim.last);
478                 strcat(listdimension,ligne);
479                 if ( dims->suiv )
480                 {
481                    strcat(listdimension,",");
482                 }
483                 dims = dims->suiv;
484              }
485              fprintf(dependfileoutput,"%s\n",listdimension);
486           }
487           else
488           {
489              fprintf(dependfileoutput,"T\n");
490           }
491           /*******************************************************************/
492           fprintf(dependfileoutput,"------------------------\n");
493        }
494     }
495     parcours = parcours->suiv;
496  }
497  fclose(dependfileoutput);
498  }
499}
500
501/******************************************************************************/
502/*                         Readthedependfile                                  */
503/******************************************************************************/
504/* This subroutine is used to read the .dependfile<name> and to insert new    */
505/*    information in the listout list.                                        */
506/******************************************************************************/
507/*                                                                            */
508/*           .dependmodule -------->                      = list of var       */
509/*                                                                            */
510/*        not.dependmodule -------->                                          */
511/*                                                                            */
512/******************************************************************************/
513listvar *Readthedependfile( char *NameTampon , listvar *listout)
514{
515  char ligne[LONG_C];
516  FILE *dependfileoutput;
517  listvar *parcours0;
518  listvar *parcours;
519  listvar *parcoursprec;
520  char nothing[LONG_C];
521  int i;
522
523  parcoursprec = (listvar *)NULL;
524
525  convert2lower(NameTampon);
526  sprintf(ligne,".depend%s",NameTampon);
527  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
528  {
529    /* if the file doesn't exist it means that it is the first time           */
530    /*    we tried to parse this file                                         */
531  }
532  else
533  {
534    /* if the file exist we should verify that this file has changed          */
535      while (!feof(dependfileoutput))
536      {
537         parcours=(listvar *)malloc(sizeof(listvar));
538         parcours->var=(variable *)malloc(sizeof(variable));
539         /*                                                                   */
540         Init_Variable(parcours->var);
541         /*                                                                   */
542           /********** TYPEVAR ************************************************/
543         fscanf(dependfileoutput,"%s\n",parcours->var->v_typevar);
544           /********** NOMVAR *************************************************/
545         fscanf(dependfileoutput,"%s\n",parcours->var->v_nomvar);
546           /********** DIMCHAR ************************************************/
547         fscanf(dependfileoutput,"%s\n",parcours->var->v_dimchar);
548         if ( !strcasecmp(parcours->var->v_dimchar,"T") )
549         {
550            strcpy(parcours->var->v_dimchar,"");
551         }
552           /********** COMMONINFILE *******************************************/
553         fscanf(dependfileoutput,"%s\n",parcours->var->v_commoninfile);
554         if ( !strcasecmp(parcours->var->v_commoninfile,"T") )
555         {
556            strcpy(parcours->var->v_commoninfile,"");
557         }
558           /********** COMMONNAME *********************************************/
559         fscanf(dependfileoutput,"%s\n",parcours->var->v_commonname);
560         if ( !strcasecmp(parcours->var->v_commonname,"T") )
561         {
562            strcpy(parcours->var->v_commonname,"");
563         }
564           /********** NBDIM **************************************************/
565/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_nbdim);*/
566           /********** DIMENSIONGIVEN *****************************************/
567/*         fscanf(dependfileoutput,"%d\n",&parcours->var->v_dimensiongiven);*/
568           /********** ALLOCATABLE ********************************************/
569         fscanf(dependfileoutput,"%d\n",&parcours->var->v_allocatable);
570         if ( parcours->var->v_allocatable == 1 )
571         {
572            Add_Allocate_Var_1(parcours->var->v_nomvar,
573                               parcours->var->v_commonname);
574         }
575           /********** POINTERDECLARE *****************************************/
576         fscanf(dependfileoutput,"%d\n",&parcours->var->v_pointerdeclare);
577         if ( parcours->var->v_pointerdeclare == 1 )
578         {
579            Add_Pointer_Var_1(parcours->var->v_nomvar);
580         }
581           /********** PRECISION **********************************************/
582         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_precision);
583         if ( !strcasecmp(parcours->var->v_precision,"T") )
584         {
585            strcpy(parcours->var->v_precision,"");
586         }
587           /********** INITIALVALUE *******************************************/
588/*         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_initialvalue);
589         if ( !strcasecmp(parcours->var->v_initialvalue,"T") )
590         {
591            strcpy(parcours->var->v_initialvalue,"");
592         }*/
593           /********** NAMEINTYPENAME *****************************************/
594         fscanf(dependfileoutput,"%[^\n] \n",parcours->var->v_nameinttypename);
595         if ( !strcasecmp(parcours->var->v_nameinttypename,"T") )
596         {
597            strcpy(parcours->var->v_nameinttypename,"");
598         }
599           /********** INDICETABVARS ******************************************/
600         fscanf(dependfileoutput,"%d\n",&parcours->var->v_indicetabvars);
601           /********** READEDLISTDIMENSION ************************************/
602         fscanf(dependfileoutput,"%s\n",parcours->var->v_readedlistdimension);
603         if ( !strcasecmp(parcours->var->v_readedlistdimension,"T") )
604         {
605            strcpy(parcours->var->v_readedlistdimension,"");
606         }
607         else
608         {
609            parcours->var->v_dimensiongiven = 1;
610            parcours->var->v_nbdim = 1;
611            i = 1;
612            /*                                                                */
613            while ( i < strlen(parcours->var->v_readedlistdimension) )
614            {
615               if ( parcours->var->v_readedlistdimension[i] == ',' )
616               {
617                  parcours->var->v_nbdim = parcours->var->v_nbdim + 1 ;
618               }
619               /*                                                             */
620               i=i+1;
621            }
622         }
623           /*******************************************************************/
624         fscanf(dependfileoutput,"%s\n",nothing);
625         parcours->suiv = NULL;
626         if ( !listout )
627         {
628            listout = parcours;
629            parcoursprec = parcours;
630         }
631         else
632         {
633            if ( parcoursprec )
634            {
635               parcoursprec->suiv = parcours;
636               parcoursprec = parcours;
637            }
638            else
639            {
640               parcours0 = listout;
641               while ( parcours0->suiv ) parcours0=parcours0->suiv;
642               parcours0->suiv = parcours;
643               parcoursprec = parcours0->suiv;
644            }
645         }
646         parcours = NULL;
647      }
648      fclose(dependfileoutput);
649  }
650  return listout;
651}
652
653void Write_Subroutine_For_Alloc()
654{
655   FILE *dependfileoutput;
656   listnom *parcours;
657
658   if ( List_Subroutine_For_Alloc )
659   {
660      if ((dependfileoutput=fopen(".dependAllocAgrif","w"))!=NULL)
661      {
662         parcours = List_Subroutine_For_Alloc;
663         while (parcours)
664         {
665            fprintf(dependfileoutput,"%s\n",parcours->o_nom);
666            parcours = parcours->suiv;
667         }
668         fclose(dependfileoutput);
669      }
670   }
671}
672
673void Read_Subroutine_For_Alloc()
674{
675  FILE *dependfileoutput;
676  listnom *parcours;
677  listnom *ref;
678
679  ref = (listnom *)NULL;
680  if ((dependfileoutput=fopen(".dependAllocAgrif","r"))!=NULL)
681  {
682     List_Subroutine_For_Alloc = (listnom *)NULL;
683     while (!feof(dependfileoutput))
684     {
685        parcours=(listnom *)malloc(sizeof(listnom));
686        strcpy(parcours->o_nom,"");
687
688        fscanf(dependfileoutput,"%s\n",&parcours->o_nom);
689        parcours->suiv = NULL;
690
691        if ( !List_Subroutine_For_Alloc )
692        {
693           List_Subroutine_For_Alloc = parcours;
694           ref = parcours;
695        }
696        else
697        {
698            ref->suiv = parcours;
699            ref = parcours;
700        }
701     }
702     fclose(dependfileoutput);
703  }
704}
705
706/******************************************************************************/
707/*                        Writethedependavailablefile                         */
708/******************************************************************************/
709/* This subroutine is used to write the .dependfileavailable file             */
710/******************************************************************************/
711/*                                                                            */
712/*                                  .dependavailable                          */
713/*     tabvars(1) = var1                                                      */
714/*     tabvars(3) = var1                  2                                   */
715/*     tabvars(4) = var1         =====>   5                                   */
716/*     tabvars(6) = var1                                                      */
717/*     tabvars(7) = var1                                                      */
718/*                                                                            */
719/*                                                                            */
720/*                                                                            */
721/******************************************************************************/
722void Writethedependavailablefile()
723{
724  FILE *dependfileoutput;
725  listindice *parcours;
726
727  if ((dependfileoutput=fopen(".dependavailable","w"))!=NULL)
728  {
729     /* We are looking for all the indices of the Listofavailableindices      */
730     parcours = Listofavailableindices;
731     while (parcours)
732     {
733        if ( parcours->i_indice != 0 )
734        {
735           fprintf(dependfileoutput,"%d\n",parcours->i_indice);
736        }
737        parcours = parcours->suiv;
738     }
739     fclose(dependfileoutput);
740  }
741}
742
743/******************************************************************************/
744/*                        Readthedependavailablefile                          */
745/******************************************************************************/
746/* This subroutine is used to read the .dependfileavailable file              */
747/******************************************************************************/
748/*                                                                            */
749/*                                  .dependavailable                          */
750/*     tabvars(1) = var1                                                      */
751/*     tabvars(3) = var1                  2                                   */
752/*     tabvars(4) = var1         =====>   5  ==> Listofavailableindices       */
753/*     tabvars(6) = var1                                                      */
754/*     tabvars(7) = var1                                                      */
755/*                                                                            */
756/*                                                                            */
757/*                                                                            */
758/******************************************************************************/
759void Readthedependavailablefile()
760{
761  FILE *dependfileoutput;
762  listindice *parcours;
763
764  if ((dependfileoutput=fopen(".dependavailable","r"))!=NULL)
765  {
766     /* We are looking for all the indices of the Listofavailableindices      */
767     Listofavailableindices = (listindice *)NULL;
768     while (!feof(dependfileoutput))
769     {
770        parcours=(listindice *)malloc(sizeof(listindice));
771        fscanf(dependfileoutput,"%d\n",&parcours->i_indice);
772        if ( parcours->i_indice != 0 && parcours->i_indice < 10000000 )
773        {
774           parcours -> suiv = Listofavailableindices;
775           Listofavailableindices = parcours;
776        }
777        else
778        {
779           free(parcours);
780        }
781     }
782     fclose(dependfileoutput);
783  }
784}
785
786
787/******************************************************************************/
788/*                      Did_filetoparse_readed                                */
789/******************************************************************************/
790/* This subroutine is used to know if the .depend<NameTampon> exist           */
791/*    it means if the file has been ever parsed                               */
792/******************************************************************************/
793/*                                                                            */
794/******************************************************************************/
795int Did_filetoparse_readed(char *NameTampon)
796{
797  FILE *dependfileoutput;
798  char ligne[LONG_C];
799  int out;
800
801  convert2lower(NameTampon);
802  sprintf(ligne,".depend%s",NameTampon);
803  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
804  {
805      out = 0;
806  }
807  else
808  {
809      out = 1;
810      fclose(dependfileoutput);
811  }
812  return out;
813}
814
815
816/******************************************************************************/
817/*                      Did_module_common_treaded                             */
818/******************************************************************************/
819/* This subroutine is used to know if the .depend<NameTampon> exist           */
820/*    it means if the file has been ever parsed                               */
821/******************************************************************************/
822/*                                                                            */
823/******************************************************************************/
824int Did_module_common_treaded(char *NameTampon)
825{
826  FILE *dependfileoutput;
827  char ligne[LONG_C];
828  int out;
829
830  convert2lower(NameTampon);
831  sprintf(ligne,".depend%s",NameTampon);
832  if ((dependfileoutput = fopen(ligne,"r"))==NULL)
833  {
834      out = 0;
835  }
836  else
837  {
838      out = 1;
839      fclose(dependfileoutput);
840  }
841  return out;
842}
843
844
845
846void Write_val_max()
847{
848  FILE *dependfileoutput;
849
850  if ((dependfileoutput=fopen(".dependvalmax","w"))!=NULL)
851  {
852     fprintf(dependfileoutput,"length_last\n");
853     fprintf(dependfileoutput,"%d\n",length_last);
854     fprintf(dependfileoutput,"length_first\n");
855     fprintf(dependfileoutput,"%d\n",length_first);
856     fprintf(dependfileoutput,"length_v_typevar\n");
857     fprintf(dependfileoutput,"%d\n",length_v_typevar);
858     fprintf(dependfileoutput,"length_v_nomvar\n");
859     fprintf(dependfileoutput,"%d\n",length_v_nomvar);
860     fprintf(dependfileoutput,"length_v_dimchar\n");
861     fprintf(dependfileoutput,"%d\n",length_v_dimchar);
862     fprintf(dependfileoutput,"length_v_modulename\n");
863     fprintf(dependfileoutput,"%d\n",length_v_modulename);
864     fprintf(dependfileoutput,"length_v_commonname\n");
865     fprintf(dependfileoutput,"%d\n",length_v_commonname);
866     fprintf(dependfileoutput,"length_v_vallengspec\n");
867     fprintf(dependfileoutput,"%d\n",length_v_vallengspec);
868     fprintf(dependfileoutput,"length_v_nameinttypename\n");
869     fprintf(dependfileoutput,"%d\n",length_v_nameinttypename);
870     fprintf(dependfileoutput,"length_v_commoninfile\n");
871     fprintf(dependfileoutput,"%d\n",length_v_commoninfile);
872     fprintf(dependfileoutput,"length_v_subroutinename\n");
873     fprintf(dependfileoutput,"%d\n",length_v_subroutinename);
874     fprintf(dependfileoutput,"length_v_precision\n");
875     fprintf(dependfileoutput,"%d\n",length_v_precision);
876     fprintf(dependfileoutput,"length_v_IntentSpec\n");
877     fprintf(dependfileoutput,"%d\n",length_v_IntentSpec);
878     fprintf(dependfileoutput,"length_v_initialvalue\n");
879     fprintf(dependfileoutput,"%d\n",length_v_initialvalue);
880     fprintf(dependfileoutput,"length_v_readedlistdimension\n");
881     fprintf(dependfileoutput,"%d\n",length_v_readedlistdimension);
882     fprintf(dependfileoutput,"length_u_usemodule\n");
883     fprintf(dependfileoutput,"%d\n",length_u_usemodule);
884     fprintf(dependfileoutput,"length_u_charusemodule\n");
885     fprintf(dependfileoutput,"%d\n",length_u_charusemodule);
886     fprintf(dependfileoutput,"length_u_cursubroutine\n");
887     fprintf(dependfileoutput,"%d\n",length_u_cursubroutine);
888     fprintf(dependfileoutput,"length_u_modulename\n");
889     fprintf(dependfileoutput,"%d\n",length_u_modulename);
890     fprintf(dependfileoutput,"length_n_name\n");
891     fprintf(dependfileoutput,"%d\n",length_n_name);
892     fprintf(dependfileoutput,"length_c_namevar\n");
893     fprintf(dependfileoutput,"%d\n",length_c_namevar);
894     fprintf(dependfileoutput,"length_c_namepointedvar\n");
895     fprintf(dependfileoutput,"%d\n",length_c_namepointedvar);
896     fprintf(dependfileoutput,"length_o_nom\n");
897     fprintf(dependfileoutput,"%d\n",length_o_nom);
898     fprintf(dependfileoutput,"length_o_module\n");
899     fprintf(dependfileoutput,"%d\n",length_o_module);
900     fprintf(dependfileoutput,"length_a_nomvar\n");
901     fprintf(dependfileoutput,"%d\n",length_a_nomvar);
902     fprintf(dependfileoutput,"length_a_subroutine\n");
903     fprintf(dependfileoutput,"%d\n",length_a_subroutine);
904     fprintf(dependfileoutput,"length_a_module\n");
905     fprintf(dependfileoutput,"%d\n",length_a_module);
906     fprintf(dependfileoutput,"length_usemodule\n");
907     fprintf(dependfileoutput,"%d\n",length_t_usemodule);
908     fprintf(dependfileoutput,"length_cursubroutine\n");
909     fprintf(dependfileoutput,"%d\n",length_t_cursubroutine);
910     fprintf(dependfileoutput,"length_curfilename\n");
911     fprintf(dependfileoutput,"%d\n",length_curfilename);
912     fprintf(dependfileoutput,"length_nomfileoutput\n");
913     fprintf(dependfileoutput,"%d\n",length_nomfileoutput);
914     fprintf(dependfileoutput,"length_motparse\n");
915     fprintf(dependfileoutput,"%d\n",length_motparse);
916     fprintf(dependfileoutput,"length_mainfile\n");
917     fprintf(dependfileoutput,"%d\n",length_mainfile);
918     fprintf(dependfileoutput,"length_nomdir\n");
919     fprintf(dependfileoutput,"%d\n",length_nomdir);
920     fprintf(dependfileoutput,"length_commondirout\n");
921     fprintf(dependfileoutput,"%d\n",length_commondirout);
922     fprintf(dependfileoutput,"length_commondirin\n");
923     fprintf(dependfileoutput,"%d\n",length_commondirin);
924     fprintf(dependfileoutput,"length_filetoparse\n");
925     fprintf(dependfileoutput,"%d\n",length_filetoparse);
926     fprintf(dependfileoutput,"length_curbuf\n");
927     fprintf(dependfileoutput,"%d\n",length_curbuf);
928     fprintf(dependfileoutput,"length_toprintglob\n");
929     fprintf(dependfileoutput,"%d\n",length_toprintglob);
930     fprintf(dependfileoutput,"Size_char0d\n");
931     fprintf(dependfileoutput,"%d\n",value_char_size);
932     fprintf(dependfileoutput,"Size_char1d\n");
933     fprintf(dependfileoutput,"%d\n",value_char_size1);
934     fprintf(dependfileoutput,"Size_char2d\n");
935     fprintf(dependfileoutput,"%d\n",value_char_size2);
936     fprintf(dependfileoutput,"Size_char3d\n");
937     fprintf(dependfileoutput,"%d\n",value_char_size3);
938     fprintf(dependfileoutput,"length_tmpvargridname\n");
939     fprintf(dependfileoutput,"%d\n",length_tmpvargridname);
940     fprintf(dependfileoutput,"length_ligne_Subloop\n");
941     fprintf(dependfileoutput,"%d\n",length_ligne_Subloop);
942     fprintf(dependfileoutput,"length_lvargridname_toamr\n");
943     fprintf(dependfileoutput,"%d\n",length_lvargridname_toamr);
944     fprintf(dependfileoutput,"length_toprint_toamr\n");
945     fprintf(dependfileoutput,"%d\n",length_toprint_utilagrif);
946     fprintf(dependfileoutput,"length_toprinttmp_utilchar\n");
947     fprintf(dependfileoutput,"%d\n",length_toprinttmp_utilchar);
948     fprintf(dependfileoutput,"length_ligne_writedecl\n");
949     fprintf(dependfileoutput,"%d\n",length_ligne_writedecl);
950     fprintf(dependfileoutput,"length_newname_toamr\n");
951     fprintf(dependfileoutput,"%d\n",length_newname_toamr);
952     fprintf(dependfileoutput,"length_newname_writedecl\n");
953     fprintf(dependfileoutput,"%d\n",length_newname_writedecl);
954     fprintf(dependfileoutput,"length_ligne_toamr\n");
955     fprintf(dependfileoutput,"%d\n",length_ligne_toamr);
956     fprintf(dependfileoutput,"length_tmpligne_writedecl\n");
957     fprintf(dependfileoutput,"%d\n",length_tmpligne_writedecl);
958/*     fprintf(dependfileoutput,"\n");
959     fprintf(dependfileoutput,"%d\n",);
960     fprintf(dependfileoutput,"\n");
961     fprintf(dependfileoutput,"%d\n",);
962     fprintf(dependfileoutput,"\n");
963     fprintf(dependfileoutput,"%d\n",);
964     fprintf(dependfileoutput,"\n");
965     fprintf(dependfileoutput,"%d\n",);
966     fprintf(dependfileoutput,"\n");
967     fprintf(dependfileoutput,"%d\n",);
968     fprintf(dependfileoutput,"\n");
969     fprintf(dependfileoutput,"%d\n",);
970     fprintf(dependfileoutput,"\n");
971     fprintf(dependfileoutput,"%d\n",);
972     fprintf(dependfileoutput,"\n");
973     fprintf(dependfileoutput,"%d\n",);
974     fprintf(dependfileoutput,"\n");
975     fprintf(dependfileoutput,"%d\n",);*/
976
977     fclose(dependfileoutput);
978  }
979}
980
981
982void Read_val_max()
983{
984  char nothing[LONG_C];
985  FILE *dependfileoutput;
986
987  if ((dependfileoutput=fopen(".dependvalmax","r"))!=NULL)
988  {
989     fscanf(dependfileoutput,"%s\n",nothing);
990     fscanf(dependfileoutput,"%d\n",&length_last);
991     fscanf(dependfileoutput,"%s\n",nothing);
992     fscanf(dependfileoutput,"%d\n",&length_first);
993     fscanf(dependfileoutput,"%s\n",nothing);
994     fscanf(dependfileoutput,"%d\n",&length_v_typevar);
995     fscanf(dependfileoutput,"%s\n",nothing);
996     fscanf(dependfileoutput,"%d\n",&length_v_nomvar);
997     fscanf(dependfileoutput,"%s\n",nothing);
998     fscanf(dependfileoutput,"%d\n",&length_v_dimchar);
999     fscanf(dependfileoutput,"%s\n",nothing);
1000     fscanf(dependfileoutput,"%d\n",&length_v_modulename);
1001     fscanf(dependfileoutput,"%s\n",nothing);
1002     fscanf(dependfileoutput,"%d\n",&length_v_commonname);
1003     fscanf(dependfileoutput,"%s\n",nothing);
1004     fscanf(dependfileoutput,"%d\n",&length_v_vallengspec);
1005     fscanf(dependfileoutput,"%s\n",nothing);
1006     fscanf(dependfileoutput,"%d\n",&length_v_nameinttypename);
1007     fscanf(dependfileoutput,"%s\n",nothing);
1008     fscanf(dependfileoutput,"%d\n",&length_v_commoninfile);
1009     fscanf(dependfileoutput,"%s\n",nothing);
1010     fscanf(dependfileoutput,"%d\n",&length_v_subroutinename);
1011     fscanf(dependfileoutput,"%s\n",nothing);
1012     fscanf(dependfileoutput,"%d\n",&length_v_precision);
1013     fscanf(dependfileoutput,"%s\n",nothing);
1014     fscanf(dependfileoutput,"%d\n",&length_v_IntentSpec);
1015     fscanf(dependfileoutput,"%s\n",nothing);
1016     fscanf(dependfileoutput,"%d\n",&length_v_initialvalue);
1017     fscanf(dependfileoutput,"%s\n",nothing);
1018     fscanf(dependfileoutput,"%d\n",&length_v_readedlistdimension);
1019     fscanf(dependfileoutput,"%s\n",nothing);
1020     fscanf(dependfileoutput,"%d\n",&length_u_usemodule);
1021     fscanf(dependfileoutput,"%s\n",nothing);
1022     fscanf(dependfileoutput,"%d\n",&length_u_charusemodule);
1023     fscanf(dependfileoutput,"%s\n",nothing);
1024     fscanf(dependfileoutput,"%d\n",&length_u_cursubroutine);
1025     fscanf(dependfileoutput,"%s\n",nothing);
1026     fscanf(dependfileoutput,"%d\n",&length_u_modulename);
1027     fscanf(dependfileoutput,"%s\n",nothing);
1028     fscanf(dependfileoutput,"%d\n",&length_n_name);
1029     fscanf(dependfileoutput,"%s\n",nothing);
1030     fscanf(dependfileoutput,"%d\n",&length_c_namevar);
1031     fscanf(dependfileoutput,"%s\n",nothing);
1032     fscanf(dependfileoutput,"%d\n",&length_c_namepointedvar);
1033     fscanf(dependfileoutput,"%s\n",nothing);
1034     fscanf(dependfileoutput,"%d\n",&length_o_nom);
1035     fscanf(dependfileoutput,"%s\n",nothing);
1036     fscanf(dependfileoutput,"%d\n",&length_o_module);
1037     fscanf(dependfileoutput,"%s\n",nothing);
1038     fscanf(dependfileoutput,"%d\n",&length_a_nomvar);
1039     fscanf(dependfileoutput,"%s\n",nothing);
1040     fscanf(dependfileoutput,"%d\n",&length_a_subroutine);
1041     fscanf(dependfileoutput,"%s\n",nothing);
1042     fscanf(dependfileoutput,"%d\n",&length_a_module);
1043     fscanf(dependfileoutput,"%s\n",nothing);
1044     fscanf(dependfileoutput,"%d\n",&length_t_usemodule);
1045     fscanf(dependfileoutput,"%s\n",nothing);
1046     fscanf(dependfileoutput,"%d\n",&length_t_cursubroutine);
1047     fscanf(dependfileoutput,"%s\n",nothing);
1048     fscanf(dependfileoutput,"%d\n",&length_curfilename);
1049     fscanf(dependfileoutput,"%s\n",nothing);
1050     fscanf(dependfileoutput,"%d\n",&length_nomfileoutput);
1051     fscanf(dependfileoutput,"%s\n",nothing);
1052     fscanf(dependfileoutput,"%d\n",&length_motparse);
1053     fscanf(dependfileoutput,"%s\n",nothing);
1054     fscanf(dependfileoutput,"%d\n",&length_mainfile);
1055     fscanf(dependfileoutput,"%s\n",nothing);
1056     fscanf(dependfileoutput,"%d\n",&length_nomdir);
1057     fscanf(dependfileoutput,"%s\n",nothing);
1058     fscanf(dependfileoutput,"%d\n",&length_commondirout);
1059     fscanf(dependfileoutput,"%s\n",nothing);
1060     fscanf(dependfileoutput,"%d\n",&length_commondirin);
1061     fscanf(dependfileoutput,"%s\n",nothing);
1062     fscanf(dependfileoutput,"%d\n",&length_filetoparse);
1063     fscanf(dependfileoutput,"%s\n",nothing);
1064     fscanf(dependfileoutput,"%d\n",&length_curbuf);
1065     fscanf(dependfileoutput,"%s\n",nothing);
1066     fscanf(dependfileoutput,"%d\n",&length_toprintglob);
1067     fscanf(dependfileoutput,"%s\n",nothing);
1068     fscanf(dependfileoutput,"%d\n",&value_char_size);
1069     fscanf(dependfileoutput,"%s\n",nothing);
1070     fscanf(dependfileoutput,"%d\n",&value_char_size1);
1071     fscanf(dependfileoutput,"%s\n",nothing);
1072     fscanf(dependfileoutput,"%d\n",&value_char_size2);
1073     fscanf(dependfileoutput,"%s\n",nothing);
1074     fscanf(dependfileoutput,"%d\n",&value_char_size3);
1075     fscanf(dependfileoutput,"%s\n",nothing);
1076     fscanf(dependfileoutput,"%d\n",&length_tmpvargridname);
1077     fscanf(dependfileoutput,"%s\n",nothing);
1078     fscanf(dependfileoutput,"%d\n",&length_ligne_Subloop);
1079     fscanf(dependfileoutput,"%s\n",nothing);
1080     fscanf(dependfileoutput,"%d\n",&length_lvargridname_toamr);
1081     fscanf(dependfileoutput,"%s\n",nothing);
1082     fscanf(dependfileoutput,"%d\n",&length_toprint_utilagrif);
1083     fscanf(dependfileoutput,"%s\n",nothing);
1084     fscanf(dependfileoutput,"%d\n",&length_toprinttmp_utilchar);
1085     fscanf(dependfileoutput,"%s\n",nothing);
1086     fscanf(dependfileoutput,"%d\n",&length_ligne_writedecl);
1087     fscanf(dependfileoutput,"%s\n",nothing);
1088     fscanf(dependfileoutput,"%d\n",&length_newname_toamr);
1089     fscanf(dependfileoutput,"%s\n",nothing);
1090     fscanf(dependfileoutput,"%d\n",&length_newname_writedecl);
1091     fscanf(dependfileoutput,"%s\n",nothing);
1092     fscanf(dependfileoutput,"%d\n",&length_ligne_toamr);
1093     fscanf(dependfileoutput,"%s\n",nothing);
1094     fscanf(dependfileoutput,"%d\n",&length_tmpligne_writedecl);
1095/*     fscanf(dependfileoutput,"%s\n",nothing);
1096     fscanf(dependfileoutput,"%d\n",&);
1097     fscanf(dependfileoutput,"%s\n",nothing);
1098     fscanf(dependfileoutput,"%d\n",&);
1099     fscanf(dependfileoutput,"%s\n",nothing);
1100     fscanf(dependfileoutput,"%d\n",&);
1101     fscanf(dependfileoutput,"%s\n",nothing);
1102     fscanf(dependfileoutput,"%d\n",&);
1103     fscanf(dependfileoutput,"%s\n",nothing);
1104     fscanf(dependfileoutput,"%d\n",&);
1105     fscanf(dependfileoutput,"%s\n",nothing);
1106     fscanf(dependfileoutput,"%d\n",&);
1107     fscanf(dependfileoutput,"%s\n",nothing);
1108     fscanf(dependfileoutput,"%d\n",&);
1109     fscanf(dependfileoutput,"%s\n",nothing);
1110     fscanf(dependfileoutput,"%d\n",&);
1111     fscanf(dependfileoutput,"%s\n",nothing);
1112     fscanf(dependfileoutput,"%d\n",&);*/
1113
1114     fclose(dependfileoutput);
1115  }
1116}
Note: See TracBrowser for help on using the repository browser.