| 5 | 1/1 | 返回列表 |
| 查看: 2474 | 回復(fù): 5 | |||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | |||
alvin510銀蟲 (小有名氣)
|
[求助]
Fortran編程過程中遇到錯(cuò)誤,求大俠幫忙看下
|
||
|
我在用FORTRAN計(jì)算NLO過程中,編的一段程序遇到錯(cuò)誤,請(qǐng)高手幫忙看下,萬分感謝。 其中的一段程序?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)上傳了上來。 再次感謝你的幫助! |
銀蟲 (小有名氣)
|
謝謝你發(fā)現(xiàn)這個(gè)問題。后來我自己又發(fā)現(xiàn)了幾個(gè)問題一并做了更改,發(fā)現(xiàn)還是出現(xià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 |
銀蟲 (小有名氣)
專家顧問 (正式寫手)
![]() |
專家經(jīng)驗(yàn): +14 |
銀蟲 (小有名氣)
|
提示出錯(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ā)表 | |
|---|---|---|---|---|
|
[考研] 297求調(diào)劑 +7 | 田洪有 2026-03-26 | 7/350 |
|
|---|---|---|---|---|
|
[考研] 321求調(diào)劑 +7 | 璞玉~~ 2026-03-25 | 8/400 |
|
|
[碩博家園] 求調(diào)劑 有機(jī)化學(xué)考研356分 +3 | Nadiums 2026-03-25 | 4/200 |
|
|
[考研]
|
nnnnnnn5 2026-03-25 | 7/350 |
|
|
[考研] 2026年華南師范大學(xué)歡迎化學(xué),化工,生物,生醫(yī)工等專業(yè)優(yōu)秀學(xué)子加入! +3 | llss0711 2026-03-28 | 5/250 |
|
|
[考研] 295材料工程專碩求調(diào)劑 +7 | 1428151015 2026-03-27 | 7/350 |
|
|
[考研] 求調(diào)劑 +3 | QiMing7 2026-03-25 | 4/200 |
|
|
[考研] 0703化學(xué)/290求調(diào)劑/本科經(jīng)歷豐富/工科也可 +9 | 丹青奶蓋 2026-03-26 | 10/500 |
|
|
[碩博家園] 北京林業(yè)大學(xué)碩導(dǎo)招生廣告 +6 | kongweilin 2026-03-26 | 8/400 |
|
|
[考研] 求調(diào)劑 +6 | 林之夕 2026-03-24 | 6/300 |
|
|
[考研] 材料調(diào)劑 +8 | 匹克i 2026-03-23 | 8/400 |
|
|
[考研] 求調(diào)劑 一志愿 本科 北科大 化學(xué) 343 +6 | 13831862839 2026-03-24 | 7/350 |
|
|
[考研] 327求調(diào)劑 +7 | prayer13 2026-03-23 | 7/350 |
|
|
[考研] 325求調(diào)劑 +3 | Aoyijiang 2026-03-23 | 3/150 |
|
|
[考研] 一志愿南航 335分 | 0856材料化工 | GPA 4.07 | 有科研經(jīng)歷 +6 | cccchenso 2026-03-23 | 6/300 |
|
|
[考研] 一志愿北化315 求調(diào)劑 +3 | akrrain 2026-03-24 | 3/150 |
|
|
[考研] 化工專碩求調(diào)劑 +3 | question挽風(fēng) 2026-03-24 | 3/150 |
|
|
[考博] 26申博自薦 +3 | whh869393 2026-03-24 | 3/150 |
|
|
[考研] 328求調(diào)劑 +4 | LHHL66 2026-03-23 | 4/200 |
|
|
[考研] 石河子大學(xué)(211、雙一流)碩博研究生長期招生公告 +3 | 李子目 2026-03-22 | 3/150 |
|