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

source: trunk/AGRIF/LIB/WorkWithlistofmodulebysubroutine.c @ 530

Last change on this file since 530 was 530, checked in by opalod, 17 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: 11.5 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
39#include "decl.h"
40
41
42
43/******************************************************************************/
44/*                    RecordUseModulesVariables                               */
45/******************************************************************************/
46/******************************************************************************/
47void RecordUseModulesVariables()
48{
49  listusemodule *tmplistmodule;
50
51  /* we should record all variables defined in modules used in this file      */
52  if ( listofmodulebysubroutine )
53  {
54     listofvarofusemodulecreated = 1;
55     tmplistmodule = listofmodulebysubroutine;
56     while ( tmplistmodule )
57     {
58        if ( tmplistmodule->firstuse == 1 )
59        {
60           /* check if the file .depend<usemodule> exist                      */
61           globalvarofusefile = Readthedependfile
62                                  (tmplistmodule->usemodule,globalvarofusefile);
63
64           tmpparameterlocallist = ReaddependParameterList
65                               (tmplistmodule->usemodule,tmpparameterlocallist);
66
67        }
68
69        tmplistmodule = tmplistmodule->suiv;
70     }
71  }
72}
73
74/******************************************************************************/
75/*                RecordUseModulesUseModulesVariables                         */
76/******************************************************************************/
77/******************************************************************************/
78void  RecordUseModulesUseModulesVariables()
79{
80  listusemodule *tmplistmodule;
81  listusemodule *tmplistmodule1;
82
83  /* we should record all variables defined in modules used in this file      */
84  if ( listofmodulebysubroutine )
85  {
86     /* and we should read the .depend of the module used by the module used  */
87     tmplistmodule = listofmodulebysubroutine;
88     while ( tmplistmodule )
89     {
90        Readthedependlistofmoduleused(tmplistmodule->usemodule);
91        while( tmpuselocallist )
92        {
93           Addmoduletothelisttmp(tmpuselocallist->usemodule);
94      tmplistmodule1 = tmpuselocallist->suiv;
95      free(tmpuselocallist);
96           tmpuselocallist = tmplistmodule1;
97        }
98        tmplistmodule = tmplistmodule->suiv;
99     }
100           
101     tmplistmodule = listofmoduletmp;
102     while ( tmplistmodule )
103     {
104        /* check if the file .depend<usemodule> exist                         */
105        globalvarofusefile2 = Readthedependfile
106                                 (tmplistmodule->usemodule,globalvarofusefile2);
107
108        tmpparameterlocallist2 = ReaddependParameterList
109                              (tmplistmodule->usemodule,tmpparameterlocallist2);
110       
111        tmplistmodule = tmplistmodule->suiv;
112     }
113  }
114}
115
116
117/******************************************************************************/
118/*                      Addmoduletothelist_1                                  */
119/******************************************************************************/
120/* This subroutine is used to add a record to a list of struct                */
121/* listusemodule                                                              */
122/******************************************************************************/
123/*                                                                            */
124/*       subroutine sub ... USE mod1 ===> insert in list                      */
125/*        _______     _______     _______     _______     _______             */
126/*       +      +    +      +    +      +    +      +    +      +             */
127/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
128/*       +______+    +______+    +______+    +______+    +______+             */
129/*                                                                            */
130/*       list =  listofmodulebysubroutine                                     */
131/*                                                                            */
132/******************************************************************************/
133void Addmoduletothelist_1(char *name)
134{
135  listusemodule *newmodule;
136  listusemodule *parcours;
137  int out;
138
139  if ( firstpass == 1 )
140  {
141     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
142     strcpy(newmodule->usemodule,name);
143     strcpy(newmodule->charusemodule,charusemodule);
144     strcpy(newmodule->cursubroutine,subroutinename); 
145     newmodule->firstuse = 1 ; 
146     newmodule->suiv = NULL;
147
148     if ( !listofmodulebysubroutine)
149     {
150         listofmodulebysubroutine = newmodule ;
151     }
152     else
153     {
154    parcours = listofmodulebysubroutine;
155    while ( parcours && newmodule->firstuse == 1 )
156    {
157       if ( !strcasecmp(name,parcours->usemodule) ) 
158       {
159          newmodule->firstuse = 0 ;
160       }
161       parcours=parcours->suiv;
162    }
163    /* we can not add the same module twice for the same subroutine           */
164    parcours = listofmodulebysubroutine;
165    out = 0 ;
166    while ( parcours && out == 0 )
167    {
168       if ( !strcasecmp(name,parcours->usemodule) &&
169            !strcasecmp(subroutinename,parcours->cursubroutine)
170           )
171       {
172          out = 1 ;
173          free(newmodule);
174       }
175       else parcours=parcours->suiv;
176    }
177    if ( out == 0 )
178    {
179       newmodule->suiv = listofmodulebysubroutine;
180       listofmodulebysubroutine = newmodule;
181    }
182  }
183  }
184}
185
186
187/******************************************************************************/
188/*                        Addmoduletothelist                                  */
189/******************************************************************************/
190/* This subroutine is used to add a record to a list of struct                */
191/* listusemodule                                                              */
192/******************************************************************************/
193/*                                                                            */
194/*       subroutine sub ... USE mod1 ===> insert in list                      */
195/*        _______     _______     _______     _______     _______             */
196/*       +      +    +      +    +      +    +      +    +      +             */
197/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
198/*       +______+    +______+    +______+    +______+    +______+             */
199/*                                                                            */
200/*       list =  listofmodulebysubroutine                                     */
201/*                                                                            */
202/******************************************************************************/
203void Addmoduletothelist(char *name)
204{
205  listusemodule *newmodule;
206  listusemodule *parcours;
207  int out;
208
209     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
210     strcpy(newmodule->usemodule,name);
211     strcpy(newmodule->charusemodule,charusemodule);
212     strcpy(newmodule->cursubroutine,subroutinename); 
213     newmodule->firstuse = 1 ; 
214     newmodule->suiv = NULL;
215
216     if ( !listofmodulebysubroutine)
217     {
218         listofmodulebysubroutine = newmodule ;
219     }
220     else
221     {
222    parcours = listofmodulebysubroutine;
223    while ( parcours && newmodule->firstuse == 1 )
224    {
225       if ( !strcasecmp(name,parcours->usemodule) ) 
226       {
227          newmodule->firstuse = 0 ;
228       }
229       parcours=parcours->suiv;
230    }
231    /* we can not add the same module twice for the same subroutine           */
232    parcours = listofmodulebysubroutine;
233    out = 0 ;
234    while ( parcours && out == 0 )
235    {
236       if ( !strcasecmp(name,parcours->usemodule) &&
237            !strcasecmp(subroutinename,parcours->cursubroutine)
238           )
239       {
240          out = 1 ;
241          free(newmodule);
242       }
243       else parcours=parcours->suiv;
244    }
245    if ( out == 0 )
246    {
247       newmodule->suiv = listofmodulebysubroutine;
248       listofmodulebysubroutine = newmodule;
249    }
250  }
251}
252
253
254/******************************************************************************/
255/*                        WriteUsemoduleDeclaration                           */
256/******************************************************************************/
257/* Firstpass 0                                                                */
258/******************************************************************************/
259/*                                                                            */
260/******************************************************************************/
261void WriteUsemoduleDeclaration()
262{
263  listusemodule *newmodule;
264
265  newmodule = listofmodulebysubroutine;
266  fprintf(fortranout,"\n");
267  while ( newmodule )
268  {
269     if ( !strcasecmp(newmodule->cursubroutine,subroutinename) )
270     {
271        if ( strcasecmp(newmodule->charusemodule,"Agrif_Util") ||
272            adduseagrifutil != 1 ) fprintf(fortranout,"      USE %s \n"
273                                                     ,newmodule->charusemodule);
274     }
275        newmodule = newmodule ->suiv; 
276  }
277}
Note: See TracBrowser for help on using the repository browser.