# HG changeset patch # User "uncorrelated zombie" # Date 1721673081 -32400 # Node ID 0ca8347e4c4739795304f281ad4f99578289d151 # Parent 8026ceb4de7a35e45890a373413cc41bebadf2ef add rk_Lorenz.R and rksub.f90 diff -r 8026ceb4de7a -r 0ca8347e4c47 Makefile --- a/Makefile Tue Jul 23 01:48:31 2024 +0900 +++ b/Makefile Tue Jul 23 03:31:21 2024 +0900 @@ -13,7 +13,7 @@ gfortran -c rkmain.f90 rkmod.o: rkmod.f90 rungekutta.o - gfortran -c rkmod.f90 + gfortran -c rkmod.f90 -fPIC rungekutta.o: rungekutta.f90 gfortran -c rungekutta.f90 diff -r 8026ceb4de7a -r 0ca8347e4c47 rk_Lorenz.R --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rk_Lorenz.R Tue Jul 23 03:31:21 2024 +0900 @@ -0,0 +1,29 @@ +dll <- paste("rksub", .Platform$dynlib.ext, sep="") +dyn.load(dll) + +max_i <- as.integer(5000) + +r <- .Fortran("rk_sakamoti", + as.double(c(0.5, 0.5, 0.5)), + max_i, + matrix(0, max_i, 4)) +dyn.unload(dll) + +m <- r[[3]] +colnames(m) <- c("t", "x", "y", "z") + +png(filename = "Lorenz system.png", + width = 800, height = 600, bg="white", type="cairo") +library(scatterplot3d) +scatterplot3d(m[,2], m[,3], m[,4], + highlight.3d = FALSE, + col.axis = "blue", col.grid = "lightblue", + type = "l", color = "purple", lwd = 2, + main = "Lorenz system", + xlab = colnames(m)[2], + ylab = colnames(m)[3], + zlab = colnames(m)[4], + cex.main = 3, + cex.lab = 2) +dev.off() + diff -r 8026ceb4de7a -r 0ca8347e4c47 rkmain.f90 --- a/rkmain.f90 Tue Jul 23 01:48:31 2024 +0900 +++ b/rkmain.f90 Tue Jul 23 03:31:21 2024 +0900 @@ -3,10 +3,13 @@ implicit none real(kind=dpkind),dimension(3) :: x = [0.5, 0.5, 0.5] integer :: max_i = 5000 - real(kind=dpkind), allocatable, dimension(:, :) :: r +! real(kind=dpkind), allocatable, dimension(:, :) :: r + real(kind=dpkind), dimension(5000, 4) :: r - allocate(r(max_i, 4)) +! allocate(r(max_i, 4)) call calc(x, max_i, r) - print *, r + open(17,file='rkmain.dat', form='unformatted', access = "stream", status='replace') + write(17) r + close(17) end program diff -r 8026ceb4de7a -r 0ca8347e4c47 rksub.f90 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rksub.f90 Tue Jul 23 03:31:21 2024 +0900 @@ -0,0 +1,9 @@ +subroutine rk_sakamoti(x, max_i, r) + use rkmod + implicit none + real(kind=dpkind),dimension(3),intent(in) :: x + integer, intent(in) :: max_i + real(kind=dpkind), dimension(max_i, 4),intent(out) :: r + call calc(x, max_i, r) +end subroutine +