View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

Compiling fortran task on cygwin/winxp

iwold wrote on Dec 07, 2006

Dear Mike,

Thank you for all your help. I am trying to compile a fortran task named photstand.f I am attempting to follow procedures laid out in previous forum topics with no success. This is what I have done:

csh
>setenv iraf /iraf/iraf/
>setenv IRAFARCH cygwin
>source $iraf/unix/hlib/irafuser.csh


I then start IRAF and go to the /bin directory which contains photstand.f
cl>fc photstand.f


This is what the error looks like:

photstand.f:
MAIN:
Error on line 156 of photstand.f: nonarithmetic operand of arithmetic operator
Error on line 157 (same as line above)
Error on line 158 (same as line above)
Error on line 159 (same as line above)
Error on line 160 (same as line above)
/iraf/iraf/unix/hlib/f77.sh: line 179: gcc: command not found

Any help would be greatly appreciated.

Isak

Mike Fitzpatrick wrote on Dec 07, 2006

Hi Isak,

I'd have to see the code to be sure, but the first error (nonarithmetic ....) is usually a type conflict of some kind, e.g. use of a boolean variable in an equation.
Otherwise, it appears you'll need to install GCC from the cygwin distribution even after than is solved, you can do this with the cygwin setup under the Developer tools. If all you need is a binary and arent developing the task actively feel free to send it to me and I'll try compiling it and posting the result.

Cheers,
-Mike

iwold wrote on Dec 07, 2006

Thank you Mike,

I have installed gcc and believe that problem is taken care of.

However the nonarth. errors remain. The program has been provided to me to assist in photometry. It is currently in use on other systems. So I believe that it is a working code, just not on my system. The lines that are giving me the nonarithmetic error are of the form:
      l1 = (file(4:4) - 48) * 10000

I believe the compilier is expecting 'file(4:4)' to be a number. Any suggestions would be greatly appreciated.

Isak

Mike Fitzpatrick wrote on Dec 07, 2006

Either an atoi() function or the use of a temporary variable should do it, e.g.

l1 = (atoi(file(4:4))- 48) * 10000
or
i1 = file(4:4)
l1 = (i1 - 48) * 10000


-Mike

iwold wrote on Dec 07, 2006

Thank you Mike,

Using the atoi function seems the most promising, however still not successful. Here is the output:

ecl> fc photstand.f
    MAIN:
link:
photstand.o:photstand.c:(.text+0xac5): undefined reference to '_atoi_' 
photstand.o:photstand.c:(.text+0x143c): undefined reference to '_fit_'
(multiple occurances not shown)
collect2: ld returned 1 exit status


I am thinking that the proper fortran flag may define atoi and fit but I have been unable to find it.

Use of a temporary variable results in an error which states: impossible conversion.

I have also tried to compile this program outside of iraf using the following command copied from the program's code header information:

$ f77 -o photstand photstand.f -lpress


But this results in an error stating: Invalid form for WRITE statement, which points to the following line:
write(unit=7,*) x(i),y(i),sig(i)
....................^
Any help would be greatly appreciated. Thank you for your time.

Isak

Mike Fitzpatrick wrote on Dec 07, 2006

Maybe I only imagined that atoi() was a fortran function, in any case I just checked and using

i1 = int (file(4:4))


should work as expected and compile properly. As for the write statement: You might try putting quotes around the *, but it actually compiles for me as is.

-Mike

iwold wrote on Dec 07, 2006

Thank you Mike for going above and beyond,

The int() function works! And I have found that the undefined reference to fit, is a subroutine that is required for the photstand program. I have obtained the fit subroutine but have not been able to compile due to this error:
ecl> fc fit.f
fit.f:
    fit:
link:
/iraf/iraf/unix/bin.cygwin/libf2c.a(main.o):(.text=0x18c): undefined reference to '_MAIN__'
collect2: ld returned 1 exit status


If you have any suggestions please feel free to make them at your leisure. Thank you.

Isak

Mike Fitzpatrick wrote on Dec 07, 2006

Isak,

Use "fc -c fit.f" to compile just the object file you include when compiling your program, or else compile both programs together at the same time, e.g.

cl> fc photstand.f fit.f -o photstand.e


At the moment it appears to be trying to compile fit.f as a standalone program, but the file is missing a 'program' statement.

-Mike

iwold wrote on Dec 07, 2006

Success!!

Thank you very much.

Isak

Last post on Dec 07, 2006