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

  • Thread starter Thread starter niloy112
  • Start date Start date
  • Tags Tags
    Code Fortran
Click For Summary
The discussion centers on creating a Fortran program to read a specific formatted input file containing data in a structured layout. The user seeks assistance in modifying their existing code to read all data from the file, specifically from the first to the 73rd column, rather than just the first column. The user clarifies that this task is for research purposes, not homework. There is an emphasis on understanding formatted input in Fortran to effectively process the data. Suggestions include studying Fortran textbooks to improve skills in data handling and processing.
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?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
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
3K
  • · Replies 16 ·
Replies
16
Views
2K