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_kind),
allocatable :: nwp_mask_c(:,:)
51 real(r_kind),
allocatable :: nwp_sst_c(:,:,:)
52 real(r_kind),
allocatable :: nwp_ice_c(:,:,:)
53 real(r_kind),
allocatable :: nwp_sfct_c(:,:,:)
54 real(r_kind),
allocatable :: nwp_icet_c(:,:,:)
55 real(r_kind),
allocatable :: nwp_zorl_c(:,:,:)
56 real(r_kind),
allocatable :: nwp_hice_c(:,:,:)
58 real(r_kind),
allocatable :: nwp_mask_w(:,:)
59 real(r_kind),
allocatable :: nwp_sst_w(:,:)
60 real(r_kind),
allocatable :: nwp_ice_w(:,:)
61 real(r_kind),
allocatable :: nwp_sfct_w(:,:)
62 real(r_kind),
allocatable :: nwp_icet_w(:,:)
63 real(r_kind),
allocatable :: nwp_sfctl_w(:,:)
64 real(r_kind),
allocatable :: nwp_zorl_w(:,:)
65 real(r_kind),
allocatable :: nwp_hice_w(:,:)
89 class(fcst_nwp) :: this
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' 216 class(fcst_nwp) :: this
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)
260 class(fcst_nwp) :: this
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_kind),
intent(inout) :: mask(:,:),sst(:,:),ice(:,:),sfcT(:,:) &
271 ,iceT(:,:),sfcTl(:,:),zorl(:,:),hice(:,:)
277 call ncdata%open(trim(filename),
'r',200)
278 call ncdata%get_dim(this%dimnameEW,this%xlon)
279 call ncdata%get_dim(this%dimnameNS,this%xlat)
280 call ncdata%get_dim(this%dimnameTIME,this%xtime)
282 write(6,*)
'number of longitudes for file ', filename, this%xlon
284 write(6,*)
'number of latitudes for file ', filename, this%xlat
286 numlat = yend-ybegin+1
287 write(6,*)
'number of times for file ', filename, this%xtime
288 numtimes = this%xtime
289 write(6,*)
'the range of Y for this domain is=',ybegin,yend
292 if (wcstart ==
'cold' .OR. itype ==
' FVCOM')
then 293 allocate(this%nwp_mask_c(this%xlon,this%xlat))
294 allocate(this%nwp_sst_c(this%xlon,this%xlat,this%xtime))
295 allocate(this%nwp_ice_c(this%xlon,this%xlat,this%xtime))
296 allocate(this%nwp_sfcT_c(this%xlon,this%xlat,this%xtime))
297 allocate(this%nwp_iceT_c(this%xlon,this%xlat,this%xtime))
298 allocate(this%nwp_zorl_c(this%xlon,this%xlat,this%xtime))
299 allocate(this%nwp_hice_c(this%xlon,this%xlat,this%xtime))
304 write(6,*)
'itype = ', itype
305 write(6,*)
'wcstart = ', wcstart
306 write(6,*)
'xlat = ', this%xlat
307 write(6,*)
'xlon = ', this%xlon
308 write(6,*)
'xtime = ', this%xtime
310 if (this%i_mask .gt. 0)
then 311 call ncdata%get_var(this%varnames(this%i_mask),this%xlon, &
312 this%xlat,this%nwp_mask_c)
313 mask = this%nwp_mask_c(:,ybegin:yend)
315 if (this%i_sst .gt. 0)
then 316 write(6,*)
'get sst for cold or FVCOM' 317 call ncdata%get_var(this%varnames(this%i_sst),this%xlon, &
318 this%xlat,this%xtime,this%nwp_sst_c)
319 sst = this%nwp_sst_c(:,ybegin:yend,time_to_get)
321 if (this%i_ice .gt. 0)
then 322 call ncdata%get_var(this%varnames(this%i_ice),this%xlon, &
323 this%xlat,this%xtime,this%nwp_ice_c)
324 ice = this%nwp_ice_c(:,ybegin:yend,time_to_get)
326 if (this%i_sfcT .gt. 0)
then 327 call ncdata%get_var(this%varnames(this%i_sfcT),this%xlon, &
328 this%xlat,this%xtime,this%nwp_sfcT_c)
329 sfct = this%nwp_sfcT_c(:,ybegin:yend,time_to_get)
331 if (this%i_iceT .gt. 0)
then 332 call ncdata%get_var(this%varnames(this%i_iceT),this%xlon, &
333 this%xlat,this%xtime,this%nwp_iceT_c)
334 icet = this%nwp_iceT_c(:,ybegin:yend,time_to_get)
336 if (this%i_zorl .gt. 0)
then 337 call ncdata%get_var(this%varnames(this%i_zorl),this%xlon, &
338 this%xlat,this%xtime,this%nwp_zorl_c)
339 zorl = this%nwp_zorl_c(:,ybegin:yend,time_to_get)
341 if (this%i_hice .gt. 0)
then 342 call ncdata%get_var(this%varnames(this%i_hice),this%xlon, &
343 this%xlat,this%xtime,this%nwp_hice_c)
344 hice = this%nwp_hice_c(:,ybegin:yend,time_to_get)
347 else if (wcstart ==
'warm')
then 348 allocate(this%nwp_mask_w(this%xlon,this%xlat))
349 allocate(this%nwp_sst_w(this%xlon,this%xlat))
350 allocate(this%nwp_ice_w(this%xlon,this%xlat))
351 allocate(this%nwp_sfcT_w(this%xlon,this%xlat))
352 allocate(this%nwp_iceT_w(this%xlon,this%xlat))
353 allocate(this%nwp_sfcTl_w(this%xlon,this%xlat))
354 allocate(this%nwp_zorl_w(this%xlon,this%xlat))
355 allocate(this%nwp_hice_w(this%xlon,this%xlat))
359 write(6,*)
'itype = ', itype
360 write(6,*)
'wcstart =', wcstart
361 write(6,*)
'xlat = ', this%xlat
362 write(6,*)
'xlon = ', this%xlon
363 write(6,*)
'xtime = ', this%xtime
365 if (this%i_mask .gt. 0)
then 366 call ncdata%get_var(this%varnames(this%i_mask),this%xlon, &
367 this%xlat,this%nwp_mask_w)
368 mask = this%nwp_mask_w(:,ybegin:yend)
370 if (this%i_sst .gt. 0)
then 371 call ncdata%get_var(this%varnames(this%i_sst),this%xlon, &
372 this%xlat,this%nwp_sst_w)
373 sst = this%nwp_sst_w(:,ybegin:yend)
375 if (this%i_ice .gt. 0)
then 376 call ncdata%get_var(this%varnames(this%i_ice),this%xlon, &
377 this%xlat,this%nwp_ice_w)
378 ice = this%nwp_ice_w(:,ybegin:yend)
380 if (this%i_sfcT .gt. 0)
then 381 call ncdata%get_var(this%varnames(this%i_sfcT),this%xlon, &
382 this%xlat,this%nwp_sfcT_w)
383 sfct = this%nwp_sfcT_w(:,ybegin:yend)
385 if (this%i_iceT .gt. 0)
then 386 call ncdata%get_var(this%varnames(this%i_iceT),this%xlon, &
387 this%xlat,this%nwp_iceT_w)
388 icet = this%nwp_iceT_w(:,ybegin:yend)
390 if (this%i_sfcTl .gt. 0)
then 391 call ncdata%get_var(this%varnames(this%i_sfcTl),this%xlon, &
392 this%xlat,this%nwp_sfcTl_w)
393 sfctl = this%nwp_sfcTl_w(:,ybegin:yend)
395 if (this%i_zorl .gt. 0)
then 396 call ncdata%get_var(this%varnames(this%i_zorl),this%xlon, &
397 this%xlat,this%nwp_zorl_w)
398 zorl = this%nwp_zorl_w(:,ybegin:yend)
400 if (this%i_hice .gt. 0)
then 401 call ncdata%get_var(this%varnames(this%i_hice),this%xlon, &
402 this%xlat,this%nwp_hice_w)
403 hice = this%nwp_hice_w(:,ybegin:yend)
407 write(6,*)
'Choose either "warm" or "cold" for file' 408 stop
'Error in wcstart. Check spelling or if variable was assigned' 414 write(6,*)
'Finished read_nwp' 427 class(fcst_nwp) :: this
428 character(len=6),
intent(in) :: itype
429 character(len=4),
intent(in) :: wcstart
431 deallocate(this%varnames)
432 deallocate(this%latname)
433 deallocate(this%lonname)
434 deallocate(this%dimnameEW)
435 deallocate(this%dimnameNS)
436 deallocate(this%dimnameTIME)
437 if (wcstart ==
'cold' .OR. itype==
' FVCOM')
then 438 deallocate(this%nwp_mask_c)
439 deallocate(this%nwp_sst_c)
440 deallocate(this%nwp_ice_c)
441 deallocate(this%nwp_sfcT_c)
442 deallocate(this%nwp_iceT_c)
443 deallocate(this%nwp_zorl_c)
444 deallocate(this%nwp_hice_c)
445 if (itype==
' FVCOM')
deallocate(this%dimnameDATE)
446 else if (wcstart ==
'warm')
then 447 deallocate(this%nwp_mask_w)
448 deallocate(this%nwp_sst_w)
449 deallocate(this%nwp_ice_w)
450 deallocate(this%nwp_sfcT_w)
451 deallocate(this%nwp_iceT_w)
452 deallocate(this%nwp_sfcTl_w)
453 deallocate(this%nwp_zorl_w)
454 deallocate(this%nwp_hice_w)
456 write(6,*)
'no deallocation' 459 write(6,*)
'Finished finish_nwp' 475 class(fcst_nwp) :: this
477 character(len=*),
intent(in) :: filename
478 character(len=*),
intent(in) :: instr
479 integer,
intent(out) :: outindex
481 character(len=26) :: temp
487 call ncdata%open(trim(filename),
'r',200)
488 call ncdata%get_dim(this%dimnameTIME,this%xtime)
489 call ncdata%get_dim(this%dimnameDATE,this%datelen)
490 write(6,*)
'xtime = ', this%xtime
491 write(6,*)
'datelen = ', this%datelen
492 allocate(this%times(this%datelen,this%xtime))
493 call ncdata%get_var(
'Times',this%datelen,this%xtime,this%times)
499 temp(i:i) = this%times(i,k)
501 if (trim(temp) == trim(instr))
then 506 if (foundind == 0)
then 508 deallocate(this%times)
510 write(6,*)
'WARNING: Supplied time not found in file: ', trim(instr)
511 write(6,*)
'Stoppping fvcom_to_FV3 and proceeding without using FVCOM data' 515 deallocate(this%times)
subroutine finish_nwp(this, itype, wcstart)
Finish and deallocate.
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 get_time_ind_nwp(this, filename, instr, outindex)
This subroutine searches the FVCOM 'Times' variable and returns the matching index.
type(ncio) ncdata
Wrapper object for netCDF data file.
subroutine initial_nwp(this, itype, wcstart)
This subroutine defines the number of variables and their names for each NWP data type...
real(r_single), parameter, public rmissing
Fill value for single real missing data.
Functions to read and write netcdf files.
integer, parameter, public i_short
generic specification kind for default short.
This module defines FV3LAM and FVCOM forecast data structure and the method to read and write observa...
integer, parameter, public r_kind
generic specification kind for default floating point
subroutine list_initial_nwp(this)
This subroutine lists the setup for NWP data that was done by the initial_nwp subroutine.
integer, parameter, public r_single
specification kind for single precision (4-byte) real variable.
Module to hold specification kinds for variable declaration.