1 #include "flang/Runtime/io-api.h"
2 #include "flang/Runtime/main.h"
3 #include "flang/Runtime/stop.h"
7 using namespace Fortran::runtime::io
;
10 auto io
{IONAME(BeginExternalListOutput
)()};
11 const char str
[]{"Hello, world!"};
12 IONAME(OutputAscii
)(io
, str
, std::strlen(str
));
13 IONAME(OutputInteger64
)(io
, 678);
14 IONAME(OutputReal64
)(io
, 0.0);
15 IONAME(OutputReal64
)(io
, 2.0 / 3.0);
16 IONAME(OutputReal64
)(io
, 1.0e99
);
17 IONAME(OutputReal64
)(io
, std::numeric_limits
<double>::infinity());
18 IONAME(OutputReal64
)(io
, -std::numeric_limits
<double>::infinity());
19 IONAME(OutputReal64
)(io
, std::numeric_limits
<double>::quiet_NaN());
20 IONAME(OutputComplex64
)(io
, 123.0, -234.0);
21 IONAME(OutputLogical
)(io
, false);
22 IONAME(OutputLogical
)(io
, true);
23 IONAME(EndIoStatement
)(io
);
27 auto io
{IONAME(BeginExternalListOutput
)()};
28 const char prompt
[]{"Enter an integer value:"};
29 IONAME(OutputAscii
)(io
, prompt
, std::strlen(prompt
));
30 IONAME(EndIoStatement
)(io
);
32 io
= IONAME(BeginExternalListInput
)();
34 IONAME(InputInteger
)(io
, n
);
35 IONAME(EndIoStatement
)(io
);
37 io
= IONAME(BeginExternalListOutput
)();
38 const char str
[]{"Result:"};
39 IONAME(OutputAscii
)(io
, str
, std::strlen(str
));
40 IONAME(OutputInteger64
)(io
, n
);
41 IONAME(EndIoStatement
)(io
);
44 int main(int argc
, const char *argv
[], const char *envp
[]) {
45 RTNAME(ProgramStart
)(argc
, argv
, envp
, nullptr);
48 RTNAME(PauseStatement
)();
49 RTNAME(ProgramEndStatement
)();