fortran常见问题解决
Fortran-运行中给出的系统错误及解决方法

. Fortran 运行中给出的系统错误及解决方法以下均为linker tools errors and warningsLinker Tools Error LNK1000unknown error; consult documentation for technical support options Note the circumstances of the error, try to isolate the problem and create a reproducible test case, then contact technical support.Linker Tools Error LNK1101incorrect MSPDBxx.DLL version; recheck installation of this product The version of MSPDBxx.DLL available on your system does not match the version required by this tool.Linker Tools Error LNK1102out of memoryThere was not enough memory for the tool to run. Probably the paging file exceeded available disk space. If a shortage of disk space is not the cause, note the circumstances of the error, try to isolate the problem and create a reproducible test case, then request technical support.Linker Tools Error LNK1103debugging information corrupt; recompile moduleProbably the compilation was terminated before a valid object file was created.Recompile the given object file. If recompiling does not correct the problem,note the circumstances of the error, try to isolate the problem and create a reproducible test case, then consult technical support.Linker Tools Error LNK1104cannot open file "filename"The tool could not open the given file. One of the following may be a cause:l There was not enough disk space.l The file does not exist.l The filename or its path was incorrectly specified.l The specified drive is invalid.l The file does not have the appropriate permissions.l The path for filename expands to more than 260 characters.l If the given file is named LNKn, which is a filename generated by the linker for a temporary file, then the directory specified in the TMP environment variable may not exist, or more than one directory is specified for the TMP environment variable. (Only one directory path should be specified for the TMP environment variable.) l If the error occurs on the executable filename, an earlier version of the executable may still be running. You will need to terminate the executable before linking it. In Windows NT (including Windows 2000) or Windows 95,you can use the utility PVIEWto look for and kill instances of the application.l If the error message occurs for a library name, and you recently ported the .MAK file from a previous Microsoft Visual C++ developmentLinker Tools Messages Page 3 of 37environment, the library may no longer be valid. Ensure that the library still exists in this circumstance.l If the error message occurs for a library name such as CONSOLE.LIB, and you included object modules from an older Fortran developmentenvironment such as Microsoft Fortran PowerStation, recompile all source files with Visual Fortran to create new object files and libraries.Linker Tools Error LNK1105cannot close file "filename"The tool could not close the given file. Possibly there was insufficient disk space available.Linker Tools Error LNK1106invalid file or disk full: cannot seek to locationThe tool could not read or write to location in a memory-mapped file:l Your disk may be too full to complete the link. Free up some space and try the link again.l The error may be a result of trying to link over a network. Some networks do not fully support the memory-mapped files used by the linker. Try linking on your local disk to see if that fixes the problem.l There may be a bad block on your disk. Although the operating system and disk hardware should have detected such an error, you may want to run a disk checking program.Linker Tools Error LNK1107invalid or corrupt file: cannot read at locationThe tool could not read the file. Recreate the file.Linker Tools Error LNK1108cannot write file at locationThe tool could not write to the file. One of the following may be a cause:l There was not enough disk space to create the file.l The drive being written to was not available, possibly due to a network problem.Linker Tools Error LNK1109cannot remove file "filename"LIB could not delete the given file. Before LIB writes the new version of a library, it removes the existing library file. One of the following may be a cause:l The given file does not have the appropriate permissions.l The drive containing the file was not available, possibly due to a network problem.Linker Tools Error LNK1110Linker Tools Messages Page 4 of 37cannot rename file "filename"LIB could not rename the given file. When LIB builds a new version of a library, it creates a temporary file, then renames the file. One of the following may be a cause:l The given file does not have the appropriate permissions.l The drive containing the file was not available, possibly due to a network problem.Linker Tools Error LNK1111invalid /BASE argument "argument"The /BASE option was incorrectly specified. Either no argument was specified or argument is not a number.Linker Tools Error LNK1112module machine type "type1" conflicts with target machine type "type2"The object files specified as input were compiled for different machine types.Linker Tools Error LNK1113invalid machine typeThe machine type specified in the object header is not valid. Probably the file is corrupt. Rebuild the object. See Corrupt Object File for more information.Linker Tools Error LNK1115/MACHINE option requiredLINK or LIB cannot determine the machine type for objects that are provided entirely from libraries. Either specify the /MACHINE option with the appropriate machine type or specify at least one object file in the input.Linker Tools Error LNK1117syntax error in option "option"The given option was not correctly specified.Linker Tools Error LNK1118syntax error in keyword statementThe given module-definition statement was not correctly specified.Linker Tools Error LNK1119invalid ordinal number "argument"The argument following the at sign (@) in an ordinal specification was not a valid number. An ordinal number is an optional argument in either an /EXPORT option in a LINK or LIB command or an EXPORTS statement in a moduledefinitionfile. It is an index into the exports table. The number must be aninteger in the range 1-65535.Linker Tools Error LNK1120number unresolved externalsLinker Tools Messages Page 5 of 37Error LNK1120 gives you a count (number) of unresolved externals for this link. The conditions that cause unresolved externals are described with errorLNK2001 (see Linker Errors LNK2001 to LNK2014), which precedes this error message (once for each unresolved external).Linker Tools Error LNK1121duplicate ordinal number "number"The given ordinal number was specified more than once in either an /EXPORT option in a LINK or LIB command or an EXPORTS statement in a moduledefinition file. Ordinal numbers must be unique integers in the range 1-65535.Linker Tools Error LNK1123failure during conversion to COFF: file invalid or corruptThe object or resource could not be converted to COFF. This tool requires the format of all input files to be COFF. If an input file is not COFF, the tool runs aconversion tool, either CVTOMF (to convert 32-bit OMF objects) or CVTRES (to convert resource files). This error is preceded by errors or warnings from the conversion tool. One of the following may be a cause:l The file is corrupt.l The file is not a valid file type. An example of an invalid type is a 16-bit OMF object.Linker Tools Error LNK1127library is corruptThe library file is corrupt. Rebuild the library.Linker Tools Error LNK1129cannot find resolution for weak extern symbolThe given weak external symbol does not have a default resolution. Probablythe symbol table is corrupt. Rebuild the object file. See Corrupt Object File for more information.Linker Tools Error LNK1130Linker miscalc (base relocations off by number)There was not enough space in the image to write base relocations.Linker Tools Error LNK1131no library file specifiedThe LIB /EXTRACT command required a library as input, but a library filename was not specified.Linker Tools Error LNK1132invalid format for MS-DOS stub file "filename"The filename specified with the /STUB option was not a valid real-mode MS-DOS executable (.EXE) file.Linker Tools Messages Page 6 of 37Linker Tools Error LNK1136invalid or corrupt fileThe input file either has a corrupt header or is zero size or abnormally small. See Corrupt Object File for more information.Linker Tools Error LNK1137invalid argument specified with /SECTIONEither the name or the attributes argument to the /SECTION option is specified incorrectly.Linker Tools Error LNK1140too many modules for program database; relink with /PDB:NONEThe project contains more than 4096 modules. One of the following is asolution:l Relink using /PDB:NONE.l Compile some modules without debugging information.l Reduce the number of modules.Linker Tools Error LNK1141failure during build of exports fileLINK could not build the exports (.EXP) file. Causes of this error include system problems such as insufficient memory and syntax errors in options or moduledefinitionstatements. This error is preceded by another error that givesadditional information.Linker Tools Error LNK1143invalid or corrupt file: no symbol for COMDAT section numberThe object file is corrupt. Rebuild the file. See Corrupt Object File for more information.Linker Tools Error LNK1144error with LINK_REPRO var; cannot open "filename"The linker could not create filename. One of the following may be a cause:l Check that you've set your LINK_REPRO environment variable to anexisting directory and not the current directory.l Make sure there are no read-only files in the directory.l Make sure none of the files in the LINK_REPRO directory are open byanother process, because the linker needs to write to them.Linker Tools Error LNK1145/MERGE created circular link for section "section"You attempted to merge a section into itself. Check the /MERGE options.Linker Tools Error LNK1146Linker Tools Messages Page 7 of 37no argument specified with option "option"The given option requires an argument.Linker Tools Error LNK1147invalid number specified with option "option"The argument to the given option was specified incorrectly.Linker Tools Error LNK1148failure during conversion to COFF: cannot copy temp file filenameEDITBIN could not convert the input file to COFF. When EDITBIN converts a file, it creates a temporary file, then copies the file. One of the following may be a cause:l The given file does not have the appropriate permissions.l There was not enough disk space to create the file.l The drive being written to was not available, possibly due to a network problem.Linker Tools Error LNK1149output filename matches input filename "filename"The output filename specified with the /OUT or /IMPLIB option was the same asan input file.Return to Main Linker Error PageLinker Errors LNK1152 to LNK1189Linker Tools Error LNK1152cannot resolve one or more undecorated symbolsThis error is preceded by one warning LNK4022 for each undecorated symbolthat could not be resolved and by at least two warnings LNK4006 for theduplicate symbols found for the undecorated symbol.Linker Tools Error LNK1153/VXD command-line option requiredYou attempted to build a virtual device driver without the /VXD option. Relink with the /VXD option.Linker Tools Error LNK1154specified import library filename matches exports file "filename"The filename specified with LINK /IMPORT or with LIB /DEF /OUT conflicted with the filename given by LINK or LIB to the exports file, which is formed from the base name of the main output file and the extension .EXP.Linker Tools Error LNK1155special symbol "symbol" already definedLinker Tools Messages Page 8 of 37The given symbol is reserved for use by LINK.Linker Tools Error LNK1156.sbss section not supportedAn object file contained an .sbss section.Linker Tools Error LNK1157fixup overflow; offset of target symbol "symbol" greater than +-8MBThe VXD is too large, or the sections are not arranged properly.Linker Tools Error LNK1158cannot run "filename"The given executable file called by LINK is not in the directory that contains LINK and is not in a directory specified in the PATH environment variable. Linker Tools Error LNK1159no output file specifiedNo name was specified for the main output file (executable file or DLL). LINK derives the default name of the output file from the base name of the first object file. If no object files are specified, and if the /OUT option is not used, this error occurs.Linker Tools Error LNK1160library with zero objects not allowedAn attempt was made to remove an object from a library that contained onlythat object. The object was not removed.Linker Tools Error LNK1161invalid export specificationEither the /EXPORT option or the EXPORTS module-definition statementincorrectly specified an export. A possible cause is a typing error.Linker Tools Error LNK1162expected aux symbol for comdat section numberThe linker expected to find an auxiliary symbol table for the indicated COMDAT but could not. The object file is probably corrupt. See Corrupt Object File for more information.Linker Tools Error LNK1163invalid selection for comdat section numberThe byte in the object file indicating the type of COMDAT section is invalid. The object file is probably corrupt. See Corrupt Object File for more information. Linker Tools Error LNK1164section section alignment (number) greater than /ALIGN valueThe alignment size for the given section in the object file exceeds the value specified with the /ALIGN option. The /ALIGN value must be a power of 2 and Linker Tools Messages Page 9 of 37must equal or exceed the section alignment given in the object file. Either recompile with a smaller section alignment or increase the /ALIGN value.Linker Tools Error LNK1165link failed because of fixup errorsThe build failed due to fixup errors. The /FORCE or /FORCE:UNRESOLVED option overrides this error.Linker Tools Error LNK1166cannot adjust code at offset=offset, va=valueLINK was unable to pad the code as required. Certain instructions are not allowed to cross page boundaries on some processors. LINK attempts to addpads to correct this situation. In this case, LINK could not work around the problem.Linker Tools Error LNK1167file contains relocs but header has no machine typeA converted COFF object did not have a machine type specified in its header. One cause of this error is omitting a machine type when converting a .RES file in a separate step before linking.Linker Tools Error LNK1168cannot open filename for writingThe given file does not have write permission.Linker Tools Error LNK1169one or more multiply defined symbols foundThe build failed due to multiple definitions of one or more symbols. This error is preceded by error LNK2005. The /FORCE or /FORCE:MULTIPLE option overridesthis error.Linker Tools Error LNK1170line in command file contains limit or more charactersThe length of a line in a command file must be less than the given limit. Linker Tools Error LNK1171unable to load filenameThe given DLL was unavailable. The possible locations for the DLL are the current directory, the system directory, the Windows directory, and the directories specified in the PATH environment variable.Linker Tools Error LNK1172more than one object with the name "object" found; rename object(s) orrelink /PDB:NONEA library contained two or more objects with the same name. Do one of the following:Linker Tools Messages Page 10 of 37l Rename the objects using unique names and rebuild the library.l Link using the /PDB:NONE option.Linker Tools Error LNK1173unable to find entrypoint function in filenameThe given function does not exist in the given DLL.Linker Tools Error LNK1174unable to /REBASE filename; not a valid Win32 imageThe format of the given file was invalid.Linker Tools Error LNK1175failed to /REBASE filenameThe rebase operation failed on the given file.Linker Tools Error LNK1177TOC size limit exceededThe linker was unable to create a TOC (Table of Contents) in your image file. The limit is 2048 entries in the TOC.Linker Tools Error LNK1178missing MODEND record; file is invalid or corruptThe linker tool tried to convert an OMF object module to COFF format but could not find an expected MODEND (module end) record in the OMF object. The OMF object module is corrupt and needs to be recreated or recopied. See Corrupt Object File for more information.Linker Tools Error LNK1179invalid or corrupt file: duplicate comdat comdatAn object module contained two or more COMDATs with the same name. Onepossible cause is if you use the Visual C++ /H option with the Visual C++ /Gy option. The /H option limits the length of external names, and the /Gy option packages functions in COMDATs.Linker Tools Error LNK1180insufficient disk space to complete linkThe linker tool was unable to complete a file operation since the operating system reported that the disk is full. Free up space on your local and network drives (if you are writing files there).Linker Tools Error LNK1181cannot open input file "filename"The linker tool could not find "filename" because it does not exist or the path was not found.Linker Tools Error LNK1182Linker Tools Messages Page 11 of 37cannot have more than 64K exportsYou have reached the linker's limit of 65,536 exports.Linker Tools Error LNK1183invalid or corrupt file: extended relocation count number less than 65535The COFF object file is corrupt since it contains an extended relocation count that is less than 0xFFFF. See Corrupt Object File for more information.Linker Tools Error LNK1184invalid section name "section" specified in option or directive "option"You gave the linker an invalid section name in option. Invalid section names contain "$" or blanks.Linker Tools Error LNK1185invalid section name "section" specifiedYou gave the linker an invalid section name in a .DEF file. Invalid section names contain "$" or blanks.Linker Tools Error LNK1186invalid or corrupt COFF object; reloc to undefined static symbol "symbol"Your COFF object module is corrupt since it contains a relocation entry for an undefined static symbol. See Corrupt Object File for more information.Linker Tools Error LNK1187Corrupt object - unmatched name relocation; ignoredYour object file contains bad relocation information. Recopy or recreate the object file. See Corrupt Object File for more information.Linker Tools Error LNK1188BADFIXUPSECTION:: invalid fixup target "symbol"; possible zero length section This message is issued only for VxD links when the target of a relocation does not have a section. With LINK386 (an older version), an OMF GROUP record (generated by a MASM GROUP directive) may have been used to combine thezero length section with another non-zero length section. COFF format does not support the GROUP directive and zero-length sections. When LINK automatically converts this type of OMF objects to COFF, this error may occur.Linker Tools Error LNK1189LIBTOOMANYMEMBERS:: library limit of number objects exceededThe limit of 65535 objects or members in a library has been exceeded.Return to Main Linker Error PageLinker Errors LNK1190 to LNK1581Linker Tools Error LNK1190Linker Tools Messages Page 12 of 37invalid fixup found, type typeThe object file has become corrupted. Recompile.Linker Tools Error LNK1194cannot delay-load dll name due to import of data symbol symbol name; relink without /DELAYLOAD:dll nameYou cannot delay load a DLL if data is imported from it.Linker Tools Error LNK1195target machine "machine" requires "option"Add the required option.Linker Tools Error LNK1196invalid or corrupt import object: unknown versionThe import library has become corrupted. Rebuild the library.Linker Tools Error LNK1197invalid or corrupt import object: unknown typeThe import library has become corrupted. Rebuild the library.invalid or corrupt import object: unknown name typeThe import library has become corrupted. Rebuild the library.Linker Tools Error LNK1199invalid or corrupt import object: non-zero reserved fieldsThe import library has become corrupted. Rebuild the library.Linker Tools Error LNK1200error reading program database "filename"The given program database (PDB) could not be read, probably because it is corrupted. If filename is the PDB for an object file, recompile the object file; usethe /debug:full and /pdbfile options. If filename is the PDB for the main output file and this error occurred during an incremental link, delete the PDB and relink.Linker Tools Error LNK1201error writing to program database "filename"; check for insufficient disk space LINK could not write to the program database (PDB) for the output file. One of the following may be a cause:l The file is corrupted. Delete filename and relink.l There was not enough disk space to write to the file.l The drive being written to was not available, possibly due to a network problem.Linker Tools Error LNK1202Linker Tools Messages Page 13 of 37"filename" missing debugging information for referencing moduleThe given program database (PDB) for an object file was invalid. Recompile the object file; use CL's /Zi option.Linker Tools Error LNK1203"filename" missing current debugging information for referencing moduleThe given program database (PDB) for an object file was invalid. Recompile the object file; use CL's /Zi option.Linker Tools Error LNK1204"filename" compiled /Yc /Yu /Z7; cannot create PDB; recompile with /Zi Multilayered program databases (PDBs) are not supported in combination withold-style debugging information. Recompile using CL's /Zi option.Linker Tools Error LNK1206cannot overwrite Visual C++ 1.0 PDB "filename"; delete and rebuildThis version of LINK cannot write to an existing program database (PDB)created using older versions of the visual development environment. Delete filename and rebuild.Linker Tools Error LNK1207incompatible PDB format in "filename"; delete and rebuildThis version of LINK cannot write to the existing program database (PDB).Delete filename and rebuild.program database "filename" differs from previous link; relink or rebuildThe given program database (PDB) is invalid and possibly corrupt. Relink. If filename is also the PDB for an object file, recompile to recreate the PDB. Linker Tools Error LNK1210insufficient memory for incremental link; relink with /INCREMENTAL:NOThere was not enough virtual memory available for LINK to create the incremental status (.ILK) file.Linker Tools Error LNK1211precompiled type information not found; "filename" not linked or overwritten The given object file, compiled with /Yc, either was not specified in the LINK command or was overwritten.Linker Tools Error LNK1212error opening program database; file is in useThe PDB is already in use by another application.Linker Tools Error LNK1213unexpected import object encounteredThe import library has become corrupted. Rebuild the library.Linker Tools Messages Page 14 of 37Linker Tools Error LNK1221a subsystem can't be inferred and must be definedThe linker does not have enough information to infer which subsystem you will target your application. To fix this error, use the /SUBSYSTEM option.Linker Tools Error LNK1561entry point must be definedThe symbol specified by the /ENTRY option is not defined.Linker Tools Error LNK1581corrupted object or old compiler (bad Pcode entry point)Your object file contained a bad entry point. The object file is probably corrupt.(注:可编辑下载,若有不当之处,请指正,谢谢!)。
fortran 排除错误

安装好VISUAL FORTRAN后1、运行Developer studio即可开始编译FORTRAN程序2、选择File菜单中的New选项3、在弹出的对话框选择projects标签,其他标签不用管,projects格式选用Fortran console application;在project name里命名(最好英文名),点击“ok ”4、接下来画面中,选择“an empty project”,点击“finish”5、接下来画面点击“ok”6、再选择一次File菜单中的new7、对话框选用files标签,选择Fortran free format source file ,并在file里命名8、点击“ok”Source Files 放源文件(.c、.cpp)程序的实现代码全放在这里Header Files 放头文件(.h)声明放在这里Resource Files 资源文件(.rc)放图标、图片、菜单、文字之类的,主要用来做界面的东东一般都放这里External Dependencies 除上三种以外的,程序编译时用到的文件全放这里fortran内部函数出错信息解释内部函数出错信息解释[sourcefile(line)]run-time error M62××MATH错误号函数级数学错误信息M6201 functionnames:DOMAIN error函数的自变量超出了约定的取值域,例如sqrt(-1)M6202 functionname:SING error无意义的变量。
例如log10(0)M6203 functionname:OVERFLOW error函数的结果值或其中一个既时计算值太大以致不能表示,例如EXP(250000.0) M6204 functionname:UNDERFLOW error函数的结果值或其中一个既时计算值太小以致不能表示。
M6205 functionname:TLOSS error完全丢失精度,例如COS(1E30)M6206 functionname:PLOSS errorfortran debug模式设置和技巧CVF中有两种编译(连接、执行)模式:release模式和debug模式。
fortran常见错误

FAQ之常见错误2014-02-02 13:45:35 来源:Fcode研讨团队评论:2点击:4419本文从编译错误,链接错误,运行时错误,计算结果错误等四个方面介绍了常见的错误及解决思路。
适合初学者阅读。
首先应该明确:错误有哪几种?我们当前遇到的是何种错误?阐述这些问题前,我们先讨论一下常规的应用程序开发的过程:1>>编写代码,使用一个或多个源代码文件。
2>>对第一步的每一个源代码文件执行编译操作。
得到一个或若干个目标代码。
3>>将目标代码,运行时库(Run-time Library)和其他使用到的函数库链接起来。
得到一个可执行文件(EXE 或其他)4>>编写程序的说明书,必要的(输入)数据文件5>>将上述得到的结果发布给用户。
(发布的方式可以是刻录成光盘,销售,放在网站上供别人下载,或者其他)6>>用户得到程序后,运行,输入数据,得到计算结果。
对于很多 Fortran 程序员来说,可能用户就是自己,也可能仅仅是自己教研室的同事同学。
所以第4,5,6步骤很多时候不明显。
而如果使用集成开发环境(IDE)进行开发,第1,2,3步骤又可以一键完成。
因此,很多初学者就认为,写程序就是:输入代码,运行,得到结果。
这样的理解太狭义。
不管我们面对什么使用者来写代码,程序开发应该是上述的过程。
我们的编译器,编译环境,也是为这个过程而设计的。
于是,我们将错误分为四种:一. 编译错误(发生在第2步)编译错误,一般是源代码书写格式不正确,不符合语法要求。
二. 链接错误(发生在第3步)链接错误,一般是源代码结构不完整,运行时库或函数库使用不合理。
三. 运行时错误(发生在第6步)运行时错误,一般是执行代码时,遇到了事先未料及的错误。
比如内存不足了,磁盘空间不够了,输入文件格式不对了,输出文件写入失败了等等。
四. 计算结果不符合预期(程序代码不规范,或不符合你的设想)计算结果不符合预期,可能性就很多了。
fortran常见错误及其原因

常见fortran错误1. Incrementally linked image--PC correlation disabled.!编译终止2. forrtl: severe (157): Program Exception - access violation!The program tried to read from or write to a virtual address for which it does not have the appropriate access. Try recompiling with the /check:bounds and /warn:argument_checking options set, to see if the problem is an out-of-bounds memory reference or a argument mismatch that causes data to be treated as an address.Other causes of this error include:Mismatches in C vs. STDCALL calling mechanisms, causing the stack to become corrupted References to unallocated pointers Attempting to access a protected (for example, read-only) address3 "forrtl: severe (64): input conversion error, unit 2, file D:\FORTRAN2\testi!文件testi正在读写,直到读写到2时错误。
举例:程序想读写整数,却碰到变量故终止。
4 error LNKZOOI : unresolved external symbol _ SN @ 4 fatal error LNKllZO : 1 unresolved externals! 出现了未指定的外部函数符号Sn 。
fluent问题解决方法

Fortran FAQ

1.1 FAQ之常见错误本文从编译错误,链接错误,运行时错误,计算结果错误等四个方面介绍了常见的错误及解决思路。
适合初学者阅读。
首先应该明确:错误有哪几种?我们当前遇到的是何种错误?阐述这些问题前,我们先讨论一下常规的应用程序开发的过程:1>>编写代码,使用一个或多个源代码文件。
2>>对第一步的每一个源代码文件执行编译操作。
得到一个或若干个目标代码。
3>>将目标代码,运行时库(Run-time Library)和其他使用到的函数库链接起来。
得到一个可执行文件(EXE 或其他)4>>编写程序的说明书,必要的(输入)数据文件5>>将上述得到的结果发布给用户。
(发布的方式可以是刻录成光盘,销售,放在网站上供别人下载,或者其他)6>>用户得到程序后,运行,输入数据,得到计算结果。
对于很多Fortran 程序员来说,可能用户就是自己,也可能仅仅是自己教研室的同事同学。
所以第4,5,6步骤很多时候不明显。
而如果使用集成开发环境(IDE)进行开发,第1,2,3步骤又可以一键完成。
因此,很多初学者就认为,写程序就是:输入代码,运行,得到结果。
这样的理解太狭义。
不管我们面对什么使用者来写代码,程序开发应该是上述的过程。
我们的编译器,编译环境,也是为这个过程而设计的。
于是,我们将错误分为四种:一. 编译错误(发生在第2步)编译错误,一般是源代码书写格式不正确,不符合语法要求。
二. 链接错误(发生在第3步)链接错误,一般是源代码结构不完整,运行时库或函数库使用不合理。
三. 运行时错误(发生在第6步)运行时错误,一般是执行代码时,遇到了事先未料及的错误。
比如内存不足了,磁盘空间不够了,输入文件格式不对了,输出文件写入失败了等等。
四. 计算结果不符合预期(程序代码不规范,或不符合你的设想)计算结果不符合预期,可能性就很多了。
语法与你的想法不一致,超出函数库的适用范围,执行流程控制不当等等。
fortran90常见错误

1、运行fortran时出现forrt1:severe<59>:list-directed I/O syntax error,unit 1,file G:\1\1\meat.dat怎么办这是通道1 ,链接到文件meat.dat 的读写出错了。
这问题你得认真检查类似read( 1 , * ) 或write( 1 , * ) 这样的语句,错误原因挺多的。
比如二进制文件用了文本方式读取,比如变量列表与文件不匹配。
问:另外forrt1:severe<161>:program exception -array bounds exceeded是怎么回事?回答:数组越界,也是很常见的错误。
比如real a(100)如果你使用了a(101) 就会越界,因为a 数组只有100 个元素。
2、fortran运行提示error M6201:math-**,现将代码贴出,求高手帮忙看看,急求解答!我不能确定你的错误是怎么引起的。
可能咱们的编译器不同。
你的代码在我这里的问题是:虚参和实参精度不同。
在程序中,你定义了部分real*8,但是对应的虚参和返回值却定义为real。
比如主程序里的z1(双精度),传入函数g里面的x却定义为单精度。
主程序Do 死循环了。
z2_jiashe 和 z2_suan 每一次循环都没有发生改变,于是永远跳不出循环。
我给你的建议是:同一个程序,统一使用real*8 或real*4,尽量不要混用,除非你很自信能理清他们的关系。
检查Do 循环,尤其是z2_jiashe 和z2_suan,是否应该每次循环不同?fortran_排除错误(2012-04-20 23:22:44)安装好VISUAL FORTRAN后1、运行Developer studio即可开始编译FORTRAN程序2、选择File菜单中的New选项3、在弹出的对话框选择projects标签,其他标签不用管,projects格式选用Fortran console application;在project name里命名(最好英文名),点击“ok ”4、接下来画面中,选择“an empty project”,点击“finish”5、接下来画面点击“ok”6、再选择一次File菜单中的new7、对话框选用files标签,选择Fortran free format source file ,并在file里命名8、点击“ok”数Source Files 放源文件(.c、.cpp)程序的实现代码全放在这里Header Files 放头文件(.h)声明放在这里Resource Files 资源文件(.rc)放图标、图片、菜单、文字之类的,主要用来做界面的东东一般都放这里External Dependencies 除上三种以外的,程序编译时用到的文件全放这里fortran内部函数出错信息解释内部函数出错信息解释[sourcefile(line)]run-time error M62××MATH错误号函数级数学错误信息M6201 functionnames:DOMAIN error函数的自变量超出了约定的取值域,例如sqrt(-1)M6202 functionname:SING error无意义的变量。
fortran常见错误及其原因

常见fortran错误1.Incrementally linked image--PC correlation disabled.!编译终止2. forrtl:severe(157):Program Exception - access violationbounds and /warn:argument_checking options set, to see if theproblem is an out-of-bounds memory reference or a argument mismatch that causes data to be treated as anaddress.Other causes of this error include:severe(64):input conversion error, unit 2, file D:\FORTRAN2\testi!文件testi正在读写,直到读写到2时错误。
举例:程序想读写整数,却碰到变量故终止。
4 error LNKZOOI :unresolved external symbol _ SN @ 4 fatal error LNKllZO :1 unresolved externals!出现了未指定的外部函数符号Sn。
这是因为在函数子程序中错把函数名Sn写成了ns。
根据错误信息中的提示,用户在编辑窗口寻找有错位置进行修改。
连接错误往往出现在有函数调用或子程序调用的程序中,常见的错误性质有:未定的函数符号、找不到主程序或子程序、实参与虚参的个数不一致等。
注意:连接错误只给出错误代号和错误性质,不给出具体语句的行号。
5 :: error FOR229O :implicit type for 1 detected between 1 and = C :\ abc.: error FOR33Og :undefined label 10编译系统提示用户:在程序的第5行,变量i未经类型说明;在程序的第H行,标号10未定义。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
楼主为了减少重复回答问题,特编此帖,并不定期添加和更新内容。
错误难免,欢迎讨论,仅供参考。
很多人问哪里可以找到Fortran编译器,有不少热心学友提供网址,特汇集在这里。
虽然俺检验过这些链接,但是它们不一定总有效。
Fortran编译器下载:CVF?FTN95(License:Freeforpersonaluse)以下操作,如无特别说明,都是以为例。
1.如何加大Stacksize?选Project=>Settings=>Link=>Category:Output=>?StackallocationsReserve:这里填新值(默认为1M,若需要10M,则填)2.如何用Fortran批量生成文件?设要生成4000个文件,文件名为AA1-AA4000,如何写循环生成文件,而不用写4000次write 命令呢?用内部文件:character(len=80)::filename,forminteger::idoi=1,4000selectcase(i)case(1:9)write(form,'(i1)')icase(10:99)write(form,'(i2)')icase(100:999)write(form,'(i3)')icase(1000:9999)write(form,'(i4)')iendselectwrite(filename,*)"AA",trim(form),".TXT"open(10,file=filename)write(10,*)iclose(10)enddo?stopend3.如何用Fortran动态生成输出格式?设有一个数组data(100),输出时,希望每行输出num个数,而num由用户输入,如何实现?用内部文件:character(len=80)::formreal::data(100)integer::i,numdata=(/(i,i=1,100)/)/read(*,*)numwrite(form,*)"(",num,""write(*,form)datastopend4.MS是不是很垃圾?是垃圾,其中Bug太多,多到不可用的地步!在这个主题里,换了CVF后问题就没了的人已有相当的数目。
如果你用,遇到莫名其妙的错误,建议换,这是一个比较成熟的编译器。
5.如何用F90/95生成随机数?注意:现在计算机产生的随机数都是伪随机数。
random_number(x)产生一个0到1之间的随机数(x可以是向量),但是每次总是那几个数。
用了random_seed()后,系统根据日期和时间随机地提供种子,使得随机数更随机了。
programrandomimplicitnonereal::xcallrandom_seed()!系统根据日期和时间随机地提供种子callrandom_number(x)!每次的随机数就都不一样了write(*,*)xstopendprogramrandom6.函数/子程序超载的例子设要编一个两个变量值互换的子程序swap(a,b),哑元a,b可能是实型数,整型数,数组,矩阵,字符串,派生类型等等。
但是希望只用一个子程序接口swap(a,b)来实现。
F90可以用类属接口来实现这种子程序超载:moduleUtilitiesimplicitnoneprivateI_Swap,R_Swap,RVec_Swap,RMat_Swap,Type_Swappublic::SwapinterfaceSwapmoduleprocedureI_Swap,R_Swap,RVec_Swap,RMat_Swap,Type_Swapendinterfacecontainssubroutinei_swap(a,b)!整型置换integer(ikind),intent(inout)::a,binteger(ikind)::t。
!略endsubroutinei_swapsubroutiner_swap(a,b)!实型置换real(rkind),intent(inout)::a,breal(rkind)::tt=aa=bb=treturnendsubroutiner_swapsubroutineRVec_swap(a,b)!实型向量置换real(rkind),intent(inout)::a(:),b(:)integer(ikind)::idoi=1,size(a)callR_Swap(a(i),b(i))enddoreturnendsubroutineRVec_swapsubroutineRMat_swap(a,b)!实型矩阵置换。
!略endsubroutineRMat_swapsubroutineType_swap(a,b)!派生类型置换。
!略endsubroutineType_swapendmoduleUtilities7.如何在CVF中为多行代码加注释?见:8.推荐好的代码风格根据F90子集语言ELF90和F的要求整理(部分)。
“强迫用”的语言特性:+F90的自由格式的源代码。
+implicitnone。
+子过程的哑元都要有intent属性。
+函数子程序的哑元必须指定为intent(in)。
+所有子程序和函数都放在模块(module)中,然后引用(use)该模块;或者放在program 中。
+数组哑元要求是假定形状的,或者有固定的维数和大小。
字符哑元要求是假定长度的。
+对于recursivefunction(递归函数)语句,必须有result子句。
+在所有派生类型(type)的定义语句中,必须用双冒号分隔符(::)。
+主程序要求有program语句。
+在程序单元的end语句中要求后跟程序单元的类型和名称。
+在endtype语句中要求后跟类型的名称。
+endprogram前必须有stop语句以表示停止执行。
+子过程中必须有return语句,以表示返回。
+subroutines()并且calls(),即必须有括号。
“不得用”的语言特性:-allocatable、intent、pointer、save、dimension、parameter和target语句形式。
(用属性形式代替。
)-external语句形式。
(用显式的接口代替。
)-assign、赋值goto、交错return、continue、entry、和计算goto语句。
-include文件。
(用模块代替。
)-data和blockdata。
(在类型声明语句中进行初始化或赋值。
)-common块。
(将全局数据放在模块中,用模块代替。
)-equivalence。
(被认为是许多难以查找的编程错误的来源。
)-doubleprecision语句。
(用real语句声明双精度的实型数。
)-语句函数。
(用内部函数代替。
)-专用固有函数。
(用类属函数代替。
)-假定大小数组。
(用假定形状数组代替。
)-don(其中n为语句标号)。
(用do和enddo代替。
)-非整数do变量和表达式。
-同一行上多条语句。
-逻辑型case表达式。
-从if块外面分支到endif。
-where语句形式。
(用where结构形式。
)-在open和inquire语句中的blank=说明符。
-双字关键词之间要求有空格:inout,goto。
不能写为inout,goto。
9.将字符串改为大写的子程序subroutineUpCase(str)!=========================================!changetouppercase!=========================================character(len=*),intent(inout)::strinteger(4)::icha,LL,icvalinteger(4),parameter::diff=ichar('a')-ichar('A')LL=len_trim(str)doicha=1,LLicval=ichar(str(icha:icha))if(icval>=ichar('a').and.icval<=ichar('z'))thenstr(icha:icha)=char(icval-diff)endifenddoreturnendsubroutineUpCase10.CVF中源代码信息浏览默认情况下,代码信息浏览是失效的(GotoDefinition/Reference都不起作用),你可以将其启用:1.Project/Settings/Fortran,选中GenerateSourceBrowseInformation。
2.选BrowseInfo卡页,选中BuildBrowseinfofile,点击OK。
3.Build程序。
代码浏览器仅当成功Build程序后才可应用。
4.Tools/SourceBrowser。
5.在Browse对话框底部,找到Casesensitive复选框。
Fortran是大小写不敏感的语言,去除Casesensitive的选中。
点击OK。
?6.现在可以用Browse对话框来浏览函数调用关系以及变量声明和引用关系。
7.光标置于一个变量名或函数名中,鼠标右键:GotoDefinition使光标跳到该变量声明或函数定义语句;GotoReference使光标跳到该变量的引用或函数引用语句。
注:(Addison提供)IVF中现在不适用,因为此技术是属于MS的,不是INTEL的,所以,intel正在与MS就有关问题进行磋商,目前的进展比较顺利,可能要在以后的版本中支持,目前还没有时间表。
11.如何在CVF中检验代码是否符合F90/95标准?为了检验你的代码是否符合F90或F95标准,在CVF中选:Project/Settings...选Fortran页卡Category下拉框选:CompilationDiagnosticsFortranStandardChecking下拉框选:Fortran90或Fortran95这样,凡是CVF自家扩展的语法就都会有提示了。
例:typetestinteger,allocatable::a(:)integer,pointer::b(:)endtypetest若选了标准检验,会提示:Warning:Allocatablefieldsofderivedtypesarenon-standard[A]也就是说按照F90/95标准,type中不允许用allocatable。