I am new to this forum but not very new to Fortran and did use Fortran a lot during my PhD and post-doc working on legacy codes in hydraulics, hydrology and CFD. However, these days I am with a consulting company working with flood models where things are primarily done in Python and C# and I often get laughed at . But I still prefer to do things with Fortran as that is the language I am most comfortable in.
I am writing here as I am stuck with a problem, which I want to solve in Fortran, and could use some help. I have a DEM (digital elevation model) and flow direction file for a catchment which is 220 km2. The resolution of the file is 5 m and every valid pixel flows into one of the eight neighbouring pixel and finally finds its way out at the catchment at the southern end. Time to one of the eight neighbouring pixel changes every hour but is readily computable, I want to compute the total time to the outlet at the southern end for all the pixels.
As of now in my code, I start with any valid pixel and keep on traversing down the flow direction map and adding the individual time to next pixel for each cell until I reach the outlet. As the time-to-next pixel changes every hour this is the most time consuming part (3-5 mts) of the code which makes things worse if I want to conduct simulation for events spanning couple of days. I can certainly not store the complete drainage path for all the cells because I run out of memory when I am working with over 8 to 10 million grid cells.
If this problem is very trivial in someone’s head please do put in a line or two and I would be extremely grateful.