# Compiling Xfoil

**URL:** <https://fortran-lang.discourse.group/t/compiling-xfoil/10848>\
**Category:** LFortran\
**Created:** [April 10, 2026, 10:07am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848 "2026-04-10T10:07:37Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![oroppas](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/oroppas/32/6937_2.png) [@oroppas](https://fortran-lang.discourse.group/u/oroppas)\
**Post date:** [July 20, 2026, 9:49pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/21 "2026-07-20T21:49:45Z")

</div>

@certik Thanks. `--implicit-typing` worked. Adding this option to Makefile is straightforward and not too painful. Now I see

```auto
 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?

---

<div class="post-metadata">

**Author:** ![jwmwalrus](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jwmwalrus/32/4483_2.png) [@jwmwalrus](https://fortran-lang.discourse.group/u/jwmwalrus)\
**Post date:** [July 20, 2026, 10:31pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/22 "2026-07-20T22:31:15Z")

</div>

That’s [yet another extension](https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2026-0/iargc.html) (paired with `GETARG`, I suppose). The standard way is to use `COMMAND_ARGUMENT_COUNT` and `GET_COMMAND_ARGUMENT` in a loop.

Since both ifort/ifx and gfortran support the extension, maybe LFortran should as well if it’s not too difficult?

But in any case, @RonShepard is right in that the code should be updated to use as many standard-conforming features as possible.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 20, 2026, 11:15pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/23 "2026-07-20T23:15:48Z")

</div>

We don’t support iargc or getarg, but we have an open issue for that at [Support legacy intrinsics iargc and getarg · Issue #10764 · lfortran/lfortran · GitHub](https://github.com/lfortran/lfortran/issues/10764). We should implement it.

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [July 21, 2026, 4:25am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/24 "2026-07-21T04:25:32Z")

</div>

> [@oroppas](#):
>
> `--implicit-typing` worked. Adding this option to Makefile is straightforward and not too painful.

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.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 21, 2026, 4:30am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/25 "2026-07-21T04:30:37Z")

</div>

> [@RonShepard](#):
>
> I predict that this is going to be a common occurrence with LFortran.

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.

That being said, we of course support all legacy code and all widely-used extensions, so we just implemented `iargc` and `getarg` ([feat: add legacy F77 aliases iargc and getarg by Zaneham · Pull Request #11679 · lfortran/lfortran · GitHub](https://github.com/lfortran/lfortran/pull/11679)). CC @oroppas.

---

<div class="post-metadata">

**Author:** ![oroppas](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/oroppas/32/6937_2.png) [@oroppas](https://fortran-lang.discourse.group/u/oroppas)\
**Post date:** [July 21, 2026, 4:40am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/26 "2026-07-21T04:40:40Z")

</div>

@certik Thanks. I can see LFortran version: 0.64.0-24-g5721168e4 support `IARGC` and `GETARG`.

Now I start seeing very cryptic error

```auto
lfortran -c -O -fdefault-real-8 --fixed-form --implicit-typing --implicit-interface ../src/xfoil.f
semantic error: Passing a scalar argument to an array dummy argument is not allowed. Use --legacy-array-sections to enable sequence association
 --> ../src/xfoil.f:1:1
  |
1 | C ***********************************************************************
  | ^ scalar argument
  |
1 | C ***********************************************************************
  | ^ array dummy argument

```

Let me see how much I can reduce `xfoil.f` for minimal example…

---

<div class="post-metadata">

**Author:** ![wspector](https://avatars.discourse-cdn.com/v4/letter/w/47e85d/32.png) [@wspector](https://fortran-lang.discourse.group/u/wspector)\
**Post date:** [July 21, 2026, 7:34am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/27 "2026-07-21T07:34:17Z")

</div>

For that you’ll likely want the `--legacy-array-sections` option.

As with your other problems, it is really much better to fix the code than to depend on non-Standard compatibility options though.

---

<div class="post-metadata">

**Author:** ![oroppas](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/oroppas/32/6937_2.png) [@oroppas](https://fortran-lang.discourse.group/u/oroppas)\
**Post date:** [July 21, 2026, 10:57am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/28 "2026-07-21T10:57:11Z")

</div>

Ideally, Xfoil gets fixed. That said both gfortran and flang are able to compile Xfoil as is.

> [@oroppas](#):
>
> `--legacy-array-sections`

Thanks. Here’s what I’ve got

```auto
lfortran -c -O -fdefault-real-8 --fixed-form --implicit-typing --implicit-interface --legacy-array-sections ../src/xfoil.f
make: *** [Makefile:168: xfoil.o] Segmentation fault

```

The minimal reproducible of `xfoil.f` became

```auto
      SUBROUTINE SAVE(IFTYP,FNAME1)

      CHARACTER*80 ISPARS
      COMMON/CC01/ ISPARS

      DO K=80, 1, -1
        IF(INDEX(ISPARS(K:K),' ') .NE. 1) EXIT
      ENDDO

      RETURN
      END

```

`lfortran -c -O -fdefault-real-8 --fixed-form --implicit-typing --implicit-interface save.f`

resulted in segmentation fault.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 21, 2026, 2:51pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/29 "2026-07-21T14:51:38Z")

</div>

At this point it will be faster if I just fix everything in one sweep. Which version are you compiling, the `xfoil6.996.tgz` one?

---

<div class="post-metadata">

**Author:** ![oroppas](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/oroppas/32/6937_2.png) [@oroppas](https://fortran-lang.discourse.group/u/oroppas)\
**Post date:** [July 21, 2026, 3:36pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/30 "2026-07-21T15:36:18Z")

</div>

Correct. [https://web.mit.edu/drela/Public/web/xfoil/xfoil6.996.tgz](https://web.mit.edu/drela/Public/web/xfoil/xfoil6.996.tgz)

Go to `Xfoil/bin` then edit `Makefile` to set `FC` to `lfortran`at line 118.

Add `--fixed-form --implicit-typing --implicit-interface` to `FFLAGS`.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 21, 2026, 3:44pm UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/31 "2026-07-21T15:44:18Z")

</div>

I created a repo for xfoil here: [GitHub - certik/xfoil · GitHub](https://github.com/certik/xfoil) 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](https://github.com/certik/xfoil/blob/aad3fc74ee93298a3ac8d64dc0036b310ac6671d/bin/Makefile_lfortran#L125:) `--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.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [July 22, 2026, 3:49am UTC](https://fortran-lang.discourse.group/t/compiling-xfoil/10848/32 "2026-07-22T03:49:10Z")

</div>

Ok, I have it: [Build xfoil by certik · Pull Request #12306 · lfortran/lfortran · GitHub](https://github.com/lfortran/lfortran/pull/12306)

With LFortran:

```console
==> 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:

```console
==> 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.

[Previous page](https://fortran-lang.discourse.group/t/compiling-xfoil/10848.md?page=1)
