[MOAB-dev] commit/MOAB: iulian07: replace free() calls from fortran with iMesh_freeMemory() calls

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Thu May 16 17:33:29 CDT 2013


1 new commit in MOAB:

https://bitbucket.org/fathomteam/moab/commits/df79abdb772f/
Changeset:   df79abdb772f
Branch:      master
User:        iulian07
Date:        2013-05-17 00:25:08
Summary:     replace free() calls from fortran with iMesh_freeMemory() calls
they will call underneath free() from c;
It seems that ibm fortran (xlf) does not like the mix between malloc in c and
free in fortran
function is added as an iMesh extension, and it should be used from fortran imesh
In iMesh C or C++ it is still fine  to just call free() directly.

Affected #:  3 files

diff --git a/itaps/imesh/FindAdjacencyF90.F90 b/itaps/imesh/FindAdjacencyF90.F90
index 78578a7..8115ef1 100644
--- a/itaps/imesh/FindAdjacencyF90.F90
+++ b/itaps/imesh/FindAdjacencyF90.F90
@@ -69,7 +69,7 @@ program findadjacency
 
      vert_uses = vert_uses + iverts_size
 
-     if (iverts_size .ne. 0) call free(rpverts)
+     if (iverts_size .ne. 0) call iMesh_freeMemory(%VAL(mesh), rpverts)
   end do
 
   ! now get adjacencies in one big block
@@ -81,9 +81,9 @@ program findadjacency
        offsets_size, ierr)
   CHECK("Failure in getEntArrAdj")
 
-  if (allverts_size .ne. 0) call free(rpallverts);
-  if (offsets_size .ne. 0) call free(ipoffsets);
-  if (ents_size .ne. 0) call free(rpents);
+  if (allverts_size .ne. 0) call iMesh_freeMemory(%VAL(mesh), rpallverts);
+  if (offsets_size .ne. 0) call iMesh_freeMemory(%VAL(mesh), ipoffsets);
+  if (ents_size .ne. 0) call iMesh_freeMemory(%VAL(mesh), rpents);
 
   ! compare results of two calling methods
   if (allverts_size .ne. vert_uses) then
@@ -119,6 +119,9 @@ program findadjacency
 !
   write(*, *) "num coords: ", ents_size, " few coords: ", (coords(i), i=0, ents_size/100)  
 
+  call iMesh_freeMemory(%VAL(mesh), verths);
+  call iMesh_freeMemory(%VAL(mesh), pcoord);
+
   call iMesh_dtor(%VAL(mesh), ierr)
   CHECK("Failed to destroy interface")
 

diff --git a/itaps/imesh/iMesh_MOAB.cpp b/itaps/imesh/iMesh_MOAB.cpp
index 963e740..6d55492 100644
--- a/itaps/imesh/iMesh_MOAB.cpp
+++ b/itaps/imesh/iMesh_MOAB.cpp
@@ -3423,3 +3423,13 @@ void iMesh_createStructuredMesh(iMesh_Instance instance,
   RETURN(iBase_SUCCESS);
 }
 
+void iMesh_freeMemory(
+        iMesh_Instance instance,
+          /**< [in] iMesh instance handle */
+         void ** ptrToMem)
+{
+  free(*ptrToMem);
+  *ptrToMem=0;
+  return;
+}
+

diff --git a/itaps/imesh/iMesh_extensions.h b/itaps/imesh/iMesh_extensions.h
index 8be6d22..c85571c 100644
--- a/itaps/imesh/iMesh_extensions.h
+++ b/itaps/imesh/iMesh_extensions.h
@@ -399,6 +399,15 @@ void iMesh_createStructuredMesh(
         int *err
           /**< [out] Error flag. */
 );
+/***************************************************************************//**
+ * \brief  Free memory allocated with malloc
+ *
+ ******************************************************************************/
+
+void iMesh_freeMemory(
+        iMesh_Instance instance,
+          /**< [in] iMesh instance handle */
+         void ** ptrToMem);
 
 /***************************************************************************//**
  * \defgroup ScdMesh Structured Mesh

Repository URL: https://bitbucket.org/fathomteam/moab/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the moab-dev mailing list