@@ -19,6 +19,7 @@ subroutine write_xy_slice(filein,fileout,nfirst,nlast,slice,format)
1919 use pastr_tecio
2020 use pastr_xdmf
2121 use pastr_data_convert
22+ use pastr_commtype
2223
2324 character (len=* ),intent (in ), optional :: filein,fileout
2425 integer ,intent (in ), optional :: nfirst,nlast
@@ -33,6 +34,10 @@ subroutine write_xy_slice(filein,fileout,nfirst,nlast,slice,format)
3334 character (len= 6 ) :: src_of_data
3435 real (wp),allocatable :: r8 dat(:,:)
3536 real (wp),allocatable ,dimension (:,:,:) :: dat_var_in,dat_var_out
37+ type (tblock),allocatable ,target :: pblocks(:)
38+ type (tblock),pointer :: b
39+ integer :: nblocks
40+ logical :: multi_block
3641
3742 call parse_command_line( string= src_of_data )
3843
@@ -90,13 +95,29 @@ subroutine write_xy_slice(filein,fileout,nfirst,nlast,slice,format)
9095
9196 dat_var_out= dat_out_cal(dat_var_in,nam_var_in,nam_var_out,x,y)
9297
93- if (trim (format )==' plt' ) then
94- call writetecbin2dlist_xy(' snapshot/' // trim (file2write),x(is:ie,js:je), &
95- y(is:ie,js:je), &
96- dat_var_out(is:ie,js:je,:),nam_var_out)
97- elseif (trim (format )==' xdmf' ) then
98- call xdmfwriter(dir= ' snapshot/' ,filename= trim (file2write),x= x(is:ie,0 ),y= y(0 ,js:je), &
99- var= dat_var_out(is:ie,js:je,:),varname= nam_var_out )
98+ call block_define(multi_block,nblocks,pblocks)
99+
100+ do i= 1 ,nblocks
101+ b= >pblocks(i)
102+ b% nvar= num_var_out
103+ call b% init_data()
104+ b% x(0 :b% im,0 :b% jm)= x(b% ilo:b% ihi,b% jlo:b% jhi)
105+ b% y(0 :b% im,0 :b% jm)= y(b% ilo:b% ihi,b% jlo:b% jhi)
106+ b% var(0 :b% im,0 :b% jm,1 :num_var_out)= dat_var_out(b% ilo:b% ihi,b% jlo:b% jhi,1 :num_var_out )
107+ b% varname= nam_var_out
108+ enddo
109+
110+ if (multi_block) then
111+ call xdmfwriter(dir= ' snapshot/' ,filename= trim (file2write),blocks= pblocks )
112+ else
113+ if (trim (format )==' plt' ) then
114+ call writetecbin2dlist_xy(' snapshot/' // trim (file2write),x(is:ie,js:je), &
115+ y(is:ie,js:je), &
116+ dat_var_out(is:ie,js:je,:),nam_var_out)
117+ elseif (trim (format )==' xdmf' ) then
118+ call xdmfwriter(dir= ' snapshot/' ,filename= trim (file2write),x= x(is:ie,0 ),y= y(0 ,js:je), &
119+ var= dat_var_out(is:ie,js:je,:),varname= nam_var_out )
120+ endif
100121 endif
101122
102123 enddo
@@ -263,7 +284,7 @@ subroutine write_3d_field(filein,fileout,nfirst,nlast,format)
263284 enddo
264285
265286 dat_var_out= dat_out_cal(dat_var_in,nam_var_in,nam_var_out,x,y,z)
266-
287+
267288 if (trim (format )==' plt' ) then
268289 call writetecbin3dlist(' snapshot/' // trim (file2write),x(is:ie,js:je,ks:ke), &
269290 y(is:ie,js:je,ks:ke), &
@@ -366,4 +387,40 @@ subroutine var_define(num_var_in,nam_var_in,num_var_out,nam_var_out)
366387
367388 end subroutine var_define
368389
390+ subroutine block_define (multi_block ,nblocks ,pblocks )
391+
392+ use pastr_commtype
393+
394+ logical ,intent (out ) :: multi_block
395+ integer ,intent (out ) :: nblocks
396+ type (tblock),intent (out ),allocatable :: pblocks(:)
397+
398+ integer :: i
399+ logical :: lfex
400+
401+ inquire (file= ' blockdef.txt' ,exist= lfex)
402+ if (lfex) then
403+ multi_block= .true.
404+ else
405+ multi_block= .false.
406+ return
407+ endif
408+
409+ open (12 ,file= ' blockdef.txt' )
410+ read (12 ,* )nblocks
411+ allocate (pblocks(nblocks))
412+ do i= 1 ,nblocks
413+ read (12 ,* )pblocks(i)% ilo,pblocks(i)% ihi,pblocks(i)% jlo,pblocks(i)% jhi
414+ pblocks(i)% im= pblocks(i)% ihi- pblocks(i)% ilo
415+ pblocks(i)% jm= pblocks(i)% jhi- pblocks(i)% jlo
416+ enddo
417+ close (12 )
418+ print * ,' >> blockdef.txt'
419+
420+ print * ,' ** nblocks: ' ,nblocks
421+
422+ return
423+
424+ end subroutine block_define
425+
369426end module pastr_field_view
0 commit comments