Bonsoir tous le monde,

bon je n'ai jamais programmé avec Fortran, et comme j'utilise un logiciel "Abaqus" qui m'oblige a utiliser fortran je commence a apprendre step by step ,
mon problème est que je veux lire une matrice a partir d'un fichier .txt , voila mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
 subroutine usdfld(field,statev,pnewdt,direct,t,celent,time,dtime,
     1 cmname,orname,nfield,nstatv,noel,npt,layer,kspt,kstep,kinc,
     2 ndi,nshr,coord,jmac,jmtyp,matlayo,laccflg)
 
       include 'aba_param.inc'
 
      character*80 cmname,orname
      character*3  flgray(15)
      CHARACTER(300) :: buffer
      dimension field(nfield),statev(nstatv),direct(3,3),t(3,3),time(2),
     * coord(*),jmac(*),jmtyp(*)
      integer strlen, rows, cols
      real, dimension(:,:), allocatable :: A
      dimension array(15),jarray(15)
 
 
c      X=coord(1)
c      Y=coord(2)
 
       OPEN (1, file = 'C:\Temp\FGM\matri_young.txt', status='old', action='read')
 
  !Count the number of columns
 
      read(1,'(a)') buffer !read first line WITH SPACES INCLUDED
      REWIND(1) !Get back to the file beginning
 
      strlen = len(buffer) !Find the REAL length of a string read
      do while (buffer(strlen:strlen) == ' ') 
      strlen = strlen - 1 
      enddo
 
      cols=0 !Count the number of spaces in the first line
      do i=0,strlen
        if (buffer(i:i) == ' ') then
        cols=cols+1
        endif
      enddo
 
      cols = cols+1
 !Count the number of rows
 
 
      rows = 0 !Count the number of lines in a file
      DO
        READ(1,*,iostat=io)
        IF (io/=0) EXIT
        rows = rows + 1
      END DO
 
      REWIND(1)
 
 
 
      print*, 'Number of rows:', rows
      print*, 'Number of columns:', cols
 
      allocate(A(rows,cols))
 
      do I=1,rows,1
        read(1,*) A(I,:)
        write(*,*) A(I,:)
      enddo
 
 
 
 
 
 
    do i=1,rows
          if (A(i,1)==noel) then 
             print*, 'in the IF==', A(i,1)
               field1=A(i,2)
             print*, 'Field 1==', field1
           end if 
      end do 
 
 
      field(1) = field1
 
      CLOSE (1)
      return
      end
mais ce code la ne remplit pas la matrice A , je n'arrive pas a trouver le problème