How to generate a JPEG file from the Lorenz program
What is a CGI program?
A CGI program is an executable (a real executable - not a HTML page) that runs on a WEB server (Apache 2 or similar)
normally reacting on HTML forms or simple links and generating an answer page
that the user sees as a reaction on clicking on a link.
Be warned: this is not a simple procedure. We do not consider here
the build process for the various programs (the source contains
hints for building the executables). We neither explain how a typical
WEB server handles CGI requests.
Steps executed by the CGI program
The steps executed in the following text will be executed automatically in the
background - no need for you to execute them manually. But if you
need similar procedure then this might be helpful. BTW: If you execute
program Lorenz1EH.f90 directly on you laptop then the procedure to
generate a JPEG diagram is much simpler (but similar).
- step 1: the user enters values in the Lorenz parameter form and
starts the calculation by pressing the "start calculation" button.
This inokes the CGI program here called metereo2 (btw written in
- step 2: CGI program metereo2 builds an argument string containing the
given parameters and calls shell procedure runLorenz with that argument string
- step 3: the shell script calls the main routine (executable) whose source is
called Lorenz1EH.f90. This executable will produce simple coordinate files
(text format) that later can be used by gnuplot
- step 4: the shell script runLorenz calls a simple C programm called
correctFloat that purges the REAL/Float values produced by the main
FORTRAN program Lorenz1EH.f90 (post-processing)
- step 5: the script runLorenz calls then gnuplot with a macro called
lorenz.gnu. This step produces a JPEG file called lorenz.jpg
- step 6: The generated JPEG file lorenz.jpg is copied to a WEB serer
- step 7: CGI program metereo2 prepares an HTML answer page and sends it back to
the user (to the browser). The answer page contains the generated JPEG image
and the results of the calculations.
You find all source code (FORTAN, C++, C, shell script, gnuplot macro)
in this ZIP file.
The following diagram shows the steps executed in a CGI program after
having clicked on the "start calculation" button in the parameter form.