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.
Changeset 8139 for branches/2017/dev_r8126_UKMO_AGRIF_vert_interp/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilListe.c – NEMO

Ignore:
Timestamp:
2017-06-05T12:05:17+02:00 (7 years ago)
Author:
timgraham
Message:

Updates to conv library as received from Laurent - required for vertical refinement

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_r8126_UKMO_AGRIF_vert_interp/NEMOGCM/EXTERNAL/AGRIF/LIB/UtilListe.c

    r5656 r8139  
    5252   strcpy(var->v_subroutinename     , ""); 
    5353   strcpy(var->v_precision          , ""); 
    54    strcpy(var->v_initialvalue       , ""); 
     54   var->v_initialvalue = (listname *)NULL; 
     55   var->v_initialvalue_array = (listname *)NULL; 
     56   var->v_do_loop = NULL; 
    5557   strcpy(var->v_IntentSpec         , ""); 
    5658   strcpy(var->v_readedlistdimension, ""); 
     
    103105            newvar->suiv = l; 
    104106        } 
     107        newvar=glob; 
     108        while (newvar) 
     109        { 
     110        newvar=newvar->suiv; 
     111        } 
    105112    } 
    106113    return glob; 
     
    117124void CreateAndFillin_Curvar(const char *type, variable *curvar) 
    118125{ 
     126listname *newvar; 
     127 
    119128    if ( !strcasecmp(type, "character") && strcasecmp(CharacterSize, "") ) 
    120129    { 
     
    150159    if (InitialValueGiven == 1 ) 
    151160    { 
    152         strcpy(curvar->v_initialvalue,InitValue); 
     161    curvar->v_initialvalue=Insertname(curvar->v_initialvalue,InitValue,0); 
     162     
     163//        strcpy(curvar->v_initialvalue,InitValue); 
     164         
    153165        Save_Length(InitValue,14); 
    154166    } 
     
    481493      v = newvar->var; 
    482494      strcpy(v->v_typevar,nom); 
     495       
    483496      v->v_catvar = get_cat_var(v); 
     497 
    484498      newvar = newvar->suiv; 
    485499   } 
     
    502516   { 
    503517      v=newvar->var; 
    504       printf("nom = %s, allocatable = %d dim = %s\n",v->v_nomvar,v->v_allocatable,(v->v_dimension)->dim.last); 
    505518      newvar=newvar->suiv; 
    506519   } 
     
    564577} 
    565578 
     579int testandextractfromlist(listname **lin, char*nom) 
     580{ 
     581listname *newvar; 
     582int val_1, val_2; 
     583int return_stmt; 
     584 
     585printname(*lin); 
     586if (!(*lin)) 
     587 { 
     588  return 0; 
     589 } 
     590else 
     591 { 
     592 sscanf(nom,"%d",&val_1); 
     593 sscanf((*lin)->n_name,"%d",&val_2); 
     594 if (val_1==val_2) 
     595   { 
     596/*   newvar = *lin; 
     597   *lin = (*lin)->suiv; 
     598   free(newvar);*/ 
     599   /* continue to remove while the label stays the same */ 
     600/*   return_stmt=testandextractfromlist(lin,nom);*/ 
     601   return 1; 
     602   } 
     603 else 
     604  { 
     605  return 0; 
     606  } 
     607 } 
     608} 
     609 
     610void removefromlist(listname **lin, char*nom) 
     611{ 
     612listname *newvar,*prev; 
     613int val_1, val_2; 
     614int return_stmt; 
     615int out; 
     616 
     617printname(*lin); 
     618if (*lin) 
     619 { 
     620 sscanf(nom,"%d",&val_1); 
     621 prev=(listname *) calloc(1,sizeof(listname)); 
     622 prev->suiv=*lin; 
     623 *lin=prev; 
     624 newvar=(*lin)->suiv; 
     625 out = 0; 
     626 while (newvar && out == 0) 
     627 { 
     628 sscanf((newvar)->n_name,"%d",&val_2); 
     629 if (val_1==val_2) 
     630   { 
     631   prev->suiv=newvar->suiv; 
     632   free(newvar); 
     633   } 
     634  if (prev->suiv)  
     635    { 
     636    prev=prev->suiv; 
     637    newvar=prev->suiv; 
     638    } 
     639   else 
     640   { 
     641   out = 1; 
     642   } 
     643  } 
     644 prev=*lin; 
     645 *lin=(*lin)->suiv; 
     646 free(prev); 
     647 } 
     648} 
     649 
    566650listname *concat_listname(listname *l1, listname *l2) 
    567651{ 
     
    606690   while (newvar) 
    607691   { 
    608       printf("nom = %s \n",newvar->n_name); 
    609692      newvar=newvar->suiv; 
    610693   } 
     
    694777int get_cat_var(variable *var) 
    695778{ 
     779 
    696780    if (!strcasecmp(var->v_typevar, "CHARACTER")) 
    697781        return 1; 
     
    705789        return 0; 
    706790} 
     791 
     792void Insertdoloop(variable *var,char *do_var,char *do_begin, char *do_end, char *do_step) 
     793{ 
     794listdoloop *new_do_loop; 
     795listdoloop *tmploop; 
     796new_do_loop = (listdoloop *) calloc(1,sizeof(listdoloop)); 
     797 
     798new_do_loop->cur_do_loop = (do_loop *) calloc(1,sizeof(do_loop)); 
     799 
     800strcpy(new_do_loop->cur_do_loop->do_variable,do_var); 
     801strcpy(new_do_loop->cur_do_loop->do_begin,do_begin); 
     802strcpy(new_do_loop->cur_do_loop->do_end,do_end); 
     803strcpy(new_do_loop->cur_do_loop->do_step,do_step); 
     804new_do_loop->suiv = NULL; 
     805 
     806if (!var->v_do_loop) 
     807{ 
     808  var->v_do_loop = new_do_loop; 
     809} 
     810else 
     811{ 
     812  new_do_loop->suiv = var->v_do_loop; 
     813  var->v_do_loop = new_do_loop; 
     814       
     815//   tmploop = var->v_do_loop; 
     816//   while (tmploop->suiv) 
     817//   { 
     818//     tmploop=tmploop->suiv; 
     819//   } 
     820//   tmploop->suiv = new_do_loop ; 
     821//   } 
     822} 
     823} 
Note: See TracChangeset for help on using the changeset viewer.