当前位置:文档之家› 常见fortran系统错误

常见fortran系统错误

常见fortran系统错误
常见fortran系统错误

Mistakes in Fortran 90 Programs That Might Surprise You

Over the years we have made lots of interesting and fun mistakes in Fortran 90 that we would like to share with you. We welcome your contributions and experiences so that we can share your pain.

Topics

These "gotchas" are nasty because they will not fail on some machines, while failing on others (given various combinations of compilers and machine platforms).

?Danger with Optional Arguments

?Danger with intent(out)

? A suprise with non-advancing I/O

?Suprise with locally initialized variables

?Danger of calling Fortran 90 style routines

?Danger with interfaces to Fortran 77 subroutines

? A suprise with generic functions

?Big Danger with Undefined Pointers

?Subtle danger with overloading (=) to assign pointers

?Danger with pointers to pointers

Danger with Optional Arguments

In this example an optional argument is used to determine if a header is printed.

subroutine print_char(this,header)

character(len=*), intent (in) :: this

logical, optional, intent (in) :: header

! THIS IS THE WRONG WAY

if (present(header) .and. header) then

print *, 'This is the header '

endif

print *, this

subroutine print_char(this,header)

character(len=*), intent (in) :: this

logical, optional, intent (in) :: header

! THIS IS THE RIGHT WAY

if (present(header)) then

if (header) print *, 'This is the header '

endif

print *, this

end subroutine print_char

Explanation

The first method is not safe because the compiler is allowed to evaluate the header argument before the present function is evaluated. If the header argument is not in fact present an out of bounds memory reference could occur, which could cause a failure.

Danger with intent(out)

In this example we assign components of a derived type with intent(out). program intent_gotcha

type mytype

integer :: x

real :: y

end type mytype

type (mytype) :: a

a%x = 1 ; a%y = 2.

call assign(a)

! a%y COULD BE UNDEFINED HERE

print *, a

contains

subroutine assign(this)

type (mytype), intent (out) :: this

! THIS IS THE WRONG WAY

this%x = 2

end subroutine assign

subroutine assign(this)

type (mytype), intent (out) :: this

! THIS IS THE RIGHT WAY

this%x = 2 ; this%y = 2.

end subroutine assign

Explanation

The problem is that when intent(out) is used with a derived type, any component not assigned in a procedure could become undefined on exit. For example, even though a%y was defined on entry to this routine, it could become undefined on exit because it was never assigned within the routine. The lesson is that all components of a derived type should be assigned within a procedure, when intent(out) is used. Intent(out) behaves like the result variable in a function: all components must be assigned.

As an alternative, use intent(inout).

A suprise with non-advancing I/O

Many people think that the new non-advancing I/O in Fortran 90 is the same as stream I/O in other languages. It is not.

do i = 1, 128

write (unit=6,fmt='(a)',advance='no') 'X'

end do

We expect this program to print 128 X's in a row. However, unexpected behavior may occur if the record length for unit 6 is less than 128.

One can inquire the record length in the follow way:

open(unit=6)

inquire(unit=6, recl=i)

print *, 'recl =', i

Explanation

All Fortran I/O is still record based. Non-advancing I/O allows partial reads and writes within a record. For many compilers the default record length is very large (e.g., 2147483647) giving the appearance of stream I/O. This is not true for all compilers however.

On some compilers it is possible to set the record length as follows:

open(unit=6, recl = 2147483646)

On other compilers unit 6 is preconnected and the record length cannot be changed. (Thanks to Jon Richards of the USGS for this tip.)

Note that unit 6 and unit * are not necessarily the same. Although they both may point to the default output device, with non-advancing I/O, each could keep track of the current location in its own record separately. Therefore we advise choosing one default unit and sticking with it.

Suprise with locally initialized variables

One must be careful when initializing a locally declared variable.

real function kinetic_energy(v)

real, dimension(:), intent(in) :: v

integer i

! THIS IS THE WRONG WAY

real :: ke = 0.0

do i = 1, size(v)

ke = ke + v(i)**2

enddo

kinetic_energy = .5*ke

end function kinetic_energy

real function kinetic_energy(v)

real, dimension(:), intent(in) :: v

integer i

! THIS IS THE RIGHT WAY

real :: ke

ke = 0.

do i = 1, size(v)

ke = ke + v(i)**2

enddo

kinetic_energy = .5*ke

end function kinetic_energy

Explanation

A local variable that is initialized when declared has an implicit save attribute. ke is initialized only the first time the function is called. On subsequent calls the old value of ke is retained. This is a real suprise to C programmers.

To avoid confusion it is best to add the save attribute to such locally initialized variables explicitly, even though this is redundant.

Danger of calling Fortran 90 style routines

program main

real, dimension(5) :: x

x = 0.

! THIS IS WRONG

call incb(x)

print *, x

end program main

subroutine incb(a)

! this is a fortran90 style subroutine

real, dimension(:) :: a

a = a + 1.

end subroutine incb

Explanation

The subroutine incb uses a Fortran 90 style assumed shape array (containing dimension(:)). Such routines must either be in a module, or have an explicit interface wherever they are used. In this example, neither one was true.

One correct way to call such procedures is to use an explicit interface as follows:

program main

real, dimension(5) :: x

! THIS IS THE RIGHT WAY

interface

subroutine incb(a)

real, dimension(:) :: a

end subroutine incb

end interface

x = 0.

call incb(x)

print *, x

end program main

subroutine incb(a)

! this is a fortran90 style subroutine

real, dimension(:) :: a

a = a + 1.

end subroutine incb

If the routine is in a module interfaces are generated automatically and do not need to be explicitly written.

! THIS IS ANOTHER RIGHT WAY

module inc

contains

subroutine incb(a)

! this is a fortran90 style subroutine

real, dimension(:) :: a

a = a + 1.

end subroutine incb

end module inc

program main

use inc

real, dimension(5) :: x

x = 0.

call incb(x)

print *, x

end program main

If interfaces are used, the interface MUST match the actual function. Danger with interfaces to Fortran 77 subroutines

program main

real, dimension(5) :: x

! interface to Fortran 77 style routine

interface

subroutine inca(a,n)

integer :: n

! THIS IS THE WRONG WAY

real, dimension(:) :: a

! THIS IS THE RIGHT WAY

real, dimension(n) :: a

end subroutine inca

end interface

x = 0.

call inca(x,5)

print *, x

end program main

subroutine inca(a,n)

! this is a fortran77 style subroutine

dimension a(n)

do 10 j = 1, n

a(j) = a(j) + 1.

10 continue

return

end

Explanation

The interface declaration must always match the actual subroutine declaration. In this case, the interface statement refers to a Fortran 90 style assumed shape array. The actual subroutine refers to a Fortran 77 explicit shape array. The lesson here is: Interfaces to Fortran 77 style routines must only use Fortran 77 style constructs.

In this example, it is permitted to leave out the interface altogether since routines without interfaces are treated as Fortran77 style routines by default. However, if the interface is left out, the compiler will no longer check whether the arguments of calling procedures agree with the arguments listed in the interface.

A Suprise with Generic Functions (Function Overloading)

Fortran 90 allows the same function name to be used for different actual functions, so long as the arguments to the functions differ. One would expect that the functions first_sub and second_sub below would be different, because in first_sub, the first argument is a real and the second is an integer, while in second_sub the arguments are reversed. subroutine first_sub(a,i)

real :: a

integer :: i

...

end subroutine first_sub

!

subroutine second_sub(i,a)

integer :: i

real :: a

...

end subroutine second_sub

So that one could define a generic function first_or_second below:

interface first_or_second

module procedure first, second

end interface

This is NOT so.

Explanation

The reason is that Fortran 90 allows procedures to be called by name (keyword) arguments. The following

real :: b

integer :: n

call first_or_second(i=n,a=b)

does not work because when called by keyword, first_sub and second_sub are indistinguishable,

call first_sub(i=n,a=b)

call second_sub(i=n,a=b)

and therefore a generic function cannot be defined. A generic function must be able to distinguish its arguments by type AND by name.

The solution is to not use the same dummy argument name in both procedures. For example, the following would work:

subroutine second_sub(i,aa)

integer :: i

real :: aa

...

end subroutine second_sub

Dangers with Pointers

Fortran 90 has 3 ways to implement dynamic memory: Automatic arrays, allocatable arrays, and pointers.

Automatic arrays are automatically created on entry and deleted on exit from a procedure, and they are safest and easiest to use. Allocatable arrays require the user to manually create and delete them, and should only be used if automatic creation and deletion is not the desired behavior.

Pointers are the most error prone and should only be used when allocatable arrays are not possible, e.g., when one desires an array to be a component of a derived type.

Big Danger with Undefined Pointers

Many people think that the status of a pointer which has never been associated is .not. associated. This is false.

In this example we are allocating a local_table on first entry that is to be reused on subsequent entries.

subroutine local_pointer(this)

real, dimension(:) :: this

real, dimension(:), save, pointer :: local_table

! THIS IS THE WRONG WAY

if (.not. associated(local_table)) then

allocate(local_table(size(this)))

endif

local_table = ...

...

end subroutine local_pointer

subroutine local_pointer(this)

real, dimension(:) :: this

real, dimension(:), save, pointer :: local_table

! THIS IS THE RIGHT WAY

logical, save :: first_entry = .true.

if (first_entry) then

nullify(local_table) ; first_entry = .false.

end if

if (.not. associated(local_table)) then

allocate(local_table(size(this)))

endif

local_table = ...

...

end subroutine local_pointer

Explanation

When a pointer is declared its status is undefined, and cannot be safely queried with the associated intrinsic. A second variable is introduced to nullify the pointer on first entry so that its status can be safely tested. This is not a problem in Fortran 95 which allows one to nullify a pointer on declaration.

Note that the save attribute for local_table is necessary to guarantee that the array and the pointer status are preserved on subsequent entries. We recommend that the save attribute should always be used when pointers and allocatable arrays are allocated in procedures.

Subtle danger with overloading (=) to assign pointers

One must be careful with overloading the assignment operator.

In this module we have created a private type which contains a pointer and a public procedure to assign that pointer.

module assign_pointer_class

type mytype

private

real, pointer :: pr

end type mytype

interface assignment (=)

module procedure assign_pointer

end interface

contains

subroutine assign_pointer(this, a)

type (mytype), intent(out) :: this

real, target, intent(in) :: a

this%pr => a

end subroutine assign_pointer

end module assign_pointer_class

In this main program we intend to assign the pointer component x%pr to the variable a, x%pr =>a. We cannot do so directly because the components of mytype are private. One must use a public procedure to do so. Furthermore, to simplify the syntax one might be tempted to use an overloaded assignment operator (=).

program main

use assign_pointer_class

type (mytype) :: x

real :: a = 0

! THIS IS THE WRONG WAY

x = a

end program main

Don't give into this temptation! The only safe way to accomplish this is to call the procedure directly.

program main

use assign_pointer_class

type (mytype) :: x

! THIS IS THE RIGHT WAY

real, target :: a = 0

call assign_pointer(x,a)

end program main

Explanation

The Fortran 90 standard says that the right hand side of an assignment operator is an expression that may potentially only persist for the duration of the call. In other words, x%pr could inadvertently point to a temporary copy of the variable a.

Thanks to Henry Zongaro of IBM for pointing this out. (We never would have figured this one out on our own.)

Also, James Giles found a subtle point regarding this example. We did not include "target" in the declaration of the real variable "a" (this has been corrected above). In James' words:

"Notice that for this to really work, the actual argument, 'a', must be declared with the target attribute. You correctly declare the dummy argument in the assign_pointer routine with the target attribute, but the actual argument must also have that attribute (otherwise it's illegal for any pointer to be associated with it). Just a minor point..."

Danger with pointers to pointers

When creating a hierarchy of pointers to pointers, each level of pointers must be allocated before being used.

program main

type mytype

real, dimension(:), pointer :: p

end type mytype

type (mytype), pointer :: x

! BOTH OF THESE ARE THE WRONG WAY

! AND THE COMPILER WON'T CATCH IT

! nullify(x%p)

! allocate(x%p(5))

! ONE SHOULD ALWAYS IMMEDIATELY NULLIFY THE PARENT POINTER

! OR ALLOCATE IT

nullify(x) ! or allocate(x)

...

! THEN LATER NULLIFY OR ALLOCATE THE CHILD POINTER

call child_construct(x,5)

if (associated(x%p)) print *, x%p

contains

subroutine child_construct(this,len)

! child constructor for pointer within mytype

! if len is present, then allocate it, otherwise nullify it.

! mytype is assumed to be already nullified or allocated

type (mytype), pointer :: this

integer, optional, intent(in) :: len

if (.not.associated(x)) allocate(x)

if (present(len)) then

allocate(x%p(len))

x%p = 0.

else

nullify(x%p)

endif

end subroutine child_construct

end program main

Explanation

This example creates a pointer to a pointer to an array of reals where the first pointer has not been allocated. For safety one should always either allocate or nullify the parent pointer immediately after its declaration. The child pointer cannot be allocated before the parent. Since the child pointer may be allocated elsewhere in the code, it is convenient to use constructor routines for this purpose.

Each child constructor can safely allocate or nullify its pointers only when it can be sure that its parent's pointers have been allocated or nullified.

fortran调试经验

FORTRAN调试程序的时候注意的问题 调试程序的时候注意的问题。 程序编好,能够直接运行而且完全正确,基本不可能,这就有调试程序的问题。主要有一下几个方面: 其一,在每个子程序被调用的时候留个心眼,写个输出语句,表示程序已经运行到了这里。这样一个小提示会给调试带来巨大的方便,如果程序运行出错,至少你可以知道它是在运行到哪里出的错,这样,直接去检查那个程序就可以了。不必重头开始检查。 其二,注意对中间计算结果的输出。有时候,而且是很多的时候,程序编译成功,运行也没有问题,就是结果不对,这肯定是计算原理有问题,此时,输入一些重要步骤的中间结果,往往可以检查出问题所在。同时,就算查出了问题所在,也可以不删除这段输出中间计算结果的代码,有可能后面还会有用处,此时,在每行输出语句前加一个感叹号,把代码变成注释的绿体字就可以了。等到再次需要输出的时候,直接删除一个“!”比再写一遍输出代码,当然要简单的多。 其三,对WATCH功能的应用,FORTRAN提供的这个功能很实用,可以查很多问题,尤其是程序中间计算值,这个和上述的中间结果的输出有点相似。但两者的不同是前者可以进行中间结果的输出控制,就是只有符合了某个条件的才能被输出,这样可以便捷程序的调试,同时对中间结果输出后可以直接用STOP停止程序的运行,这样对于大型程序来说,节省了很多后面继续计算的时间——因为前面的结果已经不对了,后面的算也是白算。 其四,对中间结算结果输出形式的控制,一般来说,FORTRAN计算结果可以输出到文件里面和计算界面两个地方。对较大的计算结果,可以输出到文件里面,反之较少的结果可以直接输出到屏幕上,为了增强数据的可读性,最好进行有格式的数据输出,以利于相同性质的数据的比较。输出到屏幕上的结果直接用WRITE(6,*)就可以(无格式),对于输出到文件里面的数据,可以省些事情,直接用WRITE(X,*)就可以,其中X是一个任意的正整数,最好大于10,也不用事先对这个X设备进行说明,程序会将结果输出到一个FORT.X的文件里面,例如10,就是FORT.10,此时,用NOTEPAD或者ULTRA-EDIT都可以把它打开——FORT.10实质上就是一个.DAT的文件,你可以把它重命名。 3.对数据计算时的误差控制。 以前觉得小数点后的误差不是那回事,没有太在意,可经过实战,终于明白了小小的误差完全可以改变整个计算的结果。因此,如果程序能够输入结果而不正确时,除了寻找算法的问题,不要忽略的误差。一般认为,FORTRAN的REAL变量小数点后8位数字误差定义已经足够,而事实上,这个精度可能在一些情况下不满足,这个时候,需要用更精确的变量类型——REAL(8),同理,当要判断两个数是否相等的时候,一定要慎用相等判断(.EQ.)这个比较运算符,因为任何数据,别看着在现实中它们一定相等,在程序中就不一定了。一旦经过了计算,就不可避免的产生了舍入误差,对于整数和有限几位循环的有理数都问题不大,可一旦是一个无理数或者无限循环的小数,只有在判断了小数点后的每一位都相等的时候,程序才判断为相等成立。这个相等的标准是非常苛刻的,所以一般情况下,可行的方法是将

fortran语法手册

1 FORTRAN77四则运算符 + - * / ** (其中**表示乘方) 在表达式中按优先级次序由低到高为:+或-→*或/→**→函数→() 2 FORTRAN77变量类型 2.1 隐含约定:I-N规则 凡是以字母I,J,K,L,M,N六个字母开头的,即认为是整型变量,其它为实型变量。 如IMPLICIT REAL (I,J) 三种定义的优先级别由低到高顺序为:I-N规则→IMPLICIT语句→类型说明语句,因此,在程序中IMPLICIT语句应放在类型说明语句之前。 2.4 数组的说明与使用 使用I-N规则时用DIMENSION说明数组,也可在定义变量类型同时说明数组,说明格式为:数组名(下标下界,下标上界),也可省略下标下界,此时默认为1,例: DIMENSION IA(0:9),ND(80:99),W(3,2),NUM(-1:0),A(0:2,0:1,0:3) REAL IA(10),ND(80:99)使用隐含DO循环进行数组输入输出操作:例如WRITE(*,10) ('I=',I,'A=',A(I),I=1,10,2) 10FORMAT(1X,5(A2,I2,1X,A2,I4)) 2.5 使用DATA语句给数组赋初值 变量表中可出现变量名,数组名,数组元素名,隐含DO循环,但不许出现任何形式的表达式:例如 DATA A,B,C/-1.0,-1.0,-1.0/ DATA A/-1.0/,B/-1.0/,C/-1.0/ DATA A,B,C/3*-1.0/CHARACTER*6 CHN(10)

DATA CHN/10*' '/INTEGER NUM(1000) DATA (NUM(I),I=1,500)/500*0/,(NUM(I),I=501,1000)/500*1/ 3 FORTRAN77程序书写规则 程序中的变量名,不分大小写; 变量名称是以字母开头再加上1到5位字母或数字构成,即变更名字串中只有前6位有效; 一行只能写一个语句; 程序的第一个语句固定为PROGRAM 程序名称字符串 某行的第1个字符至第5个字符位为标号区,只能书写语句标号或空着或注释内容; 某行的第1个字符为C或*号时,则表示该行为注释行,其后面的内容为注释内容; 某行的第6个字符位为非空格和非0字符时,则该行为上一行的续行,一个语句最多可有19个续行; 某行的第7至72字符位为语句区,语句区内可以任加空格以求美观; 某行的第73至80字符位为注释区,80字符位以后不能有内容。 4 FORTRAN77关系运算符 .GT. 大于 .GE. 天于或等于 .LT. 小于 .LE. 小于或等于 .EQ. 等于 .NE. 不等于 .AND. 逻辑与 .OR. 逻辑或 .NOT. 逻辑非 .EQV. 逻辑等 .NEQV. 逻辑不等 运算符优先级由高到低顺序为:()→**→*或/→+或-→.GT.或.GE.或.LT. 或.LE.或.EQ.或.NE.→.NOT.→.AND.→.OR.→.EQV.或.NEQV 5 FORTRAN77语句

华测静态数据处理流程

静态数据处理 一.静态测量的准备工作(简单介绍) (2) 二.数据下载: (3) 安装主机USB驱动: (3) 打开下载软件hcloader: (3) 输入测站信息: (3) 下载数据: (3) 三.数据处理操作过程 (4) 软件安装: (4) 安装软件狗驱动: (4) 数据处理过程 (4) 文件>新建项目 导入观测数据 查看,设置坐标系 基线处理 网平差 成果报告 附C、D、E 级GPS测量手簿记录格式 (6)

一.静态测量的准备工作(简单介绍) 在室内选点的时候要注意控制网的网形:正三角形是最好的网形(如上图),特长或特短边的出现(如下图)都会使误差增大。 在野外勘测时,尽量选择周围无遮挡、无高压线、无强电磁干扰的地方进行定点,观测,这样不仅可以保证精度,也可以减少内业处理的很多麻烦。 在外业测量时,切换到静态后,要查看数据记录指示灯(黄灯)是否有规律闪烁(间隔5秒),否则重新启动接收机,重新切换到静态。 外业观测时记录数据要全面(仪器号、点号、开机时间、关机时间、仪器高、等)。 已知控制点 未知待定点

二.数据下载: 安装主机USB驱动: 当第一次使用主机USB下载数据时,电脑会提示发现硬件,出现驱动程序安装向导, 选择驱动的保存路径(默认在COMP SS的安装路径下有`river/USB),点“下一步”即可完成安装; 打开下载软仦hcloader: 开始>娋序>华测静态处理>文件下载,点击即可。 设置连接端口:connection>settings>com选择USB、band rate选115200。 列表框里就会显示主机里有的文件(如果没有可以点击Update,稍等即可): 输入测站信息: 根据野外记录输入测站名(不超过4个字符,一般为?下端的4位仪器号)、时段(在同一点上不同时间观测的数据,目的是区别文件名)、天线高(野外实地所量测的仪器高,一般为仪器的斜高),选择文件类型(一般默认),确认即可。 下载数据: 选择需要下载的数据文件(可多选),右击鼠标数据导出,数据自动导出到之前指定的下载路径中。 下载完毕关闭软件即可。

一些 免费的fortran编译器

一些免费的fortran编译器 https://www.doczj.com/doc/ee3598903.html,/node/8 Free Fortran Compilers 取自https://www.doczj.com/doc/ee3598903.html,/compilers/fortran.shtml This page lists free Fortran compilers for various operating systems. Some of the compilers are compliant with the ANSI Fortran 77 specifications, others with Fortran 95, and so on. Some of them may also come complete with debuggers, editors and an integrated development environment (IDE). If you need a book on Fortran, you may want to check out the selection of books available at https://www.doczj.com/doc/ee3598903.html,. Disclaimer The information provided on this page comes without any warranty whatsoever. Use it at your own risk. Just because a program, book or service is listed here or has a good review does not mean that I endorse or approve of the program or of any of its contents. All the other standard disclaimers also apply. Free Fortran Compilers and IDEs Sun Studio Compilers and Tools Sun Studio Compilers and Tools for Linux and Solaris OS on Sparc and x86/x64 platforms includes command line tools as well as a NetBeans-based IDE for developing, compiling and debugging C, C++ and Fortran programs. It also includes performance analysis tools. Intel Fortran Compiler for Linux

fortran常见问题解决

楼主为了减少重复回答问题,特编此帖,并不定期添加和更新内容。 错误难免,欢迎讨论,仅供参考。 很多人问哪里可以找到Fortran编译器,有不少热心学友提供网址,特汇集在这里。虽然俺检验过这些链接,但是它们不一定总有效。 Fortran编译器下载: CVF? FTN95(License:Freeforpersonaluse) 以下操作,如无特别说明,都是以为例。 1.如何加大Stacksize? 选Project=>Settings=>Link=>Category:Output=>? Stackallocations Reserve:这里填新值(默认为1M,若需要10M,则填) 2.如何用Fortran批量生成文件? 设要生成4000个文件,文件名为AA1-AA4000,如何写循环生成文件,而不用写4000次write 命令呢? 用内部文件: character(len=80)::filename,form integer::i doi=1,4000 selectcase(i) case(1:9) write(form,'(i1)')i case(10:99) write(form,'(i2)')i case(100:999) write(form,'(i3)')i case(1000:9999) write(form,'(i4)')i endselect write(filename,*)"AA",trim(form),".TXT" open(10,file=filename) write(10,*)i close(10)

enddo? stop end 3.如何用Fortran动态生成输出格式? 设有一个数组data(100),输出时,希望每行输出num个数,而num由用户输入,如何实现? 用内部文件: character(len=80)::form real::data(100) integer::i,num data=(/(i,i=1,100)/)/ read(*,*)num write(form,*)"(",num,"" write(*,form)data stop end 4.MS是不是很垃圾? 是垃圾,其中Bug太多,多到不可用的地步! 在这个主题里,换了CVF后问题就没了的人已有相当的数目。 如果你用,遇到莫名其妙的错误,建议换,这是一个比较成熟的编译器。 5.如何用F90/95生成随机数? 注意: 现在计算机产生的随机数都是伪随机数。 random_number(x)产生一个0到1之间的随机数(x可以是向量),但是每次总是那几个数。用了random_seed()后,系统根据日期和时间随机地提供种子,使得随机数更随机了。 programrandom implicitnone real::x callrandom_seed()!系统根据日期和时间随机地提供种子 callrandom_number(x)!每次的随机数就都不一样了 write(*,*)x stop endprogramrandom 6.函数/子程序超载的例子

华测常见问题解决办法

华测常见问题解决办法 一、蓝牙问题:手簿显示打开端口失败 1、点击配置——手簿端口配置——配置,查看蓝牙是否打开。 2、点击配置——手簿端口配置,查看连接类似是否是蓝牙,端口是否是COM8 或者是COM9,再点击确定就能连上。 3、手簿和移动站的距离太远了,手簿靠近移动站2米内的距离,点击配置—— 手簿端口配置——确定。 4、通过以上操作还是显示打开端口失败的话,就把移动站主机关机开机下,等 待10秒后,点击配置——手簿端口配置——确定,就可以连上蓝牙了。 5、通过关机开机还是显示打开端口失败的话,开机查看是否显示所有灯都同时 闪3次,然后红色灯是否单独闪3次,如果是红色灯有闪3次表示蓝牙启动起来;否则蓝牙未启动起来。蓝牙未启动情况,请拨打技术电话联系厂家技术员。 二、仪器的问题:手簿一直显示正在搜星。 1、点击仪器——仪器接收机复位下,稍等会便可以固定了。 2、把仪器关机开机下,稍等会便可以固定了。 3、如果以上操作还是不行,请联系厂家技术员。 三、点校正的问题:点校正里面找不到所测量的GPS点。 1、在配置——移动站参数——移动站选项里,把使用VRS打上勾,便可以在点 校正里找到所测量的GPS点。 六、点校正计算后,水平残差和垂直残差超出误差范围,水平残差很大。(水平 残差大于0.02,垂直残差大于0.03) 1、检查坐标系统和中央子午线是否输错,一般坐标系统用北京54或西安80, 福建这边中央子午线(宁德,福州,莆田的中央子午线是120,南平,三明,龙岩的中央子午线输117,厦门输118.30),关于工程设计资料上都有提供的,请翻阅查看。 2、检查输入的已知点坐标是否正确。 3、检查实际测量的GPS点是否正确,会不会在实地测量测错了。 4、检查点校正时,是否不小心把对应的点对应错了,已知点和测量的GPS点要 一一对应起来。 点校正时的注意事项: 1、已知点最好要分布在整个作业区域的边缘,能控制整个区域,并避免短边控制长边。例如,如果用四个点做点校正的话,那么测量作业的区域最好在这四个点连成的四边形内部; 2、一定要避免已知点的线形分布。例如,如果用三个已知点进行点校正,这三

ABAQUS常见错误与警告信息汇总

*************************错误与警告信息汇总************************* --------------简称《错误汇总》 %%%%%%%%%%%%%%% @@@ 布局 @@@ &&&&&&&&&&&&&&&&&&&&&& AB系列:常见错误信息 C系列:常见警告信息 D系列:cdstudio斑竹总结的fortran二次开发的错误表 E系列:网格扭曲%%%%%%%%%%%%%%%%% @@@@@@ &&&&&&&&&&&&&&&&&&&&&&&&& 模型不能算或不收敛,都需要去monitor,msg文件查看原因,如何分析这些信息呢?这个需要具体问题具体分析,但是也存在一些共性。这里只是尝试做一个一般性的大概的总结。 如果你看见此贴就认为你的warning以为迎刃而解了,那恐怕令你失望了。不收敛的问题千奇万状,往往需要头疼医脚。接触、单元类型、边界条件、网格质量以及它们的组合能产生许多千奇百怪的警告信息。企图凭一个警告信息就知道问题所在,那就只有神仙有这个本事了。一个warning出现十次能有一回参考这个汇总而得到解决了,我们就颇为欣慰了。 我已霸占2楼3楼4楼,以便分类并续加整理。 斑竹可随意编辑或者添加你们觉得合适的条目和链接,其他版友有warning方面的疑问请回复到这个帖子,大家集思广益,斑竹们也可以集中讨论并定期汇总到1-4楼。 类似于: Fixed time is too large Too many attamps have been made THE SOLUTION APPEARS TO BE DIVERGING. CONVERGENCE ISJUDGED UNLIKELY. Time increment required is less than the minimum specified 这样的信息几乎是无用信息(除了告诉你的模型分析失败以外,没有告诉你任何有用的东西)。宜再查找别的信息来考察。根据经验,改小增量步也不一定能收敛,虽然也有人报告过改好的先例,我是从来没有遇到过,也从来没有那个奢望。所以我一般从模型的设置入手。原则上本贴只欢迎以下回帖: 1)你出现了已经解决的错误信息or解决不了的错误信息,可以回帖附上信息,并对模型和症状加以描述(斑竹会酌情加分); 2)你发现某个帖子有已经解决的错误信息or解决不了的错误信息, 可以提供链接(斑竹会加分); 3)你发现某一条错误信息可能还存在别的情况or别的应对方案, 可以回帖说明(斑竹会加分) 必须说明的是:Error和warning的性质是完全不同的。Error意味着运算失败,but出现warning可能还能算,而且有些运算必定会出现warning(比如接触分析必定出“负特征值”,下有详述)。很多警告只是通知性质的,或者只是说明一下而已,不一定都是模型有问题。比如以下warning完全可以忽略: xxxxx will (not)printed,这种只是通知你一声,某些玩意儿不输出了。还有: The parameter frequency cannot be used with the parameter field. It will be ignored(都说某某被ignored了).

fortran课后习题答案

第一章 FORTRAN程序设计基础第15页 1、2 1.简述程序设计的步骤。 “程序设计”:反映了利用计算机解决问题的全过程,通常要经过以下四个基本步骤:(1)分析问题,确定数学模型或方法;(2)设计算法,画出流程图;(3)选择编程工具,编写程序;(4)调试程序,分析输出结果。 2. 什么是算法?它有何特征?如何描述算法? 解决问题的方法和步骤称为算法。 算法的五个特征:(1) 有穷性。 (2) 确定性。 (3) 有效性。 (4) 要有数据输入。(5) 要有结果输出。 算法的描述有许多方法,常用的有:自然语言、一般流程图、N-S图等。 第二章顺序结构程序设计 第29页 1、2、3、4、5、6、7、8、9 1.简述符号常量与变量的区别? 符号常量在程序运行过程中其值不能改变。变量在程序运行过程中其值可以改变。 2. 下列符号中为合法的FORTRAN 90标识符的有哪些? (1) A123B (2) M%10 (3) X_C2 (4) 5YZ (5) X+Y (6) F(X) (7) COS(X) (8) A.2 (9) ‘A’ONE (10) U.S.S.R. (11) min*2 (12) PRINT 3. 下列数据中哪一些是合法的FORTRAN常量? (1) 9,87 (2) .0 (3) 25.82(4) -356231 (5) 3.57*E2 (6) 3.57E2.1 (7) 3.57E+2(8) 3,57E-2 4. 已知A=2,B=3,C=5(REAL);且I=2,J=3(INTEGER),求下列表达式的值: (1) A*B+C 表达式的值: 11 (2) A*(B+C) 表达式的值: 16 (3) B/C*A 表达式的值: 1.2 (4) B/(C*A) 表达式的值: 0.3 (5) A/I/J 表达式的值: 0.33 (6) I/J/A 表达式的值: 0 (7) A*B**I/A**J*2 表达式的值: 4.5 (8) C+(B/A)**3/B*2. 表达式的值: 7.25 (9) A**B**I 表达式的值: 512 5. 将下列数学表达式写成相应的FORTRAN表达式: (1) 1E-2 (2)(-B+SQRT(B*B-4*A*C)/(2*A) (3) 1+X+X*X/2+X**3/2/3 (4) COS(ATAN((A**3+B**3)**(1.0/3)/(C*C+1))) (5) EXP(A*X**2+B*X+C) (6) COS(X*Y/SQRT(X*X+Y*Y))**3 6. 用FORTRAN语句完成下列操作: (1) 将变量I的值增加1。I=I+1 (2) I的立方加上J,并将结果保存到I中。 I=I**3+J (3) 将E和F中大者存储到G中。G=Max(E,F) (4) 将两位自然数N的个位与十位互换,得到一个新的数存储到M中(不考虑个位为0的情况) M=MOD(N,10)*10+N/10 第三章选择结构程序设计第43页 1、2、3、5、6、7、9 1.分析下列程序运行结果 (1) LOGICAL P INTEGER I,I1,I2,I3 P=.FALSE. READ*,I I1=MOD(I,10) I2=MOD(I/10,10) I3=I/100

Fortran常用函数

1、RANDOM_NUMBER Syntax ['sint?ks] n. 语法 CALL RANDOM_NUMBER (harvest结果) Intrinsic Subroutine(固有子程序):Returns a pseudorandom number greater than or equal to zero and less than one from the uniform distribution. 返回大于或等于0且小于1,服从均匀分布的随机数 2、RNNOA/ DRNNOA (Single/Double precision) Generate pseudorandom numbers from a standard normal distribution using an acceptance/rejection method. 产生服从标准正态分布的随机数 Usage(用法) CALL RNNOA (NR, R) Arguments(参数) NR— Number of random numbers to generate. (Input) 要产生随机数的个数 R— Vector of length NR containing the random standard normal deviates. (Output) 输出长度为NR,随机正态分布的向量 Comments(注解) The routine RNSET can be used to initialize the seed of the random number generator. The routine RNOPT can be used to select the form of the generator. 程序RNSET可以用来初始化随机数发生器的种子 Example In this example, RNNOA is used to generate five pseudorandom deviates from a standard normal distribution. INTEGER ISEED, NOUT, NR REAL R(5) EXTERNAL RNNOA, RNSET, UMACH C CALL UMACH (2, NOUT) NR = 5 ISEED = 123457 CALL RNSET (ISEED) CALL RNNOA (NR, R) WRITE (NOUT,99999) R 99999 FORMAT (' Standard normal random deviates: ', 5F8.4) END Output Standard normal random deviates: 2.0516 1.0833 0.0826 1.2777 -1.2260

ADINA常见问题解答

ADINA常见问题解答 一般问题 Q:怎样改进ADINA-AUI 中实体的显示效果? A:在某些情况下,ADINA-AUI 显示的实体在边界上不光滑,这仅仅是显示的问题,并不影响几何尺寸的精确度。为了改进显示的效果, 1 点击Modify Mesh Plot 。 2 点击Line Depiction 。 3 将ADINA-M Chord Angle 由默认的0.4改为0.1 并且点击OK。 4 点击Surface Depiction 。 5将ADINA-M Chord Angle 由默认的0.4改为0.1 并且点击OK。 6 点击OK,关闭Modify Mesh Plot 对话框。 Q:为什么AUI 的图形功能在我的计算机上不能正常的工作? A:有些计算机的显卡在Open GL 图形系统中不能正常的工作。请切换到Windows GDI 图形系统,在Edit 菜单中,点击Graphics System ,然后选择Windows GDI 图形系统。 Q:当我从ADINA-AUI 打印文件时,为什么打印不出来任何结果? A:注意只有Windows 版本才会发生这样的问题。 当使用Open GL 图形方式时,有的打印机会出现上述问题。为解决该问题,当打印的时候,选择Windows GDI 图形方式。从菜单Edit > Graphics System…中选择Windows GDI 作为图形系统,然后开始打印。注意打印结束后,可以将图形系统切换回Open GL 以便获得更快的图形效果。 Q:为什么安装了浮动License(Floating Industry或者Floating Educational)后,Adina无法启动? A:如果安装过程正确,而且电脑上的防火墙不阻止Adina读取服务器上的License,那么这样的问题一般是由于计算机使用了中文名。不论是Adina的服务器还是Adina客户端,都不允许使用中文计算机名。 Q:如何将壳单元厚度显示出来? A:在Display-->Geometry/Mesh Plot-->Modify打开的窗口中点击Element Depiction,在新打开的窗口中的Shell Element Attributes域中选择Top/Bottom(默认是Mid-Surface)。 有关界面启动 Q:怎样在Windows 版本中以批处理的方式运行ADINA? A:在Windows 版本中,ADINA 常常是在交互方式下运行。然而,有时为了连续进行几项作业,则必须在批处理方式下运行。 以批处理方式运行ADINA-AUI 的命令为: ...\aui.exe -b -m [b|w] .[in|plo] 这里…\ 是指aui.exe 的全路径名。 值可以用bytes(b) 或者 words(w) 来定义。1 word = 4 bytes 。 例如,在批处理方式下运行prob02.in 文件,并且分配20Mb 内存(假设aui.exe 安装在c:\adina\bin) ,命令行就是: c:\adina\bin\aui.exe -b -m 20mb prob02.in 注意在定义 值时,m 可以是m(Mega)、k(Kilo)、g(Giga) 。 选项-b的含义是用adina-aui读一遍命令流,但是不打开adina-aui(如果命令流中有生成dat文件的命令行,则会自动生成一个dat文件。)。如果不用-b选项,会看到打开adina-aui,并且打开模型。批处理方式下运行ADINA 求解器的命令行是: ...\.exe -b -s -m [b|w] -M [b|w] -t <#cpu> .dat 这里.exe 是adina、adinaf、adinat、adfsi或者adtmc ,…\ 是指.exe 的全路径名。 是分配给sparse solver 内存值,<#cpu> 定义了cpu 的数目。 例如,在批处理方式下运行prob02.dat 文件,分配10Mw 的内存给ADINA求解器,分配100Mw 的内存给sparse solver ,使用2个cpu ,命令行如下所示(假设adina.exe 安装在c:\adina\bin ): c:\adina\bin\adina.exe -b -s -m 10mw -M 100mw -t 2 prob02.dat 选项-b和-s是为了保证求解完成后自动关掉求解器窗口。 以下是当ADINA安装在c:\adina目录下时,顺序求解两个模型(prob02.in和prob03.in)的批处理文

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知识点总结

F O R T R A N 第2章FORTRAN90基础知识: 程序单元的概念: fortran90程序是一种分块形式的程序,整个程序由若干程序单元块组成。每个程序只有一个主程序单元。各单元体的程序体形式上相同。 程序单元可以是主程序、子程序(外部过程或内部过程)、模块MODULE (供其他程序单元引用即把该程序单元内的全部语句复制到程序单元中)或块数据程序单元BLOCK 。 语言元素:指在程序设计中用到的基本成分,如字符集、常量、变量、记号(标号、关键字、名字、常数、运算符和定界符)以及其他的基本结构等。 字符集:英文字母、阿拉伯数字、下划线、21个特殊字符($和?没有规定用法)。 数据结构: 整型INTEGER (34-2下划线后面是种别参数),n 位字长的计算机的数据表示范围一般为12~211-+---n n ,种别参数由内在询问函数KIND 送回,种别值提供的最小范围由内在函数SELECTED-INT-KIND 送回,表示十进制幂的范围由内在函数RANGE 送回; 实型REAL ,小数形式和指数形式;复型COMPLEX (种别类

型参数值取实部与虚部中较大者); 字符型CHARACTER,由一对单撇号或双撇号之间的字符序列组成; 逻辑型LOGICAL。 派生数据类型TYPE; 数组INTEGER,DIMENSION(1,50)::A,可直接对数组元素进行运算如3*A,SQRT(A); 字符子串,在字符串CHARACTER(LEN=80)::ROW中,ROW(1:3)就表示字符串ROW中第1到第3个元素组成的子串。 变量名的命名规则:不能超过31个字符;组成成分是字母、数字、下划线;第一个字符必须是字母。 第3章基本语句: 类型说明语句:类型说明(种别说明),属性说明::变量名表 尽量避免把两个实数作相等或不相等的比较。淘汰隐式说明IMPLICIT NONE 种别说明:种别参数即对可移植数据精度和范围进行选择的机制 KIND(X) 返回变元X的种别参数值 SELECTED-REAL-KIND(n,m) 产生一个种别值,它表示某一精度和范围。N指十进制有效位数,m指明值范围内以10为底的幂次。

华测静态数据处理流程

静态数据处理 一.静态测量得准备工作(简单介绍) ............................................................................................... 2 二.数据下载: (3) 安装主机USB 驱动: ................................................................................................................ 3 打开下载软件hcloader: ........................................................................................................... 3 输入测站信息:.......................................................................................................................... 3 下载数据: ................................................................................................................................. 3 三.数据处理操作过程 . (4) 软件安装: ................................................................................................................................. 4 安装软件狗驱动:...................................................................................................................... 4 数据处理过程 (4) 文件>新建项目 导入观测数据 查瞧,设置坐标系 基线处理 网平差 成果报告 附 C 、D 、E 级GPS 测量手簿记录格式 (6) 一.静态测量得准备工作(简单介绍) (如上图),特长或特短边得出现(如下图)都会使误差增大。 在野外勘测时,尽量选择周围无遮挡、无高压线、无强电磁干扰得地方进行定点,观测,这样不仅可以保证精度,也可以减少内业处理得很多麻烦。 在外业测量时,切换到静态后,要查瞧数据记录指示灯(黄灯)就是否有规律闪烁(间隔5秒),否则重新启动接收机,重新切换到静态。 已知控制点 未知待定点

fortran中批处理实现

********************************************* fortran中批处理命令的实现函数: 利用systemqq命令(需要调用DFLIB 数据库) ********************************************* 例1: USE DFLIB character*100 CMD LOGICAL(4) res CMD="dir/a-d/b/s "//trim(fPath)//" >"//trim(outPut) res=SYSTEMQQ(CMD) 例2: USE DFLIB LOGICAL(4) result result = SYSTEMQQ('copy e:\dir.txt e:\test\dir.txt') !将e:\dir.txt 复制到e:\test\dir.txt文件中。!****************实例3:复制文件************************* 例3: programmain_pro USE DFLIB implicit none integer,parameter::sta_num=123 character(5),dimension(sta_num)::sta_ID character(500)::filein,fileout character(5000)::cmd logical(4)::judge

integer::status,is open(1,file='山东.txt',status='old',action='read',iostat=status) read(1,*) do is=1,sta_num read(1,*) sta_ID(is) filein='Z:\data\降水逐小时数据-戴至修\precip_data\'//sta_ID(is)//'_precip.txt' open(2,file= filein,status='old',action='read',iostat=status) if(status/=0) goto 1000 fileout='Z:\data\降水逐小时数据-戴至修\山东省-降水数据\'//sta_ID(is)//'_precip.txt' cmd='copy '//filein//' '//fileout judge=SYSTEMQQ( cmd) 1000 continue enddo end program

fortran心得

Read 的规则: 按行读取,每次读一行,读完后光标自动跳到下一行的开头,空格和逗号代表结束(所以空格和逗号也是读取的一部分的话,需要使用“输入输出格式”) 如果想要将一行数据读入数组,代码为: Read(10,*) s(:,:,:) 不用规定输入输出格式,因为会根据s(:,:,:)确定需要读入的数字的个数,然后fortran会按部就班的读取,甚至文件中当前这一行的数字个数不足以填满s(:,:,:)的时候,read会自动跳到下一行继续搜索数字,直到填满s(:,:,:)为止。 但是需要注意给数组赋值的顺序:read会把它搜索到的第一个数字给s(1,1,1),第二个给s(2,1,1),第三个给s(3,1,1)… 程序9 1: 将read(unit=field,fmt="(A79)",iostat=status)buffer 中的A79改为A2,结果只输出每行的前两个字符,说明read是按整行整行读取的。 中间空了几行之后,空行之后的内容还是能被读取和输出,这说明,空行和空白是不一样的:空行也算是一种文本内容,因此不会终止读取,而空白意味着结束。 !读取文件 program main implicit none character(len=79)::filename="number.txt",buffer integer,parameter::field=10 integer::status=0 logical alive inquire(file=filename,exist=alive) if(alive)then open(unit=field,file=filename) do while(.true.) read(unit=field,fmt="(A79)",iostat=status)buffer if(status/=0)exit write(*,"(A79)")buffer end do else write(*,*)filename,"does't exist." end if pause stop end program main ============================================= 附number.txt =============================== 1234555666

Fortran常见错误

fortran运行常用错误(转) (2006-11-1010:18:44) 转载▼ 分类:分子动力学 41Insufficient virtual memory虚拟内存不足 70Integer overflow整数溢出错误 71Integer divide by zero整数除0错误 72Floating overflow浮点数溢出错误 73Floating divide by zero浮点数除0错误 74Floating underflow浮点数下溢错误 75Floating point exception浮点数异常错误 77Subscript out of range数组定义超出边界 95Floating-point conversion failed浮点数格式转换失败 146Null pointer error空指针错误 147Stack overflow堆栈溢出 148String length error字符串长度超出允许范围 149Substring error数组下标超出允许范围 150Range error整数值超出允许范围 151Allocatable array is already allocated数组重复定义 161Program Exception-array bounds exceeded引用数组下标超出允许范围162Program Exception-denormal floating-point operand非法浮点数操作符163Program Exception-floating stack check浮点数堆栈检查 164Program Exception-integer divide by zero整数除0错误 165Program Exception-integer overflow整数溢出 166Program Exception-privileged instruction非法执行特权指令 168Program Exception-illegal instruction非法指令 170Program Exception-stack overflow堆栈溢出

相关主题
文本预览
相关文档 最新文档