Silverfrost Forums

Welcome to our forums

Understanding this syntax

3 Jun 2013 9:54 #12311

Please can anyone advise what does the syntax mean?

read(unit=line,fmt='(I8,3E16.0)') node,xcoor,ycoor,zcoor

What does fmt=='(I8,3E16.0)') signify?

4 Jun 2013 12:35 #12315

Code: read(unit=line,fmt='(I8,3E16.0)') node,xcoor,ycoor,zcoor

This is an 'internal' read from a character variable 'line', rather than from an external file. Line should be declared as something like: CHARACTER LINE*100 fmt='(I8,3E16.0)' defines the format statement for reading the 4 variables, being an integer in 8 characters and 3 reals of 16 characters. With FTN95, and probably most other compilers, you can use a comma to terminate each field, so that the following would be read correctly. 101,2., 3.,5.

'node,xcoor,ycoor,zcoor' is the variable list for the read, being in this case a node number and coordinates.

I note there is no IOSTAT= option. When reading, this should be included to manage and errors when interpreting the information in LINE. You should consider including IOSTAT=ii, and test if (II/=0) ... to recover in the event of an error in the input data.

Typically, LINE would have been previously read from the data file and then tested to see what sort of information it is, typically being a data line, termination line, comment line or a command line for the start of a new data element.

This READ statement expects all information to be in the first 56 characters of LINE. There is no allowance for the input information to be over two 'lines', as might be the case if 'fmt=*'

Please login to reply.