int main(int argc, char *argv[])
{
  createinfo(argc, argv);
  
  int c;
  int cm=1;
  int deformation=0;

  if (argc < 3) {
    fprintf(stderr, "\nusage: %s interaction slaterdetfile\n",
	    argv[0]);
    exit(-1);
  }
  
  char* interactionfile = argv[optind];
  char* slaterdetfile = argv[optind+1];

  Interaction Int;
  readInteractionfromFile(&Int, interactionfile);
  Int.cm = cm;

  SlaterDet Q;
  readSlaterDetfromFile(&Q, slaterdetfile);

  Observables Obs;

  calcObservables(&Int, &Q, &Obs);

  fprintinfo(stdout);
  fprintObservables(stdout, &Int, &Q, &Obs);

  return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    printinfo("3\n");

    fprintinfo(stderr, "3\n");

    return EXIT_SUCCESS;
}
void FORTRAN(egradf)(const double* x, double* gradf)
{
#ifndef MPI
  if (sigterminate)
    longjmp(env, 1);
#endif

  copyxtopara(x, Min.q);
  Min.P->ParatoSlaterDet(Min.q, Min.Q);

  // nail to center-of-mass
  moveboostSlaterDet(Min.Q, Work.X);

  double eintr, eproj;

  calcgradprojectedHamiltonian(Min.Q,
			       Min.Int,
			       Min.j, Min.par, Min.ival, 
                               Min.angpara, Min.cmpara,
			       &eintr, &eproj);

  // add gradient from intrinsic energy

  calcSlaterDetAux(Min.Q, Work.X);
  calcgradSlaterDetAux(Min.Q, Work.X, Work.dX);
  calcgradHamiltonian(Min.Int, Min.Q, Work.X, Work.dX, Work.dH);

  addmulttogradSlaterDet(Work.dhproj, Work.dH, Min.alpha);

  Min.P->ParaprojectgradSlaterDet(Min.q, Work.dhproj, gradf);
  FORTRAN(o8cnt).icgf++;
  fprintf(stderr, "grad %3d: \tE = %8.3f MeV, Eproj = %8.3f MeV, Eintr = %8.3f MeV\n", 
	  FORTRAN(o8cnt).icgf, hbc*(eproj+Min.alpha*eintr), hbc*eproj, hbc*eintr);


  if (Min.log && !(FORTRAN(o8cnt).icgf % Min.log)) {
    char logfname[255];
    sprintf(logfname, "%s.minvapp.%03d.log", Min.logfile, FORTRAN(o8cnt).icgf);
    FILE* logfp;
    if (!(logfp = fopen(logfname, "w"))) {
      fprintf(stderr, "couldn't open %s for writing\n", logfname);
    } else {
      fprintinfo(logfp);
      fprintf(logfp, "# step %3d: \tE = %8.3f MeV, Eproj = %8.3f MeV, Eintr = %8.3f MeV\n", 
	      FORTRAN(o8cnt).icgf, hbc*(eproj+Min.alpha*eintr), hbc*eproj, hbc*eintr);
      fprintf(logfp, "\n# Parameterization\n");
      fprintf(logfp, "<Parameterization %s>\n", Min.P->name);
      Min.P->Parawrite(logfp, Min.q);
      fprintf(logfp, "\n# SlaterDet\n");
      writeSlaterDet(logfp, Min.Q);
      fclose(logfp);
    }
  }  

}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    int fd = 0;
    int retcode = 0;
    void *addr = NULL;
    struct stat st = {0};

    printinfo("open filename: %s\n", MMAP_FILE);
    fd = open(MMAP_FILE, O_RDWR);
    if (fd < 0)
    {
        fprintinfo(stderr, "open %s file failure\n", MMAP_FILE);
        return EXIT_FAILURE;
    }
    printinfo("open filename: %s, fd = %d\n", MMAP_FILE, fd);
/*
    printinfo("stat filename: %s\n", MMAP_FILE);
    retcode = stat(MMAP_FILE, &st);
    if (retcode != 0)
    {
        fprintinfo(stderr, "get %s file stat failure\n", MMAP_FILE);
        return EXIT_FAILURE;
    }

    printinfo("blocksize = %ld, total size = %ld, protection = %d\n", st.st_blksize, st.st_size, st.st_mode);
*/
    printinfo("mmap fd: %d, size = %ld, attribute: (prot = %d, shared = %d)\n", fd, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE);
    addr = mmap(NULL, 10, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
    if (addr == NULL)
    {
        fprintinfo(stderr, "");
    }

    printinfo("addr = %p\n", addr);

    strcpy(addr, "private");

    printinfo("write info : %s\n", addr);

    return EXIT_SUCCESS;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    int retcode = 0 ;
//    pthread_mutexattr_t attr;
    pthread_mutex_t *addr = NULL;

    addr = mapaddr_init(sizeof(*addr), MAP_PROCESS_SHARED);
    if (addr == NULL)
    {
        printinfo("get thread mutex space failure\n");
        return EXIT_FAILURE;
    }
/*
    pthread_mutexattr_init(&attr);
    pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);

    pthread_mutex_init(addr, &attr);
*/
    retcode = pthread_mutex_lock(addr);
    if (retcode != 0)
    {
        fprintinfo(stderr, "thread mutex failure retcode = %d\n", retcode);
        return EXIT_FAILURE;
    }

    printinfo("current process pid = %d\n", getpid());
    sleep(1);

    pthread_mutex_unlock(addr);

//    pthread_mutex_destroy(addr);

    mapaddr_destroy(addr, sizeof(*addr));

    return EXIT_SUCCESS;
}
int main(int argc, char *argv[])
{
  createinfo(argc, argv);

#ifdef MPI
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &mpirank);
  MPI_Comm_size(MPI_COMM_WORLD, &mpisize);

  // fprintf(stderr, "... [%2d] %s\n", mpirank, hostname());

  if (mpirank != 0) {
    MinimizerSlave();
    MPI_Finalize();
    exit(0);
  } else {
#endif

  int c;
  int cm=1;
  int overwrite=0;
  int maxsteps=250;
  int log=0;
  double shakemag=0.0;
  int constcm=0, constT2=0, constS2=0, constL2=0, constLS=0, constJ2=0;
  int constj2=0;
  int constnosci=0;
  int constmradius=0, constmquadrupole=0, constmoctupole=0;
  int consteradius=0, constedipole=0, constequadrupole=0, consteoctupole=0;
  int constnradius=0, constnquadrupole=0, constnoctupole=0;
  int constdquadrupole=0;
  int constbeta=0, constgamma=0;
  double constT2val=0.0, constS2val=0.0;
  double constL2val=0.0, constLSval=0.0, constJ2val=0.0;
  double constj2val=0.0;
  double constnoscival=0.0;
  double constmrval=0.0, constmqval=0.0, constmoval=0.0;
  double consterval=0.0, constedval=0.0, consteqval=0.0, consteoval=0.0;
  double constnrval=0.0, constnqval=0.0, constnoval=0.0;
  double constbval=0.0, constgval=0.0;
  double constdqval = 0.0;
  

  Constraint Const[MAXCONSTRAINT];
  int nconst = 0;

  if (argc < 3) {
    fprintf(stderr, "\nusage: %s interaction slaterdetfile\n"
	    "\n   -o              overwrite in all cases"
	    "\n   -l EVERY        log EVERY step"
	    "\n   -m MAXSTEPS     maximum number of steps (default %d)"
	    "\n   -s MAGNITUDE    shake parameters before minimization"
	    "\n   -C              constrain center of mass"
	    "\n   -T T2		  constrain T2"
	    "\n   -S S2           constrain S2"
	    "\n   -L LS           constrain LS"
	    "\n   -J J2           constrain J2"
	    "\n   -j j2           constrain single-particle angular momentum"
	    "\n   -N NOSCI        constrain number of oscillator quanta"
	    "\n   -R RADIUS       constrain radius"
	    "\n   -D DIPOLE       constrain dipole moments"
	    "\n   -Q QUADRUPOLE   constrain quadrupole moments"
	    "\n   -O OCTUPOLE     constrain octupole moments"
	    "\n   -B BETA         constrain quadrupole deformation"
	    "\n   -G GAMMA        constrain quadrupole deformation\n"
	    // "\n   -M              constrain main axes of quadrupole tensor"
	    // "\n   -I Jz           cranking constrain"
	    , argv[0], maxsteps);
    cleanup(-1);
  }
  
  while((c = getopt(argc, argv, "ol:m:s:CT:L:S:J:j:N:R:D:Q:O:B:G:")) != -1)
    switch (c) {
    case 'o':
      overwrite = 1;
      break;
    case 'l':
      log = atoi(optarg);
      break;
    case 'm':
      maxsteps = atoi(optarg);
      break;
    case 's':
      shakemag = atof(optarg);
      break;
    case 'C':
      constcm = 1;
      break;
    case 'T':
      constT2 = 1;
      constT2val = atof(optarg);
      break;
    case 'L':
      constLS = 1;
      constLSval = atof(optarg);
      break;
    case 'S':
      constS2 = 1;
      constS2val = atof(optarg);
      break;
    case 'J':
      constJ2 = 1;
      constJ2val = atof(optarg);
      break;
    case 'j':
      constj2 = 1;
      constj2val = atof(optarg);
      break;
    case 'N':
      constnosci = 1;
      constnoscival = atof(optarg);
      break;
    case 'R':
      if (optarg[0] == 'E') {
	consteradius = 1;
	consterval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
	constnradius = 1;
	constnrval = atof(optarg+2);
      } else {
	constmradius = 1;
	constmrval = atof(optarg);
      }
      break;
    case 'D':
      constedipole = 1;
      constedval = atof(optarg);
      break;
    case 'Q':
      if (optarg[0] == 'E') {
	constequadrupole = 1;
	consteqval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
        constnquadrupole = 1;
        constnqval = atof(optarg+2);
      } else if (optarg[0] == 'D') {
        constdquadrupole = 1;
        constdqval = atof(optarg+2);
      } else {
	constmquadrupole = 1;
	constmqval = atof(optarg);
      }
      break;
    case 'O':
      if (optarg[0] == 'E') {
	consteoctupole = 1;
	consteoval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
	constnoctupole = 1;
	constnoval = atof(optarg+2);
      } else {
	constmoctupole = 1;
	constmoval = atof(optarg);
      }
      break;
    case 'B':
      constbeta = 1;
      constbval = atof(optarg);
      break;
    case 'G':
      constgamma = 1;
      constgval = atof(optarg);
      break;
    }
  
  if (constcm) {
    Const[nconst] = ConstraintCM;
    nconst++;
    // Const[nconst  ] = ConstraintX;
    // Const[nconst+1] = ConstraintY;
    // Const[nconst+2] = ConstraintZ;
    // Const[nconst+3] = ConstraintPX;
    // Const[nconst+4] = ConstraintPY;
    // Const[nconst+5] = ConstraintPZ;
    // nconst += 6;
  }
  if (constT2) {
    Const[nconst] = ConstraintT2;
    Const[nconst].val = constT2val;
    nconst++;
  }
  if (constS2) {
    Const[nconst] = ConstraintS2;
    Const[nconst].val = constS2val;
    nconst++;
  }
/*   if (constL2) { */
/*     Const[nconst] = ConstraintL2; */
/*     Const[nconst].val = constL2val; */
/*     nconst++; */
/*   } */
  if (constLS) { 
    Const[nconst] = ConstraintLS;
    Const[nconst].val = constLSval;
    nconst++;
  }
  if (constJ2) {
    Const[nconst] = ConstraintJ2;
    Const[nconst].val = constJ2val;
    nconst++;
  }
  if (constj2) {
    Const[nconst] = ConstraintJ2;
    Const[nconst].val = constj2val;
    nconst++;
  }
  if (constnosci) {
    Const[nconst] = ConstraintNOsci;
    Const[nconst].val = SQR(constnoscival);
    nconst++;
  }
  if (constmradius) {
    Const[nconst] = ConstraintR2;
    Const[nconst].val = SQR(constmrval);
    nconst++;
  }
  if (consteradius) {
    Const[nconst] = ConstraintER2;
    Const[nconst].val = SQR(consterval);
    nconst++;
  }
  if (constnradius) {
    Const[nconst] = ConstraintNR2;
    Const[nconst].val = SQR(constnrval);
    nconst++;
  }
  if (constedipole) {
    Const[nconst] = ConstraintED2;
    Const[nconst].val = constedval;
    nconst++;
  }
  if (constmquadrupole) {
    Const[nconst] = ConstraintQ2;
    Const[nconst].val = constmqval;
    nconst++;
  }
  if (constequadrupole) {
    Const[nconst] = ConstraintEQ2;
    Const[nconst].val = consteqval;
    nconst++;
  }
  if (constnquadrupole) {
    Const[nconst] = ConstraintNQ2;
    Const[nconst].val = constnqval;
    nconst++;
  }
   if (constdquadrupole) {
   Const[nconst] = ConstraintDetQ;
   Const[nconst].val = constdqval;
    nconst++;
    // ConstraintQuadrupole q;
    //  fprintf(stderr, "The quadrupole tensor is: %f\n", q[i]);
  }
  if (constmoctupole) {
    Const[nconst] = ConstraintO2;
    Const[nconst].val = constmoval;
    nconst++;
  }
  if (consteoctupole) {
    Const[nconst] = ConstraintEO2;
    Const[nconst].val = consteoval;
    nconst++;
  }
  if (constnoctupole) {
    Const[nconst] = ConstraintNO2;
    Const[nconst].val = constnoval;
    nconst++;
  }
  if (constbeta) {
    Const[nconst] = ConstraintQ2;
    Const[nconst].val = sqrt(24*M_PI/5)*constbval;
    nconst++;
  }
  if (constgamma) {
    if (!constbeta) {
      fprintf(stderr, "gamma constraint only in combination with beta constraint\n");
      exit(-1);
    }
    Const[nconst] = ConstraintDetQ;
    Const[nconst].val = sqrt(4*M_PI/5)*constbval*cbrt(2*cos(3*constgval*M_PI/180));
    nconst++;
  }

  char* interactionfile = argv[optind];
  char* parafile = argv[optind+1];

  Interaction Int;
  if (readInteractionfromFile(&Int, interactionfile))
    cleanup(-1);
  Int.cm = cm;

  Parameterization P;
  Para qinitial;
  if (readParafromFile(&P, &qinitial, parafile))
    cleanup(-1);

  SlaterDet Q;
  SlaterDetAux X;

  P.ParainitSlaterDet(&qinitial, &Q);
  initSlaterDetAux(&Q, &X);
  P.ParatoSlaterDet(&qinitial, &Q);

#ifdef MPI
  int task=TASKSTART;
  BroadcastTask(&task);

  BroadcastInteraction(&Int);
  BroadcastA(&Q.A);
#endif

  calcSlaterDetAux(&Q, &X);
  double einitial;
  calcHamiltonian(&Int, &Q, &X, &einitial); 

  int i;
  for (i=0; i<nconst; i++)
    fprintf(stderr, "# constraining %4s to %8.3f\n", 
	    Const[i].label, Const[i].output(Const[i].val)); 

  fprintf(stderr, "\ninitial:\tE = %8.3f MeV\n\n", hbc*einitial);


  Para q;
  P.Paraclone(&qinitial, &q);

  // shaking the parameters ?
  if (shakemag)
    shakePara(&q, shakemag);

  // in FMD parameterization move SlaterDet to origin in phase space
  if (!strcmp(P.name, "FMD")) {
    P.ParatoSlaterDet(&q, &Q);
    moveboostorientSlaterDet(&Q, &X);
    SlaterDetinitFMD(&Q, &q);
  }

  // minimize !
  MinimizeDONLP2(&Int, Const, nconst, &P, &q, maxsteps, log, parafile); 

  double e;
  P.ParatoSlaterDet(&q, &Q);

  calcSlaterDetAux(&Q, &X);
  calcHamiltonian(&Int, &Q, &X, &e);

  fprintf(stderr, "\nfinal:  \tE = %8.3f MeV\n\n", hbc*e);

  // output files

  // backup of parafile

  backup(parafile);

  // save minimization result in MIN directory
  {
    P.ParatoSlaterDet(&q, &Q);

    // orient SlaterDet
    moveboostorientSlaterDet(&Q, &X);

    // normalize SlaterDet
    normalizeSlaterDet(&Q, &X);

    // in FMD parameterization we copy the relocated SlaterDet
    if (!strcmp(P.name, "FMD"))
      SlaterDetinitFMD(&Q, &q);

    // calculate the observables
    Observables Obs;
  
    calcObservables(&Int, &Q, &Obs);

    ensuredir("MIN");
    char outfile[1024];
    sprintf(outfile, "MIN/%s-min.%d", parafile, (int) time(NULL));

    fprintf(stderr, "... writing Parameters to file %s\n", outfile);

    FILE* outfp;
    if (!(outfp = fopen(outfile, "w"))) {
      fprintf(stderr, "couldn't open %s for writing\n", outfile);
      cleanup(-1);
    }

    fprintinfo(outfp);

    fprintf(outfp, "\n# minimized %s for %s in %s parameterization\n"
            "# using %s interaction\n", 
            cm ? "< Hintr >" : "< H >", q.name, P.name, Int.name);
  
    fprintf(outfp, "# einitial: %8.3f MeV\n", hbc*einitial);
    fprintf(outfp, "# efinal:   %8.3f MeV\n", hbc*e);

    fprintObservables(outfp, &Int, &Q, &Obs);

    fprintf(outfp, "\n# Parameterization\n");
    fprintf(outfp, "<Parameterization %s>\n", P.name);
    P.Parawrite(outfp, &q);
 
    fprintf(outfp, "\n# SlaterDet\n");
    writeSlaterDet(outfp, &Q);

    fclose(outfp);  
  }

  // save minimization result in parafile
  {
    // no improvement ? then write initial parameters
    if (!overwrite && einitial < e) 
      P.Paraclone(&qinitial, &q);

    P.ParatoSlaterDet(&q, &Q);

    // orient SlaterDet
    moveboostorientSlaterDet(&Q, &X);

    // normalize SlaterDet
    normalizeSlaterDet(&Q, &X);

    // in FMD parameterization we copy the relocated SlaterDet
    if (!strcmp(P.name, "FMD"))
      SlaterDetinitFMD(&Q, &q);

    // calculate the observables
    Observables Obs;
  
    calcObservables(&Int, &Q, &Obs);

    fprintf(stderr, "... writing Parameters to file %s\n", parafile);

    FILE* outfp;
    if (!(outfp = fopen(parafile, "w"))) {
      fprintf(stderr, "couldn't open %s for writing\n", parafile);
      cleanup(-1);
    }

    fprintinfo(outfp);

    fprintf(outfp, "\n# minimized %s for %s in %s parameterization\n"
            "# using %s interaction\n", 
            cm ? "< Hintr >" : "< H >", q.name, P.name, Int.name);
  
    fprintf(outfp, "\n# einitial: %8.3f MeV\n", hbc*einitial);
    fprintf(outfp, "# efinal:   %8.3f MeV\n", hbc*e);

    if (overwrite)
      fprintf(outfp, "\n# overwrite flag: use new parameters\n\n");
    if (!overwrite && einitial < e)
      fprintf(outfp, "\n# no improvement by minimization: use initial parameters\n\n");

    fprintObservables(outfp, &Int, &Q, &Obs);

    fprintf(outfp, "\n# Parameterization\n");
    fprintf(outfp, "<Parameterization %s>\n", P.name);
    P.Parawrite(outfp, &q);
 
    fprintf(outfp, "\n# SlaterDet\n");
    writeSlaterDet(outfp, &Q);

    fclose(outfp);  
  }

  fprintf(stderr, "... %4.2f minutes computing time used\n", usertime()/60.0);

  cleanup(0);

#ifdef MPI
  }
#endif
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstate"
	    "\n   -A             show all eigenstates\n", argv[0]);
    exit(-1);
  }

  int all=0;
  int hermit=0;

  char c;

  /* manage command-line options */

  while ((c = getopt(argc, argv, "A")) != -1)
    switch (c) {
    case 'A':
      all=1;
      break;
    }

  char* mcstatefile = argv[optind];
  char** mbfile;

  // open multiconfigfile
  Projection P;
  SlaterDet* Q;
  Symmetry* S;
  Eigenstates E;
  int n;

  readMulticonfigfile(mcstatefile, &mbfile, &P, &Q, &S, &E, &n);

  void* radiime[n*n]; 

  int a,b;
  for (b=0; b<n; b++)	
    for (a=0; a<n; a++) {
      radiime[a+b*n] = initprojectedMBME(&P, &OpSDRadii);
    }

  // read or calculate matrix elements
  for (b=0; b<n; b++)
    for (a=0; a<n; a++) {
      if (readprojectedMBMEfromFile(mbfile[a], mbfile[b], &P, 
				    &OpSDRadii, S[a], S[b], 
				    radiime[a+b*n])) {
	calcprojectedMBME(&P, &OpSDRadii, &Q[a], &Q[b], 
			  S[a], S[b], radiime[a+b*n]);
	writeprojectedMBMEtoFile(mbfile[a], mbfile[b], &P, 
				 &OpSDRadii, S[a], S[b], 
				 radiime[a+b*n]);
      }
    }


  if (hermit) {
    hermitizeprojectedMBME(&P, &OpSDRadii, radiime, n);
  }

  fprintf(stderr, "calculate expectation values\n");

  // calculate expectation values
  void* radiiexp = initprojectedVector(&P, &OpSDRadii, n);
  calcexpectprojectedMBME(&P, &OpSDRadii, radiime, S, &E, radiiexp);


  // output

  char outfile[255];
  char tostrip[255];
  FILE* outfp;

  snprintf(tostrip, 255, ".states");
  snprintf(outfile, 255, "%s.radii", stripstr(mcstatefile, tostrip));
  if (!(outfp = fopen(outfile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", outfile);
    goto cleanup;
  }

  fprintinfo(outfp);
  fprintProjectinfo(outfp, &P);

  writeprojectedSDRadii(outfp, Q, &P, radiiexp, &E);

  fclose(outfp);

 cleanup:

  return 0;
}
int main(int argc, char* argv[])
{
  createinfo(argc, argv);

  /* enough arguments ? */

  if (argc < 2) {
    fprintf(stderr, "\nusage: %s [OPTIONS] mcstatefin mcstateini"
	    "\n   -a             show all eigenstates\n", argv[0]);
    exit(-1);
  }

  int all=0;
  int hermit=0;

  char c;

  /* manage command-line options */

  while ((c = getopt(argc, argv, "a")) != -1)
    switch (c) {
    case 'a':
      all=1;
      break;
    }

  char* mcstatefilefin = argv[optind];
  char* mcstatefileini = argv[optind+1];
  char** mbfilefin; char** mbfileini;

  // open multiconfigfile
  Projection P;
  SlaterDet *Qfin, *Qini;
  Symmetry *Sfin, *Sini;
  Eigenstates Efin, Eini;
  int nfin, nini;

  readMulticonfigfile(mcstatefileini, &mbfileini, &P, &Qini, &Sini, &Eini, &nini);
  readMulticonfigfile(mcstatefilefin, &mbfilefin, &P, &Qfin, &Sfin, &Efin, &nfin);

  int direction;
  if (Qfin[0].Z - Qini[0].Z == 1) {
    fprintf(stderr, "GT+ transitions");
    direction = +1;
  }
  if (Qfin[0].Z - Qini[0].Z == -1) {
    fprintf(stderr, "GT- transitions");
    direction = -1;
  }

 
  ManyBodyOperator OpGT;

  if (direction == +1)
    OpGT = OpGTplus;
  if (direction == -1)
    OpGT = OpGTminus;


  int a,b; 

  void** gtme[nfin*nini];

  for (b=0; b<nini; b++)	
    for (a=0; a<nfin; a++)
      gtme[a+b*nfin] = initprojectedMBME(&P, &OpGT);


  // read or calculate matrix elements
  for (b=0; b<nini; b++)
    for (a=0; a<nfin; a++)
      if (readprojectedMBMEfromFile(mbfilefin[a], mbfileini[b], &P,
                                    &OpGT, Sfin[a], Sini[b], gtme[a+b*nfin])) {
	calcprojectedMBME(&P, &OpGT, &Qfin[a], &Qini[b], Sfin[a], Sini[b],
                          gtme[a+b*nfin]);
        writeprojectedMBMEtoFile(mbfilefin[a], mbfileini[b], &P,
                                 &OpGT, Sfin[a], Sini[b], gtme[a+b*nfin]);
      } 
  
  fprintf(stderr, "calculate transition strengths\n");

  void**** gttrans = initprojectedtransitionVector(&P, &OpGT, nfin, nini);
  calctransitionprojectedMBME(&P, &OpGT, gtme, Sfin, Sini, &Efin, &Eini, gttrans);

  // output

  char outfile[511];
  char tostrip[255];
  FILE* outfp;

  snprintf(tostrip, 255, ".states");
  snprintf(outfile, 255, "%s--%s.transgt", 
           stripstr(mcstatefilefin, tostrip), stripstr(mcstatefileini, tostrip));
  if (!(outfp = fopen(outfile, "w"))) {
    fprintf(stderr, "couldn't open %s for writing\n", outfile);
    goto cleanup;
  }

  fprintinfo(outfp);
  fprintProjectinfo(outfp, &P);

  if (direction == +1)
    writeprojectedtransitionGTplus(outfp, &P, gttrans, &Efin, &Eini);
  else
    writeprojectedtransitionGTminus(outfp, &P, gttrans, &Efin, &Eini);

  fclose(outfp);

 cleanup:

  return 0;
}
int main(int argc, char *argv[])
{
  createinfo(argc, argv);

#ifdef MPI
  MPI_Init(&argc, &argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &mpirank);
  MPI_Comm_size(MPI_COMM_WORLD, &mpisize);

  // fprintf(stderr, "... [%2d] %s\n", mpirank, hostname());

  if (mpirank != 0) {
    MinimizerprojSlave();

    MPI_Finalize();
  } else {
#endif

  int c;
  int cm=0;
  int ival=-1;
  int j=0;
  int par=0;
  double threshkmix=0.1;
  double minnormkmix=0.01;
  double alpha=0.1;
  int overwrite=0;
  int log=0;
  int maxsteps=250;
  double shakemag=0.0;
  int constcm=1, constT2=0, constS2=0, constL2=0, constLS=0, constJ2=0;
  int constj2=0;
  int constnosci=0, constpnosci=0, constnnosci=0;
  int constbeta=0, constgamma=0;
  int constmradius=0, constmquadrupole=0, constmoctupole=0;
  int consteradius=0, constedipole=0, constequadrupole=0, consteoctupole=0;
  int constnradius=0, constnquadrupole=0, constnoctupole=0;
  int constparp=0, constparn=0, constparch=0, constd3h=0, constsxz=0, constsyz=0;
  double constT2val=0.0, constS2val=0.0;
  double constL2val=0.0, constLSval=0.0, constJ2val=0.0;
  double constj2val=0.0;
  double constnoscival=0.0, constpnoscival=0.0, constnnoscival=0.0;
  double constmrval=0.0, constmqval=0.0, constmoval=0.0;
  double constbval=0.0, constgval=0.0;
  double consterval=0.0, constedval=0.0, consteqval=0.0, consteoval=0.0;
  double constnrval=0.0, constnqval=0.0, constnoval=0.0;

  Constraint Const[MAXCONSTRAINT];
  int nconst = 0;

  if (argc < 5) {
    fprintf(stderr, "\nusage: %s PROJPARA interaction slaterdetfile\n"
            "\n   -i I            optimize Ith eigenvalue"
	    "\n   -j J            project onto angular momentum"
	    "\n   -p[+1|-1]       project onto parity"
            "\n   -t THRESH       K-mixing threshold"
            "\n   -n NORM         minimal norm for K-mixing eigenstates"
            "\n   -a ALPHA        minimize (eproj + ALPHA eintr)"
	    "\n   -l EVERY        log EVERY step"
	    "\n   -o              overwrite in all cases"
	    "\n   -m MAXSTEPS     maximum number of steps (default %d)"
	    "\n   -s MAGNITUDE    shake parameters before minimization"
	    "\n   -T T2           constrain isospin"
	    "\n   -L l2           constrain single-particle l2"
	    "\n   -S ls           constrain single-particle ls"
	    "\n   -J J2           constrain angular momentum"
	    "\n   -j j2           constrain single-particle angular momentum"
	    "\n   -N NOSCI        constrain number of oscillator quanta"
	    "\n   -R RADIUS       constrain radius"
	    "\n   -D DIPOLE       constrain dipole moments"
	    "\n   -Q QUADRUPOLE   constrain quadrupole moments"
	    "\n   -O OCTUPOLE     constrain octupole moments"
            "\n   -P[+1|-1]       constrain parity of intrinsic state"
            "\n   -C              constrain on symmetry under parity and charge"
            "\n   -V [xz|yz]      constrain reflection symmetry of intrinsic state"
            "\n   -3              constrain intrinsic state to d3h symmetry\n"
	    // "\n   -I Jz           cranking constrain"
	    , argv[0], maxsteps);
    cleanup(-1);
  }
  
  while((c = getopt(argc, argv, "i:j:p:a:n:t:Lol:m:s:T:L:S:J:N:R:D:Q:B:G:O:P:CV:3")) != -1)
    switch (c) {
    case 'i':
      ival = atoi(optarg)-1;
      break;
    case 'j':
      j = atoi(optarg);
      break;
    case 'p':
      par = atoi(optarg);
      break;
    case 'n':
      minnormkmix = atof(optarg);
      break;
    case 't':
      threshkmix = atof(optarg);
      break;
    case 'a':
      alpha = atof(optarg);
      break;
    case 'o':
      overwrite = 1;
      break;
    case 'l':
      log = atoi(optarg);
      break;
    case 'm':
      maxsteps = atoi(optarg);
      break;
    case 's':
      shakemag = atof(optarg);
      break;
    case 'T':
      constT2 = 1;
      constT2val = atof(optarg);
      break;
    case 'L':
      constL2 = 1;
      constL2val = atof(optarg);
      break;
    case 'S':
      constS2 = 1;
      constS2val = atof(optarg);
      break;
    case 'J':
      constJ2 = 1;
      constJ2val = atof(optarg);
      break;
      /*
    case 'j':
      constj2 = 1;
      constj2val = atof(optarg);
      break;
      */
    case 'N':
      if (optarg[0] == 'P') {
        constpnosci = 1;
        constpnoscival = atof(optarg+2);
      } else if (optarg[0] == 'N') {
        constnnosci = 1;
        constnnoscival = atof(optarg+2);
      } else {
        constnosci = 1;
        constnoscival = atof(optarg);
      }
      break;
    case 'R':
      if (optarg[0] == 'E' || optarg[0] == 'P') {
	consteradius = 1;
	consterval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
        constnradius = 1;
        constnrval = atof(optarg+2);
      } else {
	constmradius = 1;
	constmrval = atof(optarg);
      }
      break;
    case 'D':
      constedipole = 1;
      constedval = atof(optarg);
      break;
    case 'Q':
      if (optarg[0] == 'E' || optarg[0] == 'P') {
	constequadrupole = 1;
	consteqval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
	constnquadrupole = 1;
	constnqval = atof(optarg+2);
      } else {
	constmquadrupole = 1;
	constmqval = atof(optarg);
      }
      break;
    case 'B':
      constbeta = 1;
      constbval = atof(optarg);
      break;
    case 'G':
      constgamma = 1;
      constgval = atof(optarg);
      break;
    case 'O':
      if (optarg[0] == 'E' || optarg[0] == 'P') {
	consteoctupole = 1;
	consteoval = atof(optarg+2);
      } else if (optarg[0] == 'N') {
	constnoctupole = 1;
	constnoval = atof(optarg+2);
      } else {
	constmoctupole = 1;
	constmoval = atof(optarg);
      }
      break;
    case 'P':
      if (atoi(optarg) == +1) 
        constparp = 1;
      else
        constparn = 1;
      break;
    case 'C':
      constparch = 1;
      break;
    case 'V':
      if (!strcmp(optarg, "xz"))
        constsxz = 1;
      else if (!strcmp(optarg, "yz"))
        constsyz = 1;
      break;
    case '3':
      constd3h = 1;
      break;
    }
  
  if (constcm) {
    Const[nconst] = ConstraintCM;
    nconst++;
  }
  if (constT2) {
    Const[nconst] = ConstraintT2;
    Const[nconst].val = constT2val;
    nconst++;
  }
  if (constS2) {
    Const[nconst] = ConstraintS2;
    Const[nconst].val = constS2val;
    nconst++;
  }
/*   if (constL2) { */
/*     Const[nconst] = ConstraintL2; */
/*     Const[nconst].val = constL2val; */
/*     nconst++; */
/*   } */
/*   if (constLS) { */
/*     Const[nconst] = ConstraintLS; */
/*     Const[nconst].val = constLSval; */
/*     nconst++; */
/*   } */
  if (constJ2) {
    Const[nconst] = ConstraintJ2;
    Const[nconst].val = constJ2val;
    nconst++;
  }
  if (constj2) {
    Const[nconst] = ConstraintJ2;
    Const[nconst].val = constj2val;
    nconst++;
  }
  if (constnosci) {
    Const[nconst] = ConstraintNOsci;
    Const[nconst].val = SQR(constnoscival);
    nconst++;
  }
  if (constpnosci) {
    Const[nconst] = ConstraintPNOsci;
    Const[nconst].val = SQR(constpnoscival);
    nconst++;
  }
  if (constnnosci) {
    Const[nconst] = ConstraintNNOsci;
    Const[nconst].val = SQR(constnnoscival);
    nconst++;
  }
  if (constmradius) {
    Const[nconst] = ConstraintR2;
    Const[nconst].val = SQR(constmrval);
    nconst++;
  }
  if (consteradius) {
    Const[nconst] = ConstraintER2;
    Const[nconst].val = SQR(consterval);
    nconst++;
  }
  if (constnradius) {
    Const[nconst] = ConstraintNR2;
    Const[nconst].val = SQR(constnrval);
    nconst++;
  }
  if (constedipole) {
    Const[nconst] = ConstraintED2;
    Const[nconst].val = constedval;
    nconst++;
  }
  if (constnquadrupole) {
    Const[nconst] = ConstraintNQ2;
    Const[nconst].val = constnqval;
    nconst++;
  }
  if (constmquadrupole) {
    Const[nconst] = ConstraintQ2;
    Const[nconst].val = constmqval;
    nconst++;
  }
  if (constbeta) {
    Const[nconst] = ConstraintQ2;
    Const[nconst].val = sqrt(24*M_PI/5)*constbval;
    nconst++;
  }
  if (constgamma) {
    if (!constbeta) {
      fprintf(stderr, "gamma constraint only in combination with beta constraint\n");
      exit(-1);
    }
    Const[nconst] = ConstraintDetQ;
    Const[nconst].val = sqrt(4*M_PI/5)*constbval*cbrt(2*cos(3*constgval*M_PI/180));
    nconst++;
  }
  if (constequadrupole) {
    Const[nconst] = ConstraintEQ2;
    Const[nconst].val = consteqval;
    nconst++;
  }
  if (constmoctupole) {
    Const[nconst] = ConstraintO2;
    Const[nconst].val = constmoval;
    nconst++;
  }
  if (consteoctupole) {
    Const[nconst] = ConstraintEO2;
    Const[nconst].val = consteoval;
    nconst++;
  }
  if (constnoctupole) {
    Const[nconst] = ConstraintNO2;
    Const[nconst].val = constnoval;
    nconst++;
  }
  if (constparp) {
    Const[nconst] = ConstraintParityP;
    nconst++;
  }
  if (constparn) {
    Const[nconst] = ConstraintParityN;
    nconst++;
  }
  if (constparch) {
    Const[nconst] = ConstraintParityCharge;
    nconst++;
  }
  if (constsxz) {
    Const[nconst] = ConstraintSxz;
    nconst++;
  }
  if (constsyz) {
    Const[nconst] = ConstraintSyz;
    nconst++;
  }
  if (constd3h) {
    Const[nconst] = ConstraintD3H;
    nconst++;
  }

  int i;
  char* projpar = argv[optind];
  char* interactionfile = argv[optind+1];
  char* parafile = argv[optind+2];

  // set up angular integration
  angintegrationpara AngPar;
  initAngintegration(&AngPar, projpar);

  Interaction Int;
  if (readInteractionfromFile(&Int, interactionfile))
    cleanup(-1);
  Int.cm = cm;

  // optimize which eigenvalue
  if (ival==-1)
    ival = 0;

  // configuration to be varied
  Parameterization P;
  Para qinitial;
  if (readParafromFile(&P, &qinitial, parafile)) {
    fprintf(stderr, "couldn't read %s\n", parafile);
    cleanup(-1);
  }

  SlaterDet Q;
  P.ParainitSlaterDet(&qinitial, &Q);
  P.ParatoSlaterDet(&qinitial, &Q);

  if (!par)
    par = (Q.A % 2) ? -1 : +1;

#ifdef MPI
  int task=TASKSTART;
  BroadcastTask(&task);

  BroadcastInteraction(&Int);
  BroadcastA(&Q.A);
#endif

  initWork(j, par, &AngPar, &Int, &Q);
  
  SlaterDetAux X;
  initSlaterDetAux(&Q, &X);

  moveboostorientSlaterDet(&Q, &X);

  double eintri, eproji;
  calcprojectedHamiltonian(&Q, &Int, j, par, ival, &AngPar,
                           &eintri, &eproji);

  for (int i=0; i<nconst; i++)
    fprintf(stderr, "# constraining %4s to %8.3f\n", 
	    Const[i].label, Const[i].output(Const[i].val)); 

  double einitial = eproji + alpha*eintri;

  fprintf(stderr, "\ninitial:\tE = %8.3f MeV, Eproj = %8.3f MeV, Eintr = %8.3f MeV\n\n", 
	  hbc*einitial, hbc*eproji, hbc*eintri);

  Para q;
  P.Paraclone(&qinitial, &q);

  // shaking the parameters ?
  if (shakemag) {
    shakePara(&q, shakemag);
  }

  // in FMD parameterization move SlaterDet to origin in phase space
  // if (!strcmp(P.name, "FMD")) {
  //   P.ParatoSlaterDet(&q, &Q);
  //   moveboostorientSlaterDet(&Q, &X);
  //   SlaterDetinitFMD(&Q, &q);
  // }

  // minimize !
  MinimizeDONLP2vapp(&Int, j, par, ival, threshkmix, minnormkmix, alpha,
                     &AngPar, 
                     Const, nconst,
                     &P, &q, maxsteps,
                     log, parafile); 

  P.ParatoSlaterDet(&q, &Q);

  double eintrf, eprojf;

  calcprojectedHamiltonian(&Q, &Int, j, par, ival, &AngPar,
                           &eintrf, &eprojf);

  double e = eprojf + alpha*eintrf;

  fprintf(stderr, "\nfinal:\tE = %8.3f MeV, Eproj = %8.3f, Eintr = %8.3f MeV\n\n", 
	  hbc*e, hbc*eprojf, hbc*eintrf);

  moveboostorientSlaterDet(&Q, &X);
  
  calcprojectedHamiltonian(&Q, &Int, j, par, ival, &AngPar,
                           &eintrf, &eprojf);

  e = eprojf + alpha*eintrf;

  fprintf(stderr, "\nboosted:\tE = %8.3f MeV, Eproj = %8.3f, Eintr = %8.3f MeV\n\n", 
	  hbc*e, hbc*eprojf, hbc*eintrf);

  // output files

  // backup of parafile

  backup(parafile);

  // switch on cm for output
  Int.cm = 1;

  // save minimization result in MIN directory
  {
    P.ParatoSlaterDet(&q, &Q);

    // orient SlaterDet
    moveboostorientSlaterDet(&Q, &X);

    // normalize SlaterDet
    normalizeSlaterDet(&Q, &X);

    // in FMD parameterization we copy the relocated SlaterDet
    if (!strcmp(P.name, "FMD"))
      SlaterDetinitFMD(&Q, &q);

    // calculate the observables
    Observables Obs;
  
    calcObservables(&Int, &Q, &Obs);

    ensuredir("MIN");
    char outfile[1024];
    sprintf(outfile, "MIN/%s-minvapp.%d", parafile, (int) time(NULL));

    fprintf(stderr, "... writing Parameters to file %s\n", outfile);

    FILE* outfp;
    if (!(outfp = fopen(outfile, "w"))) {
      fprintf(stderr, "couldn't open %s for writing\n", outfile);
      cleanup(-1);
    }

    fprintinfo(outfp);

    fprintf(outfp, "\n# minimized %s for %s in %s parameterization\n"
            "# projected on J^pi = %s\n"
            "# K-mixing: threshold: %f, minnorm: %f\n"
            "# optimized eigenvalue #%d\n"
            "# using %s interaction\n", 
            "< H > - < Tcm >_intr", q.name, P.name, 
            AngmomtoStr(j, par == +1 ? 0 : 1), 
            threshkmix, minnormkmix, ival+1,
            Int.name);
  
    fprintf(outfp, "\n# initial: e = %8.3f MeV, eproj = %8.3f MeV, eintr = %8.3f MeV\n", 
            hbc*einitial, hbc*eproji, hbc*eintri);
    fprintf(outfp, "# final:   e = %8.3f MeV, eproj = %8.3f MeV, eintr = %8.3f MeV\n", 
            hbc*e, hbc*eprojf, hbc*eintrf);

    fprintObservables(outfp, &Int, &Q, &Obs);

    fprintf(outfp, "\n# Parameterization\n");
    fprintf(outfp, "<Parameterization %s>\n", P.name);
    P.Parawrite(outfp, &q);
 
    fprintf(outfp, "\n# SlaterDet\n");
    writeSlaterDet(outfp, &Q);

    fclose(outfp);  
  }

  // save minimization result in parafile
  {
    // no improvement ? then write initial parameters
    if (!overwrite && einitial < e) 
      P.Paraclone(&qinitial, &q);

    P.ParatoSlaterDet(&q, &Q);

    // orient SlaterDet
    moveboostorientSlaterDet(&Q, &X);

    // normalize SlaterDet
    normalizeSlaterDet(&Q, &X);

    // in FMD parameterization we copy the relocated SlaterDet
    if (!strcmp(P.name, "FMD"))
      SlaterDetinitFMD(&Q, &q);

    // calculate the observables
    Observables Obs;
  
    calcObservables(&Int, &Q, &Obs);

    fprintf(stderr, "... writing Parameters to file %s\n", parafile);

    FILE* outfp;
    if (!(outfp = fopen(parafile, "w"))) {
      fprintf(stderr, "couldn't open %s for writing\n", parafile);
      cleanup(-1);
    }

    fprintinfo(outfp);

    fprintf(outfp, "\n# minimized %s for %s in %s parameterization\n"
            "# projected on J^pi = %s\n"
            "# K-mixing: threshold: %f, minnorm: %f\n"
            "# optimized eigenvalue #%d\n"
            "# using %s interaction\n", 
            "< H > - < Tcm >_intr", q.name, P.name, 
            AngmomtoStr(j, par == +1 ? 0 : 1),
            threshkmix, minnormkmix, ival+1,
            Int.name);

    fprintf(outfp, "\n# initial: e = %8.3f MeV, eproj = %8.3f MeV, eintr = %8.3f MeV\n", 
            hbc*einitial, hbc*eproji, hbc*eintri);
    fprintf(outfp, "# final:   e = %8.3f MeV, eproj = %8.3f MeV, eintr = %8.3f MeV\n", 
            hbc*e, hbc*eprojf, hbc*eintrf);

    if (overwrite)
      fprintf(outfp, "\n# overwrite flag: use new parameters\n\n");
    if (!overwrite && einitial < e)
      fprintf(outfp, "\n# no improvement by minimization: use initial parameters\n\n");

    fprintObservables(outfp, &Int, &Q, &Obs);

    fprintf(outfp, "\n# Parameterization\n");
    fprintf(outfp, "<Parameterization %s>\n", P.name);
    P.Parawrite(outfp, &q);
 
    fprintf(outfp, "\n# SlaterDet\n");
    writeSlaterDet(outfp, &Q);

    fclose(outfp);  
  }

  fprintf(stderr, "... %4.2f minutes computing time used\n", usertime()/60.0);

  cleanup(0);

#ifdef MPI
  }
#endif
}
int main(int argc, char *argv[])
{
  createinfo(argc, argv);
  
  int c;
  int nljorder=0;
  int potentialonly=0;
  int cm=0;
  double omega=0.0;

  if (argc < 3) {
    fprintf(stderr, "\nusage: %s interaction slaterdetfile\n"
	    "\n   -s           sort sp states according to n, l, j"
	    "\n   -v           use only potential"
	    "\n   -o OMEGA     use oscillator constant [MeV]"
	    "\n   -c           T-Tcm\n",
	    argv[0]);
    exit(-1);
  }
  
  while((c = getopt(argc, argv, "svco:")) != -1)
    switch (c) {
    case 's':
      nljorder = 1;
      break;
    case 'v':
      potentialonly=1;
      break;
    case 'c':
      cm = 1;
      break;
    case 'o':
      omega = atof(optarg)/hbc;
      break;
    }
  
  char* interactionfile = argv[optind];
  char* slaterdetfile = argv[optind+1];

  Interaction Int;
  if (readInteractionfromFile(&Int, interactionfile))
    exit(-1);
  Int.cm = cm;

  SlaterDet Q;
  if (readSlaterDetfromFile(&Q, slaterdetfile))
    exit(-1);

  // number of nucleons
  int A = Q.A;

  // single-particle overlap matrix
  SlaterDetAux X;
  initSlaterDetAux(&Q, &X);
  calcSlaterDetAux(&Q, &X);

  // Tcm
  double tcm;
  calcTCM(&Q, &X, &tcm);

  // derive oscillator constant from center of mass motion
  double omegacm = 4.0/3.0*tcm;

  if (omega == 0.0)
    omega = omegacm;

  complex double n[A*A];
  copycmat(A, X.n, n);

  // hartree-fock matrix in Gaussian single-particle basis

  complex double hhf[A*A];
  if (potentialonly)	calcPotentialHF(&Int, &Q, &X, hhf);
  else			calcHamiltonianHF(&Int, &Q, &X, hhf);
  
  complex double l2hf[A*A];
  calcl2HF(&Q, &X, l2hf);
  
  complex double j2hf[A*A];
  calcj2HF(&Q, &X, j2hf);

  complex double hoscihf[A*A];
  calcHOsciHF(&Q, &X, omega, hoscihf);

  complex double t3hf[A*A];
  calct3HF(&Q, &X, t3hf);

  complex double parhf[A*A];
  calcparHF(&Q, &X, parhf);

  // solve eigenvalue problem
  complex double lambda[A];
  complex double V[A*A];
  int dim;

  if (nljorder) {
    complex double nljhf[A*A];
    int i;
    for (i=0; i<A*A; i++)
      nljhf[i] = 10000*hoscihf[i]/omega - 100*j2hf[i] + l2hf[i];

      generalizedeigensystem(nljhf, n, A, 0.0, lambda, V, &dim);
  } else
    generalizedeigensystem(hhf, n, A, 0.0, lambda, V, &dim);

  // calculate expectation values
  double norm[A];
  expect(A, n, V, norm);

  double h[A];
  expect(A, hhf, V, h);

  double l2[A];
  expect(A, l2hf, V, l2);
  
  double j2[A];
  expect(A, j2hf, V, j2);

  double hosci[A];
  expect(A, hoscihf, V, hosci);

  double t3[A];
  expect(A, t3hf, V, t3);

  double par[A];
  expect(A, parhf, V, par);

  fprintinfo(stdout);

  // sort single-particle states by energy
  SingleParticleState sp[A];

  int i;
  for (i=0; i<A; i++) {
    sp[i].rank = lambda[i];
    sp[i].e = h[i]/norm[i];
    sp[i].j2 = j2[i]/norm[i];
    sp[i].l2 = l2[i]/norm[i];
    sp[i].hosci = hosci[i]/norm[i];
    sp[i].t3 = t3[i]/norm[i];
    sp[i].pi = par[i]/norm[i];
  }	
  
  qsort(sp, A, sizeof(SingleParticleState), cmpSingleParticleState);
  
  // print proton and neutron levels

  fprintf(stdout, "\nusing oscillator constant: hbar Omega = %8.3f MeV\n",
	  omega*hbc);

  fprintf(stdout, "\nproton levels:\n");
  for (i=0; i<A; i++)
    if (sp[i].t3 > 0.0) {
      fprintf(stdout, "e: %8.3f MeV, j: %5.3f, l: %5.3f, pi: %+5.2f, nosci: %5.3f\n",
	      hbc*sp[i].e, angroot(sp[i].j2), angroot(sp[i].l2), sp[i].pi,
	      sp[i].hosci/omega-1.5);
    }

  fprintf(stdout, "\nneutron levels:\n");
  for (i=0; i<A; i++)
    if (sp[i].t3 < 0.0) {
      fprintf(stdout, "e: %8.3f MeV, j: %5.3f, l: %5.3f, pi: %+5.2f, nosci: %5.3f\n",
	      hbc*sp[i].e, angroot(sp[i].j2), angroot(sp[i].l2), sp[i].pi,
	      sp[i].hosci/omega-1.5);
    }

  return 0;
}