Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Subscripts and Fractions in Fortran 95

  1. Feb 8, 2009 #1
    i'm trying to write the equation dB=log_10(P_2/P_1)
    I just need help writing this equation into Fortran.
    I know for exponents I use **, but what about subscripts?
    Also, my inital thought for a fraction is /. Is this correct?
     
  2. jcsd
  3. Feb 10, 2009 #2
    Do I use 10 log(P2/P1)
     
  4. Feb 11, 2009 #3
    In fortran, subscripts mean the index of an array.
    For an array such as
    REAL*8 P(10)
    P(1) is the equivalent as what we write as P1, and so on.
    So what to write depends on how your variables have been defined.
    If you write
    Code (Text):
    REAL*8 P(2), B
    P(1)=20
    P(2)=40
    B=LOG10(P(1)/P(2))
    will be perfectly OK.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Subscripts and Fractions in Fortran 95
  1. Fortran 95 (Replies: 12)

Loading...