|
发表于 2012-5-13 10:32:18
|
显示全部楼层
程序确实比较长,给你贴出来了,暂时没时间看了,看完了再来说
- ! 这是 读取AWS产品 一个格点值 的程序。
- ! 适用于MICAPS第3类数据格式,而且:等值线条数为0、剪切区域边缘线上的点数为0、单站填图要素的个数为1。
- PROGRAM ReadT213_1
- IMPLICIT NONE !强制变量声明
- ! 变量定义
- INTEGER :: K,MaxDD,D,h,maxhh,GD
- REAL :: JD,WD,DATA0(31),JD0,WD0
- CHARACTER(7) :: Str1
- CHARACTER(30) :: Str2
- CHARACTER(2) :: YY,MM,DD,HH
- CHARACTER(256) :: InPath,OutPath,OpenFileName,WriteFileName
- !=========注意:用等号注释的变量要根据实际需要进行修改==========================
- !=========要获取格点的 经度 JD0、纬度WD0 ======================================
- JD0 = 109.309; WD0 = 35.194
- ! JD0 = 103.95; WD0 = 30.57 ! 成都双流机场的 纬度、经度
- ! JD1 = 103.00; WD1 = 30.00
- ! JD2 = 104.00; WD2 = 31.00
- ! ===============要读取的文件路径===============================================
- InPath = "D:\cll\MICAPSdata\aws5\" ! 输入 数据文件所在的路径
- OutPath = "D:\cll\OUT\" ! 输出 数据文件所在的路径
- ! ===============要读取数据的 年:MM,月:MM =================================
- YY = "11"
- MM = "05"
- ! =============== MM月的最大天数 =============================================
- MaxDD = 31
- maxhh = 23
- ! =============================================================================
- WriteFileName = TRIM(OutPath) // "aws-" // YY // MM // ".txt" ! 输出文件名(含路径)
- ! 开始循环读取格点数据
- D = 1 ! 从每月的1号开始读取数据
- DO WHILE (D <= MaxDD)
- ! 一下是将整形数D(日期)转换为字符的选项,便于文件名用。有点冗余,但可以达到目的
- SELECT CASE(D)
- CASE (1)
- DD = "01"
- CASE (2)
- DD = "02"
- CASE (3)
- DD = "03"
- CASE (4)
- DD = "04"
- CASE (5)
- DD = "05"
- CASE (6)
- DD = "06"
- CASE (7)
- DD = "07"
- CASE (8)
- DD = "08"
- CASE (9)
- DD = "09"
- CASE (10)
- DD = "10"
- CASE (11)
- DD = "11"
- CASE (12)
- DD = "12"
- CASE (13)
- DD = "13"
- CASE (14)
- DD = "14"
- CASE (15)
- DD = "15"
- CASE (16)
- DD = "16"
- CASE (17)
- DD = "17"
- CASE (18)
- DD = "18"
- CASE (19)
- DD = "19"
- CASE (20)
- DD = "20"
- CASE (21)
- DD = "21"
- CASE (22)
- DD = "22"
- CASE (23)
- DD = "23"
- CASE (24)
- DD = "24"
- CASE (25)
- DD = "25"
- CASE (26)
- DD = "26"
- CASE (27)
- DD = "27"
- CASE (28)
- DD = "28"
- CASE (29)
- DD = "29"
- CASE (30)
- DD = "30"
- CASE (31)
- DD = "31"
- ENDSELECT
- h = 0
- DO WHILE (h <= Maxhh)
- SELECT CASE(h)
- case(0)
- hh = "00"
- case(1)
- hh = "01"
- CASE (2)
- hh = "02"
- CASE (3)
- hh = "03"
- CASE (4)
- hh = "04"
- CASE (5)
- hh = "05"
- CASE (6)
- hh = "06"
- CASE (7)
- hh = "07"
- CASE (8)
- hh = "08"
- CASE (9)
- hh = "09"
- CASE (10)
- hh = "10"
- CASE (11)
- hh = "11"
- CASE (12)
- hh = "12"
- CASE (13)
- hh = "13"
- CASE (14)
- hh = "14"
- CASE (15)
- hh = "15"
- CASE (16)
- hh = "16"
- CASE (17)
- hh = "17"
- CASE (18)
- hh = "18"
- CASE (19)
- hh = "19"
- CASE (20)
- hh = "20"
- CASE (21)
- hh = "21"
- CASE (22)
- hh = "22"
- CASE (23)
- hh = "23"
- ENDSELECT
- OpenFileName = TRIM(InPath) // YY // MM // DD // HH //".aws" ! 输入文件名(含路径)
- ! PRINT *,OpenFileName
- OPEN(11,FILE = OpenFileName,STATUS = "OLD",ERR = 110) ! 打开文件出错时,则转到110行
- READ(11,*) Str1,K,Str2 !读第一行
- ! PRINT *,Str1,K,Str2
- READ(11,*) K,K,K,K,k !读第二行
- ! PRINT *,K
- !JD = 0.00
- !WD = 0.00
- DO while (JD == JD0 .and. WD == WD0)
- READ(11,*) K,JD,WD,GD,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k,k
- ENDDO
- ! PRINT *,JD,WD,DATA0(D)
- GOTO 111
- 110 &
- DATA0(D) = 9999
- PRINT *,YY,"年",MM,"月",D,"日",h,"时 文件不存在!!!!!!"
- 111 &
- h = h + 1
- enddo
- D = D + 1
- CLOSE (11)
-
- enddo
- ! 开始向 WeiteFileName 中写数据,格式:年 月 日 格点值
- OPEN(12,FILE = WriteFileName)
- D = 1
- DO WHILE(D<=MaxDD)
- h = 0
- do while(h<=maxhh)
- WRITE(12,120) YY,MM,D,H,JD,WD,GD
- h = h + 1
- enddo
- D = D + 1
- ENDDO
- 120 FORMAT(1X,A2,2X,A2,2X,I3,2X,I3,2X,F8.2,2X,F7.2,I5)
- CLOSE (12)
- END
|
|