# scalairecf.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018
    00019 #include <med.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022 #include <stdlib.h>
    00023 #include <string.h>
    00024
    00025
    00026 #define nedfscac F77_FUNC(edfscac,EDFSCAC)
    00027 #define nedfscee F77_FUNC(edfscee,EDFSCEE)
    00028 #define nedfscfe F77_FUNC(edfscfe,EDFSCFE)
    00029 #define nedfnsca F77_FUNC(edfnsca,EDFNSCA)
    00030 #define nedfscai F77_FUNC(edfscai,EDFSCAI)
    00031 #define nedfnspd F77_FUNC(edfnspd,EDFNSPD)
    00032 #define nedfspdi F77_FUNC(edfspdi,EDFSPDI)
    00033 #define nedfscel F77_FUNC(edfscel,EDFSCEL)
    00034 #define nedfscfl F77_FUNC(edfscfl,EDFSCFL)
    00035
    00036
    00037 #ifdef PPRO_NT
    00038 med_int
    00039 __stdcall EDFSCAC(med_int *fid,char *scalaire, unsigned int bidon1,
    00040                   med_int *lon1,med_int *data_type, char *desc,
    00041                   unsigned int bidon2, med_int *lon2)
    00042 #else
    00043   med_int
    00044 nedfscac(med_int *fid,char *scalaire,med_int *lon1,med_int *data_type,
    00045          char *desc,med_int *lon2)
    00046 #endif
    00047 {
    00048   med_int ret;
    00049   med_type_champ typechamp;
    00050   char *fn1, *fn2;
    00051
    00052   fn1 = _MED2cstring(scalaire, (int) * lon1);
    00053   fn2 = _MED1cstring(desc, (int) * lon2,MED_TAILLE_DESC);
    00054
    00055   if (!fn1 || !fn2)
    00056     return(-1);
    00057
    00058   typechamp = (med_type_champ) *data_type;
    00059   ret = (med_int) MEDscalaireCr((med_idt) *fid, fn1,
    00060                                 typechamp, (char *)fn2);
    00061
    00062   _MEDcstringFree(fn1);
    00063   _MEDcstringFree(fn2);
    00064
    00065   return (ret);
    00066 }
    00067
    00068 #ifdef PPRO_NT
    00069 med_int
    00070 __stdcall EDFSCEE(med_int *fid,
    00071                   char *scalaire, unsigned int bidon1, med_int *lon1, med_int *val,
    00072                   med_int *numdt, char *dt_unit, unsigned int bidon2, med_int *lon2,
    00073                   med_float *dt, med_int *numo)
    00074 #else
    00075   med_int
    00076 nedfscee(med_int *fid,
    00077          char *scalaire, med_int *lon1, med_int *val,
    00078          med_int *numdt, char *dt_unit, med_int *lon2,
    00079          med_float *dt, med_int *numo)
    00080 #endif
    00081 {
    00082   med_int ret;
    00083   char *fn1, *fn2;
    00084
    00085   fn1 = _MED2cstring(scalaire, (int) * lon1);
    00086   fn2 = _MED2cstring(dt_unit, (int) * lon2);
    00087
    00088   if (!fn1 || !fn2)
    00089     return(-1);
    00090
    00091   ret = (int) MEDscalaireEntierEcr((med_idt) *fid,(char *)fn1,(med_int) *val,
    00092                                    (med_int) *numdt, (char *) fn2, (med_float) *dt,
    00093                                    (med_int) *numo );
    00094
    00095   _MEDcstringFree(fn1);
    00096   _MEDcstringFree(fn2);
    00097
    00098   return(ret);
    00099 }
    00100
    00101
    00102 #ifdef PPRO_NT
    00103 med_int
    00104 __stdcall EDFSCFE(med_int *fid,
    00105                   char *scalaire, unsigned int bidon1, med_int *lon1, med_float *val,
    00106                   med_int *numdt, char *dt_unit, unsigned int bidon2, med_int *lon2,
    00107                   med_float *dt, med_int *numo)
    00108 #else
    00109   med_int
    00110 nedfscfe(med_int *fid,
    00111          char *scalaire, med_int *lon1, med_float *val,
    00112          med_int *numdt, char *dt_unit, med_int *lon2,
    00113          med_float *dt, med_int *numo)
    00114 #endif
    00115 {
    00116   med_int ret;
    00117   char *fn1, *fn2;
    00118
    00119   fn1 = _MED2cstring(scalaire, (int) * lon1);
    00120   fn2 = _MED2cstring(dt_unit, (int) * lon2);
    00121
    00122   if (!fn1 || !fn2)
    00123     return(-1);
    00124
    00125   ret = (int) MEDscalaireFlottantEcr((med_idt) *fid,(char *)fn1,(med_float) *val,
    00126                                      (med_int) *numdt, (char *) fn2, (med_float) *dt,
    00127                                      (med_int) *numo );
    00128
    00129   _MEDcstringFree(fn1);
    00130   _MEDcstringFree(fn2);
    00131
    00132   return(ret);
    00133 }
    00134
    00135
    00136 #ifdef PPRO_NT
    00137 med_int
    00138 __stdcall EDFNSCA(med_int *fid)
    00139 #else
    00140   med_int
    00141 nedfnsca(med_int *fid)
    00142 #endif
    00143 {
    00144   med_int ret;
    00145
    00146   ret = (med_int) MEDnScalaire((med_idt) *fid);
    00147
    00148   return(ret);
    00149 }
    00150
    00151
    00152 #ifdef PPRO_NT
    00153 med_int
    00154 __stdcall EDFSCAI(med_int *fid, med_int *ind, char *scalaire, unsigned int bidon1,
    00155                   med_int *data_type, char *desc, unsigned int bidon2)
    00156 #else
    00157   med_int
    00158 nedfscai(med_int *fid,med_int *ind,char *scalaire,
    00159          med_int *data_type,char *desc)
    00160 #endif
    00161 {
    00162   med_int ret;
    00163   char *fs1,*fs2;
    00164   med_type_champ typechamp;
    00165
    00166   fs1 = (char *) malloc(sizeof(char)*MED_TAILLE_NOM+1);
    00167   fs2 = (char *) malloc(sizeof(char)*MED_TAILLE_DESC+1);
    00168
    00169   if (!(fs1&&fs2))
    00170     return -1;
    00171
    00172   ret = (med_int) MEDscalaireInfo((med_idt) *fid, (int)*ind, (char *)fs1,
    00173                                   &typechamp ,(char *)fs2);
    00174   *data_type = (med_int) typechamp;
    00175
    00176   strncpy(scalaire,fs1,MED_TAILLE_NOM);
    00177   strncpy(desc,fs2,MED_TAILLE_DESC);
    00178   _MEDfstring(scalaire,MED_TAILLE_NOM);
    00179   _MEDfstring(desc,MED_TAILLE_DESC);
    00180   free(fs1);
    00181   free(fs2);
    00182
    00183   return(ret);
    00184 }
    00185
    00186
    00187 #ifdef PPRO_NT
    00188 med_int
    00189 __stdcall EDFNSPD(med_int *fid,char *scalaire, unsigned int bidon1, med_int *lon1)
    00190 #else
    00191   med_int
    00192 nedfnspd(med_int *fid,char *scalaire, med_int *lon1)
    00193 #endif
    00194 {
    00195   med_int ret;
    00196   char *fn1;
    00197
    00198   fn1 = _MED2cstring(scalaire, (int) *lon1);
    00199
    00200   if (!fn1)
    00201     return(-1);
    00202
    00203   ret = (med_int) MEDnScalairePasdetemps((med_idt) *fid,(char *) fn1);
    00204
    00205   _MEDcstringFree(fn1);
    00206
    00207   return (ret);
    00208 }
    00209
    00210
    00211 #ifdef PPRO_NT
    00212 med_int
    00213 __stdcall EDFSPDI(med_int *fid, char *scalaire, unsigned int bidon1, med_int *lon1,
    00214                   med_int *indice,med_int *numdt, char *dt_unit, unsigned int bidon2,
    00215                   med_float *dt, med_int *numo)
    00216 #else
    00217   med_int
    00218 nedfspdi(med_int *fid,char *scalaire, med_int *lon1,med_int *indice,
    00219          med_int *numdt,char *dt_unit, med_float *dt, med_int *numo)
    00220 #endif
    00221 {
    00222   med_int ret;
    00223   char *fn1;
    00224   char fs1[MED_TAILLE_PNOM+1];
    00225
    00226   fn1 = _MED2cstring(scalaire, (int) *lon1);
    00227
    00228   if (!fn1)
    00229     return(-1);
    00230
    00231   ret = (med_int) MEDscalairePasdetempsInfo((med_idt) *fid,(char *) fn1,(int) *indice,
    00232                                             (med_int *) numdt, (char *) fs1,
    00233                                             (med_float *) dt, (med_int *) numo);
    00234
    00235   strncpy(dt_unit,fs1,MED_TAILLE_PNOM);
    00236   _MEDfstring(dt_unit,MED_TAILLE_PNOM);
    00237
    00238   _MEDcstringFree(fn1);
    00239
    00240   return (ret);
    00241 }
    00242
    00243 #ifdef PPRO_NT
    00244 med_int
    00245 __stdcall EDFSCEL(med_int *fid,
    00246                   char *scalaire, unsigned int bidon1, med_int *lon1, med_int *val,
    00247                   med_int *numdt,med_int *numo)
    00248 #else
    00249   med_int
    00250 nedfscel(med_int *fid,
    00251          char *scalaire, med_int *lon1, med_int *val,
    00252          med_int *numdt,med_int *numo)
    00253 #endif
    00254 {
    00255   med_int ret;
    00256   char * fn1;
    00257
    00258   fn1 = _MED2cstring(scalaire, (int) * lon1);
    00259
    00260   if (!fn1)
    00261     return(-1);
    00262
    00263   ret = (med_int) MEDscalaireEntierLire((med_idt) *fid,(char *)fn1,(med_int *) val,
    00264                                         (med_int) *numdt, (med_int ) *numo);
    00265
    00266   _MEDcstringFree(fn1);
    00267
    00268   return(ret);
    00269 }
    00270
    00271
    00272 #ifdef PPRO_NT
    00273 med_int
    00274 __stdcall EDFSCFL(med_int *fid,
    00275                   char *scalaire, unsigned int bidon1, med_int *lon1, med_float *val,
    00276                   med_int *numdt,med_int *numo)
    00277 #else
    00278   med_int
    00279 nedfscfl(med_int *fid,
    00280          char *scalaire, med_int *lon1, med_float *val,
    00281          med_int *numdt, med_int *numo)
    00282 #endif
    00283 {
    00284   med_int ret;
    00285   char * fn1;
    00286
    00287   fn1 = _MED2cstring(scalaire, (int) * lon1);
    00288
    00289   if (!fn1)
    00290     return(-1);
    00291
    00292   ret = (med_int) MEDscalaireFlottantLire((med_idt) *fid,(char *)fn1,(med_float *) val,
    00293                                           (med_int) *numdt, (med_int ) *numo);
    00294
    00295   _MEDcstringFree(fn1);
    00296
    00297   return(ret);
    00298 }