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

source: trunk/AGRIF/LIB/WorkWithAllocatelist.c @ 2330

Last change on this file since 2330 was 774, checked in by rblod, 17 years ago

Update Agrif, see ticket:#39

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.9 KB
RevLine 
[396]1/******************************************************************************/
2/*                                                                            */
3/*     CONV (converter) for Agrif (Adaptive Grid Refinement In Fortran)       */
4/*                                                                            */
[663]5/* Copyright or   or Copr. Laurent Debreu (Laurent.Debreu@imag.fr)            */
6/*                        Cyril Mazauric (Cyril_Mazauric@yahoo.fr)            */
[530]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".                                                  */
[396]12/*                                                                            */
[530]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.                                                                 */
[396]18/*                                                                            */
[530]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.                                       */
[396]29/*                                                                            */
[530]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.           */
[396]32/******************************************************************************/
[774]33/* version 1.7                                                                */
[530]34/******************************************************************************/
[396]35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include "decl.h"
39
40/******************************************************************************/
[663]41/*                               Add_Allocate_Var_1                           */
[396]42/******************************************************************************/
43/* Firstpass 1                                                                */
44/******************************************************************************/
45/*                                                                            */
46/******************************************************************************/
[663]47void Add_Allocate_Var_1(char *nom,char *nommodule)
[396]48{
49   listallocate *newvar;
50   listallocate *parcours;
51   int out;
52
[663]53   if ( firstpass == 1 )
[396]54   {
[663]55      if ( !List_Allocate_Var )
[396]56      {
57         newvar = (listallocate *)malloc(sizeof(listallocate));
[663]58         strcpy(newvar->a_nomvar,nom);
[774]59         Save_Length(nom,25);
[663]60         strcpy(newvar->a_subroutine,subroutinename);
[774]61         Save_Length(subroutinename,26);
[663]62         strcpy(newvar->a_module,nommodule);
[774]63         Save_Length(nommodule,27);
[396]64         newvar->suiv = NULL;
[663]65         List_Allocate_Var = newvar;
[396]66      }
67      else
68      {
[663]69         parcours = List_Allocate_Var;
70         out = 0 ;
[396]71         while ( parcours->suiv && out == 0 )
72         {
[663]73            if (  !strcasecmp(parcours->a_nomvar,nom) &&
74                  !strcasecmp(parcours->a_subroutine,subroutinename) &&
75                  !strcasecmp(parcours->a_module,nommodule) ) out = 1;
[396]76            else
[663]77               parcours=parcours->suiv;
[396]78         }
[663]79         if ( out == 0 )
[396]80         {
[663]81            if (  !strcasecmp(parcours->a_nomvar,nom) &&
82                  !strcasecmp(parcours->a_subroutine,subroutinename) &&
83                  !strcasecmp(parcours->a_module,nommodule) ) out = 1;
[396]84            else
85            {
86               /* add the record                                              */
87              newvar = (listallocate *)malloc(sizeof(listallocate));
[663]88              strcpy(newvar->a_nomvar,nom);
[774]89              Save_Length(nom,25);
[663]90              strcpy(newvar->a_subroutine,subroutinename);
[774]91              Save_Length(subroutinename,26);
[663]92              strcpy(newvar->a_module,nommodule);
[774]93              Save_Length(nommodule,27);
[396]94              newvar->suiv = NULL;
95              parcours->suiv = newvar;
96            }
97         }
98      }
99   }
100}
101
102
103/******************************************************************************/
[530]104/*                            IsVarAllocatable_0                              */
[396]105/******************************************************************************/
106/* Firstpass 0                                                                */
107/******************************************************************************/
108/*                                                                            */
109/******************************************************************************/
[530]110int IsVarAllocatable_0(char *ident)
[396]111{
112   listallocate *parcours;
113   int out;
114
[663]115   out = 0 ;
116   if ( firstpass == 0 )
[396]117   {
[663]118      parcours = List_Allocate_Var;
[396]119      while ( parcours && out == 0 )
120      {
[663]121         if ( !strcasecmp(parcours->a_nomvar,ident)  ) out = 1 ;
122         else parcours=parcours->suiv;
[396]123      }
124   }
125   return out;
126}
127
128
129/******************************************************************************/
[530]130/*                          varisallocatable_0                                */
[396]131/******************************************************************************/
132/* Firstpass 0                                                                */
133/******************************************************************************/
134/*                                                                            */
135/******************************************************************************/
[530]136int varisallocatable_0(char *ident)
[396]137{
138   listallocate *newvaralloc;
139   int out;
140
141   out =0;
142   if (firstpass == 0 )
143   {
[663]144         newvaralloc = List_Allocate_Var;
145         while ( newvaralloc && out == 0 )
[396]146         {
[663]147            if ( !strcasecmp(ident,newvaralloc->a_nomvar) )  out = 1;
[396]148            else newvaralloc = newvaralloc->suiv;
[663]149         }
[396]150   }
151   return out;
152}
Note: See TracBrowser for help on using the repository browser.