[cig-commits] r19884 - seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH

ampuero at geodynamics.org ampuero at geodynamics.org
Tue Mar 27 14:00:53 PDT 2012


Author: ampuero
Date: 2012-03-27 14:00:53 -0700 (Tue, 27 Mar 2012)
New Revision: 19884

Modified:
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/decompose_mesh_SCOTCH.f90
   seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/fault_scotch.f90
Log:
minor clean up. Singleton pattern implemented for faults array in fault_scotch

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/decompose_mesh_SCOTCH.f90
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/decompose_mesh_SCOTCH.f90	2012-03-27 16:21:52 UTC (rev 19883)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/decompose_mesh_SCOTCH.f90	2012-03-27 21:00:53 UTC (rev 19884)
@@ -389,7 +389,7 @@
     if( nspec2D_moho > 0 ) print*, '  nspec2D_moho = ', nspec2D_moho
 
     call read_fault_files(localpath_name)
-    if (allocated(faults)) then 
+    if (faults_exist) then 
       call save_nodes_coords(nodes_coords,nnodes)
       call close_faults(nodes_coords,elmnts,nspec,nnodes,esize)    
 !JPA parallel fault      call reorder_fault_elements(nodes_coords,nnodes)
@@ -650,7 +650,8 @@
         
        close(15)
       
-       if (.not. allocated(faults)) cycle 
+       if (faults_exist) cycle 
+!jpa: TO DO: move all this to a subroutine in fault_scotch.f90
           ! write fault database
           write(prname, "(i6.6,'_Database_fault')") ipart
           open(unit=16,file=outputpath_name(1:len_trim(outputpath_name))//'/proc'//prname,&

Modified: seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/fault_scotch.f90
===================================================================
--- seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/fault_scotch.f90	2012-03-27 16:21:52 UTC (rev 19883)
+++ seismo/3D/FAULT_SOURCE/branches/new_fault_db/decompose_mesh_SCOTCH/fault_scotch.f90	2012-03-27 21:00:53 UTC (rev 19884)
@@ -1,8 +1,8 @@
 module fault_scotch
 
   implicit none
+  private 
 
-  private 
   type fault_type
     private 
     integer :: nspec
@@ -10,23 +10,32 @@
     integer, dimension(:,:), pointer  :: inodes1, inodes2 
   end type fault_type
 
+  ! Singleton design pattern: only one instance of this object can be created
   type(fault_type), allocatable, save :: faults(:) 
+
   double precision, dimension(:,:), allocatable, save :: nodes_coords_open
  
- 
   integer, parameter :: long = SELECTED_INT_KIND(18)
 
   double precision, parameter :: FAULT_GAP_TOLERANCE = 1.0d0
 
   public :: read_fault_files, fault_repartition, close_faults, write_fault_database, &
-            save_nodes_coords, nodes_coords_open, faults 
+            save_nodes_coords, nodes_coords_open, faults_exist
 !JPA parallel fault      , reorder_fault_elements
 
 CONTAINS 
+
 !==========================================================================================
+  logical function faults_exist()
 
-  Subroutine read_fault_files(localpath_name)
+  faults_exist = allocated(faults)
 
+  end function faults_exist
+
+!==========================================================================================
+
+  subroutine read_fault_files(localpath_name)
+
   character(len=256),intent(in) :: localpath_name    
   integer :: nbfaults, iflt, ier 
 
@@ -106,13 +115,12 @@
 
 
 ! ---------------------------------------------------------------------------------------------------
-! Saving nodes_coords to be used in SESAME for ibool_fault_side1 and side2
-   subroutine save_nodes_coords(nodes_coords,nnodes)
+! Saving nodes_coords with open split nodes to be used in SESAME for ibool_fault_side1 and side2
+   subroutine save_nodes_coords(nodes_coords)
    
-   integer, intent(in) :: nnodes
-   double precision, dimension(3,nnodes), intent(in) :: nodes_coords
+   double precision, dimension(:,:), intent(in) :: nodes_coords
   
-   allocate(nodes_coords_open(3,nnodes)) 
+   allocate(nodes_coords_open(size(nodes_coords,1),size(nodes_coords,2)))
    nodes_coords_open = nodes_coords 
  
    end subroutine save_nodes_coords   
@@ -243,14 +251,15 @@
 
 !===================================================================================================
   !--------------------------------------------------
-  ! Repartitioning : two coupled faultside1/side2 elements are transfered to the same partition
+  ! Repartitioning : two coupled fault side1/side2 elements are transfered to the same partition
   !--------------------------------------------------
 
   Subroutine fault_repartition (nelmnts, nnodes, elmnts, nsize, &
                         nproc, part, esize)
 
-!     part : iproc number of processor partioned. It will altered patching fault elements into the same partion.  
-!     Part, once is altered , will be input for write_partition_database.
+!     part(e) = index of the processor to which element #e is assigned. 
+!               Fault elements and neighbors are assigned to the same processor.  
+!               Part, once modified, will be input for write_partition_database.
 
 !INPUTS
   integer(long), intent(in) :: nelmnts,nsize



More information about the CIG-COMMITS mailing list