Skip to content
Snippets Groups Projects
define_cloud.f90 7.4 KiB
Newer Older
  • Learn to ignore specific revisions
  • !------------------------------------------------------------------------------|
    !------------------------------------------------------------------------------|
    !                                                                              |
    !              ||===\\                                                         | 
    !              ||    \\                                                        |
    !              ||     ||   //==\\   ||  ||   //==||  ||/==\\                   |
    !              ||     ||  ||    ||  ||  ||  ||   ||  ||    ||                  |
    !              ||    //   ||    ||  ||  ||  ||   ||  ||                        |
    !              ||===//     \\==//    \\==\\  \\==\\  ||                        |
    !                                                                              |
    !------------------------------------------------------------------------------|
    !------------------------------------------------------------------------------|
    !                                                                              |
    !              DEFINE_CLOUD    Nov. 2006                                       |
    !                                                                              |
    !------------------------------------------------------------------------------|
    !------------------------------------------------------------------------------|
    
    subroutine define_cloud (cl,params)
    
    !------------------------------------------------------------------------------|
    !(((((((((((((((( Purpose of the routine  ))))))))))))))))))))))))))))))))))))))
    !------------------------------------------------------------------------------|
    ! if irestart=0, this routine allocates and creates the cloud of points present 
    ! in the system. Otherwise it reads from a user supplied file name the surfaces 
    ! as they were at the end of a previous run. In this case, since the run output 
    ! files contain all the octree+lsf+icloud+surface informations, the routine 
    ! first reads dummy parameters until it gets to the real interesting 
    ! cloud information 
    
    !------------------------------------------------------------------------------|
    !((((((((((((((((  declaration of the subroutine arguments  ))))))))))))))))))))
    !------------------------------------------------------------------------------|
    
    use definitions
    
    implicit none
    
    type (cloud) cl
    type (parameters) params
    
    !------------------------------------------------------------------------------|
    !(((((((((((((((( declaration of the subroutine internal variables )))))))))))))
    !------------------------------------------------------------------------------|
    double precision x,y,z,u,v,w,p,r,s,t,e2d,xlsf,xn,yn,zn,don,con
    double precision current_time,activation_time
    logical inf,wlif
    integer err,iproc,nproc,ierr,i,j,k,nl,nf,nn,nr,kx,ky,kz,kt,icon
    integer ioc,iface,ilsf,noctree,nnode,nface,nlsf,nleaves,ns,nt
    
    !------------------------------------------------------------------------------|
    !------------------------------------------------------------------------------|
    
    INCLUDE 'mpif.h'
    
    call mpi_comm_size (mpi_comm_world,nproc,ierr)
    call mpi_comm_rank (mpi_comm_world,iproc,ierr)
    
    if (params%irestart.eq.0) then
       cl%np=0
       allocate (cl%x(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x in define_cloud$')
       allocate (cl%y(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%y in define_cloud$')
       allocate (cl%z(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%z in define_cloud$')
       allocate (cl%x0(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x0 in define_cloud$')
       allocate (cl%y0(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x0 in define_cloud$')
       allocate (cl%z0(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x0 in define_cloud$')
       allocate (cl%strain(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%strain in define_cloud$')
       allocate (cl%lsf0(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%lsf0 in define_cloud$')
       allocate (cl%temp(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%temp in define_cloud$')
       allocate (cl%press(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%press in define_cloud$')
       allocate (cl%tag(1), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%tag in define_cloud$')
    
    else
       open (19,file=trim(params%restartfile),status='old',form='unformatted')
       read (19) noctree, &
                   nnode,   &
                   nleaves, &
                   nface,   &
                   nlsf,    &
                   cl%np,   &
                   current_time     
    
       allocate (cl%x(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x in define_cloud$')
       allocate (cl%y(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%y in define_cloud$')
       allocate (cl%z(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%z in define_cloud$')
       allocate (cl%x0(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%x0 in define_cloud$')
       allocate (cl%y0(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%y0 in define_cloud$')
       allocate (cl%z0(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%z0 in define_cloud$')
       allocate (cl%strain(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%strain in define_cloud$')
       allocate (cl%lsf0(cl%np), stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%lsf0 in define_cloud$')
       allocate (cl%temp(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%temp in define_cloud$')
       allocate (cl%press(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%press in define_cloud$')
       allocate (cl%tag(cl%np),stat=err) ; if (err.ne.0) call stop_run ('Error alloc cl%tag in define_cloud$')
    
       read (19) (x,               &
                    y,               &
                    z,               &
                    u,               &
                    v,               &
                    w,               &
                    (xlsf,j=1,nlsf), &
                    t,               &
                    p,               &
                    s,               &
                    kx,              &
                    ky,              &
                    kz,              &
                    kt,              &
                    i=1,nnode)
       read (19) ((icon,k=1,8),con,e2d,wlif,i=1,nleaves)
       read (19) (ioc,k=1,noctree)                    
       read (19) ((iface,k=1,9),i=1,nface)
       read (19) (nn,nl,nf,nr,inf,i=1,nnode)
       read (19) (nf,i=1,nface)
       do ilsf=1,nlsf                                  
          read (19) ns, &
                      activation_time, &
                      nt
          read (19) (r,  &
                       s,  &
                       x,  &
                       y,  &
                       z,  &
                       xn, &
                       yn, &
                       zn, &
                       u,v,w, &
                       i=1,ns)
          read (19) ((icon,k=1,3),i=1,nt)
       enddo
       
       read (19) (cl%x(i),      & 
                    cl%y(i),      &
                    cl%z(i),      &
                    cl%x0(i),     &
                    cl%y0(i),     & 
                    cl%z0(i),     &
                    cl%strain(i), &
                    cl%lsf0(i),   &
                    cl%temp(i),   &
                    cl%press(i),  &
                    cl%tag(i),    &
                    i=1,cl%np)
    
       close (19)
    endif
    
    if (iproc.eq.0) write (8,*) cl%np,' particles in cloud'
    
    return
    end
    
    !------------------------------------------------------------------------------|
    !------------------------------------------------------------------------------|