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 #include <stdlib.h>
24 
_MEDsubdomainCorrespondenceSize30(int dummy,...)25 void _MEDsubdomainCorrespondenceSize30(int dummy, ...) {
26 
27 
28   med_err  _ret=-1;
29   med_idt  _eqid=0,_datagroup1=0,_dataset=0;
30   char     _path[MED_JOINT_GRP_SIZE+2*MED_NAME_SIZE+2+2*MED_MAX_PARA+1+4*MED_TAILLE_NOM_ENTITE+4]=MED_JOINT_GRP;
31   char     _datagroupname1[2*MED_TAILLE_NOM_ENTITE+2]="";
32   char     _cstpname[2*MED_MAX_PARA+1]="";
33   med_size          _njointarray=0;
34   med_sorting_type  _sortingtype=0;
35   med_int           _intlocalentitype;
36   med_int           _intlocalgeotype;
37   char              _localgeotypename [MED_TAILLE_NOM_ENTITE+1]="";
38   char              _remotegeotypename  [MED_TAILLE_NOM_ENTITE+1]="";
39 
40 
41   MED_VARGS_DECL(const, med_idt              , , fid             );
42   MED_VARGS_DECL(const, char * , const         , meshname        );
43   MED_VARGS_DECL(const, char * , const         , jointname       );
44   MED_VARGS_DECL(const, med_int              , , numdt           );
45   MED_VARGS_DECL(const, med_int              , , numit           );
46   MED_VARGS_DECL(const, med_entity_type      , , localentitype   );
47   MED_VARGS_DECL(const, med_geometry_type    , , localgeotype    );
48   MED_VARGS_DECL(const, med_entity_type      , , remoteentitype  );
49   MED_VARGS_DECL(const, med_geometry_type    , , remotegeotype   );
50   MED_VARGS_DECL(, med_int *, const            , nentitycor      );
51   MED_VARGS_DECL(, med_err *                  ,, fret            );
52 
53   va_list params;
54   va_start(params,dummy);
55 
56   MED_VARGS_DEF(const, med_idt              , , fid             );
57   MED_VARGS_DEF(const, char * , const         , meshname        );
58   MED_VARGS_DEF(const, char * , const         , jointname       );
59   MED_VARGS_DEF(const, med_int              , , numdt           );
60   MED_VARGS_DEF(const, med_int              , , numit           );
61   MED_VARGS_DEF(const, med_entity_type      , , localentitype   );
62   MED_VARGS_DEF(const, med_geometry_type    , , localgeotype    );
63   MED_VARGS_DEF(const, med_entity_type      , , remoteentitype  );
64   MED_VARGS_DEF(const, med_geometry_type    , , remotegeotype   );
65   MED_VARGS_DEF(, med_int *, const            , nentitycor      );
66   MED_VARGS_DEF(, med_err *                  ,, fret            );
67 
68   /*
69    * On inhibe le gestionnaire d'erreur
70    */
71 
72   _MEDmodeErreurVerrouiller();
73 
74 
75   if ( MEDmeshSortingTypeRd(fid,meshname,&_sortingtype) < 0 ) {
76     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
77     SSCRUTE(meshname);ISCRUTE_int(_sortingtype);goto ERROR;
78   }
79 
80 
81   strcat( _path, meshname);
82   strcat( _path, "/");
83   strcat( _path, jointname);
84   strcat( _path, "/");
85   _MEDgetComputationStepName(_sortingtype,numdt,numit,&_path[strlen(_path)]);
86   strcat( _path, "/");
87 
88   /*
89    *  Construction du nom de  datagroup <localentitype>[.<localgeotype>].<remoteentitype>[.<remotegeotype>]
90    */
91   if (_MEDgetEntityTypeName(&_path[strlen(_path)],localentitype) < 0) {
92     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
93     ISCRUTE_int(localentitype);SSCRUTE(jointname);goto ERROR;
94   }
95   if ( localentitype != MED_NODE ) {
96     if ( _MEDgetInternalGeometryTypeName(0,_localgeotypename,localgeotype) < 0) {
97       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
98       ISCRUTE_int(localgeotype);SSCRUTE(jointname);goto ERROR;
99     }
100       strcat(_path,".");
101       strcat(_path,_localgeotypename);
102   }
103 
104   strcat(_path,".");
105 
106   if (_MEDgetEntityTypeName(&_path[strlen(_path)],remoteentitype) < 0) {
107     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ENTITY,MED_ERR_VALUE_MSG);
108     ISCRUTE_int(remoteentitype);SSCRUTE(jointname);goto ERROR;
109   }
110   if ( remoteentitype != MED_NODE ) {
111     if ( _MEDgetInternalGeometryTypeName(fid,_remotegeotypename,remotegeotype) < 0) {
112       MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_GEOMETRIC,MED_ERR_VALUE_MSG);
113       ISCRUTE_int(remotegeotype);SSCRUTE(jointname);goto ERROR;
114     }
115       strcat(_path,".");
116       strcat(_path,_remotegeotypename);
117   }
118 
119 
120   if ( (_datagroup1 = _MEDdatagroupOuvrir(fid,_path)) < 0 ) {
121     *nentitycor=0;
122     goto SORTIE;
123   }
124 
125   if ((_dataset = _MEDdatasetOuvrir(_datagroup1,MED_NOM_COR)) < 0) {
126     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATASET,MED_NOM_COR);
127     SSCRUTE(_path);
128     goto ERROR;
129   }
130 
131   if ( _MEDattrEntierLire(_dataset,MED_NOM_NBR,nentitycor) < 0) {
132     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
133     SSCRUTE(_path);SSCRUTE(MED_NOM_NBR);ISCRUTE(*nentitycor);
134     goto ERROR;
135   }
136 
137  SORTIE:
138   _ret = 0;
139  ERROR:
140 
141   if (_dataset>0)     if (_MEDdatasetFermer(_dataset) < 0) {
142     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATASET,MED_NOM_COR);
143     ISCRUTE_id(_dataset);
144   }
145 
146   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
147     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
148     ISCRUTE_id(_datagroup1);
149   }
150 
151   va_end(params);
152   *fret = _ret;
153   return;
154 }
155