17 #include "moab/MOABConfig.h"
23 #error Specify MOAB_MESH_DIR path
26 integer ierr, num_procs, my_id
29 character :: appname*32
31 character :: fname*1024
33 integer ngv, nge, ndim, nparts
35 integer nverts(3), nelem(3), nblocks(3), nsbc(3), ndbc(3)
38 double precision dwork(100000)
48 character :: tagname1*128, tagname2*128
49 integer tagtype(2), enttype(2), num_co
53 integer era, beid, eid
55 integer vpere, nebl, blockid
59 integer egid, elid, eown
63 integer isbc, irbc, ivbc
65 character outfile*1024, wopts*1024
67 fname =
'unittest/io/p8ex1.h5m'//c_null_char
70 call mpi_init ( ierr )
71 call errorout(ierr,
'fail to initialize MPI')
75 call mpi_comm_rank (mpi_comm_world, my_id, ierr)
76 call errorout(ierr,
'fail to get MPI rank')
78 call mpi_comm_size (mpi_comm_world, num_procs, ierr)
79 call errorout(ierr,
'fail to get MPI size')
81 if (my_id .eq. 0)
then
82 print *,
" I'm process ", my_id,
" out of ", num_procs,
" processes."
86 ierr = imoab_initialize()
87 call errorout(ierr,
'fail to initialize iMOAB')
89 appname =
'PROTEUS'//c_null_char
97 ierr = imoab_registerapplication(appname, mpi_comm_world, compid, pid)
99 ierr = imoab_registerapplication(appname, compid, pid)
101 call errorout(ierr,
'fail to register application')
104 ierr = imoab_readheaderinfo(
filename, ngv, nge, ndim, nparts)
105 call errorout(ierr,
'fail to read header info')
108 print *,
filename,
' has ', nparts,
' parts in partition', ngv,
' vertices ', nge,
' elements of dimension ', ndim
112 readopts=
'PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;'// &
113 'PARALLEL_RESOLVE_SHARED_ENTS'//c_null_char
120 call errorout(ierr,
'fail to read file in parallel')
123 ierr = imoab_getmeshinfo(pid, nverts, nelem, nblocks, nsbc, ndbc)
124 call errorout(ierr,
'fail to get mesh info')
127 ierr = imoab_getvertexid(pid, nverts(3), iwork(vid) )
128 call errorout(ierr,
'failed to get vertex id info')
130 vra = vid + nverts(3)
131 ierr = imoab_getvertexownership(pid, nverts(3), iwork(vra) )
132 call errorout(ierr,
'failed to get vertex owner ranks')
134 ifree = vra + nverts(3)
140 ierr = imoab_getvisibleverticescoordinates(pid, nco, dwork(vco))
141 print *,
'nCO = ', nco
142 print *,
'ierr = ', ierr
143 call errorout(ierr,
'failed to get coordinates')
144 dfree = vco + 3 * nverts(3)
147 ierr = imoab_getblockid(pid, nblocks(3), iwork(bid))
148 call errorout(ierr,
'failed to get block info')
149 ifree = ifree + nblocks(3)
159 tagname1 =
'INTFIELD'//c_null_char
160 ierr = imoab_definetagstorage(pid, tagname1, tagtype(1), num_co, tagindex(1) )
161 call errorout(ierr,
'failed to get tag INTFIELD')
163 tagname2 =
'DFIELD'//c_null_char
164 ierr = imoab_definetagstorage(pid, tagname2, tagtype(2), num_co, tagindex(2) )
165 call errorout(ierr,
'failed to get tag DFIELD')
171 ierr = imoab_synchronizetags(pid, ntsync, tagindex, tagtype )
172 call errorout(ierr,
'failed to sync tag INTFIELD')
175 do irk=0, num_procs-1
176 if (irk .eq. my_id)
then
179 print *,
'on rank ', my_id,
' there are '
180 print *, nverts(3),
' visible vertices of which ',nverts(1),
' local ', nverts(2),
' ghost'
181 print *, nblocks(3),
' visible blocks'
182 print *, nsbc(3),
' visible Neumann BCs'
183 print *, ndbc(3),
' visible dirichlet BCs'
185 print *,
'on rank ', my_id,
' vertex info:'
187 write(*, 100) i, iwork(vra+i-1), iwork( vid+i-1), dwork(vco+3*i-3), dwork(vco+3*i-2), dwork(vco+3*i-1)
188 100
FORMAT(
' vertex local id ', i3,
' rank ID', i3,
' global ID:', i3,
' coords:', 3f11.3)
192 beid = eid + nelem(3)
193 era = beid + nelem(3)
194 ierr = imoab_getvisibleelementsinfo(pid, nelem(3),iwork(eid), iwork(era), iwork(beid) )
195 call errorout(ierr,
'failed to get all elem info')
196 ifree = era + nelem(3)
198 write(*, 101) iwork(eid+i-1), iwork(era+i-1), iwork(beid+i-1)
199 101
FORMAT(
' global ID ', i5,
' rank: ', i3,
' block ID: ', i4)
204 print *,
' block index:', i,
' block ID ', iwork(bid+i-1)
205 blockid = iwork(bid+i-1)
206 ierr = imoab_getblockinfo(pid, blockid , vpere, nebl)
207 call errorout(ierr,
'failed to elem block info')
208 print *,
' has' , nebl,
' elements with ', vpere,
'verts'
210 sizeconn = nebl * vpere
212 ierr = imoab_getblockelementconnectivities(pid, blockid, sizeconn, iwork(eco) )
214 call errorout(ierr,
'failed to get block elem connectivity')
216 ifree = ifree + sizeconn
218 ierr = imoab_getelementownership(pid, blockid, nebl, iwork(eown))
219 call errorout(ierr,
'failed to get block elem ownership')
224 ierr = imoab_getelementid(pid, blockid, nebl, iwork(egid), iwork(elid) )
225 call errorout(ierr,
'failed to get block elem IDs')
229 write (*, 102) j, iwork(eown+j-1),iwork(egid+j-1), iwork(elid+j-1), (iwork(eco-1+(j-1)*vpere+k), k=1,vpere)
230 102
FORMAT(
' elem ', i3,
' owned by', i3,
' gid:', i3,
' lid:', i3,
' : ', 10i5)
237 ierr = imoab_getinttagstorage(pid, tagname1, nverts(3), enttype(1), iwork(itag) )
238 call errorout(ierr,
'failed to get INTFIELD tag')
239 ifree = itag + nverts(3)
240 print * ,
'INTFIELD tag values'
241 write(*, 103) (iwork(itag+k-1), k=1,nverts(3) )
247 ierr = imoab_getdoubletagstorage(pid, tagname2, nelem(3), enttype(2), dwork(dtag) )
248 call errorout(ierr,
'failed to get DFIELD tag')
249 dfree = dtag + nelem(3)
250 print *,
'DFIELD tag values: (not exchanged) '
251 write (*, 104) (dwork(dtag+k-1), k=1,nelem(3) )
252 104
FORMAT ( 10f7.2 )
256 irbc = isbc + nsbc(3)
257 ivbc = irbc + nsbc(3)
259 ierr = imoab_getpointertosurfacebc(pid, nsbc(3), iwork(isbc),iwork(irbc), iwork(ivbc))
260 call errorout(ierr,
'failed to get surf boundary conditions')
261 ifree = ivbc + nsbc(3)
262 print * ,
'Surface boundary conditions '
263 write (*, 105) (iwork(isbc+k-1),iwork(irbc+k-1), iwork(ivbc+k-1), k=1, nsbc(3))
264 105
FORMAT (
' elem localID: ', i3,
' side:', i1,
' val:', i4)
268 ivabc = ivebc + ndbc(3)
270 ierr = imoab_getpointertovertexbc(pid, ndbc(3), iwork(ivebc),iwork(ivabc))
271 call errorout(ierr,
'failed to get vertex boundary conditions')
272 ifree = ivabc + ndbc(3)
274 print *,
' Vertex boundary conditions:'
275 write (*, 106) (iwork(ivebc+k-1),iwork(ivabc+k-1), k=1, ndbc(3))
276 106
FORMAT (
' vertex: ', i3,
' BC:', i6 )
281 call mpi_barrier(mpi_comm_world, ierr)
283 call errorout(ierr,
'fail at barrier')
286 outfile =
'fnew2.h5m'//c_null_char
288 wopts =
'PARALLEL=WRITE_PART'//c_null_char
294 ierr = imoab_writemesh(pid, outfile, wopts)
295 call errorout(ierr,
'fail to write the mesh file')
298 ierr = imoab_deregisterapplication(pid)
299 call errorout(ierr,
'fail to deregister application')
301 ierr = imoab_finalize()
302 call errorout(ierr,
'fail to finalize iMOAB')
305 call mpi_finalize ( ierr )
307 call errorout(ierr,
'fail to finalize MPI')