55 u gridman_dbg,gridman_unit
59 CHARACTER(*),
INTENT(IN) :: FNAME
61 CHARACTER(*),
INTENT(OUT) :: STITLE
63 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NX
65 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NY
67 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NNCUT
69 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NNISO
71 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NXCUT(:,:)
73 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NYCUT(:,:)
75 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NXISO(:,:)
77 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NYISO(:,:)
79 REAL(GRIDMAN_DP),
ALLOCATABLE :: BR(:,:,:)
81 REAL(GRIDMAN_DP),
ALLOCATABLE :: BZ(:,:,:)
83 INTEGER,
INTENT(OUT) :: IERR
86 INTEGER(GRIDMAN_SP) :: IX,IY,I
90 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_CARRE_READ30_ARRAY"
97 OPEN (unit=30,status=
'OLD',access=
'SEQUENTIAL',
98 o form=
'FORMATTED',file=fname,iostat=io)
101 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
102 o
"can not open ",fname(1:sl)
107 OPEN (unit=30,status=
'OLD',access=
'SEQUENTIAL',
108 o form=
'FORMATTED',file=
'fort.30',iostat=io)
111 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
112 o
"can not open fort.30"
118 READ(30,
'(A)',iostat=io) stitle
120 10
READ(30,
'(A)',iostat=io) str
122 IF(len_trim(str).LT.1)
GOTO 10
123 READ(str,*,iostat=io) nx,ny,nncut
126 IF(
ALLOCATED(nxcut))
DEALLOCATE(nxcut)
127 IF(
ALLOCATED(nycut))
DEALLOCATE(nycut)
128 ALLOCATE(nxcut(2,nncut),nycut(2,nncut),stat=is)
131 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
132 w
"can not perform allocation"
137 READ(30,*,iostat=io) (nxcut(1,i),nxcut(2,i),
138 r nycut(1,i),nycut(2,i),i=1,nncut)
142 IF(
ALLOCATED(nxcut))
DEALLOCATE(nxcut)
143 IF(
ALLOCATED(nycut))
DEALLOCATE(nycut)
144 ALLOCATE(nxcut(1,1),nycut(1,1),stat=is)
147 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
148 w
"can not perform allocation"
156 READ(30,*,iostat=io) nniso
159 IF(
ALLOCATED(nxiso))
DEALLOCATE(nxiso)
160 IF(
ALLOCATED(nyiso))
DEALLOCATE(nyiso)
161 ALLOCATE(nxiso(2,nniso),nyiso(2,nniso),stat=is)
164 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
165 w
"can not perform allocation"
170 READ(30,*,iostat=io) (nxiso(1,i),nxiso(2,i),
171 r nyiso(1,i),nyiso(2,i),i=1,nniso)
178 IF(.NOT.
ALLOCATED(nxiso) )
THEN
179 ALLOCATE(nxiso(1,1),nyiso(1,1),stat=is)
182 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
183 w
"can not perform allocation"
193 IF(nx.GT.0.AND.ny.GT.0)
THEN
195 IF(
ALLOCATED(br))
DEALLOCATE(br)
196 IF(
ALLOCATED(bz))
DEALLOCATE(bz)
197 ALLOCATE(br(nx,ny,4),bz(nx,ny,4),stat=is)
200 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
201 w
"can not perform allocation"
209 READ(30,*,iostat=io,err=200,end=200) (br(ix,iy,i),i=1,4)
212 READ(30,*,iostat=io,err=200,end=200) (bz(ix,iy,i),i=1,4)
218 WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: ",
219 w
"incorrect dimensions, NX, NY ", ny,ny
220 WRITE(gridman_unit,*)
" Reading of BR and BZ is skipped"
230 IF(.NOT.
ALLOCATED(nxcut))
ALLOCATE(nxcut(1,1))
231 IF(.NOT.
ALLOCATED(nycut))
ALLOCATE(nycut(1,1))
232 IF(.NOT.
ALLOCATED(nxiso))
ALLOCATE(nxiso(1,1))
233 IF(.NOT.
ALLOCATED(nyiso))
ALLOCATE(nyiso(1,1))
236 w
WRITE(gridman_unit,*)
"GRIDMAN_CARRE_READ30_ARRAY finished"
242 WRITE(gridman_unit,*)
243 w
"ERROR in GRIDMAN_CARRE_READ30_ARRAY: can not read fort.30"
254 END SUBROUTINE nullify
281 s rbt,br,bz,pit,bc,ierr)
283 u gridman_dbg,gridman_unit
287 CHARACTER(*),
INTENT(IN) :: FNAME
289 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NX
291 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NY
293 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NNCUT
295 INTEGER(GRIDMAN_SP),
INTENT(OUT) :: NNISO
297 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NXCUT(:)
299 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NYCUT(:)
301 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NXISO(:)
303 INTEGER(GRIDMAN_SP),
ALLOCATABLE :: NYISO(:)
305 REAL(GRIDMAN_DP) :: RBT
307 REAL(GRIDMAN_DP),
ALLOCATABLE :: BR(:,:,:)
309 REAL(GRIDMAN_DP),
ALLOCATABLE :: BZ(:,:,:)
313 REAL(GRIDMAN_DP),
ALLOCATABLE :: BC(:,:,:)
317 REAL(GRIDMAN_DP),
ALLOCATABLE :: PIT(:,:)
319 INTEGER,
INTENT(OUT) :: IERR
321 INTEGER,
PARAMETER :: LS=1024
322 CHARACTER(LEN=LS) :: STR
323 INTEGER :: I,I1,I2,I3,ST,IO,IS
324 INTEGER(GRIDMAN_SP) :: IX,IY,N,M
325 REAL(GRIDMAN_DP) :: RR(4),ZZ(4),PITT,BCX,BCY
329 w
WRITE(gridman_unit,*)
"Starting GRIDMAN_CARRE_READSONNET_ARRAY"
337 OPEN (unit=30,status=
'OLD',access=
'SEQUENTIAL',
338 o form=
'FORMATTED',file=fname,iostat=io)
341 WRITE(gridman_unit,*)
342 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
343 o
"can not open ",trim(fname)
349 w
WRITE(gridman_unit,*)
350 w
"GRIDMAN_CARRE_READSONNET_ARRAY reading header"
351 100
READ(30,
'(A)',iostat=io) str
352 IF(io.NE.0)
GOTO 1000
353 i=carre_substring(str,
'R*Btor')
355 READ(str(i+1:ls),*) rbt
358 i=carre_substring(str,
'nx')
359 i1=index(str,
'nxcut')
360 i2=index(str,
'nxiso')
361 IF(i.GT.0.AND.i1.EQ.0.AND.i2.EQ.0)
THEN
362 READ(str(i+1:ls),*) nx
365 i=carre_substring(str,
'ny')
366 i1=index(str,
'nycut')
367 i2=index(str,
'nyiso')
368 IF(i.GT.0.AND.i1.EQ.0.AND.i2.EQ.0)
THEN
369 READ(str(i+1:ls),*) ny
372 i=carre_substring(str,
'ncut')
374 READ(str(i+1:ls),*) nncut
375 IF(
ALLOCATED(nxcut))
DEALLOCATE(nxcut)
376 IF(
ALLOCATED(nycut))
DEALLOCATE(nycut)
377 ALLOCATE(nxcut(nncut),nycut(nncut),stat=is)
380 WRITE(gridman_unit,*)
381 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
382 w
"can not allocate NXCUT, NYCUT"
387 i=carre_substring(str,
'niso')
389 READ(str(i+1:ls),*) nniso
390 IF(
ALLOCATED(nxiso))
DEALLOCATE(nxiso)
391 IF(
ALLOCATED(nyiso))
DEALLOCATE(nyiso)
392 ALLOCATE(nxiso(nniso),nyiso(nniso),stat=is)
395 WRITE(gridman_unit,*)
396 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
397 w
"can not allocate NXCUT, NYCUT"
402 i=carre_substring(str,
'nxcut')
404 IF(
ALLOCATED(nxcut))
THEN
405 READ(str(i+1:ls),*) nxcut
408 WRITE(gridman_unit,*)
409 w
"WARNING from GRIDMAN_CARRE_READSONNET_ARRAY: ",
410 w
"keyword nxcut present but array NXCUT is not allocated"
414 i=carre_substring(str,
'nycut')
416 IF(
ALLOCATED(nycut))
THEN
417 READ(str(i+1:ls),*) nycut
420 WRITE(gridman_unit,*)
421 w
"WARNING from GRIDMAN_CARRE_READSONNET_ARRAY: ",
422 w
"keyword 'nxcut' present but array NYCUT is not allocated"
426 i=carre_substring(str,
'nxiso')
428 IF(
ALLOCATED(nxiso))
THEN
429 READ(str(i+1:ls),*) nxiso
432 WRITE(gridman_unit,*)
433 w
"WARNING from GRIDMAN_CARRE_READSONNET_ARRAY: ",
434 w
"keyword 'nxiso' present but array NXISO is not allocated"
438 i=carre_substring(str,
'nyiso')
440 IF(
ALLOCATED(nyiso))
THEN
441 READ(str(i+1:ls),*) nyiso
444 WRITE(gridman_unit,*)
445 w
"WARNING from GRIDMAN_CARRE_READSONNET_ARRAY: ",
446 w
"keyword 'nyiso' present but array NYISO is not allocated"
450 IF(index(str,
'===').GT.0)
GOTO 200
455 IF(nx.GT.0.AND.ny.GT.0)
THEN
456 IF(
ALLOCATED(br))
DEALLOCATE(br)
457 IF(
ALLOCATED(bz))
DEALLOCATE(bz)
458 IF(
ALLOCATED(bc))
DEALLOCATE(bc)
459 IF(
ALLOCATED(pit))
DEALLOCATE(pit)
460 ALLOCATE(br(0:nx+1,0:ny+1,4),bz(0:nx+1,0:ny+1,4),
461 a pit(0:nx+1,0:ny+1),bc(0:nx+1,0:ny+1,2),stat=st)
464 WRITE(gridman_unit,*)
465 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
466 w
"can not allocate BR, BZ, PIT, BC "
467 WRITE(gridman_unit,*)
" NX, NY ",nx,ny
472 WRITE(gridman_unit,*)
473 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
474 w
"wrong dimensions, NX, NY ",nx,ny
479 WRITE(gridman_unit,*)
"GRIDMAN_CARRE_READSONNET_ARRAY"
480 WRITE(gridman_unit,*)
" RBT ",rbt
481 WRITE(gridman_unit,*)
" NX, NY ",nx,ny
482 WRITE(gridman_unit,*)
" NCUT, NISO ",nncut,nniso
484 WRITE(gridman_unit,*)
" NXCUT ",nxcut
485 WRITE(gridman_unit,*)
" NYCUT ",nycut
488 WRITE(gridman_unit,*)
" NXCUT ",nxiso
489 WRITE(gridman_unit,*)
" NYCUT ",nyiso
493 IF(gridman_dbg)
WRITE(gridman_unit,*)
494 w
"GRIDMAN_CARRE_READSONNET_ARRAY reading the grid"
499 300
READ (30,
'(A)',iostat=io,end=400) str
500 IF(io.NE.0)
GOTO 1000
501 i=index(str,
'Element')
502 IF(i.LT.1) i=index(str,
'ELEMENT')
504 CALL find_numbers(str,1,i1,i2,i3)
505 IF(i1.EQ.0)
GOTO 1010
506 READ(str(i1+1:i2-1),*,iostat=io) ix
507 IF(io.NE.0)
GOTO 1000
508 READ(str(i2+1:i3-1),*,iostat=io) iy
509 IF(io.NE.0)
GOTO 1000
511 CALL find_numbers(str,i,i1,i2,i3)
512 IF(i1.EQ.0)
GOTO 1010
513 READ(str(i1+1:i2-1),*,iostat=io) rr(3)
514 IF(io.NE.0)
GOTO 1000
515 READ(str(i2+1:i3-1),*,iostat=io) zz(3)
516 IF(io.NE.0)
GOTO 1000
518 CALL find_numbers(str,i,i1,i2,i3)
519 IF(i1.EQ.0)
GOTO 1010
520 READ(str(i1+1:i2-1),*,iostat=io) rr(2)
521 IF(io.NE.0)
GOTO 1000
522 READ(str(i2+1:i3-1),*,iostat=io) zz(2)
523 IF(io.NE.0)
GOTO 1000
524 READ (30,
'(A)',iostat=io) str
525 IF(io.NE.0)
GOTO 1000
528 IF(i1.GT.0.AND.i2.GT.i1)
THEN
529 READ(str(i1+1:i2-1),*,iostat=io) pitt
530 IF(io.NE.0)
GOTO 1000
532 CALL find_numbers(str,i,i1,i2,i3)
533 IF(i1.EQ.0)
GOTO 1010
534 READ(str(i1+1:i2-1),*,iostat=io) bcx
535 IF(io.NE.0)
GOTO 1000
536 READ(str(i2+1:i3-1),*,iostat=io) bcy
537 IF(io.NE.0)
GOTO 1000
542 READ (30,
'(A)',iostat=io) str
543 IF(io.NE.0)
GOTO 1000
544 CALL find_numbers(str,1,i1,i2,i3)
545 IF(i1.EQ.0)
GOTO 1010
546 READ(str(i1+1:i2-1),*,iostat=io) rr(4)
547 IF(io.NE.0)
GOTO 1000
548 READ(str(i2+1:i3-1),*,iostat=io) zz(4)
549 IF(io.NE.0)
GOTO 1000
551 CALL find_numbers(str,i,i1,i2,i3)
552 IF(i1.EQ.0)
GOTO 1010
553 READ(str(i1+1:i2-1),*,iostat=io) rr(1)
554 IF(io.NE.0)
GOTO 1000
555 READ(str(i2+1:i3-1),*,iostat=io) zz(1)
556 IF(io.NE.0)
GOTO 1000
557 IF(ix.GT.-1.AND.ix.LT.nx+2.AND.
558 f iy.GT.-1.AND.iy.LT.ny+2)
THEN
566 WRITE(gridman_unit,*)
567 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
568 w
"wrong index, IX, IY, NX, NY ",ix,iy,nx,ny
580 WRITE(gridman_unit,*)
581 w
"WARNING from GRIDMAN_CARRE_READSONNET_ARRAY: ",
582 w
"could not read fild ratio, set to 1 "
588 WRITE(gridman_unit,*)
589 w
"WARNUNG from GRIDMAN_CARRE_READSONNET_ARRAY: ",
590 w
"mismatch between expected and actual number of elements"
591 WRITE(gridman_unit,*)
"Expected number of elements: ",m
592 WRITE(gridman_unit,*)
"Number of elements read: ",n
598 IF(.NOT.
ALLOCATED(nxcut))
ALLOCATE(nxcut(1))
599 IF(.NOT.
ALLOCATED(nycut))
ALLOCATE(nycut(1))
600 IF(.NOT.
ALLOCATED(nxiso))
ALLOCATE(nxiso(1))
601 IF(.NOT.
ALLOCATED(nyiso))
ALLOCATE(nyiso(1))
604 w
WRITE(gridman_unit,*)
"GRIDMAN_CARRE_READSONNET_ARRAY finished"
608 1000
WRITE(gridman_unit,*)
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: "
610 1010
WRITE(gridman_unit,*)
"Can not read ",fname(1:len_trim(fname))
611 WRITE(gridman_unit,*)
" Last line ",trim(str)
613 IF(
ALLOCATED(nxcut))
DEALLOCATE(nxcut,stat=st)
614 IF(
ALLOCATED(nycut))
DEALLOCATE(nycut,stat=st)
615 IF(
ALLOCATED(nxiso))
DEALLOCATE(nxiso,stat=st)
616 IF(
ALLOCATED(nyiso))
DEALLOCATE(nyiso,stat=st)
617 IF(
ALLOCATED(br))
DEALLOCATE(br,stat=st)
618 IF(
ALLOCATED(bz))
DEALLOCATE(bz,stat=st)
619 IF(
ALLOCATED(pit))
DEALLOCATE(pit,stat=st)
629 FUNCTION carre_substring(STR,STR1)
630 INTEGER :: CARRE_SUBSTRING,I2,I
631 CHARACTER(*) :: STR,STR1
635 IF(i2.EQ.0) i2=i+len_trim(str1)
640 END FUNCTION carre_substring
643 SUBROUTINE find_numbers(STR,I,I1,I2,I3)
645 INTEGER :: I,I1,I2,I3,L
649 i1=index(str(i:l),
'(')
650 i2=index(str(i:l),
',')
651 i3=index(str(i:l),
')')
652 IF(i1.EQ.1.OR.i2.EQ.0.OR.i3.EQ.0.OR.
653 f i2.LT.i1.OR.i3.LT.i2)
THEN
654 WRITE(gridman_unit,*)
655 w
"ERROR in GRIDMAN_CARRE_READSONNET_ARRAY: ",
656 w
"cannot read notation"
657 WRITE(gridman_unit,*)
"STR=",trim(str)
663 END SUBROUTINE find_numbers
integer, parameter, public gridman_dp
Kind parameter for real numbers.
Definition of data types, global constants and variables.
integer, parameter, public gridman_sp
Kind parameter for integer numbers.