lat=42.4025*PI/180.0
纬度应该是弧度,而非角度。
谢谢你,我明白了原理,非常感谢,已经算出来了 pasuka 发表于 2018-1-23 11:21
依旧是问题代码:
1、明明打开同一个文件,open语句为何放在do循环内?
2、有open无close;
你说的对,这样也能算出来,把open放出来和在里面都是可以的,但是习惯很重要,所以我决定拿出来了,,至于这个单双精度浮点问题刚开始接受,需要慢慢适应 pasuka 发表于 2018-1-23 11:21
依旧是问题代码:
1、明明打开同一个文件,open语句为何放在do循环内?
2、有open无close;
你好,听了你的建议我觉得确实应该严谨的 写才能避免出错,我还想问问你这个计算的时候所有的数字都得写的浮点型的吗,定义变量也要这样吗 vvt 发表于 2018-1-23 10:40
lat=42.4025*PI/180.0
纬度应该是弧度,而非角度。
我刚才又算了一遍,还是不行,大体思路我明白了,主要是角度和弧度的互换,太容易出错了,你刚才说的纬度需要换成弧度我觉得不对,我重新编了代码,后面都表明了单位,可是还是浮点数异常或者NAN,实在不知为何,计算了一上午,求解
program ex0109
real*8:: delta(366),y(366),ws(366),sl(366)
integer n
real*8,parameter::pi=3.1415926
real*8 lat
lat=42.4025
do n=1,366
y(n)=(2*pi)*(n-1)/366!年角:弧度
delta(n)=(0.006918-0.399912*cos(y(n))+0.070257*sin(y(n))-0.006758*cos(2*y(n))&
+0.000907*sin(2*y(n))-0.002697*cos(3*y(n))+0.00148*sin(3*y(n)))!太阳赤纬:角度
!delta(n)=6.918E-3-3.99912E-1*cos(y(n))+7.0257E-2*sin(y(n))-6.758E-3*cos(2*y(n))&
!+9.07E-4*sin(2*y(n))-2.697E-3*cos(3*y(n))+1.48E-3*sin(3*y(n))
ws(n)=acos(-tan(lat)*tan(delta(n)))!时角(角度),算出来为弧度
sl(n)=ws(n)*(2/15)*(pi/180)!日长:弧度
end do
!write(*,fmt="(365f8.2)")delta(n)
open(unit=7,file="D:\Fortran读写文件\计算云量\tiwen\2012tianwen")
write(*,*)sl*10
stop
end tan 就是弧度制的,不是你想什么制,就什么制。 向着光亮 发表于 2018-1-23 12:40
我刚才又算了一遍,还是不行,大体思路我明白了,主要是角度和弧度的互换,太容易出错了,你刚才说的纬度 ...
坚持角度制的话,请查找手册,譬如:
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gfortran/ASIND.html#ASIND
9.20 ASIND — Arcsine function, degrees
Description:
ASIND(X) computes the arcsine of its X in degrees (inverse of SIND(X)).
This function is for compatibility only and should be avoided in favor of standard constructs wherever possible.
Standard:
GNU Extension, enabled with -fdec-math.
Class:
Elemental function
Syntax:
RESULT = ASIND(X)
Arguments:
X The type shall be either REAL and a magnitude that is less than or equal to one - or be COMPLEX.
Return value:
The return value is of the same type and kind as X. The real part of the result is in degrees and lies in the range -90 \leq \Re \asin(x) \leq 90.
Example:
program test_asind
real(8) :: x = 0.866_8
x = asind(x)
end program test_asind
Specific names:
Name Argument Return type Standard
ASIND(X) REAL(4) X REAL(4) GNU Extension
DASIND(X) REAL(8) X REAL(8) GNU Extension
See also:
Inverse function: SIND Radians function: ASIN fcode 发表于 2018-1-23 12:58
tan 就是弧度制的,不是你想什么制,就什么制。
tan计算的不就是一个数值吗?为何是弧度制? 向着光亮 发表于 2018-1-23 21:18
tan计算的不就是一个数值吗?为何是弧度制?
请先回顾计算方法课程的相关内容:三角函数值
传送门:
http://blog.csdn.net/eric88/article/details/17031311 向着光亮 发表于 2018-1-23 21:18
tan计算的不就是一个数值吗?为何是弧度制?
tan 的定义域是以弧度制为单位,而不是值域。
所以,tan(lat) 要求 lat 是以弧度制为单位。其结果(值域),是个比值,无单位。 vvt 发表于 2018-1-23 22:59
tan 的定义域是以弧度制为单位,而不是值域。
所以,tan(lat) 要求 lat 是以弧度制为单位。其结果(值域 ...
好的,明白了
页:
1
[2]