source: CIVL/examples/contracts/contractsMPI/diffusion1dUpdate_assert_bad.c@ a389857

main test-branch
Last change on this file since a389857 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 840 bytes
Line 
1#include<mpi.h>
2#include<civlc.cvh>
3
4#pragma CIVL ACSL
5#define DATA_LIMIT 1024
6
7int nxl;
8double * u, * u_new, k;
9
10
11/*@ requires \valid(u + (0 .. (nxl + 1)));
12 @ requires \valid(u_new + (0 .. (nxl + 1)));
13 @ requires k > 0 && nxl > 0;
14 @ assigns u[1 .. nxl];
15 @ ensures \forall int i; 0< i && i <= nxl
16 @ ==>
17 @ u[i] == \old(u[i] + k*(u[i+1] + u[i-1] - 2*u[i]));
18 @*/
19void update() {
20 /*@ loop invariant 1 <= i && i <= nxl + 1;
21 @ loop invariant \forall int j; 1 <= j && j < i ==>
22 @ u_new[j] == u[j] + k*(u[j+1] + u[j-1] - 2*u[j]);
23 @*/
24 for (int i = 1; i <= nxl; i++)
25 u_new[i] = u[i] + k*(u[i+1] + u[i-1] - 2*u[i]);
26
27 double * tmp = u_new; u_new=u; u=tmp;
28
29#ifdef _CIVL
30 $assert($forall (int i : 1 .. nxl)
31 u[i] != u_new[i] + k*(u_new[i+1] + u_new[i-1] - 2*u_new[i])
32 );
33#endif
34}
Note: See TracBrowser for help on using the repository browser.