teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

6

コードの修正

2021/11/10 05:22

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -86,6 +86,14 @@
86
86
  ip = ip + 1
87
87
  end do
88
88
  end do
89
+
90
+ !roop: do while(ip < len(buff))
91
+ ! ip= ip + 1
92
+ ! if( buff(ip:ip)==" " ) then
93
+ ! nod= nod + 1
94
+ ! if( buff(ip+1:ip+1)==" " ) exit roop
95
+ ! end if
96
+ !end do roop
89
97
 
90
98
  write(*,*)"variety of angle", nod
91
99
 

5

コードの修正

2021/11/10 05:22

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -71,7 +71,7 @@
71
71
 
72
72
  write(*,*) "input the angle you process"
73
73
  read(*,*) buff
74
- write(*,*)len(buff)
74
+ write(*,*)"length of the input data", len(buff)
75
75
 
76
76
  open(10, file= "angle_list.txt")
77
77
  write(10,*) buff
@@ -86,8 +86,7 @@
86
86
  ip = ip + 1
87
87
  end do
88
88
  end do
89
-
90
-
89
+
91
90
  write(*,*)"variety of angle", nod
92
91
 
93
92
  allocate(degree(nod))
@@ -97,6 +96,7 @@
97
96
  open(10, file= "angle_list.txt")
98
97
  read(10,*) (degree(i),i=1, nod)
99
98
 
99
+ write(*,*) "degree data"
100
100
  do i=1, nod
101
101
  write(*,*) degree(i)
102
102
  end do

4

コードの修正

2021/11/10 05:14

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -59,7 +59,7 @@
59
59
  end do
60
60
  write(*,*) m
61
61
  ```
62
- ### 該当のソースコード(抜粋)
62
+ ### 該当のソースコード2
63
63
 
64
64
  ```fortran
65
65
  program test
@@ -86,15 +86,8 @@
86
86
  ip = ip + 1
87
87
  end do
88
88
  end do
89
- !roop: do while(ip < len(buff))
89
+
90
- ! ip= ip + 1
91
- ! if( buff(ip:ip)==" " ) then
92
- ! nod= nod + 1
93
- ! if( buff(ip+1:ip+1)==" " ) exit roop
94
- ! end if
95
- !end do roop
96
90
 
97
-
98
91
  write(*,*)"variety of angle", nod
99
92
 
100
93
  allocate(degree(nod))

3

コードの追加

2021/11/10 05:06

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -58,4 +58,57 @@
58
58
  m=m+1
59
59
  end do
60
60
  write(*,*) m
61
+ ```
62
+ ### 該当のソースコード(抜粋)
63
+
64
+ ```fortran
65
+ program test
66
+ implicit none
67
+ real, allocatable :: pix(:, :)
68
+ integer :: nor, noc, nod, ip , i, j
69
+ character(len = 10), allocatable :: degree(:)
70
+ character(len = 99) :: buff
71
+
72
+ write(*,*) "input the angle you process"
73
+ read(*,*) buff
74
+ write(*,*)len(buff)
75
+
76
+ open(10, file= "angle_list.txt")
77
+ write(10,*) buff
78
+
79
+ nod=0
80
+ ip=0
81
+ do while (ip < len(buff))
82
+ ip = ip + 1
83
+ if (buff(ip:ip) == ' ') cycle
84
+ nod = nod + 1
85
+ do while (buff(ip:ip) /= ' ')
86
+ ip = ip + 1
87
+ end do
88
+ end do
89
+ !roop: do while(ip < len(buff))
90
+ ! ip= ip + 1
91
+ ! if( buff(ip:ip)==" " ) then
92
+ ! nod= nod + 1
93
+ ! if( buff(ip+1:ip+1)==" " ) exit roop
94
+ ! end if
95
+ !end do roop
96
+
97
+
98
+ write(*,*)"variety of angle", nod
99
+
100
+ allocate(degree(nod))
101
+
102
+ close(10)
103
+
104
+ open(10, file= "angle_list.txt")
105
+ read(10,*) (degree(i),i=1, nod)
106
+
107
+ do i=1, nod
108
+ write(*,*) degree(i)
109
+ end do
110
+
111
+ deallocate(degree)
112
+
113
+ end program
61
114
  ```

2

改行

2021/11/10 05:03

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -1,7 +1,8 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
3
 
4
- fortran で,表の形のデータを読みこんで配列に格納し,処理するプログラムを作っており,読み取りの際に,行の数は固定で列の数が未知のデータに対応できるようにしたいと思っています。
4
+ fortran で,表の形のデータを読みこんで配列に格納し,処理するプログラムを作っており,
5
+ 読み取りの際に,行の数は固定で列の数が未知のデータに対応できるようにしたいと思っています。
5
6
 
6
7
  入力データの表は以下のような感じになっており,(〇は数値)
7
8
 

1

文章の構成

2021/10/29 13:04

投稿

epsilon
epsilon

スコア2

title CHANGED
File without changes
body CHANGED
@@ -19,14 +19,12 @@
19
19
  一つ一つの列をまとめて読み込みながら列の方向にdoループを回していき
20
20
  iostatが負を示した時点を表の終わりと見なすようにしたいと思っていました。
21
21
 
22
+ ただそのやり方では,結果を確認しても,並びが全く原型をとどめておらず,うまく読みこめていない様です。
22
23
 
23
24
 
24
- ただそのやり方では,結果確認して,並び全く原型とどめておらず,うまく読みこめてない様
25
+ allocate使う事考えました,readする前に行列の大きさ把握できなければならず,その方法が思つきませんした
26
+
25
27
  他に何か良い方法はないでしょうか。
26
-
27
- allocateを使う事も考えましたが,readする前に行列の大きさを把握できなければならず,
28
- その方法が思いつきませんでした。
29
-
30
28
  よろしくお願いします。
31
29
 
32
30
  (ちなみに,可能であれば行,列ともに未知でも可能な方法があれば,