Soon, I will reimplement adcirc class as an application, and I will provide support for file transfer between the client and server (back and forth). You do not want to modify this class.
Note that adcirc declares several public attributes of interest. The most important is an object reference to the remote object "submit" of type submitJob. AdcircFrame makes use of it, as if it was a local object (CORBA magic). Access to other services, such as file transfer, will be provided in the same way. Consequently, I pass reference to adcirc as input argument for AdcircFrame.
There are only two interesting fragments of the code:
In case of adcirc I had to write mini perl script (/home/haupt/runIt.pl):
#!/usr/bin/perl chdir "/projects/cps/jgrid/webflow/jswdk-1.0/webpages/adcirc"; exec "pg_2ddi.x";(otherwise the code will not find input files). As you see, I am running "my" version of adcirc, and not Greg's one. I copied stuff from his directory, and MODIFIED THE FORTRAN SOURCE!!! I hate to admit that, but I did modified it. See below why.
submitJob method, well, submits the job by invoking submitLocally method of the remote object submit (WebFlow module) of type submitJob. It results in executing the command in a separate thread, so the method returns instantly. In addition to the job thread, another thread is created to read the standard output generated by the code.
After submitting the job, the standard output is read and displayed in resultText textarea: line after line is appended. The lines are obtained by invoking another method of the remote object submit: getOLine. If no lines are available (i.e., getOLine returns string "wait") applet waits 10 milliseconds before it tries again. Otherwise, the line is appended to the textarea, the line is marked as read on the server side (setLineRead method of remote submit object) and a line counter is incremented. (see description of the submitJob module for details). Reading of the standard output proceeds until getOLine returns string "theEnd".
Note: The contents of the texfield is a Java String that has a finite size. Adcirc running for a longer time can easily saturate its capacity. We will have to monitor the size of the string, and remove begining before appending the next line.
Note:Reading the standard output is done by piping it to the InputDataStream of the java process object. Unfortunatelly, the stream is buffered. This causes unpleasent effect that the lines in the textarea appear in batches (when the buffer is filled) separated with annoyingly long puseses (when the buffer is filled in). To remedy it I added CALL FLUSH(6) statement in two strategic places of adcirc source. They can be easily located by greping the source in /projects/cps/jgrid/webflow/jswdk-1.0/webpages/adcirc/. This is the change I made to the fortran code.
I envision that the ultimate AdcircFrame will provide buttons and other awt/swing componets that will allow the user to specify parameters of the run, button to submit the job (just copy of what I did so far), and a button to launch visualization package. I think that downloading files for visualizations should occur automatically after completion of the job. If you prefer a separate button - it is fine with me. Actually, lauching the visualization can be done automatically, too, after the downloading the files. You can implement it the way you want it, and I will provide all necessary support (WebFlow modules and description of their interfaces).
Preparing parameters for the run: if I understand things correctly, we are talking about generating fort.15. Here is a decision to be made: where the file is to be created - on the client or server side? Because fort.15 has both variable an static part to be concatenated, it seems to me it is more natural to do it on the server side (or generate variable part on client side, and concatenation on the server side). If you decide to do things on the client side I will provide a method to upload results.
In any case, start developing generation of the fort.15 on the client. Please, implement it as a separate object rather than a part of AdcircFrame. When you are done, I will convert it to a CORBA (WebFlow) module, if needed.
In the meantime, I will convert adcirc to a Java application, and add support for file transfer.
Please, send comments and ask questions!
Tom