Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Binary file writing in Fortran: help needed

  1. Aug 17, 2011 #1
    Binary file writing in Fortran:urgent help needed

    I have 2 softwares: Software A and Software B.I have extracted some data from software A and the data extracted is correct.Now, I have to write this data in a binary file and feed it in software B.Software B understands a binary file

    The databases are written as word addressable fixed length binary files. The actual length
    depends on the amount of data saved, but will always be a multiple of 512 words (4 or 8 bytes each). Since it is likely that the database cannot be contained in a single file of length, FEMLEN,The data will spread over several files known as a family of files. Having a set of files enables them to be handled more easily than a single very large file. The root name for a family is the name of the first file member. Successive member names are compiled by appending a two or three digit number to the root name starting with 01, 02, through to 99, then 100 and ending with 999. Root names are limited to 75 characters. The original reason for a family of files was because the hard disks used for dyna3d runs could not cope with a single contiguous files large enough to contain all the data output. Subsequently, it has been found that splitting the output into separate files allows some unwanted data to be discarded and aids the copying, saving and movement of the data. Very large files can be impossible to transfer reliably over networks.

    The file length used is set in the software B run as the default size of 7x512x512 words. The size can be changed on the command line with the ‘x=factor’ parameter giving a size of: factorx512x512words.

    If the initial data or state data is larger than the given file length, the data will automatically split across files. This condition is not desirable because it is not clear whether any non root file can be discarded without destroying the continuity of the data. Schecks before writing to a file, to ensure that there is room left in the file to contain the data at a particular state time. If not,
    it closes the current family member and starts writing the state data in the next file member. The files are written with a block size of 512 words, and if the data does not complete the last block it
    is padded out. This means that files cannot be concatenated and read together. The word size is 4 bytes for the single precision version of ls-dyna and 8 bytes for the double precision version, unless 32bit ieee format is defined, see *DATABASE_FORMAT, IBINARY.

    The root file starts with a control words section, followed by node coordinates, then element
    connectivity for solids, thick shells, beams, and shells. Next are lists to reference the sequential internal numbering to the users number. State data is output next always starting with the time word. Data is of fixed length through the file members except where the mesh is adapted. The length of each area can be calculated from the information in the control words. The first file at adaption is like the root file in structure, so the new control words are used to recalculate the size of the subsequent data. The root file contains the initial data and also state data if there is room to write it. Further state data is written to the family members and each file will start with the time word provided data from the previous state did not overflow onto the file.
    If the disk address, DA, of the data being written exceeds the maximum file length, then data is written into file number int(DA/FAMLEN) at location DA-FAMLEN*int(DA/FAMLEN). If the state length is greater than the remaining length, the disk address is increased to start the writing at the beginning of the next file.

    STATE DATABASE (d3plot and d3part)
    There are three sections in this database. The first contains 64 words of control
    information plus extensions. The second contains geometric information including the nodal
    coordinates and element connectivities and user numbering lists. The third section contains the results of the analysis at sequential output intervals. The output at a given time, called a state, contains a time word, global variables such as total energies and momenta for the whole model and each material (part), node data consisting of displacements, velocities, accelerations, and optionally temperatures, and finally element data that can include stresses and strains at integration points, and element deletion flags. The control data provides information about what is in the file and is used to calculate the various data length.
    There are two other state database files, namely: d3drfl and d3part, these are similar to d3plot but contain less data. The dynamic relaxation file, d3drfl, provides the state at the end of the DR process, while d3part is state output for a reduced number of parts in the model.

    I have written the control data and Geometry data
    No errors in Fortran. Got the binary file , put it in into software B but software B reads the nodal coordinates a bit incorrectly.

    My nodal coordinates (instead of 0.9) are actually 1.0.
    0 is correct.
    When I make my coordiantes to 1*1000, it reports (software B reports) as 900 (instead of 1000) also if I connect various nodes(imagine vertices a.k.a. nodes) I should get a cube but the cube is not visible on screen.What could be the error?
    Could it be related to the bytes written? Or could it be a formatting error?
    As the software B is trapping the nodes and elements, it means that they are in correct location, right and the binary file is correctly formatted, right?

    Please can anyone help??
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Discussions: Binary file writing in Fortran: help needed
  1. Write File - Fortran (Replies: 1)