There are no inner classes and I still can't set breakpoints. File in
question is attached.


--
Kerry Alt
New Mexico State University / Dept CS
New Science Hall, Room 123
Las Cruces, NM 88003-0001
phone: 505/646-3645
fax:   505/646-1002


package cm.physicsmodels.interfaces;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.util.StringTokenizer;

import cm.physicsmodels.core.PhysicsModel;
import cm.utils.misc.App;
import cm.utils.misc.Grid;


/**
 * This class implements the hazard physics model.  It models blast effects,
 * thermal radiation, and damage to structures given a specific yield.
 *<P>
 * The hazard calculation is done through a JNI call because most of the work
 * is supported in FORTRAN and by people at Sandia National Labs.  The file name
 * attribute doubles as both the output file name and the library to load
 * dynamically.
 *<P>
 * The following is an example of how to create an object using this class.
 * This example generates two files:  one called NukeModel.txt and the other
 * NukeModel.dat.  It also expects that there lives a library called
 * NukeModel.so on Sun machines and NukeModel.dll on PC compatible machines.
 *<P>
 *<PRE>
 *HazModel haz = new HazModel(10.0, new File("NukeModel"));
 *</PRE>
 *<P>
 * @see PhysicsModel
 * @see BlastModel
 * @see PhysicsModelThread
 */
public class HazModel extends PhysicsModel {

    /**
     * JNI interface for hazard calculations.
     *<P>
     * @param inputFile The input file to the hazard model.
     * @param outputFile The data output file.
     */
    protected native void calculate(String inputFile, String outputFile);



    /**
     * Construct a HazModel with no attributes.
     *<P>
     */
    public HazModel() {
App.debug.println("HazModel:constructor with NO params");
    }


    /**
     * Construct a HazModel with attributes.
     *<P>
     * @param inputFile The name of the input file.
     * @param outputFile The name of the output file.
     * @param library The name of the physics model library.
     */
    public HazModel(File inputFile, File outputFile, File library) {

        super(inputFile, outputFile, library);
App.debug.println("HazModel:constructor with params");
App.debug.println("    inputFile="+inputFile);
App.debug.println("    outputFile="+outputFile);
App.debug.println("    library="+library);
    }

    public void writeInputFile() {

        try {

            FileWriter fileWriter = new FileWriter(getInputFile());
            BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
            PrintWriter printWriter = new PrintWriter(bufferedWriter);

            printWriter.close();
            bufferedWriter.close();
            fileWriter.close();

        } catch (Exception e) {

            System.out.println("HazModel:writeInputFile:Exception -> " + e);
        }
    }


    /**
     * Perform an hazard calculation using the specified attributes.
     *<P>
     */
    public void calculate() {
App.debug.println("HazModel:calculate(no params)");
        try {

            calculate(getInputFile().getAbsolutePath(),
                      getOutputFile().getAbsolutePath());

        } catch (NullPointerException exception) {

            String msg = new String("Exception in HazModel.calculate():  ");
            msg += "unspecified attribute(s).";

            System.out.println(msg);
        }
    }


    /**
     * Read the output file into a Grid object.
     *<P>
     */
    public Grid[] readGrid(File filename) {

App.debug.println("HazModel:readGrid()  filename=["+filename+"]");
        Grid grid[] = new Grid[6];
        int numx;
        int numy;


        try {

            RandomAccessFile fp = new RandomAccessFile(filename, "r");

            String gstring = new String();

            // read rotation angle, height and radunit
            gstring = fp.readLine();
            StringTokenizer st = new StringTokenizer(gstring);
            st.nextToken();
            st.nextToken();
            st.nextToken();

            // read T1 and T2 values
            gstring = fp.readLine();
            st = new StringTokenizer(gstring);
            st.nextToken();
            st.nextToken();
            st.nextToken();
            st.nextToken();
            st.nextToken();

            // read numx
            gstring = fp.readLine();
            st = new StringTokenizer(gstring);
            numx = Integer.parseInt(st.nextToken());
System.out.println("numx="+numx);
/*
            for(int i=0; i < numx; i++) {

                st.nextToken();
            }
*/
            // read numy
            gstring = fp.readLine();
            st = new StringTokenizer(gstring);
            numy = Integer.parseInt(st.nextToken());
System.out.println("numy="+numy);
/*
            for(int i=0; i < numy; i++) {

                st.nextToken();
            }
*/

            for(int i=0; i<6; i++) {

                double data[] = new double[numx*numy];
                grid[i] = new Grid(numx, numy);
                int count = 0;

                for(int j=0; j<numx; j++) {

                    gstring = fp.readLine();
                    st = new StringTokenizer(gstring);

                    for(int k=0; k<numy; k++) {

                        data[count]=Double.parseDouble(st.nextToken());
                        count++;

                    }

                }

                grid[i].setRawGrid(data);
            }

            fp.close();

        } catch (Exception e) {

            System.out.println("HazModel:readGrid: Error: " + e.toString());

        }

        return grid;

    }

}

Reply via email to