 |
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
IanLambley
Joined: 17 Dec 2006 Posts: 506 Location: Sunderland
|
Posted: Wed Jul 30, 2008 4:47 pm Post subject: |
|
|
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! |
|
Back to top |
|
 |
jkyun
Joined: 23 Jul 2008 Posts: 10
|
Posted: Wed Jul 30, 2008 4:49 pm Post subject: For your better understanding.. |
|
|
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
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
===================================
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. |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Wed Jul 30, 2008 7:12 pm Post subject: |
|
|
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 :
Code: | 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 |
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Wed Jul 30, 2008 7:28 pm Post subject: |
|
|
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
Code: | 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 |
|
|
Back to top |
|
 |
jkyun
Joined: 23 Jul 2008 Posts: 10
|
Posted: Fri Aug 01, 2008 5:25 am Post subject: |
|
|
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
??? |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Mon Aug 04, 2008 12:51 am Post subject: |
|
|
Having read the code that opens the 2 files,
why do they have to be fixed length record, direct access text files at all ?
There is no reference to record numbers in either the read or write statement provided, ( can they be omitted ?)
Couldn't the file on unit 10 be opened as a default text file ?
I've never used formatted direct access files (in over 30 years) to know the answer.
Why not simply set up a table in memory of all the values for
CIK, CNUM, CIC, YEAR . It would only be 22,663 x 200 bytes long !
( or only 22,633 x 21 bytes based on the format statement )
Another alternative could be :
Code: |
! open 'COMPSTATCIKCUSIP.DAT' as a text file and
! generate 'COMPCIKCUSIP9.DAT' as a 23 byte record direct access file
!
C
CHARACTER*10 CIK
CHARACTER*6 CNUM
CHARACTER*3 CIC
INTEGER*4 YEAR , i
!
i = 0
OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',STATUS='OLD',ERR=200)
OPEN(UNIT=12,FILE='COMPCIKCUSIP9.DAT',ACCESS='DIRECT',RECL=23,
* STATUS='NEW',ERR=100)
do i = 1,999999
READ (UNIT=10,FMT='(A10,A6,A3,12X,I4/)',ERR=100,END=100) CIK, CNUM, CIC, YEAR
WRITE(UNIT=12,rec=i,ERR=100) CIK, CNUM, CIC, YEAR
end do
100 write (*,*) i-1,' recorde creared in ','COMPCIKCUSIP9.DAT'
CLOSE (UNIT=10)
CLOSE (UNIT=12)
STOP
200 write (*,*) 'could not open original file'
END
|
|
|
Back to top |
|
 |
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2403 Location: Yateley, Hants, UK
|
Posted: Mon Aug 04, 2008 9:42 pm Post subject: |
|
|
JKYUN:
What about:
FTN95 -LGO Program.FOR
which compiles, links AND runs, or
FTN95 -link Program.FOR
which compiles, links and runs but keeps a copy of the executable.
You could use /LGO instead of -LGO etc.
Eddie |
|
Back to top |
|
 |
jkyun
Joined: 23 Jul 2008 Posts: 10
|
Posted: Tue Aug 19, 2008 4:11 am Post subject: Finally I could get to the level of executable file... |
|
|
Finally I could get to the level of executable file. But when I ran the file, I did not get the desired output file in the directory. Is there anyway I can find what went wrong? I do not understand why I do not get the designated output file.... ummm |
|
Back to top |
|
 |
jkyun
Joined: 23 Jul 2008 Posts: 10
|
Posted: Wed Aug 27, 2008 6:10 am Post subject: |
|
|
Could anyone please let me know why the output file is not created even though I got the executable file??? |
|
Back to top |
|
 |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2615 Location: Sydney
|
Posted: Wed Aug 27, 2008 11:09 pm Post subject: |
|
|
Put IOSTAT= in all your i/o statements and write the result to the screen to see what is going on. eg change your statements
OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',STATUS='OLD',ERR=200)
to
OPEN(UNIT=10,FILE='COMPSTATCIKCUSIP.DAT',STATUS='OLD',IOSTAT=IOSTAT)
write (*,*) 'OPEN of COMPSTATCIKCUSIP.DAT, IOSTAT=',iostat
if (iostat /= 0) goto 200
and
WRITE(UNIT=12,rec=i,ERR=100) CIK, CNUM, CIC, YEAR
to
WRITE(UNIT=12,rec=i,IOSTAT=IOSTAT) CIK, CNUM, CIC, YEAR
write (*,*) 'WRITE record',i,' , IOSTAT=',iostat
if (iostat /= 0) goto 100
And any others that may be causing problems.
You may get some idea then.
John |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|