我是Fortran的新手,但我正试图找到一种方法,我可以从我编写的程序中检索信息,而不将它们包含在我的新文件中作为子程序.到目前为止,我的新文件中有4个子程序,我希望能够将半径输入到所有4个并接收各自的输出.
这是我的代码的基本格式 - 基本上我想表明我需要4个独立的程序,以获得当前程序表达式所需的所有变量.到目前为止,我已经尝试使用include和call表达式,但是他们无法检索我需要的信息带回到我的文件中,他们提出了"不适用"的答案.
program practicedynamo
implicit none
real:: A,B,C, Radius
real::Bsquared,Vsquared
read*,radius
call programA(radius,A)
call programB(radius,B)
call programC(radius,C)
Vsquared=(1.0/3.0)*B
Bsquared= 4*pi*density*Vsquared
gradient=radius*C
Rvector=Bsquared*Vsquared*gradient
ThetaVector=Rvector*sin(A)
end program practicedynamo
!and then my four subroutines would be placed afterwards
!here is an example of one of my subroutines within my actual code (the version above has been simplified and I've changed the variables)
subroutine testdensity(radius,density)
implicit none
real::radius,x,sunradius,density
if (radius>0.and.radius<=695500000) then
sunradius=695500000
x=radius/sunradius
density=((519*x**4.0)-(1630*x**3.0)+(1844*x*x)-(889*x)+155)
print*," "
density=density*1000
print*,"the density is",density, "kg per …
Run Code Online (Sandbox Code Playgroud)