Subscripts and Fractions in Fortran 95

  • Context: Fortran 
  • Thread starter Thread starter kathrynag
  • Start date Start date
  • Tags Tags
    Fortran Fractions
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
kathrynag
Messages
595
Reaction score
0
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?
 
Physics news on Phys.org
Do I use 10 log(P2/P1)
 
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:
REAL*8 P(2), B
P(1)=20
P(2)=40
B=LOG10(P(1)/P(2))
will be perfectly OK.