| 24小時(shí)熱門版塊排行榜 |
| 5 | 1/1 | 返回列表 |
| 查看: 2473 | 回復(fù): 5 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
alvin510銀蟲 (小有名氣)
|
[求助]
Fortran編程過(guò)程中遇到錯(cuò)誤,求大俠幫忙看下
|
||
|
我在用FORTRAN計(jì)算NLO過(guò)程中,編的一段程序遇到錯(cuò)誤,請(qǐng)高手幫忙看下,萬(wàn)分感謝。 其中的一段程序?yàn)椋?br /> module def implicit none integer :: nk,nkpts,ndum,ns,nspins,nb,locat_str character (len=80) :: dummy real num_e real fermi_energy integer num_bands real,allocatable :: weight( ![]() real,allocatable :: kpoints(:, ![]() end module program main !讀入 kpoints, weights 和 eigenvalues use def implicit none integer,parameter :: fileid=10 character (len=80) :: filename="F:\FORTRAN\NLOC\CGA\unit_bands.txt" logical alive inquire (file=filename,exist=alive) if(.not. alive) then write(*,*) trim(filename), "doesn't exist!" stop end if open(unit=10,file=filename) read(unit=10,"(19XI6,/,26XI2,/,20XF7.1,/,22XI7,/,31XF13.8)" nkpts,spins,num_e,num_bands,fermi_energyallocate(kpoints(1,nkpts)) allocate(kpoints(2,nkpts)) allocate(kpoints(3,nkpts)) allocate(weight(nkpts)) do nk = 1, nkpts read(fileid, '(a)') dummy locat_str = index(dummy,'K-point') read(dummy(locat_str+7 ,*) ndum, kpoints(1,nk), kpoints(2,nk), kpoints(3,nk), weight(nk)do ns = 1, nspins read(fileid,*) dummy do nb = 1, num_bands read(fileid,*) eigenvalues(nb, nk, ns) enddo enddo enddo close(fileid) stop end program 其中調(diào)用了一個(gè)數(shù)據(jù)文件unit_bands.txt。這個(gè)文件我已經(jīng)上傳了上來(lái)。 再次感謝你的幫助! |
專家顧問(wèn) (正式寫手)
![]() |
專家經(jīng)驗(yàn): +14 |
銀蟲 (小有名氣)
銀蟲 (小有名氣)
|
謝謝你發(fā)現(xiàn)這個(gè)問(wèn)題。后來(lái)我自己又發(fā)現(xiàn)了幾個(gè)問(wèn)題一并做了更改,發(fā)現(xiàn)還是出現(xiàn)問(wèn)題了。我的代碼如下: module def implicit none integer :: nk,nkpts,ndum,ns,nspins,nb,locat_str character (len=80) :: dummy real num_e real fermi_energy integer num_bands real,allocatable :: weight( ![]() real,allocatable :: kpoints(:, ![]() real,allocatable :: eigenvalues(:,:, ![]() end module program main !讀入 kpoints, weights 和 eigenvalues use def implicit none integer,parameter :: fileid=10 character (len=80) :: filename="F:\FORTRAN\NLOC\CGA\unit_bands.txt" logical alive inquire (file=filename,exist=alive) if(.not. alive) then write(*,*) trim(filename), "doesn't exist!" stop end if open(unit=fileid,file=filename) read(unit=fileid,"(19XI6,/,26XI2,/,20XF7.1,/,22XI7,/,31XF13.8)" nkpts,nspins,num_e,num_bands,fermi_energy!read(unit=fileid,"(19XI6)" nkpts!read(unit=fileid,"(26XI2)" nspins!read(unit=fileid,"(20XF7.1)" num_e!read(unit=fileid,"(22XI7)" num_bands!read(unit=fileid,"(31XF13.8)" fermi_energyallocate(kpoints(3,nkpts)) allocate(weight(nkpts)) allocate(eigenvalues(num_bands,nkpts,nspins)) do nk = 1, nkpts read(fileid, '(a)') dummy locat_str = index(dummy,'K-point') read(dummy(locat_str+7 ,*) ndum, kpoints(1,nk), kpoints(2,nk), kpoints(3,nk), weight(nk)do ns = 1, nspins read(fileid,*) dummy do nb = 1, num_bands read(fileid,*) eigenvalues(nb, nk, ns) enddo enddo enddo close(fileid) stop end program |
銀蟲 (小有名氣)
|
提示出錯(cuò)的地方在 read(unit=fileid,"(19XI6,/,26XI2,/,20XF7.1,/,22XI7,/,31XF13.8)" nkpts,nspins,num_e,num_bands,fermi_energy這一行。 錯(cuò)誤 1 error #6357: This is not a valid specifier for a control list. ['(19XI6,/,26XI2,/,20XF7.1,/,22XI7,/,31XF13.] F:\FORTRAN\NLOC\CGA\CGA-01.f90 30 請(qǐng)幫我查查看原因,謝謝 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +7 | 爭(zhēng)取九點(diǎn)睡 2026-03-28 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 275求調(diào)劑 +10 | Micky11223 2026-03-25 | 14/700 |
|
|
[考研] 085600 286分 材料求調(diào)劑 +7 | 麻辣魷魚 2026-03-27 | 8/400 |
|
|
[考研] 339求調(diào)劑,想調(diào)回江蘇 +6 | 烤麥芽 2026-03-27 | 8/400 |
|
|
[考研] 材料求調(diào)劑一志愿哈工大324 +7 | 閆旭東 2026-03-28 | 9/450 |
|
|
[有機(jī)交流]
高溫高壓反應(yīng)求助
10+4
|
chibby 2026-03-25 | 4/200 |
|
|
[考研] 一志愿北京化工大學(xué) 070300 學(xué)碩 336分 求調(diào)劑 +9 | vv迷 2026-03-22 | 9/450 |
|
|
[考研] 308求調(diào)劑 +7 | 墨墨漠 2026-03-25 | 7/350 |
|
|
[考研] 305求調(diào)劑 +5 | 哇盧卡庫(kù) 2026-03-26 | 5/250 |
|
|
[考研] 求調(diào)劑323材料與化工 +7 | 1124361 2026-03-24 | 7/350 |
|
|
[考研] 求調(diào)劑 一志愿 本科 北科大 化學(xué) 343 +6 | 13831862839 2026-03-24 | 7/350 |
|
|
[考研] 化學(xué)調(diào)劑一志愿上海交通大學(xué)336分-本科上海211 +4 | 小魚愛有機(jī) 2026-03-25 | 4/200 |
|
|
[考研] 一志愿南航 335分 | 0856材料化工 | GPA 4.07 | 有科研經(jīng)歷 +6 | cccchenso 2026-03-23 | 6/300 |
|
|
[考研] 材料與化工304求B區(qū)調(diào)劑 +3 | 邱gl 2026-03-25 | 3/150 |
|
|
[考研] 材料專碩 335 分求調(diào)劑 +4 | 拒絕冷暴力 2026-03-25 | 4/200 |
|
|
[考研] 求b區(qū)院校調(diào)劑 +4 | 周56 2026-03-24 | 5/250 |
|
|
[有機(jī)交流]
20+3
|
FENGSHUJEI 2026-03-23 | 5/250 |
|
|
[考研] 292求調(diào)劑 +4 | 鵝鵝鵝額額額額?/a> 2026-03-24 | 4/200 |
|
|
[考博] 26申博自薦 +3 | whh869393 2026-03-24 | 3/150 |
|
|
[基金申請(qǐng)] 請(qǐng)教下大家 2026年國(guó)家基金申請(qǐng)是雙盲審嗎? +3 | lishucheng1 2026-03-22 | 5/250 |
|