isce2 icon indicating copy to clipboard operation
isce2 copied to clipboard

Fix denseoffsetsRead for modern gfortran

Open rtburns-jpl opened this issue 3 years ago • 2 comments

Allows compilation without need for -fallow-argument-mismatch

My intent here is to declare getLineBand's arr argument as type(*), which as far as I can tell is the fortran equivalent of a void* and allows passing any data. I'm a fortran newbie so I would appreciate a look from someone more experienced.

rtburns-jpl avatar Feb 15 '22 01:02 rtburns-jpl

In this case, I don't think that long Fortran experience is any help. I learned Fortran 77 and then some of the Fortran 90 and Fortran 95 additions. I found this: Fortran 2018 added TYPE(*) or assumed type as part of the enhanced C interoperability features (https://stevelionel.com/drfortran/2020/06/30/doctor-fortran-in-not-my-type/) so it is very recent. It sounds like it is what we need here to accept a variable passed back from C code, but I have never seen it before.

The problem with adding something from Fortran 2018 is that it won't be backwards compatible with earlier compilers. It is annoying when new compiler versions don't accept syntax that worked before and force you to use new syntax that is not backwards compatible.

EJFielding avatar Feb 15 '22 18:02 EJFielding

Thanks for pointing that out, and I completely agree that the lack of backward compatibility is annoying. I'm going to think about this some more and try to come up with something that is more broadly compatible.

rtburns-jpl avatar Feb 15 '22 22:02 rtburns-jpl

I was looking at some other geospatial packages and I think I found a solution that doesn't require recent gfortran versions.

https://github.com/ecmwf/eccodes/commit/2e0d31080dda0bdd06ae2e1d1d2037498c85e020

Instead of trying to teach fortran that a function is polymorphic, we can just make a bunch of aliases for any different type of argument we might want to pass, and have them all call the same underlying C function.

rtburns-jpl avatar Dec 28 '23 19:12 rtburns-jpl

Thanks for your valuable feedback :)

rtburns-jpl avatar Dec 28 '23 19:12 rtburns-jpl