gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
278 stars 62 forks source link

linking GDL to IDL based programs #1273

Open pafreema opened 2 years ago

pafreema commented 2 years ago

Hi, I am trying to run the data calibration software MIR (https://github.com/qi-molecules/sma-mir.git) which is written in IDL, with GDL.

I installed GDL 1.0.0-rc3 via MacPorts on MacOS Monterey and it is in /opt/local/share/gnudatalanguage.

I have MIR in ~/Documents/sma-mir, and this directory contains a setup.bsh script, with IDL_STARTUP, IDL_DIR, and IDL_PATH commands where I can set the path:

RDXDIR=/sma-mir export RDXDIR IDL_STARTUP=$RDXDIR/idl/idl_startup export IDL_STARTUP IDL_DIR=/opt/local/share/gnudatalanguage/lib export IDL_DIR IDL_PATH=+$RDXDIR/idl/pro:$IDL_DIR/pro export IDL_PATH IDL_DEVICE=X export IDL_DEVICE CAMPUS_LOGIN=sma export CAMPUS_LOGIN

This typically directs to the idl directory contained in sma-mir, which has its own idl_startup script. I cannot get gdl to recognize any of the idl procedures (trying the above setup and other iterations).

Is there a way to link MIR and GDL properly? Or, this is similar to https://sourceforge.net/p/gnudatalanguage/discussion/338692/thread/bb68ed82/?limit=25, should I unpack sma-mir in the gnudatalanguage/lib area?

Thanks!

alaingdl commented 2 years ago

Hi. Several points:

$ git clone https://github.com/qi-molecules/sma-mir.git
$ cd sma-mir 
$ ~/GDL/last-gdl/build_cmake/quick_start_GDL.sh (the last, the very convenient one :)
GDL> path_add, /rec,'.'
% Compiled module: PATH_ADD.
No explicit position : the defaut is AT THE BEGINNING
GDL> .r pro_mir_init
% Compiled module: PRO_MIR_INIT.

I cannot go further because I do not have the SQL log/pass ...

pafreema commented 2 years ago

Thanks for the reply!

!PATH (Disabled, 7 directories)
/opt/local/share/gnudatalanguage/lib (144 files)
/opt/local/share/gnudatalanguage/lib/CMprocedures (5 files)
/opt/local/share/gnudatalanguage/lib/dicom (10 files)
/opt/local/share/gnudatalanguage/lib/envi (3 files)
/opt/local/share/gnudatalanguage/lib/map (16 files)
/opt/local/share/gnudatalanguage/lib/obsolete (7 files)
/opt/local/share/gnudatalanguage/lib/utilities (13 files)
GDL> mirhelp,gain_cal
% MIRHELP: Variable is undefined: STR_PAR
% Execution halted at: MIRHELP             42 /Users/Pamela/Documents/sma-mir/idl/pro/sma/mirhelp.pro
%                      PRO_MIR_INIT        66 /Users/Pamela/Documents/sma-mir/idl/pro/pro_mir_init.pro
%                      $MAIN$  
alaingdl commented 2 years ago

But if you do :

GDL> mirhelp,'gain_cal'

what's happen ?

pafreema commented 2 years ago

Nothing happens:

GDL> mirhelp,'gain_cal'
GDL> 
alaingdl commented 2 years ago

Then all is OK ! :smile: I do have the same. Just a way to be sure the IDL_PATH is OK !

pafreema commented 2 years ago

Ok great!

One last follow-up: I have tried to run the other setup files after pro_mir_init,

GDL> .r pro_mir_init
% Compiled module: PRO_MIR_INIT.
GDL> .r strsplit      
GDL> .r pro_setup_env
% Compiled module: PRO_SETUP_ENV.
GDL> .r pro_constants
% Compiled module: PRO_CONSTANTS.
GDL> mirhelp,gain_cal
% Compiled module: MIRHELP.
% MIRHELP: Variable is undefined: STR_PAR
% Execution halted at: MIRHELP             42 /Users/Pamela/Documents/sma-mir/idl/pro/sma/mirhelp.pro
%                      $MAIN$

STRSPLIT is a GDL file, and I copied it into the sma-mir/idl directory in case, but it is not recognizing it. I think that's where the execution may be having problems. Would you have any idea on this?

Good to know the path is ok, though, thanks for your help!

alaingdl commented 2 years ago
GillesDuvert commented 2 years ago

@pafreema the idl/idl_startup file in the sma-mir package has numerous errors with IDL:

source ./setup.bsh
parts=strtrim(strsplit(e.start_date,' ',/extract),2L)
                                         ^
% Syntax error.
  At: /home/gildas/PACKAGES/sma-mir/idl/pro/pro_mir_init.pro, Line 97
% Compiled module: PRO_MIR_INIT.
% Attempt to call undefined procedure: 'PRO_MIR_INIT'.
% Execution halted at: $MAIN$          

common global
             ^
% Common block GLOBAL must contain variables.
  At: /home/gildas/PACKAGES/sma-mir/idl/idl_startup, Line 26

common data_set
               ^
% Common block DATA_SET must contain variables.
  At: /home/gildas/PACKAGES/sma-mir/idl/idl_startup, Line 27

common plo
          ^
% Common block PLO must contain variables.
  At: /home/gildas/PACKAGES/sma-mir/idl/idl_startup, Line 28

common wlm
          ^
% Common block WLM must contain variables.
  At: /home/gildas/PACKAGES/sma-mir/idl/idl_startup, Line 29
% Expression must be a structure in this context: E.
% Execution halted at: $MAIN$          
% FINDFILE: String expression required in this context: FILENAME.
% Execution halted at: $MAIN$          
% Variable is undefined: FILECOUNT.
% Execution halted at: $MAIN$          
% Variable is undefined: FILECOUNT.
% Execution halted at: $MAIN$          
idl_startup completed
IDL> 

GDL chokes similarly.

Bypassing setup environment, I get:

$ cd sma-mir/idl
$ idl
IDL> !PATH=expand_path("+pro")+path_sep()+!PATH
IDL> .r pro_mir_init        
% Compiled module: PRO_MIR_INIT.
IDL> mirhelp,'gain_cal'
% Compiled module: MIRHELP.
% Expression must be a structure in this context: E (GLOBAL).
% Execution halted at: MIRHELP            43 /home/gildas/PACKAGES/sma-mir/idl/pro/sma/mirhelp.pro
%                      $MAIN$          
IDL> 
$ gdl
GDL> !PATH=expand_path("+pro")+path_sep()+!PATH
GDL> .r pro_mir_init
% Compiled module: PRO_MIR_INIT.
GDL> mirhelp,'gain_cal'
% Compiled module: MIRHELP.
% MIRHELP: Common block variable is undefined: <Undefined>
% Execution halted at: MIRHELP             43 /home/gildas/PACKAGES/sma-mir/idl/pro/sma/mirhelp.pro
%                      $MAIN$          
GDL> 

HIH ...

alaingdl commented 2 years ago

@GillesDuvert in fact I made a small change in pro_mir_init.pro to avoid being blocked by dbi_sql_submit() test ...

pafreema commented 2 years ago

@GillesDuvert I was able to get to the same place you did with

% MIRHELP: Common block variable is undefined: <Undefined>
% Execution halted at: MIRHELP             43 /Users/Pamela/Documents/sma-mir/idl/pro/sma/mirhelp.pro
%                      $MAIN$  

But I'm not sure where to go from here to get mirhelp (or any other module to work).

@alaingdl noted! That settles some things.

pafreema commented 2 years ago

Is there a GDL startup file? Sorry, I am very new to IDL/GDL!

alaingdl commented 2 years ago

ha ha, I realized that ! You do have to write it by yourself. It is not really difficult and can be derived from the idl one.

Your problem is to be sure to have the files in you PATH first

GillesDuvert commented 2 years ago

@pafreema the documentation about sma-mir is at https://lweb.cfa.harvard.edu/~cqi/mircook.html Due to the errors reported by IDL at startup, notwithstanding the use of GDL in lieu of IDL, it may be safer to ask support from the person proposing his/her help in the above page. GDL aims to work like IDL, and we acknowledge it may not be fully compatible, and work to improve it, but we need first to assess that the sma-mir package really works flawlessly with IDL.

pafreema commented 2 years ago

@GillesDuvert yes, I have been in contact with them as well, and am hopefully finding a solution there! It seems there are some things to work out with MIR itself, as no one (to their knowledge) has tried GDL yet with it.

Thank you so much for your time and help!

GillesDuvert commented 2 years ago

@pafreema After you got help from sma-mir, please report success or failures with GDL here, it is always useful.

alaingdl commented 1 year ago

@pafreema please gives feedbacks then we can close this issue, thanks