36
36
extern " C" {
37
37
void *_FortranAioBeginExternalListOutput (uint32_t a1, const char *a2,
38
38
uint32_t a3);
39
+ void *_FortranAioBeginExternalFormattedOutput (const char *ptr1, uint64_t x1,
40
+ void *ptr2, uint32_t x2,
41
+ const char *ptr3, uint32_t x3);
39
42
bool _FortranAioOutputAscii (void *a1, char *a2, uint64_t a3);
40
43
bool _FortranAioOutputInteger32 (void *a1, uint32_t a2);
41
44
uint32_t _FortranAioEndIoStatement (void *a1);
@@ -63,6 +66,21 @@ extern void *V_FortranAioBeginExternalListOutput(void *fnptr, ...) {
63
66
_list_started_cookie = cookie;
64
67
return cookie;
65
68
}
69
+ extern void *V_FortranAioBeginExternalFormattedOutput (void *fnptr, ...) {
70
+ va_list args;
71
+ va_start (args, fnptr);
72
+ const char *p0 = va_arg (args, const char *);
73
+ int64_t v0 = va_arg (args, int64_t );
74
+ void *p1 = va_arg (args, void *);
75
+ int32_t v1 = va_arg (args, int32_t );
76
+ const char *p2 = va_arg (args, const char *);
77
+ int32_t v2 = va_arg (args, int32_t );
78
+ va_end (args);
79
+ void *cookie =
80
+ _FortranAioBeginExternalFormattedOutput (p0, v0, p1, v1, p2, v2);
81
+ _list_started_cookie = cookie;
82
+ return cookie;
83
+ }
66
84
extern bool V_FortranAioOutputAscii (void *fnptr, ...) {
67
85
va_list args;
68
86
va_start (args, fnptr);
@@ -211,6 +229,7 @@ typedef struct {
211
229
uint32_t dfnid; // The dvoideferred function id, in order received
212
230
uint64_t *arg_array; // ptr to malloced arg_array
213
231
char *c_ptr; // ptr to null terminated char string
232
+ char *c_ptr2; // ptr to null terminated char string
214
233
uint64_t thread_num;
215
234
uint64_t num_threads;
216
235
uint64_t team_num;
@@ -242,6 +261,7 @@ extern "C" emis_return_t EmissaryFortrt(char *data, emisArgBuf_t *ab) {
242
261
_deferred_fns_ptr = new std::vector<deferred_entry_t *>;
243
262
244
263
char *c_ptr = nullptr ;
264
+ char *c_ptr2 = nullptr ;
245
265
bool defer_for_reorder = true ;
246
266
bool run_deferred_functions = false ;
247
267
switch (ab->emisfnid ) {
@@ -257,6 +277,26 @@ extern "C" emis_return_t EmissaryFortrt(char *data, emisArgBuf_t *ab) {
257
277
a[5 ] = (emis_argptr_t *)c_ptr;
258
278
break ;
259
279
}
280
+ case _FortranAioBeginExternalFormattedOutput_idx: {
281
+ _deferred_begin_statements++;
282
+ fnptr = (void *)V_FortranAioBeginExternalFormattedOutput;
283
+ size_t slen = std::strlen ((char *)a[8 ]) + 1 ;
284
+ c_ptr = (char *)aligned_alloc (sizeof (uint64_t *), slen);
285
+ if (!c_ptr)
286
+ fprintf (stderr, " MALLOC FAILED for c_ptr size:%ld \n " , slen);
287
+ std::strncpy (c_ptr, (char *)a[8 ], slen - 1 );
288
+ c_ptr[slen - 1 ] = (char )0 ;
289
+ a[8 ] = (emis_argptr_t *)c_ptr;
290
+
291
+ slen = std::strlen ((char *)a[4 ]) + 1 ;
292
+ c_ptr2 = (char *)aligned_alloc (sizeof (uint64_t *), slen);
293
+ if (!c_ptr2)
294
+ fprintf (stderr, " MALLOC FAILED for c_ptr2 size:%ld \n " , slen);
295
+ std::strncpy (c_ptr2, (char *)a[4 ], slen - 1 );
296
+ c_ptr2[slen - 1 ] = (char )0 ;
297
+ a[4 ] = (emis_argptr_t *)c_ptr2;
298
+ break ;
299
+ }
260
300
case _FortranAioOutputAscii_idx: {
261
301
fnptr = (void *)V_FortranAioOutputAscii;
262
302
@@ -362,6 +402,7 @@ extern "C" emis_return_t EmissaryFortrt(char *data, emisArgBuf_t *ab) {
362
402
q->arg_array = arg_array;
363
403
q->return_value = (emis_return_t )0 ;
364
404
q->c_ptr = c_ptr;
405
+ q->c_ptr2 = c_ptr2;
365
406
_deferred_fns_ptr->push_back (q);
366
407
} else {
367
408
// execute a non deferred function
@@ -392,6 +433,8 @@ extern "C" emis_return_t EmissaryFortrt(char *data, emisArgBuf_t *ab) {
392
433
for (auto q : *_deferred_fns_ptr) {
393
434
if (q->c_ptr )
394
435
free (q->c_ptr );
436
+ if (q->c_ptr2 )
437
+ free (q->c_ptr2 );
395
438
free (q->arg_array );
396
439
delete q;
397
440
}
@@ -402,7 +445,7 @@ extern "C" emis_return_t EmissaryFortrt(char *data, emisArgBuf_t *ab) {
402
445
_max_num_threads = 0 ;
403
446
_max_num_teams = 0 ;
404
447
delete _deferred_fns_ptr;
405
- _deferred_fns_ptr= nullptr ;
448
+ _deferred_fns_ptr = nullptr ;
406
449
} // end run_deferred_functions
407
450
408
451
return return_value;
0 commit comments