#include <stdio.h>
FILE *fp,*fp1,*fp2,*fp3;
char a[60],b[60],c[80],d=37;
main(int ac,char **av)
{
  if(ac<2){
  printf("\n\t\t ******** twokey *********\n");
  printf("\n\t  group_fits coordinating\n");
  printf("\n\t Usage: twokey !          101008\n\n");
  printf(" 1. automatic processing pipeline1 job, not answer any question.\n"); 
  printf("    should append to onekey. \n");
  printf(" 2. coord8  p*_? %c get each center, then maydo coord8 p*_? !\n",d);
  printf("            p*_? %c +n -n    n in arcmin, center adjust\n",d);
  printf("            p*_? %c +n -n 1  force display, then modify +n -n\n",d); 
  printf(" 3. coord84 p*     work out coord.cen (only one). using 2,3_pic\n");
  printf("                   fix center, coordinating by coord81\n");
  printf("               coord81 p*_? 3 (lookup matching) using coord.cen\n");
  printf(" 4. last, should run dirccdu to check if COORD not\n\n");
  exit(0);
  }
  job2();
  job3(); 
  system("dirccdu");
  printf("\n\t****** OK ! ********\n");
} 

job2()
{
  int i,j,k;
  system("ls p*.fit >1.1");
  fp=fopen("1.1","r");
l10:
  fgets(a,60,fp); if(feof(fp))goto l20;
  a[strlen(a)-5]=0;
  sprintf(c,"coord8 %s %c",a,d);
//    printf("%s\n",c);
  system(c); 
  goto l10;
l20:
  fclose(fp);
}

job3()
{
  int i,j,k;
  fp=fopen("1.1","r");
l10:
  fgets(a,60,fp); if(feof(fp))goto l20;
  a[strlen(a)-7]=0;
  k=strcmp(a,b);
  if(k){
    sprintf(c,"coord84 %s",a);
//      printf("%s\n",c);
    system(c); 
  }
  strcpy(b,a);
  goto l10;
l20:
  fclose(fp);
}
