Cluster/unres modified to read MD coordinates in CX format, also from multiple files.
[unres.git] / source / cluster / unres / src / compinfo.c
1 #include <stdio.h>
2 #include <sys/utsname.h>
3 #include <sys/types.h>
4 #include <time.h>
5 #include <string.h>
6
7 main()
8 {
9 FILE *in, *in1, *out;
10 int i,j,k,iv1,iv2,iv3;
11 char *p1,buf[500],buf1[500],buf2[100],buf3[100];
12 struct utsname Name;
13 time_t Tp;
14
15 in=fopen("cinfo.f","r");
16 out=fopen("cinfo.f.new","w");
17 if (fgets(buf,498,in) != NULL)
18         fprintf(out,"C DO NOT EDIT THIS FILE - IT HAS BEEN GENERATED BY COMPINFO.C\n");
19 if (fgets(buf,498,in) != NULL)
20         sscanf(&buf[1],"%d %d %d",&iv1,&iv2,&iv3);
21 iv3++;
22 fprintf(out,"C %d %d %d\n",iv1,iv2,iv3);
23 fprintf(out,"      subroutine cinfo\n");
24 fprintf(out,"      include 'DIMENSIONS'\n");
25 fprintf(out,"      include 'COMMON.IOUNITS'\n");
26 fprintf(out,"      write(iout,*)'++++ Compile info ++++'\n");
27 fprintf(out,"      write(iout,*)'Version %d.%-d build %d'\n",iv1,iv2,iv3);
28 uname(&Name);
29 time(&Tp);
30 system("whoami > tmptmp");
31 in1=fopen("tmptmp","r");
32 if (fscanf(in1,"%s",buf1) != EOF)
33 {
34 p1=ctime(&Tp);
35 p1[strlen(p1)-1]='\0';
36 fprintf(out,"      write(iout,*)'compiled %s'\n",p1);
37 fprintf(out,"      write(iout,*)'compiled by %s@%s'\n",buf1,Name.nodename);
38 fprintf(out,"      write(iout,*)'OS name:    %s '\n",Name.sysname);
39 fprintf(out,"      write(iout,*)'OS release: %s '\n",Name.release);
40 fprintf(out,"      write(iout,*)'OS version:',\n");
41 fprintf(out,"     & ' %s '\n",Name.version);
42 fprintf(out,"      write(iout,*)'flags:'\n");
43 }
44 system("rm tmptmp");
45 fclose(in1);
46 in1=fopen("Makefile","r");
47 while(fgets(buf,498,in1) != NULL)
48  {
49  if((p1=strchr(buf,'=')) != NULL && buf[0] != '#')
50   {
51   buf[strlen(buf)-1]='\0';
52   if(strlen(buf) > 49)
53    {
54    buf[47]='\0';
55    strcat(buf,"...");
56    }
57   else
58    {
59    while(buf[strlen(buf)-1]=='\\')
60     {
61     strcat(buf,"\\");
62     fprintf(out,"      write(iout,*)'%s'\n",buf);
63     if (fgets(buf,498,in1) != NULL)
64         buf[strlen(buf)-1]='\0';
65     if(strlen(buf) > 49)
66      {
67      buf[47]='\0';
68      strcat(buf,"...");
69      }
70     }
71    }
72   
73   fprintf(out,"      write(iout,*)'%s'\n",buf);
74   }
75  }
76 fprintf(out,"      write(iout,*)'++++ End of compile info ++++'\n");
77 fprintf(out,"      return\n");
78 fprintf(out,"      end\n");
79 fclose(out);
80 fclose(in1);
81 fclose(in);
82 system("mv cinfo.f.new cinfo.f");
83 }