View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

C code in procedure script

Jaco wrote on Jul 22, 2011

Hi,

I am using IRAF V2.14

I have a C language code coordtransform.c which I want to include in a procedure script.
I have defined it as a foreign task by
task coordtransform = $coordtransform.c
In IRAF it works fine if I do the normal !coordtransform "filename", but the same command in the procedure script does not work.

The C code takes a file name as an argument, where the file name is defined as imname // '.coo.1' in the procedure script.

In the procedure script I have:
!gcc -lm coordtransform.c -o coordtransform
!./coordtransform , imname // '.coo.1'

Is it possible to do it like this?

Thanks
Jaco

Mike Fitzpatrick wrote on Jul 22, 2011

For C code, you can't run it directly in a CL script and I doubt you want to compile it every time the script runs, but you're on the right track. What you want is to first compile the code and then call the binary from the script as a foreign task.

For example, assuming you've compiled the program you would declare it as a foreign task using the command:

task $foreign = $/path/coordtransform


You can put this in your login.cl or loginuser.cl file before the final 'keep' statement, or in the script itself.

You would then call it from the script using something like

coordtransform (imname // ".coo.1")


or alternatively as

print ("!/path/coordtransform " // imname // ".coo.1") | cl()


which simply creates an escaped command string it pipes to the CL to execute.

Jaco wrote on Jul 22, 2011

Thank you for the reply.

Yes I included the compiling only to see if it runs in the script.
After some playing around with different syntax, I finally got it to work.

With only the "coordtransform (imname // ".coo.1")" in the script, I got an error with the arguments in the C code, but the "print ("!/path/coordtransform " // imname // ".coo.1") | cl()" worked just fine.

Thanks you!

Regards
Jaco

Last post on Jul 22, 2011