|
[Fortran] 纯文本查看 复制代码 04 | Integer , parameter :: N = 13 |
05 | type , public :: ST_Mesh |
06 | character ( len = 12 ) :: geom , out |
08 | real :: iMesh ( N ) , jMesh ( N ) , kMesh ( N ) |
09 | Integer :: iInts ( N ) , jInts ( N ) , kInts ( N ) |
16 | Logical Function ReadFrom ( this , fu ) result ( bOK ) |
17 | Class ( ST_Mesh ) :: this |
18 | Integer , Intent ( IN ) :: fu |
19 | character ( len = 2560 ) :: buf |
20 | character ( len = 512 ) :: cRead |
21 | integer :: i , j , m , k , n |
25 | Read ( fu , "(a512)" , ioStat = k ) cRead |
30 | buf ( n +1 : ) = trim ( cRead ) |
37 | k = Index ( buf ( j : ) , '=' ) |
40 | i = Index ( buf ( : m ) , ' ' , .true. ) |
42 | Select Case ( buf ( i +1 : m -1 ) ) |
44 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % geom |
46 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % origin |
48 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % imesh |
50 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % iints |
52 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % jmesh |
54 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % jints |
56 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % kmesh |
58 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % kints |
60 | Read ( buf ( m +1 : ) , * , ioStat = k ) this % out |
73 | type ( ST_Mesh ) :: mesh |
75 | Open ( 12 , File = "File.txt" ) |
76 | ok = mesh % ReadFrom ( 12 ) |
77 | if ( ok ) write ( * , * ) mesh |
|
|