xref: /libCEED/tests/t102-vector.c (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1 /// @file
2 /// Test CeedVectorGetArrayRead state counter
3 /// \test Test CeedVectorGetArrayRead state counter
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed ceed;
8   CeedVector x;
9   CeedInt n;
10   const CeedScalar *a, *b;
11 
12   CeedInit(argv[1], &ceed);
13 
14   n = 10;
15   CeedVectorCreate(ceed, n, &x);
16   CeedVectorSetValue(x, 0.0);
17 
18   // Two read accesses should not generate an error
19   CeedVectorGetArrayRead(x, CEED_MEM_HOST, &a);
20   CeedVectorGetArrayRead(x, CEED_MEM_HOST, &b);
21 
22   CeedVectorRestoreArrayRead(x, &a);
23   CeedVectorRestoreArrayRead(x, &b);
24 
25   CeedVectorDestroy(&x);
26   CeedDestroy(&ceed);
27   return 0;
28 }
29