psmile_move0_neighbors.F90

Go to the documentation of this file.
00001 !-----------------------------------------------------------------------
00002 ! Copyright 2006-2010, NEC Europe Ltd., London, UK.
00003 ! All rights reserved. Use is subject to OASIS4 license terms.
00004 !-----------------------------------------------------------------------
00005 !BOP
00006 !
00007 ! !ROUTINE: PSMILe_Move0_neighbors
00008 !
00009 ! !INTERFACE:
00010 
00011       subroutine psmile_move0_neighbors (neighbors, nloc, num_neigh, &
00012                                          ierror)
00013 !
00014 ! !USES:
00015 !
00016       use PRISM_constants
00017 !
00018       use PSMILe, dummy_interface => PSMILe_Move0_neighbors
00019 
00020       implicit none
00021 !
00022 ! !INPUT PARAMETERS:
00023 
00024       Integer, Intent (In)            :: nloc
00025 !
00026 !     Number of locations
00027 !
00028       Integer, Intent (In)            :: num_neigh
00029 !
00030 !     Last dimension of neighbors array "neighbors"
00031 !
00032 ! !INPUT/OUTPUT PARAMETERS:
00033 !
00034       Integer, Intent (InOut)         :: neighbors (nloc, num_neigh)
00035 !
00036 !     1D-Indices of neighbor locations (interpolation bases)
00037 !
00038 ! !OUTPUT PARAMETERS:
00039 !
00040       Integer, Intent (Out)           :: ierror
00041 
00042 !     Returns the error code of PSMILE_Move0_neighbors;
00043 !             ierror = 0 : No error
00044 !             ierror > 0 : Severe error !
00045 ! !LOCAL VARIABLES
00046 !
00047 !     ... 
00048 !
00049       Integer                         :: i, j, n
00050       Integer                         :: ibeg, jbeg, jend, num1
00051 !
00052 ! !DESCRIPTION:
00053 !
00054 ! Subroutine "PSMILe_Move0_neighbors" moves the 0 entries (code for no 
00055 ! interpolation base) of 1d-indices to the end of the neighbour list.
00056 !
00057 !
00058 ! !REVISION HISTORY:
00059 !
00060 !   Date      Programmer   Description
00061 ! ----------  ----------   -----------
00062 ! 03.07.21    H. Ritzdorf  created
00063 !
00064 !EOP
00065 !----------------------------------------------------------------------
00066 !
00067 !  $Id: psmile_move0_neighbors.F90 2325 2010-04-21 15:00:07Z valcke $
00068 !  $Author: valcke $
00069 !
00070    Character(len=len_cvs_string), save :: mycvs = 
00071        '$Id: psmile_move0_neighbors.F90 2325 2010-04-21 15:00:07Z valcke $'
00072 !
00073 !----------------------------------------------------------------------
00074 !
00075 !  Initialization
00076 !
00077 #ifdef VERBOSE
00078       print 9990, trim(ch_id)
00079 
00080       call psmile_flushstd
00081 #endif /* VERBOSE */
00082 !
00083 #ifdef PRISM_ASSERTION
00084 #endif
00085 !
00086       ierror = 0
00087 !
00088 !===> Move 0 entries at the end of neighbours
00089 !
00090       num1 = num_neigh - 1
00091 !
00092          do n = num_neigh-1, 1, -1
00093             ibeg = 1
00094 !
00095             do while ( ibeg <= nloc ) 
00096 !cdir vector
00097                do i = ibeg, nloc
00098                if (neighbors (i,n) == 0) exit
00099                end do
00100 !
00101                if (i <= nloc) then
00102 !
00103 !===> ... Must elements to be changed ?
00104 !
00105                      do j = 1, num1
00106                      if (neighbors (i,j) == 0 .and. neighbors (i,j+1) > 0) exit
00107                      end do
00108 !
00109                   if (j <= num1) then
00110 !
00111 !===> ...... Find first 0 (at jbeg) to be moved
00112 !
00113                      jbeg = 1
00114                      jend = num_neigh
00115 !
00116                          do while ( jbeg <= jend ) 
00117 !
00118                             do j = jbeg, jend
00119                             if (neighbors (i,j) == 0) exit
00120                             end do
00121 !
00122                          if (j > jend) exit
00123                          jbeg = j
00124 !
00125 !===> ...... Find last significant number to be moved
00126 !
00127                             do j = jend, jbeg+1, -1
00128                             if (neighbors (i,j) > 0) exit
00129                             end do
00130 !
00131                          if (j < jbeg + 1) exit
00132 !
00133                          neighbors (i, jbeg) = neighbors (i, j)
00134                          neighbors (i, j) = 0
00135 !
00136                          jend = j - 1
00137                          jbeg = jbeg + 1
00138                      end do
00139                   endif
00140                endif
00141 !
00142                ibeg = i + 1
00143             end do ! while
00144 !
00145          end do ! n = num_neigh-1, 1, -1
00146 !
00147 !===> All done
00148 !
00149 #ifdef VERBOSE
00150       print 9980, trim(ch_id)
00151 
00152       call psmile_flushstd
00153 #endif /* VERBOSE */
00154 !
00155 !  Formats:
00156 !
00157 9990 format (1x, a, ': psmile_move0_neigbors')
00158 9980 format (1x, a, ': psmile_move0_neigbors: eof')
00159 
00160       end subroutine PSMILe_Move0_neighbors

Generated on 18 Mar 2011 for Oasis4 by  doxygen 1.6.1