36 u gridman_dbg,gridman_unit,gridman_check,
45 INTEGER(GRIDMAN_SP),
INTENT(IN) :: M
47 INTEGER(GRIDMAN_SP),
INTENT(IN) :: N(m)
49 INTEGER(GRIDMAN_SP),
INTENT(IN) :: L
51 REAL(GRIDMAN_DP),
INTENT(IN) :: X(l)
53 REAL(GRIDMAN_DP),
INTENT(IN) :: Y(l)
55 INTEGER,
INTENT(OUT) :: IERR
57 INTEGER(GRIDMAN_SP) :: L1,IP,IV,IL,IPOINT,IPOINT0,
58 i iedge,nedges,npoints
60 REAL(GRIDMAN_DP) :: X1,Y1,X2,Y2
63 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_TEMPLATE2GRID"
69 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
70 w
"incorrect number of polygons, M ",m
77 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
78 w
"incorrect number of points - L=/=sum(N)"
79 WRITE(gridman_unit,*)
"L, SUM(N) ",l,l1
95 IF(abs(x1-x2).GT.gridman_tol*(abs(x1)+abs(x2)).OR.
96 f abs(y1-y2).GT.gridman_tol*(abs(y1)+abs(y2)))
THEN
103 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
104 w
"close polygon must have at least 4 points"
105 WRITE(gridman_unit,*)
" IP, N ",ip,n(ip)
109 nedges=nedges+n(ip)-1
110 npoints=npoints+n(ip)-1
118 c 0_gridman_sp,ierr,1)
120 WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE2GRID terminated"
125 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
126 w
"cannot allocate index"
141 IF(abs(x1-x2).GT.gridman_tol*(abs(x1)+abs(x2)).OR.
142 f abs(y1-y2).GT.gridman_tol*(abs(y1)+abs(y2)))
THEN
146 IF(iedge.GT.nedges)
GOTO 200
148 IF(ipoint.GT.npoints)
GOTO 300
149 grid%X(1,ipoint)=x(il+iv)
150 grid%X(2,ipoint)=y(il+iv)
151 grid%POINTS(1,iedge)=ipoint
152 grid%POINTS(2,iedge)=ipoint+1
153 grid%EDGEINDEX(1)%INDEXES(0,iedge)=iedge
154 grid%EDGEINDEX(1)%INDEXES(1,iedge)=ip
157 IF(ipoint.GT.npoints)
GOTO 300
158 grid%X(1,ipoint)=x(il+n(ip))
159 grid%X(2,ipoint)=y(il+n(ip))
165 IF(iedge.GT.nedges)
GOTO 200
167 IF(ipoint.GT.npoints)
GOTO 300
168 grid%X(1,ipoint)=x(il+iv)
169 grid%X(2,ipoint)=y(il+iv)
170 grid%POINTS(1,iedge)=ipoint
171 grid%POINTS(2,iedge)=ipoint+1
172 grid%EDGEINDEX(1)%INDEXES(0,iedge)=iedge
173 grid%EDGEINDEX(1)%INDEXES(1,iedge)=ip
175 grid%POINTS(2,iedge)=ipoint0
183 grid%UNIT2SI=1e-3_gridman_dp
184 grid%UNITS=
'MILLIMETER'
186 grid%DESCRIPTION=
'Converted from DG template'
187 grid%EDGEINDEX(1)%DESCRIPTION=
'Index of polygon'
188 grid%EDGEINDEX(1)%COLUMNS(1)=
'DG_IPOL'
191 IF(gridman_check)
THEN
193 IF(res.NE.0.OR.ierr.GT.0)
THEN
195 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
196 w
"the resulting grid is incorrect"
202 w
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE2GRID finished"
205 100
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE2GRID terminated"
208 200
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
210 WRITE(gridman_unit,*)
211 w
" Edge index is out of range, IEDGE, NEDGES ",iedge,nedges
215 300
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE2GRID: ",
217 WRITE(gridman_unit,*)
218 w
" Point index is out of range, IPOINT, NPOINTS ",
240 u gridman_dbg,gridman_unit,gridman_check
246 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: M
248 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: N(:)
250 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: L
252 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:)
254 REAL(GRIDMAN_DP),
ALLOCATABLE :: Y(:)
256 INTEGER,
INTENT(OUT) :: IERR
258 INTEGER(GRIDMAN_SP) :: IEDGE,IP1,IP2,IL
260 REAL(GRIDMAN_DP) :: FC
263 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_GRID2TEMPLATE"
270 IF(grid%TYPE.NE.2.OR.grid%PDIM.NE.2.OR.grid%EDIM.NE.2)
THEN
272 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_GRID2TEMPLATE: ",
273 w
"grid is not of 2D type"
277 IF(gridman_check)
THEN
279 IF(res.NE.0.OR.ierr.GT.0)
THEN
281 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_GRID2TEMPLATE: ",
282 w
"the input grid is incorrect"
290 IF(
ALLOCATED(n))
DEALLOCATE(n,stat=st)
291 IF(
ALLOCATED(x))
DEALLOCATE(x,stat=st)
292 IF(
ALLOCATED(y))
DEALLOCATE(y,stat=st)
293 ALLOCATE(n(m),x(l),y(l),stat=st)
296 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_GRID2TEMPLATE: ",
297 w
"cannon perform allocation M, L ",m,l
304 fc=grid%UNIT2SI*1e3_gridman_dp
308 ip1=grid%POINTS(1,iedge)
309 ip2=grid%POINTS(2,iedge)
311 x(il)=grid%X(1,ip1)*fc
312 y(il)=grid%X(2,ip1)*fc
314 x(il)=grid%X(1,ip2)*fc
315 y(il)=grid%X(2,ip2)*fc
319 w
WRITE(gridman_unit,*)
"GRIDMAN_GRID2TEMPLATE finished"
336 u gridman_dbg,gridman_unit
343 CHARACTER(*),
INTENT(IN) :: FNAME
346 INTEGER,
INTENT(OUT) :: IERR
348 INTEGER(GRIDMAN_SP) :: M,L
350 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: N(:)
351 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:),Y(:)
354 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_TEMPLATE_READ_GRID"
359 IF(ierr.NE.0)
GOTO 100
362 IF(ierr.NE.0)
GOTO 200
364 DEALLOCATE(n,stat=st)
365 DEALLOCATE(x,stat=st)
366 DEALLOCATE(y,stat=st)
369 w
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_GRID finished"
372 200
IF(
ALLOCATED(n))
DEALLOCATE(n,stat=st)
373 IF(
ALLOCATED(x))
DEALLOCATE(x,stat=st)
374 IF(
ALLOCATED(y))
DEALLOCATE(y,stat=st)
375 100
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_GRID terminated"
390 u gridman_dbg,gridman_unit
397 CHARACTER(*),
INTENT(IN) :: FNAME
399 INTEGER,
INTENT(OUT) :: IERR
401 INTEGER(GRIDMAN_SP) :: M,L
403 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: N(:)
404 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:),Y(:)
407 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_TEMPLATE_WRITE_GRID"
412 IF(ierr.NE.0)
GOTO 100
415 IF(ierr.NE.0)
GOTO 200
417 DEALLOCATE(n,stat=st)
418 DEALLOCATE(x,stat=st)
419 DEALLOCATE(y,stat=st)
422 w
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE_WRITE_GRID finished"
425 200
IF(
ALLOCATED(n))
DEALLOCATE(n,stat=st)
426 IF(
ALLOCATED(x))
DEALLOCATE(x,stat=st)
427 IF(
ALLOCATED(y))
DEALLOCATE(y,stat=st)
428 100
WRITE(gridman_unit,*)
"GRIDMAN_TEMPLATE_WRITE_GRID terminated"
integer, parameter, public gridman_dp
Kind parameter for real numbers.
Explicit interfaces to GRIDMAN subroutines and functions.
subroutine gridman_template_write_grid(GRID, FNAME, IERR)
Write GRIDMAN_GRID object in a simple template format (DG template)
subroutine gridman_grid_allocate(GRID, TYPE, NEDGES, NPOINTS, NCELLS, IERR, NEDGEINDEX, NCELLINDEX)
Allocate GRIDMAN_GRID object.
subroutine gridman_grid2d_check(GRID, RES, IERR)
Check correctness of the 2D grid object.
Data-type which describes a grid as a set of edges, methods in grid.f.
subroutine gridman_grid_deallocate(GRID, IERR)
Deallocate grid object.
subroutine gridman_index_allocate(INDEX, NINDEX, NELEMENTS, IERR)
Allocate index object.
subroutine gridman_grid2template(GRID, M, N, L, X, Y, IERR)
Convert GRIDMAN_GRID object into arrays which can be stored in simple template format (DG template) ...
Definition of data types, global constants and variables.
subroutine gridman_template2grid(GRID, M, N, L, X, Y, IERR)
Convert data read from a file in simple template format (DG template) into GRIDMAN_GRID object...
integer, parameter, public gridman_sp
Kind parameter for integer numbers.
subroutine gridman_template_read_grid(GRID, FNAME, IERR)
Read from a simple template file (DG template) into GRIDMAN_GRID object.