Silverfrost Forums

Welcome to our forums

The future of Fortran

2 Nov 2009 8:08 #5298

In many cases it is still a question which program language to use for future developments. Recently I discovered a decision matrix form 2003 (I think). At the time the programer responsible for an essential program retired. The code was partly in very old Fortran and not well documented. The code was analysed (unfortunatlely without success) and the outcome was a decision to develop the software from scratch. However, the question was which language. At the time I was not in the department where this was done. At first I did not know whether I should start such a decision matrix in the forum or only present the final outcome. I finally decided to present the result.

The decision matrix has two sections, one for the present and one for the future. It is important to mention that the software is used for the design of electrical machines, i.e. only numerical calculations. Criteria for the matrix were defined as follows:

Present                        Priority  Weight  Java  C++  Fortran
-------------------------------------------------------------------
Integrating Fortran programes  1         7       7     7    7
Modularer programming          2         6       6     6    6
Automatic documentation        3         5       5     0    0
Interfaces (ex. XML)           4         4       4     4    0
Architecture                   5         3       3     0    0
Complex numbers                6         2       0     0    2
Object orientated programing   7         1       1     1    0

Future					
------
Availability of programmers    1         20      20    20   0
Availability of compilers      2         15      15    15   0
Readability                    3         10      10    10   10
Operarting system independancy 4         5       5     0    0

Total                                    78      76    63   25

In my opinion very important aspects like the availability of numerical libraries and even the cost of porting code were not taken into account. Furthermore, the outcome of that meeting was that I might be porting a few thousand of lines! I would like to take action on the above matrix. And of course I hope to get some support here 😄

4 Nov 2009 8:51 #5336

As mentioned the in the opening of this topic: The software we speak about is intended for numerics. Furthermore, a few colleagues cannot understand this result. The group who did this definitely had some blinkers. It is on hand that they wanted a specific result. Anyway, I have some interessting couter-arguments:

Compiler availability: There are several Fortran compilers available, i.e. Absoft, Intel, Silverfrost, PGI and PathScale.

Numerical applications: If we want to convert Fahrenheit to Celsius a Fortran and JAVA program would look something like this: program celsius_table implicit none real :: Fahrenheit, Celsius write(,) 'Programm zur Umrechnung von Temperaturangaben von' write(,) 'Fahrenheit nach Grad Celsius' write(,) '---------------------------------------------------' write(,) 'Bitte geben die den Temperaturwert in Fahrenheit an'

         read(*,*)Fahrenheit
                 Celsius = (5.0/9.0) * (Fahrenheit-32.0)

         write(*,*) 'Temperaturwert in Grad Celsius: ', Celsius

         end program celsius_table

Programm 2.1 Temperatur.java
// Temperatur.java 
// 
// Transforms Fahrenheit to Celsius 
import java.awt.*; 
import java.applet.Applet; 
import java.awt.event.ActionListener; 
import java.awt.event.ActionEvent; 

public class Temperatur extends Applet 
{ 
  // variables for the problem
  double fahrenheit, celsius; 
  // objects for the graphical user interface
  Label inputPrompt, outputPrompt1, outputPrompt2; 
  TextField input, output; 
 
  // setup the graphical user interface components
  // and initialize labels and text fields
  public void init() {
    // define labels and textfields
    inputPrompt = new Label('Geben Sie eine Temperatur ' 
         + 'in Fahrenheit an und dr¨ucken Sie Return.'); 
    outputPrompt1 = new Label('Die Temperatur in ' 
         + 'Celsius betr¨agt'); 
    outputPrompt2 = new Label(' Grad.'); 
    input = new TextField(10); 
    input.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent e) { 
        calculateTemperature(); 
      } 
    }); // action will be on input field 
    output = new TextField(10); 
    output.setEditable(false); 
    // disable editing in output field 
    // add labels and textfields to the applet
    add(inputPrompt); 
    add(input); 
    add(outputPrompt1); 
    add(output); 
    add(outputPrompt2); 
  } 

  // process user’s action on the input text field
  public void calculateTemperature() { 
    // get input number
    fahrenheit = Double.parseDouble(input.getText()); 
    // calculate celsius and round it to 1/100 degrees
    celsius = 5.0 / 9 * (fahrenheit - 32); 
    // use Math class for round
    celsius = Math.round(celsius * 100); 
    celsius = celsius / 100.0; 
    // show result in textfield output
    output.setText(Double.toString(celsius)); 
  } 
}

Interfaces: It is no problem to parse for example XML files.

5 Nov 2009 2:21 #5343

Two points I could make on this and other similar posts on this subject.

  1. There should be some qualification of your discussion, based on the complexity of the numerical calculations involved. Fortran is more suited to more complex calculations or where previously developed and proven numerical algorithms are available.
  2. your selection of language should also consider the user interface. From the example you have posted, Visual Basic and FTN95 Clearwin+ are two other classes of solution that could be differentiated from what you have presented.

I was interested in your decision matrix, with the relative weightings to the items listed and the other points that could have been included, such as availability of proven algorithms, accuracy of coding and error identification. Judging by the nominations, Fortran was not the answer wanted, as no compiler, programmers or suitable operating system exist.

Good luck with that committee

11 Nov 2009 2:00 #5365

Quoted from JohnCampbell Two points I could make on this and other similar posts on this subject.

  1. There should be some qualification of your discussion, based on the complexity of the numerical calculations involved. Fortran is more suited to more complex calculations or where previously developed and proven numerical algorithms are available.

Hello John, I am not sure whether Fortran is more suitable for mathematical calculations. Because of the wide availybility and acceptance of Java, there are many libraries available, also a fine one for complex calculations: Commons Math: http://commons.apache.org/math/

(http://commons.apache.org/math/)

(http://commons.apache.org/math/)

(http://commons.apache.org/math/) [quote:315721e400="JohnCampbell"] 2) your selection of language should also consider the user interface. From the example you have posted, Visual Basic and FTN95 Clearwin+ are two other classes of solution that could be differentiated from what you have presented.

One important information is missing: Does the chosen language have to be integrated into an existing system or infrastructure? [quote:315721e400="JohnCampbell"] I was interested in your decision matrix, with the relative weightings to the items listed and the other points that could have been included, such as availability of proven algorithms, accuracy of coding and error identification. Judging by the nominations, Fortran was not the answer wanted, as no compiler, programmers or suitable operating system exist.

Good luck with that committee

It is known that Fortran compilers do exist and Intel keeps on developping. Missing programmers indeed is a problem as nowadays you find lots of Java and .NET developpers, but Fortran is in an outsider role. BTW Java offers good information and tools (in most cases only used to find memory leaks) in case of error handling.

12 Nov 2009 4:43 (Edited: 4 Feb 2010 10:13) #5368

Completely off-topic - how this Java F to C conversion program looks like ? I mean graphically or GUI-wise. Is it nice looking, convenient to use? Can someone publish the image? For comparison i show how F to C and as a bonus to K (do you also need electon-volts?) looks in Clearwin+, with the same overall text size. It automatically as you type converts everything into everything and for human body temperature range you even do not have to type anything

http://img109.imageshack.us/img109/5341/gradus.png

Text is below

! Dan R Right 2009. Reference on author is not required. Use at your own risk 
module Funct
 real*8 Rel_Temp01, Temp_Fahrenheit, Temp_Celsius, Temp_Kelvin   
 real*8 TempHumanMin, TempHumanMax 
 contains
integer function update_Slider () 
 Temp_Fahrenheit = TempHumanMin + (TempHumanMax-TempHumanMin) * Rel_Temp01 
 Temp_Celsius    = (Temp_Fahrenheit-32)*5./9. 
 Temp_Kelvin     = Temp_Celsius + 273. 
 update_Slider   = 1 
end function 
integer function update_F () 
 Rel_Temp01      = (Temp_Fahrenheit-TempHumanMin )/(TempHumanMax-TempHumanMin) 
 Temp_Celsius    = (Temp_Fahrenheit-32)*5./9.    
 Temp_Kelvin     = Temp_Celsius + 273. 
 update_F        = 1 
end function 
integer function update_C () 
 Temp_Fahrenheit = 32 + Temp_Celsius * 9./5. 
 Temp_Kelvin     = Temp_Celsius + 273. 
 Rel_Temp01      = (Temp_Fahrenheit-TempHumanMin )/(TempHumanMax-TempHumanMin) 
 update_C        = 1 
end function 
integer function update_K () 
 Temp_Celsius    = Temp_Kelvin - 273. 
 Temp_Fahrenheit = 32 + Temp_Celsius * 9./5. + 273. 
 Rel_Temp01      = (Temp_Fahrenheit-TempHumanMin )/(TempHumanMax-TempHumanMin) 
 update_K        = 1 
end function 
end module funct 

Program F_to_C_to_K 
use clrwin 
use funct 
 TempHumanMin    = 90;    TempHumanMax = 110 
 Temp_Fahrenheit = 98 
 Temp_Celsius    = 36.6 
 Temp_Kelvin     = Temp_Celsius + 273.

 i=winio@('%sy[3d_raised]%ww[casts_shadow]&')
 i=winio@('%ca[Fahrenheit to Celsius to Kelvin]&')
 i=WINIO@('%wp[BkGrTurb01]&')
 i=winio@('%bg[grey]&')
 i=winio@('%cn Type your input in any field or use slider%ff&')
 i=winio@('%2.1ob&')
   i=winio@('%^9sl[vertical ]%ff&', Rel_Temp01, 0.0D0, 1.0D0, update_Slider)
 i=winio@('%cb&')
   i=winio@('%fn[Times new Roman]%ts%tc[blue]%bf%cn F= &
     &%fl%^8rf%sf%ff&', 2.d0, -1.d36, 1.d36, Temp_Fahrenheit, update_F)
   i=winio@('%fn[Times new Roman]%ts%tc[red]%bf%cn C= &
     &%fl%^8rf%sf%ff&', 2.0d0, -1.d36, 1.d36, Temp_Celsius, update_C)
   i=winio@('%fn[Times new Roman]%ts%tc[green]%bf%cn K= &
     &%fl%^8rf%sf%ff&', 2.0d0, -1.d36, 1.d36, Temp_Kelvin, update_K)
 i=winio@('%cb&')
 i=winio@('%ac[esc]&','exit')
 i=winio@('%nl%ff%cn%3`bt[OK]')
   end
Resources
BkGrTurb01 bitmap  BkGrTurb01.bmp
13 Dec 2009 3:55 #5534

I am familiar with the Fortran standards committee. As far as I know this committee is independant of compiler developers. This is of course a very good point! Once the new standard is available, the compiler developers can start developing.

Which of the other available languages are 'organized' like this? If one looks at C++: One get Microsoft C++ and for example Borland C++. Each of them develops a C++ compiler for what they believe is C++. And if you try some program that was developed with a Microsoft compiler it will in most cases not work the first time with a Borland compiler (I recently experienced this once again). Furthermore, if some guys do not like a programming language, they start to develop a new one. Was this not the case with Java which developed form C++? Instead of expanding C++ some guys developed Java. And when comes the next generation that does not like Java and then make something new from this?

Is a language committee not a valueble argument to consider for a language to have a future? I once heard a saying: In 3000 there will be many programming languages, one of them will be Fortran.

31 Dec 2009 9:36 #5629

Hi DanRRight;

I have seen some cool stuff that were done using Clearwin! This makes Fortran again a very interesting programing language for my application.

In a recent thread (https://forums.silverfrost.com/Forum/Topic/1256) I tried to plot a finite element mesh using Clearwin. I soon realized that one need a little bit more. Especially the transformation from the real-world-axis to the window-axis. This might not be that difficult. However, some example to get me going would be helpful.

You seem to be very fit in Clearwin. At present I have some (quick and dirty) solution using simpleplot. Can you perhaps provide an equivalent example using Clearwin? This would be great! And good for the future 😄

1 Jan 2010 2:12 #5631

Just use OpenGL, you will be stunned by what you'll get. I can send you nice and easy example if i'll find it. BTW, I have sent a year or two ago such and some other snippet examples to Silverfrosts Andrew when he asked here for user examples contributions . Did not heard since that how this idea was evolving

12 Jan 2010 3:51 #5700

From a recent discussion I noticed a very important aspect not taken into account in the points mentioned in the firts entry (this thread).

It is common practice to keep the Fortran code (in its DOS-box mode) and then combine it with some GUI in another programming language. Using ClearWin directly saves of huge amount of time: It takes quite a while to define a working interface between the GUI and the program. The effort to prepare the in- and output files is often underestimated. Therefore, why not spent the time in some ClearWin+ development!

The advantage of doing everything in one language is that the variables are all in memory on execution and no interfaces is required. And in most scientific applications the user has to input his model data and calculate.

15 Jan 2010 11:10 #5763

...Therefore, why not spent the time in some ClearWin+ development!

Indeed...I just guess in what shortest amount of lines in any language anyone can produce this small window which has to include the following features below. And for you, jjgermis, guess, how many lines it will take in Clearwin?

http://img97.imageshack.us/img97/5143/clearwin7.gif

20 Jan 2010 4:39 (Edited: 4 Feb 2010 10:33) #5798

OK, i see no answer on my last last question too. The answer is 1 (one) single line of fortran code. We do not count END statement and resources of course, they can be used for many windows. Here is the whole code:

i=winio@('%ww%mi[i]%ca[win]%wp[a]%mn[File[Exit]]%th%dd%il%cn%`bg[yellow]%?7rd[index]%ff%nl%cn%^bm[e]%ff','exit',1,1,0,10,j,'exit')
end
resources
a bitmap a.bmp
e bitmap e.bmp
i icon   i.ico 

Here a.bmp - window background, e.bmp - Exit button, i.ico - icon .

All of them are optional and can be substituted by Clearwin defaults and the resources not used at all. The code then becomes even smaller, compile it ftn95 file.f95 /lgo or ftn95 file.f95 /link and see all for yourselves

i=winio@('%ww%ca[win]%mn[File[Exit]]%th%dd%il%cn%`bg[yellow]%?7rd[index]%ff%nl%cn%bt[Exit]%ff','exit',1,1,0,10,j)
end
20 Jan 2010 4:46 #5799

With this respect it's ridiculous how sounds Polyhedron 'advertisement' of Clearwin+

http://polyhedron.com/clearwin

'Salford Clearwin+ is very concise, 'Hello World' requires only 4 lines of Fortran code...'

And amazing nobody ever fixed that in a dozen of years 😦 Yes, this is how Salford always advertised itself from its day one. This is truly amazing.

20 Jan 2010 5:59 #5800

The code doesn't give an Exit button as claimed, but it does compile and link and run and produce a UI similar to the illustration.

I was surprised to find that a PROGRAM statement was not required (I knew STOP was optional). I was also surprised (at first) to find that the compiler didn't complain about i and j not being declared, which would have taken another line 😄

I take issue with not counting resource statements as lines just because they can be re-used. They might only count once, but they count.

Obviously I take your point - whether it's 1 line (being charitable) or 7 (being strict; even I don't count comment lines), it's still very impressive. OTOH, we have C available if we want to go in for obfuscated code, don't we. One-line programs are not playing the FORTRAN game at all 😉

If I was going to be really pernickety I might question whether a proprietary extension to a standard-conforming compiler counts as a language. Isn't that a little like claiming that there's something special about the Geordie dialect because it's the only 'language' in which 'Why-aye' requires just one line of code? N.B. this analogy may be less than transparent to you and other Transpondians 😉 😉 😉

Andy

20 Jan 2010 8:43 #5801

Andy, the exit button is provided by the bitmap e.bmp

Also I have written fortran code for over thirty years without ever declaring i and j to be integers! Is it wrong to use the defaults i.j.k.l.m.n for integers and the rest for reals?

20 Jan 2010 10:10 #5802

Dan, I never would have guess that it is possible in one line of code. This is all new to me (Clearwin+) and I enjoy testing your examples!

We also have code where i,j,k,l,m and n are not declared as integers. Is'nt this the implicit way of declaring variables. However, when I use something like Understand4Fortran to analyse the code, it is given as integer. I assume that [color=blue:0505e1f8c9]implicit none[/color:0505e1f8c9] was introduced at a later stage.

Yes, I agree that the marketing at Silverfrost can be better. During 2000 I started using FTN95. At that time I by accident discovered the ClearWin manuals in some cupboard. It looked quite impressive. However, it was presented in some style that was not convincing. Neither could I find information in the internet. If I would have started using it then I would have been much better off today!

21 Jan 2010 1:22 #5804

sparge,

Yes, as John mentioned, all that you mentioned as absent is optional and Exit bitmap is also there, i do not think i need to post resources, anyone can use own ones.

Just to emphasize my point better, here are real numbers: in my 250000 lines Fortran code i have 20000 lines Clarwin part and 100 lines Resource file, hence we have the whole right not to count 0.5% of 'colateral' resource code since in average this is less than 1 character per line.

And FTN95 is the compiler where implicit none is almost useless since it has undefined variable check which is much more powerful anti-error 'pest control'.

Please post the source code for any other GUI builder, who cares in which platform or language.

I glad, jjgermis, that you share my point that it is amazing that this compiler developers are losing the customers by not emphasizing their work. Working in the largest scientific institutions in the world and visiting many others i used, tried or at least saw all existing Fortran compilers for all platforms IBM, DEC, Unix, Cray, Sun and literally was shocked that no one knows Salford FTN77/95 ones which as soon as they appeared always were a whole decade ahead of others.

21 Jan 2010 10:41 #5807

Quoted from JohnHorspool Andy, the exit button is provided by the bitmap e.bmp

Also I have written fortran code for over thirty years without ever declaring i and j to be integers! Is it wrong to use the defaults i.j.k.l.m.n for integers and the rest for reals?

Aha, I see now why my window looked a bit odd. I used the same bitmap for both a *and *e. Doh.

Nothing wrong with i-n integers and the rest real. I still observe that convention - but I declare them anyway. Belt and braces!

@Dan, my error about the Exit button. And implicit none or otherwise is a preference not a requirement, I know that. And I don't have source code in any other platform or language. I wasn't claiming I could do better. In real code, I (and I suspect you) would have written your first line over several lines, with one control per line for clarity; the fact that it can be done in only one line is academic.

My comments were part frivolous and part serious. You are clearly a programming demigod and I am finding it a bit tedious the way you repeatedly iterate this fact, unbidden. I don't care about your quarter of a million lines of code; they are irrelevant for the purposes of this micro-program. If I want to measure the size of text it takes to define a single word, I include all the stuff that is required. The fact that some of those definitions can be re-used to build the entire Oxford English Dictionary is similarly irrelevant.

So, 6 lines of code, not 1. But very impressive nonetheless.

Andy

21 Jan 2010 5:21 #5814

As one develops a program using Clearwin+, the resources section grows - and the more one tries to cover all the options of screen sizes and resolutions, the worse it gets. For me, the single critical incantation is the mystical

1  24  default.manifest

that I understand can now go in a resource section (it used to have to go in a separate RC file), and which transforms the boring Windows 95 look into magnificent XP style. I still wish I understood it enough to tinker with it, say by changing the values 1 and 24, but no others I've tried seem to work.

Eddie

21 Jan 2010 6:33 #5815

The numbers cannot be changed. There are no other options.

You can write your own manifest but the last time I look at this there was nothing of significance that you could change in this context.

21 Jan 2010 10:24 #5816

Perhaps I'll never understand it. It seems that '24' means 'Manifests' and '1' means 'use the default' and 'default.manifest' means 'if you forgot what 1 and 24 do, here's a clue'.

However, the line really does make a real improvement in the look of Clearwin programs ....

E

Please login to reply.