replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Binary file discussion with John and all
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 

Binary file discussion with John and all

 
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 Aug 11, 2011 4:15 pm    Post subject: Binary file discussion with John and all Reply with quote

Hi John and all,

Thank you very muchh for all the help.I have tried to proceed further.

Now, I have extracted the data from [b]my[/b] finite element software/program (Software A) and am now in process of writing the binary file needed for another finite element software (Software B).

I have got the information from the software B from its documentation about the variables used,etc.

I'm in the process of running an example and validated that the data extracted from software A is correct.

I now have written the binary file as follows;


character*40 file_name
integer nelems

integer(KIND=Cool :: NEL8,NEL4,NEL2,NUMMAT8,NUMMAT4
integer(KIND=Cool :: NUMMAT2,NUMNP,NDIM
REAL(KIND=Cool:: X(NDIM,nelems)
INTEGER(KIND=Cool::IX8(9,nelems)






file_name = 'my_d3pfile.d3plot'

open (unit=21, file=file_name, form='UNFORMATTED', iostat=iostat)

!write (*,*) ' File ',trim(file_name),' Opened for writing: iostat=', iostat

!Below, the CONTROL data is written to

write(21) NEL8 !Number of 8 noded brick elements
write(21) NEL4 !Number of 4 noded quadrilateral elements

write(21) NEL2 !Number of 2 noded line elements
write(21) NUMMAT8 !Total number of materials used by 8 noded brick elements
write(21) NUMMAT4 !Total number of materials used by 4 noded quadrilateral elements
write(21) NUMMAT2 !Total number of materials used by 2 noded line el;ements
write(21) NUMNP !Total number of nodal points
write(21) NDIM !Total number of dimensions (1,2 or 3)

!Below the geometry data (i.e. the mesh is written to the d3plot file opened above)

write (21) ((X(i,j),i=1,3),j=1,NUMNP) !Nodal coordinates
write(21) ((IX8(i,j),i=1,9),j=1,nelems) !Element connectivity

close(unit=21)





end[/code]

Any suggestions?Please help-any suggestion on the next step?


Last edited by christyleomin on Thu Aug 18, 2011 11:50 pm; edited 3 times in total
Back to top
View user's profile Send private message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Thu Aug 11, 2011 5:14 pm    Post subject: Reply with quote

Please help

Last edited by christyleomin on Thu Aug 18, 2011 11:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Fri Aug 12, 2011 1:36 am    Post subject: Reply with quote

To address some comments on the sample code you have listed:

Did this subroutine you have listed compile with FTN95 ? I would expect this is not the case.

Comments based on the line number of the listed code copied to NOTEPAD:

Lines 1 & 2 : You appear to be mixing free format and fixed format continue. I�d recommend free format and replace as:
subroutine SK09WritingD3PlotFile (NEL8,NEL4,NEL2,NUMMAT8,NUMMAT4, &
NUMMAT2,NUMNP,NDIM,nelems,X,IX8)

Line 4 : This is C syntax for a C include file; you need a fortran compatible version of �sc03.h� and use the statement:
include 'sc03.ins' ! sc03.ins is (hopefully)converted from sc03.h

Lines 9-12 : (KIND=8 ) is not a valid value of KIND for FTN95. The correct value is probably (KIND=2), although I suggest you use REAL*8 and make the code more portable.

Line 21 : You appear to have ignored or not understood the comments about incompatible binary file formats. This OPEN statement will generate a binary file that can only easily be read by another program that is compiled using FTN95. Is this the case ? ( I suspect not as lines 9-12 look like Intel or Lahey syntax)

Line 39 : The 3 should be changed to NDIM as: write (21) ((X(i,j),i=1,NDIM),j=1,NUMNP)

To answer the second post: I'm not sure about these addresses.
Are they byte addresses ?
Does the documentation you have been reading discuss the file format ?
Reporting byte addresses suggests that possibly the reading program can accomodate both Salford and Intel/Lahey binary file formats and will use their non-standard ACCESS="BINARY", which is similar to Salfords's ACCESS='TRANSPARENT'.

I'd again suggest you should read the documentation for the compiler on the OPEN statement, especially related to unformatted read/write and also the documentation of software B.

John
Back to top
View user's profile Send private message
christyleomin



Joined: 08 Apr 2011
Posts: 155

PostPosted: Fri Aug 12, 2011 12:42 pm    Post subject: Reply with quote

Thansk again

Last edited by christyleomin on Thu Aug 18, 2011 11:51 pm; edited 2 times in total
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Fri Aug 12, 2011 2:03 pm    Post subject: Reply with quote

The file description indicates that the files are "word addressable fixed length binary files". This means that the files are fixed length random access files. Fixed length binary files do not have any record structure, as in the <header> and <trailer> as all records are the same length.

The form of the open is :
Integer*4 rec_len, iostat
Open (unit=21, file='filename', access='DIRECT', RECL=rec_len, iostat=iostat)

The write statement is of the form:
write (21,rec=1) numnp, ndim, nel8, nel4, nel2, nummat

To write the node coordinates, you need a
write (21,rec=2) ((X(i,j),i=1,ndim),j=1,NUMNP) !Nodal coordinates
{ note this will probably write multiple records 2, 3, 4... You need to understand this, although to make the record number easier to calculate, the file structure may not permit this }

To create this file you need more guidance on :
1) the value of rec_len, and
2) The contents of the first record (rec=1) as I suspect it's layout is very important. Your reference to "NDIM has disk address 15" and "NEL8 has disk address 23" refers to the word address of these variables in the first record.
The length description also refers to 4 or 8 byte words. Which one you use needs to be defined. This is important.

There is also a lot of description of the file name conventions and the parameter FEMLEN which appears to describe the maximum file length. (Lahey was limited to 2gb file sizes). My apologies but I didn't read that too carefully ! I do find this description a bit unfriendly. What is "software B"?
If you are defining only node locations and connectivity, I'd expect you will use only 1 file. Multiple files will be for analysis results.

The reading program needs to know the record length and what length unit is being used. From the info listed, it could be described by bytes, 4-byte words or 8-byte words. This needs to be clarified; probably in the first record. This is important. Again I'm puzzled by the ambiguity of the description ! They appear to be trying to make it more difficult than it should be !!

In summary these are fixed length record random access files. You need to write them using the expected layout.
I think you need to find a fortran book about this.
Good luck

John
Back to top
View user's profile Send private message
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