# A Novel GPU-Based Acceleration Algorithm for a Longwave Radiative Transfer Model
## 5 Algorithm Implementation
### trrnmc_d  
The implementations of 1D \(trrnmc\_d1\), \(trrnmc\_d4\), \(trrnmc\_d8\), \(trrnmc\_d10\), and \(trrnmc\_d11\) are similar to the procedure in Algorithm 3. The 2D \(trrnmc\_d2\) and \(trrnmc\_d9\) are used to assign a value to some arrays; their implementations are not described further here. The implementations of \(trrnmc\_d3\), 2D \(trrnmc\_d5\), and 2D \(trrnmc\_d6\) are illustrated in Algorithm 9. The implementation of \(trrnmc\_d7\) is similar to that of \(trrnmc\_d3\). ```
```
1:input=(blockIdx%x-1)\(\times\)blockDim%x+threadIdx%x
2:igc=(blockIdx%y-1)\(\times\)blockDim%y+threadIdx%y
3:lay=(blockIdx%z-1)\(\times\)blockDim%z+threadIdx%z
4:if((iplon\(\geq\)1.and.iplon\(\leq\)ncol).and.(lay\(\geq\)0.and.lay\(\leq\)nlayers).and. (igc\(\geq\)1.and.igc\(\leq\)ngptlw)) then
5:urad(iplon, igc, lay) = 0.0
6:drad(iplon, igc, lay) = 0.0
7:clrrad(iplon, igc, lay) = 0.0
8:clrrad(iplon, igc, lay) = 0.0
9:endif
10:end subroutine
2:attributes(global) subroutine\(trrnmc\_d5\)(parameters)
3:iplon=(blockIdx%x-1)\(\times\)blockDim%x+threadIdx%x
4:igc=(blockIdx%y-1)\(\times\)blockDim%y+threadIdx%y
5:if((iplon\(\geq\)1.and.iplon\(\leq\)ncol).and. (igc\(\geq\)1.and.igc\(\leq\)10)) then //Loop over frequency bands
6:iband=1 //Downward radiative transfer loop
7:do lay = nlayers, 1, -1
8:do some corresponding work
9:end do
10:endif
11:if((iplon\(\geq\)1.and.iplon\(\leq\)ncol).and. (igc\(\geq\)11.and.igc\(\leq\)22)) then
12:iband=2
13:do lay = nlayers, 1, -1
14:do some corresponding work
15:end do
16:end if
17:When iband=3 \(\sim\) 9, the algorithms are similar to that in the case of iband=1 or 2. end subroutine
18:attributes(global) subroutine\(trrnmc\_d6\)(parameters)
19:iplon=(blockIdx%x-1)\(\times\)blockDim%x+threadIdx%x
20:igc=(blockIdx%y-1)\(\times\)blockDim%y+threadIdx%y
31:if((iplon\(\geq\)1.and.iplon\(\leq\)ncol).and. (igc\(\geq\)109.and.igc\(\leq\)114)) then
21:iband=10
22:do lay = nlayers, 1, -1
23:do some corresponding work
24:end do
25:end if
26:end if
27:When iband=11 \(\sim\) 16, the algorithms are similar to that in the case of iband=10. end subroutine
```

**Algorithm 9** Implementation of \(trrnmc\_d3\). ## 6 Result and Discussion

Experimental studies were conducted to evaluate and compare the performance of the proposed algorithm with the solutions above. The results are described below. ### Experimental Setup

To fully investigate the proposed algorithm, this paper conducted an ideal global climate simulation for one model day. The time step of the RRTMG_LW was 1 h.

The experiment platforms include two GPU clusters (K20 and K40 clusters). The K20 cluster at the Computer Network Information Center of CAS has 30 GPU nodes. Each GPU node has two Intel Xeon E5-2680 v2 processors and two NVIDIA Tesla K20 GPUs. Twenty CPU cores in each GPU node share 64 GB DDR3 system memory through QuickPath Interconnect. The basic compiler is the PGI Fortran compiler Version 14.10 that supports CUDA Fortran. The K40 cluster at China University of Geosciences (Beijing) has four GPU nodes, each with two NVIDIA Tesla K40 GPUs. Table 1 lists their detailed configurations. The serial RRTMG_LW was executed on an Intel Xeon E5-2680 v2 processor of K20 cluster. The G-RRTMG_LW was executed on one K20 or K40 GPU. ### Influence of Block Size

The serial runtime of the subroutine \(rrtmg\_lw\) on one core of an Intel Xeon E5-2680 v2 processor, which accounts for 66.07% of the total computing time of the subroutine \(rad\_rrtmg\_lw\), is 647.12 s in this simulation, as shown in Table 2. Here, the computing time of the RRTMG_LW on the CPU or GPU, \(T_{rrtmg\_lw}\), is calculated with the following formula:

\[T_{rrtmg\_lw}=T_{intam}+T_{cldprmc}+T_{setcoef}+T_{taumol}+T_{rtrtrmc},\]

where \(T_{intam}\) is the computing time of the subroutine \(intam\) or kernel \(intam\_d\); moreover, \(T_{cldprmc},T_{setcoef},T_{taumol}\), and \(T_{rtrmc}\) are the corresponding computing times of the other kernels.