replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - FORTRAN writing to back storage file
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FORTRAN writing to back storage file

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Thu Mar 06, 2014 7:24 am    Post subject: FORTRAN writing to back storage file Reply with quote

Can anyone help me to understand what is a back storage file in FORTRAN to which I write statements with unit 3 like

Code:
write(3) my_number


my_number may eb some integer/real

I am trying to underatns an old piece of code that has such statements
Back to top
View user's profile Send private message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Thu Mar 06, 2014 7:29 am    Post subject: Reply with quote

Also: I do not find where the file is opened.
Back to top
View user's profile Send private message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Thu Mar 06, 2014 8:45 am    Post subject: Reply with quote

My question is where is this getting written into?
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Thu Mar 06, 2014 8:52 am    Post subject: Reply with quote

There must be a file opened on unit 3 that is an unformatted file.
Some compilers will open a default named file, other compilers will give an error that the file is not opened.
Is it your program, or are you just providing a subroutine ? You might not see the code that opens the file.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8210
Location: Salford, UK

PostPosted: Thu Mar 06, 2014 8:54 am    Post subject: Reply with quote

With FTN95 you get a run time error...

Error 94, in file ... Unit has neither been OPENed nor preconnected.

If you don't get this error report then I guess there must be an OPEN statement somewhere in your code.
Back to top
View user's profile Send private message AIM Address
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Thu Mar 06, 2014 9:10 am    Post subject: Reply with quote

I'm not getting a runtime error. I will be trying with FTN 95 only next week.

All this old code needs to work with FTN 95 finally

I have a 2011 version of FORTRAN intel compiler and it works with that.

Is it compiler dependent?

Also, I noticed that the data is read correctly :

Code:
integer rn,a,b
         
         integer itype, w, h
     
     
       mbck=3
       rn=1
       a=4
       b=7
       
       

      write(mbck) rn,a,b
     
      rewind mbck
      read(mbck) itype, w, h
      close(mbck)


I see that there is a file named fort3 at the location my project folder structure exists.

But the characters written inside the are unreadable (I opened the file in wordpad) the characters appear like below


Is this a binary file?
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 506
Location: Sunderland

PostPosted: Thu Mar 06, 2014 1:56 pm    Post subject: Reply with quote

The good old DEC VAX Fortran compiler used to automatically open a file if there was no explicit OPEN statement, i.e. FORT003.DAT in that case.
This was a "get-around" for old code derived from batch machines where the OPEN statement within the Fortran language did not exist and the files were assigned as part of the batch commands.

Paul is right, you should insert an OPEN statement at the appropriate point, and probably a CLOSE statement as well.

Yes the data is binary with record length information at the start and end of each record. The length information is compiler dependent and has been discussed at length in this forum. Do not expect an unformatted file from another compiler to be readable.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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