File: deriv.awk

package info (click to toggle)
getdp 3.0.4%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,856 kB
  • sloc: cpp: 63,020; fortran: 13,955; yacc: 9,350; f90: 1,640; lex: 799; makefile: 55; ansic: 34; awk: 33; sh: 23
file content (23 lines) | stat: -rw-r--r-- 394 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# the file should contain nbtimestep lines, and n results per line
# we compute (nbtimestep-1) time derivatives

BEGIN { 
    dt=1; 
    n=0; time=0;
}

{ 
    if(!time) n = $NF;
    for(j=0; j<n; j++) val[j,time] = $(j+1); 
    time++;
}

END { 
    for(i=1 ; i<time ; i++){
	printf("derivee = ");
	for(j=0 ; j<n ; j++){
	    printf("%g ", (val[j,i]-val[j,i-1])/dt);
	}
	printf("\n");
    }
}