Closed merijn closed 4 years ago
looks fine to me ( are you also adding the interface functions in omuse?) - some explanation of what you mean with center and edge would be nice to add in a comment (if its not already there)..like some ascii art drawing of the grid..
@ipelupessy Yeah, the plan I discussed on IRC is to basically replace the Fortran initialisation code with this code and then add it to the Ocean (and by extension OMUSE) API for Maria, but other work got in the way. I'm continuing with this tomorrow. The ASCII diagram might be a good idea, I think TRIOS even already has one in the comments somewhere.
I'm on board with this. Except that if we throw out all the fortran (incrementally), we need a place where we can still admire legacy code. So I'll make a PR with the old THCM
This reimplements the Fortran code here in TRIOS_Domain, which lets us compute the "real" position (both at the edges and center) from grid indices for https://github.com/nlesc-smcm/i-emic/issues/66.
That would let us obsolete
grid.F90
and do the initialisation for all the Fortran grid arrays from C++, as a starting point for moving the initialisation out of Fortran.Right now the code follows the Fortran exactly, but this leads to some unidiomatic C++ as some of the Fortran arrays start at 0 and some at 1 (the center index for cell 1 in the fortran arrays points to the center of logical cell 0, see the
- 0.5
in the index calculation). We could normalise that to index 0 pointing to the center of logical cell 0 by simply using+ 0.5
and keep the Fortran code the same by just translating from that 0-indexed approach to the current Fortran layout when the arrays get initialised from C++.Either way is fine with me, but I don't know what your opinions are.
(Also, obviously still needs tests that check that the C++ version matches the Fortran initialisation, but I'll do that after we decide whether or not to change the C++ code...)