00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 
00042 med_err
00043 MEDsubdomainJointCr(const med_idt      fid,
00044                     const char * const localmeshname,
00045                     const char * const jointname,
00046                     const char * const description,
00047                     const med_int      domainnumber,
00048                     const char * const remotemeshname)
00049 {
00050   med_access_mode _MED_ACCESS_MODE;
00051   med_idt        _root=0,_jntid=0,_meshid=0;
00052   med_err        _ret=-1;
00053   char           _path[MED_TAILLE_JNT+MED_NAME_SIZE+1]=MED_JNT;
00054 
00055   
00056 
00057 
00058   _MEDmodeErreurVerrouiller();
00059  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00060 
00061   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00062     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00063     goto ERROR;
00064   }
00065 
00066   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
00067     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00068     ISCRUTE_int(_MED_ACCESS_MODE);
00069     goto ERROR;
00070   }
00071 
00072   
00073 
00074 
00075   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0)
00076     if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
00077       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
00078      goto ERROR;
00079     }
00080 
00081   NOFINALBLANK(localmeshname,ERROR);
00082 
00083   
00084 
00085 
00086   if ((_meshid = _MEDdatagroupOuvrir(_root,localmeshname)) < 0)
00087     if ((_meshid = _MEDdatagroupCreer(_root,localmeshname)) < 0) {
00088       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,localmeshname);
00089       SSCRUTE(_path);goto ERROR;
00090     }
00091 
00092   strcat(_path,localmeshname);
00093   NOFINALBLANK(jointname,ERROR);
00094 
00095   
00096 
00097 
00098   if ((_jntid = _MEDdatagroupOuvrir(_meshid,jointname)) < 0)
00099     if ((_jntid = _MEDdatagroupCreer(_meshid,jointname)) < 0 ) {
00100       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,jointname);
00101       SSCRUTE(_path);goto ERROR;
00102     }
00103 
00104  
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118   
00119 
00120 
00121   if ((_ret = _MEDattributeStringWr(_jntid,MED_NOM_DES,MED_COMMENT_SIZE,
00122                                    description)) < 0) {
00123     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
00124     SSCRUTE(jointname);SSCRUTE(MED_NOM_DES);SSCRUTE(description);
00125     goto ERROR;
00126   }
00127 
00128   
00129 
00130 
00131   if ((_ret = _MEDattributeStringWr(_jntid,MED_NOM_MAI,MED_NAME_SIZE,
00132                                    remotemeshname)) < 0) {
00133     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
00134     SSCRUTE(jointname);SSCRUTE(MED_NOM_MAI);SSCRUTE(remotemeshname);
00135     goto ERROR;
00136   }
00137 
00138   
00139 
00140 
00141   if ((_ret = _MEDattributeIntWr(_jntid, MED_NOM_DOM, &domainnumber)) < 0) {
00142     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_SUBDOMAINJOINT_MSG);
00143     SSCRUTE(jointname);SSCRUTE(MED_NOM_DOM);ISCRUTE(domainnumber);
00144     goto ERROR;
00145   }
00146 
00147 
00148   _ret=0;
00149  ERROR:
00150 
00151   if (_jntid>0)            if (_MEDdatagroupFermer(_jntid) < 0) {
00152     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,jointname);
00153     ISCRUTE_id(_jntid);SSCRUTE(_path);
00154   }
00155 
00156   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00157     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00158     ISCRUTE_id(_jntid);
00159   }
00160 
00161   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00162     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_JNT);
00163     ISCRUTE_id(_jntid);
00164   }
00165 
00166   return _ret;
00167 }
00168 
00169 
00170