title: linking multiple files with fortran
body: <p>I'm new to Fortran but I'm trying to find a way that I can retrieve information from programs I've written without including them as subprograms within my new file. As of right now I have 4 subroutines within my new file and I would like to instead just be able to input the radius into all 4 and receive their respective outputs.</p>
  
  <p>this is the basic format for my code--- basically I want to show that I need 4 separate programs in order to get all the variables needed for the current programs expression.
  So far I've tried to use both the include and call expressions but they weren't able to retrieve the information I needed to bring back into my file and they came up with just "not applicable" answers.</p>
  
  <pre><code>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&gt;0.and.radius&lt;=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 meters cubed"
  
      else
  
          print*, "this radius is not an option for the sun"
  
      end if
  
  end subroutine testdensity
  </code></pre>