- #1
Hepth
Gold Member
- 464
- 40
I have some F77 code and I am wondering if it is possible to inject external code into a separate file and call it without it being a subroutine, and placed into the code. An example would be :
a = 1 + 1
b = a + 1
c = b + a
a = c + b
d = 4 + a
and I want to take lines 3 and 4 and put them into somewhere else, say another file so I have
a = 1 + 1
b = a + 1
(externalfile.f)
d = 4 + a
and it has the same result.
So basically just HIDING code into another file, such that it will be evaluated inline without using a procedure or function call to it. It just uses the local variables that are in use.
The reason I do this is that I have a LOT of variables for a few results, and I am using the FortranForm from Mathematica. But it would be MUCH easier to automate this for changes if I can just export the code to a file and never really look at it, and then my main file wouldn't be ugly.
I really really want to avoid passing all these variables to another function.
a = 1 + 1
b = a + 1
c = b + a
a = c + b
d = 4 + a
and I want to take lines 3 and 4 and put them into somewhere else, say another file so I have
a = 1 + 1
b = a + 1
(externalfile.f)
d = 4 + a
and it has the same result.
So basically just HIDING code into another file, such that it will be evaluated inline without using a procedure or function call to it. It just uses the local variables that are in use.
The reason I do this is that I have a LOT of variables for a few results, and I am using the FortranForm from Mathematica. But it would be MUCH easier to automate this for changes if I can just export the code to a file and never really look at it, and then my main file wouldn't be ugly.
I really really want to avoid passing all these variables to another function.