主题:求助大神:linux下vim+gfortranu不识别format标号和“&”!!!!
最近在linux系统下进行fortran的学习,用得是gfortran编译器和VIM编辑器
但是不知为何,编译的时候不支持fortran的format 标号输出以及 “&”链接符!!!
折腾了好就也没弄明白,请教大家!
望指导!
这是代码:(教材上求中值得例子)
1 program stats_1
2 |\\\\\ implicit none
3 |\\\\\ integer, parameter :: max_size=100
4 |\\\\\ real,dimension(max_size)::a
5 |\\\\\ logical ::exceed= .false.
6 |\\\\\ character(len=20)::filename
7 |\\\\\ integer::i
8 |\\\\\ integer::iptr
9 |\\\\\ integer::j
10 |\\\\\ real::median
11 |\\\\\ integer::nvals=0
12 |\\\\\ integer::status
13 |\\\\\ real::std_dev
14 |\\\\\ real::sum_x=0
15 |\\\\\ real::sum_x2=0
16 |\\\\\ real::temp
17 |\\\\\ real::x_bar
18 |\\\\\ write(*,1000)
[color=00FFFF] 19 |\\\\\ 1000 format(1X,'Enter the file name with the date to be sorted:')
20 |\\\\\ read(*,'(A20)') filename[/color]
[color=00FFFF]21 |\\\\\ open (unit=9,file=filename,status='old',action='read',&
22 |\\\\\ iostat=status)[/color]
23 |\\\\\ fileopen:if(status==0) then
24 |\\\\\ do
25 |\\\\\ read(9,*,iostat=status) temp
26 |\\\\\ if (status /=0) exit
27 |\\\\\ nvals=nvals+1
28 |\\\\\ size:if(nvals<=max_size) then
29 |\\\\\ a(nvals)=temp
30 |\\\\\ else
31 |\\\\\ exceed = .true.
32 |\\\\\ end if size
33 |\\\\\ end do
34 |\\\\\ toobig:if(exceed)then
[color=00FFFF]35 |\\\\\ write(*,1010)nvals,max_size
36 |\\\\\ 1010 format ('Maximum array size exceeded: ',I6,'>',I6)[/color]
37 |\\\\\ else
38 |\\\\\ outer:do i=1,nvals-1
39 |\\\\\ iptr=i
40 |\\\\\ inner:do j=i+1,nvals
41 |\\\\\ minval:if(a(j)<a(iptr)) then
42 |\\\\\ iptr=j
43 |\\\\\ end if minval
44 |\\\\\ end do inner
45 |\\\\\ swap: if (i /=iptr) then
46 |\\\\\ temp=a(i)
47 |\\\\\ a(i)=a(iptr)
48 |\\\\\ a(iptr)=temp
49 |\\\\\ end if swap
50 |\\\\\ end do outer
51 |\\\\\ sums:do i=1,nvals
52 |\\\\\ sum_x=sum_x+a(i)
53 |\\\\\ sum_x2=sum_x2+a(i)**2
54 |\\\\\ end do sums
55 |\\\\\ enough:if(nvals<2) then
56 |\\\\\ write(*,*)'At least 2 values nust be entered.'
57 |\\\\\ else
58 |\\\\\ x_bar=sum_x/real(nvals)
59 |\\\\\ std_dev=sqrt((real(nvals)*sum_x2-sum_x**2) &
60 |\\\\\ /(real(nvals)*real(nvals-1)))
61 |\\\\\ even:if (mod(nvals,2)==0) then
62 |\\\\\ median=(a(nvals/2)+a(nvals/2+1))/2.
63 |\\\\\ else
64 |\\\\\ median=a(nvals/2+1)
65 |\\\\\ end if even
66 |\\\\\ !tell user
67 |\\\\\ write(*,*)'The mean of this date set is: ',x_bar
68 |\\\\\ write(*,*)'The median of this date set is: ',median
69 |\\\\\ write(*,*)'The standard deviation is: ',std_dev
70 |\\\\\ write(*,*)'The number of this date points is: ',nvals
71 |\\\\\ end if enough
72 |\\\\\ end if toobig
73 |\\\\\ else fileopen
[color=00FFFF]74 |\\\\\ write(*,1050)status
75 |\\\\\ 1050 format (1X,'File open failed--status= '.I6)[/color]
76 |\\\\\ end if fileopen
77 |\\\\\ end program stats_1
但是不知为何,编译的时候不支持fortran的format 标号输出以及 “&”链接符!!!
折腾了好就也没弄明白,请教大家!
望指导!
这是代码:(教材上求中值得例子)
1 program stats_1
2 |\\\\\ implicit none
3 |\\\\\ integer, parameter :: max_size=100
4 |\\\\\ real,dimension(max_size)::a
5 |\\\\\ logical ::exceed= .false.
6 |\\\\\ character(len=20)::filename
7 |\\\\\ integer::i
8 |\\\\\ integer::iptr
9 |\\\\\ integer::j
10 |\\\\\ real::median
11 |\\\\\ integer::nvals=0
12 |\\\\\ integer::status
13 |\\\\\ real::std_dev
14 |\\\\\ real::sum_x=0
15 |\\\\\ real::sum_x2=0
16 |\\\\\ real::temp
17 |\\\\\ real::x_bar
18 |\\\\\ write(*,1000)
[color=00FFFF] 19 |\\\\\ 1000 format(1X,'Enter the file name with the date to be sorted:')
20 |\\\\\ read(*,'(A20)') filename[/color]
[color=00FFFF]21 |\\\\\ open (unit=9,file=filename,status='old',action='read',&
22 |\\\\\ iostat=status)[/color]
23 |\\\\\ fileopen:if(status==0) then
24 |\\\\\ do
25 |\\\\\ read(9,*,iostat=status) temp
26 |\\\\\ if (status /=0) exit
27 |\\\\\ nvals=nvals+1
28 |\\\\\ size:if(nvals<=max_size) then
29 |\\\\\ a(nvals)=temp
30 |\\\\\ else
31 |\\\\\ exceed = .true.
32 |\\\\\ end if size
33 |\\\\\ end do
34 |\\\\\ toobig:if(exceed)then
[color=00FFFF]35 |\\\\\ write(*,1010)nvals,max_size
36 |\\\\\ 1010 format ('Maximum array size exceeded: ',I6,'>',I6)[/color]
37 |\\\\\ else
38 |\\\\\ outer:do i=1,nvals-1
39 |\\\\\ iptr=i
40 |\\\\\ inner:do j=i+1,nvals
41 |\\\\\ minval:if(a(j)<a(iptr)) then
42 |\\\\\ iptr=j
43 |\\\\\ end if minval
44 |\\\\\ end do inner
45 |\\\\\ swap: if (i /=iptr) then
46 |\\\\\ temp=a(i)
47 |\\\\\ a(i)=a(iptr)
48 |\\\\\ a(iptr)=temp
49 |\\\\\ end if swap
50 |\\\\\ end do outer
51 |\\\\\ sums:do i=1,nvals
52 |\\\\\ sum_x=sum_x+a(i)
53 |\\\\\ sum_x2=sum_x2+a(i)**2
54 |\\\\\ end do sums
55 |\\\\\ enough:if(nvals<2) then
56 |\\\\\ write(*,*)'At least 2 values nust be entered.'
57 |\\\\\ else
58 |\\\\\ x_bar=sum_x/real(nvals)
59 |\\\\\ std_dev=sqrt((real(nvals)*sum_x2-sum_x**2) &
60 |\\\\\ /(real(nvals)*real(nvals-1)))
61 |\\\\\ even:if (mod(nvals,2)==0) then
62 |\\\\\ median=(a(nvals/2)+a(nvals/2+1))/2.
63 |\\\\\ else
64 |\\\\\ median=a(nvals/2+1)
65 |\\\\\ end if even
66 |\\\\\ !tell user
67 |\\\\\ write(*,*)'The mean of this date set is: ',x_bar
68 |\\\\\ write(*,*)'The median of this date set is: ',median
69 |\\\\\ write(*,*)'The standard deviation is: ',std_dev
70 |\\\\\ write(*,*)'The number of this date points is: ',nvals
71 |\\\\\ end if enough
72 |\\\\\ end if toobig
73 |\\\\\ else fileopen
[color=00FFFF]74 |\\\\\ write(*,1050)status
75 |\\\\\ 1050 format (1X,'File open failed--status= '.I6)[/color]
76 |\\\\\ end if fileopen
77 |\\\\\ end program stats_1