Tengo un fichero llamado newfortranFreeFormatFile.f en un proyecto de C++ con el siguiente contenido:
Código:
Fuente: http://www.uam.es/departamentos/cien...N/FORTRAN.htmlPROGRAM CALCULO_FACT INTEGER N REAL FACT, FACTORIAL READ (*,*) N FACT = FACTORIAL (N) PRINT *, FACT END FUNCTION FACTORIAL (N) INTEGER I, N REAL FACTORIAL, PROD PROD = 1.0 DO I = 2, N PROD = PROD * I END DO END
Cuando trato de compilarlo con NetBeans obtengo este error:
Cita:
¿Qué es lo que está mal?CLEAN SUCCESSFUL (total time: 880ms)
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
newfortranFreeFormatFile.f:8.1:
PROGRAM CALCULO_FACT
1
Error: Car�cter no num�rico en la etiqueta de declaraci�n en (1)
newfortranFreeFormatFile.f:8.1:
PROGRAM CALCULO_FACT
1
Error: Declaraci�n inclasificable en (1)
make: *** [build/Debug/MinGW-Windows/newfortranFreeFormatFile.o] Error 1
BUILD FAILED (exit value 2, total time: 2s)
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
newfortranFreeFormatFile.f:8.1:
PROGRAM CALCULO_FACT
1
Error: Car�cter no num�rico en la etiqueta de declaraci�n en (1)
newfortranFreeFormatFile.f:8.1:
PROGRAM CALCULO_FACT
1
Error: Declaraci�n inclasificable en (1)
make: *** [build/Debug/MinGW-Windows/newfortranFreeFormatFile.o] Error 1
BUILD FAILED (exit value 2, total time: 2s)
EDITO
Ya lo tengo, el problema era que la primera línea estaba sin tabular como el resto, ahora el código queda así:
Código:
y obtengo esta bonita salida:PROGRAM CALCULO_FACT INTEGER N REAL FACT, FACTORIAL READ (*,*) N FACT = FACTORIAL (N) PRINT *, FACT END FUNCTION FACTORIAL (N) INTEGER I, N REAL FACTORIAL, PROD PROD = 1.0 DO I = 2, N PROD = PROD * I END DO END
Cita:
Antes de nada aseguraros que tenéis C:\MinGW\bin, que es donde debería estar gfortran.exe, en la variable del sistema 'Path'.CLEAN SUCCESSFUL (total time: 1s)
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
BUILD SUCCESSFUL (total time: 2s)
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
BUILD SUCCESSFUL (total time: 2s)
EDITO DE NUEVO
He tenido más problemas, he añadido la ruta de la librería dinámica de Fortran, libgfortran-3.dll, en 'Additional Library Directories' y también he añadido la librería libgfortran-3.dll en 'Libraries' en Properties --> Build --> Linker.
Me daba estos errores:
Cita:
Tras hacer esto me daba estos otros errores:"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
CLEAN SUCCESSFUL (total time: 2s)
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x80): undefined reference to `_gfortran_st_read'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '20039', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x9d): undefined reference to `_gfortran_transfer_integer'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '28486', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xab): undefined reference to `_gfortran_st_read_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '24946', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xef): undefined reference to `_gfortran_st_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '11828', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x10c): undefined reference to `_gfortran_transfer_real_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '50', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x11a): undefined reference to `_gfortran_st_write_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '25966', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x13c): undefined reference to `_gfortran_set_args'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '29295', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x150): undefined reference to `_gfortran_set_options'
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
CLEAN SUCCESSFUL (total time: 2s)
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '0', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x80): undefined reference to `_gfortran_st_read'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '20039', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x9d): undefined reference to `_gfortran_transfer_integer'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '28486', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xab): undefined reference to `_gfortran_st_read_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '24946', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0xef): undefined reference to `_gfortran_st_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '11828', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x10c): undefined reference to `_gfortran_transfer_real_write'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '50', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x11a): undefined reference to `_gfortran_st_write_done'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '25966', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x13c): undefined reference to `_gfortran_set_args'
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: found dwarf version '29295', this reader only handles version 2 and 3 information.
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x150): undefined reference to `_gfortran_set_options'
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
Cita:
Después cambié el código de Fortran por esto:"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
CLEAN SUCCESSFUL (total time: 2s)
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o -L../../../../../MinGW/bin -lgfortran-3
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
rm -f -r build/Debug
rm -f dist/Debug/MinGW-Windows/pruebafortran.exe
rm -f *.mod
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
CLEAN SUCCESSFUL (total time: 2s)
"/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
"/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/pruebafortran.exe
make[2]: Entering directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
mkdir -p build/Debug/MinGW-Windows
rm -f build/Debug/MinGW-Windows/main.o.d
g++ -c -g -MMD -MP -MF build/Debug/MinGW-Windows/main.o.d -o build/Debug/MinGW-Windows/main.o main.cpp
mkdir -p build/Debug/MinGW-Windows
gfortran -c -g -o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o newfortranFreeFormatFile.f
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/pruebafortran build/Debug/MinGW-Windows/main.o build/Debug/MinGW-Windows/newfortranFreeFormatFile.o -L../../../../../MinGW/bin -lgfortran-3
c:/qtsdk/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: Dwarf Error: Offset (800) greater than or equal to (null) size (4954657).
build/Debug/MinGW-Windows/newfortranFreeFormatFile.o:newfortranFreeFormatFil e.f:(.text+0x120): multiple definition of `main'
build/Debug/MinGW-Windows/main.o:C:\Users\xxxx\Documents\NetBeansProjects\pr uebaFortran/main.cpp:15: first defined here
collect2: ld devolvi� el estado de salida 1
make[2]: *** [dist/Debug/MinGW-Windows/pruebafortran.exe] Error 1
make[2]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/c/Users/xxxx/Documents/NetBeansProjects/pruebaFortran'
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 5s)
Código:
El proyecto compila correctamente.FUNCTION FACTORIAL (N) INTEGER I, N REAL FACTORIAL, PROD PROD = 1.0 DO I = 2, N PROD = PROD * I END DO END
Saludos.