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
    will be perfectly OK.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook