Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with double asterisks write #308

Open
hlim1 opened this issue Jul 12, 2019 · 3 comments
Open

Issue with double asterisks write #308

hlim1 opened this issue Jul 12, 2019 · 3 comments
Assignees

Comments

@hlim1
Copy link
Contributor

hlim1 commented Jul 12, 2019

There is an issue when both of the formats are asterisks (*). For example,

write (*,*) __output_value__

      program odd_number
      implicit none
      integer :: N, k
      N = 19
      WRITE(*,*) 'Odd number between 0 and ', N
      end program odd_number

The output should be the standard output of the target output value.
However, currently, the crash occurs at the level of translate.py.

@pratikbhd
Copy link
Contributor

pratikbhd commented Dec 8, 2019

@skdebray
Further information about this issue. Fix for this issue is being made to the write_bugfix branch. The double asterisk write fails at two levels.

  1. (Already Fixed) For simple variables, the intermediate Python file gets generated but fails to execute. The following error shows up in format.py
fmt = fmt.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

This is because the list_output_formats function in format.py is sent an argument of the form ["{'type': 'INTEGER', 'parameter': False}","{'type': 'INTEGER', 'parameter': False}",] instead of ["INTEGER","INTEGER",].
This can be solved by converting the following lines in pyTranslate.py:

  • Lines 1134 and 1108: Change
self.pyStrings.append(f'"{self.variableMap[var.strip()]}",')

to

self.pyStrings.append(f'"{self.variableMap[var.strip()]["type"]}",')
  1. (Not Fixed Yet) The double asterisk write(*,*) fails when a string is referenced instead of a variable. The example posted by @hlim1 in the comment above is a case of that. This code fails at pyTranslate.py with the following error:
line 1135, in printWrite
    f'"{self.variableMap[var.strip()]["type"]}",'
AttributeError: 'NoneType' object has no attribute 'strip'

@pratikbhd
Copy link
Contributor

@skdebray An unhandled case for the WRITE function was detected. Currently, we do not handle writing out (in terminal or in a file) LOGICAL constants i.e. .TRUE./.FALSE..
The following error shows up in format.py when trying to run the intermediate Python file where a LOGICAL constant is being printed.

line 359, in gen_output_fmt_1
f"ERROR: Unrecognized format specifier {fmt[0]}\n"
delphi.translators.for2py.For2PyError

@adarshp
Copy link
Collaborator

adarshp commented Feb 16, 2020

@pratikbhd @hlim1 Is this issue resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants