xref: /petsc/src/dm/impls/plex/tests/ex26f90.F90 (revision 280aadf639d17c6340e15cfb6d09f7f4f589614d)
1*280aadf6SBlaise Bourdinprogram ex26f90
2*280aadf6SBlaise Bourdin#include "petsc/finclude/petsc.h"
3*280aadf6SBlaise Bourdin    use petsc
4*280aadf6SBlaise Bourdin    implicit none
5*280aadf6SBlaise Bourdin#include "exodusII.inc"
6*280aadf6SBlaise Bourdin
7*280aadf6SBlaise Bourdin    ! Get the fortran kind associated with PetscInt and PetscReal so that we can use literal constants.
8*280aadf6SBlaise Bourdin    PetscInt                           :: dummyPetscInt
9*280aadf6SBlaise Bourdin    PetscReal                          :: dummyPetscreal
10*280aadf6SBlaise Bourdin    integer,parameter                  :: kPI = kind(dummyPetscInt)
11*280aadf6SBlaise Bourdin    integer,parameter                  :: kPR = kind(dummyPetscReal)
12*280aadf6SBlaise Bourdin
13*280aadf6SBlaise Bourdin    type(tDM)                          :: dm,dmU,dmA,dmS,dmUA,dmUA2,pDM
14*280aadf6SBlaise Bourdin    type(tDM),dimension(:),pointer     :: dmList
15*280aadf6SBlaise Bourdin    type(tVec)                         :: X,U,A,S,UA,UA2
16*280aadf6SBlaise Bourdin    type(tIS)                          :: isU,isA,isS,isUA
17*280aadf6SBlaise Bourdin    type(tPetscSection)                :: section
18*280aadf6SBlaise Bourdin    PetscInt,dimension(1)              :: fieldU = [0]
19*280aadf6SBlaise Bourdin    PetscInt,dimension(1)              :: fieldA = [2]
20*280aadf6SBlaise Bourdin    PetscInt,dimension(1)              :: fieldS = [1]
21*280aadf6SBlaise Bourdin    PetscInt,dimension(2)              :: fieldUA = [0,2]
22*280aadf6SBlaise Bourdin    character(len=PETSC_MAX_PATH_LEN)  :: ifilename,ofilename,IOBuffer
23*280aadf6SBlaise Bourdin    integer                            :: exoid = -1
24*280aadf6SBlaise Bourdin    type(tIS)                          :: csIS
25*280aadf6SBlaise Bourdin    PetscInt,dimension(:),pointer      :: csID
26*280aadf6SBlaise Bourdin    PetscInt,dimension(:),pointer      :: pStartDepth,pEndDepth
27*280aadf6SBlaise Bourdin    PetscInt                           :: order = 1
28*280aadf6SBlaise Bourdin    PetscInt                           :: sdim,d,pStart,pEnd,p,numCS,set,i,j
29*280aadf6SBlaise Bourdin    PetscMPIInt                        :: rank,numProc
30*280aadf6SBlaise Bourdin    PetscBool                          :: flg
31*280aadf6SBlaise Bourdin    PetscErrorCode                     :: ierr
32*280aadf6SBlaise Bourdin    MPI_Comm                           :: comm
33*280aadf6SBlaise Bourdin    type(tPetscViewer)                 :: viewer
34*280aadf6SBlaise Bourdin
35*280aadf6SBlaise Bourdin    Character(len=MXSTLN)              :: sJunk
36*280aadf6SBlaise Bourdin    PetscInt                           :: numstep = 3, step
37*280aadf6SBlaise Bourdin    PetscInt                           :: numNodalVar,numZonalVar
38*280aadf6SBlaise Bourdin    character(len=MXSTLN)              :: nodalVarName(4)
39*280aadf6SBlaise Bourdin    character(len=MXSTLN)              :: zonalVarName(6)
40*280aadf6SBlaise Bourdin    logical,dimension(:,:),pointer     :: truthtable
41*280aadf6SBlaise Bourdin
42*280aadf6SBlaise Bourdin    type(tIS)                          :: cellIS
43*280aadf6SBlaise Bourdin    PetscInt,dimension(:),pointer      :: cellID
44*280aadf6SBlaise Bourdin    PetscInt                           :: numCells, cell, closureSize
45*280aadf6SBlaise Bourdin    PetscInt,dimension(:),pointer      :: closureA,closure
46*280aadf6SBlaise Bourdin
47*280aadf6SBlaise Bourdin    type(tPetscSection)                :: sectionUA,coordSection
48*280aadf6SBlaise Bourdin    type(tVec)                         :: UALoc,coord
49*280aadf6SBlaise Bourdin    PetscScalar,dimension(:),pointer   :: cval,xyz
50*280aadf6SBlaise Bourdin    PetscInt                           :: dofUA,offUA,c
51*280aadf6SBlaise Bourdin
52*280aadf6SBlaise Bourdin    ! dof layout ordered by increasing height in the DAG: cell, face, edge, vertex
53*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofS2D     = [0, 0, 3]
54*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofUP1Tri  = [2, 0, 0]
55*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofAP1Tri  = [1, 0, 0]
56*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofUP2Tri  = [2, 2, 0]
57*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofAP2Tri  = [1, 1, 0]
58*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofUP1Quad = [2, 0, 0]
59*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofAP1Quad = [1, 0, 0]
60*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofUP2Quad = [2, 2, 2]
61*280aadf6SBlaise Bourdin    PetscInt,dimension(3),target        :: dofAP2Quad = [1, 1, 1]
62*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofS3D     = [0, 0, 0, 6]
63*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofUP1Tet  = [3, 0, 0, 0]
64*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofAP1Tet  = [1, 0, 0, 0]
65*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofUP2Tet  = [3, 3, 0, 0]
66*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofAP2Tet  = [1, 1, 0, 0]
67*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofUP1Hex  = [3, 0, 0, 0]
68*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofAP1Hex  = [1, 0, 0, 0]
69*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofUP2Hex  = [3, 3, 3, 3]
70*280aadf6SBlaise Bourdin    PetscInt,dimension(4),target        :: dofAP2Hex  = [1, 1, 1, 1]
71*280aadf6SBlaise Bourdin    PetscInt,dimension(:),pointer       :: dofU,dofA,dofS
72*280aadf6SBlaise Bourdin
73*280aadf6SBlaise Bourdin    type(tPetscSF)                      :: migrationSF
74*280aadf6SBlaise Bourdin    PetscPartitioner                    :: part
75*280aadf6SBlaise Bourdin
76*280aadf6SBlaise Bourdin    type(tVec)                          :: tmpVec
77*280aadf6SBlaise Bourdin    PetscReal                           :: norm
78*280aadf6SBlaise Bourdin    PetscReal                           :: time = 1.234_kPR
79*280aadf6SBlaise Bourdin
80*280aadf6SBlaise Bourdin    call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
81*280aadf6SBlaise Bourdin    if (ierr /= 0) then
82*280aadf6SBlaise Bourdin      print*,'Unable to initialize PETSc'
83*280aadf6SBlaise Bourdin      stop
84*280aadf6SBlaise Bourdin    endif
85*280aadf6SBlaise Bourdin
86*280aadf6SBlaise Bourdin    call MPI_Comm_rank(PETSC_COMM_WORLD,rank,ierr)
87*280aadf6SBlaise Bourdin    call MPI_Comm_size(PETSC_COMM_WORLD,numProc,ierr)
88*280aadf6SBlaise Bourdin    call PetscOptionsGetString(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,"-i",ifilename,flg,ierr);CHKERRA(ierr)
89*280aadf6SBlaise Bourdin    if (.not. flg) then
90*280aadf6SBlaise Bourdin        SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"missing input file name -i <input file name>")
91*280aadf6SBlaise Bourdin    end if
92*280aadf6SBlaise Bourdin    call PetscOptionsGetString(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,"-o",ofilename,flg,ierr);CHKERRA(ierr)
93*280aadf6SBlaise Bourdin    if (.not. flg) then
94*280aadf6SBlaise Bourdin        SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,"missing output file name -o <output file name>")
95*280aadf6SBlaise Bourdin    end if
96*280aadf6SBlaise Bourdin    call PetscOptionsGetInt(PETSC_NULL_OPTIONS,PETSC_NULL_CHARACTER,"-order",order,flg,ierr);CHKERRA(ierr)
97*280aadf6SBlaise Bourdin    if ((order > 2) .or. (order < 1)) then
98*280aadf6SBlaise Bourdin        write(IOBuffer,'("Unsupported polynomial order ", I2, " not in [1,2]")') order
99*280aadf6SBlaise Bourdin        SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_ARG_OUTOFRANGE,IOBuffer)
100*280aadf6SBlaise Bourdin    end if
101*280aadf6SBlaise Bourdin
102*280aadf6SBlaise Bourdin    ! Read the mesh in any supported format
103*280aadf6SBlaise Bourdin    call DMPlexCreateFromFile(PETSC_COMM_WORLD, ifilename,PETSC_TRUE,dm,ierr);CHKERRA(ierr)
104*280aadf6SBlaise Bourdin    call DMSetFromOptions(dm,ierr);CHKERRA(ierr);
105*280aadf6SBlaise Bourdin    call DMGetDimension(dm, sdim,ierr);CHKERRA(ierr)
106*280aadf6SBlaise Bourdin    call DMViewFromOptions(dm, PETSC_NULL_OPTIONS,"-dm_view",ierr);CHKERRA(ierr);
107*280aadf6SBlaise Bourdin
108*280aadf6SBlaise Bourdin    ! Create the exodus result file
109*280aadf6SBlaise Bourdin
110*280aadf6SBlaise Bourdin    ! enable exodus debugging informations
111*280aadf6SBlaise Bourdin    call exopts(EXVRBS+EXDEBG,ierr)
112*280aadf6SBlaise Bourdin    ! Create the exodus file
113*280aadf6SBlaise Bourdin    call PetscViewerExodusIIOpen(PETSC_COMM_WORLD,ofilename,FILE_MODE_WRITE,viewer,ierr);CHKERRA(ierr)
114*280aadf6SBlaise Bourdin    ! The long way would be
115*280aadf6SBlaise Bourdin    !
116*280aadf6SBlaise Bourdin    ! call PetscViewerCreate(PETSC_COMM_WORLD,viewer,ierr);CHKERRA(ierr)
117*280aadf6SBlaise Bourdin    ! call PetscViewerSetType(viewer,PETSCVIEWEREXODUSII,ierr);CHKERRA(ierr)
118*280aadf6SBlaise Bourdin    ! call PetscViewerFileSetMode(viewer,FILE_MODE_WRITE,ierr);CHKERRA(ierr)
119*280aadf6SBlaise Bourdin    ! call PetscViewerFileSetName(viewer,ofilename,ierr);CHKERRA(ierr)
120*280aadf6SBlaise Bourdin
121*280aadf6SBlaise Bourdin    ! set the mesh order
122*280aadf6SBlaise Bourdin    call PetscViewerExodusIISetOrder(viewer,order,ierr);CHKERRA(ierr)
123*280aadf6SBlaise Bourdin    call PetscViewerView(viewer,PETSC_VIEWER_STDOUT_WORLD,ierr);CHKERRA(ierr)
124*280aadf6SBlaise Bourdin    !
125*280aadf6SBlaise Bourdin    !    Notice how the exodus file is actually NOT open at this point (exoid is -1)
126*280aadf6SBlaise Bourdin    !    Since we are overwritting the file (mode is FILE_MODE_WRITE), we are going to have to
127*280aadf6SBlaise Bourdin    !    write the geometry (the DM), which can only be done on a brand new file.
128*280aadf6SBlaise Bourdin    !
129*280aadf6SBlaise Bourdin
130*280aadf6SBlaise Bourdin    ! Save the geometry to the file, erasing all previous content
131*280aadf6SBlaise Bourdin    call DMView(dm,viewer,ierr);CHKERRA(ierr)
132*280aadf6SBlaise Bourdin    call PetscViewerView(viewer,PETSC_VIEWER_STDOUT_WORLD,ierr);CHKERRA(ierr)
133*280aadf6SBlaise Bourdin    !
134*280aadf6SBlaise Bourdin    !    Note how the exodus file is now open
135*280aadf6SBlaise Bourdin    !
136*280aadf6SBlaise Bourdin    ! "Format" the exodus result file, i.e. allocate space for nodal and zonal variables
137*280aadf6SBlaise Bourdin    select case(sdim)
138*280aadf6SBlaise Bourdin    case(2)
139*280aadf6SBlaise Bourdin        numNodalVar = 3
140*280aadf6SBlaise Bourdin        nodalVarName(1:numNodalVar) = ["U_x  ","U_y  ","Alpha"]
141*280aadf6SBlaise Bourdin        numZonalVar = 3
142*280aadf6SBlaise Bourdin        zonalVarName(1:numZonalVar) = ["Sigma_11","Sigma_22","Sigma_12"]
143*280aadf6SBlaise Bourdin    case(3)
144*280aadf6SBlaise Bourdin        numNodalVar = 4
145*280aadf6SBlaise Bourdin        nodalVarName(1:numNodalVar) = ["U_x  ","U_y  ","U_z  ","Alpha"]
146*280aadf6SBlaise Bourdin        numZonalVar = 6
147*280aadf6SBlaise Bourdin        zonalVarName(1:numZonalVar) = ["Sigma_11","Sigma_22","Sigma_33","Sigma_23","Sigma_13","Sigma_12"]
148*280aadf6SBlaise Bourdin    case default
149*280aadf6SBlaise Bourdin        write(IOBuffer,'("No layout for dimension ",I2)') sdim
150*280aadf6SBlaise Bourdin    end select
151*280aadf6SBlaise Bourdin    call PetscViewerExodusIIGetId(viewer,exoid,ierr);CHKERRA(ierr)
152*280aadf6SBlaise Bourdin    call expvp(exoid, "E", numZonalVar,ierr)
153*280aadf6SBlaise Bourdin    call expvan(exoid, "E", numZonalVar, zonalVarName,ierr)
154*280aadf6SBlaise Bourdin    call expvp(exoid, "N", numNodalVar,ierr)
155*280aadf6SBlaise Bourdin    call expvan(exoid, "N", numNodalVar, nodalVarName,ierr)
156*280aadf6SBlaise Bourdin    call exinq(exoid, EX_INQ_ELEM_BLK,numCS,PETSC_NULL_REAL,sjunk,ierr)
157*280aadf6SBlaise Bourdin
158*280aadf6SBlaise Bourdin    !    An exodusII truth table specifies which fields are saved at which time step
159*280aadf6SBlaise Bourdin    !    It speeds up I/O but reserving space for fields in the file ahead of time.
160*280aadf6SBlaise Bourdin    allocate(truthtable(numCS,numZonalVar))
161*280aadf6SBlaise Bourdin    truthtable = .true.
162*280aadf6SBlaise Bourdin    call expvtt(exoid, numCS, numZonalVar, truthtable, ierr)
163*280aadf6SBlaise Bourdin    deallocate(truthtable)
164*280aadf6SBlaise Bourdin
165*280aadf6SBlaise Bourdin    !   Writing time step information in the file. Note that this is currently broken in the exodus library for netcdf4 (HDF5-based) files */
166*280aadf6SBlaise Bourdin    do step = 1,numstep
167*280aadf6SBlaise Bourdin        call exptim(exoid,step,Real(step,kind=kPR),ierr)
168*280aadf6SBlaise Bourdin    end do
169*280aadf6SBlaise Bourdin
170*280aadf6SBlaise Bourdin    call PetscObjectGetComm(dm,comm,ierr);CHKERRA(ierr)
171*280aadf6SBlaise Bourdin    call PetscSectionCreate(comm, section,ierr);CHKERRA(ierr)
172*280aadf6SBlaise Bourdin    call PetscSectionSetNumFields(section, 3_kPI,ierr);CHKERRA(ierr)
173*280aadf6SBlaise Bourdin    call PetscSectionSetFieldName(section, fieldU, "U",ierr);CHKERRA(ierr)
174*280aadf6SBlaise Bourdin    call PetscSectionSetFieldName(section, fieldA, "Alpha",ierr);CHKERRA(ierr)
175*280aadf6SBlaise Bourdin    call PetscSectionSetFieldName(section, fieldS, "Sigma",ierr);CHKERRA(ierr)
176*280aadf6SBlaise Bourdin    call DMPlexGetChart(dm, pStart, pEnd,ierr);CHKERRA(ierr)
177*280aadf6SBlaise Bourdin    call PetscSectionSetChart(section, pStart, pEnd,ierr);CHKERRA(ierr)
178*280aadf6SBlaise Bourdin
179*280aadf6SBlaise Bourdin    allocate(pStartDepth(sdim+1))
180*280aadf6SBlaise Bourdin    allocate(pEndDepth(sdim+1))
181*280aadf6SBlaise Bourdin    do d = 1, sdim+1
182*280aadf6SBlaise Bourdin        call DMPlexGetDepthStratum(dm, d-1, pStartDepth(d), pEndDepth(d),ierr);CHKERRA(ierr)
183*280aadf6SBlaise Bourdin    end do
184*280aadf6SBlaise Bourdin
185*280aadf6SBlaise Bourdin    ! Vector field U, Scalar field Alpha, Tensor field Sigma
186*280aadf6SBlaise Bourdin    call PetscSectionSetFieldComponents(section, fieldU, sdim,ierr);CHKERRA(ierr);
187*280aadf6SBlaise Bourdin    call PetscSectionSetFieldComponents(section, fieldA, 1_kPI,ierr);CHKERRA(ierr);
188*280aadf6SBlaise Bourdin    call PetscSectionSetFieldComponents(section, fieldS, sdim*(sdim+1)/2,ierr);CHKERRA(ierr);
189*280aadf6SBlaise Bourdin
190*280aadf6SBlaise Bourdin    ! Going through cell sets then cells, and setting up storage for the sections
191*280aadf6SBlaise Bourdin    call DMGetLabelSize(dm, "Cell Sets", numCS, ierr);CHKERRA(ierr)
192*280aadf6SBlaise Bourdin    call DMGetLabelIdIS(dm, "Cell Sets", csIS, ierr);CHKERRA(ierr)
193*280aadf6SBlaise Bourdin    call ISGetIndicesF90(csIS, csID, ierr);CHKERRA(ierr)
194*280aadf6SBlaise Bourdin    do set = 1,numCS
195*280aadf6SBlaise Bourdin        call DMGetStratumSize(dm, "Cell Sets", csID(set), numCells,ierr);CHKERRA(ierr)
196*280aadf6SBlaise Bourdin        call DMGetStratumIS(dm, "Cell Sets", csID(set), cellIS,ierr);CHKERRA(ierr)
197*280aadf6SBlaise Bourdin        if (numCells > 0) then
198*280aadf6SBlaise Bourdin            select case(sdim)
199*280aadf6SBlaise Bourdin            case(2)
200*280aadf6SBlaise Bourdin                dofs => dofS2D
201*280aadf6SBlaise Bourdin            case(3)
202*280aadf6SBlaise Bourdin                dofs => dofS3D
203*280aadf6SBlaise Bourdin            case default
204*280aadf6SBlaise Bourdin                write(IOBuffer,'("No layout for dimension ",I2)') sdim
205*280aadf6SBlaise Bourdin                SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE,IOBuffer)
206*280aadf6SBlaise Bourdin            end select ! sdim
207*280aadf6SBlaise Bourdin
208*280aadf6SBlaise Bourdin            ! Identify cell type based on closure size only. This works for Tri/Tet/Quad/Hex meshes
209*280aadf6SBlaise Bourdin            ! It will not be enough to identify more exotic elements like pyramid or prisms...  */
210*280aadf6SBlaise Bourdin            call ISGetIndicesF90(cellIS, cellID,ierr);CHKERRA(ierr)
211*280aadf6SBlaise Bourdin            nullify(closureA)
212*280aadf6SBlaise Bourdin            call DMPlexGetTransitiveClosure(dm,cellID(1), PETSC_TRUE, closureA,ierr);CHKERRA(ierr)
213*280aadf6SBlaise Bourdin            select case(size(closureA)/2)
214*280aadf6SBlaise Bourdin            case(7) ! Tri
215*280aadf6SBlaise Bourdin                if (order == 1) then
216*280aadf6SBlaise Bourdin                    dofU => dofUP1Tri
217*280aadf6SBlaise Bourdin                    dofA => dofAP1Tri
218*280aadf6SBlaise Bourdin                else
219*280aadf6SBlaise Bourdin                    dofU => dofUP2Tri
220*280aadf6SBlaise Bourdin                    dofA => dofAP2Tri
221*280aadf6SBlaise Bourdin                end if
222*280aadf6SBlaise Bourdin            case(9) ! Quad
223*280aadf6SBlaise Bourdin                if (order == 1) then
224*280aadf6SBlaise Bourdin                    dofU => dofUP1Quad
225*280aadf6SBlaise Bourdin                    dofA => dofAP1Quad
226*280aadf6SBlaise Bourdin                else
227*280aadf6SBlaise Bourdin                    dofU => dofUP2Quad
228*280aadf6SBlaise Bourdin                    dofA => dofAP2Quad
229*280aadf6SBlaise Bourdin                end if
230*280aadf6SBlaise Bourdin            case(15) ! Tet
231*280aadf6SBlaise Bourdin                if (order == 1) then
232*280aadf6SBlaise Bourdin                    dofU => dofUP1Tet
233*280aadf6SBlaise Bourdin                    dofA => dofAP1Tet
234*280aadf6SBlaise Bourdin                else
235*280aadf6SBlaise Bourdin                    dofU => dofUP2Tet
236*280aadf6SBlaise Bourdin                    dofA => dofAP2Tet
237*280aadf6SBlaise Bourdin                end if
238*280aadf6SBlaise Bourdin            case(27) ! Hex
239*280aadf6SBlaise Bourdin                if (order == 1) then
240*280aadf6SBlaise Bourdin                    dofU => dofUP1Hex
241*280aadf6SBlaise Bourdin                    dofA => dofAP1Hex
242*280aadf6SBlaise Bourdin                else
243*280aadf6SBlaise Bourdin                    dofU => dofUP2Hex
244*280aadf6SBlaise Bourdin                    dofA => dofAP2Hex
245*280aadf6SBlaise Bourdin                end if
246*280aadf6SBlaise Bourdin            case default
247*280aadf6SBlaise Bourdin                write(IOBuffer,'("Unknown element with closure size ",I2)') size(closureA)/2
248*280aadf6SBlaise Bourdin                SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP,IOBuffer)
249*280aadf6SBlaise Bourdin            end select
250*280aadf6SBlaise Bourdin            call DMPlexRestoreTransitiveClosure(dm, cellID(1), PETSC_TRUE,closureA,ierr);CHKERRA(ierr)
251*280aadf6SBlaise Bourdin            do cell = 1,numCells!
252*280aadf6SBlaise Bourdin                nullify(closure)
253*280aadf6SBlaise Bourdin                call DMPlexGetTransitiveClosure(dm, cellID(cell), PETSC_TRUE, closure,ierr);CHKERRA(ierr)
254*280aadf6SBlaise Bourdin                do p = 1,size(closure),2
255*280aadf6SBlaise Bourdin                    ! find the depth of p
256*280aadf6SBlaise Bourdin                    do d = 1,sdim+1
257*280aadf6SBlaise Bourdin                        if ((closure(p) >= pStartDepth(d)) .and. (closure(p) < pEndDepth(d))) then
258*280aadf6SBlaise Bourdin                            call PetscSectionSetDof(section, closure(p), dofU(d)+dofA(d)+dofS(d),ierr);CHKERRA(ierr)
259*280aadf6SBlaise Bourdin                            call PetscSectionSetFieldDof(section, closure(p), fieldU, dofU(d),ierr);CHKERRA(ierr)
260*280aadf6SBlaise Bourdin                            call PetscSectionSetFieldDof(section, closure(p), fieldA, dofA(d),ierr);CHKERRA(ierr)
261*280aadf6SBlaise Bourdin                            call PetscSectionSetFieldDof(section, closure(p), fieldS, dofS(d),ierr);CHKERRA(ierr)
262*280aadf6SBlaise Bourdin                        end if ! closure(p)
263*280aadf6SBlaise Bourdin                    end do ! d
264*280aadf6SBlaise Bourdin                end do ! p
265*280aadf6SBlaise Bourdin                call DMPlexRestoreTransitiveClosure(dm, cellID(cell), PETSC_TRUE, closure,ierr);CHKERRA(ierr)
266*280aadf6SBlaise Bourdin            end do ! cell
267*280aadf6SBlaise Bourdin            call ISRestoreIndicesF90(cellIS, cellID,ierr);CHKERRA(ierr)
268*280aadf6SBlaise Bourdin            call ISDestroy(cellIS,ierr);CHKERRA(ierr)
269*280aadf6SBlaise Bourdin        end if ! numCells
270*280aadf6SBlaise Bourdin    end do ! set
271*280aadf6SBlaise Bourdin    call ISRestoreIndicesF90(csIS, csID,ierr);CHKERRA(ierr)
272*280aadf6SBlaise Bourdin    call ISDestroy(csIS,ierr);CHKERRA(ierr)
273*280aadf6SBlaise Bourdin    call PetscSectionSetUp(section,ierr);CHKERRA(ierr)
274*280aadf6SBlaise Bourdin    call DMSetLocalSection(dm, section,ierr);CHKERRA(ierr)
275*280aadf6SBlaise Bourdin    call PetscObjectViewFromOptions(section, PETSC_NULL_SECTION, "-dm_section_view",ierr);CHKERRQ(ierr)
276*280aadf6SBlaise Bourdin    call PetscSectionDestroy(section,ierr);CHKERRA(ierr)
277*280aadf6SBlaise Bourdin
278*280aadf6SBlaise Bourdin    call DMSetUseNatural(dm,PETSC_TRUE,ierr);CHKERRA(ierr)
279*280aadf6SBlaise Bourdin    call DMPlexGetPartitioner(dm,part,ierr);CHKERRA(ierr)
280*280aadf6SBlaise Bourdin    call PetscPartitionerSetFromOptions(part,ierr);CHKERRA(ierr)
281*280aadf6SBlaise Bourdin    call DMPlexDistribute(dm,0_kPI,migrationSF,pdm,ierr);CHKERRA(ierr)
282*280aadf6SBlaise Bourdin
283*280aadf6SBlaise Bourdin    if (numProc > 1) then
284*280aadf6SBlaise Bourdin        call DMPlexSetMigrationSF(pdm,migrationSF,ierr);CHKERRA(ierr)
285*280aadf6SBlaise Bourdin        call PetscSFDestroy(migrationSF,ierr);CHKERRA(ierr)
286*280aadf6SBlaise Bourdin        call DMDestroy(dm,ierr);CHKERRA(ierr)
287*280aadf6SBlaise Bourdin        dm = pdm
288*280aadf6SBlaise Bourdin    end if
289*280aadf6SBlaise Bourdin    call DMViewFromOptions(dm,PETSC_NULL_OPTIONS,"-dm_view",ierr);CHKERRA(ierr)
290*280aadf6SBlaise Bourdin
291*280aadf6SBlaise Bourdin
292*280aadf6SBlaise Bourdin    ! Get DM and IS for each field of dm
293*280aadf6SBlaise Bourdin    call DMCreateSubDM(dm, 1_kPI, fieldU,  isU,  dmU,ierr);CHKERRA(ierr)
294*280aadf6SBlaise Bourdin    call DMCreateSubDM(dm, 1_kPI, fieldA,  isA,  dmA,ierr);CHKERRA(ierr)
295*280aadf6SBlaise Bourdin    call DMCreateSubDM(dm, 1_kPI, fieldS,  isS,  dmS,ierr);CHKERRA(ierr)
296*280aadf6SBlaise Bourdin    call DMCreateSubDM(dm, 2_kPI, fieldUA, isUA, dmUA,ierr);CHKERRA(ierr)
297*280aadf6SBlaise Bourdin
298*280aadf6SBlaise Bourdin    !Create the exodus result file
299*280aadf6SBlaise Bourdin    allocate(dmList(2))
300*280aadf6SBlaise Bourdin    dmList(1) = dmU;
301*280aadf6SBlaise Bourdin    dmList(2) = dmA;
302*280aadf6SBlaise Bourdin    call DMCreateSuperDM(dmList,2_kPI,PETSC_NULL_IS,dmUA2,ierr);CHKERRA(ierr)
303*280aadf6SBlaise Bourdin    deallocate(dmList)
304*280aadf6SBlaise Bourdin
305*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dm,   X,ierr);CHKERRA(ierr)
306*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmU,  U,ierr);CHKERRA(ierr)
307*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmA,  A,ierr);CHKERRA(ierr)
308*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmS,  S,ierr);CHKERRA(ierr)
309*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmUA, UA,ierr);CHKERRA(ierr)
310*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmUA2, UA2,ierr);CHKERRA(ierr)
311*280aadf6SBlaise Bourdin
312*280aadf6SBlaise Bourdin    call PetscObjectSetName(U,  "U",ierr);CHKERRA(ierr)
313*280aadf6SBlaise Bourdin    call PetscObjectSetName(A,  "Alpha",ierr);CHKERRA(ierr)
314*280aadf6SBlaise Bourdin    call PetscObjectSetName(S,  "Sigma",ierr);CHKERRA(ierr)
315*280aadf6SBlaise Bourdin    call PetscObjectSetName(UA, "UAlpha",ierr);CHKERRA(ierr)
316*280aadf6SBlaise Bourdin    call PetscObjectSetName(UA2, "UAlpha2",ierr);CHKERRA(ierr)
317*280aadf6SBlaise Bourdin    call VecSet(X, -111.0_kPR,ierr);CHKERRA(ierr)
318*280aadf6SBlaise Bourdin
319*280aadf6SBlaise Bourdin    ! Setting u to [x,y,z]  and alpha to x^2+y^2+z^2 by writing in UAlpha then restricting to U and Alpha */
320*280aadf6SBlaise Bourdin    call DMGetLocalSection(dmUA, sectionUA,ierr);CHKERRA(ierr)
321*280aadf6SBlaise Bourdin    call DMGetLocalVector(dmUA, UALoc,ierr);CHKERRA(ierr)
322*280aadf6SBlaise Bourdin    call VecGetArrayF90(UALoc, cval,ierr);CHKERRA(ierr)
323*280aadf6SBlaise Bourdin    call DMGetCoordinateSection(dmUA, coordSection,ierr);CHKERRA(ierr)
324*280aadf6SBlaise Bourdin    call DMGetCoordinatesLocal(dmUA, coord,ierr);CHKERRA(ierr)
325*280aadf6SBlaise Bourdin    call DMPlexGetChart(dmUA, pStart, pEnd,ierr);CHKERRA(ierr)
326*280aadf6SBlaise Bourdin
327*280aadf6SBlaise Bourdin
328*280aadf6SBlaise Bourdin    do p = pStart,pEnd-1
329*280aadf6SBlaise Bourdin        call PetscSectionGetDof(sectionUA, p, dofUA,ierr);CHKERRA(ierr)
330*280aadf6SBlaise Bourdin        if (dofUA > 0) then
331*280aadf6SBlaise Bourdin            call PetscSectionGetOffset(sectionUA, p, offUA,ierr);CHKERRA(ierr)
332*280aadf6SBlaise Bourdin            call DMPlexVecGetClosure(dmUA, coordSection, coord, p, xyz,ierr);CHKERRA(ierr)
333*280aadf6SBlaise Bourdin            closureSize = size(xyz)
334*280aadf6SBlaise Bourdin            do i = 1,sdim
335*280aadf6SBlaise Bourdin                do j = 0, closureSize-1,sdim
336*280aadf6SBlaise Bourdin                    cval(offUA+i) = cval(offUA+i) + xyz(j/sdim+i)
337*280aadf6SBlaise Bourdin                end do
338*280aadf6SBlaise Bourdin                cval(offUA+i) = cval(offUA+i) * sdim / closureSize;
339*280aadf6SBlaise Bourdin                cval(offUA+sdim+1) = cval(offUA+sdim+1) + cval(offUA+i)**2
340*280aadf6SBlaise Bourdin            end do
341*280aadf6SBlaise Bourdin            call DMPlexVecRestoreClosure(dmUA, coordSection, coord, p, xyz,ierr);CHKERRA(ierr)
342*280aadf6SBlaise Bourdin        end if
343*280aadf6SBlaise Bourdin    end do
344*280aadf6SBlaise Bourdin
345*280aadf6SBlaise Bourdin    call VecRestoreArrayF90(UALoc, cval,ierr);CHKERRA(ierr)
346*280aadf6SBlaise Bourdin    call DMLocalToGlobalBegin(dmUA, UALoc, INSERT_VALUES, UA,ierr);CHKERRA(ierr)
347*280aadf6SBlaise Bourdin    call DMLocalToGlobalEnd(dmUA, UALoc, INSERT_VALUES, UA,ierr);CHKERRA(ierr)
348*280aadf6SBlaise Bourdin    call DMRestoreLocalVector(dmUA, UALoc,ierr);CHKERRA(ierr)
349*280aadf6SBlaise Bourdin
350*280aadf6SBlaise Bourdin    !Update X
351*280aadf6SBlaise Bourdin    call VecISCopy(X, isUA, SCATTER_FORWARD, UA,ierr);CHKERRA(ierr)
352*280aadf6SBlaise Bourdin    ! Restrict to U and Alpha
353*280aadf6SBlaise Bourdin    call VecISCopy(X, isU, SCATTER_REVERSE, U,ierr);CHKERRA(ierr)
354*280aadf6SBlaise Bourdin    call VecISCopy(X, isA, SCATTER_REVERSE, A,ierr);CHKERRA(ierr)
355*280aadf6SBlaise Bourdin    call VecViewFromOptions(UA, PETSC_NULL_OPTIONS, "-ua_vec_view",ierr);CHKERRA(ierr)
356*280aadf6SBlaise Bourdin    call VecViewFromOptions(U, PETSC_NULL_OPTIONS, "-u_vec_view",ierr);CHKERRA(ierr)
357*280aadf6SBlaise Bourdin    call VecViewFromOptions(A, PETSC_NULL_OPTIONS, "-a_vec_view",ierr);CHKERRA(ierr)
358*280aadf6SBlaise Bourdin    ! restrict to UA2
359*280aadf6SBlaise Bourdin    call VecISCopy(X, isUA, SCATTER_REVERSE, UA2,ierr);CHKERRA(ierr)
360*280aadf6SBlaise Bourdin    call VecViewFromOptions(UA2, PETSC_NULL_OPTIONS, "-ua2_vec_view",ierr);CHKERRA(ierr)
361*280aadf6SBlaise Bourdin
362*280aadf6SBlaise Bourdin    ! Writing nodal variables to ExodusII file
363*280aadf6SBlaise Bourdin    call DMSetOutputSequenceNumber(dmU,0_kPI,time,ierr);CHKERRA(ierr)
364*280aadf6SBlaise Bourdin    call DMSetOutputSequenceNumber(dmA,0_kPI,time,ierr);CHKERRA(ierr)
365*280aadf6SBlaise Bourdin
366*280aadf6SBlaise Bourdin    call VecView(U, viewer,ierr);CHKERRA(ierr)
367*280aadf6SBlaise Bourdin    call VecView(A, viewer,ierr);CHKERRA(ierr)
368*280aadf6SBlaise Bourdin
369*280aadf6SBlaise Bourdin    ! Saving U and Alpha in one shot.
370*280aadf6SBlaise Bourdin    ! For this, we need to cheat and change the Vec's name
371*280aadf6SBlaise Bourdin    ! Note that in the end we write variables one component at a time,
372*280aadf6SBlaise Bourdin    ! so that there is no real value in doing this
373*280aadf6SBlaise Bourdin    call DMSetOutputSequenceNumber(dmUA,1_kPI,time,ierr);CHKERRA(ierr)
374*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmUA, tmpVec,ierr);CHKERRA(ierr)
375*280aadf6SBlaise Bourdin    call VecCopy(UA, tmpVec,ierr);CHKERRA(ierr)
376*280aadf6SBlaise Bourdin    call PetscObjectSetName(tmpVec, "U",ierr);CHKERRA(ierr)
377*280aadf6SBlaise Bourdin    call VecView(tmpVec, viewer,ierr);CHKERRA(ierr)
378*280aadf6SBlaise Bourdin
379*280aadf6SBlaise Bourdin    ! Reading nodal variables in Exodus file
380*280aadf6SBlaise Bourdin    call VecSet(tmpVec, -1000.0_kPR,ierr);CHKERRA(ierr)
381*280aadf6SBlaise Bourdin    call VecLoad(tmpVec, viewer,ierr);CHKERRA(ierr)
382*280aadf6SBlaise Bourdin    call VecAXPY(UA, -1.0_kPR, tmpVec,ierr);CHKERRA(ierr)
383*280aadf6SBlaise Bourdin    call VecNorm(UA, NORM_INFINITY, norm,ierr);CHKERRA(ierr)
384*280aadf6SBlaise Bourdin    if (norm > PETSC_SQRT_MACHINE_EPSILON) then
385*280aadf6SBlaise Bourdin        write(IOBuffer,'("UAlpha ||Vin - Vout|| = ",ES12.5)') norm
386*280aadf6SBlaise Bourdin    end if
387*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmUA, tmpVec,ierr);CHKERRA(ierr)
388*280aadf6SBlaise Bourdin
389*280aadf6SBlaise Bourdin    ! same thing with the UA2 Vec obtained from the superDM
390*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmUA2, tmpVec,ierr);CHKERRA(ierr)
391*280aadf6SBlaise Bourdin    call VecCopy(UA2, tmpVec,ierr);CHKERRA(ierr)
392*280aadf6SBlaise Bourdin    call PetscObjectSetName(tmpVec, "U",ierr);CHKERRA(ierr)
393*280aadf6SBlaise Bourdin    call DMSetOutputSequenceNumber(dmUA2,2_kPI,time,ierr);CHKERRA(ierr)
394*280aadf6SBlaise Bourdin    call VecView(tmpVec, viewer,ierr);CHKERRA(ierr)
395*280aadf6SBlaise Bourdin
396*280aadf6SBlaise Bourdin    ! Reading nodal variables in Exodus file
397*280aadf6SBlaise Bourdin    call VecSet(tmpVec, -1000.0_kPR,ierr);CHKERRA(ierr)
398*280aadf6SBlaise Bourdin    call VecLoad(tmpVec,viewer,ierr);CHKERRA(ierr)
399*280aadf6SBlaise Bourdin    call VecAXPY(UA2, -1.0_kPR, tmpVec,ierr);CHKERRA(ierr)
400*280aadf6SBlaise Bourdin    call VecNorm(UA2, NORM_INFINITY, norm,ierr);CHKERRA(ierr)
401*280aadf6SBlaise Bourdin    if (norm > PETSC_SQRT_MACHINE_EPSILON) then
402*280aadf6SBlaise Bourdin        write(IOBuffer,'("UAlpha2 ||Vin - Vout|| = ",ES12.5)') norm
403*280aadf6SBlaise Bourdin    end if
404*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmUA2, tmpVec,ierr);CHKERRA(ierr)
405*280aadf6SBlaise Bourdin
406*280aadf6SBlaise Bourdin    ! Building and saving Sigma
407*280aadf6SBlaise Bourdin    !   We set sigma_0 = rank (to see partitioning)
408*280aadf6SBlaise Bourdin    !          sigma_1 = cell set ID
409*280aadf6SBlaise Bourdin    !          sigma_2 = x_coordinate of the cell center of mass
410*280aadf6SBlaise Bourdin    call DMGetCoordinateSection(dmS, coordSection,ierr);CHKERRA(ierr)
411*280aadf6SBlaise Bourdin    call DMGetCoordinatesLocal(dmS, coord,ierr);CHKERRA(ierr)
412*280aadf6SBlaise Bourdin    call DMGetLabelIdIS(dmS, "Cell Sets", csIS,ierr);CHKERRA(ierr)
413*280aadf6SBlaise Bourdin    call DMGetLabelSize(dmS, "Cell Sets",numCS,ierr);CHKERRA(ierr)
414*280aadf6SBlaise Bourdin    call ISGetIndicesF90(csIS, csID,ierr);CHKERRA(ierr)
415*280aadf6SBlaise Bourdin
416*280aadf6SBlaise Bourdin    do set = 1, numCS
417*280aadf6SBlaise Bourdin        call DMGetStratumIS(dmS, "Cell Sets", csID(set), cellIS,ierr);CHKERRA(ierr)
418*280aadf6SBlaise Bourdin        call ISGetIndicesF90(cellIS, cellID,ierr);CHKERRA(ierr)
419*280aadf6SBlaise Bourdin        call ISGetSize(cellIS, numCells,ierr);CHKERRA(ierr)
420*280aadf6SBlaise Bourdin        do cell = 1,numCells
421*280aadf6SBlaise Bourdin            call DMPlexVecGetClosure(dmS, PETSC_NULL_SECTION, S, cellID(cell), cval,ierr);CHKERRA(ierr)
422*280aadf6SBlaise Bourdin            call DMPlexVecGetClosure(dmS, coordSection, coord, cellID(cell), xyz,ierr);CHKERRA(ierr)
423*280aadf6SBlaise Bourdin            cval(1) = rank
424*280aadf6SBlaise Bourdin            cval(2) = csID(set)
425*280aadf6SBlaise Bourdin            cval(3) = 0.0_kPR
426*280aadf6SBlaise Bourdin            do c = 1, size(xyz),sdim
427*280aadf6SBlaise Bourdin                cval(3) = cval(3) + xyz(c)
428*280aadf6SBlaise Bourdin            end do
429*280aadf6SBlaise Bourdin            cval(3) = cval(3) * sdim / size(xyz)
430*280aadf6SBlaise Bourdin            call DMPlexVecSetClosure(dmS, PETSC_NULL_SECTION, S, cellID(cell), cval, INSERT_ALL_VALUES,ierr);CHKERRA(ierr)
431*280aadf6SBlaise Bourdin            call DMPlexVecRestoreClosure(dmS, PETSC_NULL_SECTION, S, cellID(cell), cval,ierr);CHKERRA(ierr)
432*280aadf6SBlaise Bourdin            call DMPlexVecRestoreClosure(dmS, coordSection, coord, cellID(cell), xyz,ierr);CHKERRA(ierr)
433*280aadf6SBlaise Bourdin        end do
434*280aadf6SBlaise Bourdin        call ISRestoreIndicesF90(cellIS, cellID,ierr);CHKERRA(ierr)
435*280aadf6SBlaise Bourdin        call ISDestroy(cellIS,ierr);CHKERRA(ierr)
436*280aadf6SBlaise Bourdin    end do
437*280aadf6SBlaise Bourdin    call ISRestoreIndicesF90(csIS, csID,ierr);CHKERRA(ierr)
438*280aadf6SBlaise Bourdin    call ISDestroy(csIS,ierr);CHKERRA(ierr)
439*280aadf6SBlaise Bourdin    call VecViewFromOptions(S, PETSC_NULL_OPTIONS, "-s_vec_view",ierr);CHKERRA(ierr)
440*280aadf6SBlaise Bourdin
441*280aadf6SBlaise Bourdin    ! Writing zonal variables in Exodus file
442*280aadf6SBlaise Bourdin    call DMSetOutputSequenceNumber(dmS,0_kPI,time,ierr);CHKERRA(ierr)
443*280aadf6SBlaise Bourdin    call VecView(S,viewer,ierr);CHKERRA(ierr)
444*280aadf6SBlaise Bourdin
445*280aadf6SBlaise Bourdin    ! Reading zonal variables in Exodus file */
446*280aadf6SBlaise Bourdin    call DMGetGlobalVector(dmS, tmpVec,ierr);CHKERRA(ierr)
447*280aadf6SBlaise Bourdin    call VecSet(tmpVec, -1000.0_kPR,ierr);CHKERRA(ierr)
448*280aadf6SBlaise Bourdin    call PetscObjectSetName(tmpVec, "Sigma",ierr);CHKERRA(ierr)
449*280aadf6SBlaise Bourdin    call VecLoad(tmpVec,viewer,ierr);CHKERRA(ierr)
450*280aadf6SBlaise Bourdin    call VecAXPY(S, -1.0_kPR, tmpVec,ierr);CHKERRA(ierr)
451*280aadf6SBlaise Bourdin    call VecNorm(S, NORM_INFINITY,norm,ierr);CHKERRQ(ierr)
452*280aadf6SBlaise Bourdin    if (norm > PETSC_SQRT_MACHINE_EPSILON) then
453*280aadf6SBlaise Bourdin       write(IOBuffer,'("Sigma ||Vin - Vout|| = ",ES12.5)') norm
454*280aadf6SBlaise Bourdin    end if
455*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmS, tmpVec,ierr);CHKERRA(ierr)
456*280aadf6SBlaise Bourdin
457*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmUA2, UA2,ierr);CHKERRA(ierr)
458*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmUA, UA,ierr);CHKERRA(ierr)
459*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmS,  S,ierr);CHKERRA(ierr)
460*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmA,  A,ierr);CHKERRA(ierr)
461*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dmU,  U,ierr);CHKERRA(ierr)
462*280aadf6SBlaise Bourdin    call DMRestoreGlobalVector(dm,   X,ierr);CHKERRA(ierr)
463*280aadf6SBlaise Bourdin    call DMDestroy(dmU,ierr);CHKERRA(ierr);
464*280aadf6SBlaise Bourdin    call ISDestroy(isU,ierr);CHKERRA(ierr)
465*280aadf6SBlaise Bourdin    call DMDestroy(dmA,ierr);CHKERRA(ierr);
466*280aadf6SBlaise Bourdin    call ISDestroy(isA,ierr);CHKERRA(ierr)
467*280aadf6SBlaise Bourdin    call DMDestroy(dmS,ierr);CHKERRA(ierr);
468*280aadf6SBlaise Bourdin    call ISDestroy(isS,ierr);CHKERRA(ierr)
469*280aadf6SBlaise Bourdin    call DMDestroy(dmUA,ierr);CHKERRA(ierr)
470*280aadf6SBlaise Bourdin    call ISDestroy(isUA,ierr);CHKERRA(ierr)
471*280aadf6SBlaise Bourdin    call DMDestroy(dmUA2,ierr);CHKERRA(ierr)
472*280aadf6SBlaise Bourdin    call DMDestroy(dm,ierr);CHKERRA(ierr)
473*280aadf6SBlaise Bourdin
474*280aadf6SBlaise Bourdin    deallocate(pStartDepth)
475*280aadf6SBlaise Bourdin    deallocate(pEndDepth)
476*280aadf6SBlaise Bourdin
477*280aadf6SBlaise Bourdin    call PetscViewerDestroy(viewer,ierr);CHKERRA(ierr)
478*280aadf6SBlaise Bourdin    call PetscFinalize(ierr)
479*280aadf6SBlaise Bourdinend program ex26f90
480*280aadf6SBlaise Bourdin
481*280aadf6SBlaise Bourdin! /*TEST
482*280aadf6SBlaise Bourdin!
483*280aadf6SBlaise Bourdin! build:
484*280aadf6SBlaise Bourdin!   requires: exodusii pnetcdf !complex
485*280aadf6SBlaise Bourdin!   # 2D seq
486*280aadf6SBlaise Bourdin! test:
487*280aadf6SBlaise Bourdin!   suffix: 0
488*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareT-large.exo -o FourSquareT-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
489*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
490*280aadf6SBlaise Bourdin! test:
491*280aadf6SBlaise Bourdin!   suffix: 1
492*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareQ-large.exo -o FourSquareQ-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
493*280aadf6SBlaise Bourdin!
494*280aadf6SBlaise Bourdin! test:
495*280aadf6SBlaise Bourdin!   suffix: 2
496*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareH-large.exo -o FourSquareH-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
497*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
498*280aadf6SBlaise Bourdin! test:
499*280aadf6SBlaise Bourdin!   suffix: 3
500*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareT-large.exo -o FourSquareT-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
501*280aadf6SBlaise Bourdin! test:
502*280aadf6SBlaise Bourdin!   suffix: 4
503*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareQ-large.exo -o FourSquareQ-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
504*280aadf6SBlaise Bourdin! test:
505*280aadf6SBlaise Bourdin!   suffix: 5
506*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareH-large.exo -o FourSquareH-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
507*280aadf6SBlaise Bourdin!   # 2D par
508*280aadf6SBlaise Bourdin! test:
509*280aadf6SBlaise Bourdin!   suffix: 6
510*280aadf6SBlaise Bourdin!   nsize: 2
511*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareT-large.exo -o FourSquareT-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
512*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
513*280aadf6SBlaise Bourdin! test:
514*280aadf6SBlaise Bourdin!   suffix: 7
515*280aadf6SBlaise Bourdin!   nsize: 2
516*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareQ-large.exo -o FourSquareQ-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
517*280aadf6SBlaise Bourdin! test:
518*280aadf6SBlaise Bourdin!   suffix: 8
519*280aadf6SBlaise Bourdin!   nsize: 2
520*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareH-large.exo -o FourSquareH-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
521*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: invalid dimension ID or name
522*280aadf6SBlaise Bourdin! test:
523*280aadf6SBlaise Bourdin!   suffix: 9
524*280aadf6SBlaise Bourdin!   nsize: 2
525*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareT-large.exo -o FourSquareT-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
526*280aadf6SBlaise Bourdin! test:
527*280aadf6SBlaise Bourdin!   suffix: 10
528*280aadf6SBlaise Bourdin!   nsize: 2
529*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareQ-large.exo -o FourSquareQ-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
530*280aadf6SBlaise Bourdin! test:
531*280aadf6SBlaise Bourdin!   # Something is now broken with parallel read/write for wahtever shape H is
532*280aadf6SBlaise Bourdin!   TODO: broken
533*280aadf6SBlaise Bourdin!   suffix: 11
534*280aadf6SBlaise Bourdin!   nsize: 2
535*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourSquareH-large.exo -o FourSquareH-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
536*280aadf6SBlaise Bourdin
537*280aadf6SBlaise Bourdin!   #3d seq
538*280aadf6SBlaise Bourdin! test:
539*280aadf6SBlaise Bourdin!   suffix: 12
540*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickHex-large.exo -o FourBrickHex-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
541*280aadf6SBlaise Bourdin! test:
542*280aadf6SBlaise Bourdin!   suffix: 13
543*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickTet-large.exo -o FourBrickTet-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
544*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
545*280aadf6SBlaise Bourdin! test:
546*280aadf6SBlaise Bourdin!   suffix: 14
547*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickHex-large.exo -o FourBrickHex-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
548*280aadf6SBlaise Bourdin! test:
549*280aadf6SBlaise Bourdin!   suffix: 15
550*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickTet-large.exo -o FourBrickTet-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
551*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
552*280aadf6SBlaise Bourdin!   #3d par
553*280aadf6SBlaise Bourdin! test:
554*280aadf6SBlaise Bourdin!   suffix: 16
555*280aadf6SBlaise Bourdin!   nsize: 2
556*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickHex-large.exo -o FourBrickHex-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
557*280aadf6SBlaise Bourdin! test:
558*280aadf6SBlaise Bourdin!   suffix: 17
559*280aadf6SBlaise Bourdin!   nsize: 2
560*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickTet-large.exo -o FourBrickTet-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 1
561*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
562*280aadf6SBlaise Bourdin! test:
563*280aadf6SBlaise Bourdin!   suffix: 18
564*280aadf6SBlaise Bourdin!   nsize: 2
565*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickHex-large.exo -o FourBrickHex-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
566*280aadf6SBlaise Bourdin! test:
567*280aadf6SBlaise Bourdin!   suffix: 19
568*280aadf6SBlaise Bourdin!   nsize: 2
569*280aadf6SBlaise Bourdin!   args: -i ${wPETSC_DIR}/share/petsc/datafiles/meshes/FourBrickTet-large.exo -o FourBrickTet-large_out.exo -dm_view -dm_section_view -petscpartitioner_type simple -order 2
570*280aadf6SBlaise Bourdin!   #TODO: bug in call to NetCDF failed to complete invalid type definition in file id 65536 NetCDF: One or more variable sizes violate format constraints
571*280aadf6SBlaise Bourdin! TEST*/
572