1 /* This file is part of MED.
2 *
3 * COPYRIGHT (C) 1999 - 2019 EDF R&D, CEA/DEN
4 * MED is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * MED is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with MED. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19 #include "med_config.h"
20 #include <med.h>
21 #include "med_outils.h"
22 #include <string.h>
23
24 #include <2.3.6/med23v30.h>
25 #include <2.3.6/med23v30_proto.h>
26 #include "2.3.6/med23v30_misc.h"
27
28
_MEDparameterInfoByName236(int dummy,...)29 void _MEDparameterInfoByName236(int dummy, ...) {
30
31
32 med_err _ret=-1,_err=0;
33 med_idt _paramidt=0,_cpstid=0;
34 char _path[MED_NUMERICAL_DATA_GRP_SIZE+MED_TAILLE_NOM+1+1]=MED_NUMERICAL_DATA_GRP;
35 char _cpstname[2*MED_MAX_PARA+1]="";
36 med_size _nstep=0;
37 med_int _intparamtype=0;
38
39 MED_VARGS_DECL(const, med_idt , , fid );
40 MED_VARGS_DECL(const, char * , const , paramname );
41 MED_VARGS_DECL(, med_parameter_type *, const , paramtype );
42 MED_VARGS_DECL(, char * , const , description );
43 MED_VARGS_DECL(, char * , const , dtunit );
44 MED_VARGS_DECL(, med_int * , const , nstep );
45 MED_VARGS_DECL(, med_err * ,, fret );
46
47 va_list params;
48 va_start(params,dummy);
49
50 MED_VARGS_DEF(const, med_idt , , fid );
51 MED_VARGS_DEF(const, char * , const , paramname );
52 MED_VARGS_DEF(, med_parameter_type *, const , paramtype );
53 MED_VARGS_DEF(, char * , const , description );
54 MED_VARGS_DEF(, char * , const , dtunit );
55 MED_VARGS_DEF(, med_int * , const , nstep );
56 MED_VARGS_DEF(, med_err * ,, fret );
57
58 /*
59 * On inhibe le gestionnaire d'erreur HDF 5
60 */
61 _MEDmodeErreurVerrouiller();
62
63 /*
64 * On construit le chemin d'acces
65 */
66 strcat(_path,paramname);
67 strcat(_path,"/");
68
69 if ((_err=_MEDnObjects(fid, _path, &_nstep)) < 0 )
70 if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
71 MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_path);
72 goto ERROR;
73 }
74 *nstep=(med_int) _nstep;
75
76 if ((_paramidt = _MEDdatagroupOuvrir(fid,_path)) < 0) {
77 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
78 goto ERROR;
79 }
80
81 /*
82 * L'attribut "TYP"
83 */
84 if ( _MEDattrEntierLire(_paramidt, MED_NOM_TYP, &_intparamtype) < 0) {
85 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
86 SSCRUTE(MED_NOM_TYP);ISCRUTE(_intparamtype);
87 goto ERROR;
88 }
89 *paramtype = (med_parameter_type) _intparamtype;
90
91 /*
92 * L'attribut DES
93 */
94 if ( _MEDattrStringLire(_paramidt,MED_NOM_DES,MED_TAILLE_DESC,description) < 0) {
95 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
96 SSCRUTE(MED_NOM_DES);SSCRUTE(description);
97 goto ERROR;
98 }
99
100 if ( _MEDobjectGetName( _paramidt,".",0,_cpstname) < 0 ) {
101 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);SSCRUTE(_cpstname);
102 goto ERROR;
103 }
104
105
106 /* Lecture de l'attribut MED_NOM_UNI */
107 if ( _MEDattributeStringRdByName(_paramidt,_cpstname,MED_NOM_UNI,MED_TAILLE_PNOM,dtunit) < 0) {
108 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,_path);
109 SSCRUTE(_cpstname);SSCRUTE(MED_NOM_UNI);SSCRUTE(dtunit);goto ERROR;
110 }
111
112 _ret = 0;
113
114 ERROR:
115
116
117 if (_paramidt>0) if (_MEDdatagroupFermer(_paramidt) < 0) {
118 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
119 ISCRUTE_id(_paramidt);
120 }
121
122 va_end(params);
123 *fret = _ret;
124 return;
125 }
126