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




Loading...
Similar Threads for Subscripts Fractions Fortran Date
If statement for Monte Carlo integration Sunday at 7:46 AM
C/++/# How to use C++ in studying calculus Apr 3, 2018
Decimal fraction to binary Sep 22, 2013
Exact Arithmetic using Continued Fractions Jul 12, 2011
Fortran: Pointer to array section with vector subscripts Mar 10, 2011