34 s ifirst,lvertex,ivertex,ctype,ierr,
37 u gridman_sp,gridman_dp,
38 u gridman_dbg,gridman_unit,gridman_check
45 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NPOINTS
47 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NCELLS
49 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NVERTEX
51 REAL(GRIDMAN_DP),
ALLOCATABLE,
INTENT(OUT) :: X(:,:)
53 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: IFIRST(:)
55 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: LVERTEX(:)
57 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: IVERTEX(:)
59 INTEGER,
ALLOCATABLE,
INTENT(OUT) :: CTYPE(:)
61 INTEGER,
INTENT(OUT) :: IERR
63 INTEGER,
INTENT(IN) :: NTHETA
67 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL :: THETA(ntheta)
69 INTEGER(GRIDMAN_SP) :: IEDGE,IV
70 INTEGER :: ND,IS,RES,IERR0
74 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_2DGRID2VTK"
78 IF(grid%TYPE.NE.2.OR.grid%PDIM.NE.2.OR.grid%EDIM.NE.2)
THEN
80 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
81 w
"the grid is not of 2D type"
82 WRITE(gridman_unit,*)
" TYPE, PDIM, EDIM ",
83 w grid%TYPE,grid%PDIM,grid%EDIM
87 IF(gridman_check)
THEN
89 IF(res.NE.0.OR.ierr.GT.0)
THEN
90 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
91 w
"incorrect GRID object"
99 WRITE(gridman_unit,*)
"GRIDMAN_2DGRID2VTK terminated"
105 nvertex=chains%L-chains%N
107 IF(chains%N.NE.ncells.OR.nvertex.LT.3*ncells)
THEN
108 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
109 w
"internal error after GRIDMAN_GRID2D_CHAINS"
110 WRITE(gridman_unit,*)
" L, N, NCELLS ",chains%L,chains%N,ncells
117 CALL rearrange_chains(ierr)
118 IF(ierr.NE.0)
GOTO 100
121 DO iedge=1,grid%NEDGES
122 IF(grid%CELLS(1,iedge).EQ.0.AND.
123 f grid%CELLS(2,iedge).EQ.0)
THEN
129 IF(ntheta.GT.1.AND.
PRESENT(theta))
THEN
133 ncells=ncells*(ntheta-1)
134 nvertex=2*nvertex*(ntheta-1)
135 npoints=npoints*ntheta
141 ALLOCATE(x(nd,npoints),ifirst(ncells),
142 a lvertex(ncells),ivertex(nvertex),
143 a ctype(ncells),stat=is)
145 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
146 w
"can not perform allocation"
147 WRITE(gridman_unit,*)
" NPOINTS, NCELLS, NVERTEX ",
148 w npoints, ncells, nvertex
154 CALL create_2d_grid(ierr)
155 IF(ierr.NE.0)
GOTO 100
157 CALL create_3d_grid(ierr)
158 IF(ierr.NE.0)
GOTO 100
163 ivertex(iv)=ivertex(iv)-1
169 w
WRITE(gridman_unit,*)
"GRIDMAN_2DGRID2VTK completed"
174 CALL deallocate_output
179 SUBROUTINE create_2d_grid(IERR)
180 INTEGER,
INTENT(OUT) :: IERR
181 INTEGER(GRIDMAN_SP) :: ICELL,IEDGE,IV,IE
185 DO icell=1,grid%NCELLS
187 lvertex(icell)=chains%ILAST(icell)-chains%IFIRST(icell)
188 DO ie=chains%IFIRST(icell),chains%ILAST(icell)-1
189 ivertex(iv)=chains%IND(ie)
192 IF(lvertex(icell).GT.4)
THEN
194 ELSE IF(lvertex(icell).EQ.4)
THEN
202 DO iedge=1,grid%NEDGES
203 IF(grid%CELLS(1,iedge).EQ.0.AND.
204 f grid%CELLS(2,iedge).EQ.0)
THEN
209 ivertex(iv)=grid%POINTS(1,iedge)
211 ivertex(iv)=grid%POINTS(2,iedge)
215 IF(iv-1.NE.nvertex.OR.icell.NE.ncells)
THEN
216 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
218 WRITE(gridman_unit,*)
"Mismatch of dimensions"
219 WRITE(gridman_unit,*)
" NVERTEX, IV ",nvertex,iv-1
220 WRITE(gridman_unit,*)
" NCELLS, ICELL ",ncells,icell
224 END SUBROUTINE create_2d_grid
227 SUBROUTINE create_3d_grid(IERR)
228 INTEGER,
INTENT(OUT) :: IERR
229 INTEGER(GRIDMAN_SP) :: IPOINT,ICELL,IE,IV,IEDGE,
230 i ipoint1,icell1,i,npoints0
232 REAL(GRIDMAN_DP) :: COSTOR,SINTOR
235 npoints0=grid%NPOINTS
238 costor=cos(theta(itor))
239 sintor=sin(theta(itor))
242 x(1,ipoint1)=grid%X(1,ipoint)*costor
243 x(2,ipoint1)=grid%X(1,ipoint)*sintor
244 x(3,ipoint1)=grid%X(2,ipoint)
250 DO icell=1,grid%NCELLS
252 lvertex(icell1)=chains%ILAST(icell)-chains%IFIRST(icell)
254 IF(lvertex(icell1).EQ.3)
THEN
256 ELSE IF(lvertex(icell1).EQ.4)
THEN
259 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
260 w
"unsupported cell type"
261 WRITE(gridman_unit,*)
262 w
"3D grids with cells which have ",
263 w
"number of corners other than 3 or 4 ",
264 w
"are not supported for VTK"
265 WRITE(gridman_unit,*)
" ICELL, NCORNERS ",
266 w icell, lvertex(icell1)
270 ie=chains%IFIRST(icell)
271 DO i=0,lvertex(icell1)-1
272 ivertex(iv)=chains%IND(ie+i)+npoints0*(itor-1)
275 DO i=0,lvertex(icell1)-1
276 ivertex(iv)=chains%IND(ie+i)+npoints0*itor
279 lvertex(icell1)=lvertex(icell1)*2
282 DO iedge=1,grid%NEDGES
283 IF(grid%CELLS(1,iedge).EQ.0.AND.
284 f grid%CELLS(2,iedge).EQ.0)
THEN
289 ivertex(iv)=grid%POINTS(1,iedge)+npoints0*(itor-1)
291 ivertex(iv)=grid%POINTS(2,iedge)+npoints0*(itor-1)
293 ivertex(iv)=grid%POINTS(2,iedge)+npoints0*itor
295 ivertex(iv)=grid%POINTS(1,iedge)+npoints0*itor
302 IF(iv-1.NE.nvertex.OR.icell1.NE.ncells.OR.
303 f ipoint1.NE.npoints)
THEN
304 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
306 WRITE(gridman_unit,*)
"Mismatch of dimensions"
307 WRITE(gridman_unit,*)
" NVERTEX, IV ",nvertex,iv-1
308 WRITE(gridman_unit,*)
" NCELLS, ICELL1 ",ncells,icell1
309 WRITE(gridman_unit,*)
" NPOINTS, IPOINT1 ",npoints,ipoint1
317 IF(iv.NE.nvertex)
THEN
318 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
320 WRITE(gridman_unit,*)
"Mismatch of dimensions"
321 WRITE(gridman_unit,*)
" NVERTEX, IV ",nvertex,iv
326 IF(ivertex(iv).GT.npoints)
THEN
327 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
329 WRITE(gridman_unit,*)
"Wrong point index"
330 WRITE(gridman_unit,*)
"IV, IVERTEX, NPOINTS ",
331 w iv, ivertex(iv), npoints
335 END SUBROUTINE create_3d_grid
338 SUBROUTINE rearrange_chains(IERR)
339 INTEGER,
INTENT(OUT) :: IERR
340 INTEGER(GRIDMAN_SP) :: IC,IE,IE1,IE2,IP,N,ITMP,IEE
341 REAL(GRIDMAN_DP) :: X1,Y1,X2,Y2,S
349 ie1=chains%IFIRST(ic)
353 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK: ",
354 w
"internal error after GRIDMAN_GRID2D_CHAINS"
355 WRITE(gridman_unit,*)
" Wrong number of vertices"
356 WRITE(gridman_unit,*)
" ICELL, IFIRST, ILAST ",
357 w ic,chains%IFIRST(ic),chains%ILAST(ic)
376 n=floor(
REAL((ie2-ie1+1)/2.))-1
380 chains%IND(ie)=chains%IND(iee)
387 END SUBROUTINE rearrange_chains
390 SUBROUTINE deallocate_output
392 IF(
ALLOCATED(x))
THEN
393 DEALLOCATE(x,stat=is)
395 WRITE(gridman_unit,*)
"WARNING from GRIDMAN_2DGRID2VTK: ",
396 w
"can not deallocate X"
399 IF(
ALLOCATED(ifirst))
THEN
400 DEALLOCATE(ifirst,stat=is)
402 WRITE(gridman_unit,*)
"WARNING from GRIDMAN_2DGRID2VTK: ",
403 w
"can not deallocate IFIRST"
406 IF(
ALLOCATED(lvertex))
THEN
407 DEALLOCATE(lvertex,stat=is)
409 WRITE(gridman_unit,*)
"WARNING from GRIDMAN_2DGRID2VTK: ",
410 w
"can not deallocate LVERTEX"
413 IF(
ALLOCATED(ivertex))
THEN
414 DEALLOCATE(ivertex,stat=is)
416 WRITE(gridman_unit,*)
"WARNING from GRIDMAN_2DGRID2VTK: ",
417 w
"can not deallocate IVERTEX"
420 IF(
ALLOCATED(ctype))
THEN
421 DEALLOCATE(ctype,stat=is)
423 WRITE(gridman_unit,*)
"WARNING from GRIDMAN_2DGRID2VTK: ",
424 w
"can not deallocate CTYPE"
427 END SUBROUTINE deallocate_output
439 u gridman_dbg,gridman_unit,gridman_check,
443 INTRINSIC sum,trim,adjustl
447 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: N
449 INTEGER,
INTENT(OUT) :: M
455 REAL(GRIDMAN_DP),
ALLOCATABLE,
INTENT(OUT) :: RINDEXES(:,:)
460 CHARACTER(GRIDMAN_LENGTH),
ALLOCATABLE,
INTENT(OUT) :: SINDEXES(:)
462 INTEGER,
INTENT(OUT) :: IERR
464 INTEGER :: RES,I,J,IS,IR,IR1,IR2
465 INTEGER(GRIDMAN_SP) :: IE,ICELL,IEDGE,NEDGES
466 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: IEDGES(:)
470 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_2DGRID2VTK_INDEX"
474 IF(grid%TYPE.NE.2.OR.grid%PDIM.NE.2.OR.grid%EDIM.NE.2)
THEN
476 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK_INDEX: ",
477 w
"the grid is not of 2D type"
478 WRITE(gridman_unit,*)
" TYPE, PDIM, EDIM ",
479 w grid%TYPE,grid%PDIM,grid%EDIM
483 IF(gridman_check)
THEN
485 IF(res.NE.0.OR.ierr.GT.0)
THEN
486 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK_INDEX: ",
487 w
"incorrect GRID object"
494 IF(ierr.NE.0)
GOTO 100
497 IF(grid%NCELLINDEX.GT.0) m=sum(grid%CELLINDEX(:)%NINDEX)
498 IF(n.GT.grid%NCELLS.AND.grid%NEDGEINDEX.GT.0)
THEN
499 m=m+sum(grid%EDGEINDEX(:)%NINDEX)
508 ALLOCATE(rindexes(n,m),sindexes(m),stat=is)
513 DO i=1,grid%NCELLINDEX
515 DO j=1,grid%CELLINDEX(i)%NINDEX
518 sindexes(ir)=
'I'//trim(adjustl(str))
520 sindexes(ir)=trim(sindexes(ir))//
'_'//trim(adjustl(str))
521 sindexes(ir)=trim(sindexes(ir))//
'_'//
522 / grid%CELLINDEX(i)%COLUMNS(j)
525 DO ie=1,grid%CELLINDEX(i)%NELEMENTS
526 icell=grid%CELLINDEX(i)%INDEXES(0,ie)
527 IF(icell.GT.0.AND.icell.LE.grid%NCELLS)
THEN
528 rindexes(icell,ir1:ir2)=grid%CELLINDEX(i)%INDEXES(1:,ie)
534 IF(n.GT.grid%NCELLS.AND.grid%NEDGEINDEX.GT.0)
THEN
535 ALLOCATE(iedges(grid%NEDGES),stat=is)
539 DO iedge=1,grid%NEDGES
540 IF(grid%CELLS(1,iedge).EQ.0.AND.grid%CELLS(2,iedge).EQ.0)
THEN
545 IF(nedges.NE.n-grid%NCELLS)
GOTO 400
547 DO i=1,grid%NEDGEINDEX
549 DO j=1,grid%EDGEINDEX(i)%NINDEX
552 sindexes(ir)=
'E'//trim(adjustl(str))
554 sindexes(ir)=trim(sindexes(ir))//
'_'//trim(adjustl(str))
555 sindexes(ir)=trim(sindexes(ir))//
'_'//
556 / grid%EDGEINDEX(i)%COLUMNS(j)
559 DO ie=1,grid%EDGEINDEX(i)%NELEMENTS
560 iedge=grid%EDGEINDEX(i)%INDEXES(0,ie)
561 IF(iedge.GT.0.AND.iedge.LE.grid%NEDGES)
THEN
564 rindexes(iedge+grid%NCELLS,ir1:ir2)=
565 = grid%EDGEINDEX(i)%INDEXES(1:,ie)
570 DEALLOCATE(iedges,stat=is)
574 w
WRITE(gridman_unit,*)
"GRIDMAN_2DGRID2VTK_INDEX completed"
578 100
WRITE(gridman_unit,*)
"GRIDMAN_2DGRID2VTK_INDEX terminated"
580 200
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK_INDEX: ",
581 w
"cannot perform allocation"
582 WRITE(gridman_unit,*)
" M, N ",m,n
585 210
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK_INDEX: ",
586 w
"cannot allocate temporary array"
587 WRITE(gridman_unit,*)
" NEDGES ",grid%NEDGES
590 400
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_2DGRID2VTK_INDEX: ",
591 w
"internal error - musmatch between number of edges"
592 WRITE(gridman_unit,*)
" NEDGES, NCOUNT-NCELLS ",
593 w nedges, n-grid%NCELLS
606 s ncs,ncv,nps,npv,ierr,
612 u gridman_dbg,gridman_unit,gridman_length
617 CHARACTER(*),
INTENT(IN) :: FNAME
619 CHARACTER(*),
INTENT(IN) :: HEADER
627 INTEGER,
INTENT(IN) :: NELEMENTS
629 INTEGER,
INTENT(IN) :: NCS
631 INTEGER,
INTENT(IN) :: NCV
633 INTEGER,
INTENT(IN) :: NPS
635 INTEGER,
INTENT(IN) :: NPV
637 INTEGER,
INTENT(OUT) :: IERR
639 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
640 r cell_scalar(nelements,ncs)
642 CHARACTER(*),
INTENT(IN),
OPTIONAL :: CSNAME(ncs)
644 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
645 r cell_vector(2,nelements,ncv)
647 CHARACTER(*),
INTENT(IN),
OPTIONAL :: CVNAME(ncv)
649 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
650 r point_scalar(grid%NPOINTS,nps)
652 CHARACTER(*),
INTENT(IN),
OPTIONAL :: PSNAME(nps)
654 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
655 r point_vector(2,grid%NPOINTS,npv)
657 CHARACTER(*),
INTENT(IN),
OPTIONAL :: PVNAME(npv)
659 INTEGER(GRIDMAN_SP) :: NPOINTS,NCELLS,NVERTEX,NCOUNT
660 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:,:)
661 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: IFIRST(:),
662 i lvertex(:),ivertex(:)
663 INTEGER,
ALLOCATABLE :: CTYPE(:)
665 INTEGER(GRIDMAN_SP) :: N
666 INTEGER :: M,NCS1,IS,ID
667 REAL(GRIDMAN_DP),
ALLOCATABLE :: RINDEXES(:,:)
668 CHARACTER(GRIDMAN_LENGTH),
ALLOCATABLE :: SINDEXES(:),
670 REAL(GRIDMAN_DP),
ALLOCATABLE :: LOCAL_CELL_SCALAR(:,:)
673 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_VTK_GRID2D_WRITE"
678 IF(ierr.NE.0)
GOTO 100
680 IF(
PRESENT(cell_scalar).OR.
PRESENT(cell_vector))
THEN
681 IF(nelements.LT.ncount)
THEN
682 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_VTK_GRID2D_WRITE: ",
683 w
"data arrays are too small"
684 WRITE(gridman_unit,*)
" NELEMENTS ",nelements,
685 w
" required ",ncount
692 s ifirst,lvertex,ivertex,ctype,ierr,0)
693 IF(ierr.NE.0)
GOTO 100
696 IF(ierr.NE.0)
GOTO 100
698 IF(
PRESENT(cell_scalar))
THEN
704 IF(n.NE.ncount)
GOTO 400
705 ALLOCATE(local_cell_scalar(n,m+ncs1),
706 a local_csname(m+ncs1),stat=is)
709 local_cell_scalar(1:n,1:m)=rindexes(1:n,1:m)
710 local_csname(1:m)=sindexes(1:m)
713 local_cell_scalar(1:n,m+1:m+ncs1)=cell_scalar(1:n,1:ncs1)
714 IF(
PRESENT(csname))
THEN
715 local_csname(m+1:m+ncs1)=csname(1:ncs1)
718 WRITE(local_csname(m+id),
'(A11,I4.4)')
"CELL_SCALAR",id
723 s x,ifirst,lvertex,ivertex,ctype,
724 s m+ncs1,ncv,nps,npv,ierr,
725 s local_cell_scalar,local_csname,
726 s cell_vector,cvname,
727 s point_scalar,psname,point_vector,pvname)
730 s x,ifirst,lvertex,ivertex,ctype,
731 s ncs,ncv,nps,npv,ierr,
732 s cell_scalar,csname,cell_vector,cvname,
733 s point_scalar,psname,point_vector,pvname)
736 CALL deallocate_temporary_arrays
737 WRITE(gridman_unit,*)
"GRIDMAN_VTK_GRID2D_WRITE terminated"
741 CALL deallocate_temporary_arrays
744 w
WRITE(gridman_unit,*)
"GRIDMAN_VTK_GRID2D_WRITE finished"
748 100
WRITE(gridman_unit,*)
"GRIDMAN_VTK_GRID2D_WRITE terminated"
750 200
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_VTK_GRID2D_WRITE: ",
751 w
"cannot allocate temporary arrays"
752 WRITE(gridman_unit,*)
" NELEMENTS,M+NCS1 ",nelements,m+ncs1
753 CALL deallocate_temporary_arrays
756 400
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_VTK_GRID2D_WRITE: ",
758 WRITE(gridman_unit,*)
"Counts do not match, N, NCOUNT ",n,ncount
764 SUBROUTINE deallocate_temporary_arrays
767 IF(
ALLOCATED(x))
THEN
768 DEALLOCATE(x,stat=is)
770 WRITE(gridman_unit,*)
771 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
772 w
"can not deallocate X"
775 IF(
ALLOCATED(ifirst))
THEN
776 DEALLOCATE(ifirst,stat=is)
778 WRITE(gridman_unit,*)
779 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
780 w
"can not deallocate IFIRST"
783 IF(
ALLOCATED(lvertex))
THEN
784 DEALLOCATE(lvertex,stat=is)
786 WRITE(gridman_unit,*)
787 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
788 w
"can not deallocate LVERTEX"
791 IF(
ALLOCATED(ivertex))
THEN
792 DEALLOCATE(ivertex,stat=is)
794 WRITE(gridman_unit,*)
795 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
796 w
"can not deallocate IVERTEX"
799 IF(
ALLOCATED(ctype))
THEN
800 DEALLOCATE(ctype,stat=is)
802 WRITE(gridman_unit,*)
803 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
804 w
"can not deallocate CTYPE"
807 IF(
ALLOCATED(rindexes))
THEN
808 DEALLOCATE(rindexes,stat=is)
810 WRITE(gridman_unit,*)
811 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
812 w
"can not deallocate RINDEXES"
815 IF(
ALLOCATED(sindexes))
THEN
816 DEALLOCATE(sindexes,stat=is)
818 WRITE(gridman_unit,*)
819 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
820 w
"can not deallocate SINDEXES"
823 IF(
ALLOCATED(local_csname))
THEN
824 DEALLOCATE(local_csname,stat=is)
826 WRITE(gridman_unit,*)
827 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
828 w
"can not deallocate LOCAL_CSNAME"
831 IF(
ALLOCATED(local_cell_scalar))
THEN
832 DEALLOCATE(local_cell_scalar,stat=is)
834 WRITE(gridman_unit,*)
835 w
"WARNING from GRIDMAN_VTK_GRID2D_WRITE: ",
836 w
"can not deallocate LOCAL_CELL_SCALAR"
840 END SUBROUTINE deallocate_temporary_arrays
849 s ifirst,lvertex,ivertex,ctype,ierr)
851 u gridman_dbg,gridman_unit
856 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NPOINTS
858 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NCELLS
860 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NVERTEX
862 REAL(GRIDMAN_DP),
ALLOCATABLE,
INTENT(OUT) :: X(:,:)
864 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: IFIRST(:)
866 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: LVERTEX(:)
868 INTEGER(GRIDMAN_SP),
ALLOCATABLE,
INTENT(OUT) :: IVERTEX(:)
870 INTEGER,
ALLOCATABLE,
INTENT(OUT) :: CTYPE(:)
872 INTEGER,
INTENT(OUT) :: IERR
874 INTEGER(GRIDMAN_SP) :: IEDGE,IV,I,IP
878 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_3DGRID2VTK"
881 IF(grid%TYPE.NE.3.OR.grid%PDIM.NE.3.OR.grid%EDIM.NE.3)
THEN
883 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK: ",
884 w
"the grid is not of FULLERGRID type"
885 WRITE(gridman_unit,*)
" TYPE ",grid%TYPE
889 IF(grid%NCELLS.NE.0)
THEN
891 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK: ",
892 w
"at the moment only FULLER grids ",
893 w
"w/o cells are implemented"
901 ALLOCATE(x(3,npoints),ifirst(ncells),
902 a lvertex(ncells),ivertex(nvertex),
903 a ctype(ncells),stat=is)
905 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK: ",
906 w
"can not perform allocation"
907 WRITE(gridman_unit,*)
" NPOINTS, NCELLS, NVERTEX ",
908 w npoints, ncells, nvertex
921 ip=grid%POINTS(i,iedge)
928 ivertex(iv)=ivertex(iv)-1
941 u gridman_dbg,gridman_unit,gridman_check,
945 INTRINSIC sum,trim,adjustl
949 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: N
951 INTEGER,
INTENT(OUT) :: M
956 REAL(GRIDMAN_DP),
ALLOCATABLE,
INTENT(OUT) :: RINDEXES(:,:)
960 CHARACTER(GRIDMAN_LENGTH),
ALLOCATABLE,
INTENT(OUT) :: SINDEXES(:)
962 INTEGER,
INTENT(OUT) :: IERR
964 INTEGER :: RES,I,J,IS,IR,IR1,IR2
965 INTEGER(GRIDMAN_SP) :: IE,IEDGE
969 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_3DGRID2VTK_INDEX"
973 IF(grid%TYPE.NE.3.OR.grid%PDIM.NE.3.OR.grid%EDIM.NE.3)
THEN
975 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK_INDEX: ",
976 w
"the grid is not of 3D type"
977 WRITE(gridman_unit,*)
" TYPE, PDIM, EDIM ",
978 w grid%TYPE,grid%PDIM,grid%EDIM
982 IF(gridman_check)
THEN
984 IF(res.NE.0.OR.ierr.GT.0)
THEN
985 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK_INDEX: ",
986 w
"incorrect GRID object"
993 IF(grid%NEDGEINDEX.GT.0) m=sum(grid%EDGEINDEX(:)%NINDEX)
996 ALLOCATE(rindexes(n,m),sindexes(m),stat=is)
1001 DO i=1,grid%NEDGEINDEX
1003 DO j=1,grid%EDGEINDEX(i)%NINDEX
1006 sindexes(ir)=
'E'//trim(adjustl(str))
1008 sindexes(ir)=trim(sindexes(ir))//
'_'//trim(adjustl(str))
1009 sindexes(ir)=trim(sindexes(ir))//
'_'//
1010 / grid%EDGEINDEX(i)%COLUMNS(j)
1013 DO ie=1,grid%EDGEINDEX(i)%NELEMENTS
1014 iedge=grid%EDGEINDEX(i)%INDEXES(0,ie)
1015 IF(iedge.GT.0.AND.iedge.LE.grid%NEDGES)
THEN
1016 rindexes(iedge,ir1:ir2)=grid%EDGEINDEX(i)%INDEXES(1:,ie)
1022 w
WRITE(gridman_unit,*)
"GRIDMAN_3DGRID2VTK_INDEX completed"
1026 200
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_3DGRID2VTK_INDEX: ",
1027 w
"cannot perform allocation"
1028 WRITE(gridman_unit,*)
" M, N ",m,n
1043 s ncs,ncv,nps,npv,ierr,
1049 u gridman_dbg,gridman_unit,gridman_length
1054 CHARACTER(*),
INTENT(IN) :: FNAME
1056 CHARACTER(*),
INTENT(IN) :: HEADER
1061 INTEGER(GRIDMAN_SP),
INTENT(IN) :: NELEMENTS
1063 INTEGER,
INTENT(IN) :: NCS
1065 INTEGER,
INTENT(IN) :: NCV
1067 INTEGER,
INTENT(IN) :: NPS
1069 INTEGER,
INTENT(IN) :: NPV
1071 INTEGER,
INTENT(OUT) :: IERR
1073 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
1074 r cell_scalar(nelements,ncs)
1076 CHARACTER(*),
INTENT(IN),
OPTIONAL :: CSNAME(ncs)
1078 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
1079 r cell_vector(3,nelements,ncv)
1081 CHARACTER(*),
INTENT(IN),
OPTIONAL :: CVNAME(ncv)
1083 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
1084 r point_scalar(grid%NPOINTS,nps)
1086 CHARACTER(*),
INTENT(IN),
OPTIONAL :: PSNAME(nps)
1088 REAL(GRIDMAN_DP),
INTENT(IN),
OPTIONAL ::
1089 r point_vector(3,grid%NPOINTS,npv)
1091 CHARACTER(*),
INTENT(IN),
OPTIONAL :: PVNAME(npv)
1093 INTEGER(GRIDMAN_SP) :: NPOINTS,NCELLS,NVERTEX,NCOUNT
1094 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:,:)
1095 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: IFIRST(:),
1096 i lvertex(:),ivertex(:)
1097 INTEGER,
ALLOCATABLE :: CTYPE(:)
1099 INTEGER(GRIDMAN_SP) :: N
1100 INTEGER :: M,NCS1,IS,ID
1101 REAL(GRIDMAN_DP),
ALLOCATABLE :: RINDEXES(:,:)
1102 CHARACTER(GRIDMAN_LENGTH),
ALLOCATABLE :: SINDEXES(:),
1104 REAL(GRIDMAN_DP),
ALLOCATABLE :: LOCAL_CELL_SCALAR(:,:)
1107 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_VTK_GRID3D_WRITE"
1112 IF(
PRESENT(cell_scalar).OR.
PRESENT(cell_vector))
THEN
1113 IF(nelements.LT.ncount)
THEN
1114 WRITE(gridman_unit,*)
1115 w
"ERROR in GRIDMAN_VTK_GRID3D_WRITE: ",
1116 w
"data arrays are too small"
1117 WRITE(gridman_unit,*)
" NELEMENTS ",nelements,
1118 w
" required ",ncount
1125 s ifirst,lvertex,ivertex,ctype,ierr)
1126 IF(ierr.NE.0)
GOTO 100
1129 IF(ierr.NE.0)
GOTO 100
1131 IF(
PRESENT(cell_scalar))
THEN
1137 IF(n.NE.ncount)
GOTO 400
1138 ALLOCATE(local_cell_scalar(n,m+ncs1),
1139 a local_csname(m+ncs1),stat=is)
1140 IF(is.NE.0)
GOTO 200
1142 local_cell_scalar(1:n,1:m)=rindexes(1:n,1:m)
1143 local_csname(1:m)=sindexes(1:m)
1146 local_cell_scalar(1:n,m+1:m+ncs1)=cell_scalar(1:n,1:ncs1)
1147 IF(
PRESENT(csname))
THEN
1148 local_csname(m+1:m+ncs1)=csname(1:ncs1)
1151 WRITE(local_csname(m+id),
'(A11,I4.4)')
"CELL_SCALAR",id
1156 s x,ifirst,lvertex,ivertex,ctype,
1157 s m+ncs1,ncv,nps,npv,ierr,
1158 s local_cell_scalar,local_csname,
1159 s cell_vector,cvname,
1160 s point_scalar,psname,point_vector,pvname)
1163 s x,ifirst,lvertex,ivertex,ctype,
1164 s ncs,ncv,nps,npv,ierr,
1165 s cell_scalar,csname,cell_vector,cvname,
1166 s point_scalar,psname,point_vector,pvname)
1169 CALL deallocate_temporary_arrays
1170 WRITE(gridman_unit,*)
" GRIDMAN_VTK_GRID3D_WRITE terminated"
1174 CALL deallocate_temporary_arrays
1177 w
WRITE(gridman_unit,*)
" GRIDMAN_VTK_GRID3D_WRITE finished"
1181 100
WRITE(gridman_unit,*)
" GRIDMAN_VTK_GRID3D_WRITE terminated"
1183 200
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_VTK_GRID3D_WRITE: ",
1184 w
"cannot allocate temporary arrays"
1185 WRITE(gridman_unit,*)
" N,M+NCS1 ",n,m+ncs1
1186 CALL deallocate_temporary_arrays
1189 400
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_VTK_GRID3D_WRITE: ",
1191 WRITE(gridman_unit,*)
"Counts do not match, N, NCOUNT ",n,ncount
1197 SUBROUTINE deallocate_temporary_arrays
1200 IF(
ALLOCATED(x))
THEN
1201 DEALLOCATE(x,stat=is)
1203 WRITE(gridman_unit,*)
1204 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1205 w
"can not deallocate X"
1208 IF(
ALLOCATED(ifirst))
THEN
1209 DEALLOCATE(ifirst,stat=is)
1211 WRITE(gridman_unit,*)
1212 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1213 w
"can not deallocate IFIRST"
1216 IF(
ALLOCATED(lvertex))
THEN
1217 DEALLOCATE(lvertex,stat=is)
1219 WRITE(gridman_unit,*)
1220 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1221 w
"can not deallocate LVERTEX"
1224 IF(
ALLOCATED(ivertex))
THEN
1225 DEALLOCATE(ivertex,stat=is)
1227 WRITE(gridman_unit,*)
1228 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1229 w
"can not deallocate IVERTEX"
1232 IF(
ALLOCATED(ctype))
THEN
1233 DEALLOCATE(ctype,stat=is)
1235 WRITE(gridman_unit,*)
1236 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1237 w
"can not deallocate CTYPE"
1240 IF(
ALLOCATED(rindexes))
THEN
1241 DEALLOCATE(rindexes,stat=is)
1243 WRITE(gridman_unit,*)
1244 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1245 w
"can not deallocate RINDEXES"
1248 IF(
ALLOCATED(sindexes))
THEN
1249 DEALLOCATE(sindexes,stat=is)
1251 WRITE(gridman_unit,*)
1252 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1253 w
"can not deallocate SINDEXES"
1256 IF(
ALLOCATED(local_csname))
THEN
1257 DEALLOCATE(local_csname,stat=is)
1259 WRITE(gridman_unit,*)
1260 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1261 w
"can not deallocate LOCAL_CSNAME"
1264 IF(
ALLOCATED(local_cell_scalar))
THEN
1265 DEALLOCATE(local_cell_scalar,stat=is)
1267 WRITE(gridman_unit,*)
1268 w
"WARNING from GRIDMAN_VTK_GRID3D_WRITE: ",
1269 w
"can not deallocate LOCAL_CELL_SCALAR"
1272 END SUBROUTINE deallocate_temporary_arrays
subroutine gridman_grid_check(GRID, RES, IERR)
Check consistency of the grid data.
integer, parameter, public gridman_dp
Kind parameter for real numbers.
Explicit interfaces to GRIDMAN subroutines and functions.
subroutine gridman_grid2d_chains(GRID, CHAINS, IERR)
Find closed chain of points which form each cell.
subroutine gridman_3dgrid2vtk_index(GRID, N, M, RINDEXES, SINDEXES, IERR)
Translate edge indices in VTK input in the sense of GRIDMAN_3DGRID2VTK (in the current implementation...
subroutine gridman_grid_count(GRID, NCOUNT, IERR)
Return the number of cells plus the number of edges not belonging to any cell.
subroutine gridman_grid2d_check(GRID, RES, IERR)
Check correctness of the 2D grid object.
subroutine gridman_indlist_deallocate(INDLIST, IERR)
Deallocate list of indices.
Data-type which describes a grid as a set of edges, methods in grid.f.
subroutine gridman_vtk_grid2d_write(FNAME, HEADER, GRID, NELEMENTS, NCS, NCV, NPS, NPV, IERR, CELL_SCALAR, CSNAME, CELL_VECTOR, CVNAME, POINT_SCALAR, PSNAME, POINT_VECTOR, PVNAME)
Write 2D grid and data in VTK ASCII legacy format.
subroutine gridman_3dgrid2vtk(GRID, NPOINTS, NCELLS, NVERTEX, X, IFIRST, LVERTEX, IVERTEX, CTYPE, IERR)
Convert 3D grid into VTK format. Only grid w/o cells is implemented at the moment !!! ...
Data-type which describes lists of elements with variable number of indices for each element...
subroutine gridman_2dgrid2vtk_index(GRID, N, M, RINDEXES, SINDEXES, IERR)
Translate cell and edge indices in VTK input in the sense of GRIDMAN_2DGRID2VTK.
Definition of data types, global constants and variables.
subroutine gridman_vtk_grid3d_write(FNAME, HEADER, GRID, NELEMENTS, NCS, NCV, NPS, NPV, IERR, CELL_SCALAR, CSNAME, CELL_VECTOR, CVNAME, POINT_SCALAR, PSNAME, POINT_VECTOR, PVNAME)
Write 3D grid and data in VTK ASCII legacy format. Only grid w/o cells is implemented at the moment !...
subroutine gridman_2dgrid2vtk(GRID, NPOINTS, NCELLS, NVERTEX, X, IFIRST, LVERTEX, IVERTEX, CTYPE, IERR, NTHETA, THETA)
Convert 2D grid into VTK format.
integer, parameter, public gridman_sp
Kind parameter for integer numbers.