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

@syntax and common blocks #1980

Open
joeymukherjee opened this issue Feb 5, 2025 · 8 comments
Open

@syntax and common blocks #1980

joeymukherjee opened this issue Feb 5, 2025 · 8 comments
Labels
ON HOLD : Please Answer question GDL Team is Waiting for external input

Comments

@joeymukherjee
Copy link

I have large old codebase of IDL code that doesn't quite work in GDL, but maybe there is an easy way to fix. I will admit, I don't know IDL that well, but just enough to have it running.

Our code has things like this in there:

@lib/units_gv.pro
.r gv

which I think compiles the code and and runs the routine referenced inside. This routine has this:

common units, angstrom, nm, um, micron, cm, inch, foot, mile, mm, m, meter, km, $
gram, kg, au, pi, $......

and it is very long.

The error message I get from GDL is:

% Error opening file: lib/units_gv.pro
% Error opening file. File: gv
% Common block: UNITS must contain variables.
At: gv.pro
% Procedure not found: GV
% Execution halted at: $MAIN$

I have no idea what to "google" to look for this type of syntax, nor do I have any idea how to fix? Any ideas?

To be clear, this works perfectly in IDL v8.5+, but I am now trying to run under a container so GDL would be very helpful! I feel like it did work with IDL v7 since the code is extremely old.

Thanks,
Joey

@GillesDuvert
Copy link
Contributor

it looks like there is an "error" in lib/units_gv.pro , that is, something GDL did not digest, so probably that's why the 'gv' procedure is not defined, and all the long list of errors messages.
We need to know what is the offending command in lib/units_gv.pro

@joeymukherjee
Copy link
Author

Possibly, but when I type @lib/units_gv.pro into the gdl prompt, no errors appear. It is only when running it through my initial IDL program that I see the "Error opening file: xxxx". Same for when I write .r pro/gv.pro.

There is no verbose mode or anything which can make it produce more error messages, right?

I use a startup program which is as follows:

dir_gv = getenv('DIR_GV');
dir_gv_lib = dir_gv + '/lib'
!path = $
':' + dir_gv_lib + $
':' + dir_gv + '/pro' + $
':' + dir_gv_lib + '/astrolib/pro' + $
':' + dir_gv_lib + '/layoung/astronomy' + $
':' + dir_gv_lib + '/layoung/oc' + $
':' + dir_gv_lib + '/layoung/oc/hd' + $
':' + dir_gv_lib + '/layoung/oc/tyc2' + $
':' + dir_gv_lib + '/layoung/util' + $
':' + dir_gv_lib + '/occult/hdoccul/idl/idlutils' + $
':' + dir_gv_lib + '/buie' + $
':' + !path
resolve_routine, 'idlrc_gv'
@lib/units_gv.pro
@pro/gv.pro
.r gv
is_gv_batch = 1
gv, /BATCH
exit

If I use gdl on this program, I get:

gdl gdl_gv.pro
18:34:22: Error: Unable to initialize GTK+, is DISPLAY set properly?
WARNING: wxWidgets not initializing, widget-related commands will not be available.
GDL - GNU Data Language, Version 1.0.1

  • For basic information type HELP,/INFO
  • No startup file read (GDL_STARTUP/IDL_STARTUP env. var. not set).
  • Please report bugs, feature or help requests and patches at: https://github.com/gnudatalanguage/gdl

% Compiled module: IDLRC_GV.
% Error opening file: lib/units_gv.pro
% Error opening file: pro/gv.pro
. Error opening file. File: gv
% Common block: UNITS must contain variables.
At: /web/geoviz2/gv_exec/pro/gv.pro
% Procedure not found: GV
% Execution halted at: $MAIN$

Joey

@GillesDuvert
Copy link
Contributor

@joeymukherjee I see you use version 1.0.1 , dated 2021
An enormous amount of work has ben put in GDL since, possibly solving your problem.
I suggest you at least use version 1.1 and come back to us if problem persists.

@joeymukherjee
Copy link
Author

I upgraded to 1.1 from the Debian unstable branch. I get the same issue:

GDL - GNU Data Language, Version v1.1

  • For basic information type HELP,/INFO
  • Default library routine search path used (GDL_PATH/IDL_PATH env. var. not set): /web/geoviz2/gv_exec:/web/geoviz2/gv_exec/lib:/web/geoviz2/gv_exec/pro
  • No startup file read (GDL_STARTUP/IDL_STARTUP env. var. not set).
  • Please report bugs, feature or help requests and patches at: https://github.com/gnudatalanguage/gdl

% Compiled module: KEYWORD_EXISTS.
...
% Compiled module: LABEL_REGION_PAD.
% Compiled module: KERNEL_TRIANGLE.
% Compiled module: CHECKERBOARD.
% Compiled module: IDLRC_GV.
% Error opening file: lib/units_gv.pro
% Error opening file: pro/gv.pro
. Error opening file. File: gv
% Common block: UNITS must contain variables.
At: /web/geoviz2/gv_exec/pro/gv.pro
% Procedure not found: GV
% Execution halted at: $MAIN$

@GillesDuvert
Copy link
Contributor

GillesDuvert commented Feb 10, 2025

the error comes from UNITS common not containing variables (having no declared variables)
At: /web/geoviz2/gv_exec/pro/gv.pro
As it passes with IDL, this is a bug (well, according to the IDL doc, commons should declare all their variables)
I'm afraid I must ask for a, preferentially simple, example showing the problem. May we know the contents of /web/geoviz2/gv_exec/pro/gv.pro ?

@joeymukherjee
Copy link
Author

So this is interesting: if I run dos2unix on my lib/units_gv.pro, I get a different error which is more explanatory! Apparently, I need to define "SHELL" in my environment. Once I did that, I got further and it now stopping on DLM_REGISTER which makes sense.

So one incompatibility with IDL and GDL is you can mix DOS/Unix line endings and IDL handles them differently than GDL! Not sure how easy or hard this is to fix?

@GillesDuvert
Copy link
Contributor

@joeymukherjee ah but this is yet another story! very interesting find, although it should not be possible because the gdl parser written in ANTLR is supposed to deal with the DOS line endings ( aka "\r\n" ). Perhaps a regression following the recent changes in GDL syntax.
I'm not sure I can reproduce the bug here.

And yes GDL does not have yet support for DLM...

@GillesDuvert
Copy link
Contributor

@joeymukherjee I cannot reproduce a problem in '@something' if 'something' is DOS-like.
could you provide the culprit file (zipped, to preserve the line endings).

@GillesDuvert GillesDuvert added the ON HOLD : Please Answer question GDL Team is Waiting for external input label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ON HOLD : Please Answer question GDL Team is Waiting for external input
Projects
None yet
Development

No branches or pull requests

2 participants