# Can Fortran be forced to abide by the order of arguments in an and conditional

I am looping through indices and I am checking if I am not in the first loop interation and another condition. I don’t want the second condition to be evaluated if the first is .False.. do i = 1, n if ( i /= 1 .and. var(i) > var(i-1) ) then do something end if… Read More Can Fortran be forced to abide by the order of arguments in an and conditional

# Can you reuse the function result in Fortran?

I have read that depending on the value of a function-result variable is nonstandard Fortran. integer function my_sum(x, n) integer, dimension(n), intent(in) :: x integer , intent(in) :: n integer :: i my_sum = 0 do i = 1, n my_sum = my_sum + x(i) ! Error! Cannot re-use my_sum end do end function Instead… Read More Can you reuse the function result in Fortran?

# Difference between cupy.asnumpy() and get()

Given a CuPy array a, there are two ways to get a numpy array from it: a.get() and cupy.asnumpy(a). Is there any practical difference between them? import cupy as cp a = cp.random.randint(10, size=(4,5,6,7)) b = a.get() c = cp.asnumpy(a) assert type(b) == type(c) and (b == c).all() >Solution : cp.asnumpy is a wrapper calling… Read More Difference between cupy.asnumpy() and get()

# Find Fortran file used in R package

While trying to figure out how the Leaps package works, I came across this command: qrleaps <- .Fortran("makeqr", np = as.integer(np), nn = as.integer(nn), wt = as.double(wt), tx = t(xx), y = as.double(y), d = numeric(np), rbar = numeric(nrbar), thetab = numeric(np), sserr = numeric(1), ier = as.integer(0), PACKAGE = "leaps") I understand that it… Read More Find Fortran file used in R package

# initialize fortran character array with variable length strings

I have a code where I set up a character array with set of default "options", which I may or may not wish to overwrite during the code execution. If I initialize the array with strings of all the same length (shorter or equal to the maximum possible length of 5), then the code works:… Read More initialize fortran character array with variable length strings