How to Write a Fortran Code to Read a Specific Data File?

  • Context: Fortran 
  • Thread starter Thread starter niloy112
  • Start date Start date
  • Tags Tags
    Code Fortran
Click For Summary

Discussion Overview

The discussion revolves around writing a Fortran code to read a specific data file format. Participants explore the requirements for reading data from the file, including the need to capture all data from the first to the 80th column, with a preference for reading up to the 73rd column. The context is primarily technical, focusing on programming and data processing in Fortran.

Discussion Character

  • Technical explanation
  • Homework-related
  • Debate/contested

Main Points Raised

  • The original poster seeks assistance in writing Fortran code to read a specific data file format, mentioning the need to read all data between the first and 80th columns.
  • Some participants inquire whether the task is related to a homework assignment.
  • The original poster clarifies that the task is for research purposes, not homework.
  • One participant asks about the original poster's experience with Fortran programming.
  • The original poster indicates they have some experience with numerical work but find data processing challenging.
  • Another participant suggests studying formatted input as a solution to the input problem and inquires about the availability of a Fortran textbook for further study.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to solve the problem, and multiple views on how to proceed with the Fortran code remain present.

Contextual Notes

The discussion highlights the original poster's specific requirements for data reading and the challenges faced in processing the data format, but does not resolve the technical issues or provide a definitive solution.

niloy112
Messages
11
Reaction score
0
The input file:
---------------------------------------------------------------------------------
S 1
S 2
1H,,1H;,, G 1
70HC: G 2
s, G 3
26HRhinoceros ( Jan 18 2007 ),31HTrout Lake IGES 012 Jan 18 2007, G 4
32,38,6,308,15, G 5
, G 6
1.0D0,6,1HM,1,0.0002540000000000001D0,13H140130.224604, G 7
0.0001D0, G 8
52.0603D0, G 9
, G 10
, G 11
10,0,13H140130.224604; G 12
314 1 0 0 0 0 0 000000200D 1
314 0 1 1 0 0 0 COLOR 0D 2
406 2 0 0 1 0 0 000000300D 3
406 0 -1 1 3 0 0LEVELDEF 0D 4
406 3 0 0 2 0 0 000000300D 5
406 0 -1 1 3 0 0LEVELDEF 0D 6
128 4 0 0 2 0 0 000000000D 7
128 0 -1 634 0 0 0 TrimSrf 0D 8
314,0.0,0.0,0.0,20HRGB( 0, 0, 0 ); 0000001P 1
406,2,1,7HDefault; 0000003P 2
406,2,2,12HIGES level 0; 0000005P 3
128,50,20,3,3,0,0,1,0,0,0.0D0,0.0D0,0.0D0,0.0D0,0.0472D0, 0000007P 4
0.0668D0,0.08409999999999999D0,0.1D0,0.1154D0,0.1314D0,0.1486D0, 0000007P 5
0.1685D0,0.1904D0,0.2141D0,0.2377D0,0.2614D0,0.2851D0,0.3088D0, 0000007P 6
0.3325D0,0.3562D0,0.3799D0,0.4035D0,0.4272D0,0.4509D0,0.4746D0, 0000007P 7
0.4983D0,0.5219D0,0.5456D0,0.5693D0,0.593D0,0.6167D0,0.6403D0, 0000007P 8
0.664D0,0.6877D0,0.7114D0,0.7351D0,0.7588D0,0.7825D0,0.8062D0, 0000007P 9
0.8299D0,0.8537D0,0.8734D0,0.8892D0,0.901D0,0.9131D0,0.9257D0, 0000007P 10
0.9384D0,0.9511D0,0.9632D0,0.9742D0,0.9838D0,1.0D0,1.0D0,1.0D0, 0000007P 11
---------------------------------------------------------------------------------------
Here there is 33 line. I need to make a fortran code which can
1. read the all data.
2. all the data situated between 1st column to 80 column. but it will be better if i can read till column 73(till alphabet P,S,D)
3. i have a code which can read and write only first column but i need to read all data.
_________________________________________________________________

program test
integer::i
character(15),allocatable,dimension(:):: line

!

!
OPEN( 1, FILE='text.igs')
OPEN( 2, FILE='l1.txt')

allocate( line(33))
do i=1,33
read(1,*)line(i)
write(2,*)line(i)
end do

end
_________________________________________________________
is it possible to get a solution in fortran??
Any body can help me please?
 
Technology news on Phys.org
Is this homework for a course you are taking?
 
Thanks for your response SteamKing.
Ohh no. It is not a homework. i need to read the above described format file for my research. i think if i can read the file then i can write the above described file in my required way.
 
How much Fortran programming have you done?
 
can do some numerical work but this kind of data processing it is problematic for me...:(
 
The best way to solve your input problem is to study Formatted input. Do you have a Fortran textbook available to study?
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 34 ·
2
Replies
34
Views
4K
  • · Replies 16 ·
Replies
16
Views
2K