158 use dc_message
, only : messagenotify
193 integer :: im=32, jm=32
194 integer :: km=10, lm=10
196 integer,
dimension(:),
allocatable ::
ke 197 integer,
dimension(:),
allocatable ::
ks 198 integer,
dimension(:),
allocatable ::
kc 199 integer,
dimension(:),
allocatable ::
je 200 integer,
dimension(:),
allocatable ::
js 201 integer,
dimension(:),
allocatable ::
jc 205 integer(8),
dimension(:),
allocatable :: itj
206 real(8),
dimension(:),
allocatable :: tj
207 integer(8),
dimension(:),
allocatable :: iti
208 real(8),
dimension(:),
allocatable :: ti
210 real(8),
dimension(:),
allocatable ::
x_x 211 real(8),
dimension(:),
allocatable ::
v_y 216 real(8),
dimension(:,:),
allocatable ::
vx_x 217 real(8),
dimension(:,:),
allocatable ::
vx_y 219 real(8) :: xmin, xmax
220 real(8) :: ymin, ymax
223 real(8),
parameter :: pi=3.1415926535897932385d0
225 save im, jm, km, lm, itj, tj, iti, ti
228 save xmin, xmax, ymin, ymax, xl, yl
232 subroutine ee_mpi_initial(i_in,j_in,k_in,l_in,xmin_in,xmax_in,ymin_in,ymax_in)
240 integer,
intent(in) :: i_in
241 integer,
intent(in) :: j_in
242 integer,
intent(in) :: k_in
243 integer,
intent(in) :: l_in
245 real(8),
intent(in) :: xmin_in, xmax_in
246 real(8),
intent(in) :: ymin_in, ymax_in
251 integer :: kint, kmod
252 integer :: jint, jmod
255 im = i_in ; jm = j_in
256 km = k_in ; lm = l_in
258 xmin = xmin_in ; xmax = xmax_in
259 ymin = ymin_in ; ymax = ymax_in
260 xl = xmax-xmin ; yl = ymax-ymin
262 CALL mpi_comm_rank(mpi_comm_world,ip,ierr)
263 CALL mpi_comm_size(mpi_comm_world,np,ierr)
274 kc(iip) =
kc(iip) + 1
279 ks(iip) =
ks(iip-1) +
kc(iip-1)
280 ke(iip) =
ks(iip) +
kc(iip) - 1
292 jc(iip) =
jc(iip) + 1
297 js(iip) =
js(iip-1) +
jc(iip-1)
298 je(iip) =
js(iip) +
jc(iip) - 1
306 allocate(
x_x(0:im-1))
308 allocate(
v_y(
jc(ip)))
310 allocate(
vx_x(
jc(ip),0:im-1))
311 allocate(
vx_y(
jc(ip),0:im-1))
313 call fxrini(int(im,8),iti,ti)
314 call fxzini(int(jm,8),itj,tj)
318 x_x(ii) = xmin + xl/im*ii
323 v_y(jj) = ymin + yl/jm*(
js(ip)+jj-1)
330 call messagenotify(
'M',
'ee_mpi_initial', &
331 'ee_mpi_module (2021/04/27) is initialized')
344 integer,
intent(IN) :: k
347 if ( abs(k) <
ks(ip) .OR.
ke(ip) < abs(k) )
then 349 else if ( k >= 0 )
then 352 kf_k =
ks(ip)+2*
kc(ip)-abs(k)
362 real(8),
dimension(js(ip):je(ip),0:im-1) :: vx_ef
364 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef
366 real(8),
dimension(js(ip):je(ip),2,0:im/2-1) :: vax_work
367 real(8),
dimension(kc(ip),2,0:jm-1) :: fay_work
375 fay_work(k,1,l) = ef(l,k)
376 fay_work(k,2,l) = ef(-l,2*
kc(ip)-k+1)
377 fay_work(k,1,jm-l) = ef(-l,k)
378 fay_work(k,2,jm-l) = ef(l,2*
kc(ip)-k+1)
383 fay_work(k,1,0) = ef(0,k)
384 fay_work(k,2,0) = ef(0,2*
kc(ip)-k+1)
389 fay_work(1,1,l) = ef(l,1)
390 fay_work(1,2,l) = ef(-l,1)
391 fay_work(1,1,jm-l) = ef(l,1)
392 fay_work(1,2,jm-l) = -ef(-l,1)
394 fay_work(1,1,0) = ef(0,1)
397 call fxztba(int(
kc(ip),8),int(jm,8),fay_work,itj,tj)
401 call fxrtba(int(
jc(ip),8),int(im,8),vax_work,iti,ti)
403 vx_ef = reshape(vax_work,(/
jc(ip),im/))
411 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_vx
413 real(8),
dimension(js(ip):je(ip),0:im-1),
intent(in) :: vx
415 real(8),
dimension(js(ip):je(ip),2,0:im/2-1) :: vax_work
416 real(8),
dimension(kc(ip),2,0:jm-1) :: fay_work
419 vax_work = reshape(vx,(/
jc(ip),2,im/2/))
421 call fxrtfa(int(
jc(ip),8),int(im,8),vax_work,iti,ti)
425 if ( ip == 0 ) fay_work(1,2,:) = 0.0d0
427 call fxztfa(int(
kc(ip),8),int(jm,8),fay_work,itj,tj)
431 ef_vx(l,k) = fay_work(k,1,l)
432 ef_vx(-l,2*
kc(ip)-k+1) = fay_work(k,2,l)
433 ef_vx(-l,k) = fay_work(k,1,jm-l)
434 ef_vx(l,2*
kc(ip)-k+1) = fay_work(k,2,jm-l)
439 ef_vx(0,k) = fay_work(k,1,0)
440 ef_vx(0,2*
kc(ip)-k+1) = fay_work(k,2,0)
445 ef_vx(l,1) = fay_work(1,1,l)
446 ef_vx(-l,1) = fay_work(1,2,l)
447 ef_vx(l,2*
kc(0)) = 0.0d0
448 ef_vx(-l,2*
kc(0)) = 0.0d0
450 ef_vx(0,1) = fay_work(1,1,0)
451 ef_vx(0,2*
kc(0)) = 0.0d0
457 real(8),
dimension(kc(ip),2,0:jm-1),
intent(IN) :: fay
458 real(8),
dimension(jc(ip),2,0:im/2-1) :: vax_fay
462 integer :: isndc(0:np-1)
463 integer :: isdsp(0:np-1)
464 integer :: ircvc(0:np-1)
465 integer :: irdsp(0:np-1)
466 real(8),
allocatable :: aa_work(:,:)
469 integer :: ind1, ind2
474 allocate(aa_work(kcm*2*
jc(ip),0:np-1))
483 isdsp(iip) = sum(isndc(0:iip-1))
484 irdsp(iip) = kcm*2*
jc(ip)*iip
487 call mpi_alltoallv(fay,isndc,isdsp,mpi_real8,&
488 aa_work,ircvc,irdsp,mpi_real8,mpi_comm_world,ierr)
495 ind1 = k +
kc(iip)*2*(j-1)
496 ind2 = k +
kc(iip) +
kc(iip)*2*(j-1)
497 vax_fay(j,1,
ks(iip)-1+k) = aa_work(ind1,iip)
498 vax_fay(j,2,
ks(iip)-1+k) = aa_work(ind2,iip)
510 real(8),
dimension(jc(ip),2,0:im/2-1),
intent(IN) :: vax
511 real(8),
dimension(kc(ip),2,0:jm-1) :: fay_vax
515 integer :: isndc(0:np-1)
516 integer :: isdsp(0:np-1)
517 integer :: ircvc(0:np-1)
518 integer :: irdsp(0:np-1)
519 real(8),
allocatable :: aa_work(:,:)
522 integer :: ind1, ind2
527 allocate(aa_work(jcm*2*
kc(ip),0:np-1))
535 isdsp(iip) = sum(isndc(0:iip-1))
536 irdsp(iip) = jcm*2*
kc(ip)*iip
539 call mpi_alltoallv(vax,isndc,isdsp,mpi_real8,&
540 aa_work,ircvc,irdsp,mpi_real8,mpi_comm_world,ierr)
547 ind1 = j +
jc(iip)*2*(k-1)
548 ind2 = j +
jc(iip) +
jc(iip)*2*(k-1)
549 fay_vax(k,1,
js(iip)+j-1) = aa_work(ind1,iip)
550 fay_vax(k,2,
js(iip)+j-1) = aa_work(ind2,iip)
573 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_Lapla_ef
576 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef
586 ef_lapla_ef(l,kf) = -((2*pi*k/xl)**2+(2*pi*l/yl)**2)*ef(l,kf)
587 ef_lapla_ef(l,2*
kc(ip)-kf+1) &
588 = -((2*pi*k/xl)**2+(2*pi*l/yl)**2)*ef(l,2*
kc(ip)-kf+1)
603 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_LaplaInv_ef
606 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef
611 ef_laplainv_ef = 0.0d0
615 if ( k == 0 .AND. l == 0 )
then 616 ef_laplainv_ef(l,kf) = 0.0
618 ef_laplainv_ef(l,kf) = -ef(l,kf)/((2*pi*k/xl)**2+(2*pi*l/yl)**2)
619 ef_laplainv_ef(l,2*
kc(ip)-kf+1) &
620 = -ef(l,2*
kc(ip)-kf+1)/((2*pi*k/xl)**2+(2*pi*l/yl)**2)
636 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_Dx_ef
639 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef
648 ef_dx_ef(l,kf) = -(2*pi*k/xl)*ef(-l,2*
kc(ip)-kf+1)
649 ef_dx_ef(l,2*
kc(ip)-kf+1) = -(2*pi*(-k)/xl)*ef(-l,kf)
664 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_Dy_ef
667 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef
674 if ( ip == 0 .AND. kf == 1 )
then 676 ef_dy_ef(l,kf) = -(2*pi*l/yl)*ef(-l,kf)
677 ef_dy_ef(l,2*
kc(ip)-kf+1) = 0.0d0
681 ef_dy_ef(l,kf) = -(2*pi*l/yl)*ef(-l,2*
kc(ip)-kf+1)
682 ef_dy_ef(l,2*
kc(ip)-kf+1) = -(2*pi*l/yl)*ef(-l,kf)
700 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_Jacobian_ef_ef
703 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef_a
706 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef_b
722 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_JacobianZ_ef
725 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef_Zeta
728 real(8),
dimension(jc(ip),0:im-1) :: vx_U
729 real(8),
dimension(jc(ip),0:im-1) :: vx_V
730 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_UV
734 ef_uv =
ef_vx(vx_u*vx_v)
750 real(8),
dimension(jc(ip),0:im-1) :: vx
757 integer :: i, j, ierr
767 CALL mpi_allreduce(intyxtmp,intyx_vx,1,mpi_real8, &
768 mpi_sum,mpi_comm_world,ierr)
778 real(8),
dimension(jc(ip),0:im-1) :: vx
781 real(8),
dimension(jc(ip)) :: v_IntX_vx
789 v_intx_vx(:) = v_intx_vx(:) + vx(:,i) *
x_x_weight(i)
799 real(8),
dimension(jc(ip),0:im-1) :: vx
802 real(8),
dimension(0:im-1) :: x_IntY_vx
805 real(8),
dimension(0:im-1) :: x_IntYTmp
811 x_intytmp(:) = x_intytmp(:) + vx(j,:) *
v_y_weight(j)
814 CALL mpi_allreduce(x_intytmp,x_inty_vx,im,mpi_real8, &
815 mpi_sum,mpi_comm_world,ierr)
825 real(8),
dimension(0:im-1) :: x
837 real(8),
dimension(jc(ip)) :: v
845 CALL mpi_allreduce(intytmp,inty_v,1,mpi_real8, &
846 mpi_sum,mpi_comm_world,ierr)
858 real(8),
dimension(jc(ip),0:im-1) :: vx
875 real(8),
dimension(jc(ip),0:im-1) :: vx
878 real(8),
dimension(jc(ip)) :: v_AvrX_vx
892 real(8),
dimension(jc(ip),0:im-1) :: vx
895 real(8),
dimension(0:im-1) :: x_AvrY_vx
909 real(8),
dimension(0:im-1) :: x
923 real(8),
dimension(jc(ip)) :: v
941 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_EnergyFromStreamfunc_ef
944 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef_StrFunc
953 ef_energyfromstreamfunc_ef(l,kf) &
954 = 0.5 * ( (2*pi*k/xl)**2 + (2*pi*l/yl)**2 ) &
955 * (ef_strfunc(l,kf)**2 + ef_strfunc(-l,2*
kc(ip)-kf+1)**2)
956 ef_energyfromstreamfunc_ef(l,2*
kc(ip)-kf+1) &
957 = ef_energyfromstreamfunc_ef(l,kf)
973 real(8),
dimension(-lm:lm,2*kc(ip)) :: ef_EnstrophyFromStreamfunc_ef
976 real(8),
dimension(-lm:lm,2*kc(ip)),
intent(in) :: ef_StrFunc
985 ef_enstrophyfromstreamfunc_ef(l,kf) &
986 = 0.5 * ( (2*pi*k/xl)**2 + (2*pi*l/yl)**2 )**2 &
987 * (ef_strfunc(l,kf)**2 + ef_strfunc(-l,2*
kc(ip)-kf+1)**2)
988 ef_enstrophyfromstreamfunc_ef(l,2*
kc(ip)-kf+1) &
989 = ef_enstrophyfromstreamfunc_ef(l,kf)
998 real(8),
intent(IN) :: ef_data(-lm:lm,2*
kc(ip))
999 real(8),
intent(IN) :: x
1000 real(8),
intent(IN) :: y
1001 real(8) :: Interpolate_ef
1002 real(8) :: InterpolateTmp
1004 integer :: kf, k, l, ierr
1007 xx =(2*pi/xl)*(x - xmin)
1008 yy =(2*pi/yl)*(y - ymin)
1011 interpolatetmp = ef_data(0,1)
1013 interpolatetmp = 0.0d0
1020 interpolatetmp = interpolatetmp &
1021 + 2*( ef_data(0,kf)*cos(k*xx) - ef_data(0,
kf_k(-k))*sin(k*xx) )
1026 interpolatetmp = interpolatetmp &
1027 + 2*( ef_data(0,kf)*cos(k*xx) - ef_data(0,
kf_k(-k))*sin(k*xx) )
1034 interpolatetmp = interpolatetmp &
1035 + 2*( ef_data(l,
kf_k(0))*cos(l*yy) - ef_data(-l,
kf_k(0))*sin(l*yy) )
1044 interpolatetmp = interpolatetmp &
1045 + 2*( ef_data(l,kf)*( cos(k*xx)*cos(l*yy) &
1046 - sin(k*xx)*sin(l*yy) ) &
1047 -ef_data(-l,
kf_k(-k))*( sin(k*xx)*cos(l*yy) &
1048 + cos(k*xx)*sin(l*yy) ) )
1053 interpolatetmp = interpolatetmp &
1054 + 2*( ef_data(l,kf)*( cos(k*xx)*cos(l*yy) &
1055 - sin(k*xx)*sin(l*yy) ) &
1056 -ef_data(-l,
kf_k(-k))*( sin(k*xx)*cos(l*yy) &
1057 + cos(k*xx)*sin(l*yy) ) )
1067 interpolatetmp = interpolatetmp &
1068 + 2*( ef_data(-l,kf)*( cos(k*xx)*cos(l*yy) &
1069 + sin(k*xx)*sin(l*yy) ) &
1070 -ef_data(l,
kf_k(-k))*( sin(k*xx)*cos(l*yy) &
1071 - cos(k*xx)*sin(l*yy) ) )
1076 interpolatetmp = interpolatetmp &
1077 + 2*( ef_data(-l,kf)*( cos(k*xx)*cos(l*yy) &
1078 + sin(k*xx)*sin(l*yy) ) &
1079 -ef_data(l,
kf_k(-k))*( sin(k*xx)*cos(l*yy) &
1080 - cos(k*xx)*sin(l*yy) ) )
1085 CALL mpi_allreduce(interpolatetmp,interpolate_ef,1,mpi_real8, &
1086 mpi_sum,mpi_comm_world,ierr)
real(8) function, dimension(kc(ip), 2, 0:jm-1), public fay_vax(vax)
integer, dimension(:), allocatable, save, public kc
real(8) function, dimension(jc(ip)), public v_intx_vx(vx)
integer, dimension(:), allocatable, save, public je
real(8) function, public inty_v(v)
integer function, public kf_k(k)
real(8) function, dimension(jc(ip), 2, 0:im/2-1), public vax_fay(fay)
real(8) function, dimension(0:im-1), public x_inty_vx(vx)
real(8), dimension(:), allocatable, save, public v_y_weight
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_energyfromstreamfunc_ef(ef_StrFunc)
integer, dimension(:), allocatable, save, public ks
integer, dimension(:), allocatable, save, public js
real(8) function, public avry_v(v)
real(8), dimension(:), allocatable, save, public v_y
real(8) function, dimension(jc(ip)), public v_avrx_vx(vx)
real(8), dimension(:), allocatable, save, public x_x
real(8) function, public intx_x(x)
real(8) function, public interpolate_ef(ef_Data, x, y)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_vx(vx)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_enstrophyfromstreamfunc_ef(ef_StrFunc)
real(8) function, public intyx_vx(vx)
real(8) function, dimension(0:im-1), public x_avry_vx(vx)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_jacobian_ef_ef(ef_a, ef_b)
real(8) function, public avryx_vx(vx)
real(8) function, dimension(js(ip):je(ip), 0:im-1), public vx_ef(ef)
real(8), dimension(:,:), allocatable, save, public vx_x
real(8), dimension(:,:), allocatable, save, public vx_y
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_laplainv_ef(ef)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_lapla_ef(ef)
real(8) function, public avrx_x(x)
real(8), dimension(:), allocatable, save, public x_x_weight
subroutine, public ee_mpi_initial(i_in, j_in, k_in, l_in, xmin_in, xmax_in, ymin_in, ymax_in)
integer, dimension(:), allocatable, save, public jc
integer, dimension(:), allocatable, save, public ke
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_dy_ef(ef)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_dx_ef(ef)
real(8) function, dimension(-lm:lm, 2 *kc(ip)), public ef_jacobianz_ef(ef_zeta)