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 branches/dev_001_GM/AGRIF/LIB – NEMO

source: branches/dev_001_GM/AGRIF/LIB/WorkWithlistofmodulebysubroutine.c @ 4310

Last change on this file since 4310 was 663, checked in by opalod, 17 years ago

RB: update CONV

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.0 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.6                                                                */
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/*                                                                            */
47/******************************************************************************/
48void RecordUseModulesVariables()
49{
50  listusemodule *tmplistmodule;
51
52  /* we should record all variables defined in modules used in this file      */
53  if ( List_NameOfModuleUsed )
54  {
55     tmplistmodule = List_NameOfModuleUsed;
56     while ( tmplistmodule )
57     {
58        if ( tmplistmodule->u_firstuse == 1 )
59        {
60           /* check if the file .depend<u_usemodule> exist                    */
61           List_ModuleUsed_Var = Readthedependfile
62                               (tmplistmodule->u_usemodule,List_ModuleUsed_Var);
63
64           List_GlobParamModuleUsed_Var = ReaddependParameterList
65                      (tmplistmodule->u_usemodule,List_GlobParamModuleUsed_Var);
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 ( List_NameOfModuleUsed )
85  {
86     /* and we should read the .depend of the module used by the module used  */
87     tmplistmodule = List_NameOfModuleUsed;
88     while ( tmplistmodule )
89     {
90        Readthedependlistofmoduleused(tmplistmodule->u_usemodule);
91        while( tmpuselocallist )
92        {
93           Addmoduletothelisttmp(tmpuselocallist->u_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        Readthedependlistofmoduleused(tmplistmodule->u_usemodule);
105        while( tmpuselocallist )
106        {
107           Addmoduletothelisttmp(tmpuselocallist->u_usemodule);
108           tmplistmodule1 = tmpuselocallist->suiv;
109           free(tmpuselocallist);
110           tmpuselocallist = tmplistmodule1;
111        }
112        tmplistmodule = tmplistmodule->suiv;
113     }
114
115
116
117     tmplistmodule = listofmoduletmp;
118     while ( tmplistmodule )
119     {
120        /* check if the file .depend<u_usemodule> exist                       */
121        List_ModuleUsedInModuleUsed_Var = Readthedependfile
122                   (tmplistmodule->u_usemodule,List_ModuleUsedInModuleUsed_Var);
123
124        List_GlobParamModuleUsedInModuleUsed_Var = ReaddependParameterList
125          (tmplistmodule->u_usemodule,List_GlobParamModuleUsedInModuleUsed_Var);
126        tmplistmodule = tmplistmodule->suiv;
127     }
128  }
129}
130
131/******************************************************************************/
132/*                      Add_NameOfModuleUsed_1                                */
133/******************************************************************************/
134/* This subroutine is used to add a record to a list of struct                */
135/* listusemodule                                                              */
136/******************************************************************************/
137/*                                                                            */
138/*       subroutine sub ... USE mod1 ===> insert in list                      */
139/*        _______     _______     _______     _______     _______             */
140/*       +      +    +      +    +      +    +      +    +      +             */
141/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
142/*       +______+    +______+    +______+    +______+    +______+             */
143/*                                                                            */
144/*       list =  List_NameOfModuleUsed                                        */
145/*                                                                            */
146/******************************************************************************/
147void Add_NameOfModuleUsed_1(char *name)
148{
149  listusemodule *newmodule;
150  listusemodule *parcours;
151  int out;
152
153  if ( firstpass == 1 )
154  {
155     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
156     strcpy(newmodule->u_usemodule,name);
157     strcpy(newmodule->u_charusemodule,charusemodule);
158     strcpy(newmodule->u_modulename,curmodulename);
159     strcpy(newmodule->u_cursubroutine,subroutinename);
160     newmodule->u_firstuse = 1 ;
161     newmodule->suiv = NULL;
162
163     if ( !List_NameOfModuleUsed)
164     {
165         List_NameOfModuleUsed = newmodule ;
166     }
167     else
168     {
169    parcours = List_NameOfModuleUsed;
170    while ( parcours && newmodule->u_firstuse == 1 )
171    {
172       if ( !strcasecmp(name,parcours->u_usemodule) )
173       {
174          newmodule->u_firstuse = 0 ;
175       }
176       parcours=parcours->suiv;
177    }
178    /* we can not add the same module twice for the same subroutine           */
179    parcours = List_NameOfModuleUsed;
180    out = 0 ;
181    while ( parcours && out == 0 )
182    {
183       if ( !strcasecmp(name,parcours->u_usemodule) &&
184            !strcasecmp(subroutinename,parcours->u_cursubroutine)
185           )
186       {
187          out = 1 ;
188          free(newmodule);
189       }
190       else parcours=parcours->suiv;
191    }
192    if ( out == 0 )
193    {
194       newmodule->suiv = List_NameOfModuleUsed;
195       List_NameOfModuleUsed = newmodule;
196    }
197  }
198  }
199}
200
201
202/******************************************************************************/
203/*                        Addmoduletothelist                                  */
204/******************************************************************************/
205/* This subroutine is used to add a record to a list of struct                */
206/* listusemodule                                                              */
207/******************************************************************************/
208/*                                                                            */
209/*       subroutine sub ... USE mod1 ===> insert in list                      */
210/*        _______     _______     _______     _______     _______             */
211/*       +      +    +      +    +      +    +      +    +      +             */
212/*       + NEW  +--->+ list +--->+ list +--->+ list +--->+ list +             */
213/*       +______+    +______+    +______+    +______+    +______+             */
214/*                                                                            */
215/*       list =  List_NameOfModuleUsed                                     */
216/*                                                                            */
217/******************************************************************************/
218void Addmoduletothelist(char *name)
219{
220  listusemodule *newmodule;
221  listusemodule *parcours;
222  int out;
223
224     newmodule =(listusemodule *)malloc(sizeof(listusemodule));
225     strcpy(newmodule->u_usemodule,name);
226     strcpy(newmodule->u_charusemodule,charusemodule);
227     strcpy(newmodule->u_cursubroutine,subroutinename);
228     newmodule->u_firstuse = 1 ;
229     newmodule->suiv = NULL;
230
231     if ( !List_NameOfModuleUsed)
232     {
233         List_NameOfModuleUsed = newmodule ;
234     }
235     else
236     {
237    parcours = List_NameOfModuleUsed;
238    while ( parcours && newmodule->u_firstuse == 1 )
239    {
240       if ( !strcasecmp(name,parcours->u_usemodule) )
241       {
242          newmodule->u_firstuse = 0 ;
243       }
244       parcours=parcours->suiv;
245    }
246    /* we can not add the same module twice for the same subroutine           */
247    parcours = List_NameOfModuleUsed;
248    out = 0 ;
249    while ( parcours && out == 0 )
250    {
251       if ( !strcasecmp(name,parcours->u_usemodule) &&
252            !strcasecmp(subroutinename,parcours->u_cursubroutine)
253           )
254       {
255          out = 1 ;
256          free(newmodule);
257       }
258       else parcours=parcours->suiv;
259    }
260    if ( out == 0 )
261    {
262       newmodule->suiv = List_NameOfModuleUsed;
263       List_NameOfModuleUsed = newmodule;
264    }
265  }
266}
267
268
269/******************************************************************************/
270/*                        WriteUsemoduleDeclaration                           */
271/******************************************************************************/
272/* Firstpass 0                                                                */
273/******************************************************************************/
274/*                                                                            */
275/******************************************************************************/
276void WriteUsemoduleDeclaration()
277{
278  listusemodule *newmodule;
279
280  newmodule = List_NameOfModuleUsed;
281  fprintf(fortranout,"\n");
282  while ( newmodule )
283  {
284     if ( !strcasecmp(newmodule->u_cursubroutine,subroutinename) )
285     {
286             fprintf(fortranout,"      USE %s \n"
287                                                   ,newmodule->u_charusemodule);
288     }
289        newmodule = newmodule ->suiv;
290  }
291}
Note: See TracBrowser for help on using the repository browser.