NEED HELP with fortran compiler

In summary: I'll check my project file.In summary, the individual is having trouble compiling their code and is receiving an error message with multiple definitions of symbols. They are unsure if there is an issue with their make or project file. They are seeking help.
  • #1
shenie
3
0
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
 
Technology news on Phys.org
  • #2
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?
 
  • #3
Thanks..I didn't realize it was trying to compile 2. My first time using fortran.
 

Question 1: What is a Fortran compiler?

A Fortran compiler is a software program that translates source code written in the Fortran programming language into executable machine code that a computer can understand and execute. It is an essential tool for developing and running Fortran programs.

Question 2: How do I install a Fortran compiler?

The installation process for a Fortran compiler may vary depending on the specific compiler you are using. However, most compilers have a user-friendly installation process that can be completed by following the instructions provided by the compiler's documentation or website. Some popular Fortran compilers include GNU Fortran (gfortran), Intel Fortran (ifort), and IBM XL Fortran (xlf).

Question 3: Can I use a Fortran compiler on any operating system?

Yes, Fortran compilers are available for a variety of operating systems, including Windows, macOS, and Linux. Some compilers may be specific to certain operating systems, so it is important to check the compatibility before choosing a compiler for your project.

Question 4: How do I compile and run a Fortran program?

The exact process for compiling and running a Fortran program may differ depending on the compiler you are using. Generally, you will need to use a command prompt or terminal to navigate to the directory where your Fortran program is located. Then, you can use the appropriate compiler command (e.g. gfortran, ifort) followed by the name of your program file to compile it. Once the program is compiled, you can run it by typing the name of the executable file into the command prompt or terminal.

Question 5: What can I do if I encounter errors while compiling my Fortran program?

If you encounter errors while compiling your Fortran program, it is important to carefully read the error messages to determine the cause of the error. Common errors may include syntax errors, undefined variables, or incorrect function usage. You can consult the compiler's documentation or online resources for help troubleshooting these errors. Additionally, seeking assistance from a more experienced Fortran programmer or joining online forums and communities can also be helpful in resolving compiler errors.

Similar threads

  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
2
Replies
54
Views
4K
  • Programming and Computer Science
Replies
16
Views
5K
Back
Top