diff --git a/src/ExB_shear_flow_mod.F90 b/src/ExB_shear_flow_mod.F90 index 8d76ef39255dc3a225616ac521b63184a7c93343..ff48c1a260af3a821729e0d76fe6650d6752a40b 100644 --- a/src/ExB_shear_flow_mod.F90 +++ b/src/ExB_shear_flow_mod.F90 @@ -95,7 +95,7 @@ CONTAINS USE grid, ONLY: local_nky, total_nky, kyarray, inv_dkx, update_grids, deltaky!,kyarray_full USE geometry, ONLY: gxx,gxy,gyy,inv_hatB2, evaluate_magn_curv USE numerics, ONLY: evaluate_EM_op, evaluate_kernels - USE model, ONLY: LINEARITY + ! USE model, ONLY: LINEARITY USE time_integration, ONLY: c_E!, ntimelevel IMPLICIT NONE INTEGER, INTENT(IN) :: step_number diff --git a/src/fields_mod.F90 b/src/fields_mod.F90 index f689f8f51c454227d1bd5f995ed80c2098753f82..9677dfd758c5ec8998a89b0495a46732c96ef9b4 100644 --- a/src/fields_mod.F90 +++ b/src/fields_mod.F90 @@ -10,7 +10,10 @@ MODULE fields ! Normalized electric potential: \hat{\phi} ! (kx,ky,z) COMPLEX(xp), DIMENSION(:,:,:), ALLOCATABLE :: phi -!------------------Vector field part +!------------------MAGNETIC VECTOR + ! Parallel component (A_\parallel) COMPLEX(xp), DIMENSION(:,:,:), ALLOCATABLE :: psi + ! delta B parallel (not implemeneted) + ! COMPLEX(xp), DIMENSION(:,:,:), ALLOCATABLE :: dBpar END MODULE fields diff --git a/src/ghosts_mod.F90 b/src/ghosts_mod.F90 index eaead766f00798bf5a452656fbf2a6291144faf0..95a88b0bd2b60a45025b8eb5b04b13727a5acb6a 100644 --- a/src/ghosts_mod.F90 +++ b/src/ghosts_mod.F90 @@ -55,10 +55,13 @@ SUBROUTINE update_ghosts_p_mom USE grid, ONLY: local_na,local_np,local_nj,local_nky,local_nkx,local_nz,& ngp,ngj,ngz IMPLICIT NONE - INTEGER :: ierr, first, last, count + !! buffer for data exchanges + ! COMPLEX(xp),DIMENSION(local_na,-Ngp/2:Ngp/2,local_nj+ngj,local_nky,local_nkx,local_nz+ngz) :: buff_jxyz + COMPLEX(xp),DIMENSION(local_na,local_nj+ngj,local_nky,local_nkx,local_nz+ngz) :: buff_jxyz_in, buff_jxyz_out + INTEGER :: ierr, first, last, count, ig first = 1 + ngp/2 last = local_np + ngp/2 - +#if 0 count = (ngp/2)*local_na*(local_nj+ngj)*local_nky*local_nkx*(local_nz+ngz) ! Number of elements to send !!!!!! Send to the right, receive from the left CALL mpi_sendrecv(moments(:,(last-(ngp/2-1)):(last),:,:,:,:,updatetlevel), count, mpi_xp_c, nbr_R, 14, & @@ -68,8 +71,40 @@ SUBROUTINE update_ghosts_p_mom CALL mpi_sendrecv(moments(:,(first):(first+(ngp/2-1)),:,:,:,:,updatetlevel), count, mpi_xp_c, nbr_L, 16, & moments(:,(last+1):(last+ngp/2) ,:,:,:,:,updatetlevel), count, mpi_xp_c, nbr_R, 16, & comm0, status, ierr) +#else + !! Alternative version (explicit copy here, EXPERIMENTAL) + !! Send the last local moment to fill the -1 neighbour ghost + count = local_na*(local_nj+ngj)*local_nky*local_nkx*(local_nz+ngz) ! Number of elements to send + DO ig=1,ngp/2 + buff_jxyz_out = moments(:,last-(ig-1),:,:,:,:,updatetlevel) + CALL mpi_sendrecv(buff_jxyz_out,count,mpi_xp_c,nbr_R,14+ig, & ! Send to Right the last + buff_jxyz_in ,count,mpi_xp_c,nbr_L,14+ig, & ! Recieve from Left the first-1 + comm0, status, ierr) + moments(:,first-ig,:,:,:,:,updatetlevel) = buff_jxyz_in + ENDDO + ! !!!!!!! Send to the left, receive from the right + DO ig=1,ngp/2 + buff_jxyz_out = moments(:,first+(ig-1),:,:,:,:,updatetlevel) + CALL mpi_sendrecv(buff_jxyz_out,count,mpi_xp_c,nbr_L,16+ig, & ! Send to Left the first + buff_jxyz_in ,count,mpi_xp_c,nbr_R,16+ig, & ! Recieve from Right the last+1 + comm0, status, ierr) + moments(:,last+ig,:,:,:,:,updatetlevel) = buff_jxyz_in + ENDDO +#endif END SUBROUTINE update_ghosts_p_mom +! |t = 0.01| Px = -0.608E-19| Qx = 0.152E-01| +! |t = 0.02| Px = -0.336E-19| Qx = 0.303E-01| +! |t = 0.03| Px = 0.683E-19| Qx = 0.454E-01| +! |t = 0.04| Px = -0.122E-18| Qx = 0.605E-01| +! |t = 0.05| Px = 0.322E-19| Qx = 0.756E-01| +! |t = 0.06| Px = -0.905E-19| Qx = 0.906E-01| +! |t = 0.07| Px = 0.833E-19| Qx = 0.106 | +! |t = 0.08| Px = 0.276E-18| Qx = 0.120 | +! |t = 0.09| Px = -0.889E-19| Qx = 0.135 | +! |t = 0.10| Px = 0.284E-18| Qx = 0.150 | + + !Communicate z+1, z+2 moments to left neighboor and z-1, z-2 moments to right one ! [a b|C D|e f] : proc n has moments a to f where a,b,e,f are ghosts ! @@ -107,8 +142,8 @@ SUBROUTINE update_ghosts_z_mom ENDDO !!!!!!!!!!! Send ghost to down neighbour !!!!!!!!!!!!!!!!!!!!!! DO ig=1,ngz/2 - CALL mpi_sendrecv(moments(:,:,:,:,:,first+(ig-1),updatetlevel),count,mpi_xp_c,nbr_D,26+ig, & ! Send to Up the last - buff_pjxy_zBC(:,:,:,:,:,ig),count,mpi_xp_c,nbr_U,26+ig, & ! Recieve from Down the first-1 + CALL mpi_sendrecv(moments(:,:,:,:,:,first+(ig-1),updatetlevel),count,mpi_xp_c,nbr_D,26+ig, & ! Send to Down the first + buff_pjxy_zBC(:,:,:,:,:,ig),count,mpi_xp_c,nbr_U,26+ig, & ! Recieve from Up the last+1 comm0, status, ierr) ENDDO ELSE !No parallel (just copy) diff --git a/src/initial_mod.F90 b/src/initial_mod.F90 index 38527118d65af8212e09a334b48bb6492adec30a..c5668dfac54b7bf69ff3030b76c950d5982fecfa 100644 --- a/src/initial_mod.F90 +++ b/src/initial_mod.F90 @@ -289,7 +289,7 @@ CONTAINS USE fields, ONLY: moments USE prec_const, ONLY: xp USE model, ONLY: LINEARITY - USE grid, ONLY: total_nkx, local_nkx_offset, local_nky, local_nky_offset, iky0,& + USE grid, ONLY: total_nkx, local_nkx_offset, local_nky, local_nky_offset,& kxarray_full, kyarray_full, kx_max, kx_min, ky_max, deltakx, deltaky IMPLICIT NONE INTEGER :: ikx,iky, im, I_, J_ diff --git a/src/numerics_mod.F90 b/src/numerics_mod.F90 index 6101fcbd6d792e980aed6d1afc843b6db430afdf..840d096a32b352aec305c4d2b3f4e294e99d4a36 100644 --- a/src/numerics_mod.F90 +++ b/src/numerics_mod.F90 @@ -3,9 +3,9 @@ ! the beginng of a run. These routines do not need to be optimzed MODULE numerics USE prec_const, ONLY: xp - implicit none - PUBLIC :: build_dnjs_table, evaluate_kernels, evaluate_EM_op - PUBLIC :: compute_lin_coeff, build_dv4Hp_table + IMPLICIT NONE + PUBLIC :: build_dnjs_table, evaluate_kernels, evaluate_EM_op + PUBLIC :: compute_lin_coeff, build_dv4Hp_table CONTAINS @@ -77,7 +77,10 @@ SUBROUTINE evaluate_kernels USE grid, ONLY : local_na, local_nj,ngj, local_nkx, local_nky, local_nz, ngz, jarray, kp2array,& nzgrid USE species, ONLY : sigma2_tau_o2 - USE model, ONLY : KN_MODEL, ORDER, ORDER_NUM, ORDER_DEN + USE model, ONLY : KN_MODEL, ORDER +#ifdef LAPACK + USE model, ONLY : ORDER_NUM, ORDER_DEN +#endif IMPLICIT NONE INTEGER :: j_int, ia, eo, ikx, iky, iz, ij REAL(xp) :: j_xp, y_, factj, sigma_i @@ -107,9 +110,7 @@ SUBROUTINE evaluate_kernels ENDDO ENDDO CASE ('pade') -#ifdef NOLAPACK - error stop "ERROR STOP: Pade kernels cannot be used when LAPACK is not included (marconi?)" -#else +#ifdef LAPACK ! Kernels based on the ORDER_NUM / ORDER_DEN Pade approximation of the kernels WRITE (*,*) 'Kernel approximation uses ', ORDER_NUM ,'/', ORDER_DEN, ' Pade approximation' DO ia = 1,local_na @@ -131,6 +132,8 @@ SUBROUTINE evaluate_kernels ENDDO ENDDO ENDDO +#else + error stop "ERROR STOP: Pade kernels cannot be used when LAPACK is not included (marconi?)" #endif CASE DEFAULT DO ia = 1,local_na @@ -301,7 +304,7 @@ SUBROUTINE compute_lin_coeff DO ij = 1,local_nj j_int= jarray(ij+ngj/2) ! Laguerre degree j_xp = REAL(j_int,xp) ! REAL of Laguerre degree - ! All Napj terms + ! All Napj terms related to magn. curvature and perp. gradient xnapj(ia,ip,ij) = tau(ia)/q(ia)*(k_cB*(2._xp*p_xp + 1._xp) & +k_gB*(2._xp*j_xp + 1._xp)) ! Mirror force terms @@ -328,7 +331,7 @@ SUBROUTINE compute_lin_coeff DO ij = 1,local_nj j_int= jarray(ij+ngj/2) ! Laguerre degree j_xp = REAL(j_int,xp) ! REAL of Laguerre degree - ! Magnetic gradient term + ! Magnetic perp. gradient term xnapjp1(ia,ij) = -tau(ia)/q(ia) * (j_xp + 1._xp) * k_gB xnapjm1(ia,ij) = -tau(ia)/q(ia) * j_xp * k_gB ENDDO @@ -399,8 +402,7 @@ REAL(xp) FUNCTION taylor_kernel_n(order, n, y) taylor_kernel_n = sum_variable END FUNCTION taylor_kernel_n -#ifdef NOLAPACK -#else +#ifdef LAPACK REAL(xp) FUNCTION pade_kernel_n(n, y, N_NUM, N_DEN) IMPLICIT NONE INTEGER, INTENT(IN) :: n, N_NUM, N_DEN diff --git a/src/processing_mod.F90 b/src/processing_mod.F90 index 028bb44a3468cddccf05e2c50ae944672d5bbf82..aab454c8da248e2440320cf35f1c978ca7f41674 100644 --- a/src/processing_mod.F90 +++ b/src/processing_mod.F90 @@ -87,7 +87,7 @@ CONTAINS DO ip = 1,local_np+ngp DO ia = 1,local_na IF(nzgrid .GT. 1) THEN - p_int = parray(ip+ngp/2) + p_int = parray(ip) eo = MODULO(p_int,2)+1 ! Indicates if we are on even or odd z grid ELSE eo = 0 @@ -276,9 +276,9 @@ CONTAINS -Jacobian(izi,ieven)*tau(ia)*imagu*kyarray(iky)*phi(iky,ikx,izi)& *kernel(ia,ini,iky,ikx,izi,ieven)*CONJG(& 0.5_xp*SQRT2*moments(ia,ip2,ini ,iky,ikx,izi,updatetlevel)& - +(2._xp*n_xp + 1.5_xp)*moments(ia,ip0,ini ,iky,ikx,izi,updatetlevel)& - -(n_xp+1._xp)*moments(ia,ip0,ini+1,iky,ikx,izi,updatetlevel)& - -n_xp*moments(ia,ip0,ini-1,iky,ikx,izi,updatetlevel)) + +(2._xp*n_xp + 1.5_xp)*moments(ia,ip0,ini ,iky,ikx,izi,updatetlevel)& + -(n_xp+1._xp)*moments(ia,ip0,ini+1,iky,ikx,izi,updatetlevel)& + -n_xp*moments(ia,ip0,ini-1,iky,ikx,izi,updatetlevel)) ENDDO ENDDO ENDDO @@ -298,11 +298,11 @@ CONTAINS integrant(iz) = integrant(iz) & +Jacobian(izi,iodd)*tau(ia)*sqrt_tau_o_sigma(ia)*imagu*kyarray(iky)*CONJG(psi(iky,ikx,izi))& *kernel(ia,ini,iky,ikx,izi,iodd)*(& - 0.5_xp*SQRT2*SQRT3*moments(ia,ip3,ini ,iky,ikx,izi,updatetlevel)& + 0.5_xp*SQRT2*SQRT3*moments(ia,ip3,ini ,iky,ikx,izi,updatetlevel)& +1.5_xp*moments(ia,ip1,ini ,iky,ikx,izi,updatetlevel)& +(2._xp*n_xp+1._xp)*moments(ia,ip1,ini ,iky,ikx,izi,updatetlevel)& -(n_xp+1._xp)*moments(ia,ip1,ini+1,iky,ikx,izi,updatetlevel)& - -n_xp*moments(ia,ip1,ini-1,iky,ikx,izi,updatetlevel)) + -n_xp*moments(ia,ip1,ini-1,iky,ikx,izi,updatetlevel)) ENDDO ENDDO ENDDO