| |
ðÒÉÍÅÒ 6.6 üÔÏÔ ÐÒÉÍÅÒ ÐÏËÁÚÙ×ÁÅÔ, ËÁË ÍÏÇÕÔ ÉÓÐÏÌØÚÏ×ÁÔØÓÑ × ÐÒÉËÌÁÄÎÏÊ ÐÒÏÇÒÁÍÍÅ ÆÕÎËÃÉÉ ÆÏÒÍÉÒÏ×ÁÎÉÑ ÒÅÛÅÔËÉ É ÆÕÎËÃÉÉ ÚÁÐÒÏÓÁ. äÉÆÆÅÒÅÎÃÉÁÌØÎÙÅ ÕÒÁ×ÎÅÎÉÑ × ÞÁÓÔÎÙÈ ÐÒÏÉÚ×ÏÄÎÙÈ, ÎÁÐÒÉÍÅÒ, ÕÒÁ×ÎÅÎÉÅ ðÕÁÓÓÏÎÁ, ÍÏÇÕÔ ÂÙÔØ ÒÅÛÅÎÙ ÎÁ ÐÒÑÍÏÕÇÏÌØÎÏÊ ÒÅÛÅÔËÅ. óÎÁÞÁÌÁ ÐÒÏÃÅÓÓÙ ÒÁÓÐÏÌÁÇÁÀÔÓÑ × Ä×ÕÍÅÒÎÏÊ ÓÔÒÕËÔÕÒÅ. ëÁÖÄÙÊ ÐÒÏÃÅÓÓ ÚÁÔÅÍ ÚÁÐÒÁÛÉ×ÁÅÔ ÎÏÍÅÒÁ ÓÏÓÅÄÅÊ × ÞÅÔÙÒÅÈ ÎÁÐÒÁ×ÌÅÎÉÑÈ (××ÅÒÈ, ×ÎÉÚ, ×ÐÒÁ×Ï, ×ÌÅ×Ï). þÉÓÌÏ×ÁÑ ÚÁÄÁÞÁ ÒÅÛÁÅÔÓÑ ÉÔÅÒÁÃÉÏÎÎÙÍ ÍÅÔÏÄÏÍ, ÄÅÔÁÌÉ ËÏÔÏÒÏÇÏ ÓËÒÙÔÙ × ÐÏÄÐÒÏÇÒÁÍÍÅ.
îÁ ËÁÖÄÏÊ ÉÔÅÒÁÃÉÉ ËÁÖÄÙÊ ÐÒÏÃÅÓÓ ×ÙÞÉÓÌÑÅÔ ÎÏ×ÙÅ ÚÎÁÞÅÎÉÑ ÄÌÑ ÆÕÎËÃÉÉ × ÏÂÌÁÓÔÉ ÒÅÛÅÔËÉ, ÚÁ ËÏÔÏÒÕÀ ÏÎ ÏÔ×ÅÔÓÔ×ÅÎÅÎ. úÁÔÅÍ ÐÒÏÃÅÓÓ ÎÁ Ó×ÏÉÈ ÇÒÁÎÉÃÁÈ ÄÏÌÖÅÎ ÏÂÍÅÎÑÔØÓÑ ÚÎÁÞÅÎÉÑÍÉ ÆÕÎËÃÉÉ Ó ÓÏÓÅÄÎÉÍÉ ÐÒÏÃÅÓÓÁÍÉ. îÁÐÒÉÍÅÒ, ÐÏÄÐÒÏÇÒÁÍÍÁ ÏÂÍÅÎÁ ÍÏÖÅÔ ÓÏÄÅÒÖÁÔØ ×ÙÚÏ× ÆÕÎËÃÉÉ MPI_SEND(..., neigh_rank (1), ...) , ÞÔÏÂÙ ÚÁÔÅÍ ÐÏÓÌÁÔØ ÍÏÄÉÆÉÃÉÒÏ×ÁÎÎÙÅ ÚÎÁÞÅÎÉÑ ÆÕÎËÃÉÉ ÌÅ×ÏÍÕ ÓÏÓÅÄÕ (i-1, j).
Integer ndims, num_neihg Logical reorder Parameter (ndims=2,num_neigh=4,reorder=.true.) Integer comm, comm_cart, dims (ndims), neigh_def (ndims), ierr Integer neigh_rank (num_neigh), own_position (ndims), i,j Logical periods (ndims) Real*8 u(0:101,0:101), f(0:101,0:101) Data dims /ndims*0/ Comm = MPI_COMM_WORLD C ÕÓÔÁÎÁ×ÌÉ×ÁÅÔ ÒÁÚÍÅÒ ÒÅÛÅÔËÉ É ÐÅÒÉÏÄÉÞÎÏÓÔØ Call MPI_DIMS_CREATE (comm, ndims, dims, ierr) Periods (1) = .TRUE. Periods (2) = .TRUE. C ÓÏÚÄÁÅÔ ÓÔÒÕËÔÕÒÕ ÒÅÛÅÔËÉ × ÇÒÕÐÐÅ WORLD C É ÚÁÐÒÁÛÉ×ÁÅÔ ÓÏÂÓÔ×ÅÎÎÕÀ ÐÏÚÉÃÉÀ Call MPI_CART_CREATE (comm, ndims, dims, periods, reorder, comm_cart, ierr) Call MPI_CART_GET (comm_cart, ndims, dims, periods, own_position, ierr) C ÐÒÏÓÍÁÔÒÉ×ÁÅÔ ÎÏÍÅÒÁ ÓÏÓÅÄÅÊ. óÏÂÓÔ×ÅÎÎÙÅ ËÏÏÒÄÉÎÁÔÙ ÅÓÔØ C (i,j). óÏÓÅÄÑÍÉ Ñ×ÌÑÀÔÓÑ ÐÒÏÃÅÓÓÙ Ó ÎÏÍÅÒÁÍÉ C (i-1,j), (i+1,j), (i,j-1), (i,j+1) I = own_position(1) J = own_position(2) Neigh_def(1)= i-1 Neigh_def(2)= j Call MPI_CART_RANK (comm_cart, neigh_def, neigh_rank(1), ierr) Neigh_def(1)= i+1 Neigh_def(2)= j Call MPI_CART_RANK (comm_cart, neigh_def, neigh_rank(2), ierr) Neigh_def(1)= i Neigh_def(2)= j-1 Call MPI_CART_RANK (comm_cart, neigh_def, neigh_rank(3), ierr) Neigh_def(1)= i Neigh_def(2)= j+1 Call MPI_CART_RANK (comm_cart, neigh_def, neigh_rank(4), ierr) C ÉÎÉÃÉÁÌÉÚÁÃÉÑ ÆÕÎËÃÉÊ ÒÅÛÅÔÏË É ÎÁÞÁÌÏ ÉÔÅÒÁÃÉÉ Call init (u,f) Do 10 it=1,100 Call relax (u,f) C ÏÂÍÅÎ ÄÁÎÎÙÍÉ Ó ÓÏÓÅÄÎÉÍÉ ÐÒÏÃÅÓÓÁÍÉ Óall exchange (u, comm_cart, neigh_rank, num_neigh) 10 continue call output (u) end
úÁËÌÁÄËÉ ÎÁ ÓÁÊÔÅ ðÒÏÓÌÅÄÉÔØ ÚÁ ÓÔÒÁÎÉÃÅÊ |
Created 1996-2024 by Maxim Chirkov äÏÂÁ×ÉÔØ, ðÏÄÄÅÒÖÁÔØ, ÷ÅÂÍÁÓÔÅÒÕ |