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

F90: adding vector to 2D array

  1. Feb 24, 2010 #1
    hi. i have a quick question regarding fortran 90. i often need to add a vector to a 2d dimensional array, and i find it a bit to 'bulky' to always use do loops.

    let's say i have this:
    Code (Text):

    do i=1, 20
       a(:, i)=a(:, i)+b(:)
    end do
    is there a simple(r) way to tell fortran that i want to add the values to the 'first' value of the array? so i could use something as simple as
    Code (Text):

    a(:, :)=a(:, :)+b(:)
    thx in advance for the answers and suggestions.
  2. jcsd
  3. Feb 25, 2010 #2


    User Avatar
    Science Advisor

    You could either write a quick FUNCTION or perhaps define a custom operator.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook