I rectified the code to address the errors, but I still get segmentation faults.
read (20,*) (vecy(i), j = 1,10) ! read column index
do i = 1,16
do j = 1,min(i,10)
read(20,*,end=100) vecx(i) , hamilt(i,j) ! row index and matrix elements...
Hi All,
While trying to read a matrix from data file using fortran90 code ,I get garbage values and a backtrace error.
Error termination. Backtrace:
#0 0x7f4a4de3631a
#1 0x7f4a4de36ec5
#2 0x7f4a4de3768d
#3 0x7f4a4dfa4d42
#4 0x7f4a4dfa6ad5
#5 0x7f4a4dfa80f9
#6 0x56040bbeae57
#7...
I'm new to fortran coding and trying to read a file called "data.dat" with data like a triangular matrix
0.1
0.1 0.2
0.1 0.2 0.3
0.1 0.2 0.3 0.4
0.1 0.2 0.3 0.4 0.5
using the code
PROGRAM matrix
IMPLICIT NONE
REAL, DIMENSION(5,5) :: a
INTEGER :: row,col,max_rows,max_cols
max_rows=5...
I got it now. I was missing a space in the initial file. sorry for the trouble . and thank you for your inputs. @FactChecker @Mark44 @DrClaude @anorlunda
I tried your solution u
I tried to read the line. but it is not reading it. I did exactly like you said.
program read_mat
implicit none
integer ::ios,i
character (len =39) :: str_name
character (len=1000) :: line
str_name='OVERLAP MATRIX - CELL N. 1( 0 0 0)'...
I did that using a code from stackoverflow, but it is not working,
program open_file
implicit none
integer ::ios
character (len =39) :: str_name
character , allocatable :: command(:)
character (len=200) :: line
integer :: n,i
str_name = 'OVERLAP MATRIX - CELL N. 1( 0 0 0)'...