Silverfrost Forums

Welcome to our forums

Could you give me some examples of compiling under \\FTN95 ?

24 Jul 2008 1:58 #3533

I used to use FORTRAN 77 under VAX and IBM. Several years ago I used COMPAQ made FORTRAN Compiler. I used to use the command as follows:

FORT Filename.for LINK Filename RUN Filename

But I have faced continuous error messages - in other words, I cannot even compile my source code file.

Could anyone help me by sending few examples for me to go along step by step?

24 Jul 2008 2:18 #3534

Hi,

I guess that you prefer to work from the command line? Usually you should use SIDE or PLATO, but for the first steps you may go on like this:

(a) compile all your files with c:\...\salford\ftn95\ftn95 /silent /fixed_format *.for

(b) create a file modules.txt containing lo c:\<source code directory>\*.obj file c:\<...>\name_of_programme.exe

(c) link using c:\...\salford\ftn95\slink modules.txt

Regards, Wilfried

24 Jul 2008 8:48 #3543

While I am doing the step (a), I am getting the error message as follows:

*** Source file 'readcusip.for' cannot be opened

'readcusip.for' is written in ASCII (notepad). Does this cause problem?

24 Jul 2008 9:07 #3544

Are you working from a DOS window in the directory containing your source code file?

Yes, it should be an ascii text file (as produced by notepad), but that's not your problem, either you are trying to compile in the wrong directory or you don't have permission to read the file or write into that directory.

24 Jul 2008 9:26 #3545

If: (1) the source code file 'readcusip.for' is in the same directory (2) the source code file 'readcusip.for' is written in ASCII text using notepad

then what would be the possible cause of error message?

24 Jul 2008 9:32 #3547

Look at the subdirectory listing and check that your file hasn't been named (by Notepad) something daft like 'readcusip.for.txt' !

Eddie

24 Jul 2008 10:33 #3550

Yet I am used to FORTRAN 77 language and all my source files are written in FORTRAN 77 acceptable language. Could you let me know where I need to look up tp learn the changes between FORTRAN 77 to FORTRAN 95 (or conversion of F77 to F95)?

As you see below, I receive the error messages:

Setting Environment for FTN95 Win32

C:\Program Files\Silverfrost\FTN95>ftn95 /silent/fixed_format *.for [FTN95/Win32 Ver. 5.21.0 Copyright (c) Silverfrost Ltd 1993-2008] *** *.for does not match any source files

1 ERROR [] - Compilation failed.

C:\Program Files\Silverfrost\FTN95>dir *.for Volume in drive C has no label. Volume Serial Number is 6497-C3F6

Directory of C:\Program Files\Silverfrost\FTN95

File Not Found

C:\Program Files\Silverfrost\FTN95>ftn95 /silent/fixed_format readcusip.for [FTN95/Win32 Ver. 5.21.0 Copyright (c) Silverfrost Ltd 1993-2008] *** Source file 'C:\Program Files\Silverfrost\FTN95\readcusip.for' cannot be opened

C:\Program Files\Silverfrost\FTN95>dir *.txt Volume in drive C has no label. Volume Serial Number is 6497-C3F6

Directory of C:\Program Files\Silverfrost\FTN95

07/17/2008 05:01 PM 886 READCUSIP.FOR.txt 02/18/2008 12:32 AM 9,491 readme.txt 2 File(s) 10,377 bytes 0 Dir(s) 24,511,225,856 bytes free

C:\Program Files\Silverfrost\FTN95>ftn95 /silent/fixed_format readcusip.for.txt [FTN95/Win32 Ver. 5.21.0 Copyright (c) Silverfrost Ltd 1993-2008] 0017) OPEN(UNIT=10,NAME='COMPSTATCIKCUSIP.DAT', 0018) * TYPE='OLD', READONLY) *** Keyword NAME is not allowed with OPEN *** This expression cannot receive a value, from the I/O keyword NAME *** TYPE is not a recognised keyword in OPEN *** Non-keyword specifiers must appear before keyword specifiers 0020) OPEN(UNIT=12,NAME='COMPCIKCUSIP9.DAT', 0021) * TYPE='NEW',RECORDTYPE= 0022) * 'VARIABLE',RECORDSIZE=500,CARRIAGECONTROL='LIST') *** Keyword NAME is not allowed with OPEN *** This expression cannot receive a value, from the I/O keyword NAME *** TYPE is not a recognised keyword in OPEN *** RECORDTYPE is not a recognised keyword in OPEN *** RECORDSIZE is not a recognised keyword in OPEN *** CARRIAGECONTROL is not a recognised keyword in OPEN 10 ERRORS [<main program> FTN95/Win32 v5.21.0] *** Compilation failed

25 Jul 2008 12:54 #3552

In a 'dos box' (cmd.exe) try the following

ren readcusip.for.txt readcusip.for ftn95 readcusip slink lo readcusip map file readcusip

or even try ftn95 readcusip /lgo ftn95 /help will get help

the commands : lo readcusip map file

could be placed in a text file, such as load.txt and then use the command slink load.txt. Then all commands could be placed in a batch file.

You should change 'NAME=' to 'FILE=', although I did not see the file 'COMPCIKCUSIP9.DAT' listed in your directory.

FTN95 help file can provide more information on fortran 95 standard use of OPEN. It is much better than the old FTN or FTN77 days.

the file name as .for implies that the file is fixed format fortran. I use a .f95 extension and free format.

John

25 Jul 2008 8:15 #3558

Aha! I was right about the horrid .txt on the end.

After renaming, it is even easier than you thought: try

ftn95 -lgo readcusip.for

As for fortran 90 or 95, try:

http://www.nsc.liu.se/~boein/f77to90/f77to90.html

or

http://www.star.le.ac.uk/~cgp/f90course/f90.html#tth_sEc1.1

Beware. These web references tell you that Fortran 90 is 'better' than Fortran 77. It may or may not be. It is often very different. Many of the features are simply a different - and incompatible - way of doing the same job. The number of additional features is very small - probably zero.

You can use FTN95 as if it was FTN77 - I do. Fortran 95 is basically Fortran 90 with a few refinements.

Eddie

30 Jul 2008 4:26 #3622

C:\Program Files\Silverfrost\FTN95>ftn95 /silent/fixed_format readcusip.for.txt [FTN95/Win32 Ver. 5.21.0 Copyright (c) Silverfrost Ltd 1993-2008] 0017) OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',ACCESS='DIRECT',RECL=200, 0018) * FORM='FORMATTED',ACTION='READ',STATUS='OLD',ERR=100,REC=22633) *** Variable FORM follows another operand (possible unexpected space?) 1 ERROR [<main program> FTN95/Win32 v5.21.0] *** Compilation failed

====================== Actually, I have edited my source program using the reference of FTN95 User's Guide. I have realized some difference. I have tried to follow the Guide as much as I can. Yet I still get the error message about the FORM='FORMATTED'. I do not understand the error message. Did I miss some syntax? Could anyone help me?

30 Jul 2008 6:38 #3624

The asterisk symbol (*) is probably in the wrong column. It should be in column 6. The compiler sets a tab to 8 spaces. Avoid tabs.

30 Jul 2008 9:50 #3625

You may know what you are doing, but in my experience :-

  1. combining FORM='FORMATTED' with ACCESS='DIRECT' can be difficult to achieve. Do you only need direct access, to achieve backspace ? An alternative could be to use a simple formatted text file and read each line into a character buffer then read the buffer. eg Character buffer*200 Read (unit=10, fmt='(a)') buffer Read (buffer,fmt=...) i/o list You could even have buffer as an array, if you need to go back more than 1 line.

  2. ACTION='READ' implies the file already exists, in the correct fixed length format. How did you create the file ?

  3. REC=22633; I'm not sure of this in standard fortran either. I would have some file reading approach to determine the number of records.

A few areas where I see possible problems.

John

0017) OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',ACCESS='DIRECT',RECL=200, 
0018) * FORM='FORMATTED',ACTION='READ',STATUS='OLD',ERR=100,REC=22633) 
30 Jul 2008 11:15 #3628

Isn't 'REC=' only valid with a READ statement? Or is it meant to be a maximum record number, I remember ICL and VAX having something like 'MXREC=', but either way I don't believe the standard allows for this anyway.

30 Jul 2008 2:00 #3629

From FTN95.chm:

RECL=<value>

<value> is an integer expression, which gives record length in bytes. For direct access files, this specifier is obligatory.

As an extension to the standard, RECL may also be specified for a file opened for sequential access. This causes fixed length records to be read from or written to file and allows a BACKSPACE to be followed by a WRITE. (.... without truncating the file immediately after what was written, it just overwrites one or more records - E.).

Eddie

30 Jul 2008 2:13 #3630

Eddie,

If you inspect the OPEN statement above you will see RECL=200 and REC=22633 as arguments. There is nothing wrong with 'RECL=' , but 'REC=' does not make sense to me in this context, unless it was some form of setting maximum record length, which is not as far as I know part of the fortran standard.

Cheers, John

30 Jul 2008 3:47 #3632

John,

You are right about VAX Fortran, there was a MAXREC statement. See link below. It probably does not matter now with the large discs of today.

www.helsinki.fi/atk/unix/dec_manuals/df90au52/dfum029.htm#index_x_2555

The carriagecontrol='list' was only so the line printer queue would interpret the first character of each line as printer control, i.e. 0, 1 and +

With regard to the VAX, I seem to remember that the RECL= value was in four-byte words rather than single bytes. An that might have varied for formatted and unformatted. I could probably look it up if I could be bothered to rumage in the garage for my VAX manuals or start up my VAX and type $ help fortran.

Regards

Ian

PS Have you really gat a VAX do I hear you say? No I've got two!

30 Jul 2008 3:49 #3633

I have used the following source code:

++++++++++++++++++++++++++++++++ C THIS PROGRAM IS DESIGNED TO CONSTRUCT THE BASIC DATA SET THAT IS C MATCHING COMPANY ID (CIK) WITH CUSIP (9-DIGIT) FROM COMPUSTAT C C . .

C NEED TO READ ONE INPUT DATA FILE C 1) 'COMPSTATCIKCUSIP' : RETRIEVED FROM COMPUSTAT C
C
C CHARACTER10 CIK CHARACTER6 CNUM CHARACTER3 CIC CHARACTER9 CUSIP9 INTEGER YEAR

   OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',ACCESS='DIRECT',RECL=200,
 * FORM='FORMATTED',ACTION='READ',STATUS='OLD',ERR=100,REC=22633)

   OPEN(UNIT=12,FILE='COMPCIKCUSIP9.DAT',ACCESS='DIRECT',RECL=200,
 * FORM='FORMATTED',ACTION='WRITE',STATUS='NEW',ERR=100)
 

5 READ(UNIT=10,FMT='(A10,A6,A3,12X,I4/)',ERR=100,END=100) CIK, CNUM, CIC, YEAR

   WRITE(UNIT=12,FMT='(A8,1X,A6,A3,1X,I4)',ERR=100) CIK, CNUM, CIC, YEAR
   GO TO 5
 

100 CLOSE (UNIT=10) CLOSE (UNIT=12) STOP END

=================================== And the erroe message is still the same as below: +++++++++++++++++++++++++++++++++

C:\Program Files\Silverfrost\FTN95>ftn95 /silent/fixed_format readcusip.for.txt [FTN95/Win32 Ver. 5.21.0 Copyright (c) Silverfrost Ltd 1993-2008] 0017) OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',ACCESS='DIRECT',RECL=200, 0018) * FORM='FORMATTED',ACTION='READ',STATUS='OLD',ERR=100) *** Variable FORM follows another operand (possible unexpected space?) 1 ERROR [<main program> FTN95/Win32 v5.21.0] *** Compilation failed

C:\Program Files\Silverfrost\FTN95>

===================================

What I do not understand is why the error message tells:

.....variable FORM ......

I think FORM is not the variable, but a specifier. Does this mean that my source code is totally wrong??

For your better understanding:

I have a iniput file of fixed format: The purpose of the source code is to read the input file, and rearrange the data to be useful for future data extractions.

30 Jul 2008 6:12 #3634

John,

Oops ... amazing what you don't see when reading code, isn't it?

Digital Fortran does have a REC= on reading, and this specifies the record number to read from with direct access files as in :

READ(UNIT=12,REC=24) X

but I can't find a REC for an OPEN. Maybe it's a starting record.

FTN95 didn't get as far as REC=, as it choked on the continuation before it got there.

Eddie

30 Jul 2008 6:28 #3635

JKYUN,

Once you get the fixed-format input spaced out correctly as you were advised by an earlier post, then the compilation gets as far as the invalid REC=. (I've done it for you below). The continuation marker * MUST go into column 6.

If you now delete REC=22633 that nobody understands, the program will compile and run. It's up to you what it does!

Once you have the start of your READ statements in the right place, the end of them overlaps with column 73, so they need to be continued on the following line. Using * as a continuation marker gives you a possibility for confusion - I suggest using &.

I suggest that you also delete ACCESS='DIRECT' and RECL=200, and also the / from the READ(UNIT=10 ... statement.

Eddie

C ++++++++++++++++++++++++++++++++ 
C THIS PROGRAM IS DESIGNED TO CONSTRUCT THE BASIC DATA SET THAT IS 
C MATCHING COMPANY ID (CIK) WITH CUSIP (9-DIGIT) FROM COMPUSTAT 
C 
C . . 

C NEED TO READ ONE INPUT DATA FILE 
C 1) 'COMPSTATCIKCUSIP' : RETRIEVED FROM COMPUSTAT 
C 
C 
C 
      CHARACTER*10 CIK 
      CHARACTER*6 CNUM 
      CHARACTER*3 CIC 
      CHARACTER*9 CUSIP9 
      INTEGER YEAR 

      OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',ACCESS='DIRECT',RECL=200, 
     *    FORM='FORMATTED',ACTION='READ',STATUS='OLD',ERR=100,REC=22633) 

      OPEN(UNIT=12,FILE='COMPCIKCUSIP9.DAT',ACCESS='DIRECT',RECL=200, 
     *    FORM='FORMATTED',ACTION='WRITE',STATUS='NEW',ERR=100) 

5     READ(UNIT=10,FMT='(A10,A6,A3,12X,I4/)',ERR=100,END=100) CIK, CNUM, 
     *    CIC, YEAR 

      WRITE(UNIT=12,FMT='(A8,1X,A6,A3,1X,I4)',ERR=100) CIK, CNUM, CIC, 
     *     YEAR 
      GO TO 5 

100   CLOSE (UNIT=10) 
      CLOSE (UNIT=12) 
      STOP 
      END
1 Aug 2008 4:25 #3638

I happened to be in success in the first step of compilation. Now I need to link the *.obj file and run the *.exe file.

Could anyone let me know the command line syntax of FTN95 in: (1) LINK (2) RUN

???

Please login to reply.