Porting continues.
authorilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Mon, 29 Jan 2018 23:12:36 +0000 (23:12 +0000)
committerilb@NIH.GOV <ilb@NIH.GOV@ba61647d-9d00-f842-95cd-605cb4296b96>
Mon, 29 Jan 2018 23:12:36 +0000 (23:12 +0000)
git-svn-id: https://citdcbmipav.cit.nih.gov/repos-pub/mipav/trunk@15354 ba61647d-9d00-f842-95cd-605cb4296b96

mipav/src/gov/nih/mipav/model/algorithms/SymmsIntegralMapping.java

index baa7af0..e4865b7 100644 (file)
@@ -11,94 +11,98 @@ import gov.nih.mipav.model.structures.jama.LinearEquations2;
 import gov.nih.mipav.view.MipavUtil;\r
 import gov.nih.mipav.view.Preferences;\r
 \r
-public class SymmsIntegralMapping extends AlgorithmBase  {\r
+public class SymmsIntegralMapping extends AlgorithmBase {\r
        String fileDir;\r
-       \r
-       // EPS returns the distance from 1.0 to the next larger double-precision number, that is, eps = 2^-52.\r
-    private double EPS;\r
-    // Filename to receive FORTRAN output code\r
-    private String FORTFL = null;\r
-    // Does the domain have any symmetry?\r
-    private boolean SYMTY;\r
-    // If SYMTY is true, are there any reflectional symmetries?\r
-    private boolean REFLN;\r
-    // If SYMTY is true, what are the coordinates of the center of symmetry?\r
-    private final int MNARC = 100;\r
-    private double CENSY[] = new double[2];\r
-    // If SYMTY is true, number of arcs on the fundamental boundary section\r
-    // If SYMTY is false, number of arcs on the boundary\r
-    // NARCS <= MNARC-1 = 99\r
-    private int NARCS;\r
-    // NUMDER is of length MNARC\r
-    // NUMDER is initially false\r
-    private boolean NUMDER[] = new boolean[MNARC];\r
-    // ARCTY is of length MNARC\r
-    // Type of arc, 1 = LINE SEGMENT, 2 = CIRCULAR ARC SEGMENT, 3 = CARTESIAN PARAMETRIC FUNCTION\r
-    // 4 = POLAR FUNCTION\r
-    private int ARCTY[] = new int[MNARC];\r
-    // STAPT is of length MNARC,2\r
-    // Initial point on line, initial point on circle, or initial point on curve\r
-    // IF (SYMTY) THEN\r
-    // WRITE(*,*) 'COORDINATES OF FINAL POINT ON THIS ARC?'\r
-    //STAPT[NARCS]=CMPLX(FINAL X point, FINAL Y point)\r
-    //ELSE\r
-    // STAPT[NARCS]=STAPT[1]\r
-    //ENDIF\r
-    private double STAPT[][] = new double[MNARC][2];\r
-    // Start with GMCO = 0\r
-    // For types 2, 3, and 4 increment GMCO and put\r
-    //GMCO=GMCO+1\r
-       //PGM[IA-1]=GMCO where IA is the number of the curve from 1 to NARCS\r
-    // For type 2 circular arc:\r
-    // RGM[GMCO-1]= X center of circle\r
+\r
+       // EPS returns the distance from 1.0 to the next larger double-precision\r
+       // number, that is, eps = 2^-52.\r
+       private double EPS;\r
+       // Filename to receive FORTRAN output code\r
+       private String FORTFL = null;\r
+       // Does the domain have any symmetry?\r
+       private boolean SYMTY;\r
+       // If SYMTY is true, are there any reflectional symmetries?\r
+       private boolean REFLN;\r
+       // If SYMTY is true, what are the coordinates of the center of symmetry?\r
+       private final int MNARC = 100;\r
+       private double CENSY[] = new double[2];\r
+       // If SYMTY is true, number of arcs on the fundamental boundary section\r
+       // If SYMTY is false, number of arcs on the boundary\r
+       // NARCS <= MNARC-1 = 99\r
+       private int NARCS;\r
+       // NUMDER is of length MNARC\r
+       // NUMDER is initially false\r
+       private boolean NUMDER[] = new boolean[MNARC];\r
+       // ARCTY is of length MNARC\r
+       // Type of arc, 1 = LINE SEGMENT, 2 = CIRCULAR ARC SEGMENT, 3 = CARTESIAN\r
+       // PARAMETRIC FUNCTION\r
+       // 4 = POLAR FUNCTION\r
+       private int ARCTY[] = new int[MNARC];\r
+       // STAPT is of length MNARC,2\r
+       // Initial point on line, initial point on circle, or initial point on curve\r
+       // IF (SYMTY) THEN\r
+       // WRITE(*,*) 'COORDINATES OF FINAL POINT ON THIS ARC?'\r
+       // STAPT[NARCS]=CMPLX(FINAL X point, FINAL Y point)\r
+       // ELSE\r
+       // STAPT[NARCS]=STAPT[1]\r
+       // ENDIF\r
+       private double STAPT[][] = new double[MNARC][2];\r
+       // Start with GMCO = 0\r
+       // For types 2, 3, and 4 increment GMCO and put\r
+       // GMCO=GMCO+1\r
+       // PGM[IA-1]=GMCO where IA is the number of the curve from 1 to NARCS\r
+       // For type 2 circular arc:\r
+       // RGM[GMCO-1]= X center of circle\r
        // GMCO=GMCO+1\r
        // RGM[GMCO-1]= Y center of circle\r
-       //GMCO=GMCO+1\r
-       //RGM[GMCO-1]=ALPHA*PI where alpha is the signed angle subtended at center in units of PI\r
-    // ALPHA is positive for CCW and negative for CW.\r
-    // For type 3 CARTESIAN PARAMETRIC FUNCTION:\r
-    // RGM[GMCO-1]= initial parameter value\r
-    // GMCO=GMCO+1\r
-    // RGM[GMCO-1]= final parameter value\r
-    // For type 4 polar function:\r
-    // RGM[GMCO-1]= (initial polar angle in units of PI) *PI\r
-    // GMCO=GMCO+1\r
-    // RGM[GMCO-1]= (final polar angle in units of PI) *PI\r
-    // PGM is of length MNARC\r
-    private int PGM[] = new int[MNARC];\r
-    // RGM is of length 3*MNARC\r
-    private double RGM[] = new double[3*MNARC];\r
-    // Start with TXCO = 0\r
-    // For types 3 and 4\r
-    // For each IA = 1 to NARCS do J = 1,2\r
-    //TXCO=TXCO+1\r
-    //PTX[IA-1+(J-1)*MNARC]=TXCO\r
-    // DEFN[TXCO-1][0]= TXT for real part\r
-    // DEFN[TXCO-1][1] = TXT for imaginary part\r
-    // where TXT = A COMPLEX EXPRESSION for TYPE 3 and a REAL EXPRESSION FOR TYPE 4\r
-    // for J = 1 and TYPE = 3 JAVA EXPRESSION FOR PARFUN\r
-    // for J = 2 and TYPE = 3 JAVA EXPRESSION FOR DPARFN\r
-    // for J = 1 and TYPE = 4 JAVA EXPRESSION FOR RADIUS\r
-    // for J = 2 and TYPE = 4 JAVA EXPRESSION FOR RADIUS DERIVATIVE\r
-    // PTX is of length 2*MNARC\r
-    private int PTX[] = new int[2*MNARC];\r
-    private int NTX[]= new int[2*MNARC];\r
-    //CHARACTER DEFN(MNARC*2)*72\r
-    // Holds text for real for types 3 and 4 and imaginary parts for type 3\r
-    // Start imaginary text with ui.  All text following ui is imaginary.\r
-    String DEFN[]= new String[2*MNARC];\r
-    private boolean traditionalInput = false;\r
-    Scanner input = new Scanner(System.in);\r
-    private double zzset[][] = new double[400][2];\r
-    private int IBNDS[] = new int[5];\r
-    private int IGEOM[] = new int[4]; // Written in original JAPHYC\r
-    private int PARNT[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
-    private double RGEOM[] = new double[2]; // Written in original JAPHYC\r
-    private double HALEN[]= new double[IBNDS[0]]; // Written in original JAPHYC\r
+       // GMCO=GMCO+1\r
+       // RGM[GMCO-1]=ALPHA*PI where alpha is the signed angle subtended at center\r
+       // in units of PI\r
+       // ALPHA is positive for CCW and negative for CW.\r
+       // For type 3 CARTESIAN PARAMETRIC FUNCTION:\r
+       // RGM[GMCO-1]= initial parameter value\r
+       // GMCO=GMCO+1\r
+       // RGM[GMCO-1]= final parameter value\r
+       // For type 4 polar function:\r
+       // RGM[GMCO-1]= (initial polar angle in units of PI) *PI\r
+       // GMCO=GMCO+1\r
+       // RGM[GMCO-1]= (final polar angle in units of PI) *PI\r
+       // PGM is of length MNARC\r
+       private int PGM[] = new int[MNARC];\r
+       // RGM is of length 3*MNARC\r
+       private double RGM[] = new double[3 * MNARC];\r
+       // Start with TXCO = 0\r
+       // For types 3 and 4\r
+       // For each IA = 1 to NARCS do J = 1,2\r
+       // TXCO=TXCO+1\r
+       // PTX[IA-1+(J-1)*MNARC]=TXCO\r
+       // DEFN[TXCO-1][0]= TXT for real part\r
+       // DEFN[TXCO-1][1] = TXT for imaginary part\r
+       // where TXT = A COMPLEX EXPRESSION for TYPE 3 and a REAL EXPRESSION FOR\r
+       // TYPE 4\r
+       // for J = 1 and TYPE = 3 JAVA EXPRESSION FOR PARFUN\r
+       // for J = 2 and TYPE = 3 JAVA EXPRESSION FOR DPARFN\r
+       // for J = 1 and TYPE = 4 JAVA EXPRESSION FOR RADIUS\r
+       // for J = 2 and TYPE = 4 JAVA EXPRESSION FOR RADIUS DERIVATIVE\r
+       // PTX is of length 2*MNARC\r
+       private int PTX[] = new int[2 * MNARC];\r
+       private int NTX[] = new int[2 * MNARC];\r
+       // CHARACTER DEFN(MNARC*2)*72\r
+       // Holds text for real for types 3 and 4 and imaginary parts for type 3\r
+       // Start imaginary text with ui. All text following ui is imaginary.\r
+       String DEFN[] = new String[2 * MNARC];\r
+       private boolean traditionalInput = false;\r
+       Scanner input = new Scanner(System.in);\r
+       private double zzset[][] = new double[400][2];\r
+       private int IBNDS[] = new int[5];\r
+       private int IGEOM[] = new int[4]; // Written in original JAPHYC\r
+       private int PARNT[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
+       private double RGEOM[] = new double[2]; // Written in original JAPHYC\r
+       private double HALEN[] = new double[IBNDS[0]]; // Written in original JAPHYC\r
        private double MIDPT[] = new double[IBNDS[0]]; // Written in original JAPHYC\r
        private double VTARG[] = new double[IBNDS[0]]; // Written in original JPAHYC\r
-    private int ISNPH[] = new int[6]; // Written in original JAPHYC\r
-    private int DGPOL[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
+       private int ISNPH[] = new int[6]; // Written in original JAPHYC\r
+       private int DGPOL[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
        private int JATYP[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
        private int LOSUB[] = new int[IBNDS[0]]; // Written in original JAPHYC\r
        // Parts of RSNPH\r
@@ -136,7 +140,7 @@ public class SymmsIntegralMapping extends AlgorithmBase  {
        private double A1COF[] = new double[IBNDS[1]];\r
        private double B1COF[] = new double[IBNDS[1]];\r
        private double TOLOU[] = new double[IBNDS[1]];\r
-       private double XIDST[] = new double[2*IBNDS[1]];\r
+       private double XIDST[] = new double[2 * IBNDS[1]];\r
        private double XENPT[] = new double[IBNDS[2]];\r
        private double QCOMX[] = new double[IBNDS[3]];\r
        private double QCOMW[] = new double[IBNDS[3]];\r
@@ -147,2633 +151,2511 @@ public class SymmsIntegralMapping extends AlgorithmBase  {
        private double CQCOF[] = new double[TNGQP];\r
        private double COLSC[] = new double[TNGQP];\r
        private double RIGLL[] = new double[TNGQP];\r
-       private double WORK[] = new double[2*NQPTS];\r
+       private double WORK[] = new double[2 * NQPTS];\r
        private double DIAG[] = new double[NQPTS];\r
        private double SDIAG[] = new double[NQPTS];\r
-       private double WORKT[] = new double[2*NQPTS*NQPTS];\r
-       private double WORKQ[] = new double[NQPTS*NQPTS];\r
+       private double WORKT[] = new double[2 * NQPTS * NQPTS];\r
+       private double WORKQ[] = new double[NQPTS * NQPTS];\r
        // Parts of ZWORK\r
        private double ZCOLL[][] = new double[MNEQN][2];\r
-       private double XIVAL[][] = new double[2*IBNDS[1]][2];\r
+       private double XIVAL[][] = new double[2 * IBNDS[1]][2];\r
        // Parts of LWORK\r
        private boolean NEWQU[] = new boolean[IBNDS[1]];\r
        private boolean LCOPY[] = new boolean[IBNDS[0]];\r
        private boolean PNEWQ[] = new boolean[IBNDS[0]];\r
        private boolean LNSEG[] = new boolean[IBNDS[0]];\r
-       \r
-//  CENTR  - COMPLEX\r
-//                     THE POINT IN THE PHYSICAL PLANE THAT IS TO BE\r
-//                     MAPPED TO THE CENTRE OF THE UNIT DISC.  FOR\r
-//                     EXTERIOR DOMAINS CENTR MUST BE SOME POINT IN THE\r
-//                     COMPLEMENTARY INTERIOR  PHYSICAL DOMAIN.\r
-//                     IN CASE ABS(ISYGP).GT.1 THEN CENTR MUST ALSO BE\r
-//                     A CENTRE OF SYMMETRY FOR THE PHYSICAL DOMAIN.\r
+\r
+       // CENTR - COMPLEX\r
+       // THE POINT IN THE PHYSICAL PLANE THAT IS TO BE\r
+       // MAPPED TO THE CENTRE OF THE UNIT DISC. FOR\r
+       // EXTERIOR DOMAINS CENTR MUST BE SOME POINT IN THE\r
+       // COMPLEMENTARY INTERIOR PHYSICAL DOMAIN.\r
+       // IN CASE ABS(ISYGP).GT.1 THEN CENTR MUST ALSO BE\r
+       // A CENTRE OF SYMMETRY FOR THE PHYSICAL DOMAIN.\r
        private double CENTR[] = new double[2]; // Written in original JAPHYC\r
-//  INTER  - LOGICAL\r
-//                     TRUE IF THE PHYSICAL DOMAIN IS INTERIOR, FALSE \r
-//                     OTHERWISE.\r
+       // INTER - LOGICAL\r
+       // TRUE IF THE PHYSICAL DOMAIN IS INTERIOR, FALSE\r
+       // OTHERWISE.\r
        private boolean INTER; // Written in in original JAPHYC\r
-       \r
-       //COMMON /FNDEF/\r
+\r
+       // COMMON /FNDEF/\r
        private double BETA;\r
        private double A1;\r
        private double B1;\r
        private double P0VAL;\r
        private double SCALE;\r
        private int TYPE;\r
-       \r
+\r
        // From GQPHYC:\r
-       // IQUPH  - INTEGER ARRAY\r
-       //                     AN INTEGER VECTOR OF SIZE AT LEAST 2*IBNDS(1) + 4,\r
-       //                     WHERE IBNDS(1) (=IGEOM(4)) IS THE VALUE PREVIOUSLY\r
-       //                     SUPPLIED TO JAPHYC; IQUPH STORES POINTERS TO \r
-       //                     ACCESS RQUPH AND ZQUPH.\r
+       // IQUPH - INTEGER ARRAY\r
+       // AN INTEGER VECTOR OF SIZE AT LEAST 2*IBNDS(1) + 4,\r
+       // WHERE IBNDS(1) (=IGEOM(4)) IS THE VALUE PREVIOUSLY\r
+       // SUPPLIED TO JAPHYC; IQUPH STORES POINTERS TO\r
+       // ACCESS RQUPH AND ZQUPH.\r
        private int IQUPH[] = new int[4];\r
        private int LQSBF[] = new int[IBNDS[0]];\r
-       private int NPPQF[] = new int[IBNDS[0]];\r
-//  MQUPH  - INTEGER\r
-//                     THE MAXIMUM NUMBER OF QUADRATURE POINTS ALLOWED\r
-//                     IN THE FINAL GLOBAL RULE.  (THE VALUE OF THIS\r
-//                     ARGUMENT IS LINKED TO THOSE OF ARGUMENTS NQPTS\r
-//                     AND IBNDS(1) PREVIOUSLY SUPPLIED TO JAPHYC VIA\r
-//                     MQUPH <= (MQIN1-1)*NQPTS*IBNDS(1))\r
-       private int MQUPH;\r
-       // RQUPH  - REAL ARRAY\r
-       //                     A REAL VECTOR OF SIZE AT LEAST 3*MQUPH + 1; STORES\r
-       //                     THE REAL QUADRATURE DATA.\r
-       private double RQUPH[] = new double[1];\r
-       private double TPPQF[] = new double[MQUPH];\r
-       private double TRRAD[] = new double[MQUPH];\r
-       private double WPPQF[] = new double[MQUPH];\r
-//  ZQUPH  - COMPLEX ARRAY\r
-//                     A COMPLEX VECTOR OF SIZE AT LEAST MQUPH + 1; \r
-//                     STORES THE QUADRATURE POINTS ON THE PHYSICAL \r
-//                     BOUNDARY.\r
-       private double FACTR[] = new double[2]; // At first location of ZQUPH\r
-       private double ZPPQF[][] = new double[MQUPH][2];\r
-       // From JACANP:\r
-       //            ISNCA  - INTEGER ARRAY\r
-       //                     AN INTEGER VECTOR OF SIZE AT LEAST\r
-       //                        4*IBNDS(1) + 6 ;\r
-       //                     ISNCA MAINLY STORES POINTERS TO ACCESS RSNCA AND\r
-       //                     ZSNCA.\r
-       private int ISNCA[] = new int[6];\r
-       private int DGPOC[] = new int[IBNDS[0]];\r
-    private int JTYPC[] = new int[IBNDS[0]];\r
-    private int LSUBC[] = new int[IBNDS[0]];\r
-    private int PRNSA[] = new int[IBNDS[0]];\r
-    //            RSNCA  - REAL ARRAY\r
-       //                     A REAL VECTOR OF SIZE AT LEAST\r
-       //                         2*IBNDS(1) + (4 + 6*NQPTS)*(NARCS + 1) + 2, \r
-       //                     WHERE NARCS, NQPTS ARE INPUT ARGUMENTS TO JAPHYC.\r
-       //                     (NOTE: NARCS=IGEOM(1), NQPTS=IGEOM(2))\r
-       //                     STORES DATA RELATING TO THREE-TERM RECURRENCE\r
-       //                     SCHEMES, ELEMENTARY GAUSS-JACOBI QUADRATURE RULES,\r
-       //                     AND THE ARGUMENTS OF SUB-ARC ENDPOINTS ON THE UNIT\r
-       //                     DISC.\r
-    private double RSNCA[] = new double[1];\r
-    private double ACOFC[] = new double[TNGQP];\r
-    private double BCOFC[] = new double[TNGQP];\r
-    private double AICOC[] = new double[TNGQP];\r
-    private double BICOC[] = new double[TNGQP];\r
-    private double QUPTC[] = new double[TNGQP];\r
-    private double QUWTC[] = new double[TNGQP];\r
-    private double H0VLC[] = new double[NJIND];\r
-    private double HIVLC[] = new double[NJIND];\r
-    private double JAINC[] = new double[NJIND];\r
-    private double COARG[] = new double[NJIND];\r
-    private double PHPAS[] = new double[IBNDS[0]];\r
-    private double VARGC[] = new double[IBNDS[0]];\r
-       //            ZSNCA  - COMPLEX ARRAY\r
-    //            Also called CSNCA elsewhere\r
-       //                     A COMPLEX VECTOR OF SIZE AT LEAST 2*IBNDS(2) + 1;\r
-       //                     STORES THE JACOBI COEFFICIENTS FOR THE COMPLEX\r
-       //                     (INVERSE) BOUNDARY CORRESPONDENCE FUNCTION AND\r
-       //                     ITS DERIVATIVE.\r
-    private double ZSNCA[] = new double[2]; // At first location of ZSNCA\r
-    private double BFSNC[][] = new double[IBNDS[1]][2];\r
-    private double SOLNC[][] = new double[IBNDS[1]][2];\r
-    // From GQCANP:\r
-    //            MQIN1  - INTEGER\r
-       //                     DEFINES THE NUMBER OF PANELS ALLOWED IN A \r
-       //                     COMPOSITE RULE.  SPECIFICALLY, MQIN1 = 1 + (THE\r
-       //                     MAXIMUM NUMBER OF PANELS IN A COMPOSITE RULE FOR\r
-       //                     A SINGLE SUB-ARC ON THE BOUNDARY)\r
+       private int NPPQF[] = new int[IBNDS[0]];\r
+       // MQUPH - INTEGER\r
+       // THE MAXIMUM NUMBER OF QUADRATURE POINTS ALLOWED\r
+       // IN THE FINAL GLOBAL RULE. (THE VALUE OF THIS\r
+       // ARGUMENT IS LINKED TO THOSE OF ARGUMENTS NQPTS\r
+       // AND IBNDS(1) PREVIOUSLY SUPPLIED TO JAPHYC VIA\r
+       // MQUPH <= (MQIN1-1)*NQPTS*IBNDS(1))\r
+       private int MQUPH;\r
+       // RQUPH - REAL ARRAY\r
+       // A REAL VECTOR OF SIZE AT LEAST 3*MQUPH + 1; STORES\r
+       // THE REAL QUADRATURE DATA.\r
+       private double RQUPH[] = new double[1];\r
+       private double TPPQF[] = new double[MQUPH];\r
+       private double TRRAD[] = new double[MQUPH];\r
+       private double WPPQF[] = new double[MQUPH];\r
+       // ZQUPH - COMPLEX ARRAY\r
+       // A COMPLEX VECTOR OF SIZE AT LEAST MQUPH + 1;\r
+       // STORES THE QUADRATURE POINTS ON THE PHYSICAL\r
+       // BOUNDARY.\r
+       private double FACTR[] = new double[2]; // At first location of ZQUPH\r
+       private double ZPPQF[][] = new double[MQUPH][2];\r
+       // From JACANP:\r
+       // ISNCA - INTEGER ARRAY\r
+       // AN INTEGER VECTOR OF SIZE AT LEAST\r
+       // 4*IBNDS(1) + 6 ;\r
+       // ISNCA MAINLY STORES POINTERS TO ACCESS RSNCA AND\r
+       // ZSNCA.\r
+       private int ISNCA[] = new int[6];\r
+       private int DGPOC[] = new int[IBNDS[0]];\r
+       private int JTYPC[] = new int[IBNDS[0]];\r
+       private int LSUBC[] = new int[IBNDS[0]];\r
+       private int PRNSA[] = new int[IBNDS[0]];\r
+       // RSNCA - REAL ARRAY\r
+       // A REAL VECTOR OF SIZE AT LEAST\r
+       // 2*IBNDS(1) + (4 + 6*NQPTS)*(NARCS + 1) + 2,\r
+       // WHERE NARCS, NQPTS ARE INPUT ARGUMENTS TO JAPHYC.\r
+       // (NOTE: NARCS=IGEOM(1), NQPTS=IGEOM(2))\r
+       // STORES DATA RELATING TO THREE-TERM RECURRENCE\r
+       // SCHEMES, ELEMENTARY GAUSS-JACOBI QUADRATURE RULES,\r
+       // AND THE ARGUMENTS OF SUB-ARC ENDPOINTS ON THE UNIT\r
+       // DISC.\r
+       private double RSNCA[] = new double[1];\r
+       private double ACOFC[] = new double[TNGQP];\r
+       private double BCOFC[] = new double[TNGQP];\r
+       private double AICOC[] = new double[TNGQP];\r
+       private double BICOC[] = new double[TNGQP];\r
+       private double QUPTC[] = new double[TNGQP];\r
+       private double QUWTC[] = new double[TNGQP];\r
+       private double H0VLC[] = new double[NJIND];\r
+       private double HIVLC[] = new double[NJIND];\r
+       private double JAINC[] = new double[NJIND];\r
+       private double COARG[] = new double[NJIND];\r
+       private double PHPAS[] = new double[IBNDS[0]];\r
+       private double VARGC[] = new double[IBNDS[0]];\r
+       // ZSNCA - COMPLEX ARRAY\r
+       // Also called CSNCA elsewhere\r
+       // A COMPLEX VECTOR OF SIZE AT LEAST 2*IBNDS(2) + 1;\r
+       // STORES THE JACOBI COEFFICIENTS FOR THE COMPLEX\r
+       // (INVERSE) BOUNDARY CORRESPONDENCE FUNCTION AND\r
+       // ITS DERIVATIVE.\r
+       private double ZSNCA[] = new double[2]; // At first location of ZSNCA\r
+       private double BFSNC[][] = new double[IBNDS[1]][2];\r
+       private double SOLNC[][] = new double[IBNDS[1]][2];\r
+       // From GQCANP:\r
+       // MQIN1 - INTEGER\r
+       // DEFINES THE NUMBER OF PANELS ALLOWED IN A\r
+       // COMPOSITE RULE. SPECIFICALLY, MQIN1 = 1 + (THE\r
+       // MAXIMUM NUMBER OF PANELS IN A COMPOSITE RULE FOR\r
+       // A SINGLE SUB-ARC ON THE BOUNDARY)\r
        private int MQIN1;\r
-       //            MQUCA  - INTEGER\r
-       //                     THE MAXIMUM NUMBER OF QUADRATURE POINTS ALLOWED\r
-       //                     IN THE FINAL GLOBAL RULE.  THE VALUE OF THIS\r
-       //                     ARGUMENT IS LINKED TO THOSE OF ARGUMENTS NQPTS\r
-       //                     AND IBNDS(1) PREVIOUSLY SUPPLIED TO JACANP VIA\r
-       //                     MQUCA <= (MQIN1-1)*NQPTS*IBNDS(1).  (NOTE THAT\r
-    //                     NQPTS = ISNCA(2) 'JACANP'IBNDS(1) =ISNCA(5) )\r
-       private int MQUCA = (MQIN1-1)*NQPTS*IBNDS[0];\r
-    //            IQUCA  - INTEGER ARRAY\r
-       //                     AN INTEGER VECTOR OF SIZE AT LEAST 2*IBNDS(1) + 4,\r
-       //                     WHERE IBNDS(1) (=ISNCA(5)) IS THE VALUE PREVIOUSLY\r
-       //                     SUPPLIED TO JACANP;  IQUCA MAINLY STORES POINTERS\r
-       //                     TO ACCESS ZQUCA.\r
-    private int IQUCA[] = new int[4];\r
-    private int LQSBG[] = new int[IBNDS[0]];\r
-    private int NPPQG[] = new int[IBNDS[0]];\r
-       //            ZQUCA  - COMPLEX ARRAY\r
-       //                     A COMPLEX VECTOR OF SIZE AT LEAST 2*MQUCA+1;\r
-       //                     STORES THE QUADRATURE POINTS AND WEIGHTS.\r
-    private double ZQUCA[] = new double[2]; // At first location of ZQUCA\r
-    private double WPPQG[][] = new double[MQUCA][2];\r
-    private double ZPPQG[][] = new double[MQUCA][2];\r
-    // COMMON /DSDTDA/PT,MD,HL\r
-    private int PT;\r
-    private double MD;\r
-    private double HL;\r
+       // MQUCA - INTEGER\r
+       // THE MAXIMUM NUMBER OF QUADRATURE POINTS ALLOWED\r
+       // IN THE FINAL GLOBAL RULE. THE VALUE OF THIS\r
+       // ARGUMENT IS LINKED TO THOSE OF ARGUMENTS NQPTS\r
+       // AND IBNDS(1) PREVIOUSLY SUPPLIED TO JACANP VIA\r
+       // MQUCA <= (MQIN1-1)*NQPTS*IBNDS(1). (NOTE THAT\r
+       // NQPTS = ISNCA(2) 'JACANP'IBNDS(1) =ISNCA(5) )\r
+       private int MQUCA = (MQIN1 - 1) * NQPTS * IBNDS[0];\r
+       // IQUCA - INTEGER ARRAY\r
+       // AN INTEGER VECTOR OF SIZE AT LEAST 2*IBNDS(1) + 4,\r
+       // WHERE IBNDS(1) (=ISNCA(5)) IS THE VALUE PREVIOUSLY\r
+       // SUPPLIED TO JACANP; IQUCA MAINLY STORES POINTERS\r
+       // TO ACCESS ZQUCA.\r
+       private int IQUCA[] = new int[4];\r
+       private int LQSBG[] = new int[IBNDS[0]];\r
+       private int NPPQG[] = new int[IBNDS[0]];\r
+       // ZQUCA - COMPLEX ARRAY\r
+       // A COMPLEX VECTOR OF SIZE AT LEAST 2*MQUCA+1;\r
+       // STORES THE QUADRATURE POINTS AND WEIGHTS.\r
+       private double ZQUCA[] = new double[2]; // At first location of ZQUCA\r
+       private double WPPQG[][] = new double[MQUCA][2];\r
+       private double ZPPQG[][] = new double[MQUCA][2];\r
+       // COMMON /DSDTDA/PT,MD,HL\r
+       private int PT;\r
+       private double MD;\r
+       private double HL;\r
+       //From LEVCUR:\r
+       String NEWD;\r
+       private double ZZ[][] = new double[2][2];\r
+\r
        public SymmsIntegralMapping() {\r
-               \r
+\r
        }\r
-       \r
-       public SymmsIntegralMapping(ModelImage destImg, ModelImage srcImg, String FORTFL, boolean SYMTY,\r
-                       boolean REFLN, double CENSY[], int NARCS, boolean NUMDER[], int ARCTY[], double STAPT[][],\r
-                       int PGM[], double RGM[], int PTX[], int NTX[], String DEFN[]) {\r
-           super(destImg, srcImg);\r
-           this.FORTFL = FORTFL;\r
-           this.SYMTY = SYMTY;\r
-           this.REFLN = REFLN;\r
-           this.CENSY = CENSY;\r
-           this.NARCS = NARCS;\r
-           this.NUMDER = NUMDER;\r
-           this.ARCTY = ARCTY;\r
-           this.STAPT = STAPT;\r
-           this.PGM = PGM;\r
-           this.RGM = RGM;\r
-           this.PTX = PTX;\r
-           this.NTX = NTX;\r
-           this.DEFN = DEFN;\r
+\r
+       public SymmsIntegralMapping(ModelImage destImg, ModelImage srcImg, String FORTFL, boolean SYMTY, boolean REFLN,\r
+                       double CENSY[], int NARCS, boolean NUMDER[], int ARCTY[], double STAPT[][], int PGM[], double RGM[],\r
+                       int PTX[], int NTX[], String DEFN[]) {\r
+               super(destImg, srcImg);\r
+               this.FORTFL = FORTFL;\r
+               this.SYMTY = SYMTY;\r
+               this.REFLN = REFLN;\r
+               this.CENSY = CENSY;\r
+               this.NARCS = NARCS;\r
+               this.NUMDER = NUMDER;\r
+               this.ARCTY = ARCTY;\r
+               this.STAPT = STAPT;\r
+               this.PGM = PGM;\r
+               this.RGM = RGM;\r
+               this.PTX = PTX;\r
+               this.NTX = NTX;\r
+               this.DEFN = DEFN;\r
        }\r
-       \r
+\r
        public void runAlgorithm() {\r
-           fileDir = srcImage.getFileInfo(0).getFileDirectory();\r
-           \r
-        // eps returns the distance from 1.0 to the next larger double-precision number, that is, eps = 2^-52.\r
-       // epsilon = D1MACH(4)\r
-        // Machine epsilon is the smallest positive epsilon such that\r
-        // (1.0 + epsilon) != 1.0.\r
-        // epsilon = 2**(1 - doubleDigits) = 2**(1 - 53) = 2**(-52)\r
-        // epsilon = 2.2204460e-16\r
-        // epsilon is called the largest relative spacing\r
-        EPS = 1.0;\r
-        double neweps = 1.0;\r
-\r
-\r
-        while (true) {\r
-\r
-            if (1.0 == (1.0 + neweps)) {\r
-                break;\r
-            } else {\r
-                EPS = neweps;\r
-                neweps = neweps / 2.0;\r
-            }\r
-        } // while(true)\r
+               fileDir = srcImage.getFileInfo(0).getFileDirectory();\r
+\r
+               // eps returns the distance from 1.0 to the next larger double-precision\r
+               // number, that is, eps = 2^-52.\r
+               // epsilon = D1MACH(4)\r
+               // Machine epsilon is the smallest positive epsilon such that\r
+               // (1.0 + epsilon) != 1.0.\r
+               // epsilon = 2**(1 - doubleDigits) = 2**(1 - 53) = 2**(-52)\r
+               // epsilon = 2.2204460e-16\r
+               // epsilon is called the largest relative spacing\r
+               EPS = 1.0;\r
+               double neweps = 1.0;\r
+\r
+               while (true) {\r
+\r
+                       if (1.0 == (1.0 + neweps)) {\r
+                               break;\r
+                       } else {\r
+                               EPS = neweps;\r
+                               neweps = neweps / 2.0;\r
+                       }\r
+               } // while(true)\r
        }\r
-       \r
+\r
        public void PARGEN() {\r
-       //.......................................................................\r
-       //     AN INTERACTIVE PREPROCESSOR TO HELP THE  C O N F P A C K  USER \r
-       //     GENERATE THE FORTRAN CODE DEFINING THE BOUNDARY PARAMETRISATION \r
-       //     AND ITS DERIVATIVE.\r
-       //\r
-       //     THE FOLLOWING CONVENTIONS ARE ASSUMED:\r
-       //\r
-       //  ** IF A QUESTION REQUIRES A YES OR NO ANSWER, THE DETECTION OF 'Y' OR\r
-       //     'y' IN THE FIRST 6 INPUT CHARACTERS IS TAKEN AS YES, ANYTHING ELSE\r
-       //     AS NO.\r
-       //\r
-       //  ** WHEN ASKED FOR COORDINATES, THIS ALWAYS MEANS CARTESIAN COORDIN-\r
-       //     ATES AND THESE SHOULD BE SUPPLIED AS TWO REAL NUMBERS, AS EITHER \r
-       //\r
-       //                      X,Y     OR      X Y\r
-       //\r
-       //     WITHOUT PARENTHESES. \r
-       //\r
-       //  ** FOUR TYPES OF ARCS ARE CURRENTLY TREATED, WITH NUMERICAL CODES TO \r
-       //     DENOTE THE TYPE AS FOLLOWS:\r
-       //       1:= LINE SEGMENT.\r
-       //       2:= CIRCULAR ARC SEGMENT.\r
-       //           CONVENTIONS:\r
-       //           1 - THE ANGLE SUBTENDED AT THE CENTRE IS POSITIVE FOR\r
-       //               ANTICLOCKWISE TRAVERSAL OF THE ARC AND NEGATIVE FOR\r
-       //               CLOCKWISE TRAVERSAL.\r
-       //       3:= THE USER IS ASKED TO SUPPLY THE FORTRAN 77 ARITHMETIC \r
-       //           EXPRESSIONS WHICH DEFINE THE CARTESIAN PARAMETRIC FUNCTION  \r
-       //           AND THE DERIVATIVE OF THIS FUNCTION.\r
-       //           CONVENTIONS:\r
-       //           1 - THE PARAMETER MUST BE DENOTED BY T.\r
-       //           2 - THE REAL CONSTANT PI=3.14159.. AND THE COMPLEX CONSTANT\r
-       //               UI=(0.0,1.0) MAY BE USED IN THE ARITHMETIC EXPRESSIONS.\r
-       //       4:= THE USER IS ASKED TO SUPPLY THE FORTRAN 77 ARITHMETIC \r
-       //           EXPRESSIONS WHICH DEFINE THE POLAR COORDINATE AS A FUNCTION\r
-       //           OF POLAR ANGLE AND THE DERIVATIVE OF THIS FUNCTION.\r
-       //           CONVENTIONS:\r
-       //           1 - THE POLAR ANGLE MUST BE DENOTED BY T.\r
-       //           2 - THE REAL CONSTANT PI=3.14159.. MAY BE USED IN THE ARITH-\r
-       //               METIC EXPRESSIONS. \r
-       //           3 - PARGEN ASSIGNS THE EXPRESSION FOR THE RADIUS TO THE \r
-       //               COMPLEX VARIABLE ZRAD;  IF REQUIRED THE USER MAY THERE- \r
-       //               FORE USE THE VARIABLE ZRAD IN THE EXPRESSION FOR THE \r
-       //               DERIVATIVE OF THE RADIUS WRT POLAR ANGLE\r
-       //      IN ADDITION, FOR TYPES 3 AND 4, THE FOLLOWING CONVENTIONS HOLD:\r
-       //           1 - ONLY USE UP TO 66 CHARACTERS PER LINE.\r
-       //           2 - IF THE EXPRESSION OCCUPIES MORE THAN ONE LINE THEN THERE\r
-       //               IS NO NEED TO SUPPLY ANY CONTINUATION CHARACTER.\r
-       //           3 - ONLY USE THOSE FORTRAN 77 INTRINSIC MATHS FUNCTIONS  \r
-       //               WHICH ACCEPT COMPLEX ARGUMENTS AND ARE ANALYTIC; I.E.,\r
-       //               IN STANDARD FORTRAN,\r
-       //                    SQRT, EXP, LOG, SIN, COS\r
-       //           4 - THE WHOLE EXPRESSION SHOULD BE TERMINATED WITH A\r
-       //               REPEATED DIVISION SIGN, I.E. //.\r
-       //\r
-       // ** THE CODE ISN'T VERY ROBUST IN THAT THERE IS LITTLE PROVISION FOR\r
-       //    INTERACTIVE CORRECTION OF ERRORS.  HOWEVER, ALL THE USER'S INPUT\r
-       //     IS AUTOMATICALLY OUTPUT TO A FILE NAMED pgenin.  IF THE USER\r
-       //     REALISES THAT AN ITEM HAS BEEN INPUT INCORRECTLY, THE BEST POLICY\r
-       //     IS TO CARRY ON TO THE END OF THE INPUT PHASE AND THEN TERMINATE \r
-       //     THE EXECUTION;  THE FILE pgenin CAN BE EDITED, RENAMED AND \r
-       //     SUBMITTED AS STANDARD INPUT FOR A SECOND RUN OF PARGEN.   \r
-       //     (THE SUGGESTION TO RENAME IS TO AVOID ANY POSSIBLE DIFFICULTY \r
-       //    ARISING FROM READING THE FILE AS STANDARD INPUT WHILST ALSO \r
-       //     WRITING OUTPUT TO THE SAME FILE.) \r
-       //     IF THE USER REALISES ONLY AT A LATER STAGE (E.G. IN PLOTTING THE \r
-       //     BOUNDARY) THAT AN ITEM HAS BEEN INPUT INCORRECTLY THEN pgenin \r
-       //     MAY STILL BE AVAILABLE FOR RE-USE AS ABOVE.\r
-       //  \r
-       //     SUBROUTINES OR FUNCTIONS NEEDED\r
-       //              - THE CONFPACK LIBRARY.\r
-       //              - THE REAL FUNCTION R1MACH.\r
-       //\r
-       //.......................................................................\r
-       //     AUTHOR: DAVID HOUGH, COVENTRY POLYTECHNIC, UK\r
-       //     LAST UPDATE: 15 FEB 1991\r
-       //.......................................................................\r
-       //\r
-       //     LOCAL VARIABLES\r
-       //\r
-             int GMCO,IA,I,J,L,SW,\r
-                 TXCO;\r
-             int TYPE = 1;\r
-             int IER[] = new int[1];\r
-             int ORDRG[] = new int[1];\r
-             int ORDSG[] = new int[1];\r
-             double ALPHA,PI,X,Y;\r
-             //COMPLEX CENSY,RTUNI,U2\r
-             double RTUNI[] = new double[2];\r
-             double U2[] = new double[2];\r
-            // CHARACTER TXT*72,TABC*6,FORTFL*72,CH*2,SIG(10)*2,WID(10)*2,REDD*6,\r
-            //+FMT1*8,FMT2*9\r
-             String TXT;\r
-             String CH;\r
-             String SIG[] = new String[]{"7","8","9","10","11","12","13","14","15","16"};\r
-             String WID[] = new String[]{"15","16","17","18","19","20","21","22","23","24"};\r
-             String REDD;\r
-             //String FMT1;\r
-             //String FMT2;\r
-       \r
-             //PARAMETER (MNARC=100,TABC='     +',CHNL=20,CHIN=21)\r
-             final String TABC = "     +";\r
-             final int CHNL = 20;\r
-             //final int CHIN = 21;\r
-             \r
-             File file;\r
-             RandomAccessFile raFile = null;\r
-             boolean validInput;\r
-       \r
-             //EXTERNAL CHRIN,HEADER,R1MACH,SYINF1,WRFUN1,WRFUN2,WRHEAD,WRSYM1,\r
-             //+WRSYM2,WRSYM3,WRTAIL\r
-       \r
-             WRHEAD(6,0, null);\r
-       \r
-             PI= Math.PI;\r
-             \r
-             //**** DETERMINE NUMBER OF SIGNIFICANT FIGURES REQUIRED TO MATCH MACHINE \r
-          //**** PRECISION AND SET UP POINTER SW TO SIG AND WID\r
-       \r
-             SW=(int)(-Math.log10(EPS))+2;\r
-             if (SW <= 7) {\r
-               SW=1;\r
-             }\r
-             else if (SW >= 16) {\r
-               SW=10;\r
-             }\r
-             else {\r
-               SW=SW-6;\r
-             }\r
-             \r
-                 //**** SET UP THE EDIT DESCRIPTOR AND FORMAT SPECIFICATION FOR FLOATING \r
-                 //**** POINT OUTPUT\r
-               \r
-                 REDD="E"+WID[SW-1]+"."+SIG[SW-1]; \r
-                 //FMT1="("+REDD+")";\r
-                 //FMT2="(2"+REDD+")";\r
-                 \r
-                 if (traditionalInput) {\r
-                     System.out.println("ENTER FILENAME TO RECEIVE OUTPUT JAVA CODE");  \r
-                     FORTFL = input.next();\r
-                 } // if (traditionalInput)\r
-             \r
-             //**** WRITE THE SOURCE CODE FOR PARFUN\r
-             file = new File(fileDir + FORTFL);\r
-             try {\r
-                 raFile = new RandomAccessFile(file, "rw");\r
-             }\r
-             catch (IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " on raFile = new RandomAccessFile(file, rw)");\r
-                 System.exit(-1);\r
-             }\r
-             // Necessary so that if this is an overwritten file there isn't any\r
-             // junk at the end\r
-             try {\r
-                 raFile.setLength(0);\r
-             }\r
-             catch (IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " on raFile.setLength(0)");\r
-                 System.exit(-1);  \r
-             }\r
-\r
-             //OPEN(CHNL,FILE=FORTFL)\r
-             \r
-             if (traditionalInput) {\r
-                 validInput = false;\r
-                 while (!validInput) {\r
-                     System.out.println("DOES THE DOMAIN HAVE ANY SYMMETRY (Y/N)?");\r
-                     String sym = input.next();\r
-                     String firstSym = sym.substring(0,1);\r
-                     if (firstSym.equalsIgnoreCase("Y")) {\r
-                         SYMTY = true;\r
-                         validInput = true;\r
-                     }\r
-                     else if (firstSym.equalsIgnoreCase("N")) {\r
-                         SYMTY = false;\r
-                         validInput = true;\r
-                     }\r
-                     else {\r
-                         System.out.println(sym + " is not a valid response");\r
-                     }\r
-                 } // while (!validInput)\r
-                 \r
-                 if (SYMTY) {\r
-                         validInput = false;\r
-                         while (!validInput) {\r
-                             System.out.println("ARE THERE ANY REFLECTIONAL SYMMETRIES (Y/N)?");\r
-                             String ref = input.next();\r
-                             String firstRef = ref.substring(0,1);\r
-                             if (firstRef.equalsIgnoreCase("Y")) {\r
-                                 REFLN = true;\r
-                                 validInput = true;\r
-                             }\r
-                             else if (firstRef.equalsIgnoreCase("N")) {\r
-                                 REFLN = false;\r
-                                 validInput = true;\r
-                             }\r
-                             else {\r
-                                 System.out.println(ref + " is not a valid response");\r
-                             }\r
-                         } // while (!validInput)      \r
-                         \r
-                         System.out.println("What are the coordinates of the center of symmetry (X Y)?");\r
-                         CENSY[0] = input.nextDouble();\r
-                         CENSY[1] = input.nextDouble();\r
-                         validInput = false;\r
-                         while (!validInput) {\r
-                             System.out.println("How many arcs are there on the fundamental boundary section?");\r
-                             NARCS = input.nextInt();\r
-                             if (NARCS <= MNARC-1) {\r
-                                 validInput = true;\r
-                             }\r
-                             else {\r
-                                 System.out.println("NARCS must be <= " + (MNARC-1));\r
-                             }\r
-                         } // while (!validInput)\r
-                 } // if (SYMTY)\r
-                 else { // !SYMTY\r
-                         validInput = false;\r
-                         while (!validInput) {\r
-                                 System.out.println("How many arcs are there on the boundary?");\r
-                                 NARCS = input.nextInt();\r
-                                 if (NARCS <= MNARC-1) {\r
-                                 validInput = true;\r
-                             }\r
-                             else {\r
-                                 System.out.println("NARCS must be <= " + (MNARC-1));\r
-                             }\r
-                         } // while (!validInput)\r
-                 } // else !SYMTY\r
-                 \r
-                 GMCO = 0;\r
-                 TXCO = 0;\r
-                 \r
-                 for (IA = 1; IA <= NARCS; IA++) {\r
-                           NUMDER[IA-1] = false; \r
-                           validInput = false;\r
-                           while (!validInput) {\r
-                               System.out.println("ENTER THE TYPE OF ARC(1-4) for ARC NUMBER " + IA);\r
-                               TYPE = input.nextInt();\r
-                               if ((TYPE >= 1) && (TYPE <= 4)) {\r
-                                       validInput = true;\r
-                               }\r
-                               else {\r
-                                       System.out.println("TYPE MUST BE BETWEEN 1 and 4");\r
-                               }\r
-                           } // while (!validInput)\r
-                           if (TYPE == 1) {\r
-                               ARCTY[IA-1] = TYPE;     \r
-                               System.out.println("What are the coordinates of the initial point on the line (X Y)?");\r
-                               STAPT[IA-1][0] = input.nextDouble();\r
-                               STAPT[IA-1][1] = input.nextDouble();\r
-                           } // if (TYPE == 1)\r
-                           else if (TYPE == 2) {\r
-                               ARCTY[IA-1] = TYPE;     \r
-                               System.out.println("What are the coordinates of the initial point on the circle (X Y)?");\r
-                               STAPT[IA-1][0] = input.nextDouble();\r
-                               STAPT[IA-1][1] = input.nextDouble();\r
-                               System.out.println("What are the coordinates of the center of the circle (X Y)?");\r
-                               X = input.nextDouble();\r
-                               Y = input.nextDouble(); \r
-                               System.out.println("What is the signed angle subtended at center (in units of PI)?");\r
-                               ALPHA = input.nextDouble();\r
-                               GMCO=GMCO+1;\r
-                               PGM[IA-1]=GMCO;\r
-                               RGM[GMCO-1]=X;\r
-                               GMCO=GMCO+1;\r
-                               RGM[GMCO-1]=Y;\r
-                               GMCO=GMCO+1;\r
-                               RGM[GMCO-1]=ALPHA*PI;\r
-                           } // else if (TYPE == 2)\r
-                           else if ((TYPE == 3) || (TYPE == 4)) {\r
-                               ARCTY[IA-1] = TYPE;     \r
-                               System.out.println("What are the coordinates of the initial point on the curve (X Y)?");\r
-                               STAPT[IA-1][0] = input.nextDouble();\r
-                               STAPT[IA-1][1] = input.nextDouble();\r
-                               if (TYPE == 3) {\r
-                                       System.out.println("Enter the initial and final parameter values (X Y)");\r
-                               }\r
-                               else {\r
-                                       System.out.println("Enter the initial and final polar values (in angles of PI) (X Y)");\r
-                               }\r
-                               X = input.nextDouble();\r
-                               Y = input.nextDouble();\r
-                               GMCO=GMCO+1;\r
-                               PGM[IA-1]=GMCO;\r
-                               if (TYPE == 4) {\r
-                                 RGM[GMCO-1]=X*PI;\r
-                                 GMCO=GMCO+1;\r
-                                 RGM[GMCO-1]=Y*PI;\r
-                               }\r
-                               else {\r
-                                 RGM[GMCO-1]=X;\r
-                                 GMCO=GMCO+1;\r
-                                 RGM[GMCO-1]=Y;\r
-                               }\r
-                               for (J = 1; J <= 2; J++) {\r
-                                       if (J == 1 && TYPE == 3) {\r
-                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR PARFUN");\r
-                                       System.out.println("PUT REAL PART ui IMAGINARY PART");\r
-                                       }\r
-                                       else if (J == 2 && TYPE == 3) {          \r
-                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR DPARFN");\r
-                                       System.out.println("PUT REAL PART ui IMAGINARY PART");\r
-                                       }\r
-                                       else if (J == 1 && TYPE == 4) {\r
-                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR RADIUS");\r
-                                       }\r
-                                       else {\r
-                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR RADIUS DERIVATIVE");\r
-                                       }\r
-                     \r
-                                   TXCO=TXCO+1;\r
-                                   PTX[IA-1+(J-1)*MNARC]=TXCO;\r
-                                   I=1;\r
-       \r
-                                   TXT = input.next();\r
-                                   L = -1;\r
-                                   while (L == -1) {\r
-                                           L = TXT.indexOf("//");\r
-                                           if (L == -1) {\r
-                                               DEFN[TXCO-1]=TABC+TXT;\r
-                                               I=I+1;\r
-                                               TXCO=TXCO+1;\r
-                                           } // if (L == -1)\r
-                                   } // while (L == -1)\r
-                                   NTX[IA-1+(J-1)*MNARC]=I;\r
-                                   if (L == 0) {\r
-                                       DEFN[TXCO-1]=TABC;\r
-                                       NUMDER[IA-1] = true;\r
-                                   }\r
-                                   else {\r
-                                       DEFN[TXCO-1]=TABC+TXT.substring(0,L);\r
-                                   }\r
-                            if ((J == 1) && (TYPE == 4)) {\r
-                               System.out.println("(... = ZRAD)");\r
-                            }\r
-                               } // for (J = 1; J <= 2; J++)\r
-                           } // else if ((TYPE == 3) || (TYPE == 4))\r
-                 } // for (IA = 1; IA <= NARCS; IA++)\r
-                 \r
-                 if (SYMTY) {\r
-                     System.out.println("ENTER THE COORDINATES OF FINAL POINT ON THIS LAST ARC (X Y)");\r
-                     STAPT[NARCS][0] = input.nextDouble();\r
-                     STAPT[NARCS][1] = input.nextDouble();\r
-                 }\r
-                 else {\r
-                     STAPT[NARCS][0]=STAPT[0][0];\r
-                     STAPT[NARCS][1]=STAPT[0][1];\r
-                 }\r
-              \r
-                 validInput = false;\r
-                     while (!validInput) {\r
-                     System.out.println("END OF INPUT PHASE; CONTINUE WITH PROCESSING (Y/N)?");\r
-                     String term = input.next();\r
-                     String firstTerm = term.substring(0,1);\r
-                     if (firstTerm.equalsIgnoreCase("Y")) {\r
-                         validInput = true;\r
-                     }\r
-                     else if (firstTerm.equalsIgnoreCase("N")) {\r
-                         validInput = true;\r
-                         setCompleted(false);\r
-                         return;\r
-                     }\r
-                     else {\r
-                         System.out.println(term + " is not a valid response");\r
-                     }\r
-                 } // while (!validInput)\r
-             } // if (traditionalInput)\r
-             HEADER("PARFUN",REDD,raFile);\r
-             if (SYMTY) {\r
-               SYINF1(ORDRG,ORDSG,RTUNI,U2,REFLN,CENSY,STAPT[0],\r
-                          STAPT[NARCS],IER);\r
-               if (IER[0] > 0) {\r
-                       WRTAIL(6,0,IER[0],null);\r
-                       return;\r
-               }\r
-               System.out.println("\nN O T E : THE ORDER OF THE SYMMETRY GROUP IS " + ORDSG);\r
-               if (REFLN) {\r
-                   System.out.println("          ISYGP = " + (-ORDSG[0]));     \r
-               }\r
-               else {\r
-                       System.out.println("          ISYGP = " + (ORDSG[0]));          \r
-               }\r
-               WRSYM1(NARCS,ORDRG[0],ORDSG[0],RTUNI,U2,CENSY,REFLN,true,REDD,CHNL,raFile);\r
-               if (REFLN) {\r
-                 CH = "TS";\r
-               }\r
-               else {\r
-                 CH = "TT";\r
-               }\r
-               WRFUN1(NARCS,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,CHNL,\r
-                        "IB",CH,"ZETA  ",REDD, raFile);\r
-               WRSYM2(NARCS,ORDRG[0],CENSY,REFLN,CHNL, raFile);\r
-             }\r
-             else {\r
-               WRFUN1(NARCS,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,CHNL,\r
-                      "IA","TT","PARFUN",REDD,raFile);\r
-             }\r
-       \r
-             try {\r
-                 raFile.writeBytes("//\n");\r
-                 raFile.writeBytes("}\n");\r
-         \r
-                // **** WRITE THE SOURCE CODE FOR DPARFN\r
-            \r
-                raFile.writeBytes("//...........................................\n");\r
-             }\r
-             catch (IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " in PARGEN");\r
-                 System.exit(-1);\r
-             }\r
-             HEADER("DPARFN",REDD,raFile);\r
-             if (SYMTY) {\r
-               WRSYM1(NARCS,ORDRG[0],ORDSG[0],RTUNI,U2,CENSY,REFLN,false,REDD,\r
-                      CHNL, raFile);\r
-               if (REFLN) {\r
-                 CH="TS";\r
-               }\r
-               else {\r
-                 CH="TT";\r
-               }\r
-               WRFUN2(NARCS,MNARC,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,\r
-                          CHNL,"IB",CH,"ZETA  ",NUMDER,REDD, raFile);\r
-               WRSYM3(NARCS,ORDRG[0],REFLN,CHNL, raFile);\r
-             } // if (SYMTY)\r
-             else {\r
-                 WRFUN2(NARCS,MNARC,STAPT,ARCTY,PGM,RGM,PTX,NTX,DEFN,\r
-                        CHNL,"IA","TT","DPARFN",NUMDER,REDD, raFile);\r
-             }\r
-       \r
-             try {\r
-                     raFile.writeBytes("//\n");\r
-                     raFile.writeBytes("}\n");\r
-                     raFile.close();\r
-             }\r
-             catch (IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " in PARGEN");\r
-                 System.exit(-1);\r
-             }\r
-             WRTAIL(6,0,IER[0], null);\r
-       \r
+               // .......................................................................\r
+               // AN INTERACTIVE PREPROCESSOR TO HELP THE C O N F P A C K USER\r
+               // GENERATE THE FORTRAN CODE DEFINING THE BOUNDARY PARAMETRISATION\r
+               // AND ITS DERIVATIVE.\r
+               //\r
+               // THE FOLLOWING CONVENTIONS ARE ASSUMED:\r
+               //\r
+               // ** IF A QUESTION REQUIRES A YES OR NO ANSWER, THE DETECTION OF 'Y' OR\r
+               // 'y' IN THE FIRST 6 INPUT CHARACTERS IS TAKEN AS YES, ANYTHING ELSE\r
+               // AS NO.\r
+               //\r
+               // ** WHEN ASKED FOR COORDINATES, THIS ALWAYS MEANS CARTESIAN COORDIN-\r
+               // ATES AND THESE SHOULD BE SUPPLIED AS TWO REAL NUMBERS, AS EITHER\r
+               //\r
+               // X,Y OR X Y\r
+               //\r
+               // WITHOUT PARENTHESES.\r
+               //\r
+               // ** FOUR TYPES OF ARCS ARE CURRENTLY TREATED, WITH NUMERICAL CODES TO\r
+               // DENOTE THE TYPE AS FOLLOWS:\r
+               // 1:= LINE SEGMENT.\r
+               // 2:= CIRCULAR ARC SEGMENT.\r
+               // CONVENTIONS:\r
+               // 1 - THE ANGLE SUBTENDED AT THE CENTRE IS POSITIVE FOR\r
+               // ANTICLOCKWISE TRAVERSAL OF THE ARC AND NEGATIVE FOR\r
+               // CLOCKWISE TRAVERSAL.\r
+               // 3:= THE USER IS ASKED TO SUPPLY THE FORTRAN 77 ARITHMETIC\r
+               // EXPRESSIONS WHICH DEFINE THE CARTESIAN PARAMETRIC FUNCTION\r
+               // AND THE DERIVATIVE OF THIS FUNCTION.\r
+               // CONVENTIONS:\r
+               // 1 - THE PARAMETER MUST BE DENOTED BY T.\r
+               // 2 - THE REAL CONSTANT PI=3.14159.. AND THE COMPLEX CONSTANT\r
+               // UI=(0.0,1.0) MAY BE USED IN THE ARITHMETIC EXPRESSIONS.\r
+               // 4:= THE USER IS ASKED TO SUPPLY THE FORTRAN 77 ARITHMETIC\r
+               // EXPRESSIONS WHICH DEFINE THE POLAR COORDINATE AS A FUNCTION\r
+               // OF POLAR ANGLE AND THE DERIVATIVE OF THIS FUNCTION.\r
+               // CONVENTIONS:\r
+               // 1 - THE POLAR ANGLE MUST BE DENOTED BY T.\r
+               // 2 - THE REAL CONSTANT PI=3.14159.. MAY BE USED IN THE ARITH-\r
+               // METIC EXPRESSIONS.\r
+               // 3 - PARGEN ASSIGNS THE EXPRESSION FOR THE RADIUS TO THE\r
+               // COMPLEX VARIABLE ZRAD; IF REQUIRED THE USER MAY THERE-\r
+               // FORE USE THE VARIABLE ZRAD IN THE EXPRESSION FOR THE\r
+               // DERIVATIVE OF THE RADIUS WRT POLAR ANGLE\r
+               // IN ADDITION, FOR TYPES 3 AND 4, THE FOLLOWING CONVENTIONS HOLD:\r
+               // 1 - ONLY USE UP TO 66 CHARACTERS PER LINE.\r
+               // 2 - IF THE EXPRESSION OCCUPIES MORE THAN ONE LINE THEN THERE\r
+               // IS NO NEED TO SUPPLY ANY CONTINUATION CHARACTER.\r
+               // 3 - ONLY USE THOSE FORTRAN 77 INTRINSIC MATHS FUNCTIONS\r
+               // WHICH ACCEPT COMPLEX ARGUMENTS AND ARE ANALYTIC; I.E.,\r
+               // IN STANDARD FORTRAN,\r
+               // SQRT, EXP, LOG, SIN, COS\r
+               // 4 - THE WHOLE EXPRESSION SHOULD BE TERMINATED WITH A\r
+               // REPEATED DIVISION SIGN, I.E. //.\r
+               //\r
+               // ** THE CODE ISN'T VERY ROBUST IN THAT THERE IS LITTLE PROVISION FOR\r
+               // INTERACTIVE CORRECTION OF ERRORS. HOWEVER, ALL THE USER'S INPUT\r
+               // IS AUTOMATICALLY OUTPUT TO A FILE NAMED pgenin. IF THE USER\r
+               // REALISES THAT AN ITEM HAS BEEN INPUT INCORRECTLY, THE BEST POLICY\r
+               // IS TO CARRY ON TO THE END OF THE INPUT PHASE AND THEN TERMINATE\r
+               // THE EXECUTION; THE FILE pgenin CAN BE EDITED, RENAMED AND\r
+               // SUBMITTED AS STANDARD INPUT FOR A SECOND RUN OF PARGEN.\r
+               // (THE SUGGESTION TO RENAME IS TO AVOID ANY POSSIBLE DIFFICULTY\r
+               // ARISING FROM READING THE FILE AS STANDARD INPUT WHILST ALSO\r
+               // WRITING OUTPUT TO THE SAME FILE.)\r
+               // IF THE USER REALISES ONLY AT A LATER STAGE (E.G. IN PLOTTING THE\r
+               // BOUNDARY) THAT AN ITEM HAS BEEN INPUT INCORRECTLY THEN pgenin\r
+               // MAY STILL BE AVAILABLE FOR RE-USE AS ABOVE.\r
+               //\r
+               // SUBROUTINES OR FUNCTIONS NEEDED\r
+               // - THE CONFPACK LIBRARY.\r
+               // - THE REAL FUNCTION R1MACH.\r
+               //\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, COVENTRY POLYTECHNIC, UK\r
+               // LAST UPDATE: 15 FEB 1991\r
+               // .......................................................................\r
+               //\r
+               // LOCAL VARIABLES\r
+               //\r
+               int GMCO, IA, I, J, L, SW, TXCO;\r
+               int TYPE = 1;\r
+               int IER[] = new int[1];\r
+               int ORDRG[] = new int[1];\r
+               int ORDSG[] = new int[1];\r
+               double ALPHA, PI, X, Y;\r
+               // COMPLEX CENSY,RTUNI,U2\r
+               double RTUNI[] = new double[2];\r
+               double U2[] = new double[2];\r
+               // CHARACTER TXT*72,TABC*6,FORTFL*72,CH*2,SIG(10)*2,WID(10)*2,REDD*6,\r
+               // +FMT1*8,FMT2*9\r
+               String TXT;\r
+               String CH;\r
+               String SIG[] = new String[] { "7", "8", "9", "10", "11", "12", "13", "14", "15", "16" };\r
+               String WID[] = new String[] { "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };\r
+               String REDD;\r
+               // String FMT1;\r
+               // String FMT2;\r
+\r
+               // PARAMETER (MNARC=100,TABC=' +',CHNL=20,CHIN=21)\r
+               final String TABC = "     +";\r
+               final int CHNL = 20;\r
+               // final int CHIN = 21;\r
+\r
+               File file;\r
+               RandomAccessFile raFile = null;\r
+               boolean validInput;\r
+\r
+               // EXTERNAL CHRIN,HEADER,R1MACH,SYINF1,WRFUN1,WRFUN2,WRHEAD,WRSYM1,\r
+               // +WRSYM2,WRSYM3,WRTAIL\r
+\r
+               WRHEAD(6, 0, null);\r
+\r
+               PI = Math.PI;\r
+\r
+               // **** DETERMINE NUMBER OF SIGNIFICANT FIGURES REQUIRED TO MATCH\r
+               // MACHINE\r
+               // **** PRECISION AND SET UP POINTER SW TO SIG AND WID\r
+\r
+               SW = (int) (-Math.log10(EPS)) + 2;\r
+               if (SW <= 7) {\r
+                       SW = 1;\r
+               } else if (SW >= 16) {\r
+                       SW = 10;\r
+               } else {\r
+                       SW = SW - 6;\r
+               }\r
+\r
+               // **** SET UP THE EDIT DESCRIPTOR AND FORMAT SPECIFICATION FOR FLOATING\r
+               // **** POINT OUTPUT\r
+\r
+               REDD = "E" + WID[SW - 1] + "." + SIG[SW - 1];\r
+               // FMT1="("+REDD+")";\r
+               // FMT2="(2"+REDD+")";\r
+\r
+               if (traditionalInput) {\r
+                       System.out.println("ENTER FILENAME TO RECEIVE OUTPUT JAVA CODE");\r
+                       FORTFL = input.next();\r
+               } // if (traditionalInput)\r
+\r
+               // **** WRITE THE SOURCE CODE FOR PARFUN\r
+               file = new File(fileDir + FORTFL);\r
+               try {\r
+                       raFile = new RandomAccessFile(file, "rw");\r
+               } catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " on raFile = new RandomAccessFile(file, rw)");\r
+                       System.exit(-1);\r
+               }\r
+               // Necessary so that if this is an overwritten file there isn't any\r
+               // junk at the end\r
+               try {\r
+                       raFile.setLength(0);\r
+               } catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " on raFile.setLength(0)");\r
+                       System.exit(-1);\r
+               }\r
+\r
+               // OPEN(CHNL,FILE=FORTFL)\r
+\r
+               if (traditionalInput) {\r
+                       validInput = false;\r
+                       while (!validInput) {\r
+                               System.out.println("DOES THE DOMAIN HAVE ANY SYMMETRY (Y/N)?");\r
+                               String sym = input.next();\r
+                               String firstSym = sym.substring(0, 1);\r
+                               if (firstSym.equalsIgnoreCase("Y")) {\r
+                                       SYMTY = true;\r
+                                       validInput = true;\r
+                               } else if (firstSym.equalsIgnoreCase("N")) {\r
+                                       SYMTY = false;\r
+                                       validInput = true;\r
+                               } else {\r
+                                       System.out.println(sym + " is not a valid response");\r
+                               }\r
+                       } // while (!validInput)\r
+\r
+                       if (SYMTY) {\r
+                               validInput = false;\r
+                               while (!validInput) {\r
+                                       System.out.println("ARE THERE ANY REFLECTIONAL SYMMETRIES (Y/N)?");\r
+                                       String ref = input.next();\r
+                                       String firstRef = ref.substring(0, 1);\r
+                                       if (firstRef.equalsIgnoreCase("Y")) {\r
+                                               REFLN = true;\r
+                                               validInput = true;\r
+                                       } else if (firstRef.equalsIgnoreCase("N")) {\r
+                                               REFLN = false;\r
+                                               validInput = true;\r
+                                       } else {\r
+                                               System.out.println(ref + " is not a valid response");\r
+                                       }\r
+                               } // while (!validInput)\r
+\r
+                               System.out.println("What are the coordinates of the center of symmetry (X Y)?");\r
+                               CENSY[0] = input.nextDouble();\r
+                               CENSY[1] = input.nextDouble();\r
+                               validInput = false;\r
+                               while (!validInput) {\r
+                                       System.out.println("How many arcs are there on the fundamental boundary section?");\r
+                                       NARCS = input.nextInt();\r
+                                       if (NARCS <= MNARC - 1) {\r
+                                               validInput = true;\r
+                                       } else {\r
+                                               System.out.println("NARCS must be <= " + (MNARC - 1));\r
+                                       }\r
+                               } // while (!validInput)\r
+                       } // if (SYMTY)\r
+                       else { // !SYMTY\r
+                               validInput = false;\r
+                               while (!validInput) {\r
+                                       System.out.println("How many arcs are there on the boundary?");\r
+                                       NARCS = input.nextInt();\r
+                                       if (NARCS <= MNARC - 1) {\r
+                                               validInput = true;\r
+                                       } else {\r
+                                               System.out.println("NARCS must be <= " + (MNARC - 1));\r
+                                       }\r
+                               } // while (!validInput)\r
+                       } // else !SYMTY\r
+\r
+                       GMCO = 0;\r
+                       TXCO = 0;\r
+\r
+                       for (IA = 1; IA <= NARCS; IA++) {\r
+                               NUMDER[IA - 1] = false;\r
+                               validInput = false;\r
+                               while (!validInput) {\r
+                                       System.out.println("ENTER THE TYPE OF ARC(1-4) for ARC NUMBER " + IA);\r
+                                       TYPE = input.nextInt();\r
+                                       if ((TYPE >= 1) && (TYPE <= 4)) {\r
+                                               validInput = true;\r
+                                       } else {\r
+                                               System.out.println("TYPE MUST BE BETWEEN 1 and 4");\r
+                                       }\r
+                               } // while (!validInput)\r
+                               if (TYPE == 1) {\r
+                                       ARCTY[IA - 1] = TYPE;\r
+                                       System.out.println("What are the coordinates of the initial point on the line (X Y)?");\r
+                                       STAPT[IA - 1][0] = input.nextDouble();\r
+                                       STAPT[IA - 1][1] = input.nextDouble();\r
+                               } // if (TYPE == 1)\r
+                               else if (TYPE == 2) {\r
+                                       ARCTY[IA - 1] = TYPE;\r
+                                       System.out.println("What are the coordinates of the initial point on the circle (X Y)?");\r
+                                       STAPT[IA - 1][0] = input.nextDouble();\r
+                                       STAPT[IA - 1][1] = input.nextDouble();\r
+                                       System.out.println("What are the coordinates of the center of the circle (X Y)?");\r
+                                       X = input.nextDouble();\r
+                                       Y = input.nextDouble();\r
+                                       System.out.println("What is the signed angle subtended at center (in units of PI)?");\r
+                                       ALPHA = input.nextDouble();\r
+                                       GMCO = GMCO + 1;\r
+                                       PGM[IA - 1] = GMCO;\r
+                                       RGM[GMCO - 1] = X;\r
+                                       GMCO = GMCO + 1;\r
+                                       RGM[GMCO - 1] = Y;\r
+                                       GMCO = GMCO + 1;\r
+                                       RGM[GMCO - 1] = ALPHA * PI;\r
+                               } // else if (TYPE == 2)\r
+                               else if ((TYPE == 3) || (TYPE == 4)) {\r
+                                       ARCTY[IA - 1] = TYPE;\r
+                                       System.out.println("What are the coordinates of the initial point on the curve (X Y)?");\r
+                                       STAPT[IA - 1][0] = input.nextDouble();\r
+                                       STAPT[IA - 1][1] = input.nextDouble();\r
+                                       if (TYPE == 3) {\r
+                                               System.out.println("Enter the initial and final parameter values (X Y)");\r
+                                       } else {\r
+                                               System.out.println("Enter the initial and final polar values (in angles of PI) (X Y)");\r
+                                       }\r
+                                       X = input.nextDouble();\r
+                                       Y = input.nextDouble();\r
+                                       GMCO = GMCO + 1;\r
+                                       PGM[IA - 1] = GMCO;\r
+                                       if (TYPE == 4) {\r
+                                               RGM[GMCO - 1] = X * PI;\r
+                                               GMCO = GMCO + 1;\r
+                                               RGM[GMCO - 1] = Y * PI;\r
+                                       } else {\r
+                                               RGM[GMCO - 1] = X;\r
+                                               GMCO = GMCO + 1;\r
+                                               RGM[GMCO - 1] = Y;\r
+                                       }\r
+                                       for (J = 1; J <= 2; J++) {\r
+                                               if (J == 1 && TYPE == 3) {\r
+                                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR PARFUN");\r
+                                                       System.out.println("PUT REAL PART ui IMAGINARY PART");\r
+                                               } else if (J == 2 && TYPE == 3) {\r
+                                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR DPARFN");\r
+                                                       System.out.println("PUT REAL PART ui IMAGINARY PART");\r
+                                               } else if (J == 1 && TYPE == 4) {\r
+                                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR RADIUS");\r
+                                               } else {\r
+                                                       System.out.println("ENTER JAVA EXPRESSION ENDING IN // FOR RADIUS DERIVATIVE");\r
+                                               }\r
+\r
+                                               TXCO = TXCO + 1;\r
+                                               PTX[IA - 1 + (J - 1) * MNARC] = TXCO;\r
+                                               I = 1;\r
+\r
+                                               TXT = input.next();\r
+                                               L = -1;\r
+                                               while (L == -1) {\r
+                                                       L = TXT.indexOf("//");\r
+                                                       if (L == -1) {\r
+                                                               DEFN[TXCO - 1] = TABC + TXT;\r
+                                                               I = I + 1;\r
+                                                               TXCO = TXCO + 1;\r
+                                                       } // if (L == -1)\r
+                                               } // while (L == -1)\r
+                                               NTX[IA - 1 + (J - 1) * MNARC] = I;\r
+                                               if (L == 0) {\r
+                                                       DEFN[TXCO - 1] = TABC;\r
+                                                       NUMDER[IA - 1] = true;\r
+                                               } else {\r
+                                                       DEFN[TXCO - 1] = TABC + TXT.substring(0, L);\r
+                                               }\r
+                                               if ((J == 1) && (TYPE == 4)) {\r
+                                                       System.out.println("(... = ZRAD)");\r
+                                               }\r
+                                       } // for (J = 1; J <= 2; J++)\r
+                               } // else if ((TYPE == 3) || (TYPE == 4))\r
+                       } // for (IA = 1; IA <= NARCS; IA++)\r
+\r
+                       if (SYMTY) {\r
+                               System.out.println("ENTER THE COORDINATES OF FINAL POINT ON THIS LAST ARC (X Y)");\r
+                               STAPT[NARCS][0] = input.nextDouble();\r
+                               STAPT[NARCS][1] = input.nextDouble();\r
+                       } else {\r
+                               STAPT[NARCS][0] = STAPT[0][0];\r
+                               STAPT[NARCS][1] = STAPT[0][1];\r
+                       }\r
+\r
+                       validInput = false;\r
+                       while (!validInput) {\r
+                               System.out.println("END OF INPUT PHASE; CONTINUE WITH PROCESSING (Y/N)?");\r
+                               String term = input.next();\r
+                               String firstTerm = term.substring(0, 1);\r
+                               if (firstTerm.equalsIgnoreCase("Y")) {\r
+                                       validInput = true;\r
+                               } else if (firstTerm.equalsIgnoreCase("N")) {\r
+                                       validInput = true;\r
+                                       setCompleted(false);\r
+                                       try {\r
+                                               raFile.close();\r
+                                       } catch (IOException e) {\r
+\r
+                                       }\r
+                                       return;\r
+                               } else {\r
+                                       System.out.println(term + " is not a valid response");\r
+                               }\r
+                       } // while (!validInput)\r
+               } // if (traditionalInput)\r
+               HEADER("PARFUN", REDD, raFile);\r
+               if (SYMTY) {\r
+                       SYINF1(ORDRG, ORDSG, RTUNI, U2, REFLN, CENSY, STAPT[0], STAPT[NARCS], IER);\r
+                       if (IER[0] > 0) {\r
+                               WRTAIL(6, 0, IER[0], null);\r
+                               return;\r
+                       }\r
+                       System.out.println("\nN O T E : THE ORDER OF THE SYMMETRY GROUP IS " + ORDSG);\r
+                       if (REFLN) {\r
+                               System.out.println("          ISYGP = " + (-ORDSG[0]));\r
+                       } else {\r
+                               System.out.println("          ISYGP = " + (ORDSG[0]));\r
+                       }\r
+                       WRSYM1(NARCS, ORDRG[0], ORDSG[0], RTUNI, U2, CENSY, REFLN, true, REDD, CHNL, raFile);\r
+                       if (REFLN) {\r
+                               CH = "TS";\r
+                       } else {\r
+                               CH = "TT";\r
+                       }\r
+                       WRFUN1(NARCS, STAPT, ARCTY, PGM, RGM, PTX, NTX, DEFN, CHNL, "IB", CH, "ZETA  ", REDD, raFile);\r
+                       WRSYM2(NARCS, ORDRG[0], CENSY, REFLN, CHNL, raFile);\r
+               } else {\r
+                       WRFUN1(NARCS, STAPT, ARCTY, PGM, RGM, PTX, NTX, DEFN, CHNL, "IA", "TT", "PARFUN", REDD, raFile);\r
+               }\r
+\r
+               try {\r
+                       raFile.writeBytes("//\n");\r
+                       raFile.writeBytes("}\n");\r
+\r
+                       // **** WRITE THE SOURCE CODE FOR DPARFN\r
+\r
+                       raFile.writeBytes("//...........................................\n");\r
+               } catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in PARGEN");\r
+                       System.exit(-1);\r
+               }\r
+               HEADER("DPARFN", REDD, raFile);\r
+               if (SYMTY) {\r
+                       WRSYM1(NARCS, ORDRG[0], ORDSG[0], RTUNI, U2, CENSY, REFLN, false, REDD, CHNL, raFile);\r
+                       if (REFLN) {\r
+                               CH = "TS";\r
+                       } else {\r
+                               CH = "TT";\r
+                       }\r
+                       WRFUN2(NARCS, MNARC, STAPT, ARCTY, PGM, RGM, PTX, NTX, DEFN, CHNL, "IB", CH, "ZETA  ", NUMDER, REDD,\r
+                                       raFile);\r
+                       WRSYM3(NARCS, ORDRG[0], REFLN, CHNL, raFile);\r
+               } // if (SYMTY)\r
+               else {\r
+                       WRFUN2(NARCS, MNARC, STAPT, ARCTY, PGM, RGM, PTX, NTX, DEFN, CHNL, "IA", "TT", "DPARFN", NUMDER, REDD,\r
+                                       raFile);\r
+               }\r
+\r
+               try {\r
+                       raFile.writeBytes("//\n");\r
+                       raFile.writeBytes("}\n");\r
+                       raFile.close();\r
+               } catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in PARGEN");\r
+                       System.exit(-1);\r
+               }\r
+               WRTAIL(6, 0, IER[0], null);\r
+\r
        } // public void PARGEN\r
-    private void HEADER(String TXT, String REDD, RandomAccessFile raFile) {\r
-\r
-    String TAB6="      ";\r
-\r
-    String LINE=TAB6+"private void "+TXT+"(int IA, double TT[]) {\n";\r
-    try {\r
-    raFile.writeBytes(LINE);\r
-\r
-    LINE="//" + TAB6+"IMPLICIT REAL(A-H,O-S),INTEGER(I-N),COMPLEX(T-Z)\n";\r
-    raFile.writeBytes(LINE);\r
-\r
-    raFile.writeBytes("      double PI = "+Math.PI+ ";\n");\r
-    raFile.writeBytes("      double UI[] = new double[]{0.0,1.0};\n");\r
-    raFile.writeBytes("//\n");\r
-    }\r
-    catch (IOException e) {\r
-       MipavUtil.displayError("IOException " + e + " in HEADER");\r
-       System.exit(-1);\r
-    }\r
-\r
-    } // private void HEADER\r
-    \r
-    private void SYINF1(int ORDRG[],int ORDSG[],double RTUNI[], double U2[],boolean REFLN,\r
-               double Z0[], double Z1[], double Z2[], int IER[]) {\r
-    //COMPLEX RTUNI,U2,Z0,Z1,Z2\r
-\r
-//**** GIVEN Z0,THE CENTRE OF SYMMETRY, Z1 AND Z2, THE INITIAL AND FINAL\r
-//**** POINTS ON THE FUNDAMENTAL BOUNDARY SECTION, REFLN, WHICH IS TRUE\r
-//**** IF THE SYMMETRY GROUP HAS IMPROPER  ROTATIONAL ELEMENTS\r
-//**** (I.E. REFLECTIONAL SYMMETRIES), THIS ROUTINE COMPUTES \r
-//**** ORDRG - THE ORDER OF THE SUBGROUP OF PROPER ROTATIONS (THIS IS THE\r
-//****         ORDER OF THE SYMMETRY GROUP IF REFLN=.FALSE.)\r
-//**** ORDSG - THE ORDER OF THE FULL SYMMETRY GROUP,  EITHER ORDRG OR \r
-//****         2*ORDRG DEPENDING ON WHETHER REFLN IS .FALSE. OR .TRUE.\r
-//**** RTUNI - THE ROOT OF UNITY FROM WHICH THE PROPER ROTATIONAL SUBROUP\r
-//****         IS GENERATED\r
-//**** U2    - THE ADDITIONAL IN-PLANE ROTATION WHICH, WHEN COMBINED WITH\r
-//****         CONJUGATION, DEFINES THE IMPROPER ROTATION FOR THE CASE\r
-//****         REFLN=.TRUE.\r
-\r
-//     LOCAL VARIABLES\r
-\r
-    double ALPHA, PI,SQRTEPS;\r
-    //COMPLEX CT,U\r
-    double CT[] = new double[2];\r
-    double U[] = new double[2];\r
-    double cr[] = new double[1];\r
-    double ci[] = new double[1];\r
-\r
-    PI=Math.PI;\r
-    SQRTEPS=Math.sqrt(EPS);\r
-    CT[0]=Z2[0]-Z0[0];\r
-    CT[1] = Z2[1] - Z0[1];\r
-    double ABSCT = zabs(CT[0], CT[1]);\r
-    if (ABSCT < SQRTEPS) {\r
-      IER[0]=56;\r
-      return;\r
-    }\r
-    U[0]=CT[0]/ABSCT;\r
-    U[1]= CT[1]/ABSCT;\r
-    zmlt(U[0],U[1],U[0],U[1], cr, ci);\r
-    U2[0] = cr[0];\r
-    U2[1] = ci[0];\r
-\r
-    zmlt(Z1[0]-Z0[0],Z1[1]-Z0[1],U[0],-U[1],cr,ci);\r
-    CT[0] = cr[0];\r
-    CT[1] = ci[0];\r
-    ABSCT = zabs(CT[0],CT[1]);\r
-    if (ABSCT < SQRTEPS) {\r
-      IER[0]=57;\r
-      return;\r
-    }\r
-    ALPHA=Math.atan2(CT[1],CT[0]);\r
-    ALPHA=Math.abs(ALPHA);\r
-\r
-    if (REFLN) {\r
-      ORDRG[0]=(int)Math.round(PI/ALPHA);\r
-      ORDSG[0]=2*ORDRG[0];\r
-    }\r
-    else {\r
-      ORDRG[0]=2*(int)Math.round(PI/ALPHA);\r
-      ORDSG[0]=ORDRG[0];\r
-    }\r
-\r
-    ALPHA=2.0*PI/(double)(ORDRG[0]);\r
-    RTUNI[0] = Math.cos(ALPHA);\r
-    RTUNI[1] = Math.sin(ALPHA);\r
-\r
-    // NORMAL EXIT\r
-\r
-    IER[0]=0;\r
-    return;\r
-    } // private void SYINF1\r
 \r
+       private void HEADER(String TXT, String REDD, RandomAccessFile raFile) {\r
 \r
-       \r
-      //COMPLEX FUNCTION PARFUN(I,T)\r
-      //INTEGER I\r
-      //COMPLEX T\r
-      double[] PARFUN(int I, double T[]) {\r
+               String TAB6 = "      ";\r
 \r
-          // DUMMY FUNCTION TO AID LINK-LOADING OF PARGEN\r
+               String LINE = TAB6 + "private void " + TXT + "(int IA, double TT[]) {\n";\r
+               try {\r
+                       raFile.writeBytes(LINE);\r
+\r
+                       LINE = "//" + TAB6 + "IMPLICIT REAL(A-H,O-S),INTEGER(I-N),COMPLEX(T-Z)\n";\r
+                       raFile.writeBytes(LINE);\r
+\r
+                       raFile.writeBytes("      double PI = " + Math.PI + ";\n");\r
+                       raFile.writeBytes("      double UI[] = new double[]{0.0,1.0};\n");\r
+                       raFile.writeBytes("//\n");\r
+               } catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in HEADER");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void HEADER\r
+\r
+       private void SYINF1(int ORDRG[], int ORDSG[], double RTUNI[], double U2[], boolean REFLN, double Z0[], double Z1[],\r
+                       double Z2[], int IER[]) {\r
+               // COMPLEX RTUNI,U2,Z0,Z1,Z2\r
+\r
+               // **** GIVEN Z0,THE CENTRE OF SYMMETRY, Z1 AND Z2, THE INITIAL AND\r
+               // FINAL\r
+               // **** POINTS ON THE FUNDAMENTAL BOUNDARY SECTION, REFLN, WHICH IS TRUE\r
+               // **** IF THE SYMMETRY GROUP HAS IMPROPER ROTATIONAL ELEMENTS\r
+               // **** (I.E. REFLECTIONAL SYMMETRIES), THIS ROUTINE COMPUTES\r
+               // **** ORDRG - THE ORDER OF THE SUBGROUP OF PROPER ROTATIONS (THIS IS\r
+               // THE\r
+               // **** ORDER OF THE SYMMETRY GROUP IF REFLN=.FALSE.)\r
+               // **** ORDSG - THE ORDER OF THE FULL SYMMETRY GROUP, EITHER ORDRG OR\r
+               // **** 2*ORDRG DEPENDING ON WHETHER REFLN IS .FALSE. OR .TRUE.\r
+               // **** RTUNI - THE ROOT OF UNITY FROM WHICH THE PROPER ROTATIONAL\r
+               // SUBROUP\r
+               // **** IS GENERATED\r
+               // **** U2 - THE ADDITIONAL IN-PLANE ROTATION WHICH, WHEN COMBINED WITH\r
+               // **** CONJUGATION, DEFINES THE IMPROPER ROTATION FOR THE CASE\r
+               // **** REFLN=.TRUE.\r
+\r
+               // LOCAL VARIABLES\r
+\r
+               double ALPHA, PI, SQRTEPS;\r
+               // COMPLEX CT,U\r
+               double CT[] = new double[2];\r
+               double U[] = new double[2];\r
+               double cr[] = new double[1];\r
+               double ci[] = new double[1];\r
+\r
+               PI = Math.PI;\r
+               SQRTEPS = Math.sqrt(EPS);\r
+               CT[0] = Z2[0] - Z0[0];\r
+               CT[1] = Z2[1] - Z0[1];\r
+               double ABSCT = zabs(CT[0], CT[1]);\r
+               if (ABSCT < SQRTEPS) {\r
+                       IER[0] = 56;\r
+                       return;\r
+               }\r
+               U[0] = CT[0] / ABSCT;\r
+               U[1] = CT[1] / ABSCT;\r
+               zmlt(U[0], U[1], U[0], U[1], cr, ci);\r
+               U2[0] = cr[0];\r
+               U2[1] = ci[0];\r
+\r
+               zmlt(Z1[0] - Z0[0], Z1[1] - Z0[1], U[0], -U[1], cr, ci);\r
+               CT[0] = cr[0];\r
+               CT[1] = ci[0];\r
+               ABSCT = zabs(CT[0], CT[1]);\r
+               if (ABSCT < SQRTEPS) {\r
+                       IER[0] = 57;\r
+                       return;\r
+               }\r
+               ALPHA = Math.atan2(CT[1], CT[0]);\r
+               ALPHA = Math.abs(ALPHA);\r
+\r
+               if (REFLN) {\r
+                       ORDRG[0] = (int) Math.round(PI / ALPHA);\r
+                       ORDSG[0] = 2 * ORDRG[0];\r
+               } else {\r
+                       ORDRG[0] = 2 * (int) Math.round(PI / ALPHA);\r
+                       ORDSG[0] = ORDRG[0];\r
+               }\r
+\r
+               ALPHA = 2.0 * PI / (double) (ORDRG[0]);\r
+               RTUNI[0] = Math.cos(ALPHA);\r
+               RTUNI[1] = Math.sin(ALPHA);\r
+\r
+               // NORMAL EXIT\r
+\r
+               IER[0] = 0;\r
+               return;\r
+       } // private void SYINF1\r
+\r
+       // COMPLEX FUNCTION PARFUN(I,T)\r
+       // INTEGER I\r
+       // COMPLEX T\r
+       double[] PARFUN(int I, double T[]) {\r
+\r
+               // DUMMY FUNCTION TO AID LINK-LOADING OF PARGEN\r
+\r
+               double result[] = new double[] { 1.0, 0.0 };\r
+               return result;\r
+       } // double[] PARFUN\r
+\r
+       // COMPLEX FUNCTION DPARFN(I,T)\r
+       // INTEGER I\r
+       // COMPLEX T\r
+       double[] DPARFN(int I, double T[]) {\r
+\r
+               // DUMMY FUNCTION TO AID LINK-LOADING OF PARGEN\r
+\r
+               double result[] = new double[] { 1.0, 0.0 };\r
+               return result;\r
+       } // double[] DPARFN\r
+\r
+       private void WRHEAD(int I, int CHNL, RandomAccessFile raFile) {\r
+\r
+               // **** WRITE A HEADING FOR THE MAIN CONFPACK MODULES JAPHYC (I=1),\r
+               // **** GQPHYC (I=2), JACANP (I=3), GQCANP (I=4), CNDPLT (I=5), THE\r
+               // **** PARAMETRIC FUNCTION GENERATOR PARGEN (I=6),THE PARAMETRIC\r
+               // FUNCTION\r
+               // **** TESTER TSTPLT (I=7) AND THE LEVEL CURVE ROUTINE LEVCUR (I=8). IF\r
+               // **** CHNL=0 THEN WRITE ON THE STANDARD OUTPUT CHANNEL, OTHERWISE\r
+               // WRITE\r
+               // **** ON THE CHANNEL SPECIFIED BY CHNL.\r
+               //\r
+               // LOCAL VARIABLES\r
+               //\r
+               String DOTS = ".................................................";\r
+               String CPHEAD = ": C O N F P A C K    M O D U L E    ";\r
+               String MOD[] = new String[] { "J A P H Y C :", "G Q P H Y C :", "J A C A N P :", "G Q C A N P :",\r
+                               "C N D P L T :", "P A R G E N :", "T S T P L T :", "L E V C U R :" };\r
+               String TXT = CPHEAD + MOD[I - 1];\r
+\r
+               if (CHNL == 0 || CHNL == 6) {\r
+                       System.out.println("\n\n      " + DOTS + "\n      " + TXT + "\n      " + DOTS);\r
+               } else {\r
+                       try {\r
+                               raFile.writeBytes("\n\n      //" + DOTS + "\n      //" + TXT + "\n      //" + DOTS + "\n");\r
+                       } catch (IOException e) {\r
+                               MipavUtil.displayError("IOException " + e + " on raFile.writeBytes in WRHEAD");\r
+                               System.exit(-1);\r
+                       }\r
+               }\r
+               return;\r
+       } // private void WRHEAD\r
+\r
+       private void WRTAIL(int I, int CHNL, int IER, RandomAccessFile raFile) {\r
+\r
+               //\r
+               // **** WRITE A CLOSING MESSAGE FOR THE MAIN CONFPACK MODULES JAPHYC\r
+               // (I=1)\r
+               // **** GQPHYC (I=2), JACANP (I=3), GQCANP (I=4), CNDPLT (I=5), THE\r
+               // PARA-\r
+               // **** METRIC FUNCTION GENERATOR PARGEN (I=6), THE PARAMETRIC FUNCTION\r
+               // **** TESTER TSTPLT (I=7) AND THE LEVEL CURVE ROUTINE LEVCUR (I=8). IF\r
+               // **** CHNL=0 THEN WRITE ON THE STANDARD OUTPUT CHANNEL, OTHERWISE\r
+               // WRITE\r
+               // **** ON THE CHANNEL SPECIFIED BY CHNL. THE TEXT OF THE MESSAGE IS\r
+               // **** DETERMINED BY THE ERROR NUMBER IER VIA THE SUBROUTINE IERTXT.\r
+\r
+               // LOCAL VARIABLES\r
+\r
+               String MOD[] = new String[] { "J A P H Y C :", "G Q P H Y C :", "J A C A N P :", "G Q C A N P :",\r
+                               "C N D P L T :", "P A R G E N :", "T S T P L T :", "L E V C U R :" };\r
+               String GOOD = "  NORMAL EXIT";\r
+               String BAD = "  ABNORMAL EXIT";\r
+               String LINE = "__________________________________________________________________&";\r
+\r
+               String TXT, TXT2;\r
+               if (IER == 0) {\r
+                       TXT = MOD[I - 1] + GOOD;\r
+               } else {\r
+                       TXT = MOD[I - 1] + BAD;\r
+               }\r
+               TXT2 = IERTXT(IER);\r
+\r
+               if ((CHNL == 0) || (CHNL == 6)) {\r
+                       System.out.println("\n\n      " + TXT);\r
+                       System.out.println("      " + TXT2);\r
+                       System.out.println(LINE);\r
+               } else {\r
+                       try {\r
+                               raFile.writeBytes("\n\n      //" + TXT + "\n");\r
+                               raFile.writeBytes("      //" + TXT2 + "\n");\r
+                               raFile.writeBytes("//" + LINE + "\n");\r
+                       } catch (IOException e) {\r
+                               MipavUtil.displayError("IOException " + e + " in WRTAIL");\r
+                               System.exit(-1);\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+\r
+       private String IERTXT(int IER) {\r
+\r
+               // **** SUPPLY ERROR MESSAGE TEXT FOR ERROR NUMBER IER\r
+               String result = null;\r
+               if (IER == 0) {\r
+                       result = " ";\r
+               } else if (IER == 1) {\r
+                       result = "PARAMETER IBNDS[0] IS TOO SMALL AT START OF JAPHYC";\r
+               } else if (IER == 2) {\r
+                       result = "PARAMETER IBNDS[1] IS TOO SMALL AT START OF JAPHYC";\r
+               } else if (IER == 3) {\r
+                       result = "NQPTS < 1 AT START OF JAPHYC";\r
+               } else if (IER == 4) {\r
+                       result = "FAILURE TO CONVERGE IN EIGSYS; CAN''T SET UP BASIC QUADRATURE RULES";\r
+               } else if (IER == 5) {\r
+                       result = "PARAMETER MNQPT IN IGNLVL MUST BE INCREASED TO AT LEAST NQPTS";\r
+               } else if (IER == 6) {\r
+                       result = "FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP IGNORE LEVELS";\r
+               } else if (IER == 7) {\r
+                       result = "FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP COLLOCATION POINTS";\r
+               } else if (IER == 8) {\r
+                       result = "ARGUMENT MNEQN IS TOO SMALL AT START OF JAPHYC";\r
+               } else if (IER == 9) {\r
+                       result = "PARAMETER IBNDS[3] IS TOO SMALL AT START OF JAPHYC";\r
+               } else if (IER == 10) {\r
+                       result = "PARAMETER NMAX IN SUBIN7 MUST BE INCREASED TO AT LEAST 2*NQPTS";\r
+               } else if (IER == 11) {\r
+                       result = "PARAMETER IBNDS[2] IS TOO SMALL AT START OF JAPHYC";\r
+               } else if (IER == 12) {\r
+                       result = "PARAMETER NC IN DEJAC7 AND DELEG7 MUST BE INCREASED";\r
+               } else if (IER == 13) {\r
+                       result = "PARAMETER NR IN DEJAC7 AND DELEG7 MUST BE >= (NQPTS -1)";\r
+               } else if (IER == 14) {\r
+                       result = "A CORNER ANGLE IS TOO SMALL; MAY CAUSE OVERFLOW IN GAMMA FUNCTION";\r
+               } else if (IER == 15) {\r
+                       result = "SINGULAR COLLOCATION MATRIX";\r
+               } else if (IER == 16) {\r
+                       result = "COLLOCATION MATRIX IS EFFECTIVELY SINGULAR";\r
+               } else if (IER == 17) {\r
+                       result = "NUMBER OF SUBARCS EXCEEDS IBNDS[0] DURING REFINEMENT";\r
+               } else if (IER == 18) {\r
+                       result = "NUMBER OF EQUATIONS EXCEEDS MNEQN DURING REFINEMENT";\r
+               } else if (IER == 19) {\r
+                       result = "TOTAL NUMBER OF QUADRATURE PTS EXCEEDS IBNDS[3] DURING REFINEMENT";\r
+               } else if (IER == 20) {\r
+                       result = "NUMBER OF QUADRATURE PANELS EXCEEDS IBNDS[2] DURING REFINEMENT";\r
+               } else if (IER == 21) {\r
+                       result = "FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP TEST POINTS";\r
+               } else if (IER == 22) {\r
+                       result = "ARGUMENT MQUPH OF GQPHYC MUST BE INCREASED";\r
+               } else if (IER == 23) {\r
+                       result = "PARAMETER MNCOF IN POPQF1 MUST BE >= NQPTS";\r
+               } else if (IER == 24) {\r
+                       result = "NUMBER OF QUADRATURE PANELS EXCEEDS MQIN1 IN GQPHYC";\r
+               } else if (IER == 25) {\r
+                       result = "PARAMETER MNXI IN DEPPJ8 AND DEPPL8 MUST BE INCREASED";\r
+               } else if (IER == 26) {\r
+                       result = "PARAMETER MAXNZ IN DEPPJ9 AND DEPPL9 MUST BE INCREASED";\r
+               } else if (IER == 27) {\r
+                       result = "PARAMETER MXNQD IN PHTCA1 MUST BE INCREASED";\r
+               } else if (IER == 28) {\r
+                       result = "PARAMETER MXCOF IN PHTCA1 MUST BE INCREASED";\r
+               } else if (IER == 29) {\r
+                       result = "PARAMETER MQIN1 IN PHTCA1 MUST BE INCREASED";\r
+               } else if (IER == 30) {\r
+                       result = "PARAMETER MNDG IN JCFIM5 MUST BE INCREASED";\r
+               } else if (IER == 31) {\r
+                       result = "PARAMETER MNQD IN JCFIM5 MUST BE INCREASED";\r
+               } else if (IER == 32) {\r
+                       result = "ARGUMENT IBNDS[1] SUPPLIED TO JACANP MUST BE INCREASED";\r
+               } else if (IER == 33) {\r
+                       result = "ARGUMENT IBNDS[0] SUPPLIED TO JACANP MUST BE INCREASED";\r
+               } else if (IER == 34) {\r
+                       result = "FN HAS SAME SIGN AT INTERVAL ENDS IN BISNEW; CAN''T SOLVE BCF EQN";\r
+               } else if (IER == 35) {\r
+                       result = "DERIVATIVE OF BCF IS ZERO IN BISNEW; CAN''T SOLVE BCF EQN";\r
+               } else if (IER == 36) {\r
+                       result = "ELEMENT OF ARGUMENT ARRAY SVAL IN RHOFN IS +-1; CAN''T CONTINUE";\r
+               } else if (IER == 37) {\r
+                       result = "PARAMETER MXNQD IN CINRAD MUST BE INCREASED";\r
+               } else if (IER == 38) {\r
+                       result = "PARAMETER MXCOF IN CINRAD MUST BE INCREASED";\r
+               } else if (IER == 39) {\r
+                       result = "CENTRE POINT IS PATHOLOGICALLY CLOSE TO BOUNDARY;CAN''T CONTINUE";\r
+               } else if (IER == 40) {\r
+                       result = "PARAMETER MQIN1 IN CINRAD MUST BE INCREASED";\r
+               } else if (IER == 41) {\r
+                       result = "ARGUMENT MQUCA OF GQCANP MUST BE INCREASED";\r
+               } else if (IER == 42) {\r
+                       result = "PARAMETER MNCOF IN POPQG1 MUST BE >= NQPTS";\r
+               } else if (IER == 43) {\r
+                       result = "NUMBER OF QUADRATURE PANELS EXCEEDS MQIN1 IN GQCANP";\r
+               } else if (IER == 44) {\r
+                       result = "PARAMETER MNCOF IN BMPHC1 MUST BE >= NQPTS";\r
+               } else if (IER == 45) {\r
+                       result = "ARGUMENTS IARC, PHYPT OF BMPHYC DON''T DEFINE A BOUNDARY POINT";\r
+               } else if (IER == 46) {\r
+                       result = "PARAMETER MNCOF IN BMCAP1 MUST BE >= NQPTS";\r
+               } else if (IER == 47) {\r
+                       result = "PARAMETER MXNQD IN CATPH4 MUST BE INCREASED";\r
+               } else if (IER == 48) {\r
+                       result = "PARAMETER MNCOF IN CATPH4 MUST BE >= NQPTS";\r
+               } else if (IER == 49) {\r
+                       result = "PARAMETER MQIN1 IN CATPH4 MUST BE INCREASED";\r
+               } else if (IER == 50) {\r
+                       result = "PARAMETER MXCOF IN DIAGN3 MUST BE >= NQPTS";\r
+               } else if (IER == 51) {\r
+                       result = "NON-ANALYTIC ARC DETECTED IN DIAGN3";\r
+               } else if (IER == 52) {\r
+                       result = "PARAMETER MAXSA IN CNDPLT MUST BE INCREASED";\r
+               } else if (IER == 53) {\r
+                       result = "OVERFLOW EXPECTED IN IGNLVL; A CORNER ANGLE IS TOO SMALL";\r
+               } else if (IER == 54) {\r
+                       result = "PARAMETER MXCO IN AXION1 MUST BE INCREASED";\r
+               } else if (IER == 55) {\r
+                       result = "NARCS ISN''T AN INTEGER MULTIPLE OF THE ORDER OF THE SYMMETRY GROUP";\r
+               } else if (IER == 56) {\r
+                       result = "CENTRE OF SYMMETRY IS PATHOLOGICALLY CLOSE TO LAST POINT ON FBS";\r
+               } else if (IER == 57) {\r
+                       result = "CENTRE OF SYMMETRY IS PATHOLOGICALLY CLOSE TO FIRST POINT ON FBS";\r
+               } else if (IER == 58) {\r
+                       result = "NUMBER OF ARCS IS TOO BIG; INCREASE PARAMETER MNARC IN PARGEN";\r
+               } else if (IER == 59) {\r
+                       result = "NUMBER OF ARCS IS TOO BIG; INCREASE PARAMETER MNARC IN TSTPLT";\r
+               } else if (IER == 60) {\r
+                       result = "NON-ANALYTIC ARC (DPARFN=(0.,0.)) DETECTED IN TSTPLT";\r
+               } else {\r
+                       result = "UNRECOGNIZED ERROR NUMBER IN IERTXT ROUTINE !!";\r
+               }\r
+               return result;\r
+       }\r
+\r
+       private void WRSYM1(int NARCS, int ORDRG, int ORDSG, double[] RTUNI, double[] U2, double[] CENSY, boolean REFLN,\r
+                       boolean PARFUN, String REDD, int CHNL, RandomAccessFile raFile) {\r
+               // COMPLEX RTUNI,U2,CENSY\r
+\r
+               // **** TO WRITE THE DIMENSION AND PARAMETER STATEMENTS AND THE CODE TO\r
+               // **** TO REDUCE A GIVEN ARC NUMBER TO ITS SYMMETRIC COUNTERPART ON THE\r
+               // **** FUNDAMENTAL BOUNDARY SECTION.\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 4 AUG 1990\r
+               // .......................................................................C\r
+               // LOCAL VARIABLES\r
+\r
+               int I;\r
+               double R, A;\r
+               // COMPLEX ZT\r
+               double ZT[] = new double[2];\r
+               boolean NEEDC;\r
+               // String FMT;\r
+               double cr[] = new double[1];\r
+               double ci[] = new double[1];\r
+\r
+               // FMT="(A12,"+REDD+",A1,"+REDD+",A2)";\r
+\r
+               try {\r
+                       if (PARFUN) {\r
+                               NEEDC = ((CENSY[0] != 0.0) || (CENSY[1] != 0.0));\r
+                               if (NEEDC || REFLN) {\r
+                                       raFile.writeBytes("      PARAMETER (\n");\r
+                                       if (NEEDC && REFLN) {\r
+                                               R = U2[0];\r
+                                               A = U2[1];\r
+                                               raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                                               raFile.writeBytes("U2[1] = " + A + ";\n");\r
+                                               R = CENSY[0];\r
+                                               A = CENSY[1];\r
+                                               raFile.writeBytes("ZCEN[0] = " + R + ";\n");\r
+                                               raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
+                                       } // if (NEEDC && REFLN)\r
+                                       else if (NEEDC && (!REFLN)) {\r
+                                               R = CENSY[0];\r
+                                               A = CENSY[1];\r
+                                               raFile.writeBytes("ZCEN[0] = " + R + ";\n");\r
+                                               raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
+                                       } // else if (NEEDC && (!REFLN))\r
+                                       else {\r
+                                               R = U2[0];\r
+                                               A = U2[1];\r
+                                               raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                                               raFile.writeBytes("U2[1] = " + A + ";)\n");\r
+                                       } // else\r
+                                       raFile.writeBytes("//\n");\r
+                               } // if (NEEDC || REFLN)\r
+                       } else if (REFLN) {\r
+                               R = U2[0];\r
+                               A = U2[1];\r
+                               raFile.writeBytes("      PARAMETER (\n");\r
+                               raFile.writeBytes("U2[0] = " + R + ";\n");\r
+                               raFile.writeBytes("U2[1] = " + A + ";)\n");\r
+                               raFile.writeBytes("//\n");\r
+                       }\r
+\r
+                       // FMT="(A7,"+REDD+",A1,"+REDD+",A2)";\r
+\r
+                       if (ORDRG >= 2) {\r
+                               raFile.writeBytes("double WW[] = new double[" + (ORDRG - 1) + "];\n");\r
+                               ZT[0] = 1.0;\r
+                               ZT[1] = 0.0;\r
+                               for (I = 0; I < ORDRG - 2; I++) {\r
+                                       zmlt(ZT[0], ZT[1], RTUNI[0], RTUNI[1], cr, ci);\r
+                                       ZT[0] = cr[0];\r
+                                       ZT[1] = ci[0];\r
+                                       raFile.writeBytes("WW[" + I + "][0] = " + ZT[0] + ";\n");\r
+                                       raFile.writeBytes("WW[" + I + "][1] = " + ZT[1] + ";\n");\r
+                               }\r
+                               zmlt(ZT[0], ZT[1], RTUNI[0], RTUNI[1], cr, ci);\r
+                               ZT[0] = cr[0];\r
+                               ZT[1] = ci[0];\r
+                               raFile.writeBytes("WW[" + I + "][0] = " + ZT[0] + ";\n");\r
+                               raFile.writeBytes("WW[" + I + "][1] = " + ZT[1] + ";)\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // if (ORDRG >= 2)\r
+\r
+                       if (ORDRG > 19) {\r
+                               System.out.println("\n");\r
+                               System.out.println("             ****WARNING****");\r
+                               System.out.println("MORE THAN 19 CONTINUTATION LINES HAVE BEEN WRITTEN");\r
+                       }\r
+\r
+                       if (REFLN) {\r
+                               if (ORDRG > 1) {\r
+                                       if (NARCS > 1) {\r
+                                               I = 2 * NARCS;\r
+                                               raFile.writeBytes("IB = IA%" + I + ";\n");\r
+                                               raFile.writeBytes("if (IB == 0) IB = " + I + ";\n");\r
+                                               I = I + 1;\r
+                                               raFile.writeBytes("if (IB > " + NARCS + ") {\n");\r
+                                               raFile.writeBytes("    IB = " + I + " - IB;\n");\r
+                                               raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                               raFile.writeBytes("else {\n");\r
+                                               raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                       } // if (NARCS > 1)\r
+                                       else {\r
+                                               raFile.writeBytes("if ((IA%2) == 0) {\n");\r
+                                               raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                               raFile.writeBytes("else {\n");\r
+                                               raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                       } // else\r
+                               } // if (ORDRG > 1)\r
+                               else {\r
+                                       if (NARCS > 1) {\r
+                                               I = 2 * NARCS + 1;\r
+                                               raFile.writeBytes("if (IA > " + NARCS + "){\n");\r
+                                               raFile.writeBytes("    IB = " + I + " -IA;\n");\r
+                                               raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                               raFile.writeBytes("else {\n");\r
+                                               raFile.writeBytes("    IB = IA;\n");\r
+                                               raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                       } // if (NARCS)\r
+                                       else {\r
+                                               raFile.writeBytes("if (IA == 2) {\n");\r
+                                               raFile.writeBytes("    TS[0] = -TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1]);\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                               raFile.writeBytes("else {\n");\r
+                                               raFile.writeBytes("    TS[0] = TT[0];\n");\r
+                                               raFile.writeBytes("    TS[1] = TT[1];\n");\r
+                                               raFile.writeBytes("}\n");\r
+                                       } // else\r
+                               } // else\r
+                       } // if (REFLN)\r
+                       else if (NARCS > 1) {\r
+                               raFile.writeBytes("IB = IA%" + NARCS + ";\n");\r
+                               raFile.writeBytes("if (IB == 0) IB = " + NARCS + ";\n");\r
+                       } // else if (NARCS > 1)\r
+\r
+                       raFile.writeBytes("//\n");\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRSYM1");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       }\r
+\r
+       private void WRFUN1(int NARCS, double STAPT[][], int ARCTY[], int PGM[], double RGM[], int PTX[], int NTX[],\r
+                       String DEFN[], int CHNL, String CHIA, String CHTT, String VAR, String REDD, RandomAccessFile raFile) {\r
+               // COMPLEX STAPT(*)\r
+               // CHARACTER DEFN(*)*72,CHIA*2,CHTT*2,VAR*6,REDD*6\r
+\r
+               // **** TO WRITE THE SOURCE CODE FOR PARFUN IN THE CASE WHERE NO\r
+               // **** SYMMETRY IS INVOLVED.\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 4 AUG 1990\r
+               // .......................................................................\r
+\r
+               // LOCAL VARIABLES\r
+\r
+               int IA, I, J, K;\r
+               // CHARACTER TX1*16,TX2*21,FMT1*11,FMT2*11\r
+               String TX1, TX2;\r
+               // String FMT1,FMT2;\r
+               // EXTERNAL PTFUN1\r
+               TX1 = "     if(" + CHIA + " == ";\r
+               TX2 = "     else if(" + CHIA + " == ";\r
+               // FMT1="(A16,I3,A6)";\r
+               // FMT2="(A21,I3,A6)";\r
+               double STAPT2[][];\r
+               double RGM2[];\r
+               String DEFN2[];\r
+\r
+               try {\r
+                       for (IA = 1; IA <= NARCS; IA++) {\r
+                               I = PGM[IA - 1];\r
+                               J = PTX[IA - 1];\r
+                               STAPT2 = new double[STAPT.length - IA + 1][2];\r
+                               for (K = IA; K <= STAPT.length; K++) {\r
+                                       STAPT2[K - IA] = STAPT[K - 1];\r
+                               }\r
+                               RGM2 = new double[RGM.length - I + 1];\r
+                               for (K = I; K <= RGM.length; K++) {\r
+                                       RGM2[K - I] = RGM[K - 1];\r
+                               }\r
+                               DEFN2 = new String[DEFN.length - J + 1];\r
+                               for (K = J; K <= DEFN.length; K++) {\r
+                                       DEFN2[K - J] = DEFN[K - 1];\r
+                               }\r
+                               if (NARCS == 1) {\r
+                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile);\r
+                               } else {\r
+                                       if (IA == 1) {\r
+                                               raFile.writeBytes(TX1 + IA + ") {\n");\r
+                                       } else if (IA == NARCS) {\r
+                                               raFile.writeBytes("      else {\n");\r
+                                       } else {\r
+                                               raFile.writeBytes(TX2 + IA + ") {\n");\r
+                                       }\r
+                                       PTFUN1(ARCTY[IA - 1], STAPT2, RGM2, NTX[IA - 1], DEFN2, CHNL, CHTT, VAR, REDD, raFile);\r
+                                       if (IA == NARCS)\r
+                                               raFile.writeBytes("      }\n");\r
+                               } // else\r
+                       } // for (IA=1; IA <= NARCS; IA++)\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRFUN1");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void WRFUN1\r
+\r
+       private void PTFUN1(int TYPE, double STAPT[][], double RGM[], int NTX, String TXT[], int CHNL, String CHTT,\r
+                       String VAR, String REDD, RandomAccessFile raFile) {\r
+\r
+               // COMPLEX STAPT(*)\r
+               // CHARACTER TXT(*)*72,CHTT*2,VAR*6,REDD*6\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 8 AUG 1990\r
+               // .......................................................................C\r
+               // **** LOCAL VARIABLES\r
+\r
+               int I;\r
+               double HA, MD, RAD;\r
+               double C1[] = new double[2];\r
+               double C2[] = new double[2];\r
+               double CENTR[] = new double[2];\r
+               // COMPLEX C1,C2,CENTR\r
+               // String TX1, TX1B, TX2;\r
+               // String TX2B, CTX1B, FMT1, FMT2, FMT3, FMT4, FMT5;\r
+               // CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,CTX1B*10,\r
+               // +FMT1*25,FMT2*25,FMT3*14,FMT4*25,FMT5*24\r
+\r
+               // TX1 = "+"+CHTT+"*";\r
+               // TX1B = TX1 + "(";\r
+               // CTX1B=" " + TX1B;\r
+               // TX2=" "+VAR+" = ";\r
+               // TX2B=TX2+"(";\r
+\r
+               // FMT1='(A14,'//REDD//',A1,'//REDD//',A2)'\r
+               // FMT2='(A10,'//REDD//',A1,'//REDD//',A1)'\r
+               // FMT3='(A6,'//REDD//',A1)'\r
+               // FMT4='(A14,'//REDD//',A5,'//REDD//',A3)'\r
+               // FMT5='(A8,'//REDD//',A5,'//REDD//',A1)'\r
+\r
+               try {\r
+                       if (TYPE == 1) {\r
+                               C1[0] = 0.5 * (STAPT[1][0] + STAPT[0][0]);\r
+                               C1[1] = 0.5 * (STAPT[1][1] + STAPT[0][1]);\r
+                               C2[0] = 0.5 * (STAPT[1][0] - STAPT[0][0]);\r
+                               C2[1] = 0.5 * (STAPT[1][1] - STAPT[0][1]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes(\r
+                                               VAR + "[0] = " + C1[0] + "+" + CHTT + "[0]*" + C2[0] + " - " + CHTT + "[1]*" + C2[1] + ";\n");\r
+                               raFile.writeBytes(\r
+                                               VAR + "[1] = " + C1[1] + "+" + CHTT + "[0]*" + C2[1] + " + " + CHTT + "[1]*" + C2[0] + ";\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // if (TYPE == 1)\r
+                       else if (TYPE == 2) {\r
+                               CENTR[0] = RGM[0];\r
+                               CENTR[1] = RGM[1];\r
+                               C1[0] = STAPT[0][0] - CENTR[0];\r
+                               C1[1] = STAPT[0][1] - CENTR[1];\r
+                               HA = 0.5 * RGM[2];\r
+                               MD = Math.atan2(C1[1], C1[0]) + HA;\r
+                               RAD = zabs(C1[0], C1[1]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes(VAR + "[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*" + HA\r
+                                               + ")*" + "Math.cos(" + MD + CHTT + "[0]*" + HA + ");\n");\r
+                               raFile.writeBytes(VAR + "[1] = " + CENTR[1] + "+" + RAD + " * " + "Math.exp(-" + CHTT + "[1]*" + HA\r
+                                               + ")*" + "Math.sin(" + MD + CHTT + "[0]*" + HA + ");\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // else if (TYPE == 2)\r
+                       else if (TYPE == 3) {\r
+                               MD = 0.5 * (RGM[1] + RGM[0]);\r
+                               HA = 0.5 * (RGM[1] - RGM[0]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * " + HA + ";\n");\r
+                               raFile.writeBytes("T[1] = " + MD + "+" + CHTT + "[1] * " + HA + ";\n");\r
+\r
+                               raFile.writeBytes(VAR + "[0] = ");\r
+                               // NTX = 1 if statements are entered without newlines for\r
+                               // multiple lines\r
+                               for (I = 1; I <= NTX; I++) {\r
+                                       int index = TXT[I - 1].indexOf("ui");\r
+                                       String realString = null;\r
+                                       if (index == -1) {\r
+                                               realString = TXT[I - 1];\r
+                                       } else {\r
+                                               realString = TXT[I - 1].substring(0, index);\r
+                                       }\r
+                                       if ((index == -1) || (index > 0)) {\r
+                                               raFile.writeBytes(realString);\r
+                                       }\r
+                                       if (I == NTX) {\r
+                                               raFile.writeBytes(";\n");\r
+                                       }\r
+                               }\r
+                               raFile.writeBytes(VAR + "[1] = ");\r
+                               // NTX = 1 if statements are entered without newlines for\r
+                               // multiple lines\r
+                               for (I = 1; I <= NTX; I++) {\r
+                                       int index = TXT[I - 1].indexOf("ui");\r
+                                       String imagString = null;\r
+                                       if ((index >= 0) && (index + 2 < TXT[I - 1].length())) {\r
+                                               imagString = TXT[I - 1].substring(index + 2);\r
+                                               raFile.writeBytes(imagString);\r
+                                       }\r
+                                       if (I == NTX) {\r
+                                               raFile.writeBytes(";\n");\r
+                                       }\r
+                               }\r
+                               raFile.writeBytes("//\n");\r
+                       } // else if (TYPE == 3)\r
+                       else {\r
+                               MD = 0.5 * (RGM[1] + RGM[0]);\r
+                               HA = 0.5 * (RGM[1] - RGM[0]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * " + HA + ";\n");\r
+                               raFile.writeBytes("T[1] = " + MD + "+" + CHTT + "[1] * " + HA + ";\n");\r
+                               raFile.writeBytes("     ZRAD = ");\r
+                               // NTX = 1 if statements are entered without newlines for\r
+                               // multiple lines\r
+                               for (I = 1; I <= NTX; I++) {\r
+                                       raFile.writeBytes(TXT[I - 1]);\r
+                               }\r
+                               raFile.writeBytes(VAR + "[0] = Math.exp(-T[1])*(ZRAD * Math.cos(T[0]));\n");\r
+                               raFile.writeBytes(VAR + "[1] = Math.exp(-T[1])*(ZRAD * Math.sin(T[0]));\n");\r
+                               raFile.writeBytes("//\n");\r
+                       }\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in PTFUN1");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void PTFUN1\r
+\r
+       private void WRSYM2(int NARCS, int ORDRG, double CENSY[], boolean REFLN, int CHNL, RandomAccessFile raFile) {\r
+\r
+               // COMPLEX CENSY\r
+\r
+               // **** TO WRITE THE CODE TO RECOVER THE BOUNDARY POINT FROM ITS\r
+               // SYMMETRIC\r
+               // **** COUNTERPART ON THE FUNDAMENTAL BOUNDARY SECTION.\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 4 AUG 1990\r
+               // .......................................................................C\r
+               // LOCAL VARIABLES\r
+\r
+               int I;\r
+               boolean NEEDC;\r
+\r
+               NEEDC = ((CENSY[0] != 0.0) || (CENSY[1] != 0.0));\r
+               try {\r
+                       raFile.writeBytes("//\n");\r
+\r
+                       if (REFLN) {\r
+                               if (ORDRG > 1) {\r
+                                       I = 2 * NARCS;\r
+                                       if (NARCS > 1) {\r
+                                               raFile.writeBytes("IS = (IA-IB)%" + I + ";\n");\r
+                                               raFile.writeBytes("IR = (IA-IB-IS)/" + I + ";\n");\r
+                                       } // if (NARCS > 1)\r
+                                       else {\r
+                                               raFile.writeBytes("IS = (IA-1)%2;\n");\r
+                                               raFile.writeBytes("IR = (IA-1-IS)/2;\n");\r
+                                       }\r
+                                       raFile.writeBytes("if ((IR == 0) && (IS == 0)) {\n");\r
+                                       raFile.writeBytes("    PARFUN[0] = ZETA[0];\n");\r
+                                       raFile.writeBytes("    PARFUN[1] = ZETA[1];\n");\r
+                                       raFile.writeBytes("}\n");\r
+                                       raFile.writeBytes("else if ((IR > 0) && (IS == 0)) {\n");\r
+                                       if (NEEDC) {\r
+                                               raFile.writeBytes("    PARFUN[0] = ZCEN[0] + WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
+                                                               + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
+                                               raFile.writeBytes("    PARFUN[1] = ZCEN[1] + WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
+                                                               + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
+                                       } // if (NEEDC)\r
+                                       else {\r
+                                               raFile.writeBytes("PARFUN[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
+                                       }\r
+                                       raFile.writeBytes("else if ((IR == 0) && (IS > 0)) {\n");\r
+                                       if (NEEDC) {\r
+                                               raFile.writeBytes(\r
+                                                               "    PARFUN[0] = ZCEN[0] + U2[0]*(ZETA[0]-ZCEN[0]) + " + "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
+                                               raFile.writeBytes(\r
+                                                               "    PARFUN[1] = ZCEN[1] - U2[0]*(ZETA[1]-ZCEN[1]) + " + "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("    PARFUN[0] = U2[0]*ZETA[0] + U2[1]*ZETA[1];\n");\r
+                                               raFile.writeBytes("    PARFUN[1] = -U2[0]*ZETA[1] + U2[1]*ZETA[0];\n");\r
+                                       }\r
+                                       raFile.writeBytes("}\n");\r
+                                       raFile.writeBytes("else {\n");\r
+                                       if (NEEDC) {\r
+                                               raFile.writeBytes("double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
+                                               raFile.writeBytes("double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
+                                               raFile.writeBytes("PARFUN[0] = ZCEN[0] + realPart*(ZETA[0]-ZCEN[0]) + "\r
+                                                               + "imagPart*(ZETA[1]-ZCEN[1]);\n");\r
+                                               raFile.writeBytes("PARFUN[1] = ZCEN[1] - realPart*(ZETA[1]-ZCEN[1]) + "\r
+                                                               + "imagPart*(ZETA[0]-ZCEN[0]);\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
+                                               raFile.writeBytes("double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
+                                               raFile.writeBytes("PARFUN[0] = realPart * ZETA[0] + imagPart * ZETA[1];\n");\r
+                                               raFile.writeBytes("PARFUN[1] = -realPart * ZETA[1] + imagPart * ZETA[0];\n");\r
+                                       }\r
+                                       raFile.writeBytes("}\n");\r
+                               } // if (ORDRG > 1)\r
+                               else { // ORDRG <= 1\r
+                                       if (NARCS > 1) {\r
+                                               raFile.writeBytes("IS = IA - IB;\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("IS = IA - 1;\n");\r
+                                       }\r
+                                       raFile.writeBytes("if (IS == 0) {\n");\r
+                                       raFile.writeBytes("    PARFUN[0] = ZETA[0];\n");\r
+                                       raFile.writeBytes("    PARFUN[1] = ZETA[1];\n");\r
+                                       raFile.writeBytes("}\n");\r
+                                       raFile.writeBytes("else {\n");\r
+                                       if (NEEDC) {\r
+                                               raFile.writeBytes(\r
+                                                               "    PARFUN[0] = ZCEN[0] + U2[0]*(ZETA[0]-ZCEN[0]) + " + "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
+                                               raFile.writeBytes(\r
+                                                               "    PARFUN[1] = ZCEN[1] - U2[0]*(ZETA[1]-ZCEN[1]) + " + "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("    PARFUN[0] = U2[0]*(ZETA[0]-ZCEN[0]) + " + "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
+                                               raFile.writeBytes(\r
+                                                               "    PARFUN[1] =  -U2[0]*(ZETA[1]-ZCEN[1]) + " + "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
+                                       }\r
+                                       raFile.writeBytes("}\n");\r
+                               } // else ORDRG <= 1\r
+                       } // if (REFLN)\r
+                       else { // !REFLN\r
+                               if (NARCS > 1) {\r
+                                       raFile.writeBytes("IR = (IA - IB)/" + NARCS + ";\n");\r
+                               } else {\r
+                                       raFile.writeBytes("IR = IA - 1;\n");\r
+                               }\r
+                               raFile.writeBytes("if (IR == 0) {\n");\r
+                               raFile.writeBytes("PARFUN[0] = ZETA[0]);\n");\r
+                               raFile.writeBytes("PARFUN[1] = ZETA[1]);\n");\r
+                               raFile.writeBytes("}\n");\r
+                               raFile.writeBytes("else {\n");\r
+                               if (NEEDC) {\r
+                                       raFile.writeBytes("    PARFUN[0] = ZCEN[0] + WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
+                                                       + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
+                                       raFile.writeBytes("    PARFUN[1] = ZCEN[1] + WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
+                                                       + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
+                               } else {\r
+                                       raFile.writeBytes("    PARFUN[0] = WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
+                                                       + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
+                                       raFile.writeBytes("    PARFUN[1] = WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
+                                                       + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
+                               }\r
+                               raFile.writeBytes("}\n");\r
+                       } // else !REFLN\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRSYM2");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void WRSYM2\r
+\r
+       private void WRFUN2(int NARCS, int MNARC, double STAPT[][], int ARCTY[], int PGM[], double RGM[], int PTX[],\r
+                       int NTX[], String DEFN[], int CHNL, String CHIA, String CHTT, String VAR, boolean NUMDER[], String REDD,\r
+                       RandomAccessFile raFile) {\r
+\r
+               // COMPLEX STAPT(*)\r
+               // CHARACTER DEFN(*)*72,CHIA*2,CHTT*2,VAR*6,REDD*6\r
+\r
+               // **** TO WRITE THE SOURCE CODE FOR DPARFN IN THE CASE WHERE NO\r
+               // **** SYMMETRY IS INVOLVED.\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 4 AUG 1990\r
+               // .......................................................................\r
+\r
+               // LOCAL VARIABLES\r
+\r
+               int IA, I, J1, J2, N1, N2;\r
+               String TX1, TX2;\r
+               // String FMT1, FMT2;\r
+               // CHARACTER TX1*16,TX2*21,FMT1*11,FMT2*11\r
+               // EXTERNAL PTFUN2\r
+               double STAPT2[][];\r
+               double RGM2[];\r
+               String DEFN2[];\r
+               String DEFN3[];\r
+               int K;\r
+\r
+               TX1 = "      if (" + CHIA + " == ";\r
+               TX2 = "      else if (" + CHIA + " == ";\r
+               // FMT1="(A16,I3,A6)";\r
+               // FMT2="(A21,I3,A6)";\r
+\r
+               try {\r
+                       for (IA = 1; IA <= NARCS; IA++) {\r
+                               I = PGM[IA - 1];\r
+                               J1 = PTX[IA - 1];\r
+                               J2 = PTX[IA + MNARC - 1];\r
+                               N1 = NTX[IA - 1];\r
+                               N2 = NTX[IA + MNARC - 1];\r
+                               STAPT2 = new double[STAPT.length - IA + 1][2];\r
+                               for (K = IA; K <= STAPT.length; K++) {\r
+                                       STAPT2[K - IA][0] = STAPT[K - 1][0];\r
+                                       STAPT2[K - IA][1] = STAPT[K - 1][1];\r
+                               }\r
+                               RGM2 = new double[RGM.length - I + 1];\r
+                               for (K = I; K <= RGM.length; K++) {\r
+                                       RGM2[K - I] = RGM[K - 1];\r
+                               }\r
+                               DEFN2 = new String[DEFN.length - J1 + 1];\r
+                               for (K = J1; K <= DEFN.length; K++) {\r
+                                       DEFN2[K - J1] = DEFN[K - 1];\r
+                               }\r
+                               DEFN3 = new String[DEFN.length - J2 + 1];\r
+                               for (K = J2; K <= DEFN.length; K++) {\r
+                                       DEFN3[K - J2] = DEFN[K - 1];\r
+                               }\r
+                               if (NARCS == 1) {\r
+                                       PTFUN2(ARCTY[IA - 1], STAPT2, RGM2, N1, DEFN2, N2, DEFN3, CHNL, CHTT, VAR, " 1", NUMDER[IA - 1],\r
+                                                       REDD, raFile);\r
+                               } else {\r
+                                       if (IA == 1) {\r
+                                               raFile.writeBytes(TX1 + IA + ") {\n");\r
+                                       } else if (IA == NARCS) {\r
+                                               raFile.writeBytes("      else {\n");\r
+                                       } else {\r
+                                               raFile.writeBytes(TX2 + IA + ") {\n");\r
+                                       }\r
+                                       PTFUN2(ARCTY[IA - 1], STAPT2, RGM2, N1, DEFN2, N2, DEFN3, CHNL, CHTT, VAR, CHIA, NUMDER[IA - 1],\r
+                                                       REDD, raFile);\r
+                                       if (IA == NARCS) {\r
+                                               raFile.writeBytes("      }\n");\r
+                                       }\r
+                               } // else\r
+                       } // for (IA=1; IA <= NARCS; IA++)\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRFUN2");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void WRFUN2\r
+\r
+       private void PTFUN2(int TYPE, double STAPT[][], double RGM[], int NTX1, String TXT1[], int NTX2, String TXT2[],\r
+                       int CHNL, String CHTT, String VAR, String CHIA, boolean NUMDER, String REDD, RandomAccessFile raFile) {\r
+               // COMPLEX STAPT(*)\r
+               // CHARACTER TXT1(*)*72,TXT2(*)*72,CHTT*2,VAR*6,CHIA*2,REDD*6\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 8 AUG 1990\r
+               // .......................................................................C\r
+               // **** LOCAL VARIABLES\r
+\r
+               int I;\r
+               double HA, MD, RAD, A, R;\r
+               double C1[] = new double[2];\r
+               double CENTR[] = new double[2];\r
+               // COMPLEX C1,CENTR\r
+               // String TX1, TX1B, TX2, TX2B, TX3, FMT1, FMT2, FMT3, FMT4, FMT5;\r
+               // CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,TX3*39,\r
+               // FMT1*25,FMT2*15,FMT3*15,FMT4*25,FMT5*24\r
+               // String TX3R, TX3I;\r
+\r
+               // TX1 = "+"+CHTT+"*";\r
+               // TX1B = TX1 + "(";\r
+               // TX2 = " "+VAR+" = ";\r
+               // TX2B = TX2 + "(";\r
+               // TX3R = " "+VAR+"[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(";\r
+               // TX3I = " "+VAR+"[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(";\r
+               // TX3=TX2//'(ZDER+UI*ZRAD)*EXP(UI*T)*('\r
+\r
+               // FMT1='(A14,'//REDD//',A1,'//REDD//',A2)'\r
+               // FMT2='(A39,'//REDD//',A1)'\r
+               // FMT3='(A13,'//REDD//',A2)'\r
+               // FMT4='(A14,'//REDD//',A5,'//REDD//',A3)'\r
+               // FMT5='(A8,'//REDD//',A5,'//REDD//',A1)'\r
+\r
+               try {\r
+                       if (TYPE == 1) {\r
+                               C1[0] = 0.5 * (STAPT[1][0] - STAPT[0][0]);\r
+                               C1[1] = 0.5 * (STAPT[1][1] - STAPT[0][1]);\r
+                               raFile.writeBytes("//\n");\r
+                               R = C1[0];\r
+                               A = C1[1];\r
+                               raFile.writeBytes("      " + VAR + "[0] = " + R + ";\n");\r
+                               raFile.writeBytes("      " + VAR + "[1] = " + A + ";\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // if (TYPE == 1)\r
+                       else if (TYPE == 2) {\r
+                               CENTR[0] = RGM[0];\r
+                               CENTR[1] = RGM[1];\r
+                               C1[0] = STAPT[0][0] - CENTR[0];\r
+                               C1[1] = STAPT[0][1] - CENTR[1];\r
+                               HA = 0.5 * RGM[2];\r
+                               MD = Math.atan2(C1[1], C1[0]) + HA;\r
+                               RAD = zabs(C1[0], C1[1]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes(\r
+                                               VAR + "[0] = -" + RAD + "*" + HA + "*Math.sin(" + MD + "+" + CHTT + "*" + HA + ");\n");\r
+                               raFile.writeBytes(VAR + "[1] = " + RAD + "*" + HA + "*Math.cos(" + MD + "+" + CHTT + "*" + HA + ");\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // else if (TYPE == 2)\r
+                       else if (NUMDER) {\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes("      " + VAR + " = ZDPARF(" + CHIA + "," + CHTT + ");\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // else if (NUMDER)\r
+                       else if (TYPE == 3) {\r
+                               MD = 0.5 * (RGM[1] + RGM[0]);\r
+                               HA = 0.5 * (RGM[1] - RGM[0]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes("      T = " + MD + "+" + CHTT + "*" + "(" + HA + ");\n");\r
+                               raFile.writeBytes("      " + VAR + " = " + HA + "*(");\r
+                               for (I = 1; I <= NTX2; I++) {\r
+                                       raFile.writeBytes(TXT2[I - 1]);\r
+                               }\r
+                               raFile.writeBytes(");\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // else if (TYPE == 3)\r
+                       else {\r
+                               MD = 0.5 * (RGM[1] + RGM[0]);\r
+                               HA = 0.5 * (RGM[1] - RGM[0]);\r
+                               raFile.writeBytes("//\n");\r
+                               raFile.writeBytes("      T = " + MD + "+" + CHTT + "*" + "(" + HA + ");\n");\r
+                               raFile.writeBytes("      ZRAD = ");\r
+                               for (I = 1; I <= NTX1; I++) {\r
+                                       raFile.writeBytes(TXT1[I - 1]);\r
+                               }\r
+                               raFile.writeBytes(";\n");\r
+                               raFile.writeBytes("      ZDEr = ");\r
+                               for (I = 1; I <= NTX2; I++) {\r
+                                       raFile.writeBytes(TXT2[I - 1]);\r
+                               }\r
+                               raFile.writeBytes(";\n");\r
+                               raFile.writeBytes("      " + VAR + "[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(" + HA + ");\n");\r
+                               raFile.writeBytes("      " + VAR + "[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(" + HA + ");\n");\r
+                               raFile.writeBytes("//\n");\r
+                       } // else\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in PTFUN2");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       }\r
+\r
+       private void WRSYM3(int NARCS, int ORDRG, boolean REFLN, int CHN, RandomAccessFile raFile) {\r
+\r
+               // **** TO WRITE THE CODE TO RECOVER THE DERIVATIVE FROM ITS SYMMETRIC\r
+               // **** COUNTERPART ON THE FUNDAMENTAL BOUNDARY SECTION.\r
+\r
+               // .......................................................................\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 4 AUG 1990\r
+               // .......................................................................C\r
+               // LOCAL VARIABLES\r
+\r
+               int I;\r
+\r
+               try {\r
+                       raFile.writeBytes("//\n");\r
+\r
+                       if (REFLN) {\r
+                               if (ORDRG > 1) {\r
+                                       I = 2 * NARCS;\r
+                                       if (NARCS > 1) {\r
+                                               raFile.writeBytes("      IS = (IA-IB)%" + I + ";\n");\r
+                                               raFile.writeBytes("      IR=(IA-IB-IS)/" + I + ";\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("      IS=(IA-1)%2;\n");\r
+                                               raFile.writeBytes("      IR=(IA-1-IS)/2;\n");\r
+                                       }\r
+                                       raFile.writeBytes("      if ((IR == 0) && (IS == 0)) {\n");\r
+                                       raFile.writeBytes("          DPARFN[0] =ZETA[0];\n");\r
+                                       raFile.writeBytes("          DPARFN[1] =ZETA[1];\n");\r
+                                       raFile.writeBytes("      }\n");\r
+                                       raFile.writeBytes("      else if ((IR > 0) && (IS == 0)) {\n");\r
+                                       raFile.writeBytes("          DPARFN[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
+                                       raFile.writeBytes("          DPARFN[1] = WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\n");\r
+                                       raFile.writeBytes("      }\n");\r
+                                       raFile.writeBytes("       else if ((IR == 0 && (IS > 0)) {\n");\r
+                                       raFile.writeBytes("           DPARFN[0] = -U2[0]*ZETA[0] -U2[1]*ZETA[1];\n");\r
+                                       raFile.writeBytes("           DPARFN[1] = U2[0]*ZETA[1] -U2[1]*ZETA[0];\n");\r
+                                       raFile.writeBytes("       }\n");\r
+                                       raFile.writeBytes("       else {\n");\r
+                                       raFile.writeBytes("           double realPart = -U2[0]*WW[IR-1][0] + U2[1]*WW[IR-1][1]);\n");\r
+                                       raFile.writeBytes("           double imagPart = -U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0]);\n");\r
+                                       raFile.writeBytes("           DPARFN[0] = realPart*ZETA[0] + imagPart*ZETA[1]);\n");\r
+                                       raFile.writeBytes("           DPARFN[1] = imagPart*ZETA[0] - realPart*ZETA[1]);\n");\r
+                                       raFile.writeBytes("       }\n");\r
+                               } // if (ORDRG > 1)\r
+                               else {\r
+                                       if (NARCS > 1) {\r
+                                               raFile.writeBytes("      IS=IA-IB;\n");\r
+                                       } else {\r
+                                               raFile.writeBytes("      IS=IA-1;\n");\r
+                                       }\r
+                                       raFile.writeBytes("      if (IS == 0) {\n");\r
+                                       raFile.writeBytes("          DPARFN[0] = ZETA[0]\n");\r
+                                       raFile.writeBytes("          DPARFN[0] = ZETA[0]\n");\r
+                                       raFile.writeBytes("      }\n");\r
+                                       raFile.writeBytes("         else {\n");\r
+                                       raFile.writeBytes("             DPARFN[0] = -U2[0]*ZETA[0] + U2[1]*ZETA[1]);\n");\r
+                                       raFile.writeBytes("             DPARFN[1] = U2[0]*ZETA[1] - U2[1]*ZETA[0]);\n");\r
+                                       raFile.writeBytes("         }\n");\r
+                               } // else\r
+                       } // if (REFLN)\r
+                       else {\r
+                               if (NARCS > 1) {\r
+                                       raFile.writeBytes("      IR=(IA-IB)/" + NARCS + ";\n");\r
+                               } else {\r
+                                       raFile.writeBytes("      IR=IA-1;\n");\r
+                               }\r
+                               raFile.writeBytes("      if (IR == 0) {\n");\r
+                               raFile.writeBytes("          DPARFN[0] = ZETA[0];\n");\r
+                               raFile.writeBytes("          DPARFN[1] = ZETA[1];\n");\r
+                               raFile.writeBytes("      }\n");\r
+                               raFile.writeBytes("      else {\n");\r
+                               raFile.writeBytes("          DPARFN[0]= WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
+                               raFile.writeBytes("          DPARFN[1]= WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\n");\r
+                               raFile.writeBytes("      }\n");\r
+                       }\r
+               } // try\r
+               catch (IOException e) {\r
+                       MipavUtil.displayError("IOException " + e + " in WRSYM3");\r
+                       System.exit(-1);\r
+               }\r
+\r
+       } // private void WRSYM3\r
+\r
+       private void TSTPLT(String JBNM, double MXMIS, double MXDIF, int NARCS, double PSD, double MINPD, double MAXPD,\r
+                       int CHNL, int IER[]) {\r
+               // CHARACTER*4 JBNM\r
 \r
-          double result[] =new double[]{1.0,0.0};\r
-          return result;\r
-      } // double[] PARFUN     \r
-       \r
-         //COMPLEX FUNCTION DPARFN(I,T)\r
-         //INTEGER I\r
-         //COMPLEX T\r
-      double[] DPARFN(int I, double T[]) {\r
-       \r
-             // DUMMY FUNCTION TO AID LINK-LOADING OF PARGEN\r
-       \r
-         double result[] =new double[]{1.0,0.0};\r
-          return result;\r
-      } // double[] DPARFN\r
-\r
-      private void WRHEAD(int I,int CHNL, RandomAccessFile raFile) {\r
-   \r
-\r
-      //**** WRITE A HEADING FOR THE MAIN CONFPACK MODULES JAPHYC (I=1), \r
-      //**** GQPHYC (I=2), JACANP (I=3), GQCANP (I=4), CNDPLT (I=5), THE\r
-      //**** PARAMETRIC FUNCTION GENERATOR PARGEN (I=6),THE PARAMETRIC FUNCTION\r
-      //**** TESTER TSTPLT (I=7) AND THE LEVEL CURVE ROUTINE LEVCUR (I=8).  IF \r
-      //**** CHNL=0 THEN WRITE ON THE STANDARD OUTPUT CHANNEL, OTHERWISE WRITE \r
-      //**** ON THE CHANNEL SPECIFIED BY CHNL.\r
-      //\r
-      //    LOCAL VARIABLES\r
-      //\r
-         String DOTS = ".................................................";\r
-         String CPHEAD = ": C O N F P A C K    M O D U L E    ";\r
-         String MOD[] = new String[]{"J A P H Y C :",\r
-                                     "G Q P H Y C :",\r
-                                     "J A C A N P :",\r
-                                     "G Q C A N P :",\r
-                                     "C N D P L T :",\r
-                                     "P A R G E N :",\r
-                                     "T S T P L T :",\r
-                                     "L E V C U R :"};\r
-         String TXT = CPHEAD + MOD[I-1];\r
-            \r
-          if (CHNL == 0 || CHNL == 6) {\r
-                 System.out.println("\n\n      "+DOTS+"\n      "+TXT+"\n      "+DOTS);\r
-          }\r
-          else {\r
-                 try {\r
-                     raFile.writeBytes("\n\n      //"+DOTS+"\n      //"+TXT+"\n      //"+DOTS+"\n");\r
-                 }\r
-                 catch (IOException e) {\r
-                         MipavUtil.displayError("IOException " + e + " on raFile.writeBytes in WRHEAD");\r
-                         System.exit(-1);\r
-                 }\r
-          }\r
-          return;\r
-      } // private void WRHEAD\r
-      \r
-      private void WRTAIL(int I, int CHNL, int IER, RandomAccessFile raFile) {\r
-     \r
-//\r
-//**** WRITE A CLOSING MESSAGE FOR THE MAIN CONFPACK MODULES JAPHYC (I=1)\r
-//**** GQPHYC (I=2), JACANP (I=3), GQCANP (I=4), CNDPLT (I=5), THE PARA-\r
-//**** METRIC FUNCTION GENERATOR PARGEN (I=6), THE PARAMETRIC FUNCTION \r
-//**** TESTER TSTPLT (I=7) AND THE LEVEL CURVE ROUTINE LEVCUR (I=8).  IF \r
-//**** CHNL=0 THEN WRITE ON THE STANDARD OUTPUT CHANNEL, OTHERWISE WRITE \r
-//**** ON THE CHANNEL SPECIFIED BY CHNL.  THE TEXT OF THE MESSAGE IS \r
-//**** DETERMINED BY THE ERROR NUMBER IER VIA THE SUBROUTINE IERTXT.\r
-\r
-//     LOCAL VARIABLES\r
-     \r
-      String MOD[] = new String[]{"J A P H Y C :",       \r
-                      "G Q P H Y C :","J A C A N P :",\r
-                "G Q C A N P :","C N D P L T :","P A R G E N :",\r
-                "T S T P L T :","L E V C U R :"};\r
-     String GOOD = "  NORMAL EXIT";\r
-     String BAD= "  ABNORMAL EXIT";\r
-     String LINE = "__________________________________________________________________&";\r
-\r
-     String TXT, TXT2;\r
-     if (IER == 0) {\r
-        TXT=MOD[I-1]+GOOD;\r
-     }\r
-     else{\r
-        TXT=MOD[I-1]+BAD;\r
-     }\r
-     TXT2=IERTXT(IER);\r
-\r
-      if ((CHNL == 0) || (CHNL == 6)) {\r
-       System.out.println("\n\n      "+TXT);\r
-       System.out.println("      "+TXT2);\r
-        System.out.println(LINE);\r
-     }\r
-     else {\r
-       try {\r
-            raFile.writeBytes("\n\n      //"+TXT+"\n");\r
-            raFile.writeBytes("      //"+TXT2+"\n");\r
-            raFile.writeBytes("//"+LINE+"\n");\r
-       }\r
-       catch(IOException e) {\r
-               MipavUtil.displayError("IOException " + e + " in WRTAIL");\r
-               System.exit(-1);\r
-       }\r
-     }\r
-     return;\r
-      }\r
-      \r
-      private String IERTXT(int IER) {\r
-         \r
-//**** SUPPLY ERROR MESSAGE TEXT FOR ERROR NUMBER IER\r
-      String result = null;\r
-      if (IER == 0) {\r
-          result = " ";\r
-      }\r
-      else if (IER == 1) {\r
-          result="PARAMETER IBNDS[0] IS TOO SMALL AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 2) {\r
-          result = "PARAMETER IBNDS[1] IS TOO SMALL AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 3) {\r
-          result = "NQPTS < 1 AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 4) {\r
-          result="FAILURE TO CONVERGE IN EIGSYS; CAN''T SET UP BASIC QUADRATURE RULES";\r
-      }\r
-      else if (IER == 5) {\r
-          result="PARAMETER MNQPT IN IGNLVL MUST BE INCREASED TO AT LEAST NQPTS";\r
-      }\r
-      else if (IER == 6) {\r
-          result="FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP IGNORE LEVELS";\r
-      }\r
-      else if (IER == 7) {\r
-          result="FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP COLLOCATION POINTS";\r
-      }\r
-      else if (IER == 8) {\r
-          result="ARGUMENT MNEQN IS TOO SMALL AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 9) {\r
-          result="PARAMETER IBNDS[3] IS TOO SMALL AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 10) {\r
-          result="PARAMETER NMAX IN SUBIN7 MUST BE INCREASED TO AT LEAST 2*NQPTS";\r
-      }\r
-      else if (IER == 11) {\r
-          result="PARAMETER IBNDS[2] IS TOO SMALL AT START OF JAPHYC";\r
-      }\r
-      else if (IER == 12) {\r
-          result="PARAMETER NC IN DEJAC7 AND DELEG7 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 13) {\r
-          result="PARAMETER NR IN DEJAC7 AND DELEG7 MUST BE >= (NQPTS -1)";\r
-      }\r
-      else if (IER == 14) {\r
-          result="A CORNER ANGLE IS TOO SMALL; MAY CAUSE OVERFLOW IN GAMMA FUNCTION";\r
-      }\r
-      else if (IER == 15) {\r
-          result="SINGULAR COLLOCATION MATRIX";\r
-      }\r
-      else if (IER == 16) {\r
-          result="COLLOCATION MATRIX IS EFFECTIVELY SINGULAR";\r
-      }\r
-      else if (IER == 17) {\r
-          result="NUMBER OF SUBARCS EXCEEDS IBNDS[0] DURING REFINEMENT";\r
-      }\r
-      else if (IER == 18) {\r
-          result="NUMBER OF EQUATIONS EXCEEDS MNEQN DURING REFINEMENT";\r
-      }\r
-      else if (IER == 19) {\r
-          result="TOTAL NUMBER OF QUADRATURE PTS EXCEEDS IBNDS[3] DURING REFINEMENT";\r
-      }\r
-      else if (IER == 20) {\r
-          result="NUMBER OF QUADRATURE PANELS EXCEEDS IBNDS[2] DURING REFINEMENT";\r
-      }\r
-      else if (IER == 21) {\r
-          result="FAILURE TO CONVERGE IN IMTQLH; CAN''T SET UP TEST POINTS";\r
-      }\r
-      else if (IER == 22) {\r
-          result="ARGUMENT MQUPH OF GQPHYC MUST BE INCREASED";\r
-      }\r
-      else if (IER == 23) {\r
-          result="PARAMETER MNCOF IN POPQF1 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 24) {\r
-          result="NUMBER OF QUADRATURE PANELS EXCEEDS MQIN1 IN GQPHYC";\r
-      }\r
-      else if (IER == 25) {\r
-          result="PARAMETER MNXI IN DEPPJ8 AND DEPPL8 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 26) {\r
-          result="PARAMETER MAXNZ IN DEPPJ9 AND DEPPL9 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 27) {\r
-          result="PARAMETER MXNQD IN PHTCA1 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 28) {\r
-          result="PARAMETER MXCOF IN PHTCA1 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 29) {\r
-          result="PARAMETER MQIN1 IN PHTCA1 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 30) {\r
-          result="PARAMETER MNDG IN JCFIM5 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 31) {\r
-          result="PARAMETER MNQD IN JCFIM5 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 32) {\r
-          result="ARGUMENT IBNDS[1] SUPPLIED TO JACANP MUST BE INCREASED";\r
-      }\r
-      else if (IER == 33) {\r
-          result="ARGUMENT IBNDS[0] SUPPLIED TO JACANP MUST BE INCREASED";\r
-      }\r
-      else if (IER == 34) {\r
-          result="FN HAS SAME SIGN AT INTERVAL ENDS IN BISNEW; CAN''T SOLVE BCF EQN";\r
-      }\r
-      else if (IER == 35) {\r
-          result="DERIVATIVE OF BCF IS ZERO IN BISNEW; CAN''T SOLVE BCF EQN";\r
-      }\r
-      else if (IER == 36) {\r
-          result="ELEMENT OF ARGUMENT ARRAY SVAL IN RHOFN IS +-1; CAN''T CONTINUE";\r
-      }\r
-      else if (IER == 37) {\r
-          result="PARAMETER MXNQD IN CINRAD MUST BE INCREASED";\r
-      }\r
-      else if (IER == 38) {\r
-          result="PARAMETER MXCOF IN CINRAD MUST BE INCREASED";\r
-      }\r
-      else if (IER == 39) {\r
-          result="CENTRE POINT IS PATHOLOGICALLY CLOSE TO BOUNDARY;CAN''T CONTINUE";\r
-      }\r
-      else if (IER == 40) {\r
-          result="PARAMETER MQIN1 IN CINRAD MUST BE INCREASED";\r
-      }\r
-      else if (IER == 41) {\r
-          result="ARGUMENT MQUCA OF GQCANP MUST BE INCREASED";\r
-      }\r
-      else if (IER == 42) {\r
-          result="PARAMETER MNCOF IN POPQG1 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 43) {\r
-          result="NUMBER OF QUADRATURE PANELS EXCEEDS MQIN1 IN GQCANP";\r
-      }\r
-      else if (IER == 44) {\r
-          result="PARAMETER MNCOF IN BMPHC1 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 45) {\r
-          result="ARGUMENTS IARC, PHYPT OF BMPHYC DON''T DEFINE A BOUNDARY POINT";\r
-      }\r
-      else if (IER == 46) {\r
-          result="PARAMETER MNCOF IN BMCAP1 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 47) {\r
-          result="PARAMETER MXNQD IN CATPH4 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 48) {\r
-          result="PARAMETER MNCOF IN CATPH4 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 49) {\r
-          result="PARAMETER MQIN1 IN CATPH4 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 50) {\r
-          result="PARAMETER MXCOF IN DIAGN3 MUST BE >= NQPTS";\r
-      }\r
-      else if (IER == 51) {\r
-          result="NON-ANALYTIC ARC DETECTED IN DIAGN3";\r
-      }\r
-      else if (IER == 52) {\r
-          result="PARAMETER MAXSA IN CNDPLT MUST BE INCREASED";\r
-      }\r
-      else if (IER == 53) {\r
-          result="OVERFLOW EXPECTED IN IGNLVL; A CORNER ANGLE IS TOO SMALL";\r
-      }\r
-      else if (IER == 54) {\r
-          result="PARAMETER MXCO IN AXION1 MUST BE INCREASED";\r
-      }\r
-      else if (IER == 55) {\r
-          result="NARCS ISN''T AN INTEGER MULTIPLE OF THE ORDER OF THE SYMMETRY GROUP";\r
-      }\r
-      else if (IER == 56) {\r
-          result="CENTRE OF SYMMETRY IS PATHOLOGICALLY CLOSE TO LAST POINT ON FBS";\r
-      }\r
-      else if (IER == 57) {\r
-          result="CENTRE OF SYMMETRY IS PATHOLOGICALLY CLOSE TO FIRST POINT ON FBS";\r
-      }\r
-      else if (IER == 58) {\r
-          result="NUMBER OF ARCS IS TOO BIG; INCREASE PARAMETER MNARC IN PARGEN";\r
-      }\r
-      else if (IER == 59) {\r
-          result="NUMBER OF ARCS IS TOO BIG; INCREASE PARAMETER MNARC IN TSTPLT";\r
-      }\r
-      else if (IER == 60) {\r
-          result="NON-ANALYTIC ARC (DPARFN=(0.,0.)) DETECTED IN TSTPLT";\r
-      }\r
-      else {\r
-          result="UNRECOGNIZED ERROR NUMBER IN IERTXT ROUTINE !!";\r
-      }\r
-      return result;\r
-}\r
-      \r
-      private void WRSYM1(int NARCS,int ORDRG,int ORDSG,double[] RTUNI,double[] U2,double[] CENSY,boolean REFLN,boolean PARFUN,\r
-                    String REDD,int CHNL, RandomAccessFile raFile) {\r
-                     //COMPLEX RTUNI,U2,CENSY\r
-               \r
-               //**** TO WRITE THE DIMENSION AND PARAMETER STATEMENTS AND THE CODE TO\r
-               //**** TO REDUCE A GIVEN ARC NUMBER TO ITS SYMMETRIC COUNTERPART ON THE\r
-               //**** FUNDAMENTAL BOUNDARY SECTION.\r
-               \r
-               //.......................................................................\r
-               //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-               //     LAST UPDATE: 4 AUG 1990\r
-               //.......................................................................C\r
-               //     LOCAL VARIABLES\r
-               \r
-               int I;\r
-               double R,A;\r
-               //COMPLEX ZT\r
-               double ZT[] = new double[2];\r
-               boolean NEEDC;\r
-               //String FMT;\r
-               double cr[] = new double[1];\r
-               double ci[] = new double[1];\r
-               \r
-               //FMT="(A12,"+REDD+",A1,"+REDD+",A2)";\r
-               \r
-               try {\r
-                       if (PARFUN) {\r
-                               NEEDC = ((CENSY[0] != 0.0) || (CENSY[1] != 0.0));\r
-                           if (NEEDC || REFLN) {\r
-                               raFile.writeBytes("      PARAMETER (\n");\r
-                               if (NEEDC && REFLN) {\r
-                                   R=U2[0];\r
-                                   A=U2[1];\r
-                                   raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                                   raFile.writeBytes("U2[1] = " + A + ";\n");\r
-                                   R=CENSY[0];\r
-                                   A=CENSY[1];\r
-                                   raFile.writeBytes("ZCEN[0] = " + R +";\n");\r
-                                   raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
-                               } // if (NEEDC && REFLN)\r
-                               else if (NEEDC && (!REFLN)) {\r
-                                   R=CENSY[0];\r
-                                   A=CENSY[1];\r
-                                   raFile.writeBytes("ZCEN[0] = " + R + ";\n");\r
-                                   raFile.writeBytes("ZCEN[1] = " + A + ";)\n");\r
-                               } // else if (NEEDC && (!REFLN)) \r
-                               else {\r
-                                   R=U2[0];\r
-                                   A=U2[1];\r
-                                   raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                                   raFile.writeBytes("U2[1] = " + A + ";)\n");\r
-                               } // else\r
-                               raFile.writeBytes("//\n");\r
-                           } // if (NEEDC || REFLN)\r
-                       }\r
-                       else if (REFLN) {\r
-                           R=U2[0];\r
-                           A=U2[1];\r
-                           raFile.writeBytes("      PARAMETER (\n");\r
-                           raFile.writeBytes("U2[0] = " + R + ";\n");\r
-                           raFile.writeBytes("U2[1] = " + A + ";)\n");\r
-                           raFile.writeBytes("//\n");\r
-                       }\r
-                       \r
-                       //FMT="(A7,"+REDD+",A1,"+REDD+",A2)";\r
-                       \r
-                   if (ORDRG >= 2) {\r
-                       raFile.writeBytes("double WW[] = new double["+(ORDRG-1)+"];\n");\r
-                       ZT[0] = 1.0;\r
-                       ZT[1] = 0.0;\r
-                           for (I=0; I < ORDRG-2; I++) {\r
-                               zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
-                               ZT[0] = cr[0];\r
-                               ZT[1] = ci[0];\r
-                               raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + ";\n");\r
-                               raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + ";\n");\r
-                           }\r
-                           zmlt(ZT[0],ZT[1],RTUNI[0],RTUNI[1],cr,ci);\r
-                               ZT[0] = cr[0];\r
-                               ZT[1] = ci[0];\r
-                               raFile.writeBytes("WW["+I+"][0] = " + ZT[0] + ";\n");\r
-                               raFile.writeBytes("WW["+I+"][1] = " + ZT[1] + ";)\n");\r
-                               raFile.writeBytes("//\n");\r
-                   } // if (ORDRG >= 2)\r
-                   \r
-                       if (ORDRG > 19) {\r
-                           System.out.println("\n");\r
-                           System.out.println("             ****WARNING****");\r
-                           System.out.println("MORE THAN 19 CONTINUTATION LINES HAVE BEEN WRITTEN");\r
-                       }\r
-                       \r
-                       if (REFLN) {\r
-                       if (ORDRG > 1) {\r
-                               if (NARCS > 1) {\r
-                                   I=2*NARCS;\r
-                                   raFile.writeBytes("IB = IA%"+I+";\n");\r
-                                   raFile.writeBytes("if (IB == 0) IB = " + I + ";\n");\r
-                                   I=I+1;\r
-                                   raFile.writeBytes("if (IB > " + NARCS + ") {\n");\r
-                                   raFile.writeBytes("    IB = " + I + " - IB;\n");\r
-                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
-                                   raFile.writeBytes("}\n");\r
-                                   raFile.writeBytes("else {\n");\r
-                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
-                                   raFile.writeBytes("}\n");\r
-                               } // if (NARCS > 1)\r
-                               else {\r
-                                       raFile.writeBytes("if ((IA%2) == 0) {\n");\r
-                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
-                                   raFile.writeBytes("}\n");\r
-                                   raFile.writeBytes("else {\n");\r
-                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
-                                   raFile.writeBytes("}\n");\r
-                               } // else\r
-                       } // if (ORDRG > 1)\r
-                       else {\r
-                               if (NARCS > 1) {\r
-                                   I=2*NARCS+1;\r
-                                   raFile.writeBytes("if (IA > " + NARCS + "){\n");\r
-                                   raFile.writeBytes("    IB = " + I + " -IA;\n");\r
-                                   raFile.writeBytes("    TS[0] = -TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
-                                   raFile.writeBytes("}\n");\r
-                                   raFile.writeBytes("else {\n");\r
-                                   raFile.writeBytes("    IB = IA;\n");\r
-                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
-                                   raFile.writeBytes("}\n");\r
-                               } // if (NARCS)\r
-                               else {\r
-                                       raFile.writeBytes("if (IA == 2) {\n");\r
-                                       raFile.writeBytes("    TS[0] = -TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1]);\n");\r
-                                   raFile.writeBytes("}\n");\r
-                                   raFile.writeBytes("else {\n");\r
-                                   raFile.writeBytes("    TS[0] = TT[0];\n");\r
-                                   raFile.writeBytes("    TS[1] = TT[1];\n");\r
-                                   raFile.writeBytes("}\n");     \r
-                               } // else\r
-                       } // else\r
-                       } // if (REFLN)\r
-                       else if (NARCS > 1) {\r
-                               raFile.writeBytes("IB = IA%" + NARCS + ";\n");\r
-                           raFile.writeBytes("if (IB == 0) IB = " + NARCS + ";\n");\r
-                       } // else if (NARCS > 1)\r
-                       \r
-                       raFile.writeBytes("//\n");\r
-               } // try\r
-               catch (IOException e) {\r
-                       MipavUtil.displayError("IOException " + e + " in WRSYM1");\r
-                       System.exit(-1);\r
-               }\r
-               \r
-      }\r
-\r
-      private void WRFUN1(int NARCS,double STAPT[][],int ARCTY[],int PGM[], \r
-                 double RGM[], int PTX[], int NTX[], String DEFN[],\r
-                 int CHNL, String CHIA, String CHTT, String VAR, String REDD, RandomAccessFile raFile) {\r
-          //COMPLEX STAPT(*)\r
-          //CHARACTER DEFN(*)*72,CHIA*2,CHTT*2,VAR*6,REDD*6\r
-               \r
-          //**** TO WRITE THE SOURCE CODE FOR PARFUN IN THE CASE WHERE NO\r
-         //**** SYMMETRY IS INVOLVED.\r
-               \r
-         //.......................................................................\r
-         //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-         //     LAST UPDATE: 4 AUG 1990\r
-         //.......................................................................\r
-       \r
-         //     LOCAL VARIABLES\r
-       \r
-          int IA,I,J,K;\r
-         //CHARACTER TX1*16,TX2*21,FMT1*11,FMT2*11\r
-          String TX1,TX2;\r
-          //String FMT1,FMT2;\r
-         // EXTERNAL PTFUN1\r
-         TX1 = "     if("+CHIA+ " == ";\r
-         TX2 = "     else if("+CHIA+ " == ";\r
-          //FMT1="(A16,I3,A6)";\r
-          //FMT2="(A21,I3,A6)";\r
-          double STAPT2[][];\r
-          double RGM2[];\r
-          String DEFN2[];\r
-               \r
-         try {\r
-                 for (IA=1; IA <= NARCS; IA++) {\r
-                     I=PGM[IA-1];\r
-                         J=PTX[IA-1];\r
-                         STAPT2 = new double[STAPT.length-IA+1][2];\r
-                         for (K = IA; K <= STAPT.length; K++) {\r
-                                 STAPT2[K-IA] = STAPT[K-1];\r
-                         }\r
-                         RGM2 = new double[RGM.length-I+1];\r
-                         for (K = I; K <= RGM.length; K++) {\r
-                                 RGM2[K-I] = RGM[K-1];\r
-                         }\r
-                         DEFN2 = new String[DEFN.length-J+1];\r
-                         for (K = J; K <= DEFN.length; K++) {\r
-                                 DEFN2[K-J] = DEFN[K-1];\r
-                         }\r
-                         if (NARCS == 1) {\r
-                             PTFUN1(ARCTY[IA-1],STAPT2,RGM2,NTX[IA-1],DEFN2,\r
-                                        CHNL,CHTT,VAR,REDD, raFile);\r
-                         }\r
-                         else {\r
-                                 if (IA == 1) {\r
-                                         raFile.writeBytes(TX1 + IA + ") {\n");\r
-                                 }\r
-                                 else if (IA == NARCS) {\r
-                                         raFile.writeBytes("      else {\n");\r
-                                 }\r
-                                 else {\r
-                                         raFile.writeBytes(TX2 + IA + ") {\n");\r
-                                 }\r
-                                 PTFUN1(ARCTY[IA-1],STAPT2,RGM2,NTX[IA-1],DEFN2,\r
-                                        CHNL,CHTT,VAR,REDD, raFile);\r
-                                 if (IA == NARCS) raFile.writeBytes("      }\n");\r
-                         } // else\r
-                 } // for (IA=1; IA <= NARCS; IA++)\r
-         } // try\r
-         catch (IOException e) {\r
-             MipavUtil.displayError("IOException " + e + " in WRFUN1");\r
-             System.exit(-1);\r
-         }\r
-               \r
-      } // private void WRFUN1\r
-\r
-      private void PTFUN1(int TYPE, double STAPT[][], double RGM[],int NTX,\r
-                 String TXT[],int CHNL, String CHTT,String VAR, String REDD,\r
-                 RandomAccessFile raFile) {\r
-      \r
-          //COMPLEX STAPT(*)\r
-          //CHARACTER TXT(*)*72,CHTT*2,VAR*6,REDD*6\r
-\r
-          //.......................................................................\r
-          // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-          // LAST UPDATE: 8 AUG 1990\r
-          // .......................................................................C\r
-          //**** LOCAL VARIABLES\r
-\r
-      int I;\r
-      double HA,MD,RAD;\r
-      double C1[] = new double[2];\r
-      double C2[] = new double[2];\r
-      double CENTR[] = new double[2];\r
-      //COMPLEX C1,C2,CENTR\r
-      //String TX1, TX1B, TX2;\r
-      //String TX2B, CTX1B, FMT1, FMT2, FMT3, FMT4, FMT5;\r
-      //CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,CTX1B*10,\r
-      //+FMT1*25,FMT2*25,FMT3*14,FMT4*25,FMT5*24\r
-\r
-      //TX1 = "+"+CHTT+"*";\r
-      //TX1B = TX1 + "(";\r
-      //CTX1B="     " + TX1B;\r
-      //TX2="      "+VAR+" = ";\r
-      //TX2B=TX2+"(";\r
-\r
-      //FMT1='(A14,'//REDD//',A1,'//REDD//',A2)'\r
-      //FMT2='(A10,'//REDD//',A1,'//REDD//',A1)'\r
-      //FMT3='(A6,'//REDD//',A1)'\r
-      //FMT4='(A14,'//REDD//',A5,'//REDD//',A3)'\r
-      //FMT5='(A8,'//REDD//',A5,'//REDD//',A1)'\r
-\r
-      try {\r
-      if (TYPE == 1) {\r
-       C1[0] = 0.5*(STAPT[1][0] + STAPT[0][0]);\r
-       C1[1] = 0.5*(STAPT[1][1] + STAPT[0][1]);\r
-        C2[0] = 0.5*(STAPT[1][0] - STAPT[0][0]);\r
-        C2[1] = 0.5*(STAPT[1][1] - STAPT[0][1]);\r
-        raFile.writeBytes("//\n");\r
-        raFile.writeBytes(VAR+"[0] = " + C1[0] + "+" + CHTT+"[0]*"+C2[0]+" - "+CHTT+"[1]*"+C2[1]+";\n");\r
-        raFile.writeBytes(VAR+"[1] = " + C1[1] + "+" + CHTT+"[0]*"+C2[1]+" + "+CHTT+"[1]*"+C2[0]+";\n");\r
-        raFile.writeBytes("//\n");\r
-      } // if (TYPE == 1)\r
-      else if (TYPE == 2) {\r
-       CENTR[0] = RGM[0];\r
-       CENTR[1] = RGM[1];\r
-        C1[0] = STAPT[0][0] - CENTR[0];\r
-        C1[1] = STAPT[0][1] - CENTR[1];\r
-        HA=0.5*RGM[2];\r
-        MD = Math.atan2(C1[1], C1[0]) + HA;\r
-        RAD=zabs(C1[0],C1[1]);\r
-        raFile.writeBytes("//\n");\r
-        raFile.writeBytes(VAR+"[0] = " + CENTR[0] + "+" + RAD + " * " + "Math.exp(-"+CHTT+"[1]*"+HA+")*"\r
-        +"Math.cos("+MD+CHTT+"[0]*"+HA+");\n");\r
-        raFile.writeBytes(VAR+"[1] = " + CENTR[1] + "+" + RAD + " * " + "Math.exp(-"+CHTT+"[1]*"+HA+")*"\r
-                +"Math.sin("+MD+CHTT+"[0]*"+HA+");\n");\r
-        raFile.writeBytes("//\n");\r
-      } // else if (TYPE == 2)\r
-      else if (TYPE == 3) {\r
-        MD=0.5*(RGM[1]+RGM[0]);\r
-        HA=0.5*(RGM[1]-RGM[0]);\r
-        raFile.writeBytes("//\n");\r
-        raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * " + HA + ";\n");\r
-        raFile.writeBytes("T[1] = " + MD + "+" + CHTT + "[1] * " + HA + ";\n");\r
-        \r
-        raFile.writeBytes(VAR + "[0] = ");\r
-        // NTX = 1 if statements are entered without newlines for multiple lines\r
-        for (I  = 1; I <= NTX; I++) {\r
-               int index = TXT[I-1].indexOf("ui");\r
-               String realString = null;\r
-               if (index == -1) {\r
-                       realString = TXT[I-1];\r
-               }\r
-               else {\r
-                       realString = TXT[I-1].substring(0, index);\r
-               }\r
-               if ((index == -1) || (index > 0)) {\r
-                   raFile.writeBytes(realString);\r
-               }\r
-               if (I == NTX) {\r
-                       raFile.writeBytes(";\n");\r
-               }\r
-        }\r
-        raFile.writeBytes(VAR + "[1] = ");\r
-        // NTX = 1 if statements are entered without newlines for multiple lines\r
-        for (I  = 1; I <= NTX; I++) {\r
-               int index = TXT[I-1].indexOf("ui");\r
-               String imagString = null;\r
-               if ((index >= 0) && (index+2 < TXT[I-1].length())) {\r
-                       imagString = TXT[I-1].substring(index+2);\r
-                       raFile.writeBytes(imagString);\r
-               }\r
-               if (I == NTX) {\r
-                       raFile.writeBytes(";\n");\r
-               }\r
-        }\r
-        raFile.writeBytes("//\n");\r
-      } // else if (TYPE == 3)\r
-      else {\r
-       MD=0.5*(RGM[1]+RGM[0]);\r
-        HA=0.5*(RGM[1]-RGM[0]);\r
-        raFile.writeBytes("//\n");\r
-        raFile.writeBytes("T[0] = " + MD + "+" + CHTT + "[0] * " + HA + ";\n");\r
-        raFile.writeBytes("T[1] = " + MD + "+" + CHTT + "[1] * " + HA + ";\n");\r
-        raFile.writeBytes("     ZRAD = ");\r
-        // NTX = 1 if statements are entered without newlines for multiple lines\r
-        for (I  = 1; I <= NTX; I++) {\r
-               raFile.writeBytes(TXT[I-1]);\r
-        }\r
-        raFile.writeBytes(VAR + "[0] = Math.exp(-T[1])*(ZRAD * Math.cos(T[0]));\n");\r
-        raFile.writeBytes(VAR + "[1] = Math.exp(-T[1])*(ZRAD * Math.sin(T[0]));\n");\r
-        raFile.writeBytes("//\n");\r
-      }\r
-      } // try \r
-      catch (IOException e) {\r
-         MipavUtil.displayError("IOException " + e + " in PTFUN1");\r
-         System.exit(-1);\r
-      }\r
-\r
-      } // private void PTFUN1\r
-      \r
-\r
-      private void WRSYM2(int NARCS,int ORDRG, double CENSY[], boolean REFLN,int CHNL, RandomAccessFile raFile) {\r
-     \r
-          //COMPLEX CENSY\r
-\r
-          // **** TO WRITE THE CODE TO RECOVER THE BOUNDARY POINT FROM ITS SYMMETRIC\r
-          // **** COUNTERPART ON THE FUNDAMENTAL BOUNDARY SECTION.\r
-\r
-          //.......................................................................\r
-          // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-          // LAST UPDATE: 4 AUG 1990\r
-          // .......................................................................C\r
-          // LOCAL VARIABLES\r
-\r
-          int I;\r
-          boolean NEEDC;\r
-  \r
-          NEEDC = ((CENSY[0] != 0.0) || (CENSY[1] != 0.0));\r
-          try {\r
-                 raFile.writeBytes("//\n");\r
-\r
-              if (REFLN) {\r
-                  if (ORDRG > 1) {\r
-                      I=2*NARCS;\r
-                      if (NARCS > 1) {\r
-                         raFile.writeBytes("IS = (IA-IB)%"+I+";\n");\r
-                          raFile.writeBytes("IR = (IA-IB-IS)/" + I + ";\n");\r
-                      } // if (NARCS > 1)\r
-                      else {\r
-                         raFile.writeBytes("IS = (IA-1)%2;\n");\r
-                          raFile.writeBytes("IR = (IA-1-IS)/2;\n");\r
-                      }\r
-                      raFile.writeBytes("if ((IR == 0) && (IS == 0)) {\n");\r
-                      raFile.writeBytes("    PARFUN[0] = ZETA[0];\n");\r
-                      raFile.writeBytes("    PARFUN[1] = ZETA[1];\n");\r
-                      raFile.writeBytes("}\n");\r
-                      raFile.writeBytes("else if ((IR > 0) && (IS == 0)) {\n");\r
-                      if (NEEDC) {\r
-                         raFile.writeBytes("    PARFUN[0] = ZCEN[0] + WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
-                                       + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
-                         raFile.writeBytes("    PARFUN[1] = ZCEN[1] + WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
-                                       + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
-                       } // if (NEEDC)\r
-                      else {\r
-                         raFile.writeBytes("PARFUN[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
-                      }\r
-                      raFile.writeBytes("else if ((IR == 0) && (IS > 0)) {\n");\r
-                      if (NEEDC) {\r
-                          raFile.writeBytes("    PARFUN[0] = ZCEN[0] + U2[0]*(ZETA[0]-ZCEN[0]) + " +\r
-                                         "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
-                          raFile.writeBytes("    PARFUN[1] = ZCEN[1] - U2[0]*(ZETA[1]-ZCEN[1]) + " +\r
-                                         "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
-                      }\r
-                      else {\r
-                         raFile.writeBytes("    PARFUN[0] = U2[0]*ZETA[0] + U2[1]*ZETA[1];\n");\r
-                         raFile.writeBytes("    PARFUN[1] = -U2[0]*ZETA[1] + U2[1]*ZETA[0];\n");\r
-                      }\r
-                      raFile.writeBytes("}\n");\r
-                      raFile.writeBytes("else {\n");\r
-                      if (NEEDC) {\r
-                          raFile.writeBytes("double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
-                          raFile.writeBytes("double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
-                          raFile.writeBytes("PARFUN[0] = ZCEN[0] + realPart*(ZETA[0]-ZCEN[0]) + " +\r
-                                       "imagPart*(ZETA[1]-ZCEN[1]);\n");\r
-                          raFile.writeBytes("PARFUN[1] = ZCEN[1] - realPart*(ZETA[1]-ZCEN[1]) + " +\r
-                                       "imagPart*(ZETA[0]-ZCEN[0]);\n");\r
-                      }\r
-                      else {\r
-                         raFile.writeBytes("double realPart = U2[0]*WW[IR-1][0] - U2[1]*WW[IR-1][1];\n");\r
-                          raFile.writeBytes("double imagPart = U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0];\n");\r
-                          raFile.writeBytes("PARFUN[0] = realPart * ZETA[0] + imagPart * ZETA[1];\n");\r
-                          raFile.writeBytes("PARFUN[1] = -realPart * ZETA[1] + imagPart * ZETA[0];\n");\r
-                      }\r
-                      raFile.writeBytes("}\n");\r
-                  } // if (ORDRG > 1)\r
-                  else { // ORDRG <= 1\r
-                      if (NARCS > 1) {\r
-                         raFile.writeBytes("IS = IA - IB;\n");\r
-                      }\r
-                      else {\r
-                         raFile.writeBytes("IS = IA - 1;\n");\r
-                      }\r
-                      raFile.writeBytes("if (IS == 0) {\n");\r
-                      raFile.writeBytes("    PARFUN[0] = ZETA[0];\n");\r
-                      raFile.writeBytes("    PARFUN[1] = ZETA[1];\n");\r
-                      raFile.writeBytes("}\n");\r
-                      raFile.writeBytes("else {\n");\r
-                      if (NEEDC) {\r
-                         raFile.writeBytes("    PARFUN[0] = ZCEN[0] + U2[0]*(ZETA[0]-ZCEN[0]) + " +\r
-                                         "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
-                          raFile.writeBytes("    PARFUN[1] = ZCEN[1] - U2[0]*(ZETA[1]-ZCEN[1]) + " +\r
-                                         "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
-                      }\r
-                      else {\r
-                         raFile.writeBytes("    PARFUN[0] = U2[0]*(ZETA[0]-ZCEN[0]) + " +\r
-                                         "U2[1]*(ZETA[1]-ZCEN[1]);\n");\r
-                          raFile.writeBytes("    PARFUN[1] =  -U2[0]*(ZETA[1]-ZCEN[1]) + " +\r
-                                         "U2[1]*(ZETA[0]-ZCEN[0]);\n");\r
-                      }\r
-                      raFile.writeBytes("}\n");\r
-                  } // else ORDRG <= 1\r
-              } // if (REFLN)\r
-              else { // !REFLN\r
-                  if (NARCS > 1) {\r
-                         raFile.writeBytes("IR = (IA - IB)/" + NARCS + ";\n");\r
-                  }\r
-                  else {\r
-                         raFile.writeBytes("IR = IA - 1;\n");\r
-                  }\r
-                  raFile.writeBytes("if (IR == 0) {\n");\r
-                  raFile.writeBytes("PARFUN[0] = ZETA[0]);\n");\r
-                  raFile.writeBytes("PARFUN[1] = ZETA[1]);\n");\r
-                  raFile.writeBytes("}\n");\r
-                  raFile.writeBytes("else {\n");\r
-                  if (NEEDC) {\r
-                         raFile.writeBytes("    PARFUN[0] = ZCEN[0] + WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
-                                       + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
-                         raFile.writeBytes("    PARFUN[1] = ZCEN[1] + WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
-                                       + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
-                  }\r
-                  else {\r
-                         raFile.writeBytes("    PARFUN[0] = WW[IR-1][0]*(ZETA[0] - ZCEN[0]) - "\r
-                                       + "WW[IR-1][1]*(ZETA[1] - ZCEN[1]);\n");\r
-                      raFile.writeBytes("    PARFUN[1] = WW[IR-1][0]*(ZETA[1] - ZCEN[1]) + "\r
-                                       + "WW[IR-1][1]*(ZETA[0] - ZCEN[0]);\n");\r
-                  }\r
-                  raFile.writeBytes("}\n");\r
-              } // else !REFLN\r
-          } // try\r
-          catch(IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " in WRSYM2");\r
-                 System.exit(-1);\r
-          }\r
-\r
-      } // private void WRSYM2\r
-\r
-      private void WRFUN2(int NARCS,int MNARC, double STAPT[][], int ARCTY[], int PGM[],double RGM[],\r
-                 int PTX[],int NTX[],String DEFN[],int CHNL,String CHIA,String CHTT, String VAR,\r
-                 boolean NUMDER[], String REDD, RandomAccessFile raFile) {\r
-  \r
-          // COMPLEX STAPT(*)\r
-         // CHARACTER DEFN(*)*72,CHIA*2,CHTT*2,VAR*6,REDD*6\r
-               \r
-          //**** TO WRITE THE SOURCE CODE FOR DPARFN IN THE CASE WHERE NO\r
-         //**** SYMMETRY IS INVOLVED.\r
-               \r
-         //.......................................................................\r
-         //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-         //     LAST UPDATE: 4 AUG 1990\r
-         //.......................................................................\r
-               \r
-         //     LOCAL VARIABLES\r
-               \r
-         int IA,I,J1,J2,N1,N2;\r
-         String TX1, TX2;\r
-         //String FMT1, FMT2;\r
-         //CHARACTER TX1*16,TX2*21,FMT1*11,FMT2*11\r
-         //EXTERNAL PTFUN2\r
-         double STAPT2[][];\r
-         double RGM2[];\r
-         String DEFN2[];\r
-         String DEFN3[];\r
-         int K;\r
-               \r
-          TX1="      if ("+CHIA+" == ";\r
-         TX2="      else if ("+CHIA+" == ";\r
-         //FMT1="(A16,I3,A6)";\r
-         //FMT2="(A21,I3,A6)";\r
-               \r
-         try {\r
-         for (IA=1; IA <= NARCS; IA++) {\r
-                       I=PGM[IA-1];\r
-                       J1=PTX[IA-1];\r
-                       J2=PTX[IA+MNARC-1];\r
-                       N1=NTX[IA-1];\r
-                       N2=NTX[IA+MNARC-1];\r
-                       STAPT2 = new double[STAPT.length-IA+1][2];\r
-                       for (K = IA; K <= STAPT.length; K++) {\r
-                               STAPT2[K-IA][0] = STAPT[K-1][0];\r
-                               STAPT2[K-IA][1] = STAPT[K-1][1];\r
-                       }\r
-                       RGM2 = new double[RGM.length-I+1];\r
-                       for (K = I; K <= RGM.length; K++) {\r
-                               RGM2[K-I] = RGM[K-1];\r
-                       }\r
-                       DEFN2 = new String[DEFN.length-J1+1];\r
-                       for (K = J1; K <= DEFN.length; K++) {\r
-                               DEFN2[K-J1] = DEFN[K-1];\r
-                       }\r
-                       DEFN3 = new String[DEFN.length-J2+1];\r
-                       for (K = J2; K <= DEFN.length; K++) {\r
-                               DEFN3[K-J2] = DEFN[K-1];\r
-                       }\r
-                       if (NARCS == 1) {\r
-                         PTFUN2(ARCTY[IA-1],STAPT2,RGM2,N1,DEFN2,\r
-                                   N2,DEFN3,CHNL,CHTT,VAR," 1",NUMDER[IA-1],REDD,raFile);\r
-                       }\r
-                       else { \r
-                         if (IA == 1) {\r
-                               raFile.writeBytes(TX1 + IA + ") {\n");\r
-                         }\r
-                         else if (IA == NARCS) {\r
-                               raFile.writeBytes("      else {\n");\r
-                         }\r
-                         else {\r
-                               raFile.writeBytes(TX2 + IA + ") {\n");\r
-                         }\r
-                         PTFUN2(ARCTY[IA-1],STAPT2,RGM2,N1,DEFN2,\r
-                                N2,DEFN3,CHNL,CHTT,VAR,CHIA,NUMDER[IA-1],REDD,raFile);\r
-                         if (IA == NARCS) {\r
-                                 raFile.writeBytes("      }\n");\r
-                         }\r
-                       } // else\r
-         } // for (IA=1; IA <= NARCS; IA++)\r
-         } // try \r
-         catch (IOException e) {\r
-                 MipavUtil.displayError("IOException " + e + " in WRFUN2");\r
-                 System.exit(-1);\r
-         }\r
-               \r
-      } // private void WRFUN2\r
-      \r
-      private void PTFUN2(int TYPE,double STAPT[][], double RGM[],int NTX1, String TXT1[],int NTX2,\r
-          String TXT2[],int CHNL, String CHTT, String VAR, String CHIA, boolean NUMDER, String REDD,\r
-          RandomAccessFile raFile) {\r
-          //COMPLEX STAPT(*)\r
-          //CHARACTER TXT1(*)*72,TXT2(*)*72,CHTT*2,VAR*6,CHIA*2,REDD*6\r
-               \r
-         //.......................................................................\r
-         //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-         //     LAST UPDATE: 8 AUG 1990\r
-         //.......................................................................C\r
-         // **** LOCAL VARIABLES\r
-               \r
-         int I;\r
-         double HA,MD,RAD,A,R;\r
-         double C1[] = new double[2];\r
-         double CENTR[] = new double[2];\r
-         //COMPLEX C1,CENTR\r
-         //String TX1, TX1B, TX2, TX2B, TX3, FMT1, FMT2, FMT3, FMT4, FMT5;\r
-         //CHARACTER TX1*4,TX1B*5,TX2*13,TX2B*14,TX3*39,\r
-          //FMT1*25,FMT2*15,FMT3*15,FMT4*25,FMT5*24\r
-         //String TX3R, TX3I;\r
-               \r
-         //TX1 = "+"+CHTT+"*";\r
-         //TX1B = TX1 + "(";\r
-         //TX2 = "      "+VAR+" = ";\r
-         //TX2B = TX2 + "(";\r
-         //TX3R = "      "+VAR+"[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*(";\r
-         //TX3I = "      "+VAR+"[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*(";\r
-          //TX3=TX2//'(ZDER+UI*ZRAD)*EXP(UI*T)*('\r
-        \r
-         //FMT1='(A14,'//REDD//',A1,'//REDD//',A2)'\r
-         //FMT2='(A39,'//REDD//',A1)'\r
-         //FMT3='(A13,'//REDD//',A2)'\r
-         //FMT4='(A14,'//REDD//',A5,'//REDD//',A3)'\r
-         //FMT5='(A8,'//REDD//',A5,'//REDD//',A1)'\r
-               \r
-            try {\r
-           if (TYPE == 1) {\r
-                        C1[0] = 0.5*(STAPT[1][0] - STAPT[0][0]);\r
-                        C1[1] = 0.5*(STAPT[1][1] - STAPT[0][1]);\r
-                        raFile.writeBytes("//\n");\r
-                        R=C1[0];\r
-                        A=C1[1];\r
-                        raFile.writeBytes("      "+VAR+"[0] = " + R + ";\n");\r
-                        raFile.writeBytes("      "+VAR+"[1] = " + A + ";\n");\r
-                        raFile.writeBytes("//\n");\r
-                } // if (TYPE == 1)\r
-                else if (TYPE == 2) {\r
-                        CENTR[0] = RGM[0];\r
-                        CENTR[1] = RGM[1];\r
-                        C1[0] = STAPT[0][0] - CENTR[0];\r
-                        C1[1] = STAPT[0][1] - CENTR[1];\r
-                        HA = 0.5 * RGM[2];\r
-                        MD = Math.atan2(C1[1], C1[0]) + HA;\r
-                        RAD = zabs(C1[0],C1[1]);\r
-                        raFile.writeBytes("//\n");\r
-                        raFile.writeBytes(VAR+"[0] = -" + RAD+"*"+HA+"*Math.sin("+MD+"+"+CHTT+"*"+HA+");\n");\r
-                        raFile.writeBytes(VAR+"[1] = " + RAD+"*"+HA+"*Math.cos("+MD+"+"+CHTT+"*"+HA+");\n");\r
-                        raFile.writeBytes("//\n");\r
-                } // else if (TYPE == 2)\r
-                else if (NUMDER) {\r
-                        raFile.writeBytes("//\n");\r
-                        raFile.writeBytes("      "+VAR+" = ZDPARF("+CHIA+","+CHTT+");\n");\r
-                        raFile.writeBytes("//\n");  \r
-                } // else if (NUMDER)\r
-                else if (TYPE == 3) {\r
-                        MD = 0.5*(RGM[1] + RGM[0]);\r
-                        HA = 0.5*(RGM[1] - RGM[0]);\r
-                        raFile.writeBytes("//\n");  \r
-                        raFile.writeBytes("      T = " + MD+"+"+CHTT+"*"+"("+HA+");\n");\r
-                        raFile.writeBytes("      "+VAR+" = " +HA + "*(");\r
-                        for (I = 1; I <= NTX2; I++) {\r
-                                raFile.writeBytes(TXT2[I-1]);\r
-                        }\r
-                        raFile.writeBytes(");\n");\r
-                        raFile.writeBytes("//\n");      \r
-                } // else if (TYPE == 3)\r
-                else {\r
-                        MD = 0.5*(RGM[1] + RGM[0]);\r
-                        HA = 0.5*(RGM[1] - RGM[0]);\r
-                        raFile.writeBytes("//\n");  \r
-                        raFile.writeBytes("      T = " + MD+"+"+CHTT+"*"+"("+HA+");\n");\r
-                        raFile.writeBytes("      ZRAD = ");\r
-                        for (I = 1; I <= NTX1; I++) {\r
-                                raFile.writeBytes(TXT1[I-1]);\r
-                        }\r
-                        raFile.writeBytes(";\n");\r
-                        raFile.writeBytes("      ZDEr = ");\r
-                        for (I = 1; I <= NTX2; I++) {\r
-                                raFile.writeBytes(TXT2[I-1]);\r
-                        }\r
-                        raFile.writeBytes(";\n");      \r
-                        raFile.writeBytes("      "+VAR+"[0] = (ZDER * Math.cos(T) - ZRAD * Math.sin(T))*("+HA+");\n");  \r
-                        raFile.writeBytes("      "+VAR+"[1] = (ZDER * Math.sin(T) + ZRAD * Math.cos(T))*("+HA+");\n");\r
-                        raFile.writeBytes("//\n");      \r
-                } // else\r
-            } // try\r
-            catch(IOException e) {\r
-                MipavUtil.displayError("IOException " + e + " in PTFUN2");\r
-                System.exit(-1);\r
-            }\r
-               \r
-    }\r
-      \r
-   private void WRSYM3(int NARCS,int ORDRG, boolean REFLN, int CHN, RandomAccessFile raFile) {\r
-\r
-    //**** TO WRITE THE CODE TO RECOVER THE DERIVATIVE FROM ITS SYMMETRIC\r
-    //**** COUNTERPART ON THE FUNDAMENTAL BOUNDARY SECTION.\r
-\r
-    //.......................................................................\r
-    // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-    // LAST UPDATE: 4 AUG 1990\r
-    //.......................................................................C\r
-    //     LOCAL VARIABLES\r
-\r
-    int I;\r
-\r
-\r
-    try {\r
-           raFile.writeBytes("//\n"); \r
-       \r
-           if (REFLN) {\r
-               if (ORDRG > 1) {\r
-                   I=2*NARCS;\r
-                   if (NARCS > 1) {\r
-                       raFile.writeBytes("      IS = (IA-IB)%"+I+";\n");\r
-                       raFile.writeBytes("      IR=(IA-IB-IS)/"+I+";\n");\r
-                   }\r
-                   else {\r
-                       raFile.writeBytes("      IS=(IA-1)%2;\n");\r
-                       raFile.writeBytes("      IR=(IA-1-IS)/2;\n");\r
-                   }\r
-                   raFile.writeBytes("      if ((IR == 0) && (IS == 0)) {\n");\r
-                   raFile.writeBytes("          DPARFN[0] =ZETA[0];\n");\r
-                   raFile.writeBytes("          DPARFN[1] =ZETA[1];\n");\r
-                   raFile.writeBytes("      }\n");\r
-                   raFile.writeBytes("      else if ((IR > 0) && (IS == 0)) {\n");\r
-                   raFile.writeBytes("          DPARFN[0] = WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
-                   raFile.writeBytes("          DPARFN[1] = WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\n");\r
-                   raFile.writeBytes("      }\n");\r
-                   raFile.writeBytes("       else if ((IR == 0 && (IS > 0)) {\n");\r
-                   raFile.writeBytes("           DPARFN[0] = -U2[0]*ZETA[0] -U2[1]*ZETA[1];\n");\r
-                   raFile.writeBytes("           DPARFN[1] = U2[0]*ZETA[1] -U2[1]*ZETA[0];\n");\r
-                   raFile.writeBytes("       }\n");\r
-                   raFile.writeBytes("       else {\n");\r
-                   raFile.writeBytes("           double realPart = -U2[0]*WW[IR-1][0] + U2[1]*WW[IR-1][1]);\n");\r
-                   raFile.writeBytes("           double imagPart = -U2[0]*WW[IR-1][1] + U2[1]*WW[IR-1][0]);\n");\r
-                   raFile.writeBytes("           DPARFN[0] = realPart*ZETA[0] + imagPart*ZETA[1]);\n");\r
-                   raFile.writeBytes("           DPARFN[1] = imagPart*ZETA[0] - realPart*ZETA[1]);\n"); \r
-                   raFile.writeBytes("       }\n");\r
-               } // if (ORDRG > 1)\r
-               else {\r
-                   if (NARCS > 1) {\r
-                       raFile.writeBytes("      IS=IA-IB;\n");\r
-                   }\r
-                   else {\r
-                       raFile.writeBytes("      IS=IA-1;\n");\r
-                   }\r
-                   raFile.writeBytes("      if (IS == 0) {\n");\r
-                   raFile.writeBytes("          DPARFN[0] = ZETA[0]\n");\r
-                   raFile.writeBytes("          DPARFN[0] = ZETA[0]\n");\r
-                   raFile.writeBytes("      }\n");\r
-                   raFile.writeBytes("         else {\n");\r
-                   raFile.writeBytes("             DPARFN[0] = -U2[0]*ZETA[0] + U2[1]*ZETA[1]);\n");\r
-                   raFile.writeBytes("             DPARFN[1] = U2[0]*ZETA[1] - U2[1]*ZETA[0]);\n");\r
-                   raFile.writeBytes("         }\n");\r
-               } // else\r
-           } // if (REFLN)\r
-           else {\r
-               if (NARCS > 1) {\r
-                   raFile.writeBytes("      IR=(IA-IB)/"+NARCS+";\n");\r
-               }\r
-               else {\r
-                   raFile.writeBytes("      IR=IA-1;\n");\r
-               }\r
-               raFile.writeBytes("      if (IR == 0) {\n");\r
-               raFile.writeBytes("          DPARFN[0] = ZETA[0];\n");\r
-               raFile.writeBytes("          DPARFN[1] = ZETA[1];\n");\r
-               raFile.writeBytes("      }\n");\r
-               raFile.writeBytes("      else {\n");\r
-               raFile.writeBytes("          DPARFN[0]= WW[IR-1][0]*ZETA[0] - WW[IR-1][1]*ZETA[1];\n");\r
-               raFile.writeBytes("          DPARFN[1]= WW[IR-1][0]*ZETA[1] + WW[IR-1][1]*ZETA[0];\n");\r
-               raFile.writeBytes("      }\n");\r
-           }\r
-    } // try\r
-    catch(IOException e) {\r
-       MipavUtil.displayError("IOException " + e + " in WRSYM3");\r
-       System.exit(-1);\r
-    }\r
-\r
-    } // private void WRSYM3\r
-   \r
-   private void TSTPLT(String JBNM, double MXMIS, double MXDIF, int NARCS, double PSD,\r
-                  double MINPD, double MAXPD, int CHNL, int IER[]) {\r
-   //CHARACTER*4 JBNM\r
-\r
-    //......................................................................\r
-\r
-    // 1.     TSTPLT\r
-    //           TESTS THE PARAMETRIC FUNCTION ROUTINES PARFUN AND DPARFN\r
-    //           FOR CONSISTENCY AND OUTPUTS BOUNDARY POINTS FOR PLOTTING.\r
-           \r
-\r
-    // 2.     PURPOSE\r
-    //           THE ROUTINE FIRST CHECKS THAT THE PARAMETRIC FUNCTION\r
-    //           ROUTINE PARFUN IS CONSISTENT WITH RESPECT TO ITS DEFINITION\r
-    //           OF ANY CORNERS ON THE BOUNDARY.  THIS IS DONE BY CHECKING \r
-    //           THAT THE COMPUTED POINT AT THE END OF EACH ARC MATCHES THE \r
-    //           COMPUTED POINT AT THE START OF THE NEXT ONE.  IF ALL THE\r
-    //           RELATIVE MISFIT ERRORS AT CORNERS ARE LESS THAN\r
-    //           10*(UNIT ROUNDOFF) THEN ALL CORNERS ARE CONSIDERED TO FIT\r
-    //           SATISFACTORILY, OTHERWISE THE MAXIMUM RELATIVE MISFIT\r
-    //           ERROR IS REPORTED.\r
-\r
-    //           THE SECOND PURPOSE OF THE ROUTINE IS TO OUTPUT TO A DATA \r
-    //           FILE THE COORDINATES OF A NUMBER OF POINTS ON THE BOUNDARY. \r
-    //           THE BOUNDARY POINTS ARE SELECTED ADAPTIVELY TO MEET THE \r
-    //           PLOTTING RESOLUTION SPECIFICATIONS DEFINED BY THE ARGUMENTS \r
-    //           PSD,MINPD,MAXPD (SEE BELOW).  THE HOPE IS THAT THE USER MAY \r
-    //           EASILY FEED THESE DATA POINTS TO HIS LOCAL GRAPH PLOTTING  \r
-    //           ROUTINES SO AS TO CONSTRUCT A PLOT OF THE BOUNDARY.  THIS   \r
-    //           WILL PROVIDE AN ESSENTIAL VISUAL CHECK ON THE VALIDITY OF \r
-    //           THE ROUTINE PARFUN.  THE OUTPUT DATA FILE IS AUTOMATICALLY \r
-    //           NAMED <JBNM>zz.\r
\r
-    //           THE THIRD PURPOSE OF THE ROUTINE IS TO CHECK PARFUN AND \r
-    //           DPARFN FOR MUTUAL CONSISTECY.  THIS IS DONE BY COMPUTING \r
-    //           TWO POINT FINITE DIFFERENCE APPROXIMATIONS TO DPARFN.  \r
-    //           THESE DIFFERENCE APPROXIMATIONS ARE COMPUTED AT EACH BOUND- \r
-    //           ARY POINT THAT IS OUTPUT FOR PLOTTING AND ALSO AT NEARBY \r
-    //           POINTS WHICH LIE JUST O F F THE BOUNDARY.  THIS LATTER \r
-    //           COMPARISON ALSO TESTS PARFUN AND DPARFN FOR CORRECTNESS IN \r
-    //           ACCEPTING COMPLEX PARAMETER VALUES.   A RELATIVE ERROR IN \r
-    //           THE FINITE DIFFERENCE APPROXIMATION GREATER THAN 0.1 IS \r
-    //           REPORTED AS A POSSIBLE LOGICAL INCONSISTENCY BETWEEN PARFUN \r
-    //           AND DPARFN.  (THE CRITICAL RELATIVE ERROR VALUE OF 0.1 CAN \r
-    //           BE ALTERED BY ADJUSTING THE LOCAL PARAMETER DTOL).\r
-\r
-    // 3.     CALLING SEQUENCE\r
-    //           CALL TSTPLT(JBNM,MXMIS,MXDIF,NARCS,PSD,MINPD,MAXPD,CHNL,IER)\r
-\r
-    //        PARAMETERS\r
-    //         ON ENTRY\r
-    //            JBNM   - CHARACTER*4\r
-    //                     THE JOB NAME.  THIS IS USED TO CREATE THE OUTPUT \r
-    //                     FILE WITH FILENAME\r
-\r
-    //                                <JBNM>zz ,\r
-\r
-    //                     WHERE <JBNM> DENOTES THE VALUE OF VARIABLE JBNM\r
-    //                     WITH ANY TRAILING SPACES DELETED.\r
-\r
-    //            NARCS  - INTEGER\r
-    //                     THE NUMBER OF ANALYTIC ARCS THAT MAKE UP THE \r
-    //                     W H O L E BOUNDARY OF THE PHYSICAL DOMAIN.\r
-\r
-    //            PSD    - REAL\r
-    //                     THE PLOTTING SIZE FOR THE DOMAIN IN ANY APPROPR-\r
-    //                     IATE UNITS.  IF PSD .LE. 0.0 THEN IT IS ASSIGNED\r
-    //                     THE DEFAULT VALUE OF 160.0 (A REASONBLE WIDTH IN\r
-    //                     MM FOR PLOTTING ON A4 PAPER).\r
-\r
-    //            MINPD  - REAL\r
-    //                     THE MINIMUM SIGNIFICANT PLOTTING DISTANCE, IN THE\r
-    //                     SAME UNITS AS PSD.  IF PSD .LE. 0.0 THEN IT IS\r
-    //                     ASSIGNED THE DEFAULT VALUE OF 2.0.\r
-\r
-    //            MAXPD  - REAL\r
-    //                     THE MAXIMUM ALLOWED PLOTTING DISTANCE, IN THE\r
-    //                     SAME UNITS AS PSD.  IF PSD .LE. 0.0 THEN IT IS\r
-    //                     ASSIGNED THE DEFAULT VALUE OF 5.0.  THE LARGER\r
-    //                     MAXPD, THE COARSER WILL BE THE RESOLUTION OF THE\r
-    //                     BOUNDARY POINTS OUTPUT TO <JBNM>zz, BUT THE\r
-    //                     QUICKER THEY WILL BE COMPUTED. \r
-\r
-    //            CHNL   - INTEGER\r
-    //                     DEFINES AN OUTPUT CHANNEL THAT MAY BE USED FOR\r
-    //                     WRITING THE FILE <JBNM>zz.\r
-    //         ON EXIT\r
-    //            MXMIS  - REAL\r
-    //                     THE MAXIMUM RELATIVE MISFIT ERROR OVER ALL\r
-    //                     CORNER POINTS\r
-\r
-    //            MXDIF  - REAL\r
-    //                     THE MAXIMUM RELATIVE ERROR IN FINITE DIFFERENCE\r
-    //                     APPROXIMATIONS TO DPARFN OVER ALL BOUNDARY \r
-    //                     POINTS OUTPUT TO <JBNM>zz AND NEARBY POINTS OFF\r
-    //                     THE BOUNDARY.\r
-\r
-    //            PSD    - REAL\r
-    //                     IF PSD .LE. 0.0 ON ENTRY THEN IT WILL HAVE\r
-    //                     THE DEFAULT VALUE OF 160.0 ON  EXIT.\r
-\r
-    //            MINPD  - REAL\r
-    //                     IF PSD .LE. 0.0 ON ENTRY THEN MINPD WILL HAVE\r
-    //                     THE DEFAULT VALUE OF 2.0 ON EXIT\r
-\r
-    //            MAXPD  - REAL\r
-    //                     IF PSD .LE. 0.0 ON ENTRY THEN MAXPD WILL HAVE\r
-    //                     THE DEFAULT VALUE OF 5.0 ON EXIT\r
-\r
-    //            IER    - INTEGER\r
-    //                     IF IER > 0 THEN AN ABNORMAL EXIT HAS OCCURRED;\r
-    //                     A MESSAGE TO DESCRIBE THE ERROR IS AUTOMATICALLY\r
-    //                     WRITTEN ON THE STANDARD OUTPUT CHANNEL.\r
-    //                     IER=0 - NORMAL EXIT.\r
-    //                     IER>0 - ABNORMAL EXIT; THE ERROR MESSAGE SHOULD\r
-    //                             BE SELF EXPLANATORY.\r
-\r
-\r
-    // 4.     SUBROUTINES OR FUNCTIONS NEEDED\r
-    //              - THE CONFPACK LIBRARY.\r
-    //              - THE REAL FUNCTION R1MACH.\r
-    //              - THE USER SUPPLIED COMPLEX FUNCTIONS PARFUN AND DPARFN.\r
-\r
-\r
-    // 5.     FURTHER COMMENTS\r
-    //              - A SUMMARY LISTING IS AUTOMATICALLY WRITTEN ON THE \r
-    //                STANDARD OUTPUT CHANNEL.\r
-    //              - THE OUTPUT FILE <JBNM>zz CONTAINS COORDINATE PAIRS\r
-\r
-    //                                 X Y\r
-\r
-    //                FOR POINTS ON THE PHYSICAL BOUNDARY, WITH ONE PAIR\r
-    //                PER LINE.\r
-\r
-    // ......................................................................\r
-    //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-    //     LAST UPDATE: 6 JULY 1990\r
-    // ......................................................................C\r
-    //     LOCAL VARIABLES\r
-\r
-    int I,IA;\r
-    int IMX = 0;\r
-    double TINC = 0.0;\r
-    double TMX = 0.0;\r
-    double A1,DIFF,ERR,HH,MINC,RMAX,RMEAN,RMIN,T,TOL1,TSD;\r
-    double TT[] = new double[2];\r
-    //REAL TT(2)\r
-    double C1[] = new double[2];\r
-    double C2[] = new double[2];\r
-    double CENTR[] = new double[2];\r
-    double ZZ0[] = new double[2];\r
-    double DZZ[] = new double[2];\r
-    double NDZZ[] = new double[2];\r
-    //COMPLEX C1,C2,CENTR,ZZ0,DZZ,NDZZ;\r
-    double ZZ[][] = new double[2][2];\r
-    //COMPLEX ZZ(2)\r
-    //CHARACTER OFL*6\r
-    final int MNARC = 200;\r
-    final double DTOL = 1.0E-1;\r
-    final int NH = 4;\r
-    boolean ATEND,FIRST,WARND;\r
-    boolean LNSEG[] = new boolean[MNARC];\r
-    double PIN[] = new double[2];\r
-    double PAROUT[];\r
-    int zzindex;\r
-    double cr[] = new double[1];\r
-    double ci[] = new double[1];\r
-    //EXTERNAL DPARFN,LINSEG,PARFUN,R1MACH,WRHEAD,WRTAIL,ZDPARF\r
-    //COMPLEX PARFUN,DPARFN,ZDPARF\r
-\r
-    //**** WRITE CONFPACK HEADING\r
-\r
-    WRHEAD(7,0,null);\r
-\r
-    if (NARCS > MNARC) {\r
-        IER[0]=59;\r
-        WRTAIL(7,0,IER[0], null);\r
-    }\r
-\r
-    //1     FORMAT(A45)\r
-    //2     FORMAT(A45,I4)\r
-    //3     FORMAT(A45,E10.3)\r
-    //4     FORMAT(//,T17,A)\r
-\r
-    TOL1= 10.0*EPS;\r
-\r
-    //**** CHECK THAT ALL ARCS MEET AT CORNER POINTS\r
-\r
-    IER[0]=0;\r
-    CENTR[0] = 0.0;\r
-    CENTR[1] = 0.0;\r
-    MXMIS=0.0;\r
-    for (IA=1; IA <= NARCS; IA++) {\r
-        if (IA == 1) {\r
-            I=NARCS;\r
-        }\r
-        else {\r
-            I=IA-1;\r
-        }\r
-        PIN[0] = -1.0;\r
-        PIN[1] = 0.0;\r
-        C1 = PARFUN(IA, PIN);\r
-        CENTR[0] = CENTR[0] + C1[0];\r
-        CENTR[1] = CENTR[1] + C1[1];\r
-        A1 = zabs(C1[0],C1[1]);\r
-        PIN[0] = 1.0;\r
-        PIN[1] = 0.0;\r
-        C2=PARFUN(I,PIN);\r
-        ERR = zabs(C1[0]-C2[0],C1[1]-C2[1]);\r
-        if (A1 >= 1.0) {\r
-            ERR=ERR/A1;\r
-        }\r
-        if (ERR > MXMIS) {\r
-            IMX=IA;\r
-            MXMIS=ERR;\r
-        }\r
-    } // for (IA=1; IA <= NARCS; IA++)\r
-       if (MXMIS >= TOL1) {\r
-        System.out.println("MAXIMUM CORNER MISFIT: " + MXMIS);\r
-        System.out.println("OCCURS AT CORNER: " + IMX);\r
-    }\r
-    else {\r
-        System.out.println("ALL ARCS FIT AT CORNERS:");\r
-    }  \r
-\r
-    // **** ESTIMATE THE DIAMETER (TSD) OF THE PHYSICAL DOMAIN\r
-\r
-    CENTR[0]=CENTR[0]/NARCS;\r
-    CENTR[1]=CENTR[1]/NARCS;\r
-    TSD=0.0;\r
-    HH=2.0/(double)(NH);\r
-    for (IA=1; IA <= NARCS; IA++) {\r
-        T=-1.0;\r
-        for (I=1; I <= NH; I++) {\r
-            T=T+HH;\r
-            PIN[0] = T;\r
-            PIN[1] = 0;\r
-            PAROUT = PARFUN(IA,PIN);\r
-            C1[0] = PAROUT[0] - CENTR[0];\r
-            C1[1] = PAROUT[1] - CENTR[1];\r
-            A1=zabs(C1[0],C1[1]);\r
-            TSD=Math.max(TSD,A1);\r
-        } // for (I=1; I <= NH; I++)\r
-    } // for (IA=1; IA <= NARCS; IA++)\r
-   TSD=2.0*TSD;\r
-\r
-   //**** DETERMINE WHICH ARCS (IF ANY) ARE LINE SEGMENTS\r
-\r
-   LINSEG(LNSEG,NARCS);\r
-\r
-   //**** OPEN FILE TO RECEIVE BOUNDARY DATA POINTS FOR PLOTTING\r
-\r
-   //L=INDEX(JBNM,' ')-1\r
-   //IF (L.EQ.-1) L=4\r
-   //OFL=JBNM(1:L)//'zz'\r
-   //OPEN(CHNL,FILE=OFL)\r
-   // Use global zzset instead\r
-\r
-   // **** SET DEFAULT PLOTTING DISTANCES, IF NECESSARY\r
-\r
-   if (PSD <= 0.0) {\r
-       PSD=1.6E+2;\r
-       MINPD=2.0;\r
-       MAXPD=5.0;\r
-   }\r
-   RMIN=MINPD*TSD/PSD;\r
-   RMAX=MAXPD*TSD/PSD;\r
-   RMEAN=0.5*(RMIN+RMAX);\r
-   MINC=Math.sqrt(EPS);\r
-   \r
-   // **** START EVALUATING BOUNDARY POINTS AND DERIVATIVES FOR PLOTTING AND\r
-   // **** TESTING\r
-\r
-   MXDIF=0.0;\r
-   zzindex = 0;\r
-   for (IA=1; IA <= NARCS; IA++) {\r
-       TT[0]=-1.0;\r
-       PIN[0] = TT[0];\r
-       PIN[1] = 0.0;\r
-       ZZ[0]=PARFUN(IA,PIN);\r
-       zzset[zzindex][0] = ZZ[0][0];\r
-       zzset[zzindex++][1] = ZZ[0][1];\r
-       if (IA == 1) {\r
-          ZZ0[0] = ZZ[0][0];\r
-          ZZ0[1] = ZZ[0][1];\r
-       }\r
-       FIRST = true;\r
-       WARND= false;\r
-       while (true) {\r
-          \r
-           //****   TEST THE COMPATIBILTY OF PARFUN AND DPARFN BY ESTIMATING DPARFN\r
-           //****   NUMERICALLY AT BOTH REAL AND COMPLEX PARAMETER VALUES.\r
-\r
-                for (I=1; I <= 2; I++) {\r
-                    if (I == 1) {\r
-                        C1[0]=TT[0];\r
-                        C1[1] = 0.0;\r
-                    }\r
-                    else {\r
-                        C1[0]=TT[0];\r
-                     C1[1] = MINC;\r
-                    }\r
-                    DZZ=DPARFN(IA,C1);\r
-                    NDZZ=ZDPARF(IA,C1);\r
-                    A1=zabs(DZZ[0],DZZ[1]);\r
-       \r
-                    if (A1 == 0.0) {\r
-                        IER[0]=60;\r
-                        System.out.println();\r
-                        System.out.println("              ***DPARFN=(0.,0.)***");\r
-                        System.out.println("                             ARC: " + IA); \r
-                        System.out.println(" STANDARDISED PARAMETER VALUE: " + TT[0]);\r
-                        WRTAIL(7,0,IER[0],null);\r
-                        return;\r
-                    } // if (A1 == 0.0)\r
-       \r
-                    if (A1 <=TOL1 && !WARND) {\r
-                        System.out.println("*** W A R N I N G  ***");\r
-                        System.out.println("PATHOLOGICALLY SMALL DERIVATIVE ON ARC" + IA);\r
-                        WARND=true;\r
-                    } // if (A1 <=TOL1 && !WARND)\r
-       \r
-                    if (FIRST) {\r
-                        TINC=RMEAN/A1;\r
-                        TINC=Math.max(TINC,MINC);\r
-                        FIRST=false;\r
-                    } // if (FIRST)\r
-       \r
-                    zdiv(1.0-NDZZ[0],-NDZZ[1],DZZ[0],DZZ[1],cr,ci);\r
-                    ERR = zabs(cr[0],ci[0]);\r
-                    if (ERR > MXDIF) {\r
-                        MXDIF=ERR;\r
-                        IMX=IA;\r
-                        TMX=TT[0];\r
-                    } // if (ERR > MXDIF)\r
-                } // for (I=1; I <= 2; I++)\r
-       \r
-            if (!LNSEG[IA-1]) {\r
-       \r
-                //DETERMINE THE NEXT BOUNDARY POINT TO BE PLOTTED\r
-                while (true) {\r
-                    TT[1]=TT[0]+TINC;\r
-                    if (TT[1] >= 1.0) {\r
-                        TT[1]=1.0;\r
-                        ATEND=true;\r
-                    }\r
-                    else {\r
-                        ATEND=false;\r
-                    }\r
-              \r
-                    PIN[0] = TT[1];\r
-                    PIN[1] = 0.0;\r
-                    ZZ[1] = PARFUN(IA,PIN);\r
-                    DIFF=zabs(ZZ[1][0]-ZZ[0][0],ZZ[1][1]-ZZ[0][1]);\r
-                    if (DIFF == 0.0 && !ATEND) {\r
-                        TINC=Math.max(MINC,2*TINC);\r
-                        continue;\r
-                    } // if (DIFF == 0.0 && !ATEND)\r
-       \r
-                    if (DIFF > RMAX || (DIFF < RMIN && !ATEND)) {\r
-                        TINC=RMEAN*TINC/DIFF;\r
-                        TINC=Math.max(TINC,MINC);\r
-                        continue;\r
-                    } // if (DIFF > RMAX || (DIFF < RMIN && !ATEND))\r
-                    break;\r
-                } // while (true)\r
-       \r
-                zzset[zzindex][0] = ZZ[1][0];\r
-                zzset[zzindex++][1] = ZZ[1][1];\r
-                if (!ATEND) {\r
-                    ZZ[0][0]=ZZ[1][0];\r
-                    ZZ[0][1] = ZZ[1][1];\r
-                    TT[0]=TT[1];\r
-              }\r
-              else {\r
-                  break;\r
-              }\r
-            } // if (!LNSEG[IA-1])\r
-            else {\r
-                break;\r
-            }\r
-       } // while (true)\r
-\r
-   } // for (IA=1; IA <= NARCS; IA++)\r
-   if (LNSEG[NARCS-1]) {\r
-          zzset[zzindex][0] = ZZ0[0];\r
-       zzset[zzindex++][1] = ZZ0[1];\r
-   }   \r
-\r
-   if (MXDIF > DTOL) {\r
-       System.out.println();\r
-       System.out.println("POSSIBLE PARFUN/DPARFN INCONSISTECY ON ARC: " + IMX);\r
-       System.out.println("OCCURS AT STANDARDISED PARAMETER VALUE: " + TMX);\r
-       System.out.println("RELATIVE FINITE DIFF ERROR: " + MXDIF);\r
-   }\r
-   else {\r
-       System.out.println();\r
-       System.out.println("PARFUN AND DPARFN ARE CONSISTENT:");\r
-   }\r
-\r
-   WRTAIL(7,0,IER[0],null);\r
-\r
-   } // private void TSTPLOT\r
-   \r
-   private void LINSEG(boolean LNSEG[], int NARCS) {\r
-\r
-       //**** TO DETERMINE THE ARRAY LNSEG, WHERE LNSEG(I) IS SET TO TRUE IF THE\r
-       //**** I'TH ARC IS A LINE SEGMENT, I=1,...,NARCS.\r
-\r
-       //**** LOCAL VARIABLES\r
-\r
-       final int NPTS = 9;\r
-          int IA,J,NINTS;\r
-       double DIFF,HH,MXDIF,TOL;\r
-       double SUM[] = new double[2];\r
-       double TT[] = new double[2];\r
-       // COMPLEX SUM,TT\r
-       double DF[][] = new double[NPTS][2];\r
-       //COMPLEX DF(NPTS)\r
-       //EXTERNAL DPARFN,R1MACH\r
-       // COMPLEX DPARFN\r
-\r
-       NINTS=NPTS-1;\r
-       HH=2.0/NINTS;\r
-       TOL=10.0*EPS;\r
-\r
-       for (IA=1; IA <= NARCS; IA++) {\r
-          SUM[0] = 0.0;\r
-          SUM[1] = 0.0;\r
-           for (J=1; J <= NPTS; J++) {\r
-               TT[0]=-1.0+(J-1)*HH;\r
-               TT[1] = 0.0;\r
-               DF[J-1]=DPARFN(IA,TT);\r
-               SUM[0]=SUM[0]+DF[J-1][0];\r
-               SUM[1]=SUM[1]+DF[J-1][1];\r
-           } // for (J=1; J <= NPTS; J++)\r
-           SUM[0]=SUM[0]/NPTS;\r
-           SUM[1]=SUM[1]/NPTS;\r
-\r
-           MXDIF=0.0;\r
-           for (J=1; J <= NPTS; J++) {\r
-               DIFF=zabs(SUM[0]-DF[J-1][0],SUM[1]-DF[J-1][1]);\r
-               MXDIF = Math.max(MXDIF,DIFF);\r
-           } // for (J=1; J <= NPTS; J++)\r
-\r
-           if (MXDIF <= TOL) {\r
-               LNSEG[IA-1] = true;\r
-           }\r
-           else {\r
-               LNSEG[IA-1] = false;\r
-           }\r
-       } // for (IA=1; IA <= NARCS; IA++)\r
-\r
-   } // private void LINSEG\r
-   \r
-\r
-   //COMPLEX FUNCTION ZDPARF(I,T)\r
-   private double[] ZDPARF(int I, double T[]) {\r
-       //COMPLEX T\r
-\r
-       //**** NUMERICAL ESTIMATION OF THE DERIVATIVE OF THE PARAMETRIC FUNCTION\r
-       //**** USING 2- OR 4-POINT TRAPEZOIDAL RULE ESTIMATES IN CAUCHY'S\r
-       //**** FORMULA.  THE 2-POINT ESTIMATE IS THE STANDARD CENTRAL DIFFERENCE\r
-       //**** IN THE REAL AXIS DIRECTION.\r
-\r
-       double EPSZ;\r
-       //final double IM[] = new double[]{0.0,1.0};\r
-       final boolean FOUR = false;\r
-       double SUM[] = new double[2];\r
-       //COMPLEX IM,SUM\r
-       double POUT1[];\r
-       double POUT2[];\r
-       double result[] = new double[2];\r
-       double PIN[] = new double[2];\r
-\r
-       //EXTERNAL PARFUN\r
-       // COMPLEX PARFUN\r
-\r
-       EPSZ = Math.pow(EPS, 0.3333);\r
-       PIN[0] = T[0] + EPSZ;\r
-       PIN[1] = T[1];\r
-       POUT1 = PARFUN(I,PIN);\r
-       PIN[0] = T[0] - EPSZ;\r
-       PIN[1] = T[1];\r
-       POUT2 = PARFUN(I,PIN);\r
-       SUM[0] = (POUT1[0] - POUT2[0])/2.0/EPSZ;\r
-       SUM[1] = (POUT1[1] - POUT2[1])/2.0/EPSZ;\r
-\r
-       if (FOUR) {\r
-           PIN[0] = T[0];\r
-           PIN[1] = T[1]+EPSZ;\r
-           POUT1 = PARFUN(I,PIN);\r
-           PIN[0] = T[0];\r
-           PIN[1] = T[1]-EPSZ;\r
-           POUT2 = PARFUN(I,PIN);\r
-            result[0] = SUM[0]/2.0 + (POUT1[1] - POUT2[1])/4.0/EPSZ;\r
-            result[1] = SUM[1]/2.0 - (POUT1[0] - POUT2[0])/4.0/EPSZ;\r
-       }\r
-       else {\r
-            result[0]=SUM[0];\r
-            result[1] = SUM[1];\r
-       }\r
-       return result;\r
-   }\r
-\r
-   private void JAPHYC(double MAXER,\r
-                     int ISYGP, boolean INCST,\r
-                     int RFARC, double RFARG[], int TSTNG,int OULVL,\r
-                     double MATRX[][][],\r
-                     int IER[]) {\r
-               \r
-                     //INTEGER IBNDS(*),IGEOM(*),ISNPH(*),IWORK(*)\r
-                     //REAL RGEOM(*),MATRX(MNEQN,MNEQN,2),RSNPH(*),RWORK(*)\r
-                     //COMPLEX CENTR\r
-                     //COMPLEX ZWORK(*)\r
-                     //LOGICAL LWORK(*)\r
-                     //CHARACTER JBNM*4,HEAD*72\r
-               \r
                // ......................................................................\r
-               \r
-               // 1.     JAPHYC\r
-               //           COMPUTATION OF PIECEWISE ORTHOGONAL JACOBI POLYNOMIAL \r
-               //           APPROXIMATIONS TO THE BOUNDARY CORRESPONDENCE DERIVATIVE FOR\r
-               //           THE MAP:PHYSICAL --> CANONICAL.\r
-               \r
-               // 2.     PURPOSE\r
-               //           THE MAIN PURPOSE IS TO CALCULATE THE COEFFICIENTS IN THE\r
-               //           PIECEWISE ORTHOGONAL JACOBI POLYNOMIAL APPROXIMATIONS TO THE\r
-               //           BOUNDARY CORRESPONDENCE DERIVATIVE FOR THE CONFORMAL MAP OF\r
-               //           A GIVEN SIMPLY CONNECTED PHYSICAL DOMAIN (WITH PIECEWISE\r
-               //           ANALYTIC BOUNDARY) ONTO A CANONICAL DOMAIN (WITH UNIT CIRCLE\r
-               //           AS BOUNDARY).  AN INTERIOR PHYSICAL DOMAIN IS MAPPED TO THE \r
-               //           UNIT DISC, AN EXTERIOR PHYSICAL DOMAIN TO THE COMPLEMENT OF\r
-               //           THE CLOSED UNIT DISC.\r
-               //           THE METHOD USED IS AN ADAPTIVE COLLOCATION SOLUTION OF\r
-               //           SYMM'S INTEGRAL EQUATION.  \r
-               //           A NUMBER OF DATA ARRAYS ASSOCIATED WITH THE POLYNOMIAL\r
-               //           APPROXIMATIONS ARE ALSO COMPUTED AND MAY BE USED FOR SUBSE-\r
-               //           QUENT PROCESSING.  IN ADDITION TO BEING RETURNED AS \r
-               //           PARAMETERS OF THE SUBROUTINE THESE ARE ALSO AUTOMATICALLY\r
-               //           OUTPUT TO DATA FILES.\r
-               \r
-               // 3.     CALLING SEQUENCE\r
-               //           CALL JAPHYC(JBNM,HEAD,MAXER,INTER,NARCS,ISYGP,NQPTS,INCST,\r
-               //                       RFARC,RFARG,CENTR,TSTNG,OULVL,IBNDS,MATRX,IWORK,\r
-               //                       RWORK,ZWORK,LWORK,OCH,IGEOM,RGEOM,ISNPH,RSNPH,\r
-               //                       IER)\r
-               \r
-               //        PARAMETERS\r
-               //         ON ENTRY\r
-               //            JBNM   - CHARACTER*4\r
-               //                     THE JOB NAME.  THIS IS USED TO CREATE THREE OUT-\r
-               //                     PUT FILES WITH FILENAMES\r
-               \r
-               //                         <JBNM>pl, <JBNM>gm, <JBNM>ph,\r
-               \r
-               //                     WHERE <JBNM> DENOTES THE VALUE OF VARIABLE JBNM\r
-               //                     WITH ANY TRAILING SPACES DELETED.  THE FIRST OF\r
-               //                     THESE IS A LISTING FILE RECORDING THE PROGRESS\r
-               //                     AND RESULTS OF THE CALCULATION FOR LATER READING\r
-               //                     BY THE USER.  THE TWO FILES <JBNM>gm AND <JBNM>ph\r
-               //                     ARE DATA FILES, NOT REALLY INTENDED TO BE READ\r
-               //                     BY THE USER.\r
-               //                     THE VALUE OF JBNM IS ALSO THE ONLY ITEM IN A\r
-               //                     FOURTH OUTPUT FILE NAMED (LITERALLY) jbnm.\r
-               \r
-               //            HEAD   - CHARACTER*72\r
-               //                     A HEADING FOR THE PROBLEM, TO APPEAR ON THE\r
-               //                     LISTING FILE <JBNM>pl.\r
-               \r
-               //            MAXER  - REAL\r
-               //                     RELATIVE ACCURACY REQUESTED FOR THE CONFORMAL MAP;\r
-               //                     THIS IS THE SAME AS THE ABSOLUTE ACCURACY ON THE\r
-               //                     BOUNDARY OF THE PHYSICAL DOMAIN.\r
-               \r
-               //            INTER  - LOGICAL\r
-               //                     TRUE IF THE PHYSICAL DOMAIN IS INTERIOR, FALSE \r
-               //                     OTHERWISE.\r
-               \r
-               //            NARCS  - INTEGER\r
-               //                     THE NUMBER OF ANALYTIC ARCS THAT MAKE UP THE \r
-               //                     W H O L E BOUNDARY OF THE PHYSICAL DOMAIN.\r
-               \r
-               //            ISYGP  - INTEGER\r
-               //                     THE MAGNITUDE OF ISYGP IS THE ORDER OF THE\r
-               //                     SYMMETRY GROUP OF THE PHYSICAL DOMAIN.\r
-               //                     ISYGP.EQ.1  -THE SYMMETRY GROUP HAS ONLY ONE ELE-\r
-               //                                  MENT,THE IDENTITY TRANSFORMATION;  IN\r
-               //                                  OTHER WORDS, THE DOMAIN HAS 'NO \r
-               //                                  SYMMETRY'.\r
-               //                     ISYGP.GT.1  -THE SYMMETRY GROUP CONTAINS ONLY\r
-               //                                  PROPER (IN-PLANE) ROTATIONS; IN OTHER\r
-               //                                  WORDS, THE DOMAIN HAS ONLY ROTATIONAL\r
-               //                                  SYMMETRIES.\r
-               //                     ISYGP.LT.-1 -THE SYMMETRY GROUP CONTAINS IMPROPER\r
-               //                                  (OUT-OF-PLANE) ROATIONS; IN OTHER\r
-               //                                  WORDS, THE DOMAIN HAS REFLECTIONAL\r
-               //                                  SYMMETRY AND MAY ALSO HAVE ROTATIONAL\r
-               //                                  SYMMETRIES.\r
-               //                     AN INPUT VALUE OF -1 OR 0 IS TREATED AS IF IT WERE\r
-               //                     1.\r
-               \r
-               //            NQPTS  - INTEGER\r
-               //                     PLAYS TWO ROLES.\r
-               //                     1. THE NUMBER OF QUADRATURE POINTS TO BE USED IN \r
-               //                        AN ELEMENTARY GAUSS-JACOBI RULE;  COMPOSITE \r
-               //                        RULES ARE CONSTRUCTED FROM PANELS OF NQPTS-\r
-               //                        POINT RULES.\r
-               //                     2. THE MAXIMUM DEGREE OF POLYNOMIAL APPROXIMATION\r
-               //                        IS FIXED AT NQPTS-1.\r
-               //                     NQPTS SHOULD BE REASONABLY LARGE; A PRACTICAL RULE\r
-               //                     OF THUMB IS THAT IF MACHINE PRECISION IS X*1E-N,\r
-               //                    1<X<10, THEN NQPTS=N+1.\r
-               \r
-               //            INCST  - LOGICAL\r
-               //                     IF INCST IS TRUE THEN AN INCREMENTAL STRATEGY IS\r
-               //                     USED TO TRY TO ACHIEVE THE ACCURACY SPECIFIED BY\r
-               //                     MAXER; VERY ROUGHLY SPEAKING, THIS MEANS THAT THE \r
-               //                     METHOD SUCCESSIVELY ACHIEVES THE TARGET ACCURACIES\r
-               //                     1E-1,1E-2,...UNTIL MAXER HAS BEEN ACHIEVED.  IF \r
-               //                     THE PROBLEM IS THOUGHT TO BE EITHER PARTICULARLY\r
-               //                     DIFFICULT OR PARTICULARLY SIMPLE, THEN INCST \r
-               //                     SHOULD BE SET TO .TRUE.  FOR PROBLEMS OF 'AVERAGE'\r
-               //                     DIFFICULTY, SETTING INCST TO .FALSE. IS USUALLY \r
-               //                     MORE EFFICIENT.\r
-               \r
-               //            RFARC  - INTEGER\r
-               //                     THE REFERENCE ARC USED TO DEFINE THE ORIENTATION \r
-               //                     THAT IS GIVEN TO THE MAP.  THE CONVENTION IS THAT \r
-               //                     THE POINT AT THE START OF ANALYTIC ARC NUMBER \r
-               //                     RFARC IS MAPPED TO THE POINT WITH ARGUMENT \r
-               //                     RFARG*PI ON THE UNIT DISC.\r
-               \r
-               //            RFARG  - REAL\r
-               //                     THE REFERENCE ARGUMENT/PI USED TO DEFINE THE \r
-               //                     ORIENTATION THAT IS GIVEN TO THE MAP.  SEE RFARC \r
-               //                     ABOVE.\r
-               \r
-               //            CENTR  - COMPLEX\r
-               //                     THE POINT IN THE PHYSICAL PLANE THAT IS TO BE\r
-               //                     MAPPED TO THE CENTRE OF THE UNIT DISC.  FOR\r
-               //                     EXTERIOR DOMAINS CENTR MUST BE SOME POINT IN THE\r
-               //                     COMPLEMENTARY INTERIOR  PHYSICAL DOMAIN.\r
-               //                     IN CASE ABS(ISYGP).GT.1 THEN CENTR MUST ALSO BE\r
-               //                     A CENTRE OF SYMMETRY FOR THE PHYSICAL DOMAIN.\r
-               \r
-               //            TSTNG  - INTEGER\r
-               //                     EITHER 0 OR 1.\r
-               //                     ON SUCCESSFUL COMPLETION OF THE NUMERICAL SOLUTION\r
-               //                     OF SYMM'S EQUATION, A MODULE IS PROVIDED FOR\r
-               //                     TESTING THE ERROR IN THE MODULUS OF THE COMPUTED\r
-               //                     MAP ON THE BOUNDARY OF THE DOMAIN.\r
-               //                     TSTNG=0 - TEST ONLY AT SUB-ARC END POINTS\r
-               //                     TSTNG=1 - IN ADDITION TO TESTING AT SUB-ARC END\r
-               //                               POINTS TEST ALSO AT INTERIOR POINTS\r
-               //                               ON EACH SUB-ARC.\r
-               \r
-               //            OULVL  - INTEGER\r
-               //                     EITHER 0,1,2,3,4 OR 5.\r
-               //                     CONTROLS THE AMOUNT OF OUTPUT IN THE LISTING FILE\r
-               //                     <JBNM>pl.\r
-               //                     OULVL=0 - OUTPUT A SOLUTION SUMMARY AT EACH STAGE\r
-               //                               IN THE ADAPTIVE PROCESS AND A SHORT\r
-               //                               SUMMARY OF THE ERRORS IN MODULUS.\r
-               //                     OULVL=1 - AS 0, BUT ALSO OUTPUT A DETAILED LIST OF\r
-               //                               THE ERRORS IN MODULUS.\r
-               //                     OULVL=2 - AS 0, BUT ALSO OUTPUT FULL DETAILS OF \r
-               //                               THE FINAL COMPUTED JACOBI COEFFICIENTS \r
-               //                               ON SUCCESSFUL COMPLETION.\r
-               //                     OULVL=3 - AS 2, BUT ALSO OUTPUT A DETAILED LIST OF\r
-               //                               THE ERRORS IN MODULUS.\r
-               //                     OULVL=4 - OUTPUT FULL DETAILS OF THE OF THE COMPU-\r
-               //                               TED JACOBI COEFFICIENTS AT EVERY STAGE\r
-               //                               IN THE ADAPTIVE PROCESS AND A SHORT\r
-               //                               SUMMARY OF THE ERRORS IN MODULUS.\r
-               //                     OULVL=5 - AS 4, BUT ALSO OUTPUT A DETAILED LIST OF\r
-               //                               THE ERRORS IN MODULUS.\r
-               \r
-               //            IBNDS  - INTEGER ARRAY\r
-               //                     INTEGER VECTOR OF SIZE AT LEAST 5.\r
-               //                     IBNDS(K), K=1,2,3,4,5, DEFINE VARIOUS UPPER LIMITS\r
-               //                     THAT HAVE BEEN SET IN THE CALLING PROGRAM AND \r
-               //                     WHICH CONTROL THE SIZES OF THE ARRAYS IGEOM,RGEOM,\r
-               //                     MATRX,ISNPH,RSNPH,IWORK,RWORK,ZWORK,LWORK. \r
-               //                     THEIR MEANINGS ARE AS FOLLOWS:\r
-               //                     IBNDS(1) - THE MAXIMUM NUMBER OF SUB-ARCS ALLOWED.\r
-               //                     IBNDS(2) - THE MAXIMUM NUMBER OF JACOBI INDECES\r
-               //                                ALLOWED (WHICH IS ALSO THE 1 + THE\r
-               //                                MAXIMUM NUMBER OF CORNERS ALLOWED ON \r
-               //                                PHYSICAL BOUNDARY).\r
-               //                     IBNDS(3) - 1 + THE MAXIMUM NUMBER OF PANELS\r
-               //                                ALLOWED IN A SINGLE COMPOSITE GAUSSIAN\r
-               //                                RULE.\r
-               //                     IBNDS(4) - THE MAXIMUM TOTAL NUMBER OF QUADRATURE \r
-               //                                POINTS ALLOWED OVER ALL COMPOSITE \r
-               //                                GAUSSIAN RULES.\r
-               //                                (IBNDS(4)<=(IBNDS(3)-1)*IBNDS(2)*NQPTS)\r
-               \r
-               //            MNEQN  - INTEGER\r
-               //                     THE MAXIMUM NUMBER OF EQUATIONS ALLOWED IN THE \r
-               //                     LINEAR ALGEBRAIC SYSTEM RESULTING FROM THE \r
-               //                     COLLOCATION METHOD. (MNEQN <= 1+IBNDS(1)*NQPTS)\r
-               \r
-               //            MATRX  - REAL ARRAY\r
-               //                     A 3-DIMENSIONAL MATRIX OF SIZE \r
-               //                          MNEQN X MNEQN X 2 .\r
-               //                     (IN THE ADAPTIVE PROCESS, MATRX(*,*,2) WILL STORE \r
-               //                     THE COEFFICIENT MATRIX OF THE CURRENT COLLOCATION \r
-               //                     SYSTEM AND MATRX(*,*,1) WILL STORE THE COEFFICIENT\r
-               //                     MATRIX OF THE PREVIOUS SYSTEM)\r
-               \r
-               //            IWORK  - INTEGER ARRAY\r
-               //                     A WORKING VECTOR OF SIZE AT LEAST\r
-               //                        8*IBNDS(1)+MNEQN+2*IBNDS(2) .\r
-               \r
-               //            RWORK  - REAL ARRAY\r
-               //                     A WORKING VECTOR OF SIZE AT LEAST\r
-               //                       (4 + 3*NQPTS + 5*IBNDS(2))*NQPTS + 2*IBNDS(1) +\r
-               //                       2*MNEQN + IBNDS(3) + 5*IBNDS(2) + 2*IBNDS(4)\r
-               \r
-               //            ZWORK  - COMPLEX ARRAY\r
-               //                     A WORKING VECTOR OF SIZE AT LEAST\r
-               //                         MNEQN + 2*IBNDS(2)\r
-               \r
-               //            LWORK  - LOGICAL ARRAY\r
-               //                     A WORKING VECTOR OF SIZE AT LEAST\r
-               //                         3*IBNDS(1) + IBNDS(2)\r
-               \r
-               //            OCH    - INTEGER\r
-               //                     DEFINES AN OUTPUT CHANNEL THAT MAY BE USED FOR\r
-               //                     WRITING THE FILES <JBNM>pl, <JBNM>gm, <JBNM>ph.\r
-               \r
-               //         ON EXIT\r
-               //            RFARG  - REAL\r
-               //                     EXIT VALUE IS PI*(ENTRY VALUE)\r
-               \r
-               //            IGEOM  - INTEGER ARRAY\r
-               //                     A VECTOR OF SIZE AT LEAST \r
-               //                          IBNDS(1) + 4;\r
-               //                     STORES DATA RELATING TO THE ARC SUBDIVISIONS THAT\r
-               //                     HAVE TAKEN PLACE.\r
-               \r
-               //            RGEOM  - REAL ARRAY\r
-               //                     A VECTOR OF SIZE AT LEAST \r
-               //                          3*IBNDS(1)+2;\r
-               //                     STORES DATA RELATING TO THE ARC SUBDIVISIONS THAT\r
-               //                     HAVE TAKEN PLACE AND THE ARGUMENTS OF SUB-ARC END\r
-               //                     POINTS ON THE UNIT DISC.\r
-               \r
-               //            ISNPH  - INTEGER ARRAY\r
-               //                     A SOLUTION VECTOR OF SIZE AT LEAST \r
-               //                          3*IBNDS(1)+6;\r
-               //                     STORES DATA DEFINING THE FINAL POLYNOMIAL DEGREES\r
-               //                     ON THE SUB-ARCS, THE JACOBI INDEX FOR EACH SUB-ARC\r
-               //                     AND POINTERS TO THE SOLUTIONS STORED IN RSNPH.\r
-               \r
-               //            RSNPH  - REAL ARRAY\r
-               //                     A SOLUTION VECTOR OF SIZE AT LEAST\r
-               //                         IBNDS(1)+2*MNEQN+3*IBNDS(2)*(1+2*NQPTS);\r
-               //                     STORES DATA DEFINING THREE-TERM RECURRENCE\r
-               //                     SCHEMES, ELEMENTARY GAUSS-JACOBI QUADRATURE RULES,\r
-               //                     THE JACOBI COEFFICIENTS FOR THE BOUNDARY\r
-               //                     CORRESPONDENCE FUNCTION AND ITS DERIVATIVE AND\r
-               //                     THE ERRORS IN MODULUS ON EACH SUB-ARC.\r
-               \r
-               //            IER    - INTEGER\r
-               //                     IF IER > 0 THEN AN ABNORMAL EXIT HAS OCCURRED;\r
-               //                     A MESSAGE TO DESCRIBE THE ERROR IS AUTOMATICALLY\r
-               //                     WRITTEN ON THE STANDARD OUTPUT CHANNEL AND THE\r
-               //                     LISTING FILE <JBNM>pl.\r
-               //                     IER=0 - NORMAL EXIT.\r
-               //                     IER>0 - ABNORMAL EXIT; THE ERROR MESSAGE SHOULD\r
-               //                             BE SELF EXPLANATORY.\r
-                                                 \r
-               \r
-               // 4.     SUBROUTINES OR FUNCTIONS NEEDED\r
-               //              - THE CONFPACK LIBRARY.\r
-               //              - THE REAL FUNCTION R1MACH, WHICH IS A MACHINE CONSTANTS \r
-               //                ROUTINE OBTAINED FROM THE PORT LIBRARY.   \r
-               //                IT MUST BE ADJUSTED TO SUIT EACH PARTICULAR MACHINE.  \r
-               //                IF YOUR MACHINE ISN'T LISTED IN R1MACH THEN YOU'LL  \r
-               //                HAVE TO WRITE YOUR OWN VERSION, BUT NOTE THAT CONFPACK \r
-               //                ONLY USES R1MACH(1), R1MACH(2) AND R1MACH(4).\r
-               //              - THE FOLLOWING LINPACK ROUTINES:\r
-               //                    ISAMAX   SASUM    SAXPY   SDOT    SGECO\r
-               //                    SGEFA    SGEDI    SGESL   SSCAL   SSWAP\r
-               //              - THE FOLLOWING QUADPACK ROUTINES:\r
-               //                    QAWS     QAWSE    QC25S   QCHEB   QK15W\r
-               //                    QMAC     QMOMO    QSORT   QWGTS\r
-               //              - THE USER SUPPLIED COMPLEX FUNCTIONS PARFUN AND DPARFN\r
-               //                WHICH DEFINE THE PARAMETRIC FUNCTION FOR THE PHYSICAL\r
-               //                BOUNDARY AND THE DERIVATIVE OF THE PARAMETRIC FUNCTION.\r
-               //                THE PARAMETRIC FUNCTION DEFINING THE K'TH ANALYTIC ARC\r
-               //                SHOULD HAVE THE SUBROUTINE HEADING\r
-               \r
-               //                    COMPLEX FUNCTION PARFUN(K,T)\r
-               //                    INTEGER K\r
-               //                    COMPLEX T\r
-               \r
-               //                WITH THE REAL PARAMETER INTERVAL -1 < REAL(T) < +1\r
-               //                BEING MAPPED TO THE PHYSICAL ARC.  A SIMILAR HEADING\r
-               //                SHOULD BE GIVEN FOR THE DERIVATIVE DPARFN.  THE PRE-\r
-               //                PROCESSING PROGRAM PARGEN IS AVAILABLE TO HELP WITH\r
-               //                THE CREATION OF PARFUN AND DPARFN.\r
-               \r
-               \r
-               // 5.     FURTHER COMMENTS\r
-               //             A SUMMARY LISTING OF ACTIONS TAKEN IS AUTOMATICALLY\r
-               //             WRITTEN ON THE STANDARD OUTPUT CHANNEL.\r
-               \r
+\r
+               // 1. TSTPLT\r
+               // TESTS THE PARAMETRIC FUNCTION ROUTINES PARFUN AND DPARFN\r
+               // FOR CONSISTENCY AND OUTPUTS BOUNDARY POINTS FOR PLOTTING.\r
+\r
+               // 2. PURPOSE\r
+               // THE ROUTINE FIRST CHECKS THAT THE PARAMETRIC FUNCTION\r
+               // ROUTINE PARFUN IS CONSISTENT WITH RESPECT TO ITS DEFINITION\r
+               // OF ANY CORNERS ON THE BOUNDARY. THIS IS DONE BY CHECKING\r
+               // THAT THE COMPUTED POINT AT THE END OF EACH ARC MATCHES THE\r
+               // COMPUTED POINT AT THE START OF THE NEXT ONE. IF ALL THE\r
+               // RELATIVE MISFIT ERRORS AT CORNERS ARE LESS THAN\r
+               // 10*(UNIT ROUNDOFF) THEN ALL CORNERS ARE CONSIDERED TO FIT\r
+               // SATISFACTORILY, OTHERWISE THE MAXIMUM RELATIVE MISFIT\r
+               // ERROR IS REPORTED.\r
+\r
+               // THE SECOND PURPOSE OF THE ROUTINE IS TO OUTPUT TO A DATA\r
+               // FILE THE COORDINATES OF A NUMBER OF POINTS ON THE BOUNDARY.\r
+               // THE BOUNDARY POINTS ARE SELECTED ADAPTIVELY TO MEET THE\r
+               // PLOTTING RESOLUTION SPECIFICATIONS DEFINED BY THE ARGUMENTS\r
+               // PSD,MINPD,MAXPD (SEE BELOW). THE HOPE IS THAT THE USER MAY\r
+               // EASILY FEED THESE DATA POINTS TO HIS LOCAL GRAPH PLOTTING\r
+               // ROUTINES SO AS TO CONSTRUCT A PLOT OF THE BOUNDARY. THIS\r
+               // WILL PROVIDE AN ESSENTIAL VISUAL CHECK ON THE VALIDITY OF\r
+               // THE ROUTINE PARFUN. THE OUTPUT DATA FILE IS AUTOMATICALLY\r
+               // NAMED <JBNM>zz.\r
+\r
+               // THE THIRD PURPOSE OF THE ROUTINE IS TO CHECK PARFUN AND\r
+               // DPARFN FOR MUTUAL CONSISTECY. THIS IS DONE BY COMPUTING\r
+               // TWO POINT FINITE DIFFERENCE APPROXIMATIONS TO DPARFN.\r
+               // THESE DIFFERENCE APPROXIMATIONS ARE COMPUTED AT EACH BOUND-\r
+               // ARY POINT THAT IS OUTPUT FOR PLOTTING AND ALSO AT NEARBY\r
+               // POINTS WHICH LIE JUST O F F THE BOUNDARY. THIS LATTER\r
+               // COMPARISON ALSO TESTS PARFUN AND DPARFN FOR CORRECTNESS IN\r
+               // ACCEPTING COMPLEX PARAMETER VALUES. A RELATIVE ERROR IN\r
+               // THE FINITE DIFFERENCE APPROXIMATION GREATER THAN 0.1 IS\r
+               // REPORTED AS A POSSIBLE LOGICAL INCONSISTENCY BETWEEN PARFUN\r
+               // AND DPARFN. (THE CRITICAL RELATIVE ERROR VALUE OF 0.1 CAN\r
+               // BE ALTERED BY ADJUSTING THE LOCAL PARAMETER DTOL).\r
+\r
+               // 3. CALLING SEQUENCE\r
+               // CALL TSTPLT(JBNM,MXMIS,MXDIF,NARCS,PSD,MINPD,MAXPD,CHNL,IER)\r
+\r
+               // PARAMETERS\r
+               // ON ENTRY\r
+               // JBNM - CHARACTER*4\r
+               // THE JOB NAME. THIS IS USED TO CREATE THE OUTPUT\r
+               // FILE WITH FILENAME\r
+\r
+               // <JBNM>zz ,\r
+\r
+               // WHERE <JBNM> DENOTES THE VALUE OF VARIABLE JBNM\r
+               // WITH ANY TRAILING SPACES DELETED.\r
+\r
+               // NARCS - INTEGER\r
+               // THE NUMBER OF ANALYTIC ARCS THAT MAKE UP THE\r
+               // W H O L E BOUNDARY OF THE PHYSICAL DOMAIN.\r
+\r
+               // PSD - REAL\r
+               // THE PLOTTING SIZE FOR THE DOMAIN IN ANY APPROPR-\r
+               // IATE UNITS. IF PSD .LE. 0.0 THEN IT IS ASSIGNED\r
+               // THE DEFAULT VALUE OF 160.0 (A REASONBLE WIDTH IN\r
+               // MM FOR PLOTTING ON A4 PAPER).\r
+\r
+               // MINPD - REAL\r
+               // THE MINIMUM SIGNIFICANT PLOTTING DISTANCE, IN THE\r
+               // SAME UNITS AS PSD. IF PSD .LE. 0.0 THEN IT IS\r
+               // ASSIGNED THE DEFAULT VALUE OF 2.0.\r
+\r
+               // MAXPD - REAL\r
+               // THE MAXIMUM ALLOWED PLOTTING DISTANCE, IN THE\r
+               // SAME UNITS AS PSD. IF PSD .LE. 0.0 THEN IT IS\r
+               // ASSIGNED THE DEFAULT VALUE OF 5.0. THE LARGER\r
+               // MAXPD, THE COARSER WILL BE THE RESOLUTION OF THE\r
+               // BOUNDARY POINTS OUTPUT TO <JBNM>zz, BUT THE\r
+               // QUICKER THEY WILL BE COMPUTED.\r
+\r
+               // CHNL - INTEGER\r
+               // DEFINES AN OUTPUT CHANNEL THAT MAY BE USED FOR\r
+               // WRITING THE FILE <JBNM>zz.\r
+               // ON EXIT\r
+               // MXMIS - REAL\r
+               // THE MAXIMUM RELATIVE MISFIT ERROR OVER ALL\r
+               // CORNER POINTS\r
+\r
+               // MXDIF - REAL\r
+               // THE MAXIMUM RELATIVE ERROR IN FINITE DIFFERENCE\r
+               // APPROXIMATIONS TO DPARFN OVER ALL BOUNDARY\r
+               // POINTS OUTPUT TO <JBNM>zz AND NEARBY POINTS OFF\r
+               // THE BOUNDARY.\r
+\r
+               // PSD - REAL\r
+               // IF PSD .LE. 0.0 ON ENTRY THEN IT WILL HAVE\r
+               // THE DEFAULT VALUE OF 160.0 ON EXIT.\r
+\r
+               // MINPD - REAL\r
+               // IF PSD .LE. 0.0 ON ENTRY THEN MINPD WILL HAVE\r
+               // THE DEFAULT VALUE OF 2.0 ON EXIT\r
+\r
+               // MAXPD - REAL\r
+               // IF PSD .LE. 0.0 ON ENTRY THEN MAXPD WILL HAVE\r
+               // THE DEFAULT VALUE OF 5.0 ON EXIT\r
+\r
+               // IER - INTEGER\r
+               // IF IER > 0 THEN AN ABNORMAL EXIT HAS OCCURRED;\r
+               // A MESSAGE TO DESCRIBE THE ERROR IS AUTOMATICALLY\r
+               // WRITTEN ON THE STANDARD OUTPUT CHANNEL.\r
+               // IER=0 - NORMAL EXIT.\r
+               // IER>0 - ABNORMAL EXIT; THE ERROR MESSAGE SHOULD\r
+               // BE SELF EXPLANATORY.\r
+\r
+               // 4. SUBROUTINES OR FUNCTIONS NEEDED\r
+               // - THE CONFPACK LIBRARY.\r
+               // - THE REAL FUNCTION R1MACH.\r
+               // - THE USER SUPPLIED COMPLEX FUNCTIONS PARFUN AND DPARFN.\r
+\r
+               // 5. FURTHER COMMENTS\r
+               // - A SUMMARY LISTING IS AUTOMATICALLY WRITTEN ON THE\r
+               // STANDARD OUTPUT CHANNEL.\r
+               // - THE OUTPUT FILE <JBNM>zz CONTAINS COORDINATE PAIRS\r
+\r
+               // X Y\r
+\r
+               // FOR POINTS ON THE PHYSICAL BOUNDARY, WITH ONE PAIR\r
+               // PER LINE.\r
+\r
                // ......................................................................\r
-               //     AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
-               //     LAST UPDATE: 15 JULY 1990\r
+               // AUTHOR: DAVID HOUGH, ETH, ZUERICH\r
+               // LAST UPDATE: 6 JULY 1990\r
+               // ......................................................................C\r
+               // LOCAL VARIABLES\r
+\r
+               int I, IA;\r
+               int IMX = 0;\r
+               double TINC = 0.0;\r
+               double TMX = 0.0;\r
+               double A1, DIFF, ERR, HH, MINC, RMAX, RMEAN, RMIN, T, TOL1, TSD;\r
+               double TT[] = new double[2];\r
+               // REAL TT(2)\r
+               double C1[] = new double[2];\r
+               double C2[] = new double[2];\r
+               double CENTR[] = new double[2];\r
+               double ZZ0[] = new double[2];\r
+               double DZZ[] = new double[2];\r
+               double NDZZ[] = new double[2];\r
+               // COMPLEX C1,C2,CENTR,ZZ0,DZZ,NDZZ;\r
+               double ZZ[][] = new double[2][2];\r
+               // COMPLEX ZZ(2)\r
+               // CHARACTER OFL*6\r
+               final int MNARC = 200;\r
+               final double DTOL = 1.0E-1;\r
+               final int NH = 4;\r
+               boolean ATEND, FIRST, WARND;\r
+               boolean LNSEG[] = new boolean[MNARC];\r
+               double PIN[] = new double[2];\r
+               double PAROUT[];\r
+               int zzindex;\r
+               double cr[] = new double[1];\r
+               double ci[] = new double[1];\r
+               // EXTERNAL DPARFN,LINSEG,PARFUN,R1MACH,WRHEAD,WRTAIL,ZDPARF\r
+               // COMPLEX PARFUN,DPARFN,ZDPARF\r
+\r
+               // **** WRITE CONFPACK HEADING\r
+\r
+               WRHEAD(7, 0, null);\r
+\r
+               if (NARCS > MNARC) {\r
+                       IER[0] = 59;\r
+                       WRTAIL(7, 0, IER[0], null);\r
+               }\r
+\r
+               // 1 FORMAT(A45)\r
+               // 2 FORMAT(A45,I4)\r
+               // 3 FORMAT(A45,E10.3)\r
+               // 4 FORMAT(//,T17,A)\r
+\r
+               TOL1 = 10.0 * EPS;\r
+\r
+               // **** CHECK THAT ALL ARCS MEET AT CORNER POINTS\r
+\r
+               IER[0] = 0;\r
+               CENTR[0] = 0.0;\r
+               CENTR[1] = 0.0;\r
+               MXMIS = 0.0;\r
+               for (IA = 1; IA <= NARCS; IA++) {\r
+                       if (IA == 1) {\r
+                               I = NARCS;\r
+                       } else {\r
+                               I = IA - 1;\r
+                       }\r
+                       PIN[0] = -1.0;\r
+                       PIN[1] = 0.0;\r
+                       C1 = PARFUN(IA, PIN);\r<