I have a GDL v0.9.9 installed on my machine running Ubuntu 20.04. I am trying to write a function calculating a Julian Date.
list_1 file:
FUNCTION JulianDate, L, M, N
L1 = L + 4716 - FLOOR((14 - M) / 12)
M1 = (M + 9) MOD 12
G = FLOOR(3/4*FLOOR((L1 + 184)/100)) - 38
RETURN, FLOOR(365.25 * L1) + FLOOR(30.6 * M1 + 0.4) + N - G - 1402
END
JD = JulianDate(1990, 4, 30)
Unfortunately, after $ gdl list_1
I get the error(s):
% Programs can't be compiled from single statement mode.
% Variable is undefined: L
% Execution halted at: $MAIN$
% Variable is undefined: M
% Execution halted at: $MAIN$
% Variable is undefined: L1
% Execution halted at: $MAIN$
% Return statement in procedures cannot have values.
% Parser syntax error: unexpected token: END
% Ambiguous: Variable is undefined: JULIANDATE or: Function not found: JULIANDATE
% Execution halted at: $MAIN$
I compared my code with the documentation of IDL (as it should be "mutually intelligible") and it looked good for me. Is declaring/defining/calling a function in GDL different than in IDL?
Edit 1: I managed to run my code on the machine with IDL 8.5. The functions must be declared in the beginning of the file before any variables. However it does not change the behaviour of GDL.
idl
and idlde
(GUI) behave differently: while idl
requires the functions to be stored in the separate .pro files, idlde
handles the functions in the same file as the run script, as long as they are declared before any other commands.
gdl
behaves just like idl
, so functions' declarations in the separate files resolved the issue.