track_cells.F [SRC] [CPP] [JOB] [SCAN]
TOOLS / TRACK_CELLS / SRC



   1 | include(dom.inc)
   2 | !    ===============================================================
   3 | !    Copyright (c) CERFACS (all rights reserved)
   4 | !    ===============================================================
   5 | 
   6 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   7 | !
   8 | !    Subroutine for finding the indices of the cells nearest to a list
   9 | !    of points in space. Output is written to 'Track.in' that is
  10 | !    used for track_cellsing nodal values in time by AVBP.
  11 | ! 
  12 | ! Author: T. PEDOT
  13 | ! Based on track_cells TOOLS of AVBP
  14 | !
  15 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  16 |         program prog_track_cells
  17 | 
  18 |         implicit none
  19 |         include 'dom_constants.h'
  20 |        
  21 |         CHARACTER*160  :: path,outpath, ccfile,gdatfile,trackfile
  22 |         CHARACTER*160  :: FMT
  23 |         DOM_INT       ::  ntcells,ntnodes,ntfaces,nnmaxfaces,ndirs,axis 
  24 |         DOM_INT 
  25 |      &         n,npmax,npts,index,np,i
  26 |         DOM_REAL
  27 |      &         xmin,xmax,ymin,ymax,zmin,zmax,
  28 |      &         xn,yn,zn,xp,yp,zp,
  29 |      &         r,big,zero
  30 | 
  31 |         DOM_INT ,dimension(:),allocatable::
  32 |      &         inear
  33 |         DOM_REAL,dimension(:),allocatable::
  34 |      &         x,y,z,xpt,ypt,zpt,rmin
  35 | !       DOM_REAL,dimension(3)            ::
  36 | !    &         norm
  37 | 
  38 | 
  39 |          big = 1.0d+15
  40 |          zero = 0.d0
  41 | ! **********************************
  42 | !  Reading of the input file 
  43 | !  For dynamic memory allocation
  44 | ! **********************************
  45 |       write(*,*) 
  46 |       write(*,*) 'I - First reading the input file'
  47 |       n = 0
  48 |       open( unit=1, file='track_cells.choices', form='formatted' )
  49 |         read(1,*) path
  50 | 1       read(1,*,end=99) 
  51 |         n = n+1
  52 |         goto 1
  53 | 99    close(1)
  54 |       npts = n
  55 |       write(*,*) 'Found ',npts,' points'
  56 | ! **********************************
  57 | 
  58 | ! **********************************
  59 | ! Local Dynamic memory allocation
  60 | ! **********************************
  61 |       allocate(xpt(1:npts))      
  62 |       allocate(ypt(1:npts))
  63 |       allocate(zpt(1:npts))
  64 |       allocate(rmin(1:npts))
  65 |       allocate(inear(1:npts))
  66 | ! **********************************  
  67 | 
  68 | ! **********************************
  69 | !  Reading of the input file
  70 | ! **********************************
  71 |       open( unit=1, file='track_cells.choices', form='formatted' )
  72 |         read(1,*) path
  73 |         do n = 1, npts
  74 |          read(1,*) xpt(n),ypt(n),zpt(n)
  75 |         enddo
  76 |       close(1)  
  77 | ! **********************************
  78 |       ccfile   = trim(path)//'/Centercells.in'
  79 |       gdatfile = trim(path)//'/Global.in'
  80 | ! **********************************
  81 | !  Reading the coordinates
  82 | ! **********************************
  83 |       write(*,*) 
  84 |       write(*,*) 'II - Reading node coordinates'
  85 |       
  86 |       OPEN(FILE_GDATA, FILE=gdatfile , FORM='UNFORMATTED')
  87 |       READ(FILE_GDATA) ntcells,ntnodes,ntfaces,nnmaxfaces,ndirs 
  88 | 
  89 |       allocate(x(1:ntcells))
  90 |       allocate(y(1:ntcells))
  91 |       allocate(z(1:ntcells))
  92 |       CLOSE(FILE_GDATA)
  93 | 
  94 |       open(FILE_CCELL, FILE=ccfile, FORM='UNFORMATTED')
  95 |       
  96 |       do n =1,ntcells
  97 |         READ(FILE_CCELL) i, x(i),y(i),z(i)    
  98 |       enddo    
  99 |       CLOSE(FILE_CCELL)
 100 | 
 101 | ! **********************************
 102 | 
 103 | 
 104 |       write(*,*)
 105 |       write(*,*) 'III - Finding nearest nodes'
 106 | 
 107 | 
 108 |       xmin = big
 109 |       xmax = -big
 110 |       ymin = big
 111 |       ymax = -big
 112 |       zmin = big
 113 |       zmax = -big
 114 | 
 115 |       do np=1,npts
 116 |          inear(np) = -1
 117 |          rmin(np)  = big
 118 |       enddo
 119 | 
 120 | 
 121 |       do n=1,ntcells
 122 |          xn=x(n)
 123 |          yn=y(n)
 124 |          zn=z(n)
 125 | !        else
 126 | !          zn=zero
 127 | !        endif
 128 | 
 129 |          xmin=min(xmin,xn)
 130 |          xmax=max(xmax,xn)
 131 |          ymin=min(ymin,yn)
 132 |          ymax=max(ymax,yn)
 133 |          zmin=min(zmin,zn)
 134 |          zmax=max(zmax,zn)
 135 |          
 136 |          do np=1,npts
 137 | 
 138 |             xp=xpt(np)
 139 |             yp=ypt(np)
 140 | !            if (ndirs.eq.3) then
 141 |                zp=zpt(np)
 142 | !            else
 143 | !               zp=zero
 144 | !            endif
 145 | 
 146 |             r=dsqrt((xp-xn)**2+(yp-yn)**2+(zp-zn)**2)
 147 | 
 148 |             if ( r.lt.rmin(np) ) then
 149 | 
 150 |                rmin (np) = r
 151 |                inear(np) = n
 152 |             endif
 153 | 
 154 |          enddo
 155 | 
 156 |       enddo
 157 | 
 158 |       write(*,*) '     Mesh extent'
 159 |       write(*,*) '     x ',xmin,xmax
 160 |       write(*,*) '     y ',ymin,ymax
 161 | !      if (ndirs.eq.3) then
 162 |       write(*,*) '     z ',zmin,zmax
 163 | !      endif
 164 | 
 165 | !
 166 | ! -----------------------
 167 | !     Write output file
 168 | ! -----------------------
 169 | !
 170 | 
 171 |       write(*,*)
 172 |       write(*,*) 'IV - Writing output for AVBP'
 173 |       trackfile = trim(path)//'/Track.in'
 174 |       open(10,file=trackfile,form='formatted')
 175 | !     write(10,FMT) npts,                     
 176 | !    +'! Number of nodes/node coor. + dist.to tracking cell'
 177 |       FMT ='(I3,32X,A)'
 178 |       WRITE(10,FMT) npts, 'index Norm_X Norm_Y Norm_Z X Y Z dist_track'
 179 |       FMT ='(I3,2X,I7.7,2X,A30,2X,4(1X,E15.6))'
 180 |       do np=1,npts
 181 |          index = inear(np)
 182 |          xn = x(index)
 183 |          yn = y(index)
 184 |          zn = z(index)
 185 | 
 186 |             write(10,FMT) np,index,'0.0d0  0.0d0  0.0d0',
 187 |      +                     xn,yn,zn,rmin(np)
 188 | 
 189 | 
 190 |       enddo
 191 |       close(10)
 192 | 
 193 | 
 194 |       end program prog_track_cells
 195 | 
 196 | 


track_cells.F could be called by:
Makefile [TOOLS/TRACK_CELLS] - 46 - 51 - 57 - 91
track_cells [TOOLS/SCRIPTS] - 26 - 27 - 30 - 31 - 32