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

Fortran merging 2 arrays

  1. Apr 10, 2015 #1
    I have 2 set of data (from different files) and I allocate each set of data to array in my main program. But now I want to merge those 2 array and sort them in ascending orders in my sub program. What should I do? I know how to sort array in ascending orders, but i don't know how to merge those 2 array together... Any suggestion or help?
     
  2. jcsd
  3. Apr 10, 2015 #2

    phinds

    User Avatar
    Gold Member
    2016 Award

    pseudo code:
    create new array big enough to hold all the data
    create a loop that puts all of the first array's elements into the new array
    create a loop that puts all of the second array's elements into the new array (starting at the index left at the end of the first loop)
     
  4. Apr 11, 2015 #3
    thanks you for answering my question. It helps a lot. However, Another subroutine is required to find the intersection of them and combined it into 1 array. Any suggestion or help please
     
    Last edited: Apr 11, 2015
  5. Apr 11, 2015 #4

    Mark44

    Staff: Mentor

    You need to show us what you have tried. We are not going to write this code for you.

    Your question should be posted in the Engineering & Comp. Sci. subsection under Homework & Coursework. I am closing this thread.
     
    Last edited: Apr 11, 2015
  6. Apr 11, 2015 #5
    First, I tried to use do loop to compare each value in both array and the write out each intersect value. But I do not know how to put them together into an array since the size of this intersect array varies if the data change.
     
  7. Apr 11, 2015 #6

    Mark44

    Staff: Mentor

    Again, you need to show us (in code) what you have tried, not explain to us what you have tried. As already noted, please start a new thread in the Homework & Coursework section.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Fortran merging 2 arrays
  1. Fortran 3D array (Replies: 3)

  2. Fortran array help (Replies: 2)

Loading...