|
7#
楼主 |
发表于 2017-4-10 10:54:32
|
只看该作者
你好,我按原博文写的这个程序,
[Fortran] 纯文本查看 复制代码 program wheat_area
implicit none
integer k,i
integer,parameter::nCol=113
!Define a constant nCol equal to 113
character(80) str(nCol)
character(9),parameter::strHead(6)=['alloc_key,'whea ','whea_h ','whea_l ','whea_i ','whea_s ']
logical (kind=4) L(nCol)
open(10,file="/home/iga_qtong/fortran_xcao/gae_c/spam_p.csv")
open(11,file="/home/iga_qtong/fortran_xcao/gae_c/whout.csv")
read(10,*) str !read the head of table
L= .false. !determin the column to read
do i=1,nCol
str(i)=AdjustL(str(i))
if(any(Trim(str(i))==strHead))then
!if the string equal to the strHead
L(i)= .true.
write(11,"(a,',')",advance='no') Trim(str(i))
end if
end do
编译时还是出现了以下错误:请问如何改正?还有在Linux下编译fortran,定义变量时过长不能编译,续行符我始终没有查明白,请赐教,谢谢
wheat_area.f(8): error #5144: Invalid character_kind_parameter. No underscore
character(9),parameter::strHead(6)=['alloc_key,'whea ','whea_h ','whea_l ','whea_i ','whea_s ']
------------------------------------------------------------------^
wheat_area.f(8): error #5082: Syntax error, found IDENTIFIER 'WHEA' when expecting one of: ( * ) :: , <END-OF-STATEMENT> ; . (/ + - : ] /) ' ** / // > .LT. ...
character(9),parameter::strHead(6)=['alloc_key,'whea ','whea_h ','whea_l ','whea_i ','whea_s ']
------------------------------------------------------^
wheat_area.f(17): error #6404: This name does not have a type, and must have an explicit type. [STRHEAD]
if(any(Trim(str(i))==strHead))then
------------------------------^
wheat_area.f(17): error #6303: The assignment operation or the binary expression operation is invalid for the data types of the two operands. [STRHEAD]
if(any(Trim(str(i))==strHead))then
------------------------------^
wheat_area.f(17): error #6361: An array-valued argument is required in this context. [ANY]
if(any(Trim(str(i))==strHead))then
----------------------------^
compilation aborted for wheat_area.f (code 1) |
|