public static void main (String args[]) {

      int iii,i,ic,k,m,n,nread,ntries,nwrite;

      int info[] = new int[2];

//      int nprob;
//      int nfev[] = new int[2];
//      int njev[] = new int[2];

      int nprobfile[] = new int[29];
      int nfile[] = new int[29];
      int mfile[] = new int[29];
      int ntryfile[] = new int[29];

      int ma[] = new int[61];
      int na[] = new int[61];
      int nf[] = new int[61];
      int nj[] = new int[61];
      int np[] = new int[61];
      int nx[] = new int[61];

      double factor,fnorm1,fnorm2,tol;

//      double fjac[][] = new double[66][41];

      double fnm[] = new double[61];
      double fvec[] = new double[66];
      double x[] = new double[41];

      int ipvt[] = new int[41];

      int num5, ilow, numleft; 


//  The npa, na, ma, and nta values are the
//  nprob, n, m, and ntries values from the testdata file.

      nprobfile[1] = 1;
      nprobfile[2] = 1;
      nprobfile[3] = 2;
      nprobfile[4] = 2;
      nprobfile[5] = 3;
      nprobfile[6] = 3;
      nprobfile[7] = 4;
      nprobfile[8] = 5;
      nprobfile[9] = 6;
      nprobfile[10] = 7;
      nprobfile[11] = 8;
      nprobfile[12] = 9;
      nprobfile[13] = 10;
      nprobfile[14] = 11;
      nprobfile[15] = 11;
      nprobfile[16] = 11;
      nprobfile[17] = 12;
      nprobfile[18] = 13;
      nprobfile[19] = 14;
      nprobfile[20] = 15;
      nprobfile[21] = 15;
      nprobfile[22] = 15;
      nprobfile[23] = 15;
      nprobfile[24] = 16;
      nprobfile[25] = 16;
      nprobfile[26] = 16;
      nprobfile[27] = 17;
      nprobfile[28] = 18;


      nfile[1] = 5;
      nfile[2] = 5;
      nfile[3] = 5;
      nfile[4] = 5;
      nfile[5] = 5;
      nfile[6] = 5;
      nfile[7] = 2;
      nfile[8] = 3;
      nfile[9] = 4;
      nfile[10] = 2;
      nfile[11] = 3;
      nfile[12] = 4;
      nfile[13] = 3;
      nfile[14] = 6;
      nfile[15] = 9;
      nfile[16] = 12;
      nfile[17] = 3;
      nfile[18] = 2;
      nfile[19] = 4;
      nfile[20] = 1;
      nfile[21] = 8;
      nfile[22] = 9;
      nfile[23] = 10;
      nfile[24] = 10;
      nfile[25] = 30;
      nfile[26] = 40;
      nfile[27] =  5;
      nfile[28] = 11;


      mfile[1] = 10;
      mfile[2] = 50;
      mfile[3] = 10;
      mfile[4] = 50;
      mfile[5] = 10;
      mfile[6] = 50;
      mfile[7] = 2;
      mfile[8] = 3;
      mfile[9] = 4;
      mfile[10] = 2;
      mfile[11] = 15;
      mfile[12] = 11;
      mfile[13] = 16;
      mfile[14] = 31;
      mfile[15] = 31;
      mfile[16] = 31;
      mfile[17] = 10;
      mfile[18] = 10;
      mfile[19] = 20;
      mfile[20] = 8;
      mfile[21] = 8;
      mfile[22] = 9;
      mfile[23] = 10;
      mfile[24] = 10;
      mfile[25] = 30;
      mfile[26] = 40;
      mfile[27] = 33;
      mfile[28] = 65;


      ntryfile[1] = 1;
      ntryfile[2] = 1;
      ntryfile[3] = 1;
      ntryfile[4] = 1;
      ntryfile[5] = 1;
      ntryfile[6] = 1;
      ntryfile[7] = 3;
      ntryfile[8] = 3;
      ntryfile[9] = 3;
      ntryfile[10] = 3;
      ntryfile[11] = 3;
      ntryfile[12] = 3;
      ntryfile[13] = 2;
      ntryfile[14] = 3;
      ntryfile[15] = 3;
      ntryfile[16] = 3;
      ntryfile[17] = 1;
      ntryfile[18] = 1;
      ntryfile[19] = 3;
      ntryfile[20] = 3;
      ntryfile[21] = 1;
      ntryfile[22] = 1;
      ntryfile[23] = 1;
      ntryfile[24] = 3;
      ntryfile[25] = 1;
      ntryfile[26] = 1;
      ntryfile[27] = 1;
      ntryfile[28] = 1;


      tol = Math.sqrt(epsmch);

      ic = 0;

      for (iii = 1; iii <= 28; iii++) {

//         nprob = nprobfile[iii];
         n = nfile[iii];
         m = mfile[iii];
         ntries = ntryfile[iii];

         LmdifTest_f77 lmdiftest = new LmdifTest_f77();

         lmdiftest.nprob = nprobfile[iii];

         factor = one;

         for (k = 1; k <= ntries; k++) {

            ic++;

            LmdifTest_f77.initpt_f77(n,x,lmdiftest.nprob,factor);

            LmdifTest_f77.ssqfcn_f77(m,n,x,fvec,lmdiftest.nprob);

            fnorm1 = Minpack_f77.enorm_f77(m,fvec);

            System.out.print("\n\n\n\n\n problem " + lmdiftest.nprob + 
                             ", dimensions:  " + n + "  " + m + "\n");
//            write (nwrite,60) nprob,n,m
//   60 format ( //// 5x, 8h problem, i5, 5x, 11h dimensions, 2i5, 5x //
//     *         )

            lmdiftest.nfev = 0;
            lmdiftest.njev = 0;

            Minpack_f77.lmdif1_f77(lmdiftest,m,n,x,fvec,tol,info);

            LmdifTest_f77.ssqfcn_f77(m,n,x,fvec,lmdiftest.nprob);

            fnorm2 = Minpack_f77.enorm_f77(m,fvec);

            np[ic] = lmdiftest.nprob;
            na[ic] = n;
            ma[ic] = m;
            nf[ic] = lmdiftest.nfev;
            nj[ic] = lmdiftest.njev/n;
            nx[ic] = info[1];

            fnm[ic] = fnorm2;

            System.out.print("\n Initial L2 norm of the residuals: " + fnorm1 +
                             "\n Final L2 norm of the residuals: " + fnorm2 +
                             "\n Number of function evaluations: " + nf[ic] +
                             "\n Number of Jacobian evaluations: " + nj[ic] +
                             "\n Info value: " + info[1] +
                             "\n Final approximate solution: \n\n");

            num5 = n/5;
            
            for (i = 1; i <= num5; i++) {

               ilow = (i-1)*5;
               System.out.print(x[ilow+1] + "  " + x[ilow+2] + "  " +
                                x[ilow+3] + "  " + x[ilow+4] + "  " +
                                x[ilow+5] + "\n");

            }

            numleft = n%5;
            ilow = n - numleft;

            switch (numleft) {

               case 1:

                  System.out.print(x[ilow+1] + "\n\n");

                  break;

               case 2:

                  System.out.print(x[ilow+1] + "  " + x[ilow+2] + "\n\n");

                  break;

               case 3:

                  System.out.print(x[ilow+1] + "  " + x[ilow+2] + "  " +
                                   x[ilow+3] + "\n\n");

                  break;

               case 4:

                  System.out.print(x[ilow+1] + "  " + x[ilow+2] + "  " +
                                   x[ilow+3] + "  " + x[ilow+4] + "\n\n");

                  break;

            }
   
//            write (nwrite,70)
//     *            fnorm1,fnorm2,nfev,njev,info,(x(i), i = 1, n)
//   70 format (5x, 33h initial l2 norm of the residuals, d15.7 // 5x,
//     *        33h final l2 norm of the residuals  , d15.7 // 5x,
//     *        33h number of function evaluations  , i10 // 5x,
//     *        33h number of jacobian evaluations  , i10 // 5x,
//     *        15h exit parameter, 18x, i10 // 5x,
//     *        27h final approximate solution // (5x, 5d15.7))

            factor *= ten;

         }

      }

      System.out.print("\n\n\n Summary of " + ic + 
                             " calls to lmdif1: \n\n");
//      write (nwrite,80) ic
//   80 format (12h1summary of , i3, 16h calls to lmdif1 /)

      System.out.print("\n\n nprob   n    m   nfev  njev  info  final L2 norm \n\n");

//      write (nwrite,90)
//   90 format (49h nprob   n    m   nfev  njev  info  final l2 norm /)

      for (i = 1; i <= ic; i++) {

         System.out.print(np[i] + "  " + na[i] + "  " + ma[i] + "  " +
                          nf[i] + "  " + nj[i] + "  " + nx[i] + "  " + fnm[i] +
                          "\n");

//         write (nwrite,100) np[i],na[i],ma[i],nf[i],nj[i],nx[i],fnm[i]
//  100 format (3i5, 3i6, 1x, d15.7)

      }

   }