Silverfrost Forums

Welcome to our forums

Compiling old style Fortran

14 Jan 2010 12:10 #5727

I am using FTN95 to compile a relative old style fortran program. A few useful tips on this topic I found at: 1.) http://cs.ubishops.ca/ljensen/fortran/oldfort.htm and 2.) http://userpage.chemie.fu-berlin.de/diverse/doc/f77_info.html

I get several errors to that I am not familair with. Like the & in the parameter list from a subroutine, i.e. CALL A11ANFA
1 (ASCHUZ,ABAUFO,ATE,ALPHA1,BU,B1S,BS1S,C1,C2,DA2,DI2S,F1,FVFE, 2 FFE,GMINUS,HU,HS4,IPROGR,ITYP,IBL,IWART,IMPR,IHI,IHJ,IHN,IHM, 3 IHR,IHW,KBLANK,KAPPAT,LFR,MART,MBART,N2,NUMMER,N6,NRECHN, 4 PNS,PZ,PN,PI,RV2,UN,UREDS,V20,XV2,DKF,GAMFE, 5 &9999) I have seen * before. What does the following message mean anf how should I correct it?

error 174 - Unexpected '&' in expression

Another part of the code that I do not understand is: CHARACTER*1 Z27,ZF9,ZF4 DATA Z27,ZF9,ZF4/Z27,ZF9,ZF4/ Here I get the following error:

fatal 287 - All items in a DATA statement's value list must be literal constants

14 Jan 2010 12:43 #5728

Not sure about the first one because I don't understand what the & is doing in the source code myself, so if I weere a compiler I'd probably output much the same error message.

For the second one, I am (intelligently) guessing it implements some compiler-specific way of rendering a constant in hexadecimal notation, and FTN95 is objecting because its own specific syntax is slightly different. I think this will work:

CHARACTER*1 Z27,ZF9,ZF4 DATA Z27,ZF9,ZF4/Z'27',Z'F9',Z'F4'/

Andy

14 Jan 2010 1:01 #5730

&9999 is probably intended to represent a label for an 'alternate return'.

This is not standard Fortran which uses a * not &.

14 Jan 2010 1:29 #5732

I replaced & with * and it seems to solve the problem. Furthermore, I tried

DATA Z27,ZF9,ZF4/Z'27',Z'F9',Z'F4'/

and now get the following message.

error 1001 - You cannot use the CHARACTER(LEN=4) constant 39 to initialise the CHARACTER(LEN=1) variable Z27

I have never seen a DATA statement as above and cannot reall tell what is happening before I get the code to compile without any errors - the code appears in the main part. It compiles fine with IVF but I would like to get it working with FTN95 and use ClearWin+.

FTN95 permits the use of B, O and Z constants anywhere in a program (the standard specifies these should only appear in DATA statements.) To specify the size of the constant, a kind specifier should appear after the constant, e.g. 'Z'7F'_1' is an INTEGER(KIND=1) constant.

14 Jan 2010 2:11 #5734

If I have some code as given below, what does it mean. Hexadecimal seems to be some hint in the right direction. However, I have no clue what this should do. program data_test implicit none CHARACTER(len=1) Z27,ZF9,ZF4 DATA Z27,ZF9,ZF4/Z'27',Z'F9',Z'F4'/ write(*,'(A)') Z27 end program data_test

14 Jan 2010 4:25 #5738

[quote='jjgermis']I replaced & with * and it seems to solve the problem. Furthermore, I tried

DATA Z27,ZF9,ZF4/Z'27',Z'F9',Z'F4'/

and now get the following message.

error 1001 - You cannot use the CHARACTER(LEN=4) constant 39 to initialise the CHARACTER(LEN=1) variable Z27

Doh! Of course. A hex value is not of type character. Z'27' = 39 != char(39) etc. This compiles:

CHARACTER*1 Z27,ZF9,ZF4 DATA Z27,ZF9,ZF4/char(Z'27'),char(Z'F9'),char(Z'F4')/

Though why you would want to do this (and whether it is what the original code did) is not apparent to me ...

15 Jan 2010 6:05 #5743

Thanks Andy! It compiles now. The program was developed when memory was a problem and a lot of data exchange is done via files (at least that what I assume). The given variables are only used as (probably) some specific format.

program data_test
  implicit none 
  CHARACTER(len=1) Z27,ZF9,ZF4
  DATA Z27,ZF9,ZF4/char(Z'27'),char(Z'F9'),char(Z'F4')/
  write(*,'(A)') Z27//'-'//ZF9//'-'//ZF4
end program data_test
15 Jan 2010 7:21 #5744

Maybe someone has experiecend the same: Three years ago (before my time here) it was recognised to update the compilers. For this several compilers were tested (my first choice would have been FTN95). From the tests FTN95 produced the most warnings and errors and based on this was not used.

I compiled the code from then to see what happens (using FTN95). I now realise that FTN95 discovered some errors which the other compilers allowed.

15 Jan 2010 7:57 #5746

For this several compilers were tested ..... . From the tests FTN95 produced the most warnings and errors and based on this was not used.

And I thought that this level of stupidity only occured in the UK.

It just beggars belief, jjgermis I hope that you manage to convince them of the error of their ways, good luck!

15 Jan 2010 10:44 #5749

With the help from the Silverfrost forum I managed to compile the old style Fortran. In doing so I also discovered some errors in the code (good old FTN95). The first facelift was to change the (punched card style) input file (that has no text and only numbers) with a very simple XML-file. It might sound crazy, but associating software with XML already makes it modern! The next step would be to collect the user data using ClearWin+. I cannot wait to see the expressions of my colleagues when I inform them everything is done using FTN95 😃

The XML-parser link: http://xml-fortran.sourceforge.net

17 Jan 2010 4:40 #5766

I must admit that working through old style Fortran is sometimes not that easy. Especially the way do-loops, if-then and goto lables are implemented takes a while to get used to. However, there is also a solution available to this 😄 Beside the above mentioned link there is very useful software that I can recommend, i.e. http://www.scitools.com. I personaly like the graphical presentation of the calls from the main program.

It would be interessting to know what other possibilties are available to analyse source code.

19 Jan 2010 3:16 #5781

Two useful converters from Fortran 77 to Fortran 90 are: 1.) to_f90.f90 by A. Miller and 2.) **convert.f90 **by Michael Metcalf and can be found at http://www.unics.uni-hannover.de/zzzzwg1/frei.html

At the same link there is a reference to Salford/Silverfrost's Personal Edition 😄

20 Jan 2010 7:53 #5785

You could also try using the FTN95 command line option /CONVERT but this is rather limited.

Please login to reply.