source: trunk/WRF.COMMON/WRFV3/external/io_pnetcdf/module_wrfsi_static.F90

Last change on this file was 2759, checked in by aslmd, 2 years ago

adding unmodified code from WRFV3.0.1.1, expurged from useless data +1M size

File size: 3.2 KB
Line 
1MODULE wrfsi_static
2
3!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
4CONTAINS
5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6  SUBROUTINE open_wrfsi_static(dataroot,cdfid)
7 
8    IMPLICIT NONE
9#    include "pnetcdf.inc"
10    CHARACTER(LEN=*), INTENT(IN)   :: dataroot
11    INTEGER, INTENT(OUT)           :: cdfid
12    CHARACTER(LEN=255)            :: staticfile
13    LOGICAL                       :: static_exists
14    INTEGER                       :: status
15
16    staticfile = TRIM(dataroot) // '/static/static.wrfsi'
17    INQUIRE(FILE=staticfile, EXIST=static_exists)
18    IF (static_exists) THEN
19      status = nfmpi_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'
23      END IF
24
25    ELSE
26
27!mp
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 = nfmpi_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'
38      END IF
39                    ELSE
40
41      PRINT '(A)', 'rotlat Static file not found, either: ', staticfile
42      STOP 'open_wrfsi_static'
43                    ENDIF
44
45        ENDIF
46
47    RETURN
48  END SUBROUTINE open_wrfsi_static     
49!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
50  SUBROUTINE get_wrfsi_static_dims(dataroot, nx, ny)
51 
52    ! Subroutine to return the horizontal dimensions of WRF static file
53    ! contained in the input dataroot
54
55    IMPLICIT NONE
56#    include "pnetcdf.inc"
57    CHARACTER(LEN=*), INTENT(IN)  :: dataroot
58    INTEGER         , INTENT(OUT) :: nx
59    INTEGER         , INTENT(OUT) :: ny
60
61    INTEGER                       :: cdfid,vid, status
62
63    CALL open_wrfsi_static(dataroot,cdfid)
64    status = nfmpi_inq_dimid(cdfid, 'x', vid)
65    status = nfmpi_inq_dimlen(cdfid, vid, nx)
66    status = nfmpi_inq_dimid(cdfid, 'y', vid)
67    status = nfmpi_inq_dimlen(cdfid, vid, ny)
68      PRINT '(A,I5,A,I5)', 'WRF X-dimension = ',nx, &
69        ' WRF Y-dimension = ',ny 
70    status = nfmpi_close(cdfid) 
71    RETURN
72  END SUBROUTINE get_wrfsi_static_dims     
73!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
74  SUBROUTINE get_wrfsi_static_2d(dataroot, varname, data)
75
76    IMPLICIT NONE
77#    include "pnetcdf.inc"
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(:,:)
82 
83    INTEGER                             :: cdfid, vid, status
84   
85    CALL open_wrfsi_static(dataroot,cdfid)
86    status = nfmpi_inq_varid(cdfid,varname,vid)
87    status = nfmpi_get_var_real(cdfid,vid,data)
88    IF (status .NE. NF_NOERR) THEN
89      PRINT '(A)', 'Problem getting 2D data.'
90    ENDIF
91    status = nfmpi_close(cdfid)
92    RETURN
93  END SUBROUTINE get_wrfsi_static_2d   
94!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95 
96END MODULE wrfsi_static
Note: See TracBrowser for help on using the repository browser.