It's always a bit difficult to help without knowing the details; when writing a little processor program like this one, often times one also designs the format of the expected data to make things simpler.
For example, I think that having x,y pair sets, one after the other, in one single file is...
Try the following:
Those arrays that were declared with full length, x(3), in the main program but with just on, x(1), in the subroutines, declared them with full length in every subroutine, too.
Well, it was mentioned that each set of sources is an actual program, each with its own "program" unit.
In any case, there is no need for a formal interface, if you don't want one.
So, it all depends what you want to achieve...if the Fortran 90 needs nothing from the "main" of the Fortran 77...
And, as I mentioned before, for as long as you need to tell things apart you are going to need a "select" or an "if-then" somewhere, there is no way around it...even the example with pointers needs a "select" to assign the pointer, so, what's the point of complicating the matter with potential...
module my_module
implicit none
integer :: a
contains
subroutine alpha()
a = 1
end subroutine alpha
subroutine beta()
a = 2
end subroutine beta
subroutine gamma()
a = 3
end subroutine gamma
end module my_module
program main
use...
And, no, with modules you do not need to pass a long list of arguments, just encapsulate the data and the functions that manipulate it in the same module.
mikrom beat me to the punch...I was about to say just about the same; basically, you cannot get away from the 'if-then' in some shape or form if you want to tell things apart. So, instead of putting the "if-then" in the main program, you place it inside the single function being call.
Yes, they are both officially accepted; though, it is recommended to go the "array(:,:,...)" route for clarity, for you and others reading your code.
To quote a couple of items from "The Zen of Python":
- Explicit is better than implicit.
- Readability counts.
I suggest you do a few things:
- break down the equation into several lines to make it easier to read and make it look as much as possible to the textbook
- leave the "sign(0.8,-0.2)" operation out of the double loop, its value does not change with the indices...it will always be -0.8
-...
In line 142 if the attached spline.f90 file you have "xn(i)=int", except that "int" has never been initialized nor assigned any value, not before entering the loop, not in the loop, not anywhere.
By the way, for your variable names, try to use something other that Fortran keywords for...
program rbx
integer i, j
real*8 z(5,10)
z=0.0
outer: do i = 1, 5, 1
do j = 1, 10, 1
! complicated mathematics to calculate Z(i,j)
! test Z(i,j)...but do it correctly; for example, can Z(i,j) be negative?
if ( z(i,j) > 1.0e-06 ) then...
Lost in translation", I am sure judging by "fortan 90 and his logical background"; not uncommon, after all, most people in the world are not native English speakers and this site, I presume, can be reached from anywhere.
just a comment regarding the loop in the function above;
this:
do i=1,n
V2%q(i) = s + V1%q(i)
end do
can be more efficiently written like this:
V2%q(1:n) = s + V1%q(1:n)
I think what you need to do is calculate the "counter" as a function of the loop variables so that it can be calculated any time independent of the order in which the looks are carried out (in parallel). Something like:
cont = ii + ncx*(jj-1) + ncx*ncy*(kk-1)
hhhmmm, operator overloading is not something I do often; but, first...I am curious, why are you implementing something Fortran already does? I guess there is more to 'vector' type, but you don't show it. Is it more than just an array? And size and resize does not count! That can be done...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.