Gcc 在Cygwin中编译gfortran时出现问题,需要大量内存

Gcc 在Cygwin中编译gfortran时出现问题,需要大量内存,gcc,windows-8,compiler-errors,cygwin,fortran,Gcc,Windows 8,Compiler Errors,Cygwin,Fortran,我的计算机(intel core i7 CPU,20 GB RAM,2TB HDD)运行的是Windows 8,我通常会启动Linux虚拟机来进行编程,但我目前正在尝试使用Cygwin在Windows 8中本机运行Fortran程序。我正在编写一个需要大量内存的程序,我正在创建一个双精度数组,大小为13943 x Nfiles,在该数组中,我允许Nfiles发生变化,并试图使其尽可能大,同时仍保持在20 GB内存以下 我注意到,当我使用大约Nfiles=17000时,它使用了大约1.77GB的R

我的计算机(intel core i7 CPU,20 GB RAM,2TB HDD)运行的是Windows 8,我通常会启动Linux虚拟机来进行编程,但我目前正在尝试使用Cygwin在Windows 8中本机运行Fortran程序。我正在编写一个需要大量内存的程序,我正在创建一个双精度数组,大小为
13943 x Nfiles
,在该数组中,我允许Nfiles发生变化,并试图使其尽可能大,同时仍保持在20 GB内存以下

我注意到,当我使用大约
Nfiles=17000
时,它使用了大约1.77GB的RAM。但是,当我将
Nfiles
提高到20000时,我会得到一个编译错误

gfortran -ffixed-line-length-132 -fimplicit-none -O2   -o smear_sfs.exe xdriver.F90 modules.o
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/crtbegin.o:cygming-crtbegin.c:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetModuleHandleA' defined in .idata$5 section in /usr/lib/w32api/libkernel32.a(dysgbs00548.o)
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/crtbegin.o:cygming-crtbegin.c:(.text+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `__imp_GetProcAddress' defined in .idata$5 section in /usr/lib/w32api/libkernel32.a(dysgbs00598.o)
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/4.8.1/crtbegin.o: bad reloc address 0x0 in section `.pdata'
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/../../../../x86_64-pc-cygwin/bin/ld: final link failed: Invalid operation
collect2: error: ld returned 1 exit status
Makefile:30: recipe for target `smear_sfs' failed
make: *** [smear_sfs] Error 1
但在网上搜索后,我无法找出问题所在
gfortran-v
显示以下信息

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.1-3/src/gcc-4.8.1/configure --srcdir=/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.1-3/src/gcc-4.8.1 --prefix=/usr --exec-    prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --disable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symvers --with-ecj-jar=/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib
Thread model: posix
gcc version 4.8.1 (GCC)
看来我在64位操作系统上正确地使用了64位编译器


有什么想法吗?

64位编译器默认情况下仍然使用32位寻址。有关详细信息,请在编译器文档或本网站上搜索
-mcmodel=medium
。或者,您可以动态分配数组,而不是声明静态数组。我尝试了动态分配,我可以超过20000标记,但当我大约达到50000标记时,我得到一个
程序接收信号SIGSEGV:Segmentation fault-无效内存引用。
错误。我知道当我用一个较小的数字运行它时,它可以正常工作,所以我怀疑这是一个逻辑错误。segfault可能是由很多事情引起的。我建议您启用调试符号、运行时检查和trackback,然后再次运行(如果速度太慢,请先使用较小的数字)。