Actual source code: ex5f.F90
1: !
2: !
3: program main
4: #include <petsc/finclude/petscsys.h>
5: #include <petsc/finclude/petscdraw.h>
6: use petscsys
7: implicit none
8: !
9: ! This example demonstrates basic use of the Fortran interface for
10: ! PetscDraw routines.
11: !
12: PetscDraw draw
13: PetscDrawLG lg
14: PetscDrawAxis axis
15: PetscErrorCode ierr
16: PetscBool flg
17: integer x,y,width,height
18: PetscScalar xd,yd
19: PetscReal ten
20: PetscInt i,n,w,h
21: PetscInt one
23: n = 15
24: x = 0
25: y = 0
26: w = 400
27: h = 300
28: ten = 10.0
29: one = 1
31: PetscCallA(PetscInitialize(ierr))
33: ! GetInt requires a PetscInt so have to do this ugly setting
34: PetscCallA(PetscOptionsGetInt(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,'-width',w, flg,ierr))
35: width = int(w)
36: PetscCallA(PetscOptionsGetInt(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,'-height',h,flg,ierr))
37: height = int(h)
38: PetscCallA(PetscOptionsGetInt(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,'-n',n,flg,ierr))
40: PetscCallA(PetscDrawCreate(PETSC_COMM_WORLD,PETSC_NULL_CHARACTER,PETSC_NULL_CHARACTER,x,y,width,height,draw,ierr))
41: PetscCallA(PetscDrawSetFromOptions(draw,ierr))
43: PetscCallA(PetscDrawLGCreate(draw,one,lg,ierr))
44: PetscCallA(PetscDrawLGGetAxis(lg,axis,ierr))
45: PetscCallA(PetscDrawAxisSetColors(axis,PETSC_DRAW_BLACK,PETSC_DRAW_RED,PETSC_DRAW_BLUE,ierr))
46: PetscCallA(PetscDrawAxisSetLabels(axis,'toplabel','xlabel','ylabel',ierr))
48: do 10, i=0,n-1
49: xd = real(i) - 5.0
50: yd = xd*xd
51: PetscCallA(PetscDrawLGAddPoint(lg,xd,yd,ierr))
52: 10 continue
54: PetscCallA(PetscDrawLGSetUseMarkers(lg,PETSC_TRUE,ierr))
55: PetscCallA(PetscDrawLGDraw(lg,ierr))
57: PetscCallA(PetscSleep(ten,ierr))
59: PetscCallA(PetscDrawLGDestroy(lg,ierr))
60: PetscCallA(PetscDrawDestroy(draw,ierr))
61: PetscCallA(PetscFinalize(ierr))
62: end
64: !/*TEST
65: !
66: ! build:
67: ! requires: x
68: !
69: ! test:
70: ! output_file: output/ex1_1.out
71: !
72: !TEST*/