1

this is my Headline in a IDL-source code:

pro gamow,t_plasma,z1=z1,z2=z2,a1=a1,a2=a2

; displays gamow peak for input value of t (in K)  
; default values for protons
  if not keyword_set(z1) then z1=1. 
  if not keyword_set(z2) then z2=1.
  if not keyword_set(a1) then a1=1.
  if not keyword_set(a2) then a2=1.

I am executing this in the terminal/console, with, for example:

gamow, 1d8

This works, since then z1=z2=a1=a2 = 1.0. And 1d8 means 100 Million. But, this doesn't work:

gamow, 1d8, 2, 2, 4, 4

why?

Best regards

ollowain86
  • 19
  • 4

1 Answers1

1

You defined t_plasma as a positional parameter, but z1, z2, a1, and a2 as keyword parameters. Your first example only passes a single positional parameter, so t_plasma is defined, and the other parameters are not, which is fine. Your second example tries to pass all 5 arguments as positional parameters, but only one positional parameter is defined. So IDL reports an error, "Incorrect number of arguments".

Instead, try this:

gamow,1d8,z1=2,z2=2,a1=4,a2=4
Jim Lewis
  • 43,505
  • 7
  • 82
  • 96
  • Just a quick note - in Python you can specify "keywords" using the actual keyword names or just as positional arguments - either one will work as long as the positional arguments are in the correct order. In IDL there is a difference between positional arguments and keyword arguments. Positional arguments must be in order, although you don't have to specify all of them. Keyword arguments must use the keyword name, and they can be in any order. [Editorial comment: In my opinion, the IDL approach is better because it enhances code readability and avoids mysterious errors.] – Chris Torrence May 14 '16 at 14:02