C语言和Fortran语言的比较 下载本文

内容发布更新时间 : 2024/6/30 15:42:41星期一 下面是文章的全部内容请认真阅读。

promotion of employment, form a reasonable and orderly pattern of income distribution, build a more fair and sustainable social security systems, medical and health system reform. The plenary, innovation of social governance, must focus on the maintenance of fundamental interests of the overwhelming majority of the people, maximize factors, enhance social development, improving social governance, the interests of national security, ensure that the people live and work, social stability and order. o improve social governance, stimulating social organization, innovative and effective system of preventing and resolving social conflicts, improving the public security system, set up the National Security Council, national security systems and national security strategy to ensure national security. Plenary session, the construction of ecological civilization, you must establish systems of ecological system, using the system to protect the ecological environment. o improve naturalresources asset property right system and use control, red line of delimitation of ecological protection, resources paid use system and ecological compensation system in ecological environment protection management system reform. Plenary session, centering on building a listening party command, can win and having a fine style of the people's army, a strong army under the new situation of the party Goals, restricting the development of national defense and army building is solved outstanding contradictions and problems, innovation and development of military theory, enhance military strategic guidance, improve the military strategy in the new period, building a modern military force system with Chinese characteristics. o deepen the adjustment of personnel system reform in the army, military policy and system reform, promote the development of military and civilian integration depth. Plenary session stressed that comprehensive reform must be to strengthen and improve theparty's leadership, give full play to the core role of the party commands the overall situation and coordinating all parties, improving the party's leading water ... Margin. Challenged the leadership of the Communist Party of China, Marxism-Leninism and Mao Zedong thought by Deng Xiao-ping's flag, replaced by three representatives and the harmonic society. The former Communist Party spirit and social cohesion point of almost all political makeover. Characteristics of socialism public ownership is shifting to private ownership, planned regulation and market regulation, the proletarian regime controlled by the elite. Of universal equality, fairness and basic principles of distribution system is socialist society, however after economic monopolized by powerful, vested interests growemployers do not have the same status, hardly seems fair social distribution. State key protection of capital interests rather than the interests of citizens, had been hits the bottom of the proletariat C语言和Fortran语言的差异

本文详细介绍C语言和Fortran语言的差异 1. C++语言和Fortran语言的发展背景

在程序设计语言的发展过程中,FORTRAN 语言被认为是科学计算的专用语言。后来推出的FORTRAN90 和FORTRAN 95 版本也不例外,它们虽然可以完全实现C++语言同样的功能,然而其软件开发环境和软件的集成性等方面都远不如C++ 语言。近年来,随着计算机软硬件技术的发展,数据结构、数据库管理技术、可视化与计算机图形学、用户接口系统集成以及人工智能等领域的成果被逐渐应用到结构分析软件中,结构分析软件的设计并不仅仅局限于单一的科学计算需要涉及众多的软件开发领域。C++ 语言可以提供这类软件开发所需的功能,而用FORTRAN 90 却很难实现,另一方面从软件的编程环境来看,目前FORTRAN 90 的编译器极少,而C++ 语言的编译系统相当普及,可以运行在各种机型上,便于实现跨平台的软件系统集成。 2. C语言和Fortran语言的差异

由于两者产生的背景不同,它们是存在差异的,在比较了几组源代码之后,主要有以下体会:

C 最大的优点在于灵活,不但可以藉由 struct 来定义新的数据结构 ,同时 C 的pointer 更可以让我们自由而且有效率地处理大数据。而在 UNIX 系统 中,由于整个操作系统绝大部分就是 C 写出来的,故我们也有方便的 C 函数库, 直接使用系统资源与享受系统带来的服务,以做到一些低阶、快速的动作。而FORTRAN从一开始就用于科学计算,它与C的差异主要表现为: * 复数运算的速度 * 程序参数与字串 * 内存的动态管理 * 多维阵列的处理 * 函数调用与参数传递 2.1. 复数运算的速度

在进行复数运算的时候,C++ 可以定义复数的 class,还可以重新定义所有的四则运算式,复杂的算式也可以做到由一个表达式来解决。但它的重新定义复数四则运算是用函数来做的,使用函数来调用其速度很慢,除非采用 inline function 的方式,但会遇到以下的问题:要先将这个算式拆解,分别算过后再重组结果,故表面上程序代码很简洁,但实际上是 compiler做了很多工作,还是要付出相当的计算时间代价的。

至于 Fortran,最大的优点在于复数 (complex number) 的运算,复数是 Fortran 的基本数据类型之一,这正是 C 所缺乏的 (C 基本上只有实型与整型类型而已)。 虽然C 也可以由 struct 的定义,达到复数四则运算的目的,但 却很可能牺牲了程序效能,或者是程序写起来相当繁杂降低可读性。因此,在大量而且要求高速的复数运算场合, Fortran 实际上比 C 还要适合。

然而既然复数已是 Fortran 基本数据类型之一,则 Fortran compiler在设计上可以做到对复数特别的 optimization,例如如果遇到较短的复数运算式,它可以用“心算” 直接得出 real_part 与 imag_part 的 expression,像这样:

real(a) =……;imag(a) = …….

如此只需两步就得到结果。直到遇到太长太复杂的算式,才去做拆解的动作。

这样使用 C 来做复数运算可能需要绕圈圈,而且绕出来的圈圈可能还不小。不过如果程序中需要复合的数据结构,如一个自定义的数据结构中既有浮点数、整数、还有字符串时, Fortran 只有举白旗投降了。当然, Fortran 如果要做还是可以做,只是不太方便,而且可能也需要绕圈圈。但如果使用 Fortran 90 则不成问题了,因为 Fortran 90 也有类似 C 的 struct 结构以定义复合的数据类型。 2.2. 程序参数与字串

bviously, face China's Socialist system, the Communist Party is not the party. In that case, political chaos has been very tight. Is remodeling or reconstruction, is a correction or a stove. Whether to turn right or left, is back to the source or put forward new political ideas. This is to determine the road problems in China, is also the key out of the deep water of the reform of the economic system. After 18, the new Central collective leadership attaches great importance to political orientation. First, the \cles\ng point, starting from the Central Government's self-restraint, which preaches and pro-image, brought fresh feeling to the community. Secondly, before reform and opening up and reform and opening two periods after non-negative, untying the tangle of the society a long time on this issue. Third, a new generation of party leaders on various occasions to Mao Ze-Dong and Mao Ze-Dong's thought of evaluation has room for manoeuvre, through to the ruling ideology of Mao Zedong thought, is the call of the soul to the Socialist Revolution and construction. Empty talks jeopardize national interests and try again, is an affirmation of Deng Xiao-ping's reform ideas. These strong political signal showing a new generation of political leaders is still keeping to the Socialist road. Four is revisiting the \o Ze-Dong's historical cycle of\ofile anti-corruption and the importance of the Constitution, reorganization is bad style of officialdom, was to civilize people obey the law, while improving the color change of the regime of vigilance. Five is to reform into deeper waters and stressed that top-level design, this is a review on the reform and opening up in the past, is also looking for a way out. Six foreign and Russia closer, the flexible attitude on the issue of the Korean peninsula, Sino-Japanese fishing hardline China on the island out of the \nt\ow profile shadow began to gradually plan development. Signs show that the new leadership began to make a left turn in politics. However, as of right now, not only ideological confusion in the community, the new leadership's thinking is messy. New leaders both stressed the need to implement the Constitution, stressed the need to turn off the power in a cage. Also stresses that Mao Zedong thought cannot be lost, 30 years after the reform and opening up 30 years ago can not deny each other. Both advocate democracy and release \n does not speak of\cal constraints. Neither deny the history of the CPC Central Committee on several issues ... Comrades: today brings together members, mainly in order to provide a platform to Exchange and learn from each other in order to facilitate our work. Just now, we focus on taxation, planning and stability, safety, project construction, typical topics such as private facts presentation and interaction, and towns currently exist in the in-depth analysis of the problems to be solved, to explore new methods to solve the problem. It can be said that summing up the achievement, no grandstanding; analysis promotion of employment, form a reasonable and orderly pattern of income distribution, build a more fair and sustainable social security systems, medical and health system reform. The plenary, innovation of social governance, must focus on the maintenance of fundamental interests of the overwhelming majority of the people, maximize factors, enhance social development, improving social governance, the interests of national security, ensure that the people live and work, social stability and order. o improve social governance, stimulating social organization, innovative and effective system of preventing and resolving social conflicts, improving the public security system, set up the National Security Council, national security systems and national security strategy to ensure national security. Plenary session, the construction of ecological civilization, you must establish systems of ecological system, using the system to protect the ecological environment. o improve naturalresources asset property right system and use control, red line of delimitation of ecological protection, resources paid use system and ecological compensation system in ecological environment protection management system reform. Plenary session, centering on building a listening party command, can win and having a fine style of the people's army, a strong army under the new situation of the party Goals, restricting the development of national defense and army building is solved outstanding contradictions and problems, innovation and development of military theory, enhance military strategic guidance, improve the military strategy in the new period, building a modern military force system with Chinese characteristics. o deepen the adjustment of personnel system reform in the army, military policy and system reform, promote the development of military and civilian integration depth. Plenary session stressed that comprehensive reform must be to strengthen and improve theparty's leadership, give full play to the core role of the party commands the overall situation and coordinating all parties, improving the party's leading water ... Margin. Challenged the leadership of the Communist Party of China, Marxism-Leninism and Mao Zedong thought by Deng Xiao-ping's flag, replaced by three representatives and the harmonic society. The former Communist Party spirit and social cohesion point of almost all political makeover. Characteristics of socialism public ownership is shifting to private ownership, planned regulation and market regulation, the proletarian regime controlled by the elite. Of universal equality, fairness and basic principles of distribution system is socialist society, however after economic monopolized by powerful, vested interests growemployers do not have the same status, hardly seems fair social distribution. State key protection of capital interests rather than the interests of citizens, had been hits the bottom of the proletariat C 程序可以有参数串列, Fortran 则没有。例如,当程序执 行时,必须输入 a, b, c 三个参数,在 C 可以这样写: int main(int argc, char **argv) {

int a, b, c; a = atoi(argv[1]); b = atoi(argv[2]); c = atoi(argv[3]); }

而程序执行时,参数就是这样传入: a.out 12 15 18

bviously, face China's Socialist system, the Communist Party is not the party. In that case, political chaos has been very tight. Is remodeling or reconstruction, is a correction or a stove. Whether to turn right or left, is back to the source or put forward new political ideas. This is to determine the road problems in China, is also the key out of the deep water of the reform of the economic system. After 18, the new Central collective leadership attaches great importance to political orientation. First, the \cles\ng point, starting from the Central Government's self-restraint, which preaches and pro-image, brought fresh feeling to the community. Secondly, before reform and opening up and reform and opening two periods after non-negative, untying the tangle of the society a long time on this issue. Third, a new generation of party leaders on various occasions to Mao Ze-Dong and Mao Ze-Dong's thought of evaluation has room for manoeuvre, through to the ruling ideology of Mao Zedong thought, is the call of the soul to the Socialist Revolution and construction. Empty talks jeopardize national interests and try again, is an affirmation of Deng Xiao-ping's reform ideas. These strong political signal showing a new generation of political leaders is still keeping to the Socialist road. Four is revisiting the \o Ze-Dong's historical cycle of\ofile anti-corruption and the importance of the Constitution, reorganization is bad style of officialdom, was to civilize people obey the law, while improving the color change of the regime of vigilance. Five is to reform into deeper waters and stressed that top-level design, this is a review on the reform and opening up in the past, is also looking for a way out. Six foreign and Russia closer, the flexible attitude on the issue of the Korean peninsula, Sino-Japanese fishing hardline China on the island out of the \nt\ow profile shadow began to gradually plan development. Signs show that the new leadership began to make a left turn in politics. However, as of right now, not only ideological confusion in the community, the new leadership's thinking is messy. New leaders both stressed the need to implement the Constitution, stressed the need to turn off the power in a cage. Also stresses that Mao Zedong thought cannot be lost, 30 years after the reform and opening up 30 years ago can not deny each other. Both advocate democracy and release \n does not speak of\cal constraints. Neither deny the history of the CPC Central Committee on several issues ...Comrades: today brings together members, mainly in order to provide a platform to Exchange and learn from each other in order to facilitate our work. Just now, we focus on taxation, planning and stability, safety, project construction, typical topics such as private facts presentation and interaction, and towns currently exist in the in-depth analysis of the problems to be solved, to explore new methods to solve the problem. It can be said that summing up the achievement, no grandstanding; analysis