PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/WPS/util/src/plotgrids.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 732 lines | 412 code | 172 blank | 148 comment | 35 complexity | b5f0a0896d9a0affb8c5193ac4c915e8 MD5 | raw file
Possible License(s): AGPL-1.0
  1. program plotgrids
  2. use map_utils
  3. implicit none
  4. ! Parameters
  5. integer, parameter :: MAX_DOMAINS = 21
  6. ! Variables
  7. integer :: iproj_type, n_domains, io_form_output, dyn_opt
  8. integer :: i, j, max_dom, funit, io_form_geogrid
  9. integer :: interval_seconds
  10. integer, dimension(MAX_DOMAINS) :: parent_grid_ratio, parent_id, ixdim, jydim
  11. integer, dimension(MAX_DOMAINS) :: i_parent_start, j_parent_start, &
  12. s_we, e_we, s_sn, e_sn, &
  13. start_year, start_month, start_day, start_hour, &
  14. end_year, end_month, end_day, end_hour
  15. logical, dimension(MAX_DOMAINS) :: active_grid
  16. real :: known_lat, known_lon, stand_lon, truelat1, truelat2, known_x, known_y, &
  17. dxkm, dykm, ref_lat, ref_lon, ref_x, ref_y
  18. real :: dx, dy
  19. real :: ri, rj, rlats, rlons, rlate, rlone
  20. real :: polat , rot
  21. real :: rparent_gridpts
  22. real :: xa,xb,ya,yb,xxa,xxy,yya,yyb
  23. real :: xs, xe, ys, ye
  24. integer :: jproj, jgrid, jlts, iusout, idot, ier
  25. integer :: ltype , idom
  26. real, dimension(MAX_DOMAINS) :: parent_ll_x, parent_ll_y, parent_ur_x, parent_ur_y
  27. character (len=128) :: geog_data_path, opt_output_from_geogrid_path, opt_geogrid_tbl_path
  28. character (len=128), dimension(MAX_DOMAINS) :: geog_data_res
  29. character (len=128) :: map_proj
  30. character (len=128), dimension(MAX_DOMAINS) :: start_date, end_date
  31. character (len=3) :: wrf_core
  32. character (len=1) :: gridtype
  33. logical :: do_tiled_output
  34. integer :: debug_level
  35. logical :: is_used
  36. type (proj_info) :: map_projection
  37. namelist /share/ wrf_core, max_dom, start_date, end_date, &
  38. start_year, end_year, start_month, end_month, &
  39. start_day, end_day, start_hour, end_hour, &
  40. interval_seconds, io_form_geogrid, opt_output_from_geogrid_path, &
  41. debug_level, active_grid
  42. namelist /geogrid/ parent_id, parent_grid_ratio, &
  43. i_parent_start, j_parent_start, s_we, e_we, s_sn, e_sn, &
  44. map_proj, ref_x, ref_y, ref_lat, ref_lon, &
  45. truelat1, truelat2, stand_lon, dx, dy, &
  46. geog_data_res, geog_data_path, opt_geogrid_tbl_path
  47. ! Set defaults for namelist variables
  48. debug_level = 0
  49. io_form_geogrid = 2
  50. wrf_core = 'ARW'
  51. max_dom = 1
  52. geog_data_path = 'NOT_SPECIFIED'
  53. ref_x = NAN
  54. ref_y = NAN
  55. ref_lat = NAN
  56. ref_lon = NAN
  57. dx = 10000.
  58. dy = 10000.
  59. map_proj = 'Lambert'
  60. truelat1 = NAN
  61. truelat2 = NAN
  62. stand_lon = NAN
  63. do i=1,MAX_DOMAINS
  64. geog_data_res(i) = 'default'
  65. parent_id(i) = 1
  66. parent_grid_ratio(i) = INVALID
  67. s_we(i) = 1
  68. e_we(i) = INVALID
  69. s_sn(i) = 1
  70. e_sn(i) = INVALID
  71. start_year(i) = 0
  72. start_month(i) = 0
  73. start_day(i) = 0
  74. start_hour(i) = 0
  75. end_year(i) = 0
  76. end_month(i) = 0
  77. end_day(i) = 0
  78. end_hour(i) = 0
  79. start_date(i) = '0000-00-00_00:00:00'
  80. end_date(i) = '0000-00-00_00:00:00'
  81. end do
  82. opt_output_from_geogrid_path = './'
  83. opt_geogrid_tbl_path = 'geogrid/'
  84. interval_seconds = INVALID
  85. ! Read parameters from Fortran namelist
  86. do funit=10,100
  87. inquire(unit=funit, opened=is_used)
  88. if (.not. is_used) exit
  89. end do
  90. open(funit,file='namelist.wps',status='old',form='formatted',err=1000)
  91. read(funit,share)
  92. read(funit,geogrid)
  93. close(funit)
  94. dxkm = dx
  95. dykm = dy
  96. known_lat = ref_lat
  97. known_lon = ref_lon
  98. known_x = ref_x
  99. known_y = ref_y
  100. ! Convert wrf_core to uppercase letters
  101. do i=1,3
  102. if (ichar(wrf_core(i:i)) >= 97) wrf_core(i:i) = char(ichar(wrf_core(i:i))-32)
  103. end do
  104. ! Before doing anything else, we must have a valid grid type
  105. gridtype = ' '
  106. if (wrf_core == 'ARW') then
  107. gridtype = 'C'
  108. dyn_opt = 2
  109. else if (wrf_core == 'NMM') then
  110. gridtype = 'E'
  111. dyn_opt = 4
  112. end if
  113. if (gridtype /= 'C' .and. gridtype /= 'E') then
  114. write(6,*) 'A valid wrf_core must be specified in the namelist. '// &
  115. 'Currently, only "ARW" and "NMM" are supported.'
  116. stop
  117. end if
  118. if (max_dom > MAX_DOMAINS) then
  119. write(6,*) 'In namelist, max_dom must be <= ',MAX_DOMAINS,'. To run with more'// &
  120. ' than ',MAX_DOMAINS,' domains, increase the MAX_DOMAINS parameter.'
  121. stop
  122. end if
  123. ! Every domain must have a valid parent id
  124. do i=2,max_dom
  125. if (parent_id(i) <= 0 .or. parent_id(i) >= i) then
  126. write(6,*) 'In namelist, the parent_id of domain ',i,' must be in '// &
  127. 'the range 1 to ',i-1
  128. stop
  129. end if
  130. end do
  131. ! Convert map_proj to uppercase letters
  132. do i=1,len(map_proj)
  133. if (ichar(map_proj(i:i)) >= 97) map_proj(i:i) = char(ichar(map_proj(i:i))-32)
  134. end do
  135. ! Assign parameters to module variables
  136. if ((index(map_proj, 'LAMBERT') /= 0) .and. &
  137. (len_trim(map_proj) == len('LAMBERT'))) then
  138. iproj_type = PROJ_LC
  139. rot=truelat1
  140. polat=truelat2
  141. jproj = 3
  142. else if ((index(map_proj, 'MERCATOR') /= 0) .and. &
  143. (len_trim(map_proj) == len('MERCATOR'))) then
  144. iproj_type = PROJ_MERC
  145. rot=0.
  146. polat=0.
  147. jproj = 9
  148. else if ((index(map_proj, 'POLAR') /= 0) .and. &
  149. (len_trim(map_proj) == len('POLAR'))) then
  150. iproj_type = PROJ_PS
  151. rot=0.
  152. polat=SIGN(90., ref_lat)
  153. jproj = 1
  154. else if ((index(map_proj, 'ROTATED_LL') /= 0) .and. &
  155. (len_trim(map_proj) == len('ROTATED_LL'))) then
  156. iproj_type = PROJ_ROTLL
  157. else
  158. write(6,*) 'In namelist, invalid map_proj specified. Valid '// &
  159. 'projections are "lambert", "mercator", "polar", '// &
  160. 'and "rotated_ll".'
  161. stop
  162. end if
  163. n_domains = max_dom
  164. do i=1,n_domains
  165. ixdim(i) = e_we(i) - s_we(i) + 1
  166. jydim(i) = e_sn(i) - s_sn(i) + 1
  167. end do
  168. ! If the user hasn't supplied a known_x and known_y, assume the center of domain 1
  169. if (known_x == NAN) known_x = ixdim(1) / 2.
  170. if (known_y == NAN) known_y = jydim(1) / 2.
  171. ! Checks specific to C grid
  172. if (gridtype == 'C') then
  173. ! C grid does not support the rotated lat/lon projection
  174. if (iproj_type == PROJ_ROTLL) then
  175. write(6,*) 'Rotated lat/lon projection is not supported for the ARW core. '// &
  176. 'Valid projecitons are "lambert", "mercator", and "polar".'
  177. stop
  178. end if
  179. ! Check that nests have an acceptable number of grid points in each dimension
  180. do i=2,n_domains
  181. rparent_gridpts = real(ixdim(i)-1)/real(parent_grid_ratio(i))
  182. if (floor(rparent_gridpts) /= ceiling(rparent_gridpts)) then
  183. write(6,*) 'For nest ',i,' (e_we-s_we+1) must be one greater than an '// &
  184. 'integer multiple of the parent_grid_ratio.'
  185. stop
  186. end if
  187. rparent_gridpts = real(jydim(i)-1)/real(parent_grid_ratio(i))
  188. if (floor(rparent_gridpts) /= ceiling(rparent_gridpts)) then
  189. write(6,*) 'For nest ',i,' (e_sn-s_sn+1) must be one greater than an '// &
  190. 'integer multiple of the parent_grid_ratio.'
  191. stop
  192. end if
  193. end do
  194. end if
  195. ! Checks specific to E grid
  196. if (gridtype == 'E') then
  197. ! E grid supports only the rotated lat/lon projection
  198. if (iproj_type /= PROJ_ROTLL) then
  199. write(6,*) 'Rotated lat/lon is the only supported projection for the NMM core.'
  200. stop
  201. end if
  202. ! Check that the parent_grid_ratio is set to 3 for all nests
  203. do i=2,n_domains
  204. if (parent_grid_ratio(i) /= 3) then
  205. write(6,*) 'The parent_grid_ratio must be set to 3 for the NMM core.'
  206. stop
  207. end if
  208. end do
  209. CALL plot_e_grid ( ref_lat , -1. * ref_lon , &
  210. dy , dx, &
  211. n_domains , &
  212. e_we , e_sn , &
  213. parent_id , parent_grid_ratio , &
  214. i_parent_start , j_parent_start )
  215. stop
  216. end if
  217. do i=1,n_domains
  218. parent_ll_x(i) = real(i_parent_start(i))
  219. parent_ll_y(i) = real(j_parent_start(i))
  220. parent_ur_x(i) = real(i_parent_start(i))+real(ixdim(i))/real(parent_grid_ratio(i))-1.
  221. parent_ur_y(i) = real(j_parent_start(i))+real(jydim(i))/real(parent_grid_ratio(i))-1.
  222. end do
  223. call map_init(map_projection)
  224. call map_set(iproj_type, map_projection, &
  225. lat1=known_lat, &
  226. lon1=known_lon, &
  227. knowni=known_x, &
  228. knownj=known_y, &
  229. dx=dx, &
  230. stdlon=stand_lon, &
  231. truelat1=truelat1, &
  232. truelat2=truelat2, &
  233. ixdim=ixdim(1), &
  234. jydim=jydim(1))
  235. call ij_to_latlon(map_projection, 0.5, 0.5, rlats, rlons)
  236. call ij_to_latlon(map_projection, real(e_we(1))-0.5, real(e_sn(1))-0.5, rlate, rlone)
  237. call opngks
  238. ! Set some colors
  239. call gscr(1, 0, 1.00, 1.00, 1.00)
  240. call gscr(1, 1, 0.00, 0.00, 0.00)
  241. ! Do not grind them with details
  242. jgrid=10
  243. jlts=-2
  244. iusout=1
  245. idot=0
  246. call supmap(jproj,polat,stand_lon,rot,&
  247. rlats,rlons,rlate,rlone, &
  248. jlts,jgrid,iusout,idot,ier)
  249. call setusv('LW',1000)
  250. call perim(e_we(1)-1,1,e_sn(1)-1,1)
  251. call getset(xa,xb,ya,yb,xxa,xxy,yya,yyb,ltype)
  252. call set (xa,xb,ya,yb, &
  253. 1.,real(e_we(1)),1.,real(e_sn(1)),ltype)
  254. do idom = 2 , max_dom
  255. call getxy ( xs, xe, ys, ye, &
  256. idom , max_dom , &
  257. e_we , e_sn , &
  258. parent_id , parent_grid_ratio , &
  259. i_parent_start , j_parent_start )
  260. call line ( xs , ys , xe , ys )
  261. call line ( xe , ys , xe , ye )
  262. call line ( xe , ye , xs , ye )
  263. call line ( xs , ye , xs , ys )
  264. end do
  265. call frame
  266. write(6,*) ' '
  267. write(6,*) 'Creating plot in NCAR Graphics metafile...'
  268. write(6,*) ' '
  269. call clsgks
  270. write(6,*) ' *** Successful completion of program plotgrids.exe *** '
  271. stop
  272. 1000 write(6,*) 'Error opening namelist.wps'
  273. stop
  274. end program plotgrids
  275. subroutine getxy ( xs, xe, ys, ye, &
  276. dom_id , num_domains , &
  277. e_we , e_sn , &
  278. parent_id , parent_grid_ratio , &
  279. i_parent_start , j_parent_start )
  280. implicit none
  281. integer , intent(in) :: dom_id
  282. integer , intent(in) :: num_domains
  283. integer , intent(in) , dimension(num_domains):: e_we , e_sn , &
  284. parent_id , parent_grid_ratio , &
  285. i_parent_start , j_parent_start
  286. real , intent(out) :: xs, xe, ys, ye
  287. ! local vars
  288. integer :: idom
  289. xs = 0.
  290. xe = e_we(dom_id) -1
  291. ys = 0.
  292. ye = e_sn(dom_id) -1
  293. idom = dom_id
  294. compute_xy : DO
  295. xs = (i_parent_start(idom) + xs -1 ) / &
  296. real(parent_grid_ratio(parent_id(idom)))
  297. xe = xe / real(parent_grid_ratio(idom))
  298. ys = (j_parent_start(idom) + ys -1 ) / &
  299. real(parent_grid_ratio(parent_id(idom)))
  300. ye = ye / real(parent_grid_ratio(idom))
  301. idom = parent_id(idom)
  302. if ( idom .EQ. 1 ) then
  303. exit compute_xy
  304. end if
  305. END DO compute_xy
  306. xs = xs + 1
  307. xe = xs + xe
  308. ys = ys + 1
  309. ye = ys + ye
  310. end subroutine getxy
  311. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  312. !!!!!! E GRID MAP INFO BELOW !!!!!!!!!!!!!!
  313. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  314. SUBROUTINE plot_e_grid ( rlat0d , rlon0d , dphd , dlmd, &
  315. n_domains , &
  316. e_we , e_sn , &
  317. parent_id , parent_grid_ratio , &
  318. i_parent_start , j_parent_start )
  319. ! This routine generates a gmeta file of the area covered by an Arakawa e-grid.
  320. ! We assume that NCAR Graphics has not been called yet (and will be closed
  321. ! upon exit). The required input fields are as from the WPS namelist file.
  322. IMPLICIT NONE
  323. ! 15 April 2005 NCEP/EMC
  324. ! The Code and some instructions are provided by Tom BLACK to
  325. ! NCAR/DTC Meral Demirtas
  326. ! 4 May 2005 NCAR/DTC Meral DEMIRTAS
  327. ! - An include file (plot_inc) is added to get
  328. ! Domain size: IM,JM
  329. ! Central latitute and longnitute: RLAT0D,RLON0D
  330. ! Horizontal resolution: DPHD, DLMD
  331. ! Feb 2007 NCAR/MMM
  332. ! Turn into f90
  333. ! Add implicit none
  334. ! Remove non-mapping portions
  335. ! Make part of WPS domain plotting utility
  336. ! Dec 2008 NCAR/DTC
  337. ! Pass additional arguments to enable plotting of nests
  338. ! Input map parameters for E grid.
  339. REAL , INTENT(IN) :: rlat0d , & ! latitude of grid center (degrees)
  340. rlon0d ! longitude of grid center (degrees, times -1)
  341. REAL , INTENT(IN) :: dphd , & ! angular distance between rows (degrees)
  342. dlmd ! angular distance between adjacent H and V points (degrees)
  343. INTEGER , INTENT(in) :: n_domains ! number of domains
  344. INTEGER , INTENT(in) , DIMENSION(n_domains):: e_we , &
  345. e_sn , &
  346. parent_id , &
  347. parent_grid_ratio , &
  348. i_parent_start , &
  349. j_parent_start
  350. ! Some local vars
  351. REAL :: rlat1d , &
  352. rlon1d
  353. INTEGER :: im, & ! number of H points in odd rows
  354. jm , & ! number of rows
  355. ngpwe , &
  356. ngpsn , &
  357. ilowl , &
  358. jlowl
  359. INTEGER :: imt , imtjm
  360. REAL :: latlft,lonlft,latrgt,lonrgt
  361. im = e_we(1)-1
  362. jm = e_sn(1)-1
  363. imt=2*im-1
  364. imtjm=imt*jm
  365. rlat1d=rlat0d
  366. rlon1d=rlon0d
  367. ngpwe=2*im-1
  368. ngpsn=jm
  369. ! Get lat and lon of left and right points.
  370. CALL corners ( rlat1d,rlon1d,im,jm,rlat0d,rlon0d,dphd,dlmd,&
  371. ngpwe,ngpsn,ilowl,jlowl,latlft,lonlft,latrgt,lonrgt)
  372. ! With corner points, make map background.
  373. CALL mapbkg_egrid ( imt,jm,ilowl,jlowl,ngpwe,ngpsn,&
  374. rlat0d,rlon0d,latlft,lonlft,latrgt,lonrgt,&
  375. dlmd,dphd,&
  376. n_domains,&
  377. e_we,e_sn,&
  378. parent_id,parent_grid_ratio,&
  379. i_parent_start,j_parent_start)
  380. END SUBROUTINE plot_e_grid
  381. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  382. SUBROUTINE corners ( glatd,glond,im,jm,tph0d,tlm0d,dphd,dlmd,&
  383. ngpwe,ngpsn,ilowl,jlowl,glatl,glonl,glatr,glonr)
  384. IMPLICIT NONE
  385. REAL , INTENT(IN) :: glatd,glond,tph0d,tlm0d,dphd,dlmd,&
  386. glatl,glonl,glatr,glonr
  387. INTEGER , INTENT(IN) :: im,jm,ngpwe,ngpsn
  388. INTEGER , INTENT(OUT) :: ilowl,jlowl
  389. ! Local vars
  390. REAL , PARAMETER :: d2r = 1.74532925E-2 , r2D = 1./D2R
  391. REAL :: glat , glon , dph , dlm , tph0 , tlm0
  392. REAL :: x , y , z , tlat , tlon , tlat1 , tlat2 , tlon1 , tlon2
  393. REAL :: row , col
  394. REAL :: dlm1 , dlm2 , d1 , d2 , d3 , d4 , dmin
  395. INTEGER :: jmt , ii , jj , iuppr , juppr
  396. INTEGER :: nrow , ncol
  397. jmt = jm/2+1
  398. ! Convert from geodetic to transformed coordinates (degrees).
  399. glat = glatd * d2r
  400. glon = glond * d2r
  401. dph = dphd * d2r
  402. dlm = dlmd * d2r
  403. tph0 = tph0d * d2r
  404. tlm0 = tlm0d * d2r
  405. x = COS(tph0) * COS(glat) * COS(glon-tlm0)+SIN(tph0) * SIN(glat)
  406. y = -COS(glat) * SIN(glon-tlm0)
  407. z = COS(tph0) * SIN(glat)-SIN(tph0) * COS(glat) * COS(glon-tlm0)
  408. tlat = r2d * ATAN(z/SQRT(x*x + y*y))
  409. tlon = r2d * ATAN(y/x)
  410. ! Find the real (non-integer) row and column of the input location on
  411. ! the filled e-grid.
  412. row = tlat/dphd+jmt
  413. col = tlon/dlmd+im
  414. nrow = INT(row)
  415. ncol = INT(col)
  416. tlat = tlat * d2r
  417. tlon = tlon * d2r
  418. ! E2 E3
  419. !
  420. !
  421. ! X
  422. ! E1 E4
  423. tlat1 = (nrow-jmt) * dph
  424. tlat2 = tlat1+dph
  425. tlon1 = (ncol-im) * dlm
  426. tlon2 = tlon1+dlm
  427. dlm1 = tlon-tlon1
  428. dlm2 = tlon-tlon2
  429. d1 = ACOS(COS(tlat) * COS(tlat1) * COS(dlm1)+SIN(tlat) * SIN(tlat1))
  430. d2 = ACOS(COS(tlat) * COS(tlat2) * COS(dlm1)+SIN(tlat) * SIN(tlat2))
  431. d3 = ACOS(COS(tlat) * COS(tlat2) * COS(dlm2)+SIN(tlat) * SIN(tlat2))
  432. d4 = ACOS(COS(tlat) * COS(tlat1) * COS(dlm2)+SIN(tlat) * SIN(tlat1))
  433. dmin = MIN(d1,d2,d3,d4)
  434. IF ( ABS(dmin-d1) .LT. 1.e-6 ) THEN
  435. ii = ncol
  436. jj = nrow
  437. ELSE IF ( ABS(dmin-d2) .LT. 1.e-6 ) THEN
  438. ii = ncol
  439. jj = nrow+1
  440. ELSE IF ( ABS(dmin-d3) .LT. 1.e-6 ) THEN
  441. ii = ncol+1
  442. jj = nrow+1
  443. ELSE IF ( ABS(dmin-d4) .LT. 1.e-6 ) THEN
  444. ii = ncol+1
  445. jj = nrow
  446. END IF
  447. ! Now find the i and j of the lower left corner of the desired grid
  448. ! region and of the upper right.
  449. ilowl = ii-ngpwe/2
  450. jlowl = jj-ngpsn/2
  451. iuppr = ii+ngpwe/2
  452. juppr = jj+ngpsn/2
  453. ! Find their geodetic coordinates.
  454. CALL e2t2g(ilowl,jlowl,im,jm,tph0d,tlm0d,dphd,dlmd,glatl,glonl)
  455. CALL e2t2g(iuppr,juppr,im,jm,tph0d,tlm0d,dphd,dlmd,glatr,glonr)
  456. END SUBROUTINE corners
  457. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  458. SUBROUTINE mapbkg_egrid ( imt,jm,ilowl,jlowl,ngpwe,ngpsn,&
  459. rlat0d,rlon0d,glatl,glonl,glatr,glonr,&
  460. dlmd,dphd,&
  461. n_domains,&
  462. e_we,e_sn,&
  463. parent_id,parent_grid_ratio,&
  464. i_parent_start , j_parent_start )
  465. ! IMPLICIT NONE
  466. INTEGER , INTENT(in) :: n_domains
  467. INTEGER , INTENT(in) , DIMENSION(n_domains):: e_we , e_sn , &
  468. parent_id , parent_grid_ratio , &
  469. i_parent_start , j_parent_start
  470. ! Some local vars
  471. CHARACTER (LEN=97) :: string
  472. INTEGER :: i
  473. REAL :: xs, xe, ys, ye
  474. ! Yet more center lon messing around, hoo boy.
  475. ! clonx=180.-rlon0d
  476. clonx=-rlon0d
  477. ! Open up NCAR Graphics
  478. CALL opngks
  479. CALL gopwk(8,9,3)
  480. CALL gsclip(0)
  481. ! Make the background white, and the foreground black.
  482. CALL gscr ( 1 , 0 , 1., 1., 1. )
  483. CALL gscr ( 1 , 1 , 0., 0., 0. )
  484. ! Line width default thickness.
  485. CALL setusv('LW',1000)
  486. ! Make map outline a solid line, not dots.
  487. CALL mapsti('MV',8)
  488. CALL mapsti('DO',0)
  489. ! Map outlines are political and states.
  490. CALL mapstc('OU','PS')
  491. ! Cylindrical equidistant.
  492. CALL maproj('CE',rlat0d,clonx,0.)
  493. ! Specify corner points.
  494. CALL mapset('CO',glatl,glonl,glatr,glonr)
  495. ! Lat lon lines every 5 degrees.
  496. CALL mapsti('GR',5)
  497. ! Map takes up this much real estate.
  498. CALL mappos( 0.05 , 0.95 , 0.05 , 0.95 )
  499. ! Initialize and draw map.
  500. CALL mapint
  501. CALL mapdrw
  502. ! Line width twice default thickness.
  503. CALL setusv('LW',2000)
  504. ! Add approx grid point tick marks
  505. CALL perim(((imt+3)/2)-1,1,jm-1,1)
  506. ! Line width default thickness.
  507. CALL setusv('LW',1000)
  508. ! Put on a quicky description.
  509. WRITE ( string , FMT = '("E-GRID E_WE = ",I4,", E_SN = ",I4 , &
  510. &", DX = ",F6.4,", DY = ",F6.4 , &
  511. &", REF_LAT = ",F8.3,", REF_LON = ",F8.3)') &
  512. (imt+3)/2,jm+1,dlmd,dphd,rlat0d,-1.*rlon0d
  513. CALL getset(xa,xb,ya,yb,xxa,xxy,yya,yyb,ltype)
  514. CALL pchiqu(xxa,yya-(yyb-yya)/20.,string,8.,0.,-1.)
  515. CALL set (xa,xb,ya,yb,&
  516. 1.,real(e_we(1)),1.,real(e_sn(1)),ltype)
  517. ! Line width twice default thickness.
  518. CALL setusv('LW',2000)
  519. ! Draw a box for each nest.
  520. do i=2 , n_domains
  521. call getxy ( xs, xe, ys, ye, &
  522. i , n_domains , &
  523. e_we , e_sn , &
  524. parent_id , parent_grid_ratio , &
  525. i_parent_start , j_parent_start )
  526. call line ( xs , ys , xe , ys )
  527. call line ( xe , ys , xe , ye )
  528. call line ( xe , ye , xs , ye )
  529. call line ( xs , ye , xs , ys )
  530. end do
  531. CALL frame
  532. ! Close workstation and NCAR Grpahics.
  533. CALL gclwk(8)
  534. CALL clsgks
  535. END SUBROUTINE mapbkg_egrid
  536. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  537. SUBROUTINE e2t2g ( ncol,nrow,im,jm,tph0d,tlm0d,dphd,dlmd,glatd,glond)
  538. ! IMPLICIT NONE
  539. REAL , PARAMETER :: D2R=1.74532925E-2 , R2D=1./D2R
  540. DPH=DPHD*D2R
  541. DLM=DLMD*D2R
  542. TPH0=TPH0D*D2R
  543. TLM0=TLM0D*D2R
  544. !*** FIND THE TRANSFORMED LAT (POSITIVE NORTH) AND LON (POSITIVE EAST)
  545. TLATD=(NROW-(JM+1)/2)*DPHD
  546. TLOND=(NCOL-IM)*DLMD
  547. !*** NOW CONVERT TO GEODETIC LAT (POSITIVE NORTH) AND LON (POSITIVE EAST)
  548. TLATR=TLATD*D2R
  549. TLONR=TLOND*D2R
  550. ARG1=SIN(TLATR)*COS(TPH0)+COS(TLATR)*SIN(TPH0)*COS(TLONR)
  551. GLATR=ASIN(ARG1)
  552. GLATD=GLATR*R2D
  553. ARG2=COS(TLATR)*COS(TLONR)/(COS(GLATR)*COS(TPH0))- &
  554. TAN(GLATR)*TAN(TPH0)
  555. IF(ABS(ARG2).GT.1.)ARG2=ABS(ARG2)/ARG2
  556. FCTR=1.
  557. IF(TLOND.GT.0.)FCTR=-1.
  558. GLOND=TLM0D+FCTR*ACOS(ARG2)*R2D
  559. GLOND=-GLOND
  560. END SUBROUTINE e2t2g