3 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6 SUBROUTINE open_wrfsi_static(dataroot,cdfid)
10 CHARACTER(LEN=*), INTENT(IN) :: dataroot
11 INTEGER, INTENT(OUT) :: cdfid
12 CHARACTER(LEN=255) :: staticfile
13 LOGICAL :: static_exists
16 staticfile = TRIM(dataroot) // '/static/static.wrfsi'
17 INQUIRE(FILE=staticfile, EXIST=static_exists)
18 IF (static_exists) THEN
19 status = NF_OPEN(TRIM(staticfile),NF_NOWRITE,cdfid)
20 IF (status .NE. NF_NOERR) THEN
21 PRINT '(A,I5)', 'NetCDF error opening WRF static file: ',status
22 STOP 'open_wrfsi_static'
28 ! search for rotlat version??
29 ! PRINT '(A)', 'Static file not found ', staticfile
30 ! PRINT '(A)', 'Look for NMM version'
31 staticfile = TRIM(dataroot) // '/static/static.wrfsi.rotlat'
32 INQUIRE(FILE=staticfile, EXIST=static_exists)
33 IF (static_exists) THEN
34 status = NF_OPEN(TRIM(staticfile),NF_NOWRITE,cdfid)
35 IF (status .NE. NF_NOERR) THEN
36 PRINT '(A,I5)', 'NetCDF error opening WRF static file: ',status
37 STOP 'open_wrfsi_static'
41 PRINT '(A)', 'rotlat Static file not found, either: ', staticfile
42 STOP 'open_wrfsi_static'
48 END SUBROUTINE open_wrfsi_static
49 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
50 SUBROUTINE get_wrfsi_static_dims(dataroot, nx, ny)
52 ! Subroutine to return the horizontal dimensions of WRF static file
53 ! contained in the input dataroot
57 CHARACTER(LEN=*), INTENT(IN) :: dataroot
58 INTEGER , INTENT(OUT) :: nx
59 INTEGER , INTENT(OUT) :: ny
61 INTEGER :: cdfid,vid, status
63 CALL open_wrfsi_static(dataroot,cdfid)
64 status = NF_INQ_DIMID(cdfid, 'x', vid)
65 status = NF_INQ_DIMLEN(cdfid, vid, nx)
66 status = NF_INQ_DIMID(cdfid, 'y', vid)
67 status = NF_INQ_DIMLEN(cdfid, vid, ny)
68 PRINT '(A,I5,A,I5)', 'WRF X-dimension = ',nx, &
69 ' WRF Y-dimension = ',ny
70 status = NF_CLOSE(cdfid)
72 END SUBROUTINE get_wrfsi_static_dims
73 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
74 SUBROUTINE get_wrfsi_static_2d(dataroot, varname, data)
78 ! Gets any 2D variable from the static file
79 CHARACTER(LEN=*), INTENT(IN) :: dataroot
80 CHARACTER(LEN=*), INTENT(IN) :: varname
81 REAL, INTENT(OUT) :: data(:,:)
83 INTEGER :: cdfid, vid, status
85 CALL open_wrfsi_static(dataroot,cdfid)
86 status = NF_INQ_VARID(cdfid,varname,vid)
87 status = NF_GET_VAR_REAL(cdfid,vid,data)
88 IF (status .NE. NF_NOERR) THEN
89 PRINT '(A)', 'Problem getting 2D data.'
91 status = NF_CLOSE(cdfid)
93 END SUBROUTINE get_wrfsi_static_2d
94 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
96 END MODULE wrfsi_static