*********************************************************************** program AssignRock *********************************************************************** c c Assigns rock type all elements within a specified domain. c c S. Finsterle c parameter (maxel=100000) character*5 elem,cmat,cbmat character*10 caht,cpermmod character*40 filein,fileout character*80 line dimension elem(maxel) write(*,*) write(*,*) ' Assign Rock Type' write(*,*) ' ****************' write(*,*) write(*,*) ' Input MESH file : ? ' read(*,'(a)')filein open(1,file=filein, status='old') write(*,*) ' Output MESH file : ? ' read(*,'(a)')fileout open(2,file=fileout,status='unknown') write(*,*) ' Rock type name (A5) : ? ' read(*,'(a)')cbmat write(*,*) ' Domain shape: 1=box ' write(*,*) ' 2=cylinder : ? ' read(*,*) ishape write(*,*) ' Xmin : ? ' read(*,*) xmin write(*,*) ' Xmax : ? ' read(*,*) xmax write(*,*) ' Ymin : ? ' read(*,*) ymin write(*,*) ' Ymax : ? ' read(*,*) ymax write(*,*) ' Zmin : ? ' read(*,*) zmin write(*,*) ' Zmax : ? ' read(*,*) zmax if (ishape.gt.1) then write(*,*) ' Radius : ? ' read(*,*) radius endif write(*,*) 2000 continue read(1,7000,end=9000) line 7000 format(a) call lenos(line,ll) write(2,7000) line(:ll) if (line(1:5).ne.'ELEME') goto 2000 iel=0 2001 continue c c --- elements iel=iel+1 if (mod(iel,1000).eq.1) & write(*,*) ' Working on element ',max(1,iel-1) read(1,7001) elem(iel),cmat,vol,caht,cpermmod,x,y,z 7001 format(a5,10x,a5,e10.4,2a10,3e10.4) if (elem(iel).eq.' ') goto 2002 call select(ishape,x,y,z,xmin,xmax,ymin,ymax,zmin,zmax, & radius,inout) if (inout.eq.1) cmat=cbmat read(cpermmod,'(e10.4)',iostat=ios) permmod if (abs(permmod).lt.1.0e-10) cpermmod=' ' read(caht,'(e10.4)',iostat=ios) aht if (abs(aht).lt.1.0e-10) caht=' ' write(2,7001) elem(iel),cmat,vol,caht,cpermmod,x,y,z goto 2001 2002 continue iel=iel-1 c c --- write rest of file write(2,7000) ' ' 2007 continue read(1,7000,end=9000) line call lenos(line,ll) write(2,7000) line(:ll) goto 2007 9000 continue close(1) close(2) end c --- end of AssignRocks *********************************************************************** subroutine lenos(string,lstr) *********************************************************************** character string*(*) lstr=1 ilenstr=len(string) if (ilenstr.eq.0) return do 1000 i=ilenstr,1,-1 if (string(i:i).ne.char(9).and.string(i:i).ne.' ') then lstr=i return endif 1000 continue end c --- end of lenos *********************************************************************** subroutine select(ishape,x,y,z,xmin,xmax,ymin,ymax,zmin,zmax, & radius,ini) *********************************************************************** ini=0 if (ishape.eq.1) then if (x.ge.xmin.and.x.le.xmax.and. & y.ge.ymin.and.y.le.ymax.and. & z.ge.zmin.and.z.le.zmax) ini=1 else if (ishape.eq.2) then dotp=(xmin-x)*(xmax-xmin)+ & (ymin-y)*(ymax-ymin)+ & (zmin-z)*(zmax-zmin) x2x1=(xmax-xmin)*(xmax-xmin)+ & (ymax-ymin)*(ymax-ymin)+ & (zmax-zmin)*(zmax-zmin) t=-dotp/x2x1 if (t.ge.0. .and. t.le. 1.0) then x1x=(xmin-x)*(xmin-x)+ & (ymin-y)*(ymin-y)+ & (zmin-z)*(zmin-z) dist=(x1x*x2x1-dotp*dotp)/x2x1 if (dist.le.radius*radius) ini=1 endif endif end c --- end of select