/****************************************************************/ /* splithmsc 19.06.2002 */ /****************************************************************/ /* Short Description : */ /* AU program to separate the 1J and nJ component of the */ /* HMSC experiment */ /****************************************************************/ /* Keywords : */ /* HMSC experiment */ /****************************************************************/ /* Description/Usage : */ /* The HMSC experiment records 1J+nJ and 1J-nJ interleaved */ /* in one experiment. */ /* The AU program splits and recombines the data into two */ /* separate datasets. The expno for the first dataset is */ /* requested by the AU program, the other datasets */ /* automatically uses the following expno. */ /* dataset 1 = + exp1 + exp2 */ /* dataset 2 = + exp1 - exp2 */ /****************************************************************/ /* Author(s) : */ /* Name : Wolfgang Bermel */ /* Organisation : Bruker Analytik */ /* Email : wolfgang.bermel@bruker.de */ /****************************************************************/ /* Name Date Modification: */ /* ber 020619 created */ /****************************************************************/ /* $Id: splithmsc,v 1.1.2.1 2002/07/02 12:01:01 rke Exp $ */ #include #include #define MAXSIZE 16384 char infile[PATH_MAX], outfile1[PATH_MAX], outfile2[PATH_MAX]; int row1[MAXSIZE], row2[MAXSIZE]; int rowout1[MAXSIZE], rowout2[MAXSIZE]; int td1, td2, td1s; int i, j; int nexpno, byteorder; FILE *fpin, *fpout1, *fpout2; GETCURDATA FETCHPARS ("BYTORDA",&byteorder) FETCHPARS("TD",&td2) td2 = ( (td2 + 255) / 256 ) * 256; FETCHPAR1("TD",&td1) FETCHPAR1S("TD",&td1s) (void)sprintf(infile,"%s/data/%s/nmr/%s/%d/ser",disk,user,name,expno); nexpno = expno + 10000; GETINT("First dataset to be stored in expno : ",nexpno); (void)sprintf(outfile1,"%s/data/%s/nmr/%s/%d/ser",disk,user,name,nexpno); (void)sprintf(outfile2,"%s/data/%s/nmr/%s/%d/ser",disk,user,name,nexpno+1); WRA(nexpno) WRA(nexpno+1) fpin=fopen(infile,"rb"); fpout1=fopen(outfile1,"wb"); fpout2=fopen(outfile2,"wb"); for (i=0; i < td1s/2; i++) { fread(row1,sizeof(int),td2,fpin); local_swap4(row1,sizeof(int)*td2,byteorder); fread(row2,sizeof(int),td2,fpin); local_swap4(row2,sizeof(int)*td2,byteorder); for (j=0; j < td2 ; j++) { rowout1[j] = + row1[j] + row2[j]; rowout2[j] = + row1[j] - row2[j]; } local_swap4(rowout1,sizeof(int)*td2,byteorder); fwrite(rowout1,sizeof(int),td2,fpout1); local_swap4(rowout2,sizeof(int)*td2,byteorder); fwrite(rowout2,sizeof(int),td2,fpout2); } fclose(fpin); fclose(fpout1); fclose(fpout2); td1 /= 2; td1s = (td1s / 2) ; DATASET (name,nexpno,procno,disk,user) STOREPAR1("TD",td1) STOREPAR1S("TD",td1s) DATASET (name,nexpno+1,procno,disk,user) STOREPAR1("TD",td1) STOREPAR1S("TD",td1s) QUIT