17 use kinds, only: r_kind, r_single, i_short, rmissing
29 character(len=6) :: datatype
43 character(len=20),
allocatable :: varnames(:)
44 character(len=20),
allocatable :: latname
45 character(len=20),
allocatable :: lonname
46 character(len=20),
allocatable :: dimnameEW
47 character(len=20),
allocatable :: dimnameNS
48 character(len=20),
allocatable :: dimnameTIME
49 character(len=20),
allocatable :: dimnameDATE
50 character(len=1),
allocatable :: times(:,:)
52 real(r_kind),
allocatable :: nwp_mask_c(:,:)
53 real(r_kind),
allocatable :: nwp_sst_c(:,:,:)
54 real(r_kind),
allocatable :: nwp_ice_c(:,:,:)
55 real(r_kind),
allocatable :: nwp_sfct_c(:,:,:)
56 real(r_kind),
allocatable :: nwp_icet_c(:,:,:)
57 real(r_kind),
allocatable :: nwp_zorl_c(:,:,:)
58 real(r_kind),
allocatable :: nwp_hice_c(:,:,:)
60 real(r_kind),
allocatable :: nwp_mask_w(:,:)
61 real(r_kind),
allocatable :: nwp_sst_w(:,:)
62 real(r_kind),
allocatable :: nwp_ice_w(:,:)
63 real(r_kind),
allocatable :: nwp_sfct_w(:,:)
64 real(r_kind),
allocatable :: nwp_icet_w(:,:)
65 real(r_kind),
allocatable :: nwp_sfctl_w(:,:)
66 real(r_kind),
allocatable :: nwp_zorl_w(:,:)
67 real(r_kind),
allocatable :: nwp_hice_w(:,:)
77 type(nwpbase),
pointer :: tail => NULL()
102 character(len=6),
intent(in) :: itype
103 character(len=4),
intent(in) :: wcstart
106 if (itype==
' FVCOM')
then
107 this%datatype = itype
118 allocate(this%varnames(this%numvar))
119 this%varnames(1) =
'glmask'
120 this%varnames(2) =
'tsfc'
121 this%varnames(3) =
'aice'
122 this%varnames(4) =
'tisfc'
123 this%varnames(5) =
'vice'
125 allocate(this%latname)
126 allocate(this%lonname)
130 allocate(this%dimnameEW)
131 allocate(this%dimnameNS)
132 allocate(this%dimnameTIME)
133 allocate(this%dimnameDATE)
134 this%dimnameEW =
'lon'
135 this%dimnameNS =
'lat'
136 this%dimnameTIME =
'Time'
137 this%dimnameDATE =
'DateStrLen'
141 else if (trim(itype)==
'FV3LAM' .AND. wcstart==
'warm')
then
142 this%datatype = itype
154 allocate(this%varnames(this%numvar))
155 this%varnames(1) =
'slmsk'
156 this%varnames(2) =
'tsea'
157 this%varnames(3) =
'fice'
158 this%varnames(4) =
'tisfc'
159 this%varnames(5) =
'tsfc'
160 this%varnames(6) =
'tsfcl'
161 this%varnames(7) =
'zorli'
162 this%varnames(8) =
'hice'
164 allocate(this%latname)
165 allocate(this%lonname)
166 this%latname =
'yaxis_1'
167 this%lonname =
'xaxis_1'
169 allocate(this%dimnameEW)
170 allocate(this%dimnameNS)
171 allocate(this%dimnameTIME)
172 this%dimnameEW =
'xaxis_1'
173 this%dimnameNS =
'yaxis_1'
174 this%dimnameTIME =
'Time'
176 else if (trim(itype)==
'FV3LAM' .AND. wcstart==
'cold')
then
177 this%datatype = itype
188 allocate(this%varnames(this%numvar))
189 this%varnames(1) =
'slmsk'
190 this%varnames(2) =
'tsea'
191 this%varnames(3) =
'fice'
192 this%varnames(4) =
'tisfc'
193 this%varnames(5) =
'zorl'
194 this%varnames(6) =
'hice'
196 allocate(this%latname)
197 allocate(this%lonname)
198 this%latname =
'yaxis_1'
199 this%lonname =
'xaxis_1'
201 allocate(this%dimnameEW)
202 allocate(this%dimnameNS)
203 allocate(this%dimnameTIME)
204 this%dimnameEW =
'xaxis_1'
205 this%dimnameNS =
'yaxis_1'
206 this%dimnameTIME =
'Time'
211 write(6,*)
'Unknown data type:', itype
218 write(6,*)
'Finished initial_nwp'
234 write(6,*)
'List initial setup for ', this%datatype
235 write(6,*)
'number of variables ', this%numvar
236 write(6,*)
'variable index: mask, sst, ice, sfcT, sfcTl'
237 write(6,
'(15x,10I3)') this%i_mask, this%i_sst, this%i_ice, &
238 & this%i_sfcT, this%i_sfcTl
239 write(6,*)
'variable name:'
241 write(6,*) k,trim(this%varnames(k))
244 write(6,*)
'Finished list_initial_nwp'
272 subroutine read_nwp(this,filename,itype,wcstart,numlon,numlat,numtimes,time_to_get,mask,sst,ice,sfcT,iceT,sfcTl,zorl,hice,ybegin,yend)
276 character(len=6),
intent(in) :: itype
277 character(len=*),
intent(in) :: filename
278 character(len=4),
intent(in) :: wcstart
280 integer,
intent(in) :: time_to_get
281 integer,
intent(in) :: ybegin,yend
282 integer,
intent(inout) :: numlon, numlat, numtimes
284 real(r_kind),
intent(inout) :: mask(:,:),sst(:,:),ice(:,:),sfct(:,:) &
285 ,icet(:,:),sfctl(:,:),zorl(:,:),hice(:,:)
291 call ncdata%open(trim(filename),
'r',200)
292 call ncdata%get_dim(this%dimnameEW,this%xlon)
293 call ncdata%get_dim(this%dimnameNS,this%xlat)
294 call ncdata%get_dim(this%dimnameTIME,this%xtime)
296 write(6,*)
'number of longitudes for file ', filename, this%xlon
298 write(6,*)
'number of latitudes for file ', filename, this%xlat
300 numlat = yend-ybegin+1
301 write(6,*)
'number of times for file ', filename, this%xtime
302 numtimes = this%xtime
303 write(6,*)
'the range of Y for this domain is=',ybegin,yend
306 if (wcstart ==
'cold' .OR. itype ==
' FVCOM')
then
307 allocate(this%nwp_mask_c(this%xlon,this%xlat))
308 allocate(this%nwp_sst_c(this%xlon,this%xlat,this%xtime))
309 allocate(this%nwp_ice_c(this%xlon,this%xlat,this%xtime))
310 allocate(this%nwp_sfcT_c(this%xlon,this%xlat,this%xtime))
311 allocate(this%nwp_iceT_c(this%xlon,this%xlat,this%xtime))
312 allocate(this%nwp_zorl_c(this%xlon,this%xlat,this%xtime))
313 allocate(this%nwp_hice_c(this%xlon,this%xlat,this%xtime))
318 write(6,*)
'itype = ', itype
319 write(6,*)
'wcstart = ', wcstart
320 write(6,*)
'xlat = ', this%xlat
321 write(6,*)
'xlon = ', this%xlon
322 write(6,*)
'xtime = ', this%xtime
324 if (this%i_mask .gt. 0)
then
325 call ncdata%get_var(this%varnames(this%i_mask),this%xlon, &
326 this%xlat,this%nwp_mask_c)
327 mask = this%nwp_mask_c(:,ybegin:yend)
329 if (this%i_sst .gt. 0)
then
330 write(6,*)
'get sst for cold or FVCOM'
331 call ncdata%get_var(this%varnames(this%i_sst),this%xlon, &
332 this%xlat,this%xtime,this%nwp_sst_c)
333 sst = this%nwp_sst_c(:,ybegin:yend,time_to_get)
335 if (this%i_ice .gt. 0)
then
336 call ncdata%get_var(this%varnames(this%i_ice),this%xlon, &
337 this%xlat,this%xtime,this%nwp_ice_c)
338 ice = this%nwp_ice_c(:,ybegin:yend,time_to_get)
340 if (this%i_sfcT .gt. 0)
then
341 call ncdata%get_var(this%varnames(this%i_sfcT),this%xlon, &
342 this%xlat,this%xtime,this%nwp_sfcT_c)
343 sfct = this%nwp_sfcT_c(:,ybegin:yend,time_to_get)
345 if (this%i_iceT .gt. 0)
then
346 call ncdata%get_var(this%varnames(this%i_iceT),this%xlon, &
347 this%xlat,this%xtime,this%nwp_iceT_c)
348 icet = this%nwp_iceT_c(:,ybegin:yend,time_to_get)
350 if (this%i_zorl .gt. 0)
then
351 call ncdata%get_var(this%varnames(this%i_zorl),this%xlon, &
352 this%xlat,this%xtime,this%nwp_zorl_c)
353 zorl = this%nwp_zorl_c(:,ybegin:yend,time_to_get)
355 if (this%i_hice .gt. 0)
then
356 call ncdata%get_var(this%varnames(this%i_hice),this%xlon, &
357 this%xlat,this%xtime,this%nwp_hice_c)
358 hice = this%nwp_hice_c(:,ybegin:yend,time_to_get)
361 else if (wcstart ==
'warm')
then
362 allocate(this%nwp_mask_w(this%xlon,this%xlat))
363 allocate(this%nwp_sst_w(this%xlon,this%xlat))
364 allocate(this%nwp_ice_w(this%xlon,this%xlat))
365 allocate(this%nwp_sfcT_w(this%xlon,this%xlat))
366 allocate(this%nwp_iceT_w(this%xlon,this%xlat))
367 allocate(this%nwp_sfcTl_w(this%xlon,this%xlat))
368 allocate(this%nwp_zorl_w(this%xlon,this%xlat))
369 allocate(this%nwp_hice_w(this%xlon,this%xlat))
373 write(6,*)
'itype = ', itype
374 write(6,*)
'wcstart =', wcstart
375 write(6,*)
'xlat = ', this%xlat
376 write(6,*)
'xlon = ', this%xlon
377 write(6,*)
'xtime = ', this%xtime
379 if (this%i_mask .gt. 0)
then
380 call ncdata%get_var(this%varnames(this%i_mask),this%xlon, &
381 this%xlat,this%nwp_mask_w)
382 mask = this%nwp_mask_w(:,ybegin:yend)
384 if (this%i_sst .gt. 0)
then
385 call ncdata%get_var(this%varnames(this%i_sst),this%xlon, &
386 this%xlat,this%nwp_sst_w)
387 sst = this%nwp_sst_w(:,ybegin:yend)
389 if (this%i_ice .gt. 0)
then
390 call ncdata%get_var(this%varnames(this%i_ice),this%xlon, &
391 this%xlat,this%nwp_ice_w)
392 ice = this%nwp_ice_w(:,ybegin:yend)
394 if (this%i_sfcT .gt. 0)
then
395 call ncdata%get_var(this%varnames(this%i_sfcT),this%xlon, &
396 this%xlat,this%nwp_sfcT_w)
397 sfct = this%nwp_sfcT_w(:,ybegin:yend)
399 if (this%i_iceT .gt. 0)
then
400 call ncdata%get_var(this%varnames(this%i_iceT),this%xlon, &
401 this%xlat,this%nwp_iceT_w)
402 icet = this%nwp_iceT_w(:,ybegin:yend)
404 if (this%i_sfcTl .gt. 0)
then
405 call ncdata%get_var(this%varnames(this%i_sfcTl),this%xlon, &
406 this%xlat,this%nwp_sfcTl_w)
407 sfctl = this%nwp_sfcTl_w(:,ybegin:yend)
409 if (this%i_zorl .gt. 0)
then
410 call ncdata%get_var(this%varnames(this%i_zorl),this%xlon, &
411 this%xlat,this%nwp_zorl_w)
412 zorl = this%nwp_zorl_w(:,ybegin:yend)
414 if (this%i_hice .gt. 0)
then
415 call ncdata%get_var(this%varnames(this%i_hice),this%xlon, &
416 this%xlat,this%nwp_hice_w)
417 hice = this%nwp_hice_w(:,ybegin:yend)
421 write(6,*)
'Choose either "warm" or "cold" for file'
422 stop
'Error in wcstart. Check spelling or if variable was assigned'
428 write(6,*)
'Finished read_nwp'
442 character(len=6),
intent(in) :: itype
443 character(len=4),
intent(in) :: wcstart
445 type(nwpbase
),
pointer :: thisobs,thisobsnext
447 deallocate(this%varnames)
448 deallocate(this%latname)
449 deallocate(this%lonname)
450 deallocate(this%dimnameEW)
451 deallocate(this%dimnameNS)
452 deallocate(this%dimnameTIME)
453 if (wcstart ==
'cold' .OR. itype==
' FVCOM')
then
454 deallocate(this%nwp_mask_c)
455 deallocate(this%nwp_sst_c)
456 deallocate(this%nwp_ice_c)
457 deallocate(this%nwp_sfcT_c)
458 deallocate(this%nwp_iceT_c)
459 deallocate(this%nwp_zorl_c)
460 deallocate(this%nwp_hice_c)
461 if (itype==
' FVCOM')
deallocate(this%dimnameDATE)
462 else if (wcstart ==
'warm')
then
463 deallocate(this%nwp_mask_w)
464 deallocate(this%nwp_sst_w)
465 deallocate(this%nwp_ice_w)
466 deallocate(this%nwp_sfcT_w)
467 deallocate(this%nwp_iceT_w)
468 deallocate(this%nwp_sfcTl_w)
469 deallocate(this%nwp_zorl_w)
470 deallocate(this%nwp_hice_w)
472 write(6,*)
'no deallocation'
476 if(.NOT.
associated(thisobs))
then
477 write(6,*)
'No memory to release'
480 do while(
associated(thisobs))
482 thisobsnext => thisobs%next
483 call thisobs%destroy()
484 thisobs => thisobsnext
487 write(6,*)
'Finished finish_nwp'
505 character(len=*),
intent(in) :: filename
506 character(len=*),
intent(in) :: instr
507 integer,
intent(out) :: outindex
509 character(len=26) :: temp
515 call ncdata%open(trim(filename),
'r',200)
516 call ncdata%get_dim(this%dimnameTIME,this%xtime)
517 call ncdata%get_dim(this%dimnameDATE,this%datelen)
518 write(6,*)
'xtime = ', this%xtime
519 write(6,*)
'datelen = ', this%datelen
520 allocate(this%times(this%datelen,this%xtime))
521 call ncdata%get_var(
'Times',this%datelen,this%xtime,this%times)
527 temp(i:i) = this%times(i,k)
529 if (trim(temp) == trim(instr))
then
534 if (foundind == 0)
then
536 deallocate(this%times)
538 write(6,*)
'WARNING: Supplied time not found in file: ', trim(instr)
539 write(6,*)
'Stoppping fvcom_to_FV3 and proceeding without using FVCOM data'
543 deallocate(this%times)
Module to hold specification kinds for variable declaration.
This module defines nwp observation data structure and the method to read and write observations from...
Functions to read and write netcdf files.
subroutine get_time_ind_nwp(this, filename, instr, outindex)
This subroutine searches the FVCOM 'Times' variable and returns the matching index.
procedure read_n=> read_nwp
Initialize arrays, get data.
subroutine read_nwp(this, filename, itype, wcstart, numlon, numlat, numtimes, time_to_get, mask, sst, ice, sfcT, iceT, sfcTl, zorl, hice, ybegin, yend)
This subroutine initializes arrays to receive the NWP data, and opens the file and gets the data...
subroutine initial_nwp(this, itype, wcstart)
This subroutine defines the number of variables and their names for each NWP data type...
procedure finish=> finish_nwp
Finish and deallocate.
This module defines FV3LAM and FVCOM forecast data structure and the method to read and write observa...
subroutine list_initial_nwp(this)
This subroutine lists the setup for NWP data that was done by the initial_nwp subroutine.
procedure get_time_ind=> get_time_ind_nwp
Get time ind.
subroutine finish_nwp(this, itype, wcstart)
Finish and deallocate.
procedure initial=> initial_nwp
Defines vars and names.
procedure list_initial=> list_initial_nwp
List the setup.