@certik Thanks. --implicit-typing worked. Adding this option to Makefile is straightforward and not too painful. Now I see
lfortran -c -O -fdefault-real-8 --fixed-form --implicit-typing ../src/xfoil.f
semantic error: Function 'iargc' not found (not user defined nor intrinsic)
--> ../src/xfoil.f:54:14
|
54 | NARG = IARGC()
| ^^^^^^^
Does LFortran provide the support for IARGC through the compiler option flag?
I predict that this is going to be a common occurrence with LFortran.
Some compilers require special options in order to enable nonstandard features, some compilers require special options in order to compile standard-conforming code. LFortran has chosen the latter approach for the implicit typing feature of standard fortran.
Yes, that’s the downside of our approach — for legacy code. For modern code the big upside is that LFortran gives a nice error about not declaring a variable. We are targeting modern code as a priority.
I created a repo for xfoil here: GitHub - certik/xfoil · GitHub and added build_macos.sh to build using GFortran and run tests. Had to make a few modifications. Then I added build_lfortran.sh to do the same with LFortran and I am now fixing the bugs.
Here are the LFortran options that I am using: xfoil/bin/Makefile_lfortran at aad3fc74ee93298a3ac8d64dc0036b310ac6671d · certik/xfoil · GitHub--cpp --separate-compilation --fixed-form-infer --implicit-interface --implicit-typing --legacy-array-sections --use-loop-variable-after-loop --no-style-suggestions --no-warnings. I think possibly just using --legacy might do it, but for now I use explicit options.
==> Running test case: NACA 0012 at alpha = 2 deg (inviscid) ...
Cp distribution written OK ( 241 lines). First rows:
# x Cp
1.00000 0.42134
0.99632 0.28738
0.99156 0.24271
With GFortran:
==> Running test case: NACA 0012 at alpha = 2 deg (inviscid) ...
Cp distribution written OK ( 241 lines). First rows:
# x Cp
1.00000 0.42121
0.99632 0.28703
0.99156 0.24324
There are some slight numerical differences, larger than numerical error, so probably we should track those down as well, but at least it compiles and runs pretty much correctly. In fact GFortran was called with single → double precision promotion, while LFortran was called with just a single precision, so that might completely explain the differences.
We need to first get that PR in, we usually split it into smaller ones, clean them up and get them in, so it might take a few days. But there is no blocker, just small bugs that we now have fixes for.