如何在電腦上安裝ModEM軟體
- 所寫教程是在win10 Ubuntu子系統下安裝(Ubuntu系統安裝操作一樣)
- 1. 在win10上安裝ubuntu子系統
- 2. 在Ubuntu子系統上安裝必要更新和所需基本配置
- 3. 在ubuntu子系統上安裝圖形界面(非必須,可自行決定是否安裝)
- 4. 在ubuntu子系統下安裝lapack和blas(后面編譯ModEM時需要)
- 5. 在ubuntu下安裝好intel fortran的編譯器:
- 6. 最后進行ModEM的編譯安裝
- 7. 使用教程
所寫教程是在win10 Ubuntu子系統下安裝(Ubuntu系統安裝操作一樣)
以下安裝包的下載鏈接
1. 在win10上安裝ubuntu子系統
可以參考以下鏈接:
安裝win10 Ubuntu子系統鏈接
2. 在Ubuntu子系統上安裝必要更新和所需基本配置
在子系統終端輸入如下命令:
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install alsa
sudo apt-get install xorg openbox
如圖所示:

3. 在ubuntu子系統上安裝圖形界面(非必須,可自行決定是否安裝)
同樣在終端輸入如下操作:
sudo apt-get install xfce4
sudo apt-get install xrdp
安裝完成后,輸入如下命令:
sudo sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini
sudo echo xfce4-session >~/.xsession
sudo service xrdp restart
都完成后,就可以在win10上遠程登錄子系統的圖形界面了,操作如下:
- 首先在win10電腦搜索遠程桌面連接:

- 然后在用戶名中輸入
localhost:3390

- 然后輸入子系統的用戶名和你設定的密碼即可登錄

- 登錄后是這樣:

4. 在ubuntu子系統下安裝lapack和blas(后面編譯ModEM時需要)
不用從原始碼安裝,那樣編譯又慢而且操作很復雜容易出錯,在ubuntu上一條命令就可以解決安裝問題:
sudo apt-get install liblapack-dev libblas-dev
安裝完后用下面fortan程式進行驗證是否安裝好了lapack和blas
program main
implicit none
INTEGER :: N, LDA, LDB
INTEGER :: NRHS
INTEGER :: INFO
INTEGER :: IPIV(4)
REAL(8) :: A(4,4), B(4,1)
N=4;LDA=4;LDB=4
NRHS=1
A=reshape((/1.80,2.88,2.05,-0.89,&
5.25,-2.95,-0.95,-3.80,&
1.58,-2.69,-2.90,-1.04,&
-1.11,-0.66,-0.59,0.80/),(/4,4/))
B=reshape((/9.52,24.35,0.77,-6.22/),(/4,1/))
call DGESV( N, NRHS, A, LDA, IPIV, B, LDB, INFO )
write(*,*) "Solution:"
write(*,'(f8.3)') B
write(*,*) "INFO=", INFO
end program
編譯和運行:
gfortran test1.f90 -o test1 -llapack -lblas
./test1
正確的運行結果如下:

5. 在ubuntu下安裝好intel fortran的編譯器:
前面準備作業做好了,其實安裝很簡單,推薦在圖形界面下安裝,因為這樣可以選擇模塊進行安裝,不然就只能全部進行安裝了,占用空間比較大,
- 把intel fortran安裝包進行解壓,解壓后輸入如下命令進行圖形界面安裝:
sudo ./install_GUI.sh

- 然后就會出現如下安裝界面,全部下一步即可,提供的下載包有永久使用的license:

- 安裝完成后需要設定下環境路徑:
sudo vim /etc/profile # 用vim打開進行編輯
在檔案最后加好如下路徑設定:
#intel 2019
export INTEL=/opt/intel # the install directory of intel
export PATH=$INTEL/bin:$PATH
export LD_LIBRARY_PATH=$INTEL/lib/intel64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$INTEL/mkl/lib/intel64:$LD_LIBRARY_PATH
export LIBRARY_PATH=$INTEL/lib/intel64:LIBRARY_PATH
source /opt/intel/bin/ifortvars.sh intel64
source /opt/intel/bin/iccvars.sh intel64
source /opt/intel/bin/compilervars.sh intel64

- 添加好后,關閉ubuntu子系統,然后再打開,使得環境變數生效,然后測驗一個例子,看看是否
ifort命令可以用了,
program first
print *, 'Hello World!'
print *, sin(123.4)
end program first
編譯和運行:
ifort first.f90 –o first
./first

運行出如上結果就表示ifort安裝成功,
6. 最后進行ModEM的編譯安裝
- 進入提供的f90檔案夾修改下
Makefile里面f90檔案夾所在的路徑:


其他的不用修改,我已經修改好了,
- 修改好后輸入以下命令就可以編譯:
make -j12 # 你自己電腦多少執行緒就輸入多少數字,我電腦12個執行緒,就寫-j12,這樣編譯快很多
這樣編譯好后會生成一個可執行檔案Mod3DMT, 然后把該檔案加入系統路徑,就可以在任意位置運行該可執行程式了,
- 添加任意位置執行的環境變數,命令如下:

我的生成的可執行檔案Mod3DMT在上圖所示的路徑,添加到系統環境變數即可,
sudo vim /etc/profile # 用vim打開
export Modem=/home/think/fortran
export PATH=$PATH:$Modem/modem
添加完后如下圖所示:

- 進行測驗檢驗,在終端任意位置輸入如下命令,出現這些提示符就表示安裝好了:
Mod3DMT
正確資訊:
Copyright (c) 2004-2014 Oregon State University
AUTHORS Gary Egbert, Anna Kelbert & Naser Meqbel
College of Earth, Ocean and Atmospheric Sciences
Output information to files, and progress report to screen (default).
Usage: Mod3DMT -[job] [args]
[READ_WRITE]
-R rFile_Model rFile_Data [wFile_Model wFile_Data]
Reads your input files and checks them for validity;
optionally also writes them out
[FORWARD]
-F rFile_Model rFile_Data wFile_Data [wFile_EMsoln rFile_fwdCtrl]
Calculates the predicted data and saves the EM solution
[INVERSE]
-I NLCG rFile_Model rFile_Data [lambda eps]
Here, lambda = the initial damping parameter for inversion
eps = misfit tolerance for the forward solver
OR
-I NLCG rFile_Model rFile_Data [rFile_invCtrl rFile_fwdCtrl]
Optionally, may also supply
the model covariance configuration file [rFile_Cov]
the starting model parameter perturbation [rFile_dModel]
Runs an inverse search to yield an inverse model at every iteration
[COMPUTE_J]
-J rFile_Model rFile_Data wFile_Sens [rFile_fwdCtrl]
Calculates and saves the full J(acobian)
[MULT_BY_J]
-M rFile_Model rFile_dModel rFile_Data wFile_Data [rFile_fwdCtrl]
Multiplies a model by J to create a data vector
[MULT_BY_J_T]
-T rFile_Model rFile_Data wFile_dModel [rFile_fwdCtrl]
Multiplies a data vector by J^T to create a model
[MULT_BY_J_T_multi_Tx]
-x rFile_Model rFile_Data wFile_dModel [rFile_fwdCtrl]
Multiplies a data vector by J^T to output models for each transmitter
[APPLY_COV]
-C FWD rFile_Model wFile_Model [rFile_Cov rFile_Prior]
Applies the model covariance to produce a smooth model output
Optionally, also specify the prior model to compute resistivities
from model perturbation: m = C_m^{1/2} \\tilde{m} + m_0
[TEST_ADJ]
-A J rFile_Model rFile_dModel rFile_Data [wFile_Model wFile_Data]
Tests the equality d^T J m = m^T J^T d for any model and data.
Optionally, outputs J m and J^T d.
[TEST_SENS]
-S rFile_Model rFile_dModel rFile_Data wFile_Data [wFile_Sens]
Multiplies by the full Jacobian, row by row, to get d = J m.
Compare to the output of [MULT_BY_J] to test [COMPUTE_J]
Optional final argument -v [debug|full|regular|compact|result|none]
indicates the desired level of output to screen and to files.
7. 使用教程
這里提供一組資料以供測驗:
- 測線圖:

- 資料鏈接:
鏈接:https://pan.baidu.com/s/1Exc1k1Xm5mh1BzKpvxwH6A
提取碼:1mf1
- 在Ubuntu子系統中的運行教程
運行命令為:
mpirun -np 12 Mod3DMT -I NLCG ModEM_Model_File.rho ModEM_Data.dat

- 然后就會有如下提示資訊:
node[005]: MPI TASK [ Distribute Model] received from 0
node[006]: MPI TASK [ Distribute Model] received from 0
node[007]: MPI TASK [ Distribute Model] received from 0
node[008]: MPI TASK [ Distribute Model] received from 0
node[009]: MPI TASK [ Distribute Model] received from 0
node[010]: MPI TASK [ Distribute Model] received from 0
node[011]: MPI TASK [ Distribute Model] received from 0
node[001]: Waiting for a message from Master
node[002]: Waiting for a message from Master
node[003]: Waiting for a message from Master
node[004]: Waiting for a message from Master
node[005]: Waiting for a message from Master
node[006]: Waiting for a message from Master
node[007]: Waiting for a message from Master
node[010]: Waiting for a message from Master
node[008]: Waiting for a message from Master
node[009]: Waiting for a message from Master
node[011]: Waiting for a message from Master
node[001]: MPI TASK [ FORWARD] received from 0
node[002]: MPI TASK [ FORWARD] received from 0
node[003]: MPI TASK [ FORWARD] received from 0
node[004]: MPI TASK [ FORWARD] received from 0
node[005]: MPI TASK [ FORWARD] received from 0
node[006]: MPI TASK [ FORWARD] received from 0
node[007]: MPI TASK [ FORWARD] received from 0
node[008]: MPI TASK [ FORWARD] received from 0
node[009]: MPI TASK [ FORWARD] received from 0
node[010]: MPI TASK [ FORWARD] received from 0
node[011]: MPI TASK [ FORWARD] received from 0
- 教程到這里就結束了,大家可以運行自己的模型檔案,后面寫一個使用
mtpy生成模型輸入檔案的教程,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/163427.html
標籤:其他
