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 @ 530

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

RB: update of the conv for IOM and NEC MPI library

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.3 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@imag.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.0                                                                */
34/******************************************************************************/
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include "decl.h"
39
40/******************************************************************************/
41/*                           Addtolistvarcommon                               */
42/******************************************************************************/
43/*  This subroutines is used to add the variable defined in common in the     */
44/*     commonlist                                                             */
45/******************************************************************************/
46/*                                                                            */
47/******************************************************************************/
48void Addtolistvarcommon()
49{
50   listvarcommon *newvar;
51   
52   newvar = (listvarcommon *)malloc(sizeof(listvarcommon));
53   strcpy(newvar->nomvar,commonvar);
54   strcpy(newvar->commonname,commonblockname);
55   strcpy(newvar->subroutinename,subroutinename);
56   newvar->positioninblock= positioninblock;
57   newvar->suiv = NULL;
58
59   if ( !commonlist )
60   {
61      commonlist = newvar;
62   }
63   else
64   {
65      newvar->suiv = commonlist;
66      commonlist = newvar;
67   }
68}
69
70/******************************************************************************/
71/*                           Addtolistnom                                     */
72/******************************************************************************/
73/* This subroutine is used to add a variable to the list                      */
74/******************************************************************************/
75/*                                                                            */
76/******************************************************************************/
77listnom *Addtolistnom(char *nom, listnom *listin)
78{
79   listnom *newnom;
80   listnom *parcours;
81   int out;
82
83   newnom=(listnom *) malloc (sizeof (listnom));
84   strcpy(newnom->nom,nom);
85   newnom->suiv = NULL;
86
87   if ( !listin ) listin = newnom;
88   else
89   {
90      parcours = listin;
91      out = 0 ;
92      while ( parcours && out == 0 )
93      {
94         if ( !strcasecmp(parcours->nom,nom) ) out = 1 ;
95         else parcours=parcours->suiv;
96      }
97      if ( out == 0 ) 
98      {
99          newnom->suiv = listin;
100          listin = newnom;
101      }
102      else
103      {
104         free(newnom);
105      }
106   }
107   return listin;
108}
109
110/******************************************************************************/
111/*                           Addtolistname                                     */
112/******************************************************************************/
113/* This subroutine is used to add a        variable to the list               */
114/******************************************************************************/
115/*        _______     _______     _______     _______     _______             */
116/*       +      +    +      +    +      +    +      +    +      +             */
117/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
118/*       +______+    +______+    +______+    +______+    +______+             */
119/*                                                                            */
120/*                                                                            */
121/*                                                                            */
122/******************************************************************************/
123listname *Addtolistname(char *nom,listname *input)
124{
125   listname *newnom;
126   listname *parcours;
127   int out;
128
129   if ( !input )
130   {
131      newnom=(listname *) malloc (sizeof (listname));
132      strcpy(newnom->name,nom);
133      newnom->suiv = NULL;
134      input = newnom;
135   }
136   else
137   {
138      parcours = input;
139      out = 0 ;
140      while ( parcours && out == 0 )
141      {
142         if ( !strcasecmp(parcours->name,nom) ) out = 1;
143         else parcours=parcours->suiv;         
144      }
145      if ( out == 0 )
146      {
147         newnom=(listname *) malloc (sizeof (listname));
148         strcpy(newnom->name,nom);
149         newnom->suiv = input;
150         input = newnom;
151      }
152   }
153   return input;
154}
155
156/******************************************************************************/
157/*                    ModuleIsDefineInInputFile                               */
158/******************************************************************************/
159/* This subroutine is used to know if the module is defined in the input file */
160/******************************************************************************/
161/*                                                                            */
162/*                                                                            */
163/******************************************************************************/
164int ModuleIsDefineInInputFile(char *name)
165{
166   listnom *newnom;
167   int out;
168   
169   out = 0;
170   if ( listofmodules ) 
171   {
172      newnom = listofmodules;
173      while( newnom && out == 0 )
174      {
175         if ( !strcasecmp(newnom->nom,name) ) out = 1 ;
176         else newnom=newnom->suiv;
177      }
178   }
179   return out;
180}
181
182/******************************************************************************/
183/*                       AddNameToListNamelist_1                              */
184/******************************************************************************/
185/* This subroutine is used to add a listvar l at the end of a listvar         */
186/* glob.                                                                      */
187/*                                                                            */
188/******************************************************************************/
189/*        _______     _______     _______     _______     _______             */
190/*       +      +    +      +    +      +    +      +    +      +             */
191/*       + glob +--->+ glob +--->+ glob +--->+ glob +--->+  l   +             */
192/*       +______+    +______+    +______+    +______+    +______+             */
193/*                                                                            */
194/******************************************************************************/
195void AddNameToListNamelist_1(char * name)
196{
197   listnamelist *newvar;
198   
199   if ( firstpass == 1 )
200   {
201      if ( strcasecmp(name,"") )
202      {
203         newvar =(listnamelist*)malloc(sizeof(listnamelist));
204         strcpy(newvar->name,name);
205         newvar->suiv = listenamelist;
206         listenamelist = newvar;
207      }
208   }
209}
210
211/******************************************************************************/
212/*                      Addmoduletothelisttmp                                 */
213/******************************************************************************/
214/* This subroutine is used to add a record to a list of struct                */
215/* listusemodule                                                              */
216/******************************************************************************/
217/*                                                                            */
218/*       subroutine sub ... USE mod1 ===> insert in list                      */
219/*        _______     _______     _______     _______     _______             */
220/*       +      +    +      +    +      +    +      +    +      +             */
221/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
222/*       +______+    +______+    +______+    +______+    +______+             */
223/*                                                                            */
224/*       list =  listofmoduletmp                                              */
225/*                                                                            */
226/******************************************************************************/
227void Addmoduletothelisttmp(char *name)
228{
229  listusemodule *newmodule;
230  listusemodule *parcours;
231  int out;
232
233  if ( !listofmoduletmp)
234  {
235    newmodule =(listusemodule *)malloc(sizeof(listusemodule));
236    strcpy(newmodule->usemodule,name);
237    strcpy(newmodule->cursubroutine,subroutinename); 
238    newmodule->suiv = NULL;
239    listofmoduletmp = newmodule ;
240  }
241  else
242  {
243    parcours = listofmoduletmp;
244    out = 0;
245    while( parcours && out == 0 )
246    {
247       if ( !strcasecmp(parcours->usemodule,name) ) out = 1;
248       else parcours = parcours->suiv;
249    }
250    if ( out == 0 )
251    {
252       newmodule =(listusemodule *)malloc(sizeof(listusemodule));
253       strcpy(newmodule->usemodule,name);
254       strcpy(newmodule->cursubroutine,subroutinename); 
255       newmodule->suiv = listofmoduletmp;
256       listofmoduletmp = newmodule;
257    }
258  }
259}
260
261/******************************************************************************/
262/*                   Add_ModuleTo_Modulelist_1                                */
263/******************************************************************************/
264/* This subroutine is used to add a        variable to the list               */
265/******************************************************************************/
266/*        _______     _______     _______     _______     _______             */
267/*       +      +    +      +    +      +    +      +    +      +             */
268/*       + NEW  +--->+ glob +--->+ glob +--->+ glob +--->+ glob +             */
269/*       +______+    +______+    +______+    +______+    +______+             */
270/*                                                                            */
271/*                                                                            */
272/*                                                                            */
273/******************************************************************************/
274void Add_ModuleTo_Modulelist_1(char *nom)
275{
276   listnom *newnom;
277
278   if ( firstpass == 1 )
279   {
280      newnom=(listnom *) malloc (sizeof (listnom));
281      strcpy(newnom->nom,nom);
282      newnom->suiv = modulelist;
283      modulelist = newnom;   
284   }
285}
286
287/******************************************************************************/
288/*                 completelistvarpointtovar_1                                */
289/******************************************************************************/
290/* Firstpass 1                                                                */
291/* We should complete the listvarpointtovar                                   */ 
292/******************************************************************************/
293/*                                                                            */
294/******************************************************************************/
295void completelistvarpointtovar_1(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_1                                 */
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_1(char *name)
336{
337  listusemodule *newinclude;
338
339  if ( firstpass == 1 )
340  {
341  newinclude =(listusemodule *)malloc(sizeof(listusemodule));
342  strcpy(newinclude->usemodule,name);
343  strcpy(newinclude->cursubroutine,subroutinename); 
344  newinclude->suiv = NULL;
345
346  if ( !listofincludebysubroutine)
347  {
348     listofincludebysubroutine  = newinclude ;
349  }
350  else
351  {
352    newinclude->suiv = listofincludebysubroutine;
353    listofincludebysubroutine = newinclude;
354  }
355  }
356}
357
358
359/******************************************************************************/
360/*                        WriteIncludeDeclaration                             */
361/******************************************************************************/
362/* Firstpass 0                                                                */
363/******************************************************************************/
364/*                                                                            */
365/******************************************************************************/
366void WriteIncludeDeclaration()
367{
368  listusemodule *newinclude;
369
370  newinclude = listofincludebysubroutine;
371  fprintf(fortranout,"\n");
372  while ( newinclude )
373  {
374     if ( !strcasecmp(newinclude->cursubroutine,subroutinename) )
375     {
376        fprintf(fortranout,"      INCLUDE %s \n",newinclude->usemodule);
377     }
378     newinclude = newinclude ->suiv; 
379  }
380}
Note: See TracBrowser for help on using the repository browser.