MOAB: Mesh Oriented datABase  (version 5.5.0)
ScdMeshF90.F90
Go to the documentation of this file.
1 ! MOAB structured mesh extension test
2 !
3 ! This test also tests fortran free-source format
4 !
5 
6 #define ERROR(rval) if (0 .ne. rval) call exit(1)
7 
8 real function reinterpret_ptr(xm, ni, nj, nk)
9 integer :: ni, nj, nk
10 real, dimension(ni, nj, nk) :: xm
11 
12 reinterpret_ptr = 0.0
13 do k = 1, nk
14  do j = 1, nj
15  do i = 1, ni
16  reinterpret_ptr = reinterpret_ptr + xm(i, j, k)
17  end do
18  end do
19 end do
20 end function reinterpret_ptr
21 
22 program scdmeshf90
23 implicit none
24 integer comm1, mysize,myproc,ier
25 #include "iMesh_f.h"
26 imesh_instance :: mesh
27 ibase_entitysethandle :: handle
28 ibase_entityhandle :: root_set
29 ibase_entityarriterator :: iter
30 ibase_taghandle :: tagh
31 integer :: local_dims(6),global_dims(6)
32 integer :: geom_dim, num_verts, count, i, num_quads, rsum
33 real xm
34 pointer(rpxm1, xm(*))
35 real reinterpret_ptr
36 
37 ! declarations
38 
39 ! create the Mesh instance
40 
41 local_dims(1)=0
42 local_dims(2)=0
43 local_dims(3)=-1
44 local_dims(4)=64
45 local_dims(5)=64
46 local_dims(6)=-1
47 
48 global_dims(1)=0
49 global_dims(2)=0
50 global_dims(3)=-1
51 global_dims(4)=64
52 global_dims(5)=64
53 global_dims(6)=-1
54 
55 call imesh_newmesh('MOAB', mesh, ier); error(ier);
56 
57 handle = 0
58 call imesh_createstructuredmesh(%VAL(mesh), local_dims, global_dims, %VAL(0),%VAL(0),%VAL(0), %VAL(1), %VAL(-1), &
59  %VAL(-1), %VAL(-1), %VAL(0), %VAL(1), %VAL(1), handle, ier); error(ier);
60 
61 call imesh_getrootset(%VAL(mesh), root_set, ier); error(ier);
62 
63 call imesh_getgeometricdimension(%VAL(mesh), geom_dim, ier); error(ier);
64 
65 call imesh_getnumoftype(%VAL(mesh), %VAL(root_set), %VAL(ibase_face), num_quads, ier); error(ier);
66 
67 call imesh_getnumoftype(%VAL(mesh), %VAL(root_set), %VAL(ibase_vertex), num_verts, ier); error(ier);
68 
69 call imesh_initentarriter(%VAL(mesh), %VAL(root_set), %VAL(ibase_face), %VAL(imesh_quadrilateral),%VAL(num_quads), &
70  %VAL(0), iter, ier); error(ier);
71 
72 call imesh_createtagwithoptions(%VAL(mesh), "XM1", "moab:TAG_STORAGE_TYPE=DENSE; moab:TAG_DEFAULT_VALUE=0.0", &
73  %VAL(5), %VAL(ibase_double), tagh, ier); error(ier);
74 
75 call imesh_tagiterate(%VAL(mesh), %VAL(tagh), %VAL(iter), rpxm1, count, ier); error(ier);
76 
77 call imesh_endentarriter(%VAL(mesh), %VAL(iter), ier); error(ier);
78 
79 do i = 1, 5*64*64
80  xm(i) = 1.0
81 end do
82 
83 rsum = reinterpret_ptr(xm, 5, 64, 64)
84 
85 call imesh_dtor(%VAL(mesh), ier); error(ier);
86 
87 if (rsum .ne. 5*64*64) call exit(1)
88 
89 call exit(0)
90 end