Index: /issm/trunk/src/c/Bamgx/Mesh2.h
===================================================================
--- /issm/trunk/src/c/Bamgx/Mesh2.h	(revision 2797)
+++ /issm/trunk/src/c/Bamgx/Mesh2.h	(revision 2798)
@@ -61,6 +61,4 @@
 
 class MeshIstream;
-class OFortranUnFormattedFile;
-class IFortranUnFormattedFile;
 
 extern int hinterpole;
Index: /issm/trunk/src/c/Bamgx/Meshio.cpp
===================================================================
--- /issm/trunk/src/c/Bamgx/Meshio.cpp	(revision 2797)
+++ /issm/trunk/src/c/Bamgx/Meshio.cpp	(revision 2798)
@@ -33,5 +33,4 @@
 	long int verbosity=2;
 
-const char *OFortranUnFormattedFile::unkown("unkown file name");
 void (*MeshIstreamErrorHandler)(ios & ) =0;
 ///////////////////////////////////////////////////////////
@@ -48,94 +47,4 @@
  out << '"' ;
 }
-///////////////////////////////////////////////////////////
-double * ReadbbFile(const char * file,long & nbsol,long & lsol,const int typesol,const int dim)
-{
-
-  MeshIstream frbb(file);
-  int dimlu,typesollu;
-  long i;
- double *sol =0;
-  frbb >>    dimlu >> nbsol >> lsol >> typesollu ;
-  if(typesol != typesollu )
-    { 
-      cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " <<  typesol << endl;
-      cerr << "  or       dim  of solution (read) " << dimlu  << " != (wanted) " <<  dim << endl;
-      nbsol=0;
-      lsol=0;
-    }
-  else
-    {
-      sol = new double[lsol*nbsol];
-      double *s=sol;
-      for(  i=0;i<lsol;i++)
-	for (long j=0;j<nbsol;j++)
-	  frbb >>  *s++ ;
-      //      frbb.close();
-    }
-
-  
-  return sol;
-}
-
-///////////////////////////////////////////////////////////
-double * ReadBBFile(const char * file,long & nbsol,long & lsol,int *& typesols,
-  const int dim,const int typesol)
-{
-
-  MeshIstream frbb(file);
-  int dimlu,typesollu;
-  typesols = 0;
-  long i,n=0;
-  double *sol =0;
-  int sizeoftype[] = { 1, dim ,dim * (dim+1) / 2, dim * dim } ;
-  // char * charoftype[] = {  "Scalar" , "dim Vector" ,"dim x dim Sym-Matric","dim x dim Full-Matric" } ;
-  frbb >>    dimlu >> nbsol ;
-  typesols = new int [nbsol] ;
-  for (i=0;i<nbsol;i++)
-    {
-     frbb >> typesols[i];
-     typesols[i]--;
-     if (typesols[i]<0 || typesols[i]>= 4)
-       {
-	 cerr << " Error reading BBFile the type solution " << i+1 << " is " << typesols[i]+1 
-	      << " is not in [1..4] " << endl;
-	   frbb.ShowIoErr(998);
-	 nbsol=0;
-	 lsol=0;
-	 delete [] typesols;
-	 typesols=0;
-	 return 0; 
-       }
-     n += sizeoftype[ typesols[i]];
-    }
-  frbb >> lsol >> typesollu ;
-  if(typesol != typesollu )
-    { 
-      cerr << " incorrect type of solution (read) " << typesollu << " != (wanted) " <<  typesol << endl;
-      cerr << "  or       dim  of solution (read) " << dimlu  << " != (wanted) " <<  dim << endl;
-      frbb.ShowIoErr(999);
-      nbsol=0;
-      lsol=0;
-    }
-  else
-    {
-      if (verbosity> 5)
-	cout << "     read BB file " << file << "  with nbsol " << nbsol << " total nb of field = " << n << endl; 
-      if (verbosity>9) 
-	for (i=0;i<nbsol;i++)
-	  cout << "      the type of solution " << i+1 << " is " <<  sizeoftype[ typesols[i]]  
-	       << " and  the number of sub-field are " << sizeoftype[ typesols[i]] << endl; 
-      sol = new double[lsol*n];
-      double *s=sol;
-      for(  i=0;i<lsol;i++)
-	for (long j=0;j<n;j++)
-	  frbb >>  *s++ ;
-      //      frbb.close();
-    }
-
-  
-  return sol;
-}
-
 
 void MeshIstream::ShowIoErr(int s) {
@@ -229,147 +138,3 @@
   return r ;  
 }
-///////////////////////////////////////////////////////////
-OFortranUnFormattedFile::~OFortranUnFormattedFile()
-{
-  // save the last record 
-  if (l==0) { // l rec no set --
-    l=where();
-  if (verbosity>9)
-    cout << " size of last record  = " 
-	 << l << " n = " << nb_rec << " i= " << i << endl;
-   if (!f->good()) Error(3);
-    f->seekp(i-sizeof(long));
-   if (!f->good()) Error(3);
-    f->write((char*)&l,sizeof(l)); 
-    if (!f->good()) Error(3);
-   n=j;
-  }
-
-  f->seekp(n);
-  if (!f->good()) Error(3);
-   f->write((char*) &l,sizeof(l));
-  if (!f->good()) Error(3);
-   
-  if (f && to_close) {
-    if (verbosity>9)
-      cout << "delete OFortranUnFormattedFile " << file_name 
-	   << " @end  = " << n <<  endl;
-    delete f;} f=0;
-}
-
-IFortranUnFormattedFile::~IFortranUnFormattedFile()
-{
-  if (f && to_close) {
-    if (verbosity>9)
-      cout << " delete IFortranUnFormattedFile" << file_name 
-	   << "  @end = " << n <<  endl;
-    delete f;} f=0;
-}
-
-long IFortranUnFormattedFile::Record()
-{
-  nb_rec++;
-  n += sizeof(long);
-  f->seekg(n);
-  f->read((char*)&l,sizeof(l));
-  if (!f->good()) Error(3);
-  i=j= n+sizeof(l); 
-  n +=   l + sizeof(l) ; // end 
-  if (verbosity>9)
-  cout << " Read  rec end =" << n << " l=  " << l 
-       << " current= " << j << " begin= " << i << endl;
-  return l;
-}
-
-long OFortranUnFormattedFile::Record(long ll) //
-{
-  if (j==4 && l==0) 
-    { 
-      l=ll;
-      f->seekp(0);
-      f->write((char*)&ll,sizeof(l));
-      if (!f->good()) Error(3);
-      return 0;
-    }
-  if (n>=0) 
-    {
-      if (l==0) 
-	{ // l rec no set --
-	  l=where();
-	  if (verbosity>9)
-	    cout << " set len  of rec  " << nb_rec  << " = " << l 
-		 << " @ " << i-sizeof(long) << endl;
-
-	  f->seekp(i-sizeof(long));
-	  f->write((char*)&l,sizeof(l)); 
-	  n=j;
-	}
-      f->seekp(n);
-      f->write((char*)&l,sizeof(l)); 
-      if (!f->good()) Error(3);
-    }
-  else 
-    f->seekp(0);
-  n += sizeof(long);
-  nb_rec++;
-  f->write((char*)&ll,sizeof(l));
-  if (!f->good()) Error(3);
-  
-  l=ll;
-  n +=  sizeof(long);
-  j = n;
-  i = n;
-  n +=   l;
-  if (verbosity>9)
-    cout << " Write rec end =" << n << " l=  " << l 
-	 << " current= " << j << " begin= " << i << endl;
-  return l;
-}
-void OFortranUnFormattedFile::Error(int err)
-{
-  cerr << "Fatal Error Output FortranUnFormattedFile " << endl;
-  if (err==0) 
-    cerr << "-- Error openning ";
-  else if (err==1)
-    cerr<< "-- OverFlow write ";
-  else if (err==2)
-    cerr<< "-- Erreur  write " ;
-  else if (err==3)
-    cerr<< "-- Erreur  write record info " ;
-  else 
-    cerr << " unkown err " << err ;
-
-  cerr << " Record number = "    << nb_rec << endl
-       << " read position  in file " << j << " < " << n 
-       << " =  end on record " << endl;
-  cerr << " position in the record = " << where() 
-       << " length of record = " << l <<endl;
-  cerr 	<< " file = " << file_name<< endl ;
-  MeshError(900);
-  //  throw(ErrorMesh("exit",1));
-}
-void IFortranUnFormattedFile::Error(int err)
-{
-  cerr << "Fatal Error Input FortranUnFormattedFile " << endl;
-  if (err==0) 
-    cerr << " Error openning ";
-  else if (err==1)
-    cerr<< " OverFlow read";
-  else if (err==2)
-    cerr<< " Erreur  read" ;
-  else if (err==3)
-    cerr<< " Erreur  read record info " ;
-  else 
-    cerr << " unkown err " << err ;
-
-  cerr << " Record number = "    << nb_rec << endl
-       << " read position  in file " << j << " < " << n 
-       << " =  end on record " << endl;
-  cerr << " position in the record = " << where() 
-       << " length of record = " << l <<endl;
-  cerr 	<< " file = " << file_name<< endl ;
-    MeshError(900);
-    //  throw(ErrorMesh("exit",1));
-}
-
 }// end of namespace bamg 
Index: /issm/trunk/src/c/Bamgx/Meshio.h
===================================================================
--- /issm/trunk/src/c/Bamgx/Meshio.h	(revision 2797)
+++ /issm/trunk/src/c/Bamgx/Meshio.h	(revision 2798)
@@ -48,8 +48,4 @@
 
 void WriteStr(ostream & out,char * str);
-
-double * ReadbbFile(const char * file,long & nbsol,long & lsol,const int dim=2,const int typesol=2);
-double * ReadBBFile(const char * file,long & nbsol,long & lsol,int *& typesols,const int dim=2,const int typesol=2);
-// solution at vertex (P1)
 
 union Char4orLong {  char c[4];    long l;} ;
@@ -114,131 +110,6 @@
 
 };
-// Fortran unformatted file  interface ----------
-
-class IFortranUnFormattedFile {
-//  template<class T> friend IFortranUnFormattedFile & operator>>(IFortranUnFormattedFile &f,T & l);
-  istream * f;
-  long i,l,n,j,nb_rec;
-  const char * file_name;
-  int to_close;
- public:
-  IFortranUnFormattedFile(char *name)
-    : f(new ifstream(name)),i(0),l(0),n((long)-sizeof(long)),
-      nb_rec(0),file_name(name), to_close(1)
-    { if(!*f) Error(0);}
-
-  IFortranUnFormattedFile(MeshIstream & ff)
-    : f(&ff.in),i(0),l(0),n((long)-sizeof(long)),nb_rec(0),
-      file_name(ff.CurrentFile), to_close(0)
-    { if(! *f)  Error(0);}
-  
- ~IFortranUnFormattedFile();
-  long Record();
-  long where(){return j-i;}
-  void  read4(char *c,int );// for the fortran 77 char4
-  void  read(char * p,const size_t lg);
-  void Error(int);
-};
-
-class OFortranUnFormattedFile {
-//  template<class T> friend OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const T & l);
-  ostream * f;
-  long i,l,n,j,nb_rec;
-  const static char * unkown;
-  const char * file_name;
-  int to_close;
- public:
-  
-  OFortranUnFormattedFile(const char *name,IOS_OPENMODE  mm=ios::trunc)
-    : f(new ofstream(name,mm)),i(0),l(0),n((long) -sizeof(long)),nb_rec(0),file_name(name), to_close(1)
-    { if(!*f) Error(0);}
-  OFortranUnFormattedFile(ostream &ff)
-    : f(&ff),i(0),l(0),n((long) -sizeof(long)),nb_rec(0),file_name(unkown), to_close(0)
-    { if(!*f) Error(0);}
-  
-  ~OFortranUnFormattedFile();
-
-  long Record(long ll=0);
-  long where(){return j-i;} 
-  void write4(const char *c,int );// for the fortran 77 char4
-  void write(const char * p,const size_t lg);
-  void Error(int );
-};
 
 /// ---------- inline -------------------------
 
-inline void  IFortranUnFormattedFile::read(char * p,const size_t lg){  
-  f->read(p,lg);
-  j+=lg;
-  if (j>n) Error(1);
-  else if (!f->good()) Error(2) ;
 }
-
-inline void  OFortranUnFormattedFile::write(const char * p,const size_t lg){  
-   f->write(p,lg);
-   j+=lg;
-   if (l && j>n)  Error(1);
-   else if (!f->good()) Error(2);
-}
-
-template<class T> inline
-IFortranUnFormattedFile & operator>>(IFortranUnFormattedFile &f,T & l)
-{  
-  f.read((char *) &l,sizeof(l));return f;
-}
-/*  bug sur sun  
-template inline 
- OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const T & l)
- { 
-   f.write((char *) &l,sizeof(l));return f;
- }
-on ex les template  */ 
-
-inline 
- OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const int  & l)
- { 
-   f.write((char *) &l,sizeof(l));return f;
- }
-inline 
- OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const long  & l)
- { 
-   f.write((char *) &l,sizeof(l));return f;
- }
-inline 
- OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const double  & l)
- { 
-   f.write((char *) &l,sizeof(l));return f;
- }
-inline 
- OFortranUnFormattedFile & operator<<(OFortranUnFormattedFile &f,const float & l)
- { 
-   f.write((char *) &l,sizeof(l));return f;
- }
-
-inline void OFortranUnFormattedFile::write4(const char *c,int ll)
-{
-  int i,j;
-  Char4orLong ch4;
-  for ( i=0;i<ll;i++)
-    {
-      ch4.l=0;
-      for (j=0;j<4;j++)
-	ch4.c[j]=*c? *c++:' ';
-      *this << ch4.l;
-    }
-}
-inline void IFortranUnFormattedFile::read4(char *c,int ll)
-{
-  int i,j;
-  Char4orLong ch4;
-
-  for ( i=0;i<ll;i++)
-    {
-      *this >> ch4.l;
-      for (j=0;j<4;j++)
-	*c++= ch4.c[j];
-    }
-  *c=0;// end of string 
-}
-
-}
Index: /issm/trunk/src/c/objects/BamgGeom.h
===================================================================
--- /issm/trunk/src/c/objects/BamgGeom.h	(revision 2797)
+++ /issm/trunk/src/c/objects/BamgGeom.h	(revision 2798)
@@ -30,4 +30,7 @@
 	double* RequiredEdges;
 
+	int     NumCrackedEdges;
+	double* CrackedEdges;
+
 	int     NumSubDomains;
 	double* SubDomains;
Index: /issm/trunk/src/mex/Bamg/Bamg.cpp
===================================================================
--- /issm/trunk/src/mex/Bamg/Bamg.cpp	(revision 2797)
+++ /issm/trunk/src/mex/Bamg/Bamg.cpp	(revision 2798)
@@ -63,4 +63,6 @@
 	bamggeom.NumRequiredEdges=0;
 	bamggeom.RequiredEdges=NULL;
+	bamggeom.NumCrackedEdges=0;
+	bamggeom.CrackedEdges=NULL;
 	FetchData(&NumSubDomainsGeom,mxGetField(BAMGGEOMETRY,0,"NumSubDomains"));
 	bamggeom.NumSubDomains=NumSubDomainsGeom;
@@ -125,10 +127,5 @@
 
 	/*Free ressources: */
-	xfree((void**)&VerticesGeom);
-	xfree((void**)&EdgesGeom);
-	xfree((void**)&hVerticesGeom);
-	xfree((void**)&SubDomainsGeom);
-	//xfree((void**)&TrianglesMesh);
-	//xfree((void**)&VerticesMesh);
+	//do not free any fields of bamgmesh or bamggeom as it has been freed in bamgx
 
 	/*end module: */
