# use: gawk -f -v m=N1 -v n=N2 -v k=N3 -v shapes=corename -v mod={0|1} res.dat # where N1,N2,N3 are the dimensions in the MDD file # mod=0 (default) for real data in first shape # =1 for complex (alternating real and imaginary) # last modified, add new mdd file support. V. Orekhov 2005 May 31 BEGIN{ # N - offset, count in sets, 0 ... # 40 4928 56 80 if(n==0) {n=138*2; nn=138; m=52*96; k=72; } out=sprintf("%s.%%d",shapes); # out=sprintf("out%d_%d.%%d",rank,N); printf "N=%d m=%d n=%d k=%d\n",N,m,n,k; file1=sprintf( out,1); printf "" > file1; file2=sprintf( out,2); printf "" > file2; file3=sprintf( out,3); printf "" > file3; file4=sprintf( out,4); printf "" > file4; print file1,file2,file3,file4 new_mdd=0; ro=0;; } # detect new mdd format /^mdd/{new_mdd=1; ro=8;} (NR==ro-1){m=$1; n=$2; k= $3; printf "read from res.dat m=%d n=%d k=%d\n",m,n,k; } (NR>(N)*(n+m+k+1)+ro)&&(NR<=(N)*(n+m+k+1)+m+ro){ if ((mod==1 && (NR+ro)%2==1) || (mod==0)) {print $0 >> file1;} } (NR>(N)*(n+m+k+1)+m+ro)&&(NR<=(N)*(n+m+k+1)+n+m+ro){ print $0 >> file2;} (NR>(N)*(n+m+k+1)+n+m+ro)&&(NR<=(N)*(n+m+k+1)+n+m+k+ro){ print $0 >> file3;} (NR>(N)*(n+m+k+1)+n+m+k+ro)&&(NR<=(N)*(n+m+k+1)+n+m+k+1+ro)&&(new_mdd==0){ print $0 >> file4;} (NR==ro)&&(new_mdd==1){ print $0 >> file4;}