Silverfrost Forums

Welcome to our forums

FTN95 compile error

26 Aug 2020 4:59 (Edited: 26 Aug 2020 5:10) #26270

I am brand new to Fortran. I was handed down a large file with Fortran code. It compiles fine if I use a different compiler (g95), however, it won't compile using FTN95. My file has the .f extension instead of .f95 extension. On the command line I run: g95 myfile.f -o myfile.exe and compiles creating myfile.exe but using plato interface I get many warnings which later turns into an error like this: A REAL constant has been truncated with possible loss of precision - maybe a KIND is required

If I use the command prompt within Silverfrost and type: FTN95 myfile.f I get the same errors. Can anyone give me a hint on how to run myfile.f in plato? I can provide the myfile.f upon request but it is really large. I have an image of the plato errors and warnings here: https://login.filesanywhere.com/fs/v.aspx?v=8c6a6b875d5e70ad6c9d Thanks for your help

26 Aug 2020 5:09 #26271

It sounds like the source code is in fixed format, and the .f extension implies that it is free format (or vice versa, I forget). You should have a look at the file and see which it is. Then you might have some luck by changing the file extension (say to ,for for fixed format), using a command line parameter to specify the file format, or making a setting in Plato (or a configuration option for FTN95).

Good luck.

Eddie

26 Aug 2020 5:12 #26272

Or, on second thoughts, it might be because your default real type is 4 bytes. You can change that to 8 bytes in a variaety of ways: one is to put the OPTIONS (DREAL) directive at the front of the source code (or on the command line, through a setting etc etc)

E

26 Aug 2020 5:12 #26273

There is a line limit of about 100 lines on posts. For large files, it is best to zip the file, upload the zip to your cloud storage (Google Drive, Microsoft Onedrive, Dropbox, etc.), make the uploaded file 'shared', and post a link to that shared cloud file.

You do not need to use Plato, unless you are familiar with it and like to use the facilities that it provides. Open a command window, run the Silverfrost provided batch file FVARS.BAT, and you can then compile and link your source file from the command window.

Note that a source file suffix of .f signifies fixed source format and .f90 signifies free format Fortran source. FTN95 also accepts the suffix .f95.

26 Aug 2020 5:14 #26274

Eddie: I have no idea how to do that 😄

26 Aug 2020 5:18 #26275

I will try to post my file and send the link as suggested. In the meantime, can you explain a bit more how to use FVARS.BAT?

26 Aug 2020 6:57 #26276

Open a command window (I assume that you know how to do this. If not, stop here.)

Change to the drive and directory containing the FTN95 installation. Type 'fvars', and the batch file will be run and the environment set up for Fortran development.

Change to the working directory where your source file of interest (dsibm_master2.f ?) is located. Compile it with the command

ftn95 dsibm_master2.f

If the file gets compiled with no errors, link the program:

slink dsibm_master2.obj

Run the program

dsibm_master2

26 Aug 2020 10:29 #26277

I followed all the steps but when I try to compile I get the same error described above. I will zip up the file and post it in a bit. It is a really large file.

27 Aug 2020 2:09 #26279

The compiler report 'A REAL constant has been truncated with possible loss of precision - maybe a KIND is required' is a WARNING, not an ERROR.

This would not prevent your program from running, as it is a warning only.

You need to review the Output box and find the ERROR reports that caused the Compilation Failed.

Alternatively you could compile in a DOS box to more easily see the errors.

ftn95 myfile.f /64 /check > myfile.tce notepad myfile.tce

27 Aug 2020 3:33 #26283

As mentioned above, my fortran code compiles using the g95 compiler but it does not compile using ftn95. I get a lot of warnings and then stops. I don't know what the errors mean because I am new to Fortran.

Below is a link to the 'ftn95_test.f' file. I would appreciate it if someone in this forum could try to compile it and let me know what those errors are and give me some hints on how to fix them.

Here is the link to the file: https://login.filesanywhere.com/fs/v.aspx?v=8c6a6b875e6772b4b26d

27 Aug 2020 3:47 #26284

@ John Campbell-- I followed your suggestion and I understand that warnings don't prevent the code from executing, however, after multiple warnings my fortran code stops and I get a message:

WARNING - There are (at least) 1 truncated line(s) in this file *** Compilation failed

27 Aug 2020 3:59 #26285

There are also 2 error reports. REAL(8) must be changed. You could use DOUBLE PRECISION or REAL(2) or various other ways to represent REAL*8 variables. You could alternatively leave it as REAL(8) and use /alt_kinds on the FTN95 command line.

The errors are on line 11889 and 11890.

27 Aug 2020 9:44 #26286

I tried on the command line: ftn95 ftn95_test.f /alt_kinds

And still got the errors. Did I do it correctly or you meant something different?

28 Aug 2020 1:12 #26287

Look for the string 'alive female spawner', which is on line 2114. In column 73 of that line, there is 'g'. Move that to the next line, and the 'truncated line' message should go away.

With that change, along with changing REAL(8) to REAL*8, and with the /silent option, compilation and linking occur without errors. If I had the necessary data files, I would have tried running the program.

28 Aug 2020 2:53 #26288

There are also:

occurrences of INTEGER(4) which could be changed to INTEGER4 : As FTN95 has different default kind values, REAL4, REAL8 and INTEGER4 is more portable than REAL(4), REAL(8) and INTEGER(4) when moving between FTN95 and other compilers.

numerous warnings about truncation of REAL values : Should these be 32-bit reals or 64-bit reals ?

The origional development environment has not been documented. The use of 'PARAMETER (PI=3.141592654)' is worrying for implied precision. DOUBLE PRECISION is also used, hopefully REAL*8.

28 Aug 2020 4:55 #26291

@mecej4-- I found 'alive female spawner', which is on line 2114. However, the 'g' on column 73 I cannot find.

Also, do I change Real 8 between parenthesis to Real*8 all over the code? I apologize for my naiveness about fortran 😮ops:

28 Aug 2020 6:08 #26292

The file that you uploaded to filesanywhere.com contains a 'g' at the end of line 2114:

     1 of alive female spawner super-individuals on their day of spawning

That 'g' is in column 73, as you will see if you open the file in Plato or another text editor that shows line and column numbers.

REAL(8) and REAL8 mean quite different things, depending on the compiler chosen. In 'REAL(8)', the 8 is a kind number, which is more a label than a quantity. In 'REAL8', the 8 is the length of the variable in bytes. Many of the old mainframe computers did not employ the concept of a byte.

You will do well by reading a Fortran book or the FTN95 help file and understand kind numbers.

29 Aug 2020 12:01 #26293

I did a search for all the REAL(eight) and replaced all with REAL*8. I also found the g and made it a comment. But something strange happens; I am able to compile but only if I use plato. If I use the command line it won't compile. I can settle as long as I can compile :lol:

Once the file is compiled into a ftn95_test.EXE another file is created and is named 'ftn95_test.obj'

If at this point I have to do this on the command line: SLINK ftn95_test.obj I get this error message: *** SLINK can't process the 64 bit object file ftn95_test.obj

29 Aug 2020 12:11 #26294

Suggest you take a look at this video from Paul at Silverfrost which outlines both command line and plato modes of compiling/running programs.

https://www.youtube.com/watch?v=7P8vPlCPxuk

30 Aug 2020 1:03 #26295

Use slink64 not slink

Please login to reply.