1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
| program merra2wps
! Fortran 90 version.
! This is a simple program to write data in the WPS intermediate
! format. It is included mainly as an aid to understanding said
! format.
implicit none
! Declarations:
integer, parameter :: IUNIT = 10
integer, parameter :: OUNIT = 11
integer :: ierr
integer :: IFV=5
character(len=24) :: HDATE
real :: XFCST
character(len=8) :: STARTLOC
character(len=9) :: FIELD
character(len=25) :: UNITS
character(len=46) :: DESC
character(len=32) :: MAP_SOURCE
real :: XLVL=42
integer :: NX
integer :: NY
integer :: IPROJ=3
real :: STARTLAT=34
real :: STARTLON=45
real :: DELTALAT
real :: DELTALON
real :: DX=30
real :: DY=30
real :: XLONC=4.87
real :: TRUELAT1=50.404
real :: TRUELAT2
real :: NLATS
real :: EARTH_RADIUS = 6367470. * .001
logical :: IS_WIND_EARTH_REL = .FALSE.
! SLAB is an allocatable array, because we do not necessarily know in
! advance the size of the array we need to read.
real, allocatable, dimension(:,:) :: SLAB
DATALOOP : DO
!====================================================================================!
! READ in your data from the original source - you need to add the reading code here !
! !
open(10,FILE='MERRA300.prod.assim.inst6_3d_ana_Np.20100301.SUB')
! You need to allocate SLAB (this is a 2D array) and place each 2D slab here before !
! you can write it out to into the intermadiate file format !
! !
! Other information you need to know about your data: !
! Time at which data is valid !
! Forecast time of the data !
! Source of data - you can make something up, it is never used !
! Field name - NOTE THEY NEED TO MATCH THOSE EXPECTED BY METGRID !
! Units of field !
! Description of data !
! Level of data - Pa, 200100 Pa is used for surface, and 201300 Pa is used !
! for sea-level pressure !
! X dimension !
! Y dimension !
! Data projection - only recognize !
! 0: Cylindrical Equidistant (Lat/lon) projection. !
! 1: Mercator projection. !
! 3: Lambert-conformal projection. !
! 4: Gaussian projection. !
! 5: Polar-stereographic projection. !
! Start location of data - "CENTER", "SWCORNER". "SWCORNER" is typical !
! Start lat & long of data !
! Lat/Lon increment !
! Number of latitudes north of equator (for Gaussian grids) !
! Grid-spacing in x/y !
! Center long !
! truelat1/2 !
! Has the winds been rotated !
!====================================================================================!
write (IUNIT, IOSTAT=IERR) IFV
! WRITE the second record, common to all projections:
write (IUNIT) HDATE, XFCST, MAP_SOURCE, FIELD, UNITS, DESC, XLVL, NX, NY, IPROJ
print*, HDATE//" ", XLVL, FIELD
! WRITE the third record, which depends on the projection:
if (IPROJ == 0) then
! This is the Cylindrical Equidistant (lat/lon) projection:
WRITE (IUNIT) STARTLOC, STARTLAT, STARTLON, DELTALAT, DELTALON, EARTH_RADIUS
elseif (IPROJ == 1) then
! This is the Mercator projection:
WRITE (IUNIT) STARTLOC, STARTLAT, STARTLON, DX, DY, TRUELAT1, EARTH_RADIUS
elseif (IPROJ == 3) then
! This is the Lambert Conformal projection:
WRITE (IUNIT) STARTLOC, STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1, TRUELAT2, EARTH_RADIUS
elseif (IPROJ == 4) then
! Gaussian projection
WRITE (IUNIT) STARTLOC, STARTLAT, STARTLON, NLATS, DELTALON, EARTH_RADIUS
elseif (IPROJ == 5) then
! This is the Polar Stereographic projection:
WRITE (IUNIT) STARTLOC, STARTLAT, STARTLON, DX, DY, XLONC, TRUELAT1, EARTH_RADIUS
endif
WRITE (IUNIT) IS_WIND_EARTH_REL
WRITE (IUNIT) slab
! Now that we have done all that we want to with SLAB, we need to
! deallocate it:
deallocate(slab)
! Loop back to read/write the next field.
ENDDO DATALOOP
write(*,'(/,"End of read loop. Program finished.")')
end program merra2wps |
Partager