| 
本帖最后由 godenflame135 于 2012-4-29 23:34 编辑
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  
 
 想问一下我这个程序中输入相同纬度,不同经度时,为什么转换的结果 r 不相同呢?是程序写的有错误吗? 
		
 program cal_r implicit nonecharacter       :: grid
 real                 ::    lat,  lon,  r,s
 real,external    ::    ezlh_convert
 write(*,*) ezlh_convert('Nl', 80., 10., r, s)
 write(*,*) r,s
 end
 
 function ezlh_convert(grid, lat, lon, r, s)
 character*(*) grid
 real lat, lon, r, s
 !
 ! convert geographic coordinates (spherical earth) to
 ! azimuthal equal area or equal area cylindrical grid coordinates
 !
 ! status = ezlh_convert (grid, lat, lon, r, s)
 !
 ! input : grid - projection name '[NSM][lh]'
 !               where l = "low"  = 25km resolution
 !                     h = "high" = 12.5km resolution
 !  lat, lon - geo. coords. (decimal degrees)
 !
 ! output: r, s - column, row coordinates
 !
 ! result: status = 0 indicates normal successful completion
 !   -1 indicates error status (point not on grid)
 !
 !--------------------------------------------------------------------------
 integer cols, rows, scale
 real Rg, phi, lam, rho
 ! radius of the earth (km), authalic sphere based on International datum parameter (RE_km = 6371.228)
 ! nominal cell size in kilometers
 parameter (CELL_km = 25.067525)
 ! scale factor for standard paralles at +/-30.00 degreesparameter (COS_PHI1 = .866025403)
 parameter (PI = 3.141592653589793)rad(t) = t*PI/180.
 deg(t) = t*180./PI
 ezlh_convert = -1 if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) thencols = 721
 rows = 721
 else if (grid(1:1).eq.'M') then
 cols = 1383
 rows = 586
 else
 print *, 'ezlh_convert: unknown projection: ', grid
 return
 endif
 if (grid(2:2).eq.'l') thenscale = 1
 else if (grid(2:2).eq.'h') then
 scale = 2
 else
 print *, 'ezlh_convert: unknown projection: ', grid
 return
 endif
         Rg = scale * RE_km/CELL_km !! r0,s0 are defined such that cells at all scales
 ! have coincident center points
 !
 r0 = (cols-1)/2. * scale
 s0 = (rows-1)/2. * scale
 phi = rad(lat)lam = rad(lon)
 if (grid(1:1).eq.'N') thenrho = 2 * Rg * sin(PI/4. - phi/2.)
 r = r0 + rho * sin(lam)
 s = s0 + rho * cos(lam)
 else if (grid(1:1).eq.'S') thenrho = 2 * Rg * cos(PI/4. - phi/2.)
 r = r0 + rho * sin(lam)
 s = s0 - rho * cos(lam)
         else if (grid(1:1).eq.'M') thenr = r0 + Rg * lam * COS_PHI1
 s = s0 - Rg * sin(phi) / COS_PHI1
 endif ezlh_convert = 0return
 end
 program cal_r 
 implicit nonecharacter       :: grid
 real                 ::    lat,  lon,  r,s
 real,external    ::    ezlh_convert
 write(*,*) ezlh_convert('Nl', 80., 10., r, s)
 write(*,*) r,s
 end
 
 function ezlh_convert(grid, lat, lon, r, s)
 character*(*) grid
 real lat, lon, r, s
 !
 ! convert geographic coordinates (spherical earth) to
 ! azimuthal equal area or equal area cylindrical grid coordinates
 !
 ! status = ezlh_convert (grid, lat, lon, r, s)
 !
 ! input : grid - projection name '[NSM][lh]'
 !               where l = "low"  = 25km resolution
 !                     h = "high" = 12.5km resolution
 !  lat, lon - geo. coords. (decimal degrees)
 !
 ! output: r, s - column, row coordinates
 !
 ! result: status = 0 indicates normal successful completion
 !   -1 indicates error status (point not on grid)
 !
 !--------------------------------------------------------------------------
 integer cols, rows, scale
 real Rg, phi, lam, rho
 ! radius of the earth (km), authalic sphere based on International datum parameter (RE_km = 6371.228)
 ! nominal cell size in kilometers
 parameter (CELL_km = 25.067525)
 ! scale factor for standard paralles at +/-30.00 degreesparameter (COS_PHI1 = .866025403)
 parameter (PI = 3.141592653589793)rad(t) = t*PI/180.
 deg(t) = t*180./PI
 ezlh_convert = -1 if ((grid(1:1).eq.'N').or.(grid(1:1).eq.'S')) thencols = 721
 rows = 721
 else if (grid(1:1).eq.'M') then
 cols = 1383
 rows = 586
 else
 print *, 'ezlh_convert: unknown projection: ', grid
 return
 endif
 if (grid(2:2).eq.'l') thenscale = 1
 else if (grid(2:2).eq.'h') then
 scale = 2
 else
 print *, 'ezlh_convert: unknown projection: ', grid
 return
 endif
         Rg = scale * RE_km/CELL_km !! r0,s0 are defined such that cells at all scales
 ! have coincident center points
 !
 r0 = (cols-1)/2. * scale
 s0 = (rows-1)/2. * scale
 phi = rad(lat)lam = rad(lon)
 if (grid(1:1).eq.'N') thenrho = 2 * Rg * sin(PI/4. - phi/2.)
 r = r0 + rho * sin(lam)
 s = s0 + rho * cos(lam)
 else if (grid(1:1).eq.'S') thenrho = 2 * Rg * cos(PI/4. - phi/2.)
 r = r0 + rho * sin(lam)
 s = s0 - rho * cos(lam)
         else if (grid(1:1).eq.'M') thenr = r0 + Rg * lam * COS_PHI1
 s = s0 - Rg * sin(phi) / COS_PHI1
 endif ezlh_convert = 0return
 end
 
 
 纬度40,经度10的时候结果是397.30444 ,571.5638 
 纬度80,经度10的时候结果是367.6932,403.6304 
 纬度90,经度10的时候结果是360.000,360.000 |