Quantcast NEED HELP with fortran compiler ASAP Text - Physics Forums Library

PDA

View Full Version : NEED HELP with fortran compiler ASAP


shenie
Aug4-08, 07:32 PM
I am having trouble compiling code. Here's my code:

PROGRAM Sample1

IMPLICIT NONE
! Variables and constants
INTEGER, PARAMETER :: n=1000, m=10
INTEGER :: i
REAL, DIMENSION (1: n) :: x
REAL, DIMENSION (1:100, 1:m) :: y
REAL, DIMENSION (1: m):: colavg
INTEGER :: filestat, IO_stat_num


! Open file and Check for error

OPEN( UNIT=10, FILE= 'Data1.txt', IOSTAT=filestat, STATUS='OLD')

IF (filestat>0) THEN
PRINT *, 'Error opening file. Error Code: ', filestat
STOP
ENDIF

DO i=1, n

READ (UNIT=10, FMT=101, IOSTAT=IO_stat_num) x(i)
101 FORMAT (2F8.3)

IF (IO_stat_num == 0) THEN
CYCLE
ELSEIF (IO_stat_num == -1) THEN
PRINT *,'EOF at line ', i
EXIT

ELSEIF(IO_stat_num > 0) THEN
PRINT *,'Non numeric data at line ', i
EXIT
ENDIF
ENDDO
CLOSE(UNIT=10)
! call sorting routine from book

CALL shell (n,x)

! Create ten averaged bins

y = RESHAPE(x,(/100,10/))
colavg = sum( y, dim=1)
colavg = colavg/100

OPEN(UNIT=20, FILE='Bins1', STATUS='NEW')

WRITE (UNIT=20) colavg

CLOSE (UNIT=20)

END PROGRAM Sample1

SUBROUTINE shell(n,a)

INTEGER n
REAL a(n)
INTEGER i,j, inc
REAL v

inc=1
1 inc=3*inc+1
if(inc.le.n) goto 1
2 CONTINUE
inc =inc/3
DO i = inc+1, n
v= a(i)
j=i
3 IF (a(j-inc).gt.v) THEN
a(j)=a(j-inc)
j=j-inc
IF (j.le.inc) GOTO 4
GOTO 3
ENDIF
4 a(j)=v

ENDDO

if(inc.gt.1) GOTO 2

RETURN
END


Error reads:

Begin scan
amakedepend "@/Users/sbraswell/Release/mkdep_F95"
Scan completed
Begin build
f95 -c -nowdir -mrwe -m32 -O2 -o "./Release/simple.o" "../../Applications/Absoft10.1/examples/simple.f95"
f95 -c -nowdir -mrwe -m32 -O2 -o "./Release/sample1.o" "Desktop/sample1.f90"
f95 -lmrwe -framework Carbon -laf90math -lafio_carbon -lmrwe -lafio_carbon -lamisc -labsoftmain_mrwe -laf77math -lm -lmv -osxtarget=10.4 -m32 -O2 "./Release/simple.o" "./Release/sample1.o" -o "./sample.app/Contents/MacOS/sample"
/usr/bin/ld: multiple definitions of symbol ABSOFT_IO_INITIALIZE
./Release/simple.o definition of ABSOFT_IO_INITIALIZE in section (__DATA,__data)
./Release/sample1.o definition of ABSOFT_IO_INITIALIZE in section (__DATA,__data)
/usr/bin/ld: multiple definitions of symbol _MAIN__
./Release/simple.o definition of _MAIN__ in section (__TEXT,__text)
./Release/sample1.o definition of _MAIN__ in section (__TEXT,__text)
collect2: ld returned 1 exit status
Make:
*** Error code 256 from f95
link failed.
Build interrupted

PLEASE HELP

zeitghost
Aug5-08, 03:38 AM
It appears to be compiling two files: simple.f95 and sample1.f90.

Which gives it two _MAIN_ modules which the linker doesn't like.

Is there something wrong with your make or project file?

shenie
Aug5-08, 04:02 PM
Thanks..I didn't realize it was trying to compile 2. My first time using fortran.