Skip to content

Commit 9d9c5fe

Browse files
authored
Merge pull request #1152 from LIS-navari/feature/lambert_4_lvt_DAobs
Support for Lambert projection added to LVT LISDAobs reader.
2 parents a7b4416 + 76eda29 commit 9d9c5fe

File tree

1 file changed

+159
-84
lines changed

1 file changed

+159
-84
lines changed

lvt/datastreams/LISDAobs/LISda_obsMod.F90

+159-84
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module LISda_obsMod
3131
!
3232
! !REVISION HISTORY:
3333
! 02 Oct 2008 Sujay Kumar Initial Specification
34+
! July 18 2022 Madi Navari Added support for Lambert projection.
3435
!
3536
!EOP
3637

@@ -113,6 +114,9 @@ subroutine LISda_obsInit(i)
113114
logical :: file_exists
114115
character*20 :: gridtype
115116
integer :: rc
117+
integer :: truelat1, truelat2
118+
integer :: domain_resolution
119+
integer :: standard_lon
116120

117121
if(.not.allocated(lisdaobs)) then
118122
allocate(lisdaobs(LVT_rc%nDataStreams))
@@ -168,105 +172,176 @@ subroutine LISda_obsInit(i)
168172
if(file_exists) then
169173
ios = nf90_open(path=domFile,mode=NF90_NOWRITE,ncid=ftn)
170174
call LVT_verify(ios,'Error in nf90_open in readObsDomainInput')
175+
176+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'MAP_PROJECTION',map_proj)
177+
call LVT_verify(ios, 'Error in nf90_get_att: MAP_PROJECTION')
178+
179+
if(map_proj.eq."EQUIDISTANT CYLINDRICAL" .or. map_proj.eq."EASE V2") then
171180

172-
ios = nf90_inq_dimid(ftn,"east_west",ncId)
173-
call LVT_verify(ios,&
174-
'Error in nf90_inq_dimid in readObsDomainInput:east_west')
181+
ios = nf90_inq_dimid(ftn,"east_west",ncId)
182+
call LVT_verify(ios,&
183+
'Error in nf90_inq_dimid in readObsDomainInput:east_west')
175184

176-
ios = nf90_inq_dimid(ftn,"north_south",nrId)
177-
call LVT_verify(ios,&
178-
'Error in nf90_inq_dimid in readObsDomainInput:north_south')
185+
ios = nf90_inq_dimid(ftn,"north_south",nrId)
186+
call LVT_verify(ios,&
187+
'Error in nf90_inq_dimid in readObsDomainInput:north_south')
179188

180-
ios = nf90_inquire_dimension(ftn,ncId, len=lisdaobs(i)%nc)
181-
call LVT_verify(ios,&
182-
'Error in nf90_inquire_dimension in readObsDomainInput:ncId')
189+
ios = nf90_inquire_dimension(ftn,ncId, len=lisdaobs(i)%nc)
190+
call LVT_verify(ios,&
191+
'Error in nf90_inquire_dimension in readObsDomainInput:ncId')
183192

184-
ios = nf90_inquire_dimension(ftn,nrId, len=lisdaobs(i)%nr)
185-
call LVT_verify(ios,&
186-
'Error in nf90_inquire_dimension in readObsDomainInput:nrId')
193+
ios = nf90_inquire_dimension(ftn,nrId, len=lisdaobs(i)%nr)
194+
call LVT_verify(ios,&
195+
'Error in nf90_inquire_dimension in readObsDomainInput:nrId')
187196

188-
ios = nf90_get_att(ftn, NF90_GLOBAL, 'MAP_PROJECTION',map_proj)
189-
call LVT_verify(ios, 'Error in nf90_get_att: MAP_PROJECTION')
197+
!ios = nf90_get_att(ftn, NF90_GLOBAL, 'MAP_PROJECTION',map_proj)
198+
!call LVT_verify(ios, 'Error in nf90_get_att: MAP_PROJECTION')
190199

191-
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LAT',&
192-
stlat)
193-
call LVT_verify(ios, &
194-
'Error in nf90_get_att: SOUTH_WEST_CORNER_LAT')
200+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LAT',&
201+
stlat)
202+
call LVT_verify(ios, &
203+
'Error in nf90_get_att: SOUTH_WEST_CORNER_LAT')
195204

196-
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LON',&
197-
stlon)
198-
call LVT_verify(ios, &
199-
'Error in nf90_get_att: SOUTH_WEST_CORNER_LON')
205+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LON',&
206+
stlon)
207+
call LVT_verify(ios, &
208+
'Error in nf90_get_att: SOUTH_WEST_CORNER_LON')
200209

201-
ios = nf90_get_att(ftn, NF90_GLOBAL, 'DX',dx)
202-
call LVT_warning(ios, 'Error in nf90_get_att: DX')
203-
if(ios.ne.0) then
204-
dx = 0
205-
endif
210+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'DX',dx)
211+
call LVT_warning(ios, 'Error in nf90_get_att: DX')
212+
if(ios.ne.0) then
213+
dx = 0
214+
endif
206215

207-
ios = nf90_get_att(ftn, NF90_GLOBAL, 'DY',dy)
208-
call LVT_warning(ios, 'Error in nf90_get_att: DY')
209-
if(ios.ne.0) then
210-
dy = 0
211-
endif
216+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'DY',dy)
217+
call LVT_warning(ios, 'Error in nf90_get_att: DY')
218+
if(ios.ne.0) then
219+
dy = 0
220+
endif
212221

213-
ios = nf90_get_att(ftn,NF90_GLOBAL,'GRIDTYPE',gridtype)
214-
call LVT_warning(ios,'Error in nf90_get_att: GRIDTYPE')
222+
ios = nf90_get_att(ftn,NF90_GLOBAL,'GRIDTYPE',gridtype)
223+
call LVT_warning(ios,'Error in nf90_get_att: GRIDTYPE')
215224

216-
if(map_proj.eq."EQUIDISTANT CYLINDRICAL") then
217-
218-
gridDesci(1) = 0
219-
gridDesci(2) = lisdaobs(i)%nc
220-
gridDesci(3) = lisdaobs(i)%nr
221-
gridDesci(4) = stlat
222-
gridDesci(5) = stlon
223-
gridDesci(7) = stlat + (lisdaobs(i)%nr-1)*dy
224-
gridDesci(8) = stlon + (lisdaobs(i)%nc-1)*dx
225-
gridDesci(9) = dx
225+
if(map_proj.eq."EQUIDISTANT CYLINDRICAL") then
226+
227+
gridDesci(1) = 0
228+
gridDesci(2) = lisdaobs(i)%nc
229+
gridDesci(3) = lisdaobs(i)%nr
230+
gridDesci(4) = stlat
231+
gridDesci(5) = stlon
232+
gridDesci(7) = stlat + (lisdaobs(i)%nr-1)*dy
233+
gridDesci(8) = stlon + (lisdaobs(i)%nc-1)*dx
234+
gridDesci(9) = dx
226235

227-
if(gridDesci(1).eq.0) then
228-
gridDesci(10) = dy
236+
if(gridDesci(1).eq.0) then
237+
gridDesci(10) = dy
238+
gridDesci(6) = 128
239+
gridDesci(11) = 64
240+
gridDesci(20) = 64
241+
endif
242+
if(gridDesci(7).lt.gridDesci(4)) then
243+
write(LVT_logunit,*) '[ERR] lat2 must be greater than lat1'
244+
write(LVT_logunit,*) '[ERR] ',gridDesci(7),&
245+
gridDesci(4)
246+
write(LVT_logunit,*) '[ERR] Stopping run...'
247+
call LVT_endrun
248+
endif
249+
if(gridDesci(8).lt.gridDesci(5)) then
250+
write(LVT_logunit,*) '[ERR] lon2 must be greater than lon1'
251+
write(LVT_logunit,*) '[ERR] ',gridDesci(8),&
252+
gridDesci(5)
253+
write(LVT_logunit,*) '[ERR] Stopping run...'
254+
call LVT_endrun
255+
endif
256+
elseif(map_proj.eq."EASE V2") then
257+
258+
gridDesci(1) = 9
259+
gridDesci(2) = lisdaobs(i)%nc
260+
gridDesci(3) = lisdaobs(i)%nr
261+
gridDesci(4) = stlat
262+
gridDesci(5) = stlon
229263
gridDesci(6) = 128
230-
gridDesci(11) = 64
264+
231265
gridDesci(20) = 64
266+
267+
if(gridtype.eq."M36") then
268+
gridDesci(9) = 4
269+
gridDesci(10) = 0.36
270+
dx = 0.36
271+
dy = 0.36
272+
elseif(gridtype.eq."M09") then
273+
gridDesci(9) = 5
274+
gridDesci(10) = 0.09
275+
dx = 0.09
276+
dy = 0.09
277+
endif
232278
endif
233-
if(gridDesci(7).lt.gridDesci(4)) then
234-
write(LVT_logunit,*) '[ERR] lat2 must be greater than lat1'
235-
write(LVT_logunit,*) '[ERR] ',gridDesci(7),&
236-
gridDesci(4)
237-
write(LVT_logunit,*) '[ERR] Stopping run...'
238-
call LVT_endrun
239-
endif
240-
if(gridDesci(8).lt.gridDesci(5)) then
241-
write(LVT_logunit,*) '[ERR] lon2 must be greater than lon1'
242-
write(LVT_logunit,*) '[ERR] ',gridDesci(8),&
243-
gridDesci(5)
244-
write(LVT_logunit,*) '[ERR] Stopping run...'
245-
call LVT_endrun
246-
endif
247-
elseif(map_proj.eq."EASE V2") then
248-
249-
gridDesci(1) = 9
250-
gridDesci(2) = lisdaobs(i)%nc
251-
gridDesci(3) = lisdaobs(i)%nr
252-
gridDesci(4) = stlat
253-
gridDesci(5) = stlon
254-
gridDesci(6) = 128
255-
256-
gridDesci(20) = 64
257-
258-
if(gridtype.eq."M36") then
259-
gridDesci(9) = 4
260-
gridDesci(10) = 0.36
261-
dx = 0.36
262-
dy = 0.36
263-
elseif(gridtype.eq."M09") then
264-
gridDesci(9) = 5
265-
gridDesci(10) = 0.09
266-
dx = 0.09
267-
dy = 0.09
268-
endif
269-
279+
280+
elseif(map_proj.eq."LAMBERT CONFORMAL") then
281+
ios = nf90_inq_dimid(ftn,"east_west",ncId)
282+
call LVT_verify(ios,&
283+
'Error in nf90_inq_dimid in readObsDomainInput:east_west')
284+
285+
ios = nf90_inq_dimid(ftn,"north_south",nrId)
286+
call LVT_verify(ios,&
287+
'Error in nf90_inq_dimid in readObsDomainInput:north_south')
288+
289+
ios = nf90_inquire_dimension(ftn,ncId, len=lisdaobs(i)%nc)
290+
call LVT_verify(ios,&
291+
'Error in nf90_inquire_dimension in readObsDomainInput:ncId')
292+
293+
ios = nf90_inquire_dimension(ftn,nrId, len=lisdaobs(i)%nr)
294+
call LVT_verify(ios,&
295+
'Error in nf90_inquire_dimension in readObsDomainInput:nrId')
296+
297+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LAT',&
298+
stlat)
299+
call LVT_verify(ios, &
300+
'Error in nf90_get_att: SOUTH_WEST_CORNER_LAT')
301+
302+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'SOUTH_WEST_CORNER_LON',&
303+
stlon)
304+
call LVT_verify(ios, &
305+
'Error in nf90_get_att: SOUTH_WEST_CORNER_LON')
306+
307+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'TRUELAT1',&
308+
truelat1)
309+
call LVT_verify(ios, &
310+
'Error in nf90_get_att: TRUELAT1')
311+
312+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'TRUELAT2',&
313+
truelat2)
314+
call LVT_verify(ios, &
315+
'Error in nf90_get_att: TRUELAT1')
316+
317+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'STANDARD_LON',&
318+
standard_lon)
319+
call LVT_verify(ios, &
320+
'Error in nf90_get_att: STANDARD_LON')
321+
322+
ios = nf90_get_att(ftn, NF90_GLOBAL, 'DX',&
323+
domain_resolution)
324+
call LVT_verify(ios, &
325+
'Error in nf90_get_att: DX')
326+
327+
ios = nf90_get_att(ftn,NF90_GLOBAL,'GRIDTYPE',gridtype)
328+
call LVT_warning(ios,'Error in nf90_get_att: GRIDTYPE')
329+
330+
gridDesci = 0
331+
gridDesci(1) = 3 ! Lambert conic conformal grid
332+
gridDesci(2) = lisdaobs(i)%nc
333+
gridDesci(3) = lisdaobs(i)%nr
334+
gridDesci(4) = stlat ! latitude of origin -- LL Lat
335+
gridDesci(5) = stlon ! longitude of origin -- LL Lon
336+
gridDesci(6) = 8 ! Set for Lambert in core/LDT_domainMod.F90 (line 2658)
337+
gridDesci(7) = truelat2 ! true lat2
338+
gridDesci(8) = domain_resolution ! grid spacing in km
339+
gridDesci(9) = domain_resolution ! grid spacing in km
340+
gridDesci(10) = truelat1 ! true lat1
341+
gridDesci(11) = standard_lon ! standard long
342+
gridDesci(20) = 0.0
343+
344+
270345
else
271346
write(LVT_logunit,*) '[ERR] Map projection ',trim(map_proj)
272347
write(LVT_logunit,*) '[ERR] not currently supported for LIS DAOBS plugin'

0 commit comments

Comments
 (0)