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.
DiversListe.c in trunk/AGRIF/LIB – NEMO

source: trunk/AGRIF/LIB/DiversListe.c @ 396

Last change on this file since 396 was 396, checked in by opalod, 18 years ago

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.0 KB
Line 
1/******************************************************************************/
2/*                                                                            */
3/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
4/*                                                                            */
5/*     Copyright (C) 2005 Laurent Debreu (Laurent.Debreu@imag.fr)             */
6/*                        Cyril Mazauric (Cyril.Mazauric@imag.fr)             */
7/*                                                                            */
8/*     This program is free software; you can redistribute it and/or modify   */
9/*    it                                                                      */
10/*                                                                            */
11/*    This program is distributed in the hope that it will be useful,         */
12/*     but WITHOUT ANY WARRANTY; without even the implied warranty of         */
13/*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
14/*    GNU General Public License for more details.                            */
15/*                                                                            */
16/******************************************************************************/
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include "decl.h"
21
22/******************************************************************************/
23/*                      COM_1_AddCommonvartolist                              */
24/******************************************************************************/
25/*  This subroutines is used to add the variable defined in common in the     */
26/*     commonlist                                                             */
27/******************************************************************************/
28/*                                                                            */
29/******************************************************************************/
30void COM_1_AddCommonvartolist()
31{
32   listvarcommon *newvar;
33   
34   newvar = (listvarcommon *)malloc(sizeof(listvarcommon));
35   strcpy(newvar->nomvar,commonvar);
36   strcpy(newvar->commonname,commonblockname);
37   strcpy(newvar->subroutinename,subroutinename);
38   newvar->positioninblock= positioninblock;
39
40   newvar->suiv = NULL;
41
42   if ( !commonlist )
43   {
44      commonlist = newvar;
45   }
46   else
47   {
48      newvar->suiv = commonlist;
49      commonlist = newvar;
50   }
51}
52
53/******************************************************************************/
54/*                     Addtolistnom                                           */
55/******************************************************************************/
56/* This subroutine is used to add a variable to the list                      */
57/******************************************************************************/
58/*                                                                            */
59/******************************************************************************/
60listnom *Addtolistnom(char *nom, listnom *listin)
61{
62   listnom *newnom;
63   listnom *parcours;
64   int out;
65
66   if ( !listin )
67   {
68      newnom=(listnom *) malloc (sizeof (listnom));
69      strcpy(newnom->nom,nom);
70      newnom->suiv = NULL;
71      listin = newnom;
72   }
73   else
74   {
75      parcours = listin;
76      out = 0 ;
77      while ( parcours && out == 0 )
78      {
79         if ( !strcasecmp(parcours->nom,nom) ) out = 1 ;
80         else parcours=parcours->suiv;
81      }
82      if ( out == 0 ) 
83      {
84          newnom=(listnom *) malloc (sizeof (listnom));
85          strcpy(newnom->nom,nom);
86          newnom->suiv = listin;
87          listin = newnom;
88      }
89   }
90   return listin;
91}
92
93/******************************************************************************/
94/*                           Add_listname                                     */
95/******************************************************************************/
96/* This subroutine is used to add a        variable to the list               */
97/******************************************************************************/
98/*        _______     _______     _______     _______     _______             */
99/*       +      +    +      +    +      +    +      +    +      +             */
100/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
101/*       +______+    +______+    +______+    +______+    +______+             */
102/*                                                                            */
103/*                                                                            */
104/*                                                                            */
105/******************************************************************************/
106listname *Add_listname(char *nom,listname *input)
107{
108   listname *newnom;
109   listname *parcours;
110   int out;
111
112   if ( !input )
113   {
114      newnom=(listname *) malloc (sizeof (listname));
115      strcpy(newnom->name,nom);
116      newnom->suiv = NULL;
117      input = newnom;
118   }
119   else
120   {
121      parcours = input;
122      out = 0 ;
123      while ( parcours && out == 0 )
124      {
125         if ( !strcasecmp(parcours->name,nom) ) out = 1;
126         else parcours=parcours->suiv;         
127      }
128      if ( out == 0 )
129      {
130         newnom=(listname *) malloc (sizeof (listname));
131         strcpy(newnom->name,nom);
132         newnom->suiv = input;
133         input = newnom;
134      }
135   }
136   return input;
137}
138
139/******************************************************************************/
140/*                     Add_ModuleTo_listofmodules                             */
141/******************************************************************************/
142/* This subroutine is used to add a        variable to the list               */
143/******************************************************************************/
144/*        _______     _______     _______     _______     _______             */
145/*       +      +    +      +    +      +    +      +    +      +             */
146/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
147/*       +______+    +______+    +______+    +______+    +______+             */
148/*                                                                            */
149/*                                                                            */
150/*                                                                            */
151/******************************************************************************/
152void Add_ModuleTo_listofmodules(char *nom)
153{
154   listnom *newnom;
155
156   newnom=(listnom *) malloc (sizeof (listnom));
157   strcpy(newnom->nom,nom);
158   newnom->suiv = listofmodules;
159   listofmodules = newnom;   
160}
161
162/******************************************************************************/
163/*                    ModuleIsDefineInInputFile                               */
164/******************************************************************************/
165/* This subroutine is used to know if the module is defined in the input file */
166/******************************************************************************/
167/*                                                                            */
168/*                                                                            */
169/******************************************************************************/
170int ModuleIsDefineInInputFile(char *name)
171{
172   listnom *newnom;
173   int out;
174   
175   out = 0;
176   if ( listofmodules ) 
177   {
178      newnom = listofmodules;
179      while( newnom && out == 0 )
180      {
181         if ( !strcasecmp(newnom->nom,name) ) out = 1 ;
182         else newnom=newnom->suiv;
183      }
184   }
185   return out;
186}
187
188/******************************************************************************/
189/*                         AddNameToListNamelist                              */
190/******************************************************************************/
191/* This subroutine is used to add a listvar l at the end of a listvar         */
192/* glob.                                                                      */
193/*                                                                            */
194/******************************************************************************/
195/*        _______     _______     _______     _______     _______             */
196/*       +      +    +      +    +      +    +      +    +      +             */
197/*       + glob +--->+ glob +--->+ glob +--->+ glob +--->+  l   +             */
198/*       +______+    +______+    +______+    +______+    +______+             */
199/*                                                                            */
200/******************************************************************************/
201void AddNameToListNamelist(char * name)
202{
203   listnamelist *newvar;
204
205   if ( strcasecmp(name,"") )
206   {
207      newvar =(listnamelist*)malloc(sizeof(listnamelist));
208      strcpy(newvar->name,name);
209      newvar->suiv = listenamelist;
210      listenamelist = newvar;
211   }
212}
213
214/******************************************************************************/
215/*                      Addmoduletothelisttmp                                 */
216/******************************************************************************/
217/* This subroutine is used to add a record to a list of struct                */
218/* listusemodule                                                              */
219/******************************************************************************/
220/*                                                                            */
221/*       subroutine sub ... USE mod1 ===> insert in list                      */
222/*        _______     _______     _______     _______     _______             */
223/*       +      +    +      +    +      +    +      +    +      +             */
224/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
225/*       +______+    +______+    +______+    +______+    +______+             */
226/*                                                                            */
227/*       list =  listofmoduletmp                                              */
228/*                                                                            */
229/******************************************************************************/
230void Addmoduletothelisttmp(char *name)
231{
232  listusemodule *newmodule;
233  listusemodule *parcours;
234  int out;
235
236  if ( !listofmoduletmp)
237  {
238    newmodule =(listusemodule *)malloc(sizeof(listusemodule));
239    strcpy(newmodule->usemodule,name);
240    strcpy(newmodule->cursubroutine,subroutinename); 
241    newmodule->suiv = NULL;
242    listofmoduletmp = newmodule ;
243  }
244  else
245  {
246    parcours = listofmoduletmp;
247    out = 0;
248    while( parcours && out == 0 )
249    {
250       if ( !strcasecmp(parcours->usemodule,name) ) out = 1;
251       else parcours = parcours->suiv;
252    }
253    if ( out == 0 )
254    {
255       newmodule =(listusemodule *)malloc(sizeof(listusemodule));
256       strcpy(newmodule->usemodule,name);
257       strcpy(newmodule->cursubroutine,subroutinename); 
258       newmodule->suiv = listofmoduletmp;
259       listofmoduletmp = newmodule;
260    }
261  }
262}
263
264/******************************************************************************/
265/*                     Add_ModuleTo_Modulelist                                */
266/******************************************************************************/
267/* This subroutine is used to add a        variable to the list               */
268/******************************************************************************/
269/*        _______     _______     _______     _______     _______             */
270/*       +      +    +      +    +      +    +      +    +      +             */
271/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
272/*       +______+    +______+    +______+    +______+    +______+             */
273/*                                                                            */
274/*                                                                            */
275/*                                                                            */
276/******************************************************************************/
277void Add_ModuleTo_Modulelist(char *nom)
278{
279   listnom *newnom;
280
281   newnom=(listnom *) malloc (sizeof (listnom));
282   strcpy(newnom->nom,nom);
283   newnom->suiv = modulelist;
284   modulelist = newnom;   
285}
286
287/******************************************************************************/
288/*                 OPTI_1_completelistvarpointtovar                           */
289/******************************************************************************/
290/* Firstpass 1                                                                */
291/* We should complete the listvarpointtovar                                   */ 
292/******************************************************************************/
293/*                                                                            */
294/******************************************************************************/
295void OPTI_1_completelistvarpointtovar(char *namemodule,listcouple *couple)
296{
297   listvarpointtovar *pointtmp;
298   
299   if ( firstpass == 1 ) 
300   {
301      /* we should complete the Listofvarpointtovar                           */
302      pointtmp=(listvarpointtovar *)malloc(sizeof(listvarpointtovar));
303      strcpy(pointtmp->usemodule,namemodule);
304      strcpy(pointtmp->cursubroutine,subroutinename);
305      pointtmp->couple = couple;
306      if ( Listofvarpointtovar )
307      {
308         pointtmp->suiv = Listofvarpointtovar;
309         Listofvarpointtovar = pointtmp;
310      }
311      else
312      {
313         pointtmp->suiv = NULL;
314         Listofvarpointtovar = pointtmp;   
315      }
316   }
317}
318
319/******************************************************************************/
320/*                        Addincludetothelist                                 */
321/******************************************************************************/
322/* This subroutine is used to add a record to a list of struct                */
323/*  listofincludebysubroutine                                                 */
324/******************************************************************************/
325/*                                                                            */
326/*       subroutine sub ... USE mod1 ===> insert in list                      */
327/*        _______     _______     _______     _______     _______             */
328/*       +      +    +      +    +      +    +      +    +      +             */
329/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
330/*       +______+    +______+    +______+    +______+    +______+             */
331/*                                                                            */
332/*       list =  listofmodulebysubroutine                                     */
333/*                                                                            */
334/******************************************************************************/
335void Addincludetothelist(char *name)
336{
337  listusemodule *newinclude;
338
339  newinclude =(listusemodule *)malloc(sizeof(listusemodule));
340  strcpy(newinclude->usemodule,name);
341  strcpy(newinclude->cursubroutine,subroutinename); 
342  newinclude->suiv = NULL;
343
344  if ( !listofincludebysubroutine)
345  {
346     listofincludebysubroutine  = newinclude ;
347  }
348  else
349  {
350    newinclude->suiv = listofincludebysubroutine;
351    listofincludebysubroutine = newinclude;
352  }
353}
354
355
356/******************************************************************************/
357/*                        WriteIncludeDeclaration                             */
358/******************************************************************************/
359/* Firstpass 0                                                                */
360/******************************************************************************/
361/*                                                                            */
362/******************************************************************************/
363void WriteIncludeDeclaration()
364{
365  listusemodule *newinclude;
366
367  newinclude = listofincludebysubroutine;
368  fprintf(fortranout,"\n");
369  while ( newinclude )
370  {
371     if ( !strcasecmp(newinclude->cursubroutine,subroutinename) )
372     {
373        fprintf(fortranout,"      INCLUDE %s \n",newinclude->usemodule);
374     }
375     newinclude = newinclude ->suiv; 
376  }
377}
Note: See TracBrowser for help on using the repository browser.