Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Fortran as cgi-bin progam


Is anyone using Intel Fortran to create web-based programs that run from cgi-bin in Apache?

I inherited a program that was running on a RHEL 4 OS with Apache 2.0.52, compiled with ifort version 12.0.0.  Due to security concerns, I'm forced to move it to a newer system running RHEL 7, Apache 2.4.6 (Red Hat backported version) or 2.4.27 (upstream community version), and ifort version 17.0.4.

On the new server, Apache is running, and I'm able to serve static content and a basic Perl script from /var/www/cgi-bin/ (or /usr/local/apache2/cgi-bin, depending on whether I start the Red Hat supported version of Apache or the upstream community version).  However, when I try to test a very basic Fortran program, I'm getting a timeout error.

My Fortran program and html test page is copied from

Fortran code:


      character*19 a
100   format('Content-type: text/html'//)
      read(*,*) a
      write(*,*) '<html>'
      write(*,*) 'Here is what test1.cgi sees:<br>'
      write(*,'(a72)') a
      write(*,*) '<p>'
      write(*,*) 'First box:',a(6:9),'<br>'
      write(*,*) 'Second box:',a(16:19),'</html>'

Compile statement: ifort test1.f -o test1.cgi -debug all


Please fill each box with 4 characters..
<Form method="POST" action="../../cgi-bin/test1.cgi">
<Input name="val1" type="text" maxlength=20>
<Input name="val2" type="text" maxlength=20>
<Input Type="submit" value=" Submit">

Error message from /var/log/httpd/error_log:

[Mon Dec 16 09:06:27.299344 2019] [cgi:warn] [pid 23051] [client xxx.xx.xx.x:1135] AH01220: Timeout waiting for output from CGI script /var/www/cgi-bin/test1.cgi, referer:
[Mon Dec 16 09:06:27.299388 2019] [core:error] [pid 23051] (70007)The timeout specified has expired: [client xxx.xx.xx.x:1135] AH00574: ap_content_length_filter: apr_bucket_read() failed, referer:

Other, more complex Fortran code compiles and runs just fine on the command line, so I believe the Fortran compiler is installed correctly.  I have compared the httpd.conf files between the old server (where the complex program that I inherited and the simple test program above both work) and I don't see any meaningful differences.  However, I'm banging my head against the wall trying to figure out why I can't get Fortran to work as a cgi program on my new server.  Any suggestions?

0 Kudos
1 Reply

I have not done this for a very long time.  here's what I had, no idea if this will work:

more echo.f90

more echo.f90
program echo

   implicit none
   character(len=99) :: input

   read "(a)", input

   print *
   print "(a,/,/)", "Content-type: text/html"
   print "(a)", "<html><head><title>Title</title></head>"
   print "(a)", "<body><p>"
   print "(a)", "trim(input)"
   print "(a)", "</body></html>"
end program echo

compile to echo.cgi just like you did.

Put in public_html/cgi-bin

ln -s  public_html/bin  public_html/fortran-bin

make permissions on echo.cgi to 755  aka -rwxr-xr-x

again, I have not done this is SOOOO long I have no idea if it still works.

0 Kudos