Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A simple Web-Interface to a Fortran Program

300 views
Skip to first unread message

Amarjit S. Chandhial

unread,
Jun 2, 2019, 2:26:48 AM6/2/19
to
Hi,


I have a MacBook Pro running MacOS Mojave 10.14.15., with software TextEdit, gfortran 9.1.0 and Firefox browser.

My background is Fortran-77. My aim is to add a simple web-interface to a simple Modern Fortran (or Fortran-77) program that adds 2 numbers.
On Googling I found: http://www.aim.env.uea.ac.uk/aim/info/fortran.pdf ,from the University of East Anglia, however am having difficulties.


From the article, it’s best to start with example2, as in example2 the result is outputted in a box on the web-interface as opposed to example1.

There are 2 files involved in example2: example2.html and example2.f90 (I have used *.f90).


example2.html p.5 & p.6 is as is in the article, but the only line I have changed is

new Ajax.Updater("results_div", “/cgi-bin/example2.exe"

to

new Ajax.Updater("results_div", "/usr/libexec/cups/cgi-bin/example2.exe",

the rest is as is.


example2.f90 is a modified example1.f90 p.2 & p.3, but taking into account changes in the comments, step(5) & step(6).



In Terminal I compiled example2.f90 using:
gfortran example2.f90 -o example2.exe

No errors!

In Terminal if I try to run example2.f90 using:
./example2.exe

I get

At line 16 of file example2.f90
Fortran runtime error: End of file
Error termination. Backtrace:
etc etc


Regardless, I continue…

In Finder, I copy and paste example2.exe into the directory
“/usr/libexec/cups/cgi-bin/". That directory is a hidden folder and is password protected - so I input my password. Okay.
In Finder, I double-click on example2.html in the “/example” directory, Firefox opens-up displaying the web-interface with 2 numbers to input and a results box, as expected.I input the first number and input the second number and press on ‘calculate sum’: the results box remains empty!?!

I’m sure the solution to all of this is very simple.

I appreciate any assistance with the above and/or if someone can provide a set of easier examples, let’s say ‘templates’ in .html, .f90, .FOR (which can be easily modified to display more results, etc) along with easier-to-follow STEP-BY-STEP instructions.


Many thanks in advance,

Amarjit

Ev. Drikos

unread,
Jun 2, 2019, 4:01:32 AM6/2/19
to
On 02/06/2019 9:26 AM, Amarjit S. Chandhial wrote:
> Hi,
>
>
> I have a MacBook Pro running MacOS Mojave 10.14.15., with software TextEdit, gfortran 9.1.0 and Firefox browser.
>
> My background is Fortran-77. My aim is to add a simple web-interface to a simple Modern Fortran (or Fortran-77) program that adds 2 numbers.
...
>
> In Terminal if I try to run example2.f90 using:
> ./example2.exe
>
> I get
>
> At line 16 of file example2.f90
> Fortran runtime error: End of file
> Error termination. Backtrace:
> etc etc
>
>

To my understanding, the program "example1.f" expects input from a WEB
Server along with some environment variables (ie CONTENT_LENGTH). To run
it manually from terminal, (ie to debug it) you also need to provide
manually what's required.


> Regardless, I continue…
>
> In Finder, I copy and paste example2.exe into the directory
> “/usr/libexec/cups/cgi-bin/". That directory is a hidden folder and is password protected - so I input my password. Okay.
> In Finder, I double-click on example2.html in the “/example” directory, Firefox opens-up displaying the web-interface with 2 numbers to input and a results box, as expected.I input the first number and input the second number and press on ‘calculate sum’: the results box remains empty!?!
>

To my understanding, you should normally have to type in Firefox, ie:
http://127.0.0.1/example1.html

> I’m sure the solution to all of this is very simple.
>...

It's my impression you need a WEB server installed (ie Apache) that
supports CGI.

Amarjit S. Chandhial

unread,
Jun 2, 2019, 5:25:12 AM6/2/19
to
Hi,

Many thanks for your reply and advice.

I have followed
https://crunchify.com/how-to-install-apache-web-server-on-mac-os-x-yosemite/

to get http://localhost/crunchify-php-on-mac.php visible in Firefox. No problem - Success!


On my MacPro
crunchify-php-on-mac.php is in the directory as:
/Library/Webserver/Documents/crunchify-php-on-mac.php

From the article I have placed example2.html there: /Library/Webserver/Documents/example2.html

example2.html has the line "/usr/libexec/cups/cgi-bin/example2.exe", which is where I have placed example2.exe.

In Firefox, I type http://localhost/example.html, the web-interface appears, I enter 2 numbers, press on 'calculate sum' - and nothing happens!

Please advise further. Amarjit



Amarjit S. Chandhial

unread,
Jun 2, 2019, 5:53:37 AM6/2/19
to
Opps that should be: http://localhost/example2.html

Vishnu

unread,
Jun 2, 2019, 9:04:42 AM6/2/19
to
I think what you want, does exist, although still in development: https://lfortran.org/

Amarjit S. Chandhial

unread,
Jun 2, 2019, 9:30:35 AM6/2/19
to
On Sunday, June 2, 2019 at 2:04:42 PM UTC+1, Vishnu wrote:
> I think what you want, does exist, although still in development: https://lfortran.org/

Thanks - but that's not the answer I was hoping for!

Amarjit S. Chandhial

unread,
Jun 2, 2019, 9:55:29 AM6/2/19
to
I have just tried example1, with the 2 files in:
/Library/Webserver/Documents/example1.html
"/usr/libexec/cups/cgi-bin/example1.exe"

In Firefox, after I type
http://localhost/example1.html
I get the message:

Not Found
The requested URL /usr/libexec/cups/cgi-bin/example1.exe was not found on this server.


Please advise.

Ev. Drikos

unread,
Jun 2, 2019, 10:58:48 AM6/2/19
to
On 02/06/2019 11:01 AM, Ev. Drikos wrote:
> On 02/06/2019 9:26 AM, Amarjit S. Chandhial wrote:
>> Hi,
>>
>>
>> I have
>> ...
>


The following 2 programs should run as supposed to (yet the result will
be dummy).

I've tested them in OS X 10.7 where I've an installed WEB Server (Apple
Server Tools). In this case, the 2 executables are installed at:

/Library/Webserver/CGI-Executables

You also have to add the functionality that reads from standard input,
line by line. Then parse the values entered by the user and add them.


----------------------
$ cat sumform.f90
WRITE(*,'(''Content-type: text/html'',//)') ! remove for the
second example
WRITE(*,'(1X,''<html><body>'')') ! remove for the second example
write(*,*) '<p>Enter numbers in the two boxes, and press the
"Calculate Sum" button:</p>'
write(*,*) '<form action="/cgi-bin/example2" method="post">'
write(*,*) '<p>First number: <input type="text" name="number1"
id="num1" value="" size="10" /> </p>'
write(*,*) '<p>Second number: <input type="text" name="number2"
id="num2" value="" size="10" /> </p>'
write(*,*) '<input type="submit" value=" Calculate Sum" />'
write(*,*) "</form>"
WRITE(*,'(1X,''</body></html>'')') ! remove for the second example
STOP
END

----------------------
$ cat example2.f90
program example1
implicit none
! ..(1) Declarations
! ----------------
character (len=100) :: LineIn = ' '
character (len=10) :: string = ' '
integer :: lenLineIn, startValue, endValue, ichar
real :: sum_of_numbers, var1, var2

sum_of_numbers = 10 ! add the numbers together
! ..(5) Send a header to the browser, identifying
! the type of information that will be sent.
! ---------------------------------------------
WRITE(*,'(''Content-type: text/html'',//)') ! remove for the
second example
! ..(6) Write the html results page to the browser,
! with the sum of the two numbers.
! -----------------------------------------------
WRITE(*,'(1X,''<html><body>'')') ! remove for the second example
WRITE(*,*) "Installed at: /Library/Webserver/CGI-Executables"
WRITE(*,100) sum_of_numbers
WRITE(*,'(1X,''</body></html>'')') ! remove for the second example
STOP
100 FORMAT(1X,& ! change '1X' to “/1X” for the second example
& '<p>Success! The sum of the two numbers is given below:</p>',&
& E12.4)
END




Eugene Epshteyn

unread,
Jun 2, 2019, 11:00:04 AM6/2/19
to
> I have just tried example1, with the 2 files in:
> /Library/Webserver/Documents/example1.html
> "/usr/libexec/cups/cgi-bin/example1.exe"
>
> In Firefox, after I type
> http://localhost/example1.html
> I get the message:
>
> Not Found
> The requested URL /usr/libexec/cups/cgi-bin/example1.exe was not found on this server.
>
>
> Please advise.

Please ensure that example1.exe has executable permissions set.

This could also be access permissions issue. Usually, the web server runs under a non-root account that has permissions to access the files in the web root tree. If you placed your executable file under /usr/libexec, you would need to ensure that the permissions on this file and on this directory allow the web server to access and execute that file.

Also, why /usr/libexec/***cups***? I don't know much about Unix on Mac, but on Linux, "cups" is the printing service...

Amarjit S. Chandhial

unread,
Jun 2, 2019, 12:51:57 PM6/2/19
to
Hi,

Thanks for the advice.

All 4 files are now in: /Library/Webserver/Documents/ as in the httpd.conf file: DocumentRoot "/Library/WebServer/Documents"

Also I have changed the the 2 lines in both the .html files to point at just the files themselves rather than the /cgi-bin directory. However, I could add a ScriptAlias as in the guidelines:
ScriptAlias /cgi-bin/ "/usr/libexec/cups/cgi-bin/"

In Firefox if I do http://localhost/example1.html, enter the 2 numbers and press 'calculate sum' a window appears with
"You have chosen to open example1.exe" etc etc "What should Firefox do with this file" Open with Save File etc etc. For the example2.exe, I enter 2 numbers press on calculate sum and nothing happens.

I have checked the permissions on both the .exe files and they are both
-rwxr-xr-x

Please advise.


Amarjit S. Chandhial

unread,
Jun 2, 2019, 12:57:05 PM6/2/19
to
Hi, Ev. Drikos,

Thanks for the advice. I am happy to follow your suggestion, however but with a complete reproducible example with step-by-step guidelines, as currently it’s difficult to follow for me.

Eugene Epshteyn

unread,
Jun 2, 2019, 1:08:55 PM6/2/19
to

Eugene Epshteyn

unread,
Jun 2, 2019, 1:16:33 PM6/2/19
to
On Sunday, June 2, 2019 at 12:51:57 PM UTC-4, Amarjit S. Chandhial wrote:

> In Firefox if I do http://localhost/example1.html, enter the 2 numbers and press 'calculate sum' a window appears with
> "You have chosen to open example1.exe" etc etc "What should Firefox do with this file" Open with Save File etc etc. For the example2.exe, I enter 2 numbers press on calculate sum and nothing happens.

The "You have chosen to open" message means that the web server considers example1.exe as a binary document, which was sent to Firefox to handle. Firefox doesn't know, what to do with this binary, so it displays this message.

You need to tell the web server that example1.exe is an executable that is supposed to be run by the web server. I think https://stackoverflow.com/questions/27039250/how-to-let-cgi-scripts-work-on-macos-10-10-yosemite may have an answer for you.

Ev. Drikos

unread,
Jun 3, 2019, 4:49:51 AM6/3/19
to
On 02/06/2019 7:57 PM, Amarjit S. Chandhial wrote:
> ... but with a complete reproducible example with step-by-step guidelines

With these four steps, I've the complete example running on an OS X
(10.7) box, where the (Apple) Server Tools are installed.

$ gfortran sumform.f90 -o sumform
$ sudo install -p -m 755 sumform
/Library/Webserver/CGI-Executables/example1.html
$ gfortran example1.f90 -o example1
$ sudo install -p -m 755 example1
/Library/Webserver/CGI-Executables/example1.exe

Also, you said you know how to add a ScriptAlias ( /cgi-bin/ ... ).

In my case, I had to change the Fortran statements that read the
response passed from the WEB Server to the executable. You likely
have to further work on it because the statements that parse the
two numbers entered by the user are somewhat fragile :-)

IMHO, any other problems you perhaps face are either Apache or Mojave
specific.


Ev. Drikos

---------------
$ cat sumform.f90
WRITE(*,'(''Content-type: text/html'',//)') !
WRITE(*,*) '<html><body>'
write(*,*) '<p>Enter numbers in the two boxes, and press the
"Calculate Sum" button:</p>'
write(*,*) '<form action="/cgi-bin/example1.exe" method="post">'
write(*,*) '<p>First number: <input type="text" name="number1"
id="num1" value="" size="10" /> </p>'
write(*,*) '<p>Second number: <input type="text" name="number2"
id="num2" value="" size="10" /> </p>'
write(*,*) '<input type="submit" value=" Calculate Sum" />'
write(*,*) '</form>'
WRITE(*,*) '</body></html>'
END

---------------
$ cat example1.f90
program example1
implicit none
! ..(1) Declarations
! ----------------
character (len=255) :: LineIn = ' '
character (len=10) :: string = ' '
integer :: lenLineIn, startValue, endValue, ichar, istat
real :: sum_of_numbers, var1, var2

sum_of_numbers = 0 ! add the numbers together
! ..(5) Send a header to the browser, identifying
! the type of information that will be sent.
! ---------------------------------------------
WRITE(*,'(''Content-type: text/html'',//)')
! ..(6) Write the html results page to the browser,
! with the sum of the two numbers.
! -----------------------------------------------
WRITE(*,'(1X,''<html><body>'')')

READ(*, *, iostat=istat) LineIn
if ( istat == 0 ) then
! write (*,*) "'" // LineIn // "'"
! ..(4a) Locate and read the value of 'number1' from LineIn
! ------------------------------------------------------
startValue = INDEX(LineIn,'number1=') + 8
endValue = startValue + INDEX(LineIn(startValue:),'&') - 2
READ(LineIn(startValue:endValue),*) var1
! write (*,*) "var1=", var1
! ..(4b) Locate and read the value of 'number2' from LineIn
! ------------------------------------------------------
startValue = INDEX(LineIn,'number2=') + 8
READ(LineIn(startValue:),*) var2
! write (*,*) "var2=", var2

sum_of_numbers = var1 + var2 ! add the numbers together
WRITE(*,100) sum_of_numbers

else
write (*,*) "read iostat=", istat
endif

WRITE(*,'(1X,''</body></html>'')')

Amarjit S. Chandhial

unread,
Jun 3, 2019, 7:08:20 AM6/3/19
to
Hi,

Thanks for your rely.

Let’s start from scratch.

Based on
https://crunchify.com/how-to-install-apache-web-server-on-mac-os-x-yosemite/
I have Apache working.

In my https.conf file, which is in “private/etc/apache2/“

I have the following

etc
DocumentRoot “/Library/WebServer/Documents"
etc

And based on
https://stackoverflow.com/questions/27039250/how-to-let-cgi-scripts-work-on-macos-10-10-yosemite

I have added

ScriptAlias /cgi-bin/ “/Library/WebServer/CGI-Executables/"
<Directory “/Library/WebServer/CGI-Executables/">
AllowOverride None
Options ExecCGI
AddHandler cgi-script .cgi .pl .tcl .exe
Order allow,deny
Allow from all
</Directory>

I have replaced .py with .exe.


On my PC “/Library/WebServer/CGI-Executables/“ is password protected. So in Finder, I Right-click on the directory, Get Info, down to Sharing & Permissions, Unlock, and for System, wheel, everyone, toggle them to Read & Write, apply to enclose items and Lock.


I have 3 files in the directory “/Library/WebServer/CGI-Executables/“

sumform.f90 - exactly as yours —- I’m not sure how sumform.f90 fits into this ?!?
example1.f90 - exactly as yours

example1.html - as below
<html>
<body>
<p>Enter numbers in the two boxes, and press the "Calculate Sum" button:</p>
<form action="/cgi-bin/example1.exe" method="post">
<p>First number: <input type="text" name="number1" id="num1" value="" size="10" /> </p>
<p>Second number: <input type="text" name="number2" id="num2" value="" size="10" /> </p>
<input type="submit" value=" Calculate Sum" />
</form>
</body>
</html>


In Terminal
I cd to “/Library/WebServer/CGI-Executables/“
and then
$ gfortran sumform.f90 -o sumform 
OK
$ sudo install -p -m 755  sumform /Library/Webserver/CGI-Executables/example1.html 
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...

$ gfortran example1.f90 -o example1 
OK
$ sudo install -p -m 755  example1 /Library/Webserver/CGI-Executables/example1.exe 
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...


In Finder, I double-click on example1.html, In Firefox this is as
URL: file:///Library/WebServer/CGI-Executables/example1.html
Firefox opens up, I input 2 numbers, press on ‘Calculate Sum’ and I get
File not found
Firefox can't find the file at /cgi-bin/example1.exe.

Interestingly, if I do http://localhost/example1.html
I get
Not Found
The requested URL /example1.html was not found on this server.

Regardless of adding a ScriptAlias to the httpd.conf file

This is probably because going-back to where I started
localhost is DocumentRoot “/Library/WebServer/Documents”


Please advise and correct errors - Many Thanks.

Ev. Drikos

unread,
Jun 3, 2019, 8:38:46 AM6/3/19
to
On 03/06/2019 2:08 PM, Amarjit S. Chandhial wrote:
>
> In my https.conf file, which is in “private/etc/apache2/“
>
> I have the following
>
> etc
> DocumentRoot “/Library/WebServer/Documents"
> etc
>

The opening quote doesn't look like a '"'. Copy/Paste here
the exact values found in the configuration file.

If on the other hand, you edit these files with the TextEdit
app, then you may have to adjust the TextEdit Preferences.


In such a case, try in a Terminal:

open -a TextEdit

Go To TextEdit->Preferences

Uncheck all the "Smart..." checkboxes.
Uncheck all the "Correct ... automatically" checkboxes.


Ev. Drikos

PS: To my understanding, the problems you face aren't Fortran problems
and you should better ask advice from people with in depth knowledge of
Apache.



FortranFan

unread,
Jun 3, 2019, 9:46:21 AM6/3/19
to
On Monday, June 3, 2019 at 7:08:20 AM UTC-4, Amarjit S. Chandhial wrote:

> ..
> Please advise ..


@Amarjit S. Chandhial,

You keep signing "Please advise" but you don't appear to be following up on the suggestions that are provided.

Your issues do not have anything to do with Fortran, it could be any number of issues pertaining to your MacPro MacOS environment. It appears difficult for anyone to assist you unless you do your part and be more precise. One aspect of this will be to instead try out *exactly* what some expert shows as having achieved successfully, like that by @Ev. Drikos upthread https://groups.google.com/d/msg/comp.lang.fortran/YCZIHHm487c/ebC7u2_eBQAJ, which might then give you clues.

Since you write in your original post you're familiar with FORTRAN 77, you likely realize also the implications of 'WRITE(*,.." statement involving IO to a preconnected external unit (for sequential formatted output) and given practical considerations with compile build tool chains employed by you, you will note the issues you face will be similar with another executable with GCC, say C++ even:

#include <iostream>
using namespace std;

int main() {
std::cout << "Hello World!" << std::endl;
return EXIT_SUCCESS;
}

So as suggested earlier, you can use an executable performing output to a 'stdout' using another language system say Java or C++, and work with web interface experts for MacPro and MacOS to resolve your problems - executable permissiong, std IO, etc. - and arrive at a faster recipe toward a web interface.

Once you have a working interface, you can simply swap out the executable with one based on some code written in Fortran to achieve similar success.

Amarjit S. Chandhial

unread,
Jun 3, 2019, 10:28:10 AM6/3/19
to
@Ev.Drikos. Have done that in TextEdit regarding checkboxes - and saved the httpd.conf file. Still no joy - double click on example1.html, input numbers - Firefox can't find the file at /cgi-bin/example1.exe.

Yes - you're probably correct regarding Apache.

Amarjit S. Chandhial

unread,
Jun 3, 2019, 12:21:19 PM6/3/19
to
Furthermore, if it would assist I could list my httpd.conf file (very long) and /var/log/apache2/error_log (last few lines i.e. todays). Cheers, Amarjit

Amarjit S. Chandhial

unread,
Jun 3, 2019, 2:49:01 PM6/3/19
to
So, where I'm at is if I change 1 line in the .html I previously stated to:

<form action="/Library/WebServer/CGI-Executables/example1" method="post">

double click on the .html input the 2 numbers, I'm at the stage where Firefox is trying to open or save example1 (kind Unix executable).

Alternatively, if in Terminal I run ./example1 I get the output
Content-type: text/html


<html><body>


Cheers,
Amarjit

Ev. Drikos

unread,
Jun 3, 2019, 3:38:31 PM6/3/19
to
On 03/06/2019 4:46 PM, FortranFan wrote:
> On Monday, June 3, 2019 at 7:08:20 AM UTC-4, Amarjit S. Chandhial wrote:
>
>> ..
>> Please advise ..
>
>
> @Amarjit S. Chandhial,
>
> You keep signing "Please advise" but you don't appear to be following up on the suggestions that are provided.
>
> Your issues do not have anything to do with Fortran, ...


Indeed, the OP isn't supposed ie to open the HTML form by double
clicking it just because he can find the file in Finder (which is
the "File Explorer" app in macOS) or in the Spotlight.

Perhaps the following link could possibly help the OP a little:
https://edu.gcfglobal.org/en/internetbasics/using-a-web-browser/1/

Amarjit S. Chandhial

unread,
Jun 4, 2019, 2:06:07 AM6/4/19
to
@Ev.Drikos Which version of Apple Server Tools do you have installed? The latest version I can see is 10.7.5, with a picture of a lion.

Amarjit S. Chandhial

unread,
Jun 4, 2019, 3:15:59 AM6/4/19
to
On Tuesday, June 4, 2019 at 7:06:07 AM UTC+1, Amarjit S. Chandhial wrote:
> @Ev.Drikos Which version of Apple Server Tools do you have installed? The latest version I can see is 10.7.5, with a picture of a lion.

@Ev.Drikos Just seen there's a cost to them. Obvious question: Are they required for this task? Cheers, Amarjit

Ev. Drikos

unread,
Jun 4, 2019, 5:58:39 AM6/4/19
to
Dear Amarjit,


They were preinstalled on the computer I bought and they aren't required
for this task. But you have to properly install and configure Apache or
another WEB Server on your computer.

What is required here from you is to read carefully again the responses,
all of them. Try to run a simper example first. If this doesn't work,
then seek advice from people who know Apache, obviously not in c.l.f.

When you are done but you still want to discuss Fortran related issues
there are many people here that can help you with the Fortran part of
your application.

Hope you'll post here a confirmation message as soon as your application
runs properly (ie "ok it worked!").


Regards,
Ev. Drikos


Amarjit S. Chandhial

unread,
Jun 4, 2019, 11:05:42 AM6/4/19
to
Hi Ev. Drikos,


Many thanks for yours (and others) inputs, advice & guidance! All very much appreciated!

This topic has become a little bit confusing so let me summarise the steps involved on my end:

Based on
https://crunchify.com/how-to-install-apache-web-server-on-mac-os-x-yosemite/
I have Apache working (but probably not configured properly as of the httpd.conf file, etc)

e.g
http://localhost (OR http://127.0.0.1)
It works!

Also,
http://localhost/crunchify-php-on-mac.php
Hello World - PHP Testcase on Mac OS X by Crunchify.com...
Have a fun.. Enjoy..

Now in TextEdit, I
Go To TextEdit->Preferences 
Uncheck all the "Smart..." checkboxes. 
Uncheck all the "Correct ... automatically" checkboxes. 


In my httpd.conf file (a text file), which is in “private/etc/apache2/“
I have the following:

etc
DocumentRoot “/Library/WebServer/Documents"
etc

And based on
https://stackoverflow.com/questions/27039250/how-to-let-cgi-scripts-work-on-macos-10-10-yosemite

At the bottom of httpd.conf file I have added

<Directory “/Library/WebServer/CGI-Executables/">
AllowOverride None
Options ExecCGI
AddHandler cgi-script .cgi .pl .tcl .exe
Order allow,deny
Allow from all
</Directory>

I have replaced .py with .exe

Also I have NOT used a ScriptAlias /cgi-bin/ “/Library/WebServer/CGI-Executables/" 

I save httpd.conf

On my PC “/Library/WebServer/CGI-Executables/“ is password protected. So in Finder, I Right-click on the directory, Get Info, down to Sharing & Permissions, Unlock, and for System, wheel, everyone, toggle them to Read & Write, apply to enclose items and Lock.


I have 3 files in the directory “/Library/WebServer/CGI-Executables/“

sumform.f90 - exactly as yours EXCEPT
write(*,*) '<form action="/cgi-bin/example1.exe" method="post">' 
is replaced with
write(*,*) '<form action="/Library/WebServer/CGI-Executables/example1.exe" method="post">'

example1.f90 - exactly as yours

example1.html - is as below
<html>
<body>
<p>Enter numbers in the two boxes, and press the "Calculate Sum" button:</p>
<form action="/Library/WebServer/CGI-Executables/example1" method="post">
<p>First number: <input type="text" name="number1" id="num1" value="" size="10" /> </p>
<p>Second number: <input type="text" name="number2" id="num2" value="" size="10" /> </p>
<input type="submit" value=" Calculate Sum" />
</form>
</body>
</html>


In Terminal:
cd /
cd "/Library/WebServer/CGI-Executables/"
and then
$ gfortran sumform.f90 -o sumform 
$ sudo install -p -m 755  sumform /Library/Webserver/CGI-Executables/example1.html 
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
$ gfortran example1.f90 -o example1 
$ sudo install -p -m 755  example1 /Library/Webserver/CGI-Executables/example1.exe 
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...


I now have 5 files in the directory “/Library/WebServer/CGI-Executables/“
sumform.f90
example1.f90
example1.html
example1
sumform


In Finder, I double-click on example1.html, In Firefox this is as
URL:file:///Library/WebServer/CGI-Executables/example1.html
Firefox opens up, I input 2 numbers, press on ‘Calculate Sum’

Window appears
You have chosen to open example1
Which is document (9.3KB)
From Library/WebServer/CGI-Executables/
What should Firefox do with this file?
Open with Text Edit
Save File

Also note if I do
http://127.0.0.1/example1.html
I get
Not Found

That’s as my DocumentRoot is “/Library/WebServer/Documents"


And that’s where I’m at ;-)


Whilst I appreciate this discussion group is comp.lang.fortan and my aim is NOT PURELY FORTRAN, as initially stated if members can:
(i) help me get Apache properly installed and configured on my computer
(ii) assist with the current examples
(iii) and/or provide a set of simpler examples, let’s say ‘templates’ in .html, .f90, .FOR (which can be easily modified to display more results, etc) along with easier-to-follow STEP-BY-STEP instructions.

I’m all ears!

Once again thanks to the contributions.


Cheers,
Amarjit

JRR

unread,
Jun 5, 2019, 8:25:39 AM6/5/19
to
That is really more a topic for Stackoverflow than for c.l.f.
>
>
> Whilst I appreciate this discussion group is comp.lang.fortan and my aim is NOT PURELY FORTRAN, as initially stated if members can:
> (i) help me get Apache properly installed and configured on my computer
> (ii) assist with the current examples
> (iii) and/or provide a set of simpler examples, let’s say ‘templates’ in .html, .f90, .FOR (which can be easily modified to display more results, etc) along with easier-to-follow STEP-BY-STEP instructions.
>
> I’m all ears!
>
> Once again thanks to the contributions.
>
>
> Cheers,
> Amarjit
>


--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron
Hamburg, Germany
------------------------------------
invalid is desy .and. com is de
0 new messages