Commits

Anonymous committed 47833df

NS: Various bug fixes.

Comments (0)

Files changed (4)

examples/mpi-navier-stokes/src/feval.f90

     call c_f_pointer(yptr, y)
     call c_f_pointer(f2ptr, f2)
 
-    call f2eval(ctxptr, ctx%n, ctx%n, ctx%n, y%array, t, f2%array)
+    call f2eval(ctxptr, ctx%n, ctx%n, ctx%n, y%array, ctx%nu, f2%array)
   end subroutine eval_f2
 
   subroutine f2eval(cptr, n1, n2, n3, ustar, nu, f2)

examples/mpi-navier-stokes/src/hooks.f90

     type(c_ptr) :: tmp
 
     tmp = c_loc(q%array(1,1,1,1))
-    call c_f_pointer(tmp, rarray, [ product(2*q%shape) ])
+    call c_f_pointer(tmp, rarray, [ 2*product(q%shape) ])
 
     call ndarray_dump_numpy(trim(dname)//c_null_char, trim(fname)//c_null_char, '<c16'//c_null_char, &
-         4, q%shape, product(2*q%shape), rarray)
+         4, q%shape, 2*product(q%shape), rarray)
 
   end subroutine dump
 
-
-
   subroutine dump_hook(pf, level, state, levelctx)
     use pf_mod_ndarray
 

examples/mpi-navier-stokes/src/initial.f90

     real(pfdp),    intent(in   ) :: nu, t
 
     double precision :: x, y
-    integer          :: i, j, k, n
+    integer          :: i, j, k, kk, n
 
     type(c_ptr) :: ffft, wkp
 
-    complex(c_double), pointer :: u(:,:,:), v(:,:,:), w(:,:,:), wk(:,:,:)
+    complex(c_double_complex), pointer :: u(:,:,:), v(:,:,:), w(:,:,:), wk(:,:,:)
     double precision, parameter :: uc = 0.75d0, vc = 0.85d0
     double precision, parameter :: two_pi = 6.28318530718d0
     double precision, parameter :: eight_pi2 = 78.9568352087d0
 
     n = q0%shape(1)
-
     allocate(u(n,n,n), v(n,n,n), w(n,n,n))
 
-    k = 3
+    kk = 1
     w = 0
 
     do i = 1, n
-       x = dble(i) / n
+       x = dble(i-1) / n
        do j = 1, n
-          y = dble(j) / n
-
-          u(:,j,i) = uc + 0.25 * cos(two_pi*k*(x-uc*t)) * sin(two_pi*k*(y-vc*t)) * exp(-eight_pi2*nu*t)
-          v(:,j,i) = vc - 0.25 * sin(two_pi*k*(x-uc*t)) * cos(two_pi*k*(y-vc*t)) * exp(-eight_pi2*nu*t)
+          y = dble(j-1) / n
+          u(1,j,i) = uc + 0.25 * cos(two_pi*kk*(x-uc*t)) * sin(two_pi*kk*(y-vc*t)) * exp(-eight_pi2*nu*t)
+          v(1,j,i) = vc - 0.25 * sin(two_pi*kk*(x-uc*t)) * cos(two_pi*kk*(y-vc*t)) * exp(-eight_pi2*nu*t)
 
+          do k = 2, n
+             u(k,j,i) = u(1,j,i)
+             v(k,j,i) = v(1,j,i)
+          end do
        end do
     end do
 
     wkp  = fftw_alloc_complex(int(n**3, c_size_t))
-    ffft = fftw_plan_dft_3d(n, n, n, wk, wk, FFTW_FORWARD, FFTW_ESTIMATE)
-
     call c_f_pointer(wkp, wk, [ n, n, n ])
 
+    ffft = fftw_plan_dft_3d(n, n, n, wk, wk, FFTW_FORWARD, FFTW_ESTIMATE)
+
     wk = u
     call fftw_execute_dft(ffft, wk, wk)
     q0%array(:,:,:,1) = wk
 
 void ndarray_dump_numpy(char *dname, char *fname, char endian[5], int dim, int *shape, int nvars, double *array)
 {
-  unsigned short  i, len, pad;
+  unsigned short  len, pad;
+  int             i;
   FILE*           fp;
   char            errmsg[BUFLEN];
   char            header[256*256];