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 
25 /*TODO : Test unitaire */
_MEDsubdomainComputingStepInfo30(int dummy,...)26 void _MEDsubdomainComputingStepInfo30(int dummy, ...) {
27 
28 
29   med_err  _ret=-1,_err=-1;
30   med_idt  _eqid=0,_datagroup1=0;
31   int      _num;
32   char     _cstppath[MED_JOINT_GRP_SIZE+2*MED_NAME_SIZE+2+2*MED_MAX_PARA+1]=MED_JOINT_GRP;
33   char     _cstpname[2*MED_MAX_PARA+1]="";
34   med_size _ncorrespondence=0;
35 
36   MED_VARGS_DECL(const, med_idt      , , fid             );
37   MED_VARGS_DECL(const, char * , const , meshname        );
38   MED_VARGS_DECL(const, char * , const , jointname       );
39   MED_VARGS_DECL(const, int          , , csit            );
40   MED_VARGS_DECL(, med_int *, const    , numdt           );
41   MED_VARGS_DECL(, med_int *, const    , numit           );
42   MED_VARGS_DECL(, med_int *, const    , ncorrespondence );
43   MED_VARGS_DECL(, med_err *          ,, fret            );
44 
45   va_list params;
46   va_start(params,dummy);
47 
48   MED_VARGS_DEF(const, med_idt      , , fid             );
49   MED_VARGS_DEF(const, char * , const , meshname        );
50   MED_VARGS_DEF(const, char * , const , jointname       );
51   MED_VARGS_DEF(const, int          , , csit            );
52   MED_VARGS_DEF(, med_int *, const    , numdt           );
53   MED_VARGS_DEF(, med_int *, const    , numit           );
54   MED_VARGS_DEF(, med_int *, const    , ncorrespondence );
55   MED_VARGS_DEF(, med_err *          ,, fret            );
56 
57   _num = csit -1;
58 
59   /*
60    * On inhibe le gestionnaire d'erreur
61    */
62   _MEDmodeErreurVerrouiller();
63 
64   strcat( _cstppath, meshname);
65   strcat( _cstppath, "/");
66   strcat( _cstppath, jointname);
67 
68   if ((_eqid = _MEDdatagroupOuvrir(fid,_cstppath)) < 0) {
69     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_cstppath);
70     ISCRUTE_id(_eqid);goto ERROR;
71   }
72 
73   strcat( _cstppath, "/");
74   /*
75    * On recupere le nom de l'~tape de calcul
76    */
77   if ( _MEDobjectGetName(fid, _cstppath ,_num, &_cstppath[strlen(_cstppath)]) < 0 ) {
78     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_cstppath);ISCRUTE_int(csit);
79     goto ERROR;
80   }
81 
82   if ( (_datagroup1 = _MEDdatagroupOuvrir(fid,_cstppath)) < 0 ) {
83     MED_ERR_(_ret,MED_ERR_DOESNTEXIST,MED_ERR_COMPUTINGSTEP,_cstppath);
84     SSCRUTE(_cstppath);goto ERROR;
85   }
86 
87   /*Cree ou ouvre l'attribut MED_NOM_NDT pour lecture */
88   if ( _MEDattrEntierLire(_datagroup1,MED_NOM_NDT,numdt) < 0 ) {
89     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
90     SSCRUTE(jointname);SSCRUTE(_cstppath);SSCRUTE(MED_NOM_NDT);
91     ISCRUTE(*numdt);goto ERROR;
92   }
93 
94 
95   /*Cree ou ouvre l'attribut MED_NOM_PDT pour lecture */
96 /*   if ( _MEDattrFloatLire(_datagroup1,MED_NOM_PDT,dt) < 0) { */
97 /*     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG); */
98 /*     SSCRUTE(jointname);SSCRUTE(_cstppath);SSCRUTE(MED_NOM_PDT); */
99 /*     RSCRUTE(*dt);goto ERROR; */
100 /*   } */
101 
102   /*Cree ou ouvre l'attribut MED_NOM_NOR pour lecture */
103   if ( _MEDattrEntierLire(_datagroup1,MED_NOM_NOR,numit) < 0) {
104     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
105     SSCRUTE(jointname);SSCRUTE(_cstppath);SSCRUTE(MED_NOM_NOR);
106     ISCRUTE(*numit); goto ERROR;
107   }
108 
109   /*
110    * Nombre de tableau d'~quivalence
111    */
112   if ((_err=_MEDnObjects(_datagroup1,".",&_ncorrespondence)) <0)
113     if ( _err == (MED_ERR_COUNT + MED_ERR_DATAGROUP) ) {
114       MED_ERR_(_ret,MED_ERR_COUNT,MED_ERR_DATAGROUP,_cstppath);
115       goto ERROR;
116     }
117 
118   *ncorrespondence = (med_int) _ncorrespondence;
119 
120   _ret = 0;
121  ERROR:
122 
123   if (_eqid>0)     if (_MEDdatagroupFermer(_eqid) < 0) {
124     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
125     ISCRUTE_id(_eqid);
126   }
127 
128   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
129     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_cstppath);
130     ISCRUTE_id(_datagroup1);
131   }
132 
133   va_end(params);
134   *fret = _ret;
135   return;
136 }
137