# Parallel Computation for Inversion Algorithm of 2D ZTEM
## 3 Parallel Algorithm
### Parallel Algorithm of ZTEM Inversion  
The algorithm needs to perform the calculation many times. A calculation has three parts, namely, solving the equation forward (obtaining the value of \(T\)), the first pseudo-forward solution to the equation of inversion (obtaining the value of Aty), and the second pseudo-forward solution to the equation of inversion (obtaining the value of \(Ap\)). We analyzed the algorithms of forward and inversion and found that solving the equation is the main work and costs a large proportion of the running time. As with six frequencies, when the frequency is different, we can obtain the k, and k is also different. \(K\) is in the equation \(k\alpha=s\). In order to obtain the new \(m\), we need to solve the equation 18 times in an iteration process. When there are three processes in the algorithm, every process needs to solve the equation six times. The process needs to solve the equation 18 times in the serial algorithm. The process in the parallel program needs to do less work than the serial program, so the parallel program needs less time to execute the inversion algorithm than the serial program. Therefore, the parallel efficiency is higher [17]. The six frequencies are freq(1)... freq(6) 400, 200, 100, 50, 20, and 10 Hz. When the frequency is higher than other frequencies, solving the equation needs less time. Two kinds of processes exist in the algorithm. One is the main process and the other is the subprocess. The 0 process is the main process. It owns the global data, distributes the work, sends the data, receives the data, and writes the result files. The subprocesses receive data from the 0 process, perform the work, and send the result to the 0 process. When there are three processes in the parallel program, the 0 process is the main process and the first and second processes are the subprocesses. The 0 process also needs to perform the work in the algorithm. We will introduce the main procedure. 1. MPI_INIT(), In the MPI environment. The main process reads the file, obtains the frequencies, models the information, and observes the data. MPI_Bcast() is the main process, which broadcasts the data to the other processes. The beginning resistivity of the object model is set as the background resistivity. 2. In Table 1, the allocated frequencies and process ID information are shown. Every process needs to solve the equation of the relevant frequencies separately. We obtain the apparent Tipper of the observed point after solving the forward equation. We obtain the \(A^{T}V^{-1}e\) (the symbol is named aty_mpi in the program). In MPI_recv(), the main process obtains the modeestm_all and aty_all of other processes. Aty_all has six vectors of different frequencies. Aty is the sum of six vectors. Mode_restm_all has six modrestm_mpi, and the sequence is 1, 2, 3, 4, 5, and 6. Then, we obtain the modrestm to continue computing. In MPI_Bcast(), the main process broadcasts the data, including m and Aty, to the other processes. 1. After computing the value of object function \(\psi\), the main process can obtain the rms. If rms is less than 1.5, we proceed to step 4; otherwise, we compute the second pseudo-forward equation. Every process needs to perform computing separately. Process can obtain the Ap_mpi. MPI_recv(), and the main process receives Ap_mpi from the other processes. The process puts it together and obtains the value of Ap_all. Ap_all has six Ap_mpi, of which the order is 1, 2, 3, 4, 5, and 6. We obtain the \(Ap\). In MPI_Bcast(), the main process broadcasts \(Ap\) to the subprocesses, and we obtain the value of step length \(\alpha\). We can obtain the new model \(m=m+\alpha p\), go to step 2. \begin{table}
\begin{tabular}{c c} \hline
**Process ID** & **The Frequency** \\ \hline
0 & freq(1), freq(2) \\
1 & freq(3), freq(4) \\
2 & freq(5), freq(6) \\ \hline \end{tabular}
\end{table} 
Table 1: The allocated frequencies. (4) The main process writes the \(m\) data in the result file. In MPI_FINALIZE(0), we finish the parallel environment.