Sunday, 15 March 2015

Multi dimensional array with varying size -


I want to create a 2D array "data" with the following dimensions: Data (T, N) T continuous and NI Do not know anything about it. It is possible to do something like this in Fortune

  do i = 1, t check some flag if (all the flags are ok) c = c + 1 data (I, c) = end if some value is ending   

Actually I have no information about the second dimension. Based on some flags, if those flags are fine, then I want to add more elements to the array.

How can I do this?

There are many possible solutions that you can create an allocated array to data and Can calculate the maximum value for N . As long as you do not do more N , you should continue to add data items. If a new item is more than the array size, you create a temporary array, temporal array is data < / Code> can copy, decoction data , and reallocate it with a larger dimension.

Another design option would be to use a linked list. It is more flexible that the length is uncertain. You harm "random access", the list is chained rather than indexed. You create a user-defined type in which different data, e.g., scalers, arrays, whatever, and even an indicator when you add a list item, the pointer points on the next item It is possible in Fortran & gt; = 90 because pointers are supported.

I suggest searching the web or reading a book about these data structures.

No comments:

Post a Comment