Imagine I have a model that generates cells and each year it generates a different amound of cells over the year. Each end of the year I want to catch all existing cells and properties in a 3-d array with information on the year, the postition of the cell, and some other properties, so let's say 3 columns
I have n numbers of years, something which I do know at the beginning, let's say I have 10 years
I do not know how many cells there are until the end of the year, so this is variable.
,,'year 1']
[,1][,2][,3]
[1]
[2]
[..]
[?]
[,,'year 2']
[,1][,2][,3]
[1]
[2]
[..]
I am wondering how I can best dynamically create and apend to the first dimension of this array?!
I have all the end of the year information I need at the, currently located in vectors (eg.): [,1] - is easy, that would contain the year , e.g. 2009
Tor the cell properties, I fill this in this by looping through the different vectors that contain those properties and put them into the
[,1] [,2][,3]
[1] 2009
with
[,2] - the position of the cell , taken from a pos_cell array at i =1
[,3] - a property of the cell, taken from the prop_cell array at i =1
so we have:
[,1] [,2] [,3]
[1] 2009 1 0.4
Now,
with
[,2] - the position of the cell , taken from a pos_cell array at i =2
[,3] - a property of the cell, taken from the prop_cell array at i =2
[,1] [,2] [,3]
[1] 2009 1 0.40
[2] 2009 2 0.44
I don't think this all is the most efficient way of doing it. Currently I just need something that works a bit better than what I am currently working with, which is an array that has 3 pre-defined dimensions, because I am constantly hitting new max values for the first dimension.
I was thinking of something along the lines like this:
How to add new element to dynamical array in Fortran90
But I am not sure it is actually allowed to have different dimensions, and is this a good way forward? But firstly, how would I start going about it?
I have looked at
https://libatoms.github.io/QUIP/table.html but this is too new and only for 2D
I am using Fortran 90.
Oh and please don't tell me how it could be done better in a newer fortran. In other forum's entries on this subject people had the tendency to not answer the question, but simply say how it could be done with new fortran versions. Looking forward to your suggestions.