17 use kinds, only: r_kind, r_single, i_short, rmissing
27 character(len=6) :: datatype
41 character(len=20),
allocatable :: varnames(:)
42 character(len=20),
allocatable :: latname
43 character(len=20),
allocatable :: lonname
44 character(len=20),
allocatable :: dimnameEW
45 character(len=20),
allocatable :: dimnameNS
46 character(len=20),
allocatable :: dimnameTIME
47 character(len=20),
allocatable :: dimnameDATE
48 character(len=1),
allocatable :: times(:,:)
50 real(r_single),
allocatable :: nwp_mask_c(:,:)
51 real(r_single),
allocatable :: nwp_sst_c(:,:,:)
52 real(r_single),
allocatable :: nwp_ice_c(:,:,:)
53 real(r_single),
allocatable :: nwp_sfct_c(:,:,:)
54 real(r_single),
allocatable :: nwp_icet_c(:,:,:)
55 real(r_single),
allocatable :: nwp_zorl_c(:,:,:)
56 real(r_single),
allocatable :: nwp_hice_c(:,:,:)
58 real(r_single),
allocatable :: nwp_mask_w(:,:)
59 real(r_single),
allocatable :: nwp_sst_w(:,:)
60 real(r_single),
allocatable :: nwp_ice_w(:,:)
61 real(r_single),
allocatable :: nwp_sfct_w(:,:)
62 real(r_single),
allocatable :: nwp_icet_w(:,:)
63 real(r_single),
allocatable :: nwp_sfctl_w(:,:)
64 real(r_single),
allocatable :: nwp_zorl_w(:,:)
65 real(r_single),
allocatable :: nwp_hice_w(:,:)
91 character(len=6),
intent(in) :: itype
92 character(len=4),
intent(in) :: wcstart
95 if (itype==
' FVCOM')
then
107 allocate(this%varnames(this%numvar))
108 this%varnames(1) =
'glmask'
109 this%varnames(2) =
'tsfc'
110 this%varnames(3) =
'aice'
111 this%varnames(4) =
'tisfc'
112 this%varnames(5) =
'vice'
114 allocate(this%latname)
115 allocate(this%lonname)
119 allocate(this%dimnameEW)
120 allocate(this%dimnameNS)
121 allocate(this%dimnameTIME)
122 allocate(this%dimnameDATE)
123 this%dimnameEW =
'lon'
124 this%dimnameNS =
'lat'
125 this%dimnameTIME =
'Time'
126 this%dimnameDATE =
'DateStrLen'
130 else if (trim(itype)==
'FV3LAM' .AND. wcstart==
'warm')
then
131 this%datatype = itype
143 allocate(this%varnames(this%numvar))
144 this%varnames(1) =
'slmsk'
145 this%varnames(2) =
'tsea'
146 this%varnames(3) =
'fice'
147 this%varnames(4) =
'tisfc'
148 this%varnames(5) =
'tsfc'
149 this%varnames(6) =
'tsfcl'
150 this%varnames(7) =
'zorli'
151 this%varnames(8) =
'hice'
153 allocate(this%latname)
154 allocate(this%lonname)
155 this%latname =
'yaxis_1'
156 this%lonname =
'xaxis_1'
158 allocate(this%dimnameEW)
159 allocate(this%dimnameNS)
160 allocate(this%dimnameTIME)
161 this%dimnameEW =
'xaxis_1'
162 this%dimnameNS =
'yaxis_1'
163 this%dimnameTIME =
'Time'
165 else if (trim(itype)==
'FV3LAM' .AND. wcstart==
'cold')
then
166 this%datatype = itype
177 allocate(this%varnames(this%numvar))
178 this%varnames(1) =
'slmsk'
179 this%varnames(2) =
'tsea'
180 this%varnames(3) =
'fice'
181 this%varnames(4) =
'tisfc'
182 this%varnames(5) =
'zorl'
183 this%varnames(6) =
'hice'
185 allocate(this%latname)
186 allocate(this%lonname)
187 this%latname =
'yaxis_1'
188 this%lonname =
'xaxis_1'
190 allocate(this%dimnameEW)
191 allocate(this%dimnameNS)
192 allocate(this%dimnameTIME)
193 this%dimnameEW =
'xaxis_1'
194 this%dimnameNS =
'yaxis_1'
195 this%dimnameTIME =
'Time'
200 write(6,*)
'Unknown data type:', itype
204 write(6,*)
'Finished initial_nwp'
220 write(6,*)
'List initial setup for ', this%datatype
221 write(6,*)
'number of variables ', this%numvar
222 write(6,*)
'variable index: mask, sst, ice, sfcT, sfcTl'
223 write(6,
'(15x,10I3)') this%i_mask, this%i_sst, this%i_ice, &
224 & this%i_sfcT, this%i_sfcTl
225 write(6,*)
'variable name:'
227 write(6,*) k,trim(this%varnames(k))
230 write(6,*)
'Finished list_initial_nwp'
258 subroutine read_nwp(this,filename,itype,wcstart,numlon,numlat,numtimes,time_to_get,mask,sst,ice,sfcT,iceT,sfcTl,zorl,hice,ybegin,yend)
262 character(len=6),
intent(in) :: itype
263 character(len=*),
intent(in) :: filename
264 character(len=4),
intent(in) :: wcstart
266 integer,
intent(in) :: time_to_get
267 integer,
intent(in) :: ybegin,yend
268 integer,
intent(inout) :: numlon, numlat, numtimes
270 real(r_single),
intent(inout) :: mask(:,:),sst(:,:),ice(:,:),sfct(:,:) &
271 ,icet(:,:),sfctl(:,:),zorl(:,:),hice(:,:)
273 real(r_kind),
allocatable :: tmp2d8b(:,:)
274 real(r_kind),
allocatable :: tmp3d8b(:,:,:)
280 call ncdata%open(trim(filename),
'r',200)
281 call ncdata%get_dim(this%dimnameEW,this%xlon)
282 call ncdata%get_dim(this%dimnameNS,this%xlat)
283 call ncdata%get_dim(this%dimnameTIME,this%xtime)
285 write(6,*)
'number of longitudes for file ', filename, this%xlon
287 write(6,*)
'number of latitudes for file ', filename, this%xlat
289 numlat = yend-ybegin+1
290 write(6,*)
'number of times for file ', filename, this%xtime
291 numtimes = this%xtime
292 write(6,*)
'the range of Y for this domain is=',ybegin,yend
295 if (wcstart ==
'cold' .OR. itype ==
' FVCOM')
then
296 allocate(this%nwp_mask_c(this%xlon,this%xlat))
297 allocate(this%nwp_sst_c(this%xlon,this%xlat,this%xtime))
298 allocate(this%nwp_ice_c(this%xlon,this%xlat,this%xtime))
299 allocate(this%nwp_sfcT_c(this%xlon,this%xlat,this%xtime))
300 allocate(this%nwp_iceT_c(this%xlon,this%xlat,this%xtime))
301 allocate(this%nwp_zorl_c(this%xlon,this%xlat,this%xtime))
302 allocate(this%nwp_hice_c(this%xlon,this%xlat,this%xtime))
303 allocate(tmp2d8b(this%xlon,this%xlat))
304 allocate(tmp3d8b(this%xlon,this%xlat,this%xtime))
309 write(6,*)
'itype = ', itype
310 write(6,*)
'wcstart = ', wcstart
311 write(6,*)
'xlat = ', this%xlat
312 write(6,*)
'xlon = ', this%xlon
313 write(6,*)
'xtime = ', this%xtime
315 if (this%i_mask .gt. 0)
then
316 call ncdata%get_var(this%varnames(this%i_mask),this%xlon, &
318 this%nwp_mask_c=tmp2d8b
319 mask = this%nwp_mask_c(:,ybegin:yend)
321 if (this%i_sst .gt. 0)
then
322 write(6,*)
'get sst for cold or FVCOM'
323 call ncdata%get_var(this%varnames(this%i_sst),this%xlon, &
324 this%xlat,this%xtime,tmp3d8b)
325 this%nwp_sst_c=tmp3d8b
326 sst = this%nwp_sst_c(:,ybegin:yend,time_to_get)
328 if (this%i_ice .gt. 0)
then
329 call ncdata%get_var(this%varnames(this%i_ice),this%xlon, &
330 this%xlat,this%xtime,tmp3d8b)
331 this%nwp_ice_c=tmp3d8b
332 ice = this%nwp_ice_c(:,ybegin:yend,time_to_get)
334 if (this%i_sfcT .gt. 0)
then
335 call ncdata%get_var(this%varnames(this%i_sfcT),this%xlon, &
336 this%xlat,this%xtime,tmp3d8b)
337 this%nwp_sfcT_c=tmp3d8b
338 sfct = this%nwp_sfcT_c(:,ybegin:yend,time_to_get)
340 if (this%i_iceT .gt. 0)
then
341 call ncdata%get_var(this%varnames(this%i_iceT),this%xlon, &
342 this%xlat,this%xtime,tmp3d8b)
343 this%nwp_iceT_c=tmp3d8b
344 icet = this%nwp_iceT_c(:,ybegin:yend,time_to_get)
346 if (this%i_zorl .gt. 0)
then
347 call ncdata%get_var(this%varnames(this%i_zorl),this%xlon, &
348 this%xlat,this%xtime,tmp3d8b)
349 this%nwp_zorl_c=tmp3d8b
350 zorl = this%nwp_zorl_c(:,ybegin:yend,time_to_get)
352 if (this%i_hice .gt. 0)
then
353 call ncdata%get_var(this%varnames(this%i_hice),this%xlon, &
354 this%xlat,this%xtime,tmp3d8b)
355 this%nwp_hice_c=tmp3d8b
356 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 deallocate(this%varnames)
446 deallocate(this%latname)
447 deallocate(this%lonname)
448 deallocate(this%dimnameEW)
449 deallocate(this%dimnameNS)
450 deallocate(this%dimnameTIME)
451 if (wcstart ==
'cold' .OR. itype==
' FVCOM')
then
452 deallocate(this%nwp_mask_c)
453 deallocate(this%nwp_sst_c)
454 deallocate(this%nwp_ice_c)
455 deallocate(this%nwp_sfcT_c)
456 deallocate(this%nwp_iceT_c)
457 deallocate(this%nwp_zorl_c)
458 deallocate(this%nwp_hice_c)
459 if (itype==
' FVCOM')
deallocate(this%dimnameDATE)
460 else if (wcstart ==
'warm')
then
461 deallocate(this%nwp_mask_w)
462 deallocate(this%nwp_sst_w)
463 deallocate(this%nwp_ice_w)
464 deallocate(this%nwp_sfcT_w)
465 deallocate(this%nwp_iceT_w)
466 deallocate(this%nwp_sfcTl_w)
467 deallocate(this%nwp_zorl_w)
468 deallocate(this%nwp_hice_w)
470 write(6,*)
'no deallocation'
473 write(6,*)
'Finished finish_nwp'
491 character(len=*),
intent(in) :: filename
492 character(len=*),
intent(in) :: instr
493 integer,
intent(out) :: outindex
495 character(len=26) :: temp
501 call ncdata%open(trim(filename),
'r',200)
502 call ncdata%get_dim(this%dimnameTIME,this%xtime)
503 call ncdata%get_dim(this%dimnameDATE,this%datelen)
504 write(6,*)
'xtime = ', this%xtime
505 write(6,*)
'datelen = ', this%datelen
506 allocate(this%times(this%datelen,this%xtime))
507 call ncdata%get_var(
'Times',this%datelen,this%xtime,this%times)
513 temp(i:i) = this%times(i,k)
515 if (trim(temp) == trim(instr))
then
520 if (foundind == 0)
then
522 deallocate(this%times)
524 write(6,*)
'WARNING: Supplied time not found in file: ', trim(instr)
525 write(6,*)
'Stoppping fvcom_to_FV3 and proceeding without using FVCOM data'
529 deallocate(this%times)
Module to hold specification kinds for variable declaration.
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.