Changeset 7


Ignore:
Timestamp:
03/07/11 11:49:01 (13 years ago)
Author:
jbrlod
Message:

rst write

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/meshmask.h

    r6 r7  
     1#define nav_lon( i, j ) (nav_lon[(j)*(NX)+(i)]) 
     2#define nav_lat( i, j ) (nav_lat[(j)*(NX)+(i)]) 
    13#define e1u( i, j )  (e1u[(j)*(NX)+(i)]) 
    24#define e2u( i, j )  (e2u[(j)*(NX)+(i)]) 
     
    2022// tous les indices commencent de 0 
    2123//domzgr_substitute.h90 key_zco 
     24#   define  nav_lev( i , j , k ) nav_lev[k] 
    2225#   define  fsdept( i , j , k )  gdept_0[k] 
    2326#   define  fsdepw( i , j , k )  gdepw_0[k] 
     
    5255#  define   fsahmv(i,j,k)   ahm0 
    5356 
     57double nav_lon[NY*NX]; // from mesh_mask.nc 
     58double nav_lat[NY*NX]; // from mesh_mask.nc 
    5459double e1u[NY*NX];    // from mesh_mask.nc 
    5560double e2u[NY*NX];    // from mesh_mask.nc 
     
    6065double e1f[NY*NX];    // from mesh_mask.nc 
    6166double e2f[NY*NX];    // from mesh_mask.nc 
     67double nav_lev[NZ];   // from mesh_mask.nc 
    6268double e3t_0[NZ];    // from mesh_mask.nc 
    6369double e3w_0[NZ];    // from mesh_mask.nc 
     
    8187char const    *mesh_mask_file    = PATH_NCFILES"/mesh_mask.nc"; 
    8288int mesh_mask_file_id; 
     89int nav_lon_id, nav_lat_id, nav_lev_id; //Utiliser juste pour info 
    8390int e1u_id,e2u_id,e1v_id,e2v_id,e1t_id,e2t_id,e1f_id,e2f_id,e3t_0_id,e3w_0_id; 
    8491int mbathy_id,gphit_id,gphiu_id,gphiv_id,gphif_id,gdept_0_id,gdepw_0_id; 
     
    106113 
    107114 
     115 
    108116//Ecriture du netcdf 
    109117void write_rst_global_att(int ncid); //Ecrit les attributs globaux du restart standard 
    110  
     118void voncwrite(int t,int znbval,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     119void soncwrite(int t,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     120void zoncwrite(int t,int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     121void zncwrite(int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     122void sncwrite(int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
    111123void define_dim(int ncid, int dimid[]); 
    112124//défini les dimensions en x,y,z, et t (unlimited),  
     
    119131  mesh_mask_file_id=Ouvre_nc(mesh_mask_file); 
    120132 
     133  nav_lon_id=Var_id(mesh_mask_file_id,"nav_lon"); 
     134  snclire(NY,NX, mesh_mask_file_id, nav_lon_id,nav_lon); 
     135   
     136  nav_lat_id=Var_id(mesh_mask_file_id,"nav_lat"); 
     137  snclire(NY,NX, mesh_mask_file_id, nav_lat_id,nav_lat); 
     138 
    121139  e1u_id=Var_id(mesh_mask_file_id,"e1u"); 
    122140  sonclire(0, NY,NX, mesh_mask_file_id, e1u_id,e1u); 
     
    181199  bmask_id=Var_id(mesh_mask_file_id,"bmask"); 
    182200  sonclire(0, NY,NX, mesh_mask_file_id, bmask_id,bmask); 
     201 
     202  nav_lev_id=Var_id(mesh_mask_file_id,"nav_lev"); 
     203  znclire(NZ, mesh_mask_file_id, nav_lev_id,nav_lev); 
    183204 
    184205  gdept_0_id=Var_id(mesh_mask_file_id,"gdept_0"); 
     
    358379//dimid={t_id,z_id,y_id,x_id}; 
    359380{  
    360  
     381  nc_redef(ncid); 
    361382  nc_def_dim(ncid,"x",NX,&dimid[3]); 
    362383  nc_def_dim(ncid,"y",NY,&dimid[2]); 
    363384  nc_def_dim(ncid,"z",NZ,&dimid[1]); 
    364385  nc_def_dim(ncid,"t",NC_UNLIMITED,&dimid[0]); 
    365   
     386  nc_enddef(ncid); 
    366387  
    367388  
    368389} 
     390 
     391void write_rst_var(int t,   int ncid, int dimids[]) { 
     392YREAL vect[NZ*NY*NX]; 
     393  
     394//nav_lon 
     395 for(int j=0;j<NY;j++) 
     396      for(int i=0;i<NX;i++){ 
     397        vect[(j)*(NX)+(i)]=nav_lon( i, j ); 
     398      } 
     399 sncwrite(NY,NX,"nav_lon",ncid,dimids,vect); 
     400  
     401 //nav_lat 
     402 for(int j=0;j<NY;j++) 
     403   for(int i=0;i<NX;i++){ 
     404     vect[(j)*(NX)+(i)]=nav_lat( i, j ); 
     405   } 
     406 sncwrite(NY,NX,"nav_lat",ncid,dimids,vect); 
     407  
     408 //nav_lev 
     409 for(int k=0;k<NZ;k++){ 
     410  vect[k]=nav_lev[k];   
     411} 
     412zncwrite(NZ,"nav_lev",ncid,dimids,vect); 
     413 
     414//gcx 
     415for(int j=0;j<NY;j++) 
     416   for(int i=0;i<NX;i++){ 
     417     vect[(j)*(NX)+(i)]=YS_gcx2(0,i,j,t); 
     418   } 
     419 soncwrite(0,NY,NX,"gcx",ncid,dimids,vect); 
     420  
     421//gcxb 
     422for(int j=0;j<NY;j++) 
     423   for(int i=0;i<NX;i++){ 
     424     vect[(j)*(NX)+(i)]=YS_gcx2(0,i,j,t-1); 
     425   } 
     426 soncwrite(0,NY,NX,"gcxb",ncid,dimids,vect); 
     427  
     428//sshb 
     429for(int j=0;j<NY;j++) 
     430   for(int i=0;i<NX;i++){ 
     431     vect[(j)*(NX)+(i)]=YS_sshb(0,i,j,t); 
     432   } 
     433 soncwrite(0,NY,NX,"sshb",ncid,dimids,vect); 
     434  
     435//sshn 
     436for(int j=0;j<NY;j++) 
     437   for(int i=0;i<NX;i++){ 
     438     vect[(j)*(NX)+(i)]=YS_sshn(0,i,j,t); 
     439   } 
     440 soncwrite(0,NY,NX,"sshn",ncid,dimids,vect); 
     441  
     442 //ub 
     443 for(int k=0;k<NZ;k++) 
     444   for(int j=0;j<NY;j++) 
     445     for(int i=0;i<NX;i++){ 
     446       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_ub(0,i,j,k,t); 
     447     } 
     448 voncwrite(0,NZ,NY,NX,"ub",ncid,dimids,vect); 
     449 
     450//vb 
     451 for(int k=0;k<NZ;k++) 
     452   for(int j=0;j<NY;j++) 
     453     for(int i=0;i<NX;i++){ 
     454       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_vb(0,i,j,k,t); 
     455     } 
     456 voncwrite(0,NZ,NY,NX,"vb",ncid,dimids,vect); 
     457 
     458//tb 
     459 for(int k=0;k<NZ;k++) 
     460   for(int j=0;j<NY;j++) 
     461     for(int i=0;i<NX;i++){ 
     462       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_tb(0,i,j,k,t); 
     463     } 
     464 voncwrite(0,NZ,NY,NX,"tb",ncid,dimids,vect); 
     465 
     466//sb 
     467 for(int k=0;k<NZ;k++) 
     468   for(int j=0;j<NY;j++) 
     469     for(int i=0;i<NX;i++){ 
     470       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_sb(0,i,j,k,t); 
     471     } 
     472 voncwrite(0,NZ,NY,NX,"sb",ncid,dimids,vect); 
     473 
     474//rotb 
     475 for(int k=0;k<NZ;k++) 
     476   for(int j=0;j<NY;j++) 
     477     for(int i=0;i<NX;i++){ 
     478       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_rotn(0,i,j,k,t-1); 
     479     } 
     480 voncwrite(0,NZ,NY,NX,"rotb",ncid,dimids,vect); 
     481 
     482//hdivb 
     483 for(int k=0;k<NZ;k++) 
     484   for(int j=0;j<NY;j++) 
     485     for(int i=0;i<NX;i++){ 
     486       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_hdivn(0,i,j,k,t-1); 
     487     } 
     488 voncwrite(0,NZ,NY,NX,"hdivb",ncid,dimids,vect); 
     489 
     490//un 
     491 for(int k=0;k<NZ;k++) 
     492   for(int j=0;j<NY;j++) 
     493     for(int i=0;i<NX;i++){ 
     494       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_ua(0,i,j,k,t); 
     495     } 
     496 voncwrite(0,NZ,NY,NX,"un",ncid,dimids,vect); 
     497 
     498//vn 
     499 for(int k=0;k<NZ;k++) 
     500   for(int j=0;j<NY;j++) 
     501     for(int i=0;i<NX;i++){ 
     502       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_va(0,i,j,k,t); 
     503     } 
     504 voncwrite(0,NZ,NY,NX,"vn",ncid,dimids,vect); 
     505 
     506//tn 
     507 for(int k=0;k<NZ;k++) 
     508   for(int j=0;j<NY;j++) 
     509     for(int i=0;i<NX;i++){ 
     510       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_ta(0,i,j,k,t); 
     511     } 
     512 voncwrite(0,NZ,NY,NX,"tn",ncid,dimids,vect); 
     513 
     514//sn 
     515 for(int k=0;k<NZ;k++) 
     516   for(int j=0;j<NY;j++) 
     517     for(int i=0;i<NX;i++){ 
     518       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_sa(0,i,j,k,t); 
     519     } 
     520 voncwrite(0,NZ,NY,NX,"sn",ncid,dimids,vect); 
     521 
     522//rotn 
     523 for(int k=0;k<NZ;k++) 
     524   for(int j=0;j<NY;j++) 
     525     for(int i=0;i<NX;i++){ 
     526       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_rotn(0,i,j,k,t); 
     527     } 
     528 voncwrite(0,NZ,NY,NX,"rotn",ncid,dimids,vect); 
     529 
     530//hdivn 
     531 for(int k=0;k<NZ;k++) 
     532   for(int j=0;j<NY;j++) 
     533     for(int i=0;i<NX;i++){ 
     534       vect[(k)*(NY*NX)+(j)*(NX)+(i)]=YS_hdivn(0,i,j,k,t); 
     535     } 
     536 voncwrite(0,NZ,NY,NX,"hdivn",ncid,dimids,vect); 
     537 
     538 
     539} 
     540 
     541 
    369542 
    370543void write_rst_global_att(int ncid) { 
  • trunk/include/ncutil.cpp

    r4 r7  
    5050  return(var_id); 
    5151} 
    52   
     52 
     53void voncwrite(int t,int znbval,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]) 
     54{ //Ecrrire le volume 3D au temps t 
     55  //le parametre t commence de 0. 
     56  // ecrit la variable var_name aux points (t, 1:znbval, 1:ynbval, 1:xnbval) 
     57  int status; 
     58 
     59  int var_id; 
     60  int local_dimids[4]; 
     61  static size_t start[] = {0,0,0,0}; //3D+t 
     62  static size_t count[] = {1,1,1,1}; //3D+t 
     63  count[0]= (size_t) t+1; 
     64  count[1]= (size_t) znbval; 
     65  count[2]= (size_t) ynbval; 
     66  count[3]= (size_t) xnbval; 
     67  start[0]=t; //temps commence de 0; 
     68 
     69  local_dimids[0]=dimids[0]; //t 
     70  local_dimids[1]=dimids[1]; //z 
     71  local_dimids[2]=dimids[2]; //y 
     72  local_dimids[3]=dimids[3]; //x 
     73 
     74  //Define the netCDF variable 
     75  status=nc_redef(ncid); 
     76if (status != NC_NOERR) 
     77    { 
     78      handle_error (status, "Erreur change to def mode NetCDF ::voncwrite"); 
     79    } 
     80  
     81 status=nc_def_var(ncid,var_name,NC_REAL,4,local_dimids,&var_id); 
     82  
     83  if (status != NC_NOERR) 
     84    { 
     85      printf("variable %s:",var_name); 
     86      handle_error (status, "Erreur define NetCDF variable ::voncwrite"); 
     87    } 
     88 nc_enddef(ncid); 
     89  status=nc_put_vara_real(ncid,var_id,start,count,vect); 
     90 if (status != NC_NOERR) 
     91    { 
     92      handle_error (status, "Erreur writing NetCDF variable ::voncwrite"); 
     93    } 
     94} 
     95 
    5396void vonclire(int t,int znbval, int ynbval, int xnbval, int ncid, int varid, double vect[]) 
    5497{// lire volume 3D au temps t 
     
    76119} 
    77120 
     121void soncwrite(int t,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]) 
     122{ //Ecrrire le volume 2D au temps t 
     123  //le parametre t commence de 0. 
     124  // ecrit la variable var_name aux points (t, 1:ynbval, 1:xnbval) 
     125  int status; 
     126 
     127  int var_id; 
     128  int local_dimids[3]; 
     129  static size_t start[] = {0,0,0}; //2D+t 
     130  static size_t count[] = {1,1,1}; //2D+t 
     131  count[0]= (size_t) t+1; 
     132  count[1]= (size_t) ynbval; 
     133  count[2]= (size_t) xnbval; 
     134  start[0]=t; //temps commence de 0; 
     135 
     136  local_dimids[0]=dimids[0]; //t 
     137  local_dimids[1]=dimids[2]; //y 
     138  local_dimids[2]=dimids[3]; //x 
     139 
     140  //Define the netCDF variable 
     141  status=nc_redef(ncid); 
     142if (status != NC_NOERR) 
     143    { 
     144      handle_error (status, "Erreur change to def mode NetCDF ::voncwrite"); 
     145    } 
     146  
     147 status=nc_def_var(ncid,var_name,NC_REAL,3,local_dimids,&var_id); 
     148  
     149  if (status != NC_NOERR) 
     150    { 
     151      printf("variable %s:",var_name); 
     152      handle_error (status, "Erreur define NetCDF variable ::voncwrite"); 
     153    } 
     154 nc_enddef(ncid); 
     155  status=nc_put_vara_real(ncid,var_id,start,count,vect); 
     156 if (status != NC_NOERR) 
     157    { 
     158      handle_error (status, "Erreur writing NetCDF variable ::voncwrite"); 
     159    } 
     160} 
     161 
     162 
    78163void sonclire(int t,int ynbval, int xnbval, int ncid, int varid, double vect[]) 
    79164{// lire surface 2D au temps t 
     
    99184    } 
    100185} 
     186 
    101187void sonclire(int t,int ynbval, int xnbval, int ncid, int varid, float vect[]) 
    102188{// lire surface 2D au temps t 
     
    123209} 
    124210 
     211void snclire(int ynbval, int xnbval, int ncid, int varid, double vect[]) 
     212{// lire surface 2D  
     213  // (ynbval,xnbval,ncid, varid):  
     214  // lit la variable varid aux points (1:ynbval,1:xnbval) et 
     215  // renvoie un vecteur de dim ynbval*xnbval 
     216  
     217  int           status; 
     218  static size_t   start[] = { 0, 0 };  // 2D 
     219  static size_t   count[] = { 1, 1 }; // 2D 
     220  count[0] =(size_t)  ynbval; 
     221  count[1] =(size_t)  xnbval; 
     222   
     223  // Read an array of values 
     224  status = nc_get_vara_double (ncid, varid, start, count, vect); 
     225   
     226 if (status != NC_NOERR) 
     227    { 
     228      handle_error (status, "Erreur lecture fichier NetCDF::snclire"); 
     229    } 
     230} 
     231 
     232void snclire(int ynbval, int xnbval, int ncid, int varid, float vect[]) 
     233{// lire surface 2D  
     234  // (ynbval,xnbval,ncid, varid):  
     235  // lit la variable varid aux points (1:ynbval,1:xnbval) et 
     236  // renvoie un vecteur de dim ynbval*xnbval 
     237  
     238  int           status; 
     239  static size_t   start[] = { 0, 0 };  // 2D 
     240  static size_t   count[] = { 1, 1 }; // 2D 
     241  count[0] =(size_t)  ynbval; 
     242  count[1] =(size_t)  xnbval; 
     243   
     244  // Read an array of values 
     245  status = nc_get_vara_float (ncid, varid, start, count, vect); 
     246   
     247 if (status != NC_NOERR) 
     248    { 
     249      handle_error (status, "Erreur lecture fichier NetCDF::snclire"); 
     250    } 
     251} 
     252 
     253void zoncwrite(int t,int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]) 
     254{ //Ecrrire la variable 1D au temps t 
     255  //le parametre t commence de 0. 
     256  // ecrit la variable var_name aux points (t, 1:znbval) 
     257  int status; 
     258 
     259  int var_id; 
     260  int local_dimids[2]; 
     261  static size_t start[] = {0,0}; //1D+t 
     262  static size_t count[] = {1,1}; //1D+t 
     263  count[0]= (size_t) t+1; 
     264  count[1]= (size_t) znbval; 
     265   
     266  start[0]=t; //temps commence de 0; 
     267 
     268  local_dimids[0]=dimids[0]; //t 
     269  local_dimids[1]=dimids[1]; //z 
     270   
     271 
     272  //Define the netCDF variable 
     273  status=nc_redef(ncid); 
     274if (status != NC_NOERR) 
     275    { 
     276      handle_error (status, "Erreur change to def mode NetCDF ::voncwrite"); 
     277    } 
     278  
     279 status=nc_def_var(ncid,var_name,NC_REAL,2,local_dimids,&var_id); 
     280  
     281  if (status != NC_NOERR) 
     282    { 
     283      printf("variable %s:",var_name); 
     284      handle_error (status, "Erreur define NetCDF variable ::voncwrite"); 
     285    } 
     286 nc_enddef(ncid); 
     287  status=nc_put_vara_real(ncid,var_id,start,count,vect); 
     288 if (status != NC_NOERR) 
     289    { 
     290      handle_error (status, "Erreur writing NetCDF variable ::voncwrite"); 
     291    } 
     292} 
     293 
     294 
    125295void zonclire(int t,int znbval, int ncid, int varid, double vect[]) 
    126296{// lire surface 1D au temps t 
     
    218388    } 
    219389} 
     390 
     391void znclire(int znbval, int ncid, int varid, double vect[]) 
     392{// lire surface 1D  
     393  // (znbval,ncid, varid):  
     394  // lit la variable varid aux points (1:znbval) et 
     395  // renvoie un vecteur de dim znbval 
     396  
     397  int           status; 
     398  static size_t   start[] = { 0 };  //1D 
     399  static size_t   count[] = { 1 }; // 1D 
     400  count[0] =(size_t)  znbval; 
     401  
     402   
     403  // Read an array of values 
     404  status = nc_get_vara_double (ncid, varid, start, count, vect); 
     405   
     406 if (status != NC_NOERR) 
     407    { 
     408      handle_error (status, "Erreur lecture fichier NetCDF::zonclire"); 
     409    } 
     410} 
     411 
     412 
     413void znclire(int znbval, int ncid, int varid, float vect[]) 
     414{// lire surface 1D  
     415  // (znbval,ncid, varid):  
     416  // lit la variable varid aux points (1:znbval) et 
     417  // renvoie un vecteur de dim znbval 
     418  
     419  int           status; 
     420  static size_t   start[] = { 0 };  //1D 
     421  static size_t   count[] = { 1 }; // 1D 
     422  count[0] =(size_t)  znbval; 
     423  
     424   
     425  // Read an array of values 
     426  status = nc_get_vara_float (ncid, varid, start, count, vect); 
     427   
     428 if (status != NC_NOERR) 
     429    { 
     430      handle_error (status, "Erreur lecture fichier NetCDF::zonclire"); 
     431    } 
     432} 
     433 
     434void sncwrite(int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]) 
     435{ //Ecrrire le volume 2D 
     436  // ecrit la variable var_name aux points (1:ynbval, 1:xnbval) 
     437  int status; 
     438 
     439  int var_id; 
     440  int local_dimids[2]; 
     441  static size_t start[] = {0,0}; //2D 
     442  static size_t count[] = {1,1}; //2D 
     443  count[0]= (size_t) ynbval; 
     444  count[1]= (size_t) xnbval; 
     445  
     446  local_dimids[0]=dimids[2]; //y 
     447  local_dimids[1]=dimids[3]; //x 
     448 
     449  //Define the netCDF variable 
     450  status=nc_redef(ncid); 
     451if (status != NC_NOERR) 
     452    { 
     453      handle_error (status, "Erreur change to def mode NetCDF ::voncwrite"); 
     454    } 
     455  
     456 status=nc_def_var(ncid,var_name,NC_REAL,2,local_dimids,&var_id); 
     457  
     458  if (status != NC_NOERR) 
     459    { 
     460      printf("variable %s:",var_name); 
     461      handle_error (status, "Erreur define NetCDF variable ::voncwrite"); 
     462    } 
     463 nc_enddef(ncid); 
     464  status=nc_put_vara_real(ncid,var_id,start,count,vect); 
     465 if (status != NC_NOERR) 
     466    { 
     467      handle_error (status, "Erreur writing NetCDF variable ::voncwrite"); 
     468    } 
     469} 
     470 
     471 
     472void zncwrite(int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]) 
     473{ //Ecrrire la variable 1D  
     474  // ecrit la variable var_name aux points (1:znbval) 
     475  int status; 
     476 
     477  int var_id; 
     478  int local_dimids[1]; 
     479  static size_t start[] = {0}; //1D 
     480  static size_t count[] = {1}; //1D 
     481 
     482  count[0]= (size_t) znbval; 
     483   
     484 
     485  local_dimids[0]=dimids[1]; //z 
     486   
     487 
     488  //Define the netCDF variable 
     489  status=nc_redef(ncid); 
     490if (status != NC_NOERR) 
     491    { 
     492      handle_error (status, "Erreur change to def mode NetCDF ::voncwrite"); 
     493    } 
     494  
     495 status=nc_def_var(ncid,var_name,NC_REAL,1,local_dimids,&var_id); 
     496  
     497  if (status != NC_NOERR) 
     498    { 
     499      printf("variable %s:",var_name); 
     500      handle_error (status, "Erreur define NetCDF variable ::voncwrite"); 
     501    } 
     502 nc_enddef(ncid); 
     503  status=nc_put_vara_real(ncid,var_id,start,count,vect); 
     504 if (status != NC_NOERR) 
     505    { 
     506      handle_error (status, "Erreur writing NetCDF variable ::voncwrite"); 
     507    } 
     508} 
  • trunk/include/ncutil.h

    r4 r7  
    88#include <netcdf.h> 
    99 
     10#define YYDOUBLE //équivalent du YDOUBLE/YFLOAT de YAO 
     11//normalement YYDOUBLE et YBOUBLE doivent être définis en même temps 
     12//Verifié dans appli_start 
     13 
     14 
     15#ifdef YFLOAT 
     16#define NC_REAL NC_FLOAT 
     17#define nc_put_vara_real nc_put_vara_float 
     18#define YREAL float 
     19#else 
     20#define NC_REAL NC_DOUBLE 
     21#define nc_put_vara_real nc_put_vara_double 
     22#define YREAL double 
     23#endif 
    1024 
    1125void    handle_error (int status, char *txt);///*fonction de message d'erreur 
     
    2337// renvoie un vecteur de dim znbval*ynbval*xnbval 
    2438 
     39void voncwrite(int t,int znbval,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     40 
     41 
    2542void sonclire(int t,int ynbval, int xnbval, int ncid, int varid, double vect[]); 
    2643void sonclire(int t,int ynbval, int xnbval, int ncid, int varid, float vect[]); 
     
    3148// lit la variable varid aux points (t,1:ynbval,1:xnbval) et 
    3249// renvoie un vecteur de dim ynbval*xnbval 
     50void snclire(int ynbval, int xnbval, int ncid, int varid, float vect[]); 
     51void snclire(int ynbval, int xnbval, int ncid, int varid, double vect[]); 
     52 
     53void soncwrite(int t,int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
    3354 
    3455void zonclire(int t,int znbval, int ncid, int varid, double vect[]); 
     
    4061// renvoie un vecteur de dim znbval 
    4162 
     63void znclire(int znbval, int ncid, int varid, float vect[]); 
     64void znclire(int znbval, int ncid, int varid, double vect[]); 
     65 
     66void zoncwrite(int t,int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     67 
     68void zncwrite(int znbval,char const *var_name,int ncid,int dimids[], YREAL vect[]); 
     69void sncwrite(int ynbval, int xnbval, char const *var_name,int ncid,int dimids[], YREAL vect[]); 
    4270#endif 
    4371 
  • trunk/src/sinobad.d

    r3 r7  
    1515#HAT_NAME -----------------------------------------HAT_NAME 
    1616hat_name  sinobad 
    17  
     17  
    1818#OPTION ----------------------------------------------OPTION 
    1919#option o_parallel 
     
    2424#option   O_DBG_TING 
    2525option  O_EXTOBJ "../object/ncutil.o" 
     26option O_REAL double 
    2627 
    2728#TRAJECTOIRES (DIM) -----------------------------------TRAJ 
  • trunk/src/sinobad.h

    r6 r7  
    9191  printf("////////////////////////////////////////////////////////////////////////\n"); 
    9292  printf("//                       NEMO/YAO PROJECT                             //\n"); 
    93   printf("//                     M. Berrada  02-2009                            //\n"); 
     93  printf("//                     M. Berrada 02-2009                            //\n"); 
    9494  printf("//                  LOCEAN-IPSL.UPMC (Paris 6)                        //\n"); 
    9595  printf("//====================================================================//\n"); 
     96 
     97  //Vérification du type de réel utilisé 
     98#ifdef YFLOAT 
     99#ifndef YYFLOAT 
     100  printf("Incoherent real type between O_REAL option and ncutil.h\n"); 
     101  exit(1); 
     102#endif 
     103#endif 
     104#ifdef YDOUBLE 
     105#ifndef YYDOUBLE 
     106  printf("Incoherent real type between O_REAL option and ncutil.h\n"); 
     107  exit(1); 
     108#endif 
     109#endif 
     110 
    96111  for (int i=0;i<TA+TU;i++) tniter[i]=0;//nmax;// pour backward de solsor_dynspg_flt.h 
    97112  phy_cst(); 
     
    844859      int dimid[4]; 
    845860      strcpy(rest_file,argv[1]); 
    846       rest_file_id=Ouvre_nc_write(rest_file); 
    847       write_rst_global_att(rest_file_id); 
    848       define_dim(rest_file_id,dimid); 
    849       nc_close( rest_file_id);  
    850     } 
    851 } 
     861      rest_file_id=Ouvre_nc_write(rest_file); //Ouvre le fichier netcds pour l'écriture 
     862      write_rst_global_att(rest_file_id); //Ecrit les global attributes 
     863      define_dim(rest_file_id,dimid); //Définit les dimensions 
     864      write_rst_var(TU,rest_file_id,dimid); //Ecrit les variables 
     865      nc_close( rest_file_id); //ferme le fichier 
     866    } 
     867} 
Note: See TracChangeset for help on using the changeset viewer.