進階版,檔案不存在時會回覆你檔案不存在。 -- program collecting_energy ! This program collectes the energies at each step of a trajectory. character(16) :: filename,Ofilename logical :: file_exist integer :: Nstep,Nrow character(16) :: tim(6000),ke(6000),pe(6000),C2(6000),C4(6000) print *, "Please enter a filename for loading your data" print *, "Warning: the length of the filenam must be less than 16" read(*,*) filename inquire (file=filename,exist=file_exist) if (file_exist .eq. .true.) then print *, "Please enter a filename for output file" read(*,*) Ofilename print *, "Enter the maximum step NO. in your trajectory job" print *, "Warning: the maximum step should be less than 2000" read(*,*) Nstep Nrow = Nstep*3 open (unit=7,file=filename,status='old',action='read') open (unit=8,file=Ofilename,status='new') do l = 1, Nrow read(7,2,advance='yes',end=4) tim(l),C2(l),ke(l),C4(l),pe(l) if (mod(l,3) .eq. 1) then write(8,3) tim(l),ke(l),pe(l) end if 2 format (5a16) 3 format (3a16) end do else print *, filename," doesn't exist" go to 999 end if 999 stop 4 print *, "The energies were written in ", Ofilename, ". Bye." end -- 合併前面兩個程式。 這是一個幫我從G03進行BOMD計算後的fchk裡面關於所有能量部分的檔案,自動剪出軌跡 每步的時間,動能及位能的小程式。 執行時會要求你輸入你從fchk剪輯出來能量部分的檔案的檔名,如果你輸入錯檔名會自動 告訴你檔案不存在。 當你放在執行檔同資料夾的能量列檔案存在時,會自動剪輯出時間、動能、位能。
創作者介紹
創作者 就是部落格 的頭像
mongqiu

就是部落格

mongqiu 發表在 痞客邦 留言(0) 人氣( 113 )