28 u gridman_unit,gridman_dbg,gridman_check
33 u gridman_grid_write,gridman_template_write,
36 INTRINSIC len_trim,get_command_argument,adjustl,trim
38 INTEGER,
PARAMETER :: file_length=1024
40 CHARACTER(LEN=FILE_LENGTH) ::
41 c fort30_in,fort33_in,fort34_in,fort35_in
42 REAL(GRIDMAN_DP) :: tol
43 CHARACTER(LEN=FILE_LENGTH) ::
44 c fort33_out,fort34_out,fort35_out,
45 c vtk_out,grid_out,template_out
46 LOGICAL :: dbgmod,lcheck
50 INTEGER :: ierr,res,lt
51 CHARACTER(LEN=8) :: ftmp
53 CALL get_command_argument(1,ftmp)
54 IF(len_trim(ftmp).GT.0)
THEN
55 IF(adjustl(trim(ftmp)).EQ.
'help')
THEN
65 WRITE(gridman_unit,*)
"TRIANG: read ",trim(fort30_in)
66 CALL gridman_carre_read30(plasma,fort30_in,ierr,.true.)
67 IF(ierr.NE.0)
CALL triang_error(
"failed to read fort.30")
70 WRITE(gridman_unit,*)
"TRIANG: read "//trim(fort33_in)
71 WRITE(gridman_unit,*)
" "//trim(fort34_in)//
" "
73 CALL gridman_tria_read(tria,
74 c (/fort33_in,fort34_in,fort35_in/),ierr)
75 IF(ierr.NE.0)
CALL triang_error(
"failed to read triangular grid")
78 WRITE(gridman_unit,*)
"TRIANG: preparing indexes"
80 IF(ierr.NE.0)
CALL triang_error(
"")
81 DEALLOCATE(tria%CELLINDEX)
85 WRITE(gridman_unit,*)
"TRIANG: merging grids"
88 f
CALL triang_error(
"merging failed. Try to change TOL")
91 WRITE(gridman_unit,*)
"TRIANG: triangulate plasma grid"
93 IF(ierr.NE.0)
CALL triang_error(
"triangulation failed")
94 tria_out%DESCRIPTION=trim(tria_out%DESCRIPTION)//
95 /
' - Created by TRIANG '
98 WRITE(gridman_unit,*)
"TRIANG: writing combined grid into"
99 WRITE(gridman_unit,*)
" ",trim(fort33_out)
100 WRITE(gridman_unit,*)
" ",trim(fort34_out)
101 WRITE(gridman_unit,*)
" ",trim(fort35_out)
103 CALL gridman_tria_write(tria_out,
104 c (/fort33_out,fort34_out,fort35_out/),ierr)
105 IF(ierr.NE.0)
CALL triang_error(
"writing combined grid failed")
108 WRITE(gridman_unit,*)
"TRIANG: checking the created grid"
109 CALL gridman_tria_read(tria,
110 c (/fort33_out,fort34_out,fort35_out/),ierr)
112 f
CALL triang_error(
"the created grid cannot be read")
114 IF(res.NE.0.OR.ierr.NE.0)
115 c
CALL triang_error(
"the created grid does not pass checks")
120 WRITE(gridman_unit,*)
"TRIANG: writing combined grid"
121 WRITE(gridman_unit,*)
" into VTK file ",vtk_out(1:lt)
123 c vtk_out,tria_out%DESCRIPTION,tria_out,
124 c tria_out%NCELLS,0,0,0,0,ierr)
125 IF(ierr.NE.0)
CALL triang_error(
"could not write VTK file")
127 lt=len_trim(template_out)
129 WRITE(gridman_unit,*)
"TRIANG: writing combined grid"
130 WRITE(gridman_unit,*)
131 w
" into DG template file ",template_out(1:lt)
132 CALL gridman_template_write(tria_out,template_out,ierr)
133 IF(ierr.NE.0)
CALL triang_error(
"could not write template file")
135 lt=len_trim(grid_out)
137 WRITE(gridman_unit,*)
"TRIANG: writing combined grid"
138 WRITE(gridman_unit,*)
" into GRIDMAN-grid file ",grid_out(1:lt)
139 CALL gridman_grid_write(tria_out,grid_out,ierr)
140 IF(ierr.NE.0)
CALL triang_error(
"could not write grid file")
145 WRITE(gridman_unit,*)
"TRIANG COMPLETED"
150 SUBROUTINE read_input
152 namelist /triang/ fort30_in,fort33_in,fort34_in,fort35_in,
153 n tol,fort33_out,fort34_out,fort35_out,
154 n vtk_out,grid_out,template_out,dbgmod,lcheck
172 READ(5,nml=triang,iostat=io)
173 IF(io.NE.0)
CALL triang_error(
"can not read namelist TRIANG")
178 END SUBROUTINE read_input
185 END SUBROUTINE clean_all
188 SUBROUTINE triang_error(STR)
191 CHARACTER(*),
INTENT(IN) :: str
197 stop
"ERROR in TRIANG - see log output. "
198 END SUBROUTINE triang_error
202 INTRINSIC index,len,trim
203 CHARACTER(LEN=FILE_LENGTH) :: path
204 CHARACTER(LEN=128) :: str
206 CALL get_command_argument(0,path)
207 i=index(path,
'/',.true.)
208 IF(i.GT.len(path))
THEN
214 IF(gridman_dbg)
WRITE(gridman_unit,*)
" PATH:",trim(path)
216 OPEN(unit=3,file=trim(path)//
'triang.parameters.description',
217 o status=
'OLD',iostat=io)
221 READ(3,
'(A)',iostat=io,end=200) str
227 100
WRITE(gridman_unit,*)
228 w
"Could not find triang.parameters.description",
230 WRITE(gridman_unit,*)
231 w
"Use 'which triang' to invoke via the full path"
integer, save, public gridman_unit
Index of the standard output unit.
subroutine gridman_grid2d_merge(GRID, GRID1, GRID2, TOL, IERR)
Merge two 2D grids by connecting their boundary edges.
integer, parameter, public gridman_dp
Kind parameter for real numbers.
Explicit interfaces to GRIDMAN subroutines and functions.
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_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_grid2d_triang(TRIA, GRID, IERR)
Triangulation of 2D grid.
subroutine gridman_grid_deallocate(GRID, IERR)
Deallocate grid object.
subroutine print_description
Print manual.
Definition of data types, global constants and variables.
subroutine gridman_index_deallocate(INDEX, IERR)
Allocate index object.