File io Fortran:以.dat为单位的写入长度限制
我的问题是:为什么我只能在一个.dat中写102个对齐,却能读更多 我可以生成1到101个点,但是再多了,它就会崩溃。 这里,有问题的程序和3个执行屏幕示例 经过一些测试,我写了以下内容: 这是我的点云类型(包含点的数量和每个点的坐标) 类型::点_File io Fortran:以.dat为单位的写入长度限制,file-io,fortran,limit,File Io,Fortran,Limit,我的问题是:为什么我只能在一个.dat中写102个对齐,却能读更多 我可以生成1到101个点,但是再多了,它就会崩溃。 这里,有问题的程序和3个执行屏幕示例 经过一些测试,我写了以下内容: 这是我的点云类型(包含点的数量和每个点的坐标) 类型::点_ real :: x,y 端点_ 类型::NuagePoints_ INTEGER :: m ! nombre de points type (point_), DIMENSION(1:degre_max+1) :: p
real :: x,y
端点_
类型::NuagePoints_
INTEGER :: m ! nombre de points
type (point_), DIMENSION(1:degre_max+1) :: points ! tableau des points
端点类型_
INTEGER :: m ! nombre de points
type (point_), DIMENSION(1:degre_max+1) :: points ! tableau des points
这是我做的测试程序:
用于生成细微差别点的测试模块
使用NuagePoints\u 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
在执行1期间:
是否要生成点云?是=(T);否=(F)
T
先横坐标
0
最后一次横坐标
十,
给出配速(不超过102分)
一,
现在生成的函数是x^2
vdo是否要查看生成的云?(T) =是;(F) =否
T
0.0000000.0000000
1.00000001.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.000000081.000000
10.000000 100.00000
在执行2期间:
是否要生成点云?是=(T);否=(F)
T
先横坐标
0
最后一次横坐标
101
给出配速(不超过102分)
一,
现在生成的函数是x^2
vdo是否要查看生成的云?(T) =是;(F) =否
T
0.0000000.0000000
1.00000001.0000000
2.0000000 4.0000000
3.0000000 9.0000000
4.0000000 16.000000
5.0000000 25.000000
[...]
950000009025.0000
96.000000 9216.0000
970000009409.0000
980000009604.0000
990000009801.0000
100.0000010000.000
101.00000 10201.000
执行期间3
也许
度数max
只有100,所以你触到了界外
使用
-fbounds check编译(或类似的编译器)和/或使用any查找此类错误。整数,参数::ordre_max=1000抱歉。。。但我也应该写它,我的坏