56 INTRINSIC trim,sum,index,len_trim
58 CHARACTER(*),
INTENT(IN) :: FNAME
60 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: M
62 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: N(:)
64 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: L
66 REAL(GRIDMAN_DP),
ALLOCATABLE :: X(:)
68 REAL(GRIDMAN_DP),
ALLOCATABLE :: Y(:)
70 INTEGER,
INTENT(OUT) :: IERR
72 INTEGER(GRIDMAN_SP) :: IP,IV,IV1
74 CHARACTER(256) :: STR,STR0
77 w
WRITE(
gridman_unit,*)
"Starting GRIDMAN_TEMPLATE_READ_ARRAY"
83 OPEN (unit=3,status=
'OLD',access=
'SEQUENTIAL',
84 o form=
'FORMATTED',file=fname,iostat=io)
87 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
88 o
"can not open ",trim(fname)
94 w
"GRIDMAN_TEMPLATE_READ_ARRAY: count polygons"
98 10
READ(3,
'(A)',end=20,iostat=io) str
100 IF(len_trim(str).LT.1) m=m+1
104 IF(len_trim(str0).GT.1) m=m+1
108 w
WRITE(
gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_ARRAY: M= ",m
112 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
113 o
"no polygons found in file ",trim(fname)
117 IF(
ALLOCATED(n))
DEALLOCATE(n,stat=io)
118 ALLOCATE(n(m),stat=io)
121 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
122 w
"cannot perform allocation, M ",m
128 w
"GRIDMAN_TEMPLATE_READ_ARRAY: count lengths"
134 11
READ(3,
'(A)',end=21,iostat=io) str
137 IF(index(str,
'>>').GT.0)
GOTO 11
138 IF(len_trim(str).LT.1)
THEN
141 IF(ip.LT.m+1) n(ip)=0
151 w
WRITE(
gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_ARRAY: N= ",n
156 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
157 o
"all polygons are empty in file ",trim(fname)
162 IF(
ALLOCATED(x))
DEALLOCATE(x,stat=io)
163 IF(
ALLOCATED(y))
DEALLOCATE(y,stat=io)
164 ALLOCATE(x(l),y(l),stat=io)
167 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
168 w
"cannot perform allocation, L ",l
173 w
WRITE(
gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_ARRAY: L= ",l
177 w
"GRIDMAN_TEMPLATE_READ_ARRAY: read coordinates"
183 12
READ(3,
'(A)',end=22,iostat=io) str
185 IF(index(str,
'>>').GT.0)
GOTO 12
186 IF(len_trim(str).LT.1)
THEN
188 IF(iv1.NE.n(ip))
THEN
189 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
190 w
"internal error - counts do not match"
202 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
203 w
"internal error - counts do not match"
208 READ(str,*,iostat=io) x(iv),y(iv)
217 w
WRITE(
gridman_unit,*)
"GRIDMAN_TEMPLATE_READ_ARRAY finished"
222 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_READ_ARRAY: ",
223 w
"cannot read template from file ",trim(fname)
224 200
IF(
ALLOCATED(n))
DEALLOCATE(n,stat=io)
225 IF(
ALLOCATED(x))
DEALLOCATE(x,stat=io)
226 IF(
ALLOCATED(y))
DEALLOCATE(y,stat=io)
247 CHARACTER(*),
INTENT(IN) :: FNAME
249 INTEGER(GRIDMAN_SP),
INTENT(IN) :: M
251 INTEGER(GRIDMAN_SP),
INTENT(IN) :: N(m)
253 INTEGER(GRIDMAN_SP),
INTENT(IN) :: L
255 REAL(GRIDMAN_DP),
INTENT(IN) :: X(l)
257 REAL(GRIDMAN_DP),
INTENT(IN) :: Y(l)
259 INTEGER,
INTENT(OUT) :: IERR
261 INTEGER(GRIDMAN_SP) :: L1,IP,IV,IL
265 w
WRITE(
gridman_unit,*)
"Starting GRIDMAN_TEMPLATE_READ_ARRAY"
270 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_WRITE_ARRAY: ",
271 w
"incorrect number of polygons, M ",m
278 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_WRITE_ARRAY: ",
279 w
"incorrect number of points - L=/=sum(N)"
285 OPEN (unit=3,status=
'REPLACE',access=
'SEQUENTIAL',
286 o form=
'FORMATTED',file=fname,iostat=io)
289 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_WRITE_ARRAY: ",
290 o
"can not open ",trim(fname)
300 w
"ERROR in GRIDMAN_TEMPLATE_WRITE_ARRAY: ",
301 w
"internal error - too large index, IL, L ",il,l
306 WRITE(3,*,iostat=io) x(il), y(il)
316 w
WRITE(
gridman_unit,*)
"GRIDMAN_TEMPLATE_WRITE_ARRAY finished"
322 WRITE(
gridman_unit,*)
"ERROR in GRIDMAN_TEMPLATE_WRITE_ARRAY: ",
323 w
"cannot write into file ",trim(fname)
integer, save, public gridman_unit
Index of the standard output unit.
integer, parameter, public gridman_dp
Kind parameter for real numbers.
logical, save, public gridman_dbg
Switch for debugging mode.
Definition of data types, global constants and variables.
integer, parameter, public gridman_sp
Kind parameter for integer numbers.