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.h>
20 #include <med_config.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 void
_MEDfield23ComputingStepMeshInfo236(int dummy,...)29 _MEDfield23ComputingStepMeshInfo236(int dummy,...)
30 {
31
32
33 med_err _ret=-1,_err=0;
34 med_size _num,_nmesh=0;
35
36 med_idt _datagroup1=0,_meshgid=0,_linkgid=0;
37 char _datagroupname1[2*MED_MAX_PARA+1] ="";
38 char _ent_geo [2*MED_TAILLE_NOM_ENTITE+2]="";
39 char _path [(MED_FIELD_GRP_SIZE+MED_TAILLE_NOM+1)+
40 (2*MED_TAILLE_NOM_ENTITE+1)+1+(2*MED_MAX_PARA)+1]=MED_FIELD_GRP;
41 char _meshpath [MED_MESH_GRP_SIZE+MED_TAILLE_NOM+1]=MED_MESH_GRP;
42 char _linkpath [MED_TAILLE_LIENS+MED_TAILLE_NOM+1]=MED_LIENS;
43 med_size _ncpst=0;
44 med_bool _checkmultiplemesh=MED_TRUE, _multiplemesh =MED_FALSE;
45 med_bool _checkmeshname =MED_TRUE, _samedefaultmeshname=MED_FALSE;
46
47
48 MED_VARGS_DECL(const, med_idt , , fid );
49 MED_VARGS_DECL(const, char * , const , fieldname );
50 MED_VARGS_DECL(const, int , , csit );
51 MED_VARGS_DECL(, med_int *, const , numdt );
52 MED_VARGS_DECL(, med_int *, const , numit );
53 MED_VARGS_DECL(, med_float *, const , dt );
54 MED_VARGS_DECL(, med_int *, const , nmesh );
55 MED_VARGS_DECL(, char *, const , meshname );
56 MED_VARGS_DECL(, med_bool *, const , localmesh );
57 MED_VARGS_DECL(, med_int *, const , meshnumdt );
58 MED_VARGS_DECL(, med_int *, const , meshnumit );
59 MED_VARGS_DECL(, med_err * ,, fret );
60
61 va_list params;
62 va_start(params,dummy);
63
64 MED_VARGS_DEF(const, med_idt , , fid );
65 MED_VARGS_DEF(const, char * , const , fieldname );
66 MED_VARGS_DEF(const, int , , csit );
67 MED_VARGS_DEF(, med_int *, const , numdt );
68 MED_VARGS_DEF(, med_int *, const , numit );
69 MED_VARGS_DEF(, med_float *, const , dt );
70 MED_VARGS_DEF(, med_int *, const , nmesh );
71 MED_VARGS_DEF(, char *, const , meshname );
72 MED_VARGS_DEF(, med_bool *, const , localmesh );
73 MED_VARGS_DEF(, med_int *, const , meshnumdt );
74 MED_VARGS_DEF(, med_int *, const , meshnumit );
75 MED_VARGS_DEF(, med_err * ,, fret );
76
77 _num=csit-1;
78
79 /*
80 * On inhibe le gestionnaire d'erreur HDF 5
81 */
82 _MEDmodeErreurVerrouiller();
83
84 /*
85 * On construit le nom du datagroup
86 */
87 strcat(_path,fieldname);
88
89 /* if ( _MEDfieldComputingStepCheck236(fid, fieldname, */
90 /* &_ncpst, */
91 /* _checkmultiplemesh, &_multiplemesh, */
92 /* _checkmeshname, &_samedefaultmeshname) < 0) { */
93 /* MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_FIELD,fieldname); */
94 /* goto ERROR; */
95 /* } */
96
97 /*
98 * On suppose que le modèle 2.3.6 est respecté :
99 * Il y a les mêmes séquences de calcul pour tous les couples
100 * (typent,typegeo). Autrement dit selon l'utilisation de l'API 2.3.6 :
101 * A chaque séquence de calcul, on utilise le même ensemble de (typent,typegeo).
102 * En conséquence si l'on fixe le (typeent,typegeo) les séquences
103 * de calcul que l'on va trouver seront représentatives de celles
104 * présentent dans tous les (typent,typegeo) utilisés.
105 */
106 if ( _MEDobjectGetName(fid, _path ,0, _ent_geo) < 0 ) {
107 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);
108 SSCRUTE(_path); SSCRUTE(_ent_geo); goto ERROR;
109 }
110
111 strcat(_path,"/");
112 strcat(_path,_ent_geo);
113
114 if ( _MEDobjectGetName(fid, _path ,_num, _datagroupname1) < 0 ) {
115 MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);
116 SSCRUTE(_path); SSCRUTE(_ent_geo); goto ERROR;
117 }
118
119 strcat(_path,"/");
120 strcat(_path,_datagroupname1);
121
122 if ((_datagroup1 = _MEDdatagroupOuvrir(fid,_path)) < 0) {
123 MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
124 goto ERROR;
125 }
126
127
128 /*
129 * Lecture des attributs
130 */
131
132 if (_MEDattrEntierLire(_datagroup1,MED_NOM_NDT,(med_int*) numdt) < 0) {
133 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT);
134 SSCRUTE(_path);ISCRUTE(*numdt);goto ERROR;
135 }
136
137 if (_MEDattrFloatLire(_datagroup1,MED_NOM_PDT,(med_float*) dt) < 0) {
138 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_PDT);
139 SSCRUTE(_path);RSCRUTE(*dt);goto ERROR;
140 }
141
142 if (_MEDattrEntierLire(_datagroup1,MED_NOM_NOR,(med_int*) numit) < 0) {
143 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NOR);
144 SSCRUTE(_path);ISCRUTE(*numit);goto ERROR;
145 }
146
147 if (_MEDattrStringLire(_datagroup1,MED_NOM_MAI,MED_TAILLE_NOM,meshname) < 0) {
148 MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_MAI);
149 SSCRUTE(_path);SSCRUTE(meshname);goto ERROR;
150 }
151
152
153 /* Nombre de maillages
154 * La gestion d'une incohérence sur le nombre de séquences de calcul par couple (entitytype,geotype)
155 * se fait à partir des appels :
156 * MEDfieldnProfile,MEDfieldnValue*
157 * La vérification complémentaire que l'ensemble des maillages utilisés sont les mêmes pour toutes les séquences
158 * de calcul identiques est effectué dans MEDfield23nValue
159 */
160 if ( (_err=_MEDnObjects(_datagroup1,".",&_nmesh)) <0)
161 if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
162 MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_path);
163 goto ERROR;
164 }
165 *nmesh = (med_int) _nmesh;
166
167
168 /* Maillage local ou distant */
169 strcat(_meshpath,meshname);
170
171 /* Le maillage est il distant */
172 if ( (_meshgid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
173
174 /* Verifie que le maillage est bien référencé comme distant */
175 strcat(_linkpath,meshname);
176 if ((_linkgid = _MEDdatagroupOuvrir(fid,_linkpath)) < 0) {
177 /* MED_ERR_(_ret,MED_ERR_DOESNTEXIST,MED_ERR_MESH,MED_ERR_FIELD_MSG); */
178 /* SSCRUTE(fieldname);SSCRUTE(_meshpath);SSCRUTE(_linkpath); */
179 /* goto ERROR; */
180 *localmesh = MED_FALSE;
181 }
182 *localmesh = MED_FALSE;
183 } else
184 *localmesh = MED_TRUE;
185
186 *meshnumdt=MED_NO_DT;
187 *meshnumit=MED_NO_IT;
188
189 _ret = 0;
190
191 ERROR:
192
193 if (_datagroup1>0) if (_MEDdatagroupFermer(_datagroup1) < 0) {
194 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
195 ISCRUTE_id(_datagroup1);
196 }
197
198 if (_meshgid>0) if (_MEDdatagroupFermer(_meshgid) < 0) {
199 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
200 ISCRUTE_id(_meshgid);
201 }
202
203 if (_linkgid>0) if (_MEDdatagroupFermer(_linkgid) < 0) {
204 MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_linkpath);
205 ISCRUTE_id(_linkgid);
206 }
207
208 va_end(params);
209 *fret = _ret;
210 return;
211
212 }
213