|
本帖最后由 max533 于 2015-8-19 19:06 编辑
我在windows7-64bit作業系統
使用FTN95編譯軟體
在編譯程序的過程中出現
line 133 - error 941 - array2 is adummy argument and so cannot be allocatable
line 132 - error 941 - array_sort is a dummy argument and so cannot be allocatable
line 163 - error 1173 - only character variable can be assigned to character variables, found integer (kind=3)
line 166 - error 1173 - only character variable can be assigned to character variables, found integer (kind=3)
這四個bug我一直找不出問題的癥結點,想說上來請各位高手幫忙解決這難題。
先在這邊感謝各位高手幫忙。
[Fortran] 纯文本查看 复制代码 006 | integer :: number 1 , number 2 , k , stat , error , error 2 , error 3 , stat 2 , i |
007 | character ( len = 6 ) , allocatable :: gps_array ( : ) , cwb_array ( : ) |
008 | character :: site 1 * 4 , site 2 * 6 , cwb * 6 , gps * 4 |
009 | real * 8 :: lat 1 , lon 1 , lat 2 , lon 2 , distance , height 1 , height 2 |
010 | real * 8 , allocatable :: distance_array ( : ) |
013 | open ( 11 , file = 'gps_all_info.txt' ) |
014 | open ( 12 , file = 'dbar_pick_info.txt' ) |
015 | open ( 13 , file = 'result.out' ) |
019 | read ( 11 , * , iostat = number 1 ) lon 1 , lat 1 , site 1 , height 1 |
024 | read ( 12 , * , iostat = number 2 ) lon 2 , lat 2 , site 2 , height 2 |
028 | call dis ( lat 1 , lon 1 , lat 2 , lon 2 , distance ) |
029 | write ( 13 , '(a4,2x,a6,2x,f13.7)' ) site 1 , site 2 , distance |
042 | open ( 13 , file = 'result.out' ) |
043 | open ( 14 , file = 'result_new.out' ) |
048 | read ( 13 , * , iostat = stat ) gps , cwb , distance |
054 | allocate ( distance_array ( k ) , stat = error ) |
056 | write ( * , * ) 'The distance array allocated successfully.' |
057 | else if ( error /= 0 ) then |
058 | write ( * , * ) 'The distance array failed to allocated.' |
062 | allocate ( gps_array ( k ) , stat = error 2 ) |
064 | write ( * , * ) 'The site_gps array allocated successfully.' |
065 | else if ( error 2 /= 0 ) then |
066 | write ( * , * ) 'The site_gps array failed to allocated.' |
070 | allocate ( cwb_array ( k ) , stat = error 3 ) |
072 | write ( * , * ) 'The site_cwb array allocated successfully.' |
073 | else if ( error 3 /= 0 ) then |
074 | write ( * , * ) 'The site_cwb array failed to allocated.' |
081 | read ( 13 , * , iostat = stat 2 ) gps_array ( k ) , cwb_array ( k ) , distance_array ( k ) |
085 | call bubble_sort ( distance_array , gps_array , cwb_array , k ) |
088 | write ( 14 , 20 ) gps_array ( i ) , cwb_array ( i ) , distance_array ( i ) |
089 | 20 format ( a 4 , 1 x , a 6 , 1 x , f 13.7 ) |
092 | deallocate ( distance_array ) |
093 | deallocate ( gps_array ) |
094 | deallocate ( cwb_array ) |
103 | subroutine dis ( rlat 1 , rlon 1 , rlat 2 , rlon 2 , distance ) |
106 | real * 8 :: rlat 1 , rlon 1 , rlat 2 , rlon 2 , distance |
107 | real * 8 :: clat 1 , clat 2 , slat 1 , slat 2 , cdlon , crd |
108 | real * 8 , parameter :: rerth = 6.3712e6 |
109 | real * 8 , parameter :: pi = 3.14159265358979 , dpr = 180.0 / pi |
112 | if ( ( abs ( rlat 1 - rlat 2 ) .lt. 0.0001 ) .and. ( abs ( rlon 1 - rlon 2 ) .lt. 0.0001 ) ) then |
115 | clat 1 = cos ( real ( rlat 1 ) / dpr ) |
116 | slat 1 = sin ( real ( rlat 1 ) / dpr ) |
117 | clat 2 = cos ( real ( rlat 2 ) / dpr ) |
118 | slat 2 = sin ( real ( rlat 2 ) / dpr ) |
119 | cdlon = cos ( real ( ( rlon 1 - rlon 2 ) ) / dpr ) |
120 | crd = slat 1 * slat 2 + clat 1 * clat 2 * cdlon |
121 | distance = real ( rerth * acos ( crd ) / 1000.0 ) |
127 | subroutine bubble_sort ( array_sort , array 1 , array 2 , array_dimension ) |
130 | integer :: array_dimension , scan_number , scan_order , temp_sort , temp 1 , temp 2 |
132 | real * 8 , allocatable :: array_sort ( : ) |
133 | character ( len = * ) , allocatable :: array 1 ( : ) , array 2 ( : ) |
136 | allocate ( array_sort ( array_dimension ) ) |
138 | if ( .not. allocated ( array_sort ) ) then |
139 | write ( * , * ) 'In the subroutine buule_sort,The array_sort failed to allocate.' |
142 | allocate ( array 1 ( array_dimension ) ) |
144 | if ( .not. allocated ( array 1 ) ) then |
145 | write ( * , * ) 'In the subroutine buule_sort,The array1 failed to allocate.' |
148 | allocate ( array 2 ( array_dimension ) ) |
150 | if ( .not. allocated ( array_sort ) ) then |
151 | write ( * , * ) 'In the subroutine buule_sort,The array2 failed to allocate.' |
154 | do scan_number = array_dimension -1 , 1 , -1 |
155 | do scan_order = 1 , scan_number , 1 |
157 | if ( array_sort ( scan_order ) > array_sort ( scan_order +1 ) ) then |
158 | temp_sort = array_sort ( scan_order ) |
159 | array_sort ( scan_order ) = array_sort ( scan_order +1 ) |
160 | array_sort ( scan_order +1 ) = temp_sort |
161 | temp 1 = array 1 ( scan_order ) |
162 | array 1 ( scan_order ) = array 1 ( scan_order +1 ) |
163 | array 1 ( scan_order +1 ) = temp 1 |
164 | temp 2 = array 2 ( scan_order ) |
165 | array 2 ( scan_order ) = array 2 ( scan_order +1 ) |
166 | array 2 ( scan_order +1 ) = temp 2 |
|
|