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 774 for trunk/AGRIF/LIB/toamr.c – NEMO

Ignore:
Timestamp:
2007-12-18T17:45:53+01:00 (16 years ago)
Author:
rblod
Message:

Update Agrif, see ticket:#39

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AGRIF/LIB/toamr.c

    r663 r774  
    3131/* knowledge of the CeCILL-C license and that you accept its terms.           */ 
    3232/******************************************************************************/ 
    33 /* version 1.6                                                                */ 
     33/* version 1.7                                                                */ 
    3434/******************************************************************************/ 
    3535#include <stdlib.h> 
     
    3737#include <string.h> 
    3838#include "decl.h" 
    39 char lvargridname[LONGNOM]; 
    40 char lvargridname2[LONGNOM]; 
     39char lvargridname[LONG_4C]; 
     40char lvargridname2[LONG_4C]; 
    4141 
    4242 
     
    5454  char *ligne; 
    5555 
    56   ligne = (char *) malloc (LONGLIGNE * sizeof (char)); 
     56  ligne = (char *) malloc (LONG_C * sizeof (char)); 
    5757  sprintf (ligne, "Agrif_Mygrid %% tabvars(%d) %% var ", var->v_indicetabvars); 
    5858  return ligne; 
     
    7575  char *ligne; 
    7676 
    77   ligne = (char *) malloc (LONGLIGNE * sizeof (char)); 
     77  ligne = (char *) malloc (LONG_C * sizeof (char)); 
    7878  if ( iorindice == 0 ) sprintf (ligne, " Agrif_Gr %% tabvars(%d)%% var", 
    7979                                 var->v_indicetabvars); 
     
    9595  char *ligne; 
    9696 
    97   ligne = (char *) malloc (LONGLIGNE * sizeof (char)); 
     97  ligne = (char *) malloc (LONG_C * sizeof (char)); 
    9898  if ( ParentOrCurgrid == 0 ) sprintf (ligne, " Agrif_tabvars(%d) %% var", 
    9999                              var->v_indicetabvars); 
     
    112112} 
    113113 
     114void WARNING_CharSize(variable *var) 
     115{ 
     116   if ( var->v_nbdim == 0 ) 
     117   { 
     118      if ( convert2int(var->v_dimchar) > 2050 ) 
     119      { 
     120         printf("WARNING : The dimension of the character  %s   \n", 
     121                                                              var->v_nomvar); 
     122         printf("   is upper than 2050. You must change         \n"); 
     123         printf("   the dimension of carray0                    \n"); 
     124         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n"); 
     125         printf("   line 247. Replace 300 with %d.              \n", 
     126                                            convert2int(var->v_dimchar)+100); 
     127      } 
     128      Save_Length_int(convert2int(var->v_dimchar),1); 
     129   } 
     130   else if ( var->v_nbdim == 1 ) 
     131   { 
     132      if ( convert2int(var->v_dimchar) > 300 ) 
     133      { 
     134         printf("WARNING : The dimension of the character  %s   \n", 
     135                                                              var->v_nomvar); 
     136         printf("   is upper than 300. You must change          \n"); 
     137         printf("   the dimension of carray1                    \n"); 
     138         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n"); 
     139         printf("   line 247. Replace 300 with %d.              \n", 
     140                                            convert2int(var->v_dimchar)+100); 
     141      } 
     142      Save_Length_int(convert2int(var->v_dimchar),2); 
     143   } 
     144   else if ( var->v_nbdim == 2 ) 
     145   { 
     146      if ( convert2int(var->v_dimchar) > 300 ) 
     147      { 
     148         printf("WARNING : The dimension of the character  %s   \n", 
     149                                                              var->v_nomvar); 
     150         printf("   is upper than 300. You must change          \n"); 
     151         printf("   the dimension of carray2                    \n"); 
     152         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n"); 
     153         printf("   line 247. Replace 300 with %d.              \n", 
     154                                            convert2int(var->v_dimchar)+100); 
     155      } 
     156      Save_Length_int(convert2int(var->v_dimchar),3); 
     157   } 
     158   else if ( var->v_nbdim == 3 ) 
     159   { 
     160      if ( convert2int(var->v_dimchar) > 300 ) 
     161      { 
     162         printf("WARNING : The dimension of the character  %s   \n", 
     163                                                              var->v_nomvar); 
     164         printf("   is upper than 300. You must change          \n"); 
     165         printf("   the dimension of carray3                    \n"); 
     166         printf("   in the file AGRIF/AGRIF_FILES/modtypes.F    \n"); 
     167         printf("   line 247. Replace 300 with %d.              \n", 
     168                                            convert2int(var->v_dimchar)+100); 
     169      } 
     170      Save_Length_int(convert2int(var->v_dimchar),4); 
     171   } 
     172} 
    114173/******************************************************************************/ 
    115174/*                           vargridnametabvars                               */ 
     
    126185{ 
    127186  char *tmp; 
    128   char tmp1[LONGNOM]; 
     187  char tmp1[LONG_C]; 
    129188 
    130189  tmp = variablenametabvars (var,iorindice); 
     
    151210  else if (!strcasecmp (var->v_typevar, "CHARACTER")) 
    152211    { 
     212      WARNING_CharSize(var); 
    153213      sprintf (lvargridname2, "%% carray%d", var->v_nbdim); 
    154214    } 
     
    156216  strcat (lvargridname, lvargridname2); 
    157217 
     218  Save_Length(lvargridname,42); 
     219  Save_Length(lvargridname2,42); 
    158220  return lvargridname; 
    159221} 
     
    175237{ 
    176238  char *tmp; 
    177   char tmp1[LONGNOM]; 
     239  char tmp1[LONG_C]; 
    178240 
    179241  tmp = variablecurgridtabvars (var,ParentOrCurgrid); 
     
    200262  else if (!strcasecmp (var->v_typevar, "CHARACTER")) 
    201263    { 
     264      WARNING_CharSize(var); 
    202265      sprintf (lvargridname2, "%% carray%d", var->v_nbdim); 
    203266    } 
     
    205268  strcat (lvargridname, lvargridname2); 
    206269 
     270  Save_Length(lvargridname,42); 
     271  Save_Length(lvargridname2,42); 
    207272  return lvargridname; 
    208273} 
     
    238303  else if (!strcasecmp (var->v_typevar, "CHARACTER")) 
    239304    { 
     305      WARNING_CharSize(var); 
    240306      sprintf (lvargridname2, "%% carray%d", var->v_nbdim); 
    241307    } 
     
    243309  strcat (lvargridname, lvargridname2); 
    244310 
     311  Save_Length(lvargridname,42); 
     312  Save_Length(lvargridname2,42); 
    245313  return lvargridname; 
    246314} 
     
    260328  typedim dim; 
    261329  listdim *newdim; 
    262   char newname[LONGNOM]; 
     330  char newname[LONG_4C]; 
    263331 
    264332  newdim = v->v_dimension; 
     
    305373                       (dim.last, List_ModuleUsed_Var,whichone)); 
    306374     } 
     375     Save_Length(tmpvargridname,46); 
    307376     strcat (tmpvargridname, newname); 
    308377     newdim = newdim->suiv; 
     
    311380  strcat (tmpvargridname, ")"); 
    312381  strcat (tmpvargridname, "\0"); 
     382  Save_Length(tmpvargridname,40); 
    313383  return tmpvargridname; 
    314384} 
     
    328398{ 
    329399  FILE *probdim; 
    330   char ligne[LONGLIGNE*100]; 
     400  char ligne[LONG_C]; 
    331401 
    332402  probdim = associate("probdim_agrif.h"); 
     
    376446void write_modtypeagrif_file() 
    377447{ 
    378   char ligne[LONGLIGNE*100]; 
     448  char ligne[LONG_C]; 
    379449  FILE *typedata; 
    380450 
     
    398468                                                       int *InitEmpty) 
    399469{ 
    400   char ligne[LONGLIGNE*100]; 
     470  char ligne[LONG_C]; 
    401471  char *tmp; 
    402   char temp1[LONGLIGNE]; 
     472  char temp1[LONG_C]; 
    403473 
    404474  tmp =  variablenametabvars(v,0); 
     
    420490/*                                                                            */ 
    421491/******************************************************************************/ 
    422 void write_Setnumberofcells_file() 
    423 { 
    424   char ligne[LONGLIGNE*100]; 
     492void write_Setnumberofcells_file(char *name) 
     493{ 
     494  char ligne[LONG_C]; 
    425495  FILE *setnumberofcells; 
    426496 
    427497  if ( IndicenbmaillesX != 0 ) 
    428498  { 
    429   setnumberofcells=associate("SetNumberofcells.h"); 
     499  setnumberofcells=associate(name); 
    430500 
    431501  if (onlyfixedgrids != 1 ) 
     
    489559/*                                                                            */ 
    490560/******************************************************************************/ 
    491 void write_Getnumberofcells_file() 
    492 { 
    493   char ligne[LONGLIGNE*100]; 
     561void write_Getnumberofcells_file(char *name) 
     562{ 
     563  char ligne[LONG_C]; 
    494564  FILE *getnumberofcells; 
    495565 
    496566  if ( IndicenbmaillesX != 0 ) 
    497567  { 
    498   getnumberofcells=associate("GetNumberofcells.h"); 
     568  getnumberofcells=associate(name); 
    499569  sprintf (ligne, 
    500570           "Agrif_Curgrid %% tabvars(%d) %% var %% iarray0 = Agrif_Gr %% nb(1)", 
     
    533603                                     int *VarnameEmpty) 
    534604{ 
    535   char ligne[LONGLIGNE*100]; 
    536   char temp1[LONGLIGNE]; 
     605  char ligne[LONG_C]; 
     606  char temp1[LONG_C]; 
    537607  char *tmp; 
    538608 
     
    605675   int indiceprec; 
    606676   int ValeurMax; 
    607    char initialvalue[LONGNOM]; 
     677   char initialvalue[LONG_4C]; 
    608678   listindice *list_indic; 
    609679   listindice *parcoursindic; 
    610680   int i; 
    611681 
     682   parcoursprec = (listvar *)NULL; 
    612683   parcours_nom = List_NameOfCommon; 
    613684   ValeurMax = 2; 
     
    652723        strcat (ligne, vargridnametabvars(v,0)); 
    653724        strcat (ligne, "))                       then"); 
     725        Save_Length(ligne,48); 
    654726        tofich (allocationagrif, ligne,1); 
    655727     } 
     
    700772                 strcat (ligne, vargridparam(v,0)); 
    701773                 strcat (ligne, ")"); 
     774                 Save_Length(ligne,48); 
    702775                 tofich (allocationagrif, ligne,1); 
    703776                 fprintf(allocationagrif,"      end do\n"); 
     
    721794                 strcat (ligne, vargridparam(v,0)); 
    722795                 strcat (ligne, ")"); 
     796                 Save_Length(ligne,48); 
    723797                 tofich (allocationagrif, ligne,1); 
    724798                 /*                                                           */ 
     
    759833           strcat (ligne,initialvalue); 
    760834           /*                                                                 */ 
     835           Save_Length(ligne,48); 
    761836           tofich (allocationagrif, ligne,1); 
    762837        } 
     
    801876   int indiceprec; 
    802877   int ValeurMax; 
    803    char initialvalue[LONGNOM]; 
    804  
     878   char initialvalue[LONG_4C]; 
     879 
     880   parcoursprec = (listvar *)NULL; 
    805881   parcours_nom = List_NameOfModule; 
    806882   ValeurMax = 2; 
     
    849925        strcat (ligne, vargridnametabvars(v,0)); 
    850926        strcat (ligne, "))                       then"); 
     927        Save_Length(ligne,48); 
    851928        tofich (allocationagrif, ligne,1); 
    852929     } 
     
    896973                 strcat (ligne, vargridparam(v,0)); 
    897974                 strcat (ligne, ")"); 
     975                 Save_Length(ligne,48); 
    898976                 tofich (allocationagrif, ligne,1); 
    899977                 fprintf(allocationagrif,"      end do\n"); 
     
    907985                 strcat (ligne, vargridparam(v,0)); 
    908986                 strcat (ligne, ")"); 
     987                 Save_Length(ligne,48); 
    909988                 tofich (allocationagrif, ligne,1); 
    910989              } 
     
    9361015           strcat (ligne,initialvalue); 
    9371016           /*                                                                 */ 
     1017           Save_Length(ligne,48); 
    9381018           tofich (allocationagrif, ligne,1); 
    9391019        } 
     
    9821062  variable *v; 
    9831063  int erreur; 
    984   char filefich[LONGNOM]; 
    985   char ligne[LONGNOM]; 
    986   char ligne1[LONGNOM]; 
     1064  char filefich[LONG_C]; 
     1065  char ligne[LONG_C]; 
    9871066  int IndiceMax; 
    9881067  int IndiceMin; 
     
    9951074  FILE *createvarname; 
    9961075  FILE *createvarnameglobal; 
    997   FILE *modulealloc; 
    998   FILE *dependfileoutput; 
    9991076 
    10001077  if ( todebug == 1 ) printf("Enter in creefichieramr\n"); 
     
    10851162  write_keysagrif_file(); 
    10861163  write_modtypeagrif_file(); 
    1087   write_Setnumberofcells_file(); 
    1088   write_Getnumberofcells_file(); 
     1164  if ( NbMailleXDefined == 1 ) 
     1165                             write_Setnumberofcells_file("SetNumberofcells.h"); 
     1166  if ( NbMailleXDefined == 1 ) 
     1167                             write_Getnumberofcells_file("GetNumberofcells.h"); 
     1168  retour77 = 0; 
     1169  if ( NbMailleXDefined == 1 ) 
     1170                          write_Setnumberofcells_file("SetNumberofcellsFree.h"); 
     1171  if ( NbMailleXDefined == 1 ) 
     1172                          write_Getnumberofcells_file("GetNumberofcellsFree.h"); 
     1173  retour77 = 1; 
     1174  if ( NbMailleXDefined == 1 ) 
     1175                         write_Setnumberofcells_file("SetNumberofcellsFixed.h"); 
     1176  if ( NbMailleXDefined == 1 ) 
     1177                         write_Getnumberofcells_file("GetNumberofcellsFixed.h"); 
    10891178  if ( todebug == 1 ) printf("Out of creefichieramr\n"); 
    10901179} 
Note: See TracChangeset for help on using the changeset viewer.