我的问题是:为什么我只能在.dat中编写102个lignes但是可以阅读更多 我可以生成1到101点,但是它已经崩溃了。 这里,有问题的程序和3个执行屏幕的例子。
经过一些测试,我写了这个:这是我的点类型云(包含点数和每个点坐标)
type :: point _
real :: x,y
结束类型点_
TYPE :: NuagePoints _
INTEGER :: m ! nombre de points type (point_), DIMENSION(1:degre_max+1) :: points ! tableau des points
END TYPE NuagePoints _
所以这是我做的测试程序:
模块for_test_generate_nuage_points 使用NuagePoints_imp 隐含无 包含
subroutine mkNuageDePoints ()
implicit none
type (NuagePoints_) :: imported_cloud !
integer :: n,i !
real :: pace,ordonnee,tampon,tampon2 !
logical :: flag !
Write (*,*) "give first abscisse"
read (*,*) tampon
write (*,*) "give last abscisse"
read (*,*) tampon2
Write (*,*) "give the pace (no more than 102 point)"
read (*,*) pace
n=nint((tampon2-tampon)/pace)+1
imported_cloud%m = n
!creation du nuage de point imported_cloud
do i=1,n
imported_cloud%points(i)%x=tampon
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ordonnee=tampon**2 !! Here write the function with "tampon" as variable !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
imported_cloud%points(i)%y=ordonnee
tampon=tampon+pace
end do
write (*,*) "the generated fonction right now is x^2"
!copy the imported_cloud into abc.dat file
open (unit = 4, file = 'abc.dat', form='formatted')
write (4,*) imported_cloud%m
do i=1,n
write(4,*) imported_cloud%points(i)%x,imported_cloud%points(i)%y
end do
close (4)
write (*,*) "vdo you want to see the cloud generated ? (T)=yes; (F) = no"
read (*,*) flag
if (flag)then
!open and read of file abc supposed to contain:
!-in line 1 the number (m) of points
! on following line, coordinates
open (unit = 4, file = 'abc.dat', form='formatted')
read (4,*) n
do i=1,n
!write(*,*) imported_cloud%points(i)%x,imported_cloud%points(i)%y
read(4,*) tampon,tampon2
write (*,*) tampon,tampon2
end do
close (4)
end if
end subroutine mkNuageDePoints
执行期间你想生成一个点云吗?是=(T);否=(F)
Ť
给出第一个abscisse
0
给出最后的证据
10
加快步伐(不超过102分)
1
现在生成的函数是x ^ 2
你想看到云生成的vdo吗? (T)=是; (F)=否Ť
0.0000000 0.0000000
1.0000000 1.0000000
2.0000000 4.0000000
3.0000000 9.0000000
4.0000000 16.000000
5.0000000 25.000000
6.0000000 36.000000
7.0000000 49.000000
8.0000000 64.000000
9.0000000 81.000000
10.000000 100.00000
在执行2期间你想生成一个点云吗?是=(T);否=(F)
Ť
给出第一个abscisse
0
给出最后的证据
101
加快步伐(不超过102分)
1
现在生成的函数是x ^ 2
你想看到云生成的vdo吗? (T)=是; (F)=否Ť
0.0000000 0.0000000
1.0000000 1.0000000
2.0000000 4.0000000
3.0000000 9.0000000
4.0000000 16.000000
5.0000000 25.000000
[...]
95.000000 9025.0000
96.000000 9216.0000
97.000000 9409.0000
98.000000 9604.0000
99.000000 9801.0000
100.00000 10000.000
101.00000 10201.000
执行期间答案 0 :(得分:0)
也许degre_max
只有100,所以你触及了界限?
使用-fbounds-check
(或编译器的类似内容)进行编译和/或使用任何debugger来查找这类错误。