Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28343 Discussions

Write numerical values in output file

nicolas_legrand
597 Views

Hello, I try to write numerical values in an output file (from a former post of July). but I have compilation error.

The difficulty is that I have all my Fortran source code with extension .for and not .f90, so the simple synthax of f90 cannot be re-used here (and I cannot convert my .for code in .f90).

Since the previous post, I progressed on this: I succeeded to write headers (for each numerical values I want to store) in the output file (see file attached), it compiles correctly with that synthax.

But when I want to write the numerical values using similar synthax, the compilation fails.

 

Any help ?

thanks    

Labels (1)
0 Kudos
1 Solution
nicolas_legrand
572 Views

Thanks a lot, it works !

 

There was still a small parenthesis error in your code but I corrected it and now it compiles (below the corrected source code).

 

! WRITE IN FILE THE STRIP MODEL COEFF.
OPEN(987, file = 'OutputFile.txt', status = 'unknown')
! WRITE HEADERS
WRITE(987, '(37(A,$))') 'GammaB_CB[1,1,1]', CHAR(9),
> 'GammaP_CB[1,1,1]', CHAR(9),
> 'Rb_CB[1,1,1]', CHAR(9),
> 'Rp_CB[1,1,1]', CHAR(9),
> 'def0', CHAR(9)

! WRITE VALUES
WRITE(987, '(/, 4(F5.2, A), $)')
> GammaB_CB(1,1,1), CHAR(9),
> GammaP_CB(1,1,1), CHAR(9),
> Rb_CB(1,1,1), CHAR(9),
> Rp_CB(1,1,1)

View solution in original post

0 Kudos
2 Replies
mecej4
Black Belt
586 Views

I see three errors in the first multiline statement that produced a syntax error (line 710 et seq):

 

 

c
      write(987,'(/, F5.2, A, $, F5.2, A, $,  F5.2, A, $,  F5.2, A, $)
     > GammB_CB[1,1,1],  CHAR(9),

 

 

Of the four '$' format specifiers, only the last one makes sense. Nevertheless, it would be better to use the standard method, which does away with  the '$' specifier, instead using the clause ADVANCE = 'NO' in the WRITE statement.

 

The next error is that the first line is missing two characters at the end: a single quote and right-parenthesis.  The third error is your using brackets instead of parentheses for containing subscripts. The lines above should be

 

 

c
      write(987,'(/, 4(F5.2, A), $)')
     > GammB_CB(1,1,1),  CHAR(9),

 

 

It would make it easier for people to respond if you posted program text using the </> tool icon instead of attaching Powerpoint files or screenshots. 

nicolas_legrand
573 Views

Thanks a lot, it works !

 

There was still a small parenthesis error in your code but I corrected it and now it compiles (below the corrected source code).

 

! WRITE IN FILE THE STRIP MODEL COEFF.
OPEN(987, file = 'OutputFile.txt', status = 'unknown')
! WRITE HEADERS
WRITE(987, '(37(A,$))') 'GammaB_CB[1,1,1]', CHAR(9),
> 'GammaP_CB[1,1,1]', CHAR(9),
> 'Rb_CB[1,1,1]', CHAR(9),
> 'Rp_CB[1,1,1]', CHAR(9),
> 'def0', CHAR(9)

! WRITE VALUES
WRITE(987, '(/, 4(F5.2, A), $)')
> GammaB_CB(1,1,1), CHAR(9),
> GammaP_CB(1,1,1), CHAR(9),
> Rb_CB(1,1,1), CHAR(9),
> Rp_CB(1,1,1)

0 Kudos
Reply