|
本帖最后由 slxc920113 于 2019-10-16 17:05 编辑
Linux系统从命令行直接执行Multiwfn,或者在window中直接将文件拖到Multiwfn.exe程序文件上打开的时候,由于程序的启动路径是当前shell或文件所在路径,在相对路径下无法找到settings.ini配置文件,这个时候就会导致程序使用默认的配置参数,某些功能(比如用cubegen加速表面静电势的计算)会失效。
Multiwfn的源码fileIO.f90中加载settings.ini的代码如下:
- inquire(file="settings.ini",exist=alive)
- if (alive==.true.) then
- settingpath="settings.ini"
- else if (alive==.false.) then
- call getenv("Multiwfnpath",c80tmp)
- if (isys==1) then
- settingpath=trim(c80tmp)//"\settings.ini"
- else if (isys==2) then
- settingpath=trim(c80tmp)//"/settings.ini"
- end if
- inquire(file=settingpath,exist=alive)
- if (alive==.false.) then
- write(*,"(a)") " Warning: ""settings.ini"" was found neither in current folder nor in the path defined by ""Multiwfnpath"" &
- environment variable. Now using default settings instead"
- write(*,*)
- return
- end if
- end if
复制代码
假设程序安装在/opt/software/Multiwfn路径下
Linux系统下,可以添加Multiwfnpath这个环境变量来解决问题
- export Multiwfnpath=/opt/software/Multiwfn
复制代码
window下也可以添加Multiwfnpath环境变量,或者用一个更加简单的方法吗,创建一个快捷方式。
右击快捷方式>属性,然后将起始位置改成settings.ini所在的路径(默认)
但是,这又会带来一个问题,输出各种数据文件的时候,都会保存在程序所在路径,非常不方便。
真正一劳永逸的方法:直接修改源代码。
程序执行参数中第一个参数就是程序自身所在的路径,所以只需要从Multiwfn所在的绝对路径加载settings.ini就能解决这个问题
将上面那段代码稍作修改
- inquire(file="settings.ini",exist=alive)
- if (alive==.true.) then
- settingpath="settings.ini"
- else if (alive==.false.) then
- call getenv("Multiwfnpath",c80tmp)
- if (isys==1) then
- settingpath=trim(c80tmp)//"\settings.ini"
- else if (isys==2) then
- settingpath=trim(c80tmp)//"/settings.ini"
- end if
- inquire(file=settingpath,exist=alive)
- if (alive==.false.) then
- !get prigram path of Multiwfn
- call getarg(0,c80tmp)
- if (isys==1) then
- !replace window path of Multiwfn.exe with settings.ini
- settingpath=c80tmp(:index(c80tmp,'\',.true.))//"settings.ini"
- else if (isys==2) then
- !replace *nix path of Multiwfn with settings.ini
- settingpath=c80tmp(:index(c80tmp,'/',.true.))//"settings.ini"
- end if
- inquire(file=settingpath,exist=alive)
- if (alive==.false.) then
- write(*,"(a)") " Warning: ""settings.ini"" was found neither in current folder nor in the path defined by ""Multiwfnpath"" &
- environment variable. Now using default settings instead"
- write(*,*)
- return
- end if
- end if
- end if
复制代码
重新编译源码即可。 |
评分 Rate
-
查看全部评分 View all ratings
|