爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3506|回复: 2

[经验总结] 分享一个查找后一天和查找前一天的子程序。

[复制链接]

新浪微博达人勋

发表于 2017-4-3 12:19:48 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
    subroutine nextday(yy,mm,dd,yx,mx,dx) ! find next date 查找每月下一天
    implicit none
    integer yy,mm,dd,yx,mx,dx
    integer nt
    if (mod(yy,4)==0) then
       nt =29
    else
       nt=28
    endif
    yx=yy
    mx=mm
    dx=dd+1
       if ((mm==12).and.(dd==31)) then
       yx=yy+1
    mx=1
    dx=1
    endif
    if ((mm==2).and.(dd==nt)) then
       yx=yy
    mx=3
    dx=1
    endif
    if (((mm==1).or.(mm==3).or.(mm==5).or.(mm==7).or.(mm==8).or.(mm==10)).and.(dd==31)) then
       yx=yy
    mx=mx+1
    dx=1
    endif
       if (((mm==4).or.(mm==6).or.(mm==9).or.(mm==11)).and.(dd==30)) then
       yx=yy
    mx=mx+1
    dx=1
    endif
end subroutine nextday
    subroutine beforeday(yy,mm,dd,yx,mx,dx)  !查找每月前一天
    integer yy,mm,dd,yx,mx,dx
    integer nt
    if (mod(yy,4)==0) then
       nt =29
    else
       nt=28
    endif
    yx=yy
    mx=mm
    dx=dd-1
       if ((mm==1).and.(dd==1)) then
       yx=yy-1
    mx=12
    dx=31
    endif
    if ((mm==3).and.(dd==1)) then
       yx=yy
    mx=2
    dx=nt
    endif
    if (((mm==2).or.(mm==4).or.(mm==6).or.(mm==8).or.(mm==9).or.(mm==11)).and.(dd==1)) then
       yx=yy
    mx=mx-1
    dx=31
    endif
       if (((mm==5).or.(mm==7).or.(mm==10).or.(mm==12)).and.(dd==1)) then
       yx=yy
    mx=mx-1
    dx=30
    endif
end subroutine beforeday
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-4-3 12:27:10 | 显示全部楼层
好像閏年不是這麼求的吧???
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-4-3 12:59:01 | 显示全部楼层
柿子柿子柿子 发表于 2017-4-3 12:27
好像閏年不是這麼求的吧???

嗯对,不过因为我自己的主程序时间范围是1950年-2000年,所以就用了不严谨的求法,有需求的自己改一下哈~
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表