Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #88430

Re: best way to convert a Fortran implied do loop to C++

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c++
Subject Re: best way to convert a Fortran implied do loop to C++
Date 2023-01-07 22:46 +0000
Organization A noiseless patient Spider
Message-ID <87v8ligdyx.fsf@bsb.me.uk> (permalink)
References <tpau9h$3e4fi$1@dont-email.me> <87k01yijwp.fsf@bsb.me.uk> <6NguL.537322$GNG9.514912@fx18.iad> <87eds6hv8c.fsf@bsb.me.uk> <871qo6hsrf.fsf@bsb.me.uk>

Show all headers | View raw


Ben Bacarisse <ben.usenet@bsb.me.uk> writes:

> To add a bit more detail, I image that formats will be turned into
> run-time objects containing a 'compiled' version of the format
> mini-language.  A statement like
>
>       WRITE(*, 2) A, X
>     2 FORMAT(I2, F5.2)

It might have made more sense to use a format that could be used by an
external loop like

      DO 10 I = 1, 6
        WRITE(*, 2) A(I), X(I)
   10 END DO

but which while still being sensible would give a different result.  For
example, I might have used

    2 FORMAT(3(I2, F5.2))

The rest remains the same.

> would turn into
>
>   format_2.start();
>   format_2.write(UNIT_STAR, A);
>   format_2.write(UNIT_STAR, X);
>   format_2.end();
>
> where the write method is a templated method that advances an internal
> pointer in the format "list" (it may, in fact, be a cyclic graph).  And
>
>       WRITE(*,2) (N(I), X(I), I = 1, 6)
>
> would turn into
>
>   format_2.start();
>   for (int i = 1; i <= 6; i++) {
>       format_2.write(STAR, N[i]);
>       format_2.write(STAR, X[i]);
>   }
>   format_2.end();
>
> The member function 'end' should be idempotent, because the write
> function will also call it when the last format specification is used.
>
> I'm sure this is turn out to be way more complicated that it looks to me
> right now, but this feel like the gist of what's needed.

-- 
Ben.

Back to comp.lang.c++ | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

best way to convert a Fortran implied do loop to C++ Lynn McGuire <lynnmcguire5@gmail.com> - 2023-01-06 23:00 -0600
  Re: best way to convert a Fortran implied do loop to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-01-07 12:55 +0000
    Re: best way to convert a Fortran implied do loop to C++ Richard Damon <Richard@Damon-Family.org> - 2023-01-07 11:07 -0500
      Re: best way to convert a Fortran implied do loop to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-01-07 21:48 +0000
        Re: best way to convert a Fortran implied do loop to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-01-07 22:41 +0000
          Re: best way to convert a Fortran implied do loop to C++ Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-01-07 22:46 +0000
          Re: best way to convert a Fortran implied do loop to C++ Lynn McGuire <lynnmcguire5@gmail.com> - 2023-01-07 21:29 -0600
  Re: best way to convert a Fortran implied do loop to C++ Lynn McGuire <lynnmcguire5@gmail.com> - 2023-01-11 14:16 -0600

csiph-web