Skip to content
Snippets Groups Projects
DoRuRe.f90 24.3 KiB
Newer Older
!===============================================================================
!===============================================================================
!                                                                              |
!              IO_DORURE    Apr. 2008                                          |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine io_DoRuRe2 (params,aktion)

use definitions
! when called with the 'init' argument this routine erases all preexisting output files if irestart=0.
! when called with the 'close' argument, it closes some output files that have to remain open all through the run.

implicit none

type(parameters) params
character(*) aktion

character*40  :: string
character*2  :: cis
integer iproc,ierr,is,us

!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------

INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)
   
if (params%doDoRuRe .and. iproc.eq.0) then
   if (trim(aktion).eq.'init') then
      if (params%irestart == 0) then
         open (8,file='Log.txt',status='replace')
         open (804,file='./DORURE/p_stats.dat',status='replace')              ; close(804)
         open (805,file='./DORURE/q_stats.dat',status='replace')              ; close(805)
         open (806,file='./DORURE/solver_stats.dat',status='replace')         ; close(806)
         open (807,file='./DORURE/octree_stats.dat',status='replace')         ; close(807)
         open (808,file='./DORURE/levels_stats.dat',status='replace')         ; close(808)
         open (810,file='./DORURE/conv_stats.dat',status='replace')           ; close(810)
         open (811,file='./DORURE/levels_volumes_stats.dat',status='replace') ; close(811)
         open (812,file='./DORURE/cloud_stats.dat',status='replace')          ; close(812)
         open (815,file='./DORURE/div_stats.dat',status='replace')            ; close(815)
         open (816,file='./DORURE/e2d_stats.dat',status='replace')            ; close(816)
         open (820,file='./DORURE/diag1_stats.dat',status='replace')          ; close(820)
         open (821,file='./DORURE/diag3_stats.dat',status='replace')          ; close(821)
         open (822,file='./DORURE/nelem1_stats.dat',status='replace')         ; close(822)
         open (823,file='./DORURE/nelem3_stats.dat',status='replace')         ; close(823)
         open (826,file='./DORURE/nonlin_stats.dat',status='replace')         ; close(826)
         open (827,file='./DORURE/vel_stats.dat',status='replace')            ; close(827)
         open (828,file='./DORURE/temp_stats.dat',status='replace')           ; close(828)
         open (829,file='./DORURE/e3d_stats.dat',status='replace')            ; close(829)
         open (830,file='./DORURE/dt_stats.dat',status='replace')             ; close(830)
         do is=1,params%ns
            call int_to_char(cis,2,is)
!            us=600+is
!            open(us,file='./DORURE/work_'//cis//'_stats.dat',status='replace') ; close(us)
!            us=650+is
!            open(us,file='./DORURE/vol_'//cis//'_stats.dat',status='replace') ; close(us)
            us=700+is
            open(us,file='./DORURE/surf_'//cis//'_stats.dat',status='replace') ; close(us)
         end do
         open (99,file='screen.txt',status='replace')                         
      else
         open (8,file='Log.txt',position='append',status='old')
         open (99,file='screen.txt',position='append',status='old')
      end if   
   elseif (trim(aktion).eq.'close' ) then 
      close(99)
      close(8)
   else
      call stop_run ('pb in the DoRuRe subroutine')
   end if
end if

end subroutine io_DoRuRe2







!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_DT_STATS    Feb. 2008                                    |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_dt_stats (doDoRuRe,istep,dt)
implicit none
logical doDoRuRe
integer istep
double precision dt
integer ierr, iproc
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (830,file    = 'DORURE/dt_stats.dat',&
             position= 'append',              &
             form    = 'formatted',           &
             access  = 'sequential',          &
             status  = 'old')
   write(830,'(i9,es11.4)') istep,dt
   close(830)
end if

return
end subroutine DoRuRe_dt_stats


!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_CLOUD_STATS    Feb. 2008                                 |
!                                                                              |
!===============================================================================
!===============================================================================

subroutine DoRuRe_cloud_stats (doDoRuRe,istep,iter,clnp,nremove,ninject,s,t,p)
implicit none
logical doDoRuRe
integer istep,iter,clnp,nremove,ninject
double precision s(clnp),t(clnp),p(clnp)
integer ierr, iproc
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (812,file     ='./DORURE/cloud_stats.dat',&
             position ='append',                   &
             form     ='formatted',                &
             access   ='sequential',               &
             status   ='old')
   write(812,'(es11.4,i10,2i5,9es11.4)') istep+dble(iter)*.01d0,clnp,nremove,ninject, &
                                     minval(s),sum(s)/clnp,maxval(s),             &
                                     minval(t),sum(t)/clnp,maxval(t),             &
                                     minval(p),sum(p)/clnp,maxval(p)
   close(812)
end if

return
end subroutine DoRuRe_cloud_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_DIAG_STATS    Feb. 2008                                  |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_diag_stats (doDoRuRe,sizediag,diag,ndof,istep,iter,iter_nl)
implicit none
logical doDoRuRe
integer sizediag
double precision diag(sizediag)
integer ndof,istep,iter,iter_nl
integer ierr,iproc,nproc
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then

   if (ndof==1) then 
      open (820,file    ='./DORURE/diag1_stats.dat',&
                position='append',                  &
                form    ='formatted',               &
                access  ='sequential',              &
                status  ='old')
      write(820,'(i5,2f25.8)') istep,minval(diag),maxval(diag)
      close(820)
   end if

   if (ndof==3) then
      open (821,file    ='./DORURE/diag3_stats.dat', &
                position='append',                   &
                form    ='formatted',                &
                access  ='sequential',               &
                status  ='old')
      write(821,'(3es11.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(diag),maxval(diag)
      close(821)
   end if

end if

return
end subroutine DoRuRe_diag_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_LEAF_STATS    Feb. 2008                                 |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_leaf_stats (doDoRuRe,nleaves,e2d,e3d,p,q,dilatrtemp,istep,iter,iter_nl)
implicit none
logical doDoRuRe
integer nleaves
double precision :: e2d(nleaves),p(nleaves),q(nleaves),e3d(nleaves),dilatrtemp(nleaves)
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592
integer istep,iter,iter_nl
integer ierr,iproc
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then

   open (816,file    ='./DORURE/e2d_stats.dat',&
             position='append',                &
             form    ='formatted',             &
             access  ='sequential',            &
             status  ='old')
   write(816,'(3es13.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(e2d),maxval(e2d) 
   close(816)

   open (829,file    ='./DORURE/e3d_stats.dat', &
             position='append',                 &
             form    ='formatted',              &
             access  ='sequential',             &
             status  ='old')
   write(829,'(3es13.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(e3d),maxval(e3d) 
   close(829)

   open (804,file    ='./DORURE/p_stats.dat', &
             position='append',               &
             form    ='formatted',            &
             access  ='sequential',           &
             status  ='old')
   write(804,'(3es13.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(p),maxval(p) 
   close(804)

   open (805,file    ='./DORURE/q_stats.dat', &
             position='append',               &
             form    ='formatted',            &
             access  ='sequential',           &
             status  ='old')
   write(805,'(3es13.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(q),maxval(q) 
   close(805)

end if

end subroutine DoRuRe_leaf_stats




!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_NELEM_STATS    Feb. 2008                                 |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_nelem_stats (doDoRuRe,nbproc,nelem,ndof,nleaves,istep,iter,iter_nl)
implicit none
logical doDoRuRe
integer nbproc,nelem(nbproc),ndof,nleaves,istep,iter,iter_nl
integer ierr,iproc,nproc,jproc
INCLUDE 'mpif.h'
call mpi_comm_size (mpi_comm_world,nproc,ierr)
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then

   if (ndof==1) then 
      open (822,file    ='./DORURE/nelem1_stats.dat', &
                position='append',                    &
                form    ='formatted',                 &
                access  ='sequential',                &
                status  ='old')
      write(822,'(3i10)') istep,minval(nelem),maxval(nelem)
      close(822)
   end if

   if (ndof==3) then
      open (823,file    ='./DORURE/nelem3_stats.dat', &
                position='append',                    &
                form    ='formatted',                 &
                access  ='sequential',                &
                status='old')
      write(823,'(es11.4,2i10)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,minval(nelem),maxval(nelem)
      close(823)
   end if

   write(8,*) '(processor,nb of built elements by this processor):'
   write(8,*) ('(',jproc,',',nelem(jproc),')',jproc=1,nproc)
   write(8,*) 'Redundancy ',(float(sum(nelem))/nleaves-1.)*100.,'%'

end if

return
end subroutine DoRuRe_nelem_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_SOLVER_STATS    Feb. 2008                                |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_solver_stats (doDoRuRe,istep,iter,iter_nl,n,nz,rinfog,infog,time1,time2,time3,nb)
implicit none
logical doDoRuRe
integer istep,iter,iter_nl,nl,n,nz,infog,nb
double precision rinfog
real  time1,time2,time3
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (806,file    ='./DORURE/solver_stats.dat', & 
             position='append',                    &
             form    ='formatted',                 &
             access  ='sequential',                &
             status  ='old')
   write(806,'(es11.4,2i10,4es11.4,i9)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,&
                                         n,nz, rinfog/1.d9,infog/1073741824.d0*8.d0,  &
                                         time2-time1,time3-time2,nb
   close(806)
end if

end subroutine DoRuRe_solver_stats


!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_CONV_STATS    Feb. 2008                                  |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_conv_stats (doDoRuRe,istep,iter,iter_nl,velocity_diff_norm,tol,maxu,maxv,maxw)
implicit none
logical doDoRuRe
integer istep,iter,iter_nl
double precision velocity_diff_norm,tol,maxu,maxv,maxw
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (810,file    ='./DORURE/conv_stats.dat', &
             position='append',                   &
             form    ='formatted',                &
             access  ='sequential',               &
             status  ='old')
   write(810,'(6es15.6)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,velocity_diff_norm,tol,maxu,maxv,maxw
   close(810)
end if

return
end subroutine DoRuRe_conv_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_TEMP_STATS    Feb. 2008                                  |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_temp_stats(doDoRuRe,istep,nnode,temp)
implicit none
logical doDoRuRe
integer istep,nnode
double precision temp(nnode)
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then 
   open (828,file    ='./DORURE/temp_stats.dat', &
             position='append',                   &
             form    ='formatted',                &
             access  ='sequential',               &
             status  ='old')
   write(828,'(i5,2es11.4)') istep,minval(temp),maxval(temp)
   close(828)
end if

return
end subroutine DoRuRe_temp_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_VEL_STATS    Feb. 2008                                    |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_vel_stats(doDoRuRe,istep,iter,iter_nl,nnode,unode,vnode,wnode)
implicit none
logical doDoRuRe
integer istep,iter,iter_nl,nnode
double precision unode(nnode),vnode(nnode),wnode(nnode)
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (827,file    ='./DORURE/vel_stats.dat', &
             position='append',                      &
             form='formatted',                       &
             access='sequential',                    &
             status='old')
   write(827,'(7es15.5)') istep+iter*0.01d0+iter_nl*0.0001d0, &
                          minval(unode),maxval(unode),&
                          minval(vnode),maxval(vnode),&
                          minval(wnode),maxval(wnode)
   close(827)
end if

return
end subroutine DoRuRe_vel_stats


!===============================================================================
!===============================================================================
!                                                                              |
!              DORUREE_SURF_STATS    Feb. 2008                                 |
!                                                                              |
!===============================================================================
!===============================================================================

subroutine DoRuRe_surf_stats (doDoRuRe,istep,ref_count,is,nt,nsurface,nedge,nadd)
implicit none
logical doDoRuRe
integer istep,ref_count,is,nt,nsurface,nedge,nadd
integer us,iproc,ierr
character(len=2) cis
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   call int_to_char(cis,2,is)
   us=700+is
   open(us,file    ='./DORURE/surf_'//cis//'_stats.dat',    &
           position='append',                                &
           form    ='formatted',                             &
           access  ='sequential',                            &
           status  ='old') 
   write(us,'(es11.4,4i7)') real(istep)+real(ref_count)/100.d0,nt,nsurface,nedge,nadd
   close(us)
end if

return
end subroutine DoRuRe_surf_stats 





!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_OCTREE_STATS    Feb. 2008                                |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_octree_stats (osolve,params,istep,iter,iter_nl)
use definitions
implicit none
type (octreesolve) osolve
type (parameters) params
integer istep,iter,iter_nl
integer ierr,iproc,i,ie,k,il,nlev,err
integer,dimension(:),allocatable::levs
integer,dimension(:),allocatable::levelstat
double precision phi(8),vol,voltot
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (params%doDoRuRe .and. iproc.eq.0) then

   open (807,file    ='./DORURE/octree_stats.dat', &
             position='append',                    &
             form    ='formatted',                 &
             access  ='sequential',                &
             status  ='old')
   write(807,'(es11.4,3i8)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,osolve%nleaves,osolve%nnode,osolve%nface
   close(807)

   allocate (levelstat(4:10),stat=err) ; if (err.ne.0) call stop_run ('Error alloc levelstat in write_octree_stats$')
   allocate (levs(osolve%nleaves),stat=err) ; if (err.ne.0) call stop_run ('Error alloc levs in write_octree_stats$')

   call octree_find_element_level (osolve%octree,osolve%noctree,levs,osolve%nleaves)

   levelstat( 4)=count(levs== 4)
   levelstat( 5)=count(levs== 5)
   levelstat( 6)=count(levs== 6)
   levelstat( 7)=count(levs== 7)
   levelstat( 8)=count(levs== 8)
   levelstat( 9)=count(levs== 9)
   levelstat(10)=count(levs==10)

   voltot=0.d0
   do i=1,osolve%nleaves
      do k=1,8
         phi(k)=osolve%lsf(osolve%icon(k,i),1)
      end do
      call compute_positive_volume (phi,vol,3)
      voltot=voltot+vol/(2.d0**levs(i))**3
   end do 

   open (808,file    ='./DORURE/levels_stats.dat', &
             position='append',                    &
             form    ='formatted',                 &
             access  ='sequential',                &
             status  ='old')
   write(808,'(es11.4,7i7)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,levelstat(4:10)
   close(808)

   open (811,file    ='./DORURE/levels_volumes_stats.dat', &
             position='append',                            &
             form    ='formatted',                         &
             access  ='sequential',                        &
             status  ='old')
   write(811,'(9es11.4)') istep+dble(iter)*.01d0+dble(iter_nl)*.0001d0,(levelstat(i)/8.d0**i,i=4,10),1.d0-voltot
   close(811)
   
   write (8,*) 'Levs',levelstat(4:10)
   write (8,*) 'Total fluid volume ',1.d0-voltot

   deallocate (levs)
   deallocate (levelstat)


end if

return
end subroutine DoRuRe_octree_stats


!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_DIV_STATS    Feb. 2008                                   |
!                                                                              |
!===============================================================================
!===============================================================================

subroutine DoRuRe_div_stats (doDoRuRe,istep,iter,nleaves,divergence)
implicit none
logical doDoRuRe
integer istep,iter,nleaves
double precision divergence(nleaves)
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (815,file    ='./DORURE/div_stats.dat', &
             position='append',                        &
             form    ='formatted',                     &
             access  ='sequential',                    &
             status  ='old')
   write(815,'(4es13.4)') istep+dble(iter)*.01d0,minval(divergence),sum(divergence)/nleaves,maxval(divergence)
   close(815)
end if

end subroutine DoRuRe_div_stats

!===============================================================================
!===============================================================================
!                                                                              |
!              DORURE_NONLIN_STATS    Feb. 2008                                |
!                                                                              |
!===============================================================================
!===============================================================================
subroutine DoRuRe_nonlin_stats(doDoRuRe,istep,iter,iter_nl)
implicit none
logical doDoRuRe
integer istep,iter,iter_nl
integer iproc,ierr
INCLUDE 'mpif.h'
call mpi_comm_rank (mpi_comm_world,iproc,ierr)

if (doDoRuRe .and. iproc.eq.0) then
   open (826,file    ='./DORURE/nonlin_stats.dat', &
             position='append',                    &
             form    ='formatted',                 &
             access  ='sequential',                &
             status  ='old')
   write(826,'(es11.4,i5)') istep+iter/100.d0,iter_nl
   close(826)
end if

return
end subroutine DoRuRe_nonlin_stats

!------------------------------------------------------------------------------|
!------------------------------------------------------------------------------|