]> hackdaworld.org Git - physik/posic.git/commitdiff
multiple save files to get pc
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Sep 2008 10:34:32 +0000 (12:34 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Tue, 9 Sep 2008 10:34:32 +0000 (12:34 +0200)
pair_corr_calc_script
pair_correlation_calc.c

index 67ba32c68a8e47757982e99afaa49e6c38e803a1..8006e1f423bbd14104096f53860f6b18a83f9169 100755 (executable)
@@ -7,7 +7,7 @@
 
 do_it() {
        echo "processing $1 ..."
 
 do_it() {
        echo "processing $1 ..."
-       ./pair_correlation_calc $1 $2
+       ./pair_correlation_calc $2 $1
        trg=`echo $1 | sed 's%s-%pair_corr-%' | sed 's%.save%%'`
        mv pair_corr_func.txt $trg
        echo "done"
        trg=`echo $1 | sed 's%s-%pair_corr-%' | sed 's%.save%%'`
        mv pair_corr_func.txt $trg
        echo "done"
index efe81ad64b9f85c6bae270acc937a0cb6015496e..cfe14e27a456f0e1b4ba653596c02a1d974b71cc 100644 (file)
@@ -19,7 +19,7 @@
 int usage(char *prog) {
 
        printf("\nusage:\n");
 int usage(char *prog) {
 
        printf("\nusage:\n");
-       printf("  %s <save file> <dr>\n\n",prog);
+       printf("  %s <dr> <save file 1> [<save file 2> ...]\n\n",prog);
 
        return -1;
 }
 
        return -1;
 }
@@ -28,56 +28,77 @@ int main(int argc,char **argv) {
 
        t_moldyn moldyn;
        int ret;
 
        t_moldyn moldyn;
        int ret;
-       double *stat;
+       double *stat,*total;
        int slots;
        int slots;
-       int i;
+       int i,j;
        double dr;
        int fd;
        double dr;
        int fd;
+       unsigned char first;
 
 
-       if(argc!=3) {
+       if(argc<3) {
                usage(argv[0]);
                return -1;
        }
 
                usage(argv[0]);
                return -1;
        }
 
-       memset(&moldyn,0,sizeof(t_moldyn));
+       dr=atof(argv[1]);
 
 
-       printf("[pair corr calc] reading save file ...\n");
-       ret=moldyn_read_save_file(&moldyn,argv[1]);
-       if(ret) {
-               printf("[pair corr calc] exit!\n");
-               return ret;
-       }
+       first=1;
 
 
-       moldyn.cutoff*=2;
-       moldyn.cutoff_square*=4;
+       for(j=2;j<argc;j++) {
 
 
-       dr=atof(argv[2]);
-       slots=moldyn.cutoff/dr;
-       printf("[pair corr calc]\n");
-       printf("  slots: %d\n",slots);
-       printf("  cutoff: %f\n",moldyn.cutoff);
-       printf("  dr: %f\n",dr);
+               memset(&moldyn,0,sizeof(t_moldyn));
 
 
-       stat=(double *)malloc(3*slots*sizeof(double));
-       if(stat==NULL) {
-               perror("[pair corr calc] alloc mem");
-               return -1;
-       }
+               printf("[pair corr calc] reading save file ...\n");
+               ret=moldyn_read_save_file(&moldyn,argv[j]);
+               if(ret) {
+                       printf("[pair corr calc] exit!\n");
+                       return ret;
+               }
+
+               moldyn.cutoff*=2;
+               moldyn.cutoff_square*=4;
+
+               slots=moldyn.cutoff/dr;
+               printf("[pair corr calc]\n");
+               printf("  slots: %d\n",slots);
+               printf("  cutoff: %f\n",moldyn.cutoff);
+               printf("  dr: %f\n",dr);
 
 
-       /* link cell init */
-       link_cell_init(&moldyn,VERBOSE);
+               if(first) {
+                       stat=(double *)malloc(3*slots*sizeof(double));
+                       total=(double *)malloc(3*slots*sizeof(double));
+                       first=0;
+                       if(stat==NULL) {
+                               perror("[pair corr calc] alloc mem (stat)");
+                               return -1;
+                       }
+                       if(total==NULL) {
+                               perror("[pair corr calc] alloc mem (toal)");
+                               return -1;
+                       }
+                       memset(total,0,3*slots*sizeof(double));
+               }
 
 
-       calculate_pair_correlation(&moldyn,dr,stat);
+               /* link cell init */
+               link_cell_init(&moldyn,VERBOSE);
+
+               calculate_pair_correlation(&moldyn,dr,stat);
+
+               for(i=0;i<3*slots;i++)
+                       total[i]+=stat[i];
+
+       }
 
        fd=open("pair_corr_func.txt",
                O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
        dprintf(fd,"#r #ab #aa #bb\n");
        for(i=0;i<slots;i++)
                dprintf(fd,"%f %f %f %f\n",
 
        fd=open("pair_corr_func.txt",
                O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR);
        dprintf(fd,"#r #ab #aa #bb\n");
        for(i=0;i<slots;i++)
                dprintf(fd,"%f %f %f %f\n",
-                       i*dr,stat[i],stat[slots+i],stat[2*slots+i]);
+                       i*dr,total[i],total[slots+i],total[2*slots+i]);
        close(fd);
 
        free(stat);
        close(fd);
 
        free(stat);
+       free(total);
 
        moldyn_free_save_file(&moldyn);
 
 
        moldyn_free_save_file(&moldyn);