3 include 'wrf_status_codes.h'
4 type (iosystem_desc_t), pointer :: iosystem
7 SUBROUTINE open_wrfsi_static(dataroot, FileDesc)
11 CHARACTER(LEN=*), INTENT(IN) :: dataroot
12 type(file_desc_t), INTENT(OUT) :: FileDesc
13 CHARACTER(LEN=255) :: staticfile
14 LOGICAL :: static_exists
19 staticfile = TRIM(dataroot) // '/static/static.wrfsi'
20 INQUIRE(FILE=staticfile, EXIST=static_exists)
21 IF (static_exists) THEN
22 status = PIO_openfile(iosystem, FileDesc, &
23 PIO_iotype_pnetcdf, TRIM(staticfile))
24 IF (status .NE. PIO_NOERR) THEN
25 PRINT '(A,I5)', 'NetCDF error opening WRF static file: ',status
26 STOP 'open_wrfsi_static'
29 staticfile = TRIM(dataroot) // '/static/static.wrfsi.rotlat'
30 INQUIRE(FILE=staticfile, EXIST=static_exists)
31 IF(static_exists) THEN
32 status = PIO_openfile(iosystem, FileDesc, &
33 PIO_iotype_pnetcdf, TRIM(staticfile))
34 IF(status .NE. PIO_NOERR) THEN
35 PRINT '(A,I5)', 'NetCDF error opening WRF static file: ',status
36 STOP 'open_wrfsi_static'
39 PRINT '(A)', 'rotlat Static file not found, either: ', staticfile
40 STOP 'open_wrfsi_static'
46 END SUBROUTINE open_wrfsi_static
48 !--------------------------------------------------------------------
49 SUBROUTINE get_wrfsi_static_dims(dataroot, nx, ny)
51 ! Subroutine to return the horizontal dimensions of WRF static file
52 ! contained in the input dataroot
58 CHARACTER(LEN=*), INTENT(IN) :: dataroot
59 INTEGER , INTENT(OUT) :: nx
60 INTEGER , INTENT(OUT) :: ny
62 INTEGER :: vid, status
63 type (file_desc_t) :: FileDesc
65 CALL open_wrfsi_static(dataroot, FileDesc)
66 status = pio_inq_dimid(FileDesc, 'x', vid)
67 status = pio_inq_dimlen(FileDesc, vid, nx)
68 status = pio_inq_dimid(FileDesc, 'y', vid)
69 status = pio_inq_dimlen(FileDesc, vid, ny)
70 write(unit=*, fmt='(2(A,I5))') 'WRF X-dimension = ',nx, &
71 ', WRF Y-dimension = ',ny
72 call pio_closefile(FileDesc)
75 END SUBROUTINE get_wrfsi_static_dims
77 !--------------------------------------------------------------------
78 SUBROUTINE get_wrfsi_static_2d(dataroot, varname, data)
82 !Gets any 2D variable from the static file
83 CHARACTER(LEN=*), INTENT(IN) :: dataroot
84 CHARACTER(LEN=*), INTENT(IN) :: varname
85 REAL, INTENT(OUT) :: data(:,:)
87 INTEGER :: vid, status
88 type (file_desc_t) :: FileDesc
90 CALL open_wrfsi_static(dataroot, FileDesc)
91 status = pio_inq_varid(FileDesc, varname, vid)
92 status = pio_get_var(FileDesc, vid, data)
93 !status = get_var_2d_real(FileDesc, vid, data)
94 IF(status .NE. PIO_NOERR) THEN
95 write(unit=*, fmt='(A)') 'Problem getting 2D data.'
97 call pio_closefile(FileDesc)
100 END SUBROUTINE get_wrfsi_static_2d
101 END MODULE wrfsi_static