爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 2678|回复: 2

[求助] 程序老出错,新手求助

[复制链接]

新浪微博达人勋

发表于 2015-5-18 19:53:13 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 大气小白 于 2015-5-18 19:54 编辑

楼主大二小白狗,由于Fortran和GASDS课程合并,老师Fortran讲的太浅,不对老师和学校作太多评论,自学中.....
废话不多说,直接上代码
module getdata
implicit none
character(len=79),save::filename
integer,parameter::fileid=10
integer,save::error=0
integer,save::warrning=0
integer,save::i=0,j,k
real,save,allocatable::a(:)
logical,save::alive=0
end module
!contains
subroutine get()
!program get
use getdata
implicit none
real hp
print*,'please enter file name:'
read(*,*)filename
inquire(file=filename,exist=alive)
if(alive)then
  open(fileid,file=filename,status='old',iostat=warrning)
if(warrning>0)then
  print*,"warrning"
end if
  do while(.true.)
   read(fileid,*,iostat=error)hp
   write(*,"(f9.2)")hp
   write(*,*)i
   if(error>0)then
   print*,"warrning"
   end if
   if(error/=0)exit
   i=i+1
  end do
else
  write(*,*)"does't exist."
end if
rewind(fileid)
if(allocated(a))deallocate(a)
  allocate(a(i))
if(.not.allocated(a))then
  write(*,*)"allocate buffer error!"
end if
do j=1,i
  read(fileid,*)a(j)
  write(*,'(f9.2)')a(j)
end do
return
end subroutine
!end module

以上代码本来想写在一个module里面,作获得数据之用,单独编写的时候完美运行,但在编为一个主程序时就出现了3个ERROR,为解决问题尝试了各种办法,把它直接写成subroutine还是不能调用,一下是主函数部分及错误代码(ps.主函数没有写完,只是为了测试调用功能)
program main
use getdata
implicit none
real,allocatable::dhp(:)
integer::b,c
integer,parameter::station=160
write(*,*)"enter b"
read(*,*)b
do c=1,b
  call subroutine get()    !!!!此行为61行
  allocate(dhp(i))
end do
end program

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~错误代码~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
错误  3  error #6460: This is not a field name that is defined in the encompassing structure.   [GET]        C:\f90\Console1\Console1\getdata.f90       61错误  2  error #6404: This name does not have a type, and must have an explicit type.   [SUBROUTINE]        C:\f90\Console1\Console1\getdata.f90       61        
错误  1  error #5082: Syntax error, found IDENTIFIER 'GET' when expecting one of: ( <END-OF-STATEMENT> ; % [ .        C:\f90\Console1\Console1\getdata.f90       61  

还请大神们多多指教
        




密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-5-19 10:27:20 | 显示全部楼层
call subroutine get()    !!!!此行为61行
直接写call get()   
subroutine是关键字,不能用在这个地方
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-5-19 11:50:52 | 显示全部楼层
wheelar 发表于 2015-5-19 10:27
call subroutine get()    !!!!此行为61行
直接写call get()   
subroutine是关键字,不能用在这个 ...

....谢谢  突然觉得自己好蠢的样子
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表