1 !------------------------------------------------------------------
3 !------------------------------------------------------------------
5 subroutine ext_pio_open_for_read(DatasetName, grid, SysDepInfo, DataHandle, Status)
10 include 'wrf_status_codes.h'
11 character *(*), INTENT(IN) :: DatasetName
13 character *(*), INTENT(IN) :: SysDepInfo
14 integer , INTENT(OUT) :: DataHandle
15 integer , INTENT(OUT) :: Status
16 DataHandle = 0 ! dummy setting to quiet warning message
17 CALL ext_pio_open_for_read_begin( DatasetName, grid, SysDepInfo, DataHandle, Status )
18 IF ( Status .EQ. WRF_NO_ERR ) THEN
19 CALL ext_pio_open_for_read_commit( DataHandle, Status )
22 end subroutine ext_pio_open_for_read
24 !ends training phase; switches internal flag to enable input
25 !must be paired with call to ext_pio_open_for_read_begin
26 subroutine ext_pio_open_for_read_commit(DataHandle, Status)
30 include 'wrf_status_codes.h'
31 integer, intent(in) :: DataHandle
32 integer, intent(out) :: Status
33 type(wrf_data_handle) ,pointer :: DH
35 if(WrfIOnotInitialized) then
36 Status = WRF_IO_NOT_INITIALIZED
37 write(msg,*) 'ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
38 call wrf_debug ( FATAL , msg)
41 call GetDH(DataHandle,DH,Status)
42 if(Status /= WRF_NO_ERR) then
43 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
44 call wrf_debug ( WARN , TRIM(msg))
47 DH%FileStatus = WRF_FILE_OPENED_FOR_READ
50 end subroutine ext_pio_open_for_read_commit
52 subroutine upgrade_filename(FileName)
55 character*(*), intent(inout) :: FileName
58 do i = 1, len(trim(FileName))
59 if(FileName(i:i) == '-') then
61 else if(FileName(i:i) == ':') then
66 end subroutine upgrade_filename
68 subroutine ext_pio_open_for_read_begin( FileName, grid, SysDepInfo, DataHandle, Status)
73 include 'wrf_status_codes.h'
74 character*(*) ,intent(INOUT) :: FileName
76 character*(*) ,intent(in) :: SysDepInfo
77 integer ,intent(out) :: DataHandle
78 integer ,intent(out) :: Status
79 type(wrf_data_handle) ,pointer :: DH
87 integer :: TotalNumVars
90 integer :: ndims, unlimitedDimID
91 character(PIO_MAX_NAME) :: Name
93 call upgrade_filename(FileName)
95 if(WrfIOnotInitialized) then
96 Status = WRF_IO_NOT_INITIALIZED
97 write(msg,*) 'ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
98 call wrf_debug ( FATAL , msg)
101 call allocHandle(DataHandle,DH,Status)
102 if(Status /= WRF_NO_ERR) then
103 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
104 call wrf_debug ( WARN , TRIM(msg))
108 if(DH%first_operation) then
109 call initialize_pio(grid, DH)
110 call define_pio_iodesc(grid, DH)
111 DH%first_operation = .false.
114 stat = pio_openfile(DH%iosystem, DH%file_handle, pio_iotype_pnetcdf, FileName)
115 call netcdf_err(stat,Status)
116 if(Status /= WRF_NO_ERR) then
117 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
118 call wrf_debug ( WARN , TRIM(msg))
122 stat = pio_inq_varid(DH%file_handle, DH%TimesName, DH%vtime)
123 call netcdf_err(stat,Status)
124 if(Status /= WRF_NO_ERR) then
125 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
126 call wrf_debug ( WARN , TRIM(msg))
130 stat = pio_inquire_variable(DH%file_handle, DH%vtime, DH%TimesName, XType, StoredDim, DimIDs, NAtts)
131 call netcdf_err(stat,Status)
132 if(Status /= WRF_NO_ERR) then
133 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
134 call wrf_debug ( WARN , TRIM(msg))
137 if(XType/=PIO_CHAR) then
138 Status = WRF_WARN_TYPE_MISMATCH
139 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
140 call wrf_debug ( WARN , TRIM(msg))
143 stat = pio_inq_dimlen(DH%file_handle, DimIDs(1), VLen(1))
144 call netcdf_err(stat,Status)
145 if(Status /= WRF_NO_ERR) then
146 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
147 call wrf_debug ( WARN , TRIM(msg))
150 if(VLen(1) /= DateStrLen) then
151 Status = WRF_WARN_DATESTR_BAD_LENGTH
152 write(msg,*) 'Warning DATESTR BAD LENGTH in ',__FILE__,', line', __LINE__
153 call wrf_debug ( WARN , TRIM(msg))
157 stat = pio_inq_dimlen(DH%file_handle, DimIDs(2), VLen(2))
158 call netcdf_err(stat,Status)
159 if(Status /= WRF_NO_ERR) then
160 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
161 call wrf_debug ( WARN , TRIM(msg))
164 if(VLen(2) > MaxTimes) then
165 Status = WRF_ERR_FATAL_TOO_MANY_TIMES
166 write(msg,*) 'Fatal TOO MANY TIME VALUES in ',__FILE__,', line', __LINE__
167 call wrf_debug ( FATAL , TRIM(msg))
173 stat = pio_get_var(DH%file_handle, DH%vtime, DH%Times(1:VLen(2)))
174 call netcdf_err(stat,Status)
175 if(Status /= WRF_NO_ERR) then
176 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
177 call wrf_debug ( WARN , TRIM(msg))
181 stat = pio_inquire(DH%file_handle, ndims, TotalNumVars, NAtts, unlimitedDimID)
182 call netcdf_err(stat,Status)
183 if(Status /= WRF_NO_ERR) then
184 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
185 call wrf_debug ( WARN , TRIM(msg))
191 stat = pio_inq_varname(DH%file_handle,i,Name)
192 call netcdf_err(stat,Status)
193 if(Status /= WRF_NO_ERR) then
194 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
195 call wrf_debug ( WARN , TRIM(msg))
197 elseif(Name(1:5) /= 'md___' .and. Name /= DH%TimesName) then
199 DH%VarNames(NumVars) = Name
200 DH%VarIDs(NumVars) = i
204 DH%NumberTimes = VLen(2)
205 DH%FileStatus = WRF_FILE_OPENED_NOT_COMMITTED
206 DH%FileName = trim(FileName)
207 DH%CurrentVariable = 0
213 stat = pio_inq_dimname(DH%file_handle,i,DH%DimNames(i))
214 if(Status /= WRF_NO_ERR) then
215 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
216 call wrf_debug ( WARN , TRIM(msg))
220 if(unlimitedDimID == i) then
221 DH%DimUnlimID = unlimitedDimID
222 DH%DimUnlimName = DH%DimNames(i)
227 end subroutine ext_pio_open_for_read_begin
229 subroutine ext_pio_open_for_update( FileName, grid, SysDepInfo, DataHandle, Status)
234 include 'wrf_status_codes.h'
235 character*(*) ,intent(INOUT) :: FileName
237 character*(*) ,intent(in) :: SysDepInfo
238 integer ,intent(out) :: DataHandle
239 integer ,intent(out) :: Status
240 type(wrf_data_handle) ,pointer :: DH
248 integer :: TotalNumVars
251 integer :: ndims, unlimitedDimID
252 character(PIO_MAX_NAME) :: Name
254 call upgrade_filename(FileName)
256 if(WrfIOnotInitialized) then
257 Status = WRF_IO_NOT_INITIALIZED
258 write(msg,*) 'ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
259 call wrf_debug ( FATAL , msg)
262 call allocHandle(DataHandle,DH,Status)
263 if(Status /= WRF_NO_ERR) then
264 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
265 call wrf_debug ( WARN , TRIM(msg))
269 if(DH%first_operation) then
270 call initialize_pio(grid, DH)
271 call define_pio_iodesc(grid, DH)
272 DH%first_operation = .false.
275 stat = pio_openfile(DH%iosystem, DH%file_handle, pio_iotype_pnetcdf, FileName)
276 call netcdf_err(stat,Status)
277 if(Status /= WRF_NO_ERR) then
278 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
279 call wrf_debug ( WARN , TRIM(msg))
282 stat = pio_inq_varid(DH%file_handle, DH%TimesName, DH%vtime)
283 call netcdf_err(stat,Status)
284 if(Status /= WRF_NO_ERR) then
285 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
286 call wrf_debug ( WARN , TRIM(msg))
289 stat = pio_inquire_variable(DH%file_handle, DH%vtime, DH%TimesName, &
290 XType, StoredDim, DimIDs, NAtts)
291 call netcdf_err(stat,Status)
292 if(Status /= WRF_NO_ERR) then
293 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
294 call wrf_debug ( WARN , TRIM(msg))
297 if(XType/=PIO_CHAR) then
298 Status = WRF_WARN_TYPE_MISMATCH
299 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
300 call wrf_debug ( WARN , TRIM(msg))
303 stat = pio_inq_dimlen(DH%file_handle, DimIDs(1), VLen(1))
304 call netcdf_err(stat,Status)
305 if(Status /= WRF_NO_ERR) then
306 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
307 call wrf_debug ( WARN , TRIM(msg))
310 if(VLen(1) /= DateStrLen) then
311 Status = WRF_WARN_DATESTR_BAD_LENGTH
312 write(msg,*) 'Warning DATESTR BAD LENGTH in ',__FILE__,', line', __LINE__
313 call wrf_debug ( WARN , TRIM(msg))
316 stat = pio_inq_dimlen(DH%file_handle, DimIDs(2), VLen(2))
317 call netcdf_err(stat,Status)
318 if(Status /= WRF_NO_ERR) then
319 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
320 call wrf_debug ( WARN , TRIM(msg))
323 if(VLen(2) > MaxTimes) then
324 Status = WRF_ERR_FATAL_TOO_MANY_TIMES
325 write(msg,*) 'Fatal TOO MANY TIME VALUES in ',__FILE__,', line', __LINE__
326 call wrf_debug ( FATAL , TRIM(msg))
331 !stat = pio_get_var(DH%file_handle, DH%vtime, VStart, VLen, DH%Times)
332 stat = pio_get_var(DH%file_handle, DH%vtime, DH%Times)
333 call netcdf_err(stat,Status)
334 if(Status /= WRF_NO_ERR) then
335 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
336 call wrf_debug ( WARN , TRIM(msg))
339 stat = pio_inquire(DH%file_handle, ndims, TotalNumVars, NAtts, unlimitedDimID)
340 call netcdf_err(stat,Status)
341 if(Status /= WRF_NO_ERR) then
342 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
343 call wrf_debug ( WARN , TRIM(msg))
348 stat = pio_inq_varname(DH%file_handle, i, Name)
349 call netcdf_err(stat,Status)
350 if(Status /= WRF_NO_ERR) then
351 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
352 call wrf_debug ( WARN , TRIM(msg))
354 elseif(Name(1:5) /= 'md___' .and. Name /= DH%TimesName) then
356 DH%VarNames(NumVars) = Name
357 DH%VarIDs(NumVars) = i
361 DH%NumberTimes = VLen(2)
362 DH%FileStatus = WRF_FILE_OPENED_FOR_UPDATE
363 DH%FileName = trim(FileName)
364 DH%CurrentVariable = 0
368 end subroutine ext_pio_open_for_update
371 SUBROUTINE ext_pio_open_for_write_begin(FileName,grid,SysDepInfo,DataHandle,Status)
378 include 'wrf_status_codes.h'
379 character*(*) ,intent(inout) :: FileName
381 character*(*) ,intent(in) :: SysDepInfo
382 integer ,intent(out) :: DataHandle
383 integer ,intent(out) :: Status
384 type(wrf_data_handle),pointer :: DH
387 character (7) :: Buffer
388 integer :: VDimIDs(2)
389 integer :: info, ierr ! added for Blue Gene (see PIO_CREAT below)
390 character*128 :: idstr,ntasks_x_str,loccomm_str
392 integer local_communicator_x, ntasks_x
394 call upgrade_filename(FileName)
396 if(WrfIOnotInitialized) then
397 Status = WRF_IO_NOT_INITIALIZED
398 write(msg,*) 'ext_pio_open_for_write_begin: ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
399 call wrf_debug ( FATAL , msg)
402 call allocHandle(DataHandle,DH,Status)
403 if(Status /= WRF_NO_ERR) then
404 write(msg,*) 'Fatal ALLOCATION ERROR in ext_pio_open_for_write_begin ',__FILE__,', line', __LINE__
405 call wrf_debug ( FATAL , TRIM(msg))
411 if(DH%first_operation) then
412 call initialize_pio(grid, DH)
413 call define_pio_iodesc(grid, DH)
414 DH%first_operation = .false.
417 !call mpi_info_create( info, ierr )
418 stat = pio_CreateFile(DH%iosystem, DH%file_handle, &
419 pio_iotype_pnetcdf, FileName, PIO_64BIT_OFFSET)
420 !call mpi_info_free( info, ierr)
422 call netcdf_err(stat,Status)
424 if(Status /= WRF_NO_ERR) then
425 write(msg,*) 'NetCDF error in ext_pio_open_for_write_begin ',__FILE__,', line', __LINE__
426 call wrf_debug ( WARN , TRIM(msg))
430 !JPE added for performance
431 !stat = nf90_set_fill(DH%file_handle, NF90_NOFILL, i)
433 DH%FileStatus = WRF_FILE_OPENED_NOT_COMMITTED
434 DH%FileName = trim(FileName)
435 stat = pio_def_dim(DH%file_handle, DH%DimUnlimName, PIO_UNLIMITED, DH%DimUnlimID)
436 !stat = pio_def_dim(DH%file_handle, DH%DimUnlimName, 1, DH%DimUnlimID)
437 call netcdf_err(stat,Status)
438 if(Status /= WRF_NO_ERR) then
439 write(msg,*) 'NetCDF error in ext_pio_open_for_write_begin ',__FILE__,', line', __LINE__
440 call wrf_debug ( WARN , TRIM(msg))
444 DH%VarNames (1:MaxVars) = NO_NAME
446 write(Buffer,FMT="('DIM',i4.4)") i
447 DH%DimNames (i) = Buffer
448 DH%DimLengths(i) = NO_DIM
451 DH%DimNames(1) = 'DateStrLen'
452 stat = pio_def_dim(DH%file_handle, DH%DimNames(1), DateStrLen, DH%DimIDs(1))
453 call netcdf_err(stat,Status)
454 if(Status /= WRF_NO_ERR) then
455 write(msg,*) 'NetCDF error in ext_pio_open_for_write_begin ',__FILE__,', line', __LINE__
456 call wrf_debug ( WARN , TRIM(msg))
460 VDimIDs(1) = DH%DimIDs(1)
461 VDimIDs(2) = DH%DimUnlimID
462 stat = pio_def_var(DH%file_handle,DH%TimesName,PIO_CHAR,VDimIDs,DH%vtime)
463 call netcdf_err(stat,Status)
464 if(Status /= WRF_NO_ERR) then
465 write(msg,*) 'NetCDF error in ext_pio_open_for_write_begin ',__FILE__,', line', __LINE__
466 call wrf_debug ( WARN , TRIM(msg))
469 DH%DimLengths(1) = DateStrLen
472 end subroutine ext_pio_open_for_write_begin
474 !opens a file for writing or coupler datastream for sending messages.
475 !no training phase for this version of the open stmt.
476 subroutine ext_pio_open_for_write (DatasetName, grid, &
477 SysDepInfo, DataHandle, Status)
482 include 'wrf_status_codes.h'
483 character *(*), intent(in) :: DatasetName
485 character *(*), intent(in) :: SysDepInfo
486 integer , intent(out) :: DataHandle
487 integer , intent(out) :: Status
489 DataHandle = 0 ! dummy setting to quiet warning message
491 end subroutine ext_pio_open_for_write
493 SUBROUTINE ext_pio_open_for_write_commit(DataHandle, Status)
497 include 'wrf_status_codes.h'
498 integer ,intent(in) :: DataHandle
499 integer ,intent(out) :: Status
500 type(wrf_data_handle),pointer :: DH
504 if(WrfIOnotInitialized) then
505 Status = WRF_IO_NOT_INITIALIZED
506 write(msg,*) 'ext_pio_open_for_write_commit: ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
507 call wrf_debug ( FATAL , msg)
510 call GetDH(DataHandle,DH,Status)
511 if(Status /= WRF_NO_ERR) then
512 write(msg,*) 'Warning Status = ',Status,' in ext_pio_open_for_write_commit ',__FILE__,', line', __LINE__
513 call wrf_debug ( WARN , TRIM(msg))
517 stat = pio_enddef(DH%file_handle)
518 call netcdf_err(stat,Status)
519 if(Status /= WRF_NO_ERR) then
520 write(msg,*) 'NetCDF error (',stat,') from pio_enddef in ext_pio_open_for_write_commit ',__FILE__,', line', __LINE__
521 call wrf_debug ( WARN , TRIM(msg))
524 DH%FileStatus = WRF_FILE_OPENED_FOR_WRITE
527 end subroutine ext_pio_open_for_write_commit
529 subroutine ext_pio_ioclose(DataHandle, Status)
535 include 'wrf_status_codes.h'
536 integer ,intent(in) :: DataHandle
537 integer ,intent(out) :: Status
538 type(wrf_data_handle),pointer :: DH
541 call GetDH(DataHandle,DH,Status)
542 if(Status /= WRF_NO_ERR) then
543 write(msg,*) 'Warning Status = ',Status,' in ext_pio_ioclose ',__FILE__,', line', __LINE__
544 call wrf_debug ( WARN , TRIM(msg))
547 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
548 Status = WRF_WARN_FILE_NOT_OPENED
549 write(msg,*) 'Warning FILE NOT OPENED in ext_pio_ioclose ',__FILE__,', line', __LINE__
550 call wrf_debug ( WARN , TRIM(msg))
551 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
552 Status = WRF_WARN_DRYRUN_CLOSE
553 write(msg,*) 'Warning TRY TO CLOSE DRYRUN in ext_pio_ioclose ',__FILE__,', line', __LINE__
554 call wrf_debug ( WARN , TRIM(msg))
555 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
557 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
559 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE) then
562 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
563 write(msg,*) 'Fatal error BAD FILE STATUS in ext_pio_ioclose ',__FILE__,', line', __LINE__
564 call wrf_debug ( FATAL , TRIM(msg))
568 call pio_closefile(DH%file_handle)
569 CALL deallocHandle( DataHandle, Status )
572 end subroutine ext_pio_ioclose
574 subroutine ext_pio_iosync( DataHandle, Status)
580 include 'wrf_status_codes.h'
581 integer ,intent(in) :: DataHandle
582 integer ,intent(out) :: Status
583 type(wrf_data_handle),pointer :: DH
586 call GetDH(DataHandle,DH,Status)
587 if(Status /= WRF_NO_ERR) then
588 write(msg,*) 'Warning Status = ',Status,' in ext_pio_iosync ',__FILE__,', line', __LINE__
589 call wrf_debug ( WARN , TRIM(msg))
592 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
593 Status = WRF_WARN_FILE_NOT_OPENED
594 write(msg,*) 'Warning FILE NOT OPENED in ext_pio_iosync ',__FILE__,', line', __LINE__
595 call wrf_debug ( WARN , TRIM(msg))
596 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
597 Status = WRF_WARN_FILE_NOT_COMMITTED
598 write(msg,*) 'Warning FILE NOT COMMITTED in ext_pio_iosync ',__FILE__,', line', __LINE__
599 call wrf_debug ( WARN , TRIM(msg))
600 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
602 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
605 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
606 write(msg,*) 'Fatal error BAD FILE STATUS in ext_pio_iosync ',__FILE__,', line', __LINE__
607 call wrf_debug ( FATAL , TRIM(msg))
610 call pio_syncfile(DH%file_handle)
611 call netcdf_err(stat,Status)
612 if(Status /= WRF_NO_ERR) then
613 write(msg,*) 'NetCDF error in ext_pio_iosync ',__FILE__,', line', __LINE__
614 call wrf_debug ( WARN , TRIM(msg))
618 end subroutine ext_pio_iosync
620 subroutine ext_pio_ioinit(SysDepInfo, Status)
623 include 'wrf_status_codes.h'
624 CHARACTER*(*), INTENT(IN) :: SysDepInfo
625 INTEGER ,INTENT(INOUT) :: Status
627 WrfIOnotInitialized = .false.
628 WrfDataHandles(1:WrfDataHandleMax)%Free = .true.
629 WrfDataHandles(1:WrfDataHandleMax)%TimesName = 'Times'
630 WrfDataHandles(1:WrfDataHandleMax)%DimUnlimName = 'Time'
631 WrfDataHandles(1:WrfDataHandleMax)%FileStatus = WRF_FILE_NOT_OPENED
634 end subroutine ext_pio_ioinit
636 subroutine ext_pio_inquiry (Inquiry, Result, Status)
639 include 'wrf_status_codes.h'
640 character *(*), INTENT(IN) :: Inquiry
641 character *(*), INTENT(OUT) :: Result
642 integer ,INTENT(INOUT) :: Status
643 SELECT CASE (Inquiry)
644 CASE ("RANDOM_WRITE","RANDOM_READ","SEQUENTIAL_WRITE","SEQUENTIAL_READ")
646 CASE ("OPEN_READ","OPEN_COMMIT_WRITE")
648 CASE ("OPEN_WRITE","OPEN_COMMIT_READ","PARALLEL_IO")
650 CASE ("SELF_DESCRIBING","SUPPORT_METADATA","SUPPORT_3D_FIELDS")
655 Result = 'No Result for that inquiry!'
659 end subroutine ext_pio_inquiry
661 subroutine ext_pio_ioexit(Status)
665 include 'wrf_status_codes.h'
666 integer , INTENT(INOUT) ::Status
668 type(wrf_data_handle),pointer :: DH
671 if(WrfIOnotInitialized) then
672 Status = WRF_IO_NOT_INITIALIZED
673 write(msg,*) 'ext_pio_ioinit was not called ',__FILE__,', line', __LINE__
674 call wrf_debug ( FATAL , msg)
677 do i=1,WrfDataHandleMax
678 CALL deallocHandle( i , stat )
681 end subroutine ext_pio_ioexit
683 subroutine ext_pio_get_dom_ti_real_arr(DataHandle,Element,Data,Count,OutCount,Status)
691 include 'wrf_status_codes.h'
692 integer ,intent(in) :: DataHandle
693 character*(*) ,intent(in) :: Element
694 real, intent(out) :: Data(:)
695 integer, intent(in) :: Count
696 integer, intent(out) :: OutCOunt
697 integer ,intent(out) :: Status
698 type(wrf_data_handle) ,pointer :: DH
702 real, allocatable :: Buffer(:)
704 call GetDH(DataHandle,DH,Status)
705 if(Status /= WRF_NO_ERR) then
706 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
707 call wrf_debug ( WARN , msg)
711 ! Do nothing unless it is time to read time-independent domain metadata.
712 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
716 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
717 Status = WRF_WARN_FILE_NOT_OPENED
718 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
719 call wrf_debug ( WARN , msg)
720 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
721 Status = WRF_WARN_DRYRUN_READ
722 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
723 call wrf_debug ( WARN , msg)
724 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
725 Status = WRF_WARN_READ_WONLY_FILE
726 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
727 call wrf_debug ( WARN , msg)
728 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
729 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
730 call netcdf_err(stat,Status)
731 if(Status /= WRF_NO_ERR) then
732 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
733 call wrf_debug ( WARN , msg)
736 if( XType/=PIO_REAL) then
737 Status = WRF_WARN_TYPE_MISMATCH
738 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
739 call wrf_debug ( WARN , msg)
743 Status = WRF_WARN_LENGTH_LESS_THAN_1
744 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
745 call wrf_debug ( WARN , msg)
748 allocate(Buffer(Len), STAT=stat)
750 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
751 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
752 call wrf_debug ( FATAL , msg)
755 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
756 call netcdf_err(stat,Status)
757 if(Status /= WRF_NO_ERR) then
758 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
759 call wrf_debug ( WARN , msg)
762 Data(1:min(Len,Count)) = Buffer(1:min(Len,Count))
763 deallocate(Buffer, STAT=stat)
764 if(stat/= WRF_NO_ERR) then
765 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
766 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
767 call wrf_debug ( FATAL , msg)
772 Status = WRF_WARN_MORE_DATA_IN_FILE
778 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
779 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
780 call wrf_debug ( FATAL , msg)
783 end subroutine ext_pio_get_dom_ti_real_arr
785 subroutine ext_pio_get_dom_ti_real_sca(DataHandle,Element,Data,Count,OutCount,Status)
793 include 'wrf_status_codes.h'
794 integer ,intent(in) :: DataHandle
795 character*(*) ,intent(in) :: Element
796 real, intent(out) :: Data
797 integer, intent(in) :: Count
798 integer, intent(out) :: OutCOunt
799 integer ,intent(out) :: Status
800 type(wrf_data_handle) ,pointer :: DH
804 real, allocatable :: Buffer(:)
806 call GetDH(DataHandle,DH,Status)
807 if(Status /= WRF_NO_ERR) then
808 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
809 call wrf_debug ( WARN , msg)
813 ! Do nothing unless it is time to read time-independent domain metadata.
814 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
818 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
819 Status = WRF_WARN_FILE_NOT_OPENED
820 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
821 call wrf_debug ( WARN , msg)
822 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
823 Status = WRF_WARN_DRYRUN_READ
824 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
825 call wrf_debug ( WARN , msg)
826 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
827 Status = WRF_WARN_READ_WONLY_FILE
828 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
829 call wrf_debug ( WARN , msg)
830 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
831 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
832 call netcdf_err(stat,Status)
833 if(Status /= WRF_NO_ERR) then
834 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
835 call wrf_debug ( WARN , msg)
838 if( XType/=PIO_REAL) then
839 Status = WRF_WARN_TYPE_MISMATCH
840 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
841 call wrf_debug ( WARN , msg)
845 Status = WRF_WARN_LENGTH_LESS_THAN_1
846 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
847 call wrf_debug ( WARN , msg)
850 allocate(Buffer(Len), STAT=stat)
852 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
853 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
854 call wrf_debug ( FATAL , msg)
857 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
858 call netcdf_err(stat,Status)
859 if(Status /= WRF_NO_ERR) then
860 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
861 call wrf_debug ( WARN , msg)
865 deallocate(Buffer, STAT=stat)
866 if(stat/= WRF_NO_ERR) then
867 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
868 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
869 call wrf_debug ( FATAL , msg)
874 Status = WRF_WARN_MORE_DATA_IN_FILE
880 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
881 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
882 call wrf_debug ( FATAL , msg)
885 end subroutine ext_pio_get_dom_ti_real_sca
887 subroutine ext_pio_get_dom_ti_integer_arr(DataHandle,Element,Data,Count,OutCount,Status)
895 include 'wrf_status_codes.h'
896 integer ,intent(in) :: DataHandle
897 character*(*) ,intent(in) :: Element
898 integer, intent(out) :: Data(:)
899 integer, intent(in) :: Count
900 integer, intent(out) :: OutCOunt
901 integer ,intent(out) :: Status
902 type(wrf_data_handle) ,pointer :: DH
906 integer, allocatable :: Buffer(:)
908 call GetDH(DataHandle,DH,Status)
909 if(Status /= WRF_NO_ERR) then
910 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
911 call wrf_debug ( WARN , msg)
915 ! Do nothing unless it is time to read time-independent domain metadata.
916 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
920 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
921 Status = WRF_WARN_FILE_NOT_OPENED
922 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
923 call wrf_debug ( WARN , msg)
924 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
925 Status = WRF_WARN_DRYRUN_READ
926 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
927 call wrf_debug ( WARN , msg)
928 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
929 Status = WRF_WARN_READ_WONLY_FILE
930 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
931 call wrf_debug ( WARN , msg)
932 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
933 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
934 call netcdf_err(stat,Status)
935 if(Status /= WRF_NO_ERR) then
936 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
937 call wrf_debug ( WARN , msg)
940 if( XType/=PIO_INT) then
941 Status = WRF_WARN_TYPE_MISMATCH
942 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
943 call wrf_debug ( WARN , msg)
947 Status = WRF_WARN_LENGTH_LESS_THAN_1
948 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
949 call wrf_debug ( WARN , msg)
952 allocate(Buffer(Len), STAT=stat)
954 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
955 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
956 call wrf_debug ( FATAL , msg)
959 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
960 call netcdf_err(stat,Status)
961 if(Status /= WRF_NO_ERR) then
962 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
963 call wrf_debug ( WARN , msg)
966 Data(1:min(Len,Count)) = Buffer(1:min(Len,Count))
967 deallocate(Buffer, STAT=stat)
968 if(stat/= WRF_NO_ERR) then
969 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
970 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
971 call wrf_debug ( FATAL , msg)
976 Status = WRF_WARN_MORE_DATA_IN_FILE
982 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
983 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
984 call wrf_debug ( FATAL , msg)
987 end subroutine ext_pio_get_dom_ti_integer_arr
989 subroutine ext_pio_get_dom_ti_integer_sca(DataHandle,Element,Data,Count,OutCount,Status)
997 include 'wrf_status_codes.h'
998 integer ,intent(in) :: DataHandle
999 character*(*) ,intent(in) :: Element
1000 integer, intent(out) :: Data
1001 integer, intent(in) :: Count
1002 integer, intent(out) :: OutCOunt
1003 integer ,intent(out) :: Status
1004 type(wrf_data_handle) ,pointer :: DH
1008 integer, allocatable :: Buffer(:)
1010 call GetDH(DataHandle,DH,Status)
1011 if(Status /= WRF_NO_ERR) then
1012 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1013 call wrf_debug ( WARN , msg)
1017 ! Do nothing unless it is time to read time-independent domain metadata.
1018 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1022 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1023 Status = WRF_WARN_FILE_NOT_OPENED
1024 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1025 call wrf_debug ( WARN , msg)
1026 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1027 Status = WRF_WARN_DRYRUN_READ
1028 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
1029 call wrf_debug ( WARN , msg)
1030 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1031 Status = WRF_WARN_READ_WONLY_FILE
1032 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
1033 call wrf_debug ( WARN , msg)
1034 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1035 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1036 call netcdf_err(stat,Status)
1037 if(Status /= WRF_NO_ERR) then
1038 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
1039 call wrf_debug ( WARN , msg)
1042 if( XType/=PIO_INT) then
1043 Status = WRF_WARN_TYPE_MISMATCH
1044 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1045 call wrf_debug ( WARN , msg)
1049 Status = WRF_WARN_LENGTH_LESS_THAN_1
1050 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1051 call wrf_debug ( WARN , msg)
1054 allocate(Buffer(Len), STAT=stat)
1056 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
1057 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
1058 call wrf_debug ( FATAL , msg)
1061 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
1062 call netcdf_err(stat,Status)
1063 if(Status /= WRF_NO_ERR) then
1064 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1065 call wrf_debug ( WARN , msg)
1069 deallocate(Buffer, STAT=stat)
1070 if(stat/= WRF_NO_ERR) then
1071 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
1072 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
1073 call wrf_debug ( FATAL , msg)
1076 if(Len > Count) then
1078 Status = WRF_WARN_MORE_DATA_IN_FILE
1084 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1085 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1086 call wrf_debug ( FATAL , msg)
1089 end subroutine ext_pio_get_dom_ti_integer_sca
1091 subroutine ext_pio_get_dom_ti_double_arr(DataHandle,Element,Data,Count,OutCount,Status)
1099 include 'wrf_status_codes.h'
1100 integer ,intent(in) :: DataHandle
1101 character*(*) ,intent(in) :: Element
1102 real*8, intent(out) :: Data(:)
1103 integer, intent(in) :: Count
1104 integer, intent(out) :: OutCOunt
1105 integer ,intent(out) :: Status
1106 type(wrf_data_handle) ,pointer :: DH
1110 real*8, allocatable :: Buffer(:)
1112 call GetDH(DataHandle,DH,Status)
1113 if(Status /= WRF_NO_ERR) then
1114 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1115 call wrf_debug ( WARN , msg)
1119 ! Do nothing unless it is time to read time-independent domain metadata.
1120 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1124 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1125 Status = WRF_WARN_FILE_NOT_OPENED
1126 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1127 call wrf_debug ( WARN , msg)
1128 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1129 Status = WRF_WARN_DRYRUN_READ
1130 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
1131 call wrf_debug ( WARN , msg)
1132 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1133 Status = WRF_WARN_READ_WONLY_FILE
1134 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
1135 call wrf_debug ( WARN , msg)
1136 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1137 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1138 call netcdf_err(stat,Status)
1139 if(Status /= WRF_NO_ERR) then
1140 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
1141 call wrf_debug ( WARN , msg)
1144 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
1145 Status = WRF_WARN_TYPE_MISMATCH
1146 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1147 call wrf_debug ( WARN , msg)
1151 Status = WRF_WARN_LENGTH_LESS_THAN_1
1152 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1153 call wrf_debug ( WARN , msg)
1156 allocate(Buffer(Len), STAT=stat)
1158 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
1159 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
1160 call wrf_debug ( FATAL , msg)
1163 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
1164 call netcdf_err(stat,Status)
1165 if(Status /= WRF_NO_ERR) then
1166 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1167 call wrf_debug ( WARN , msg)
1170 Data(1:min(Len,Count)) = Buffer(1:min(Len,Count))
1171 deallocate(Buffer, STAT=stat)
1172 if(stat/= WRF_NO_ERR) then
1173 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
1174 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
1175 call wrf_debug ( FATAL , msg)
1178 if(Len > Count) then
1180 Status = WRF_WARN_MORE_DATA_IN_FILE
1186 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1187 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1188 call wrf_debug ( FATAL , msg)
1191 end subroutine ext_pio_get_dom_ti_double_arr
1193 subroutine ext_pio_get_dom_ti_double_sca(DataHandle,Element,Data,Count,OutCount,Status)
1201 include 'wrf_status_codes.h'
1202 integer ,intent(in) :: DataHandle
1203 character*(*) ,intent(in) :: Element
1204 real*8, intent(out) :: Data
1205 integer, intent(in) :: Count
1206 integer, intent(out) :: OutCOunt
1207 integer ,intent(out) :: Status
1208 type(wrf_data_handle) ,pointer :: DH
1212 real*8, allocatable :: Buffer(:)
1214 call GetDH(DataHandle,DH,Status)
1215 if(Status /= WRF_NO_ERR) then
1216 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1217 call wrf_debug ( WARN , msg)
1221 ! Do nothing unless it is time to read time-independent domain metadata.
1222 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1226 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1227 Status = WRF_WARN_FILE_NOT_OPENED
1228 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1229 call wrf_debug ( WARN , msg)
1230 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1231 Status = WRF_WARN_DRYRUN_READ
1232 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
1233 call wrf_debug ( WARN , msg)
1234 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1235 Status = WRF_WARN_READ_WONLY_FILE
1236 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
1237 call wrf_debug ( WARN , msg)
1238 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1239 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1240 call netcdf_err(stat,Status)
1241 if(Status /= WRF_NO_ERR) then
1242 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',trim(Element)
1243 call wrf_debug ( WARN , msg)
1246 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
1247 Status = WRF_WARN_TYPE_MISMATCH
1248 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1249 call wrf_debug ( WARN , msg)
1253 Status = WRF_WARN_LENGTH_LESS_THAN_1
1254 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,', line', __LINE__,' Element ', trim(Element)
1255 call wrf_debug ( WARN , msg)
1258 allocate(Buffer(Len), STAT=stat)
1260 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
1261 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
1262 call wrf_debug ( FATAL , msg)
1265 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
1266 call netcdf_err(stat,Status)
1267 if(Status /= WRF_NO_ERR) then
1268 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1269 call wrf_debug ( WARN , msg)
1273 deallocate(Buffer, STAT=stat)
1274 if(stat/= WRF_NO_ERR) then
1275 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
1276 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
1277 call wrf_debug ( FATAL , msg)
1280 if(Len > Count) then
1282 Status = WRF_WARN_MORE_DATA_IN_FILE
1288 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1289 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1290 call wrf_debug ( FATAL , msg)
1293 end subroutine ext_pio_get_dom_ti_double_sca
1295 subroutine ext_pio_get_dom_ti_logical_arr(DataHandle,Element,Data,Count,OutCount,Status)
1303 include 'wrf_status_codes.h'
1304 integer ,intent(in) :: DataHandle
1305 character*(*) ,intent(in) :: Element
1306 logical, intent(out) :: Data(:)
1307 integer, intent(in) :: Count
1308 integer, intent(out) :: OutCOunt
1309 integer ,intent(out) :: Status
1310 type(wrf_data_handle) ,pointer :: DH
1314 integer, allocatable :: Buffer(:)
1316 call GetDH(DataHandle,DH,Status)
1317 if(Status /= WRF_NO_ERR) then
1318 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
1319 call wrf_debug ( WARN , msg)
1323 ! Do nothing unless it is time to read time-independent domain metadata.
1324 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1328 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1329 Status = WRF_WARN_FILE_NOT_OPENED
1330 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
1331 call wrf_debug ( WARN , msg)
1332 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1333 Status = WRF_WARN_DRYRUN_READ
1334 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
1335 call wrf_debug ( WARN , msg)
1336 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1337 Status = WRF_WARN_READ_WONLY_FILE
1338 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
1339 call wrf_debug ( WARN , msg)
1340 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1341 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1342 call netcdf_err(stat,Status)
1343 if(Status /= WRF_NO_ERR) then
1344 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',trim(Element)
1345 call wrf_debug ( WARN , msg)
1348 if ( PIO_INT == PIO_DOUBLE .OR. PIO_INT == PIO_REAL ) then
1349 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
1350 Status = WRF_WARN_TYPE_MISMATCH
1351 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1352 call wrf_debug ( WARN , msg)
1356 if( XType/=PIO_INT) then
1357 Status = WRF_WARN_TYPE_MISMATCH
1358 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1359 call wrf_debug ( WARN , msg)
1364 Status = WRF_WARN_LENGTH_LESS_THAN_1
1365 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1366 call wrf_debug ( WARN , msg)
1369 allocate(Buffer(Len), STAT=stat)
1371 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
1372 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
1373 call wrf_debug ( FATAL , msg)
1376 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
1377 call netcdf_err(stat,Status)
1378 if(Status /= WRF_NO_ERR) then
1379 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
1380 call wrf_debug ( WARN , msg)
1383 Data(1:min(Len,Count)) = Buffer(1:min(Len,Count))==1
1384 deallocate(Buffer, STAT=stat)
1385 if(stat/= WRF_NO_ERR) then
1386 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
1387 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
1388 call wrf_debug ( FATAL , msg)
1391 if(Len > Count) then
1393 Status = WRF_WARN_MORE_DATA_IN_FILE
1399 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1400 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
1401 call wrf_debug ( FATAL , msg)
1404 end subroutine ext_pio_get_dom_ti_logical_arr
1406 subroutine ext_pio_get_dom_ti_logical_sca(DataHandle,Element,Data,Count,OutCount,Status)
1414 include 'wrf_status_codes.h'
1415 integer ,intent(in) :: DataHandle
1416 character*(*) ,intent(in) :: Element
1417 logical, intent(out) :: Data
1418 integer, intent(in) :: Count
1419 integer, intent(out) :: OutCOunt
1420 integer ,intent(out) :: Status
1421 type(wrf_data_handle) ,pointer :: DH
1425 integer, allocatable :: Buffer(:)
1427 call GetDH(DataHandle,DH,Status)
1428 if(Status /= WRF_NO_ERR) then
1429 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
1430 call wrf_debug ( WARN , msg)
1434 ! Do nothing unless it is time to read time-independent domain metadata.
1435 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1439 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1440 Status = WRF_WARN_FILE_NOT_OPENED
1441 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
1442 call wrf_debug ( WARN , msg)
1443 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1444 Status = WRF_WARN_DRYRUN_READ
1445 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
1446 call wrf_debug ( WARN , msg)
1447 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1448 Status = WRF_WARN_READ_WONLY_FILE
1449 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
1450 call wrf_debug ( WARN , msg)
1451 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1452 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1453 call netcdf_err(stat,Status)
1454 if(Status /= WRF_NO_ERR) then
1455 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',trim(Element)
1456 call wrf_debug ( WARN , msg)
1459 if ( PIO_INT == PIO_DOUBLE .OR. PIO_INT == PIO_REAL ) then
1460 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
1461 Status = WRF_WARN_TYPE_MISMATCH
1462 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1463 call wrf_debug ( WARN , msg)
1467 if( XType/=PIO_INT) then
1468 Status = WRF_WARN_TYPE_MISMATCH
1469 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1470 call wrf_debug ( WARN , msg)
1475 Status = WRF_WARN_LENGTH_LESS_THAN_1
1476 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ', trim(Element)
1477 call wrf_debug ( WARN , msg)
1480 allocate(Buffer(Len), STAT=stat)
1482 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
1483 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
1484 call wrf_debug ( FATAL , msg)
1487 stat = pio_get_att (DH%file_handle,PIO_GLOBAL,Element,Buffer)
1488 call netcdf_err(stat,Status)
1489 if(Status /= WRF_NO_ERR) then
1490 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
1491 call wrf_debug ( WARN , msg)
1495 deallocate(Buffer, STAT=stat)
1496 if(stat/= WRF_NO_ERR) then
1497 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
1498 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
1499 call wrf_debug ( FATAL , msg)
1502 if(Len > Count) then
1504 Status = WRF_WARN_MORE_DATA_IN_FILE
1510 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1511 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
1512 call wrf_debug ( FATAL , msg)
1515 end subroutine ext_pio_get_dom_ti_logical_sca
1517 subroutine ext_pio_get_dom_ti_char_arr(DataHandle,Element,Data,Status)
1525 include 'wrf_status_codes.h'
1526 integer ,intent(in) :: DataHandle
1527 character*(*) ,intent(in) :: Element
1528 character*(*), intent(out) :: Data
1531 integer ,intent(out) :: Status
1532 type(wrf_data_handle) ,pointer :: DH
1538 call GetDH(DataHandle,DH,Status)
1539 if(Status /= WRF_NO_ERR) then
1540 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
1541 call wrf_debug ( WARN , msg)
1545 ! Do nothing unless it is time to read time-independent domain metadata.
1546 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1550 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1551 Status = WRF_WARN_FILE_NOT_OPENED
1552 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
1553 call wrf_debug ( WARN , msg)
1554 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1555 Status = WRF_WARN_DRYRUN_READ
1556 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
1557 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1558 Status = WRF_WARN_READ_WONLY_FILE
1559 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
1560 call wrf_debug ( WARN , msg)
1561 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1562 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1563 call netcdf_err(stat,Status)
1564 if(Status /= WRF_NO_ERR) then
1565 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',trim(Element)
1566 call wrf_debug ( WARN , msg)
1570 Status = WRF_WARN_LENGTH_LESS_THAN_1
1571 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ', trim(Element)
1572 call wrf_debug ( WARN , msg)
1576 stat = pio_get_att(DH%file_handle,PIO_GLOBAL,Element,Data)
1577 call netcdf_err(stat,Status)
1578 if(Status /= WRF_NO_ERR) then
1579 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
1580 call wrf_debug ( WARN , msg)
1584 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1585 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
1586 call wrf_debug ( FATAL , msg)
1590 end subroutine ext_pio_get_dom_ti_char_arr
1592 subroutine ext_pio_get_dom_ti_char_sca(DataHandle,Element,Data,Status)
1600 include 'wrf_status_codes.h'
1601 integer ,intent(in) :: DataHandle
1602 character*(*) ,intent(in) :: Element
1603 character*(*), intent(out) :: Data
1606 integer ,intent(out) :: Status
1607 type(wrf_data_handle) ,pointer :: DH
1613 call GetDH(DataHandle,DH,Status)
1614 if(Status /= WRF_NO_ERR) then
1615 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
1616 call wrf_debug ( WARN , msg)
1620 ! Do nothing unless it is time to read time-independent domain metadata.
1621 IF(.not. ncd_ok_to_get_dom_ti( DataHandle ) ) THEN
1625 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1626 Status = WRF_WARN_FILE_NOT_OPENED
1627 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
1628 call wrf_debug ( WARN , msg)
1629 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1630 Status = WRF_WARN_DRYRUN_READ
1631 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
1632 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1633 Status = WRF_WARN_READ_WONLY_FILE
1634 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
1635 call wrf_debug ( WARN , msg)
1636 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1637 stat = pio_inq_att(DH%file_handle, PIO_GLOBAL, Element, XType, Len)
1638 call netcdf_err(stat,Status)
1639 if(Status /= WRF_NO_ERR) then
1640 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',trim(Element)
1641 call wrf_debug ( WARN , msg)
1645 Status = WRF_WARN_LENGTH_LESS_THAN_1
1646 write(msg,*) 'Warning LENGTH < 1 in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ', trim(Element)
1647 call wrf_debug ( WARN , msg)
1651 stat = pio_get_att(DH%file_handle,PIO_GLOBAL,Element,Data)
1652 call netcdf_err(stat,Status)
1653 if(Status /= WRF_NO_ERR) then
1654 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
1655 call wrf_debug ( WARN , msg)
1659 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1660 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
1661 call wrf_debug ( FATAL , msg)
1665 end subroutine ext_pio_get_dom_ti_char_sca
1667 subroutine ext_pio_put_dom_ti_real_arr(DataHandle,Element,Data,Count,Status)
1673 include 'wrf_status_codes.h'
1674 integer ,intent(in) :: DataHandle
1675 character*(*) ,intent(in) :: Element
1676 real, intent(in) :: Data(*)
1677 integer, intent(in) :: Count
1678 integer ,intent(out) :: Status
1679 type(wrf_data_handle) ,pointer :: DH
1682 real, dimension(1:Count) :: tmparr
1684 tmparr(1:Count) = Data(1:Count)
1686 call GetDH(DataHandle,DH,Status)
1687 if(Status /= WRF_NO_ERR) then
1688 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1689 call wrf_debug ( WARN , msg)
1693 ! Do nothing unless it is time to write time-independent domain metadata.
1694 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
1698 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1699 Status = WRF_WARN_FILE_NOT_OPENED
1700 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1701 call wrf_debug ( WARN , msg)
1702 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1703 STATUS = WRF_WARN_WRITE_RONLY_FILE
1704 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
1705 call wrf_debug ( WARN , msg)
1706 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1707 !stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr)
1709 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr(1))
1711 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr(1:Count))
1713 call netcdf_err(stat,Status)
1714 if(Status /= WRF_NO_ERR) then
1715 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1716 call wrf_debug ( WARN , msg)
1719 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1721 stat = pio_redef(DH%file_handle)
1722 call netcdf_err(stat,Status)
1723 if(Status /= WRF_NO_ERR) then
1724 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1725 call wrf_debug ( WARN , msg)
1730 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr(1))
1732 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr(1:Count))
1734 call netcdf_err(stat,Status)
1735 if(Status /= WRF_NO_ERR) then
1736 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1737 call wrf_debug ( WARN , msg)
1741 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1742 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1743 call wrf_debug ( FATAL , msg)
1746 end subroutine ext_pio_put_dom_ti_real_arr
1748 subroutine ext_pio_put_dom_ti_real_sca(DataHandle,Element,Data,Count,Status)
1754 include 'wrf_status_codes.h'
1755 integer ,intent(in) :: DataHandle
1756 character*(*) ,intent(in) :: Element
1757 real, intent(in) :: Data
1758 integer, intent(in) :: Count
1759 integer ,intent(out) :: Status
1760 type(wrf_data_handle) ,pointer :: DH
1764 call GetDH(DataHandle,DH,Status)
1765 if(Status /= WRF_NO_ERR) then
1766 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1767 call wrf_debug ( WARN , msg)
1771 ! Do nothing unless it is time to write time-independent domain metadata.
1772 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
1776 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1777 Status = WRF_WARN_FILE_NOT_OPENED
1778 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1779 call wrf_debug ( WARN , msg)
1780 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1781 STATUS = WRF_WARN_WRITE_RONLY_FILE
1782 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
1783 call wrf_debug ( WARN , msg)
1784 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1785 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
1786 call netcdf_err(stat,Status)
1787 if(Status /= WRF_NO_ERR) then
1788 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1789 call wrf_debug ( WARN , msg)
1792 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1794 stat = pio_redef(DH%file_handle)
1795 call netcdf_err(stat,Status)
1796 if(Status /= WRF_NO_ERR) then
1797 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1798 call wrf_debug ( WARN , msg)
1801 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
1802 call netcdf_err(stat,Status)
1803 if(Status /= WRF_NO_ERR) then
1804 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1805 call wrf_debug ( WARN , msg)
1809 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1810 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1811 call wrf_debug ( FATAL , msg)
1814 end subroutine ext_pio_put_dom_ti_real_sca
1816 subroutine ext_pio_put_dom_ti_integer_arr(DataHandle,Element,Data,Count,Status)
1823 include 'wrf_status_codes.h'
1824 integer ,intent(in) :: DataHandle
1825 character*(*) ,intent(in) :: Element
1826 integer, intent(in) :: Data(*)
1827 integer, intent(in) :: Count
1828 integer ,intent(out) :: Status
1829 type(wrf_data_handle) ,pointer :: DH
1832 integer, dimension(Count) :: tmparr
1834 call GetDH(DataHandle,DH,Status)
1835 if(Status /= WRF_NO_ERR) then
1836 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1837 call wrf_debug ( WARN , msg)
1841 tmparr(1:Count) = Data(1:Count)
1843 !-Do nothing unless it is time to write time-independent domain metadata.
1844 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
1848 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1849 Status = WRF_WARN_FILE_NOT_OPENED
1850 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1851 call wrf_debug ( WARN , msg)
1852 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1853 STATUS = WRF_WARN_WRITE_RONLY_FILE
1854 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
1855 call wrf_debug ( WARN , msg)
1856 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1857 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,tmparr)
1858 call netcdf_err(stat,Status)
1859 if(Status /= WRF_NO_ERR) then
1860 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1861 call wrf_debug ( WARN , msg)
1864 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1866 stat = pio_redef(DH%file_handle)
1867 call netcdf_err(stat,Status)
1868 if(Status /= WRF_NO_ERR) then
1869 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1870 call wrf_debug ( WARN , msg)
1873 tmparr(1:Count) = Data(1:Count)
1875 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,tmparr(1))
1877 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,tmparr(1:Count))
1879 call netcdf_err(stat,Status)
1880 if(Status /= WRF_NO_ERR) then
1881 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1882 call wrf_debug ( WARN , msg)
1886 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1887 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1888 call wrf_debug ( FATAL , msg)
1891 end subroutine ext_pio_put_dom_ti_integer_arr
1893 subroutine ext_pio_put_dom_ti_integer_sca(DataHandle,Element,Data,Count,Status)
1900 include 'wrf_status_codes.h'
1901 integer ,intent(in) :: DataHandle
1902 character*(*) ,intent(in) :: Element
1903 integer, intent(in) :: Data
1904 integer, intent(in) :: Count
1905 integer ,intent(out) :: Status
1906 type(wrf_data_handle) ,pointer :: DH
1910 call GetDH(DataHandle,DH,Status)
1911 if(Status /= WRF_NO_ERR) then
1912 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1913 call wrf_debug ( WARN , msg)
1917 ! Do nothing unless it is time to write time-independent domain metadata.
1918 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
1922 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
1923 Status = WRF_WARN_FILE_NOT_OPENED
1924 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
1925 call wrf_debug ( WARN , msg)
1926 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
1927 STATUS = WRF_WARN_WRITE_RONLY_FILE
1928 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
1929 call wrf_debug ( WARN , msg)
1930 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
1931 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,Data)
1932 call netcdf_err(stat,Status)
1933 if(Status /= WRF_NO_ERR) then
1934 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1935 call wrf_debug ( WARN , msg)
1938 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
1941 stat = pio_redef(DH%file_handle)
1942 call netcdf_err(stat,Status)
1943 if(Status /= WRF_NO_ERR) then
1944 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1945 call wrf_debug ( WARN , msg)
1949 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,Data)
1950 call netcdf_err(stat,Status)
1951 if(Status /= WRF_NO_ERR) then
1952 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
1953 call wrf_debug ( WARN , msg)
1957 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
1958 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
1959 call wrf_debug ( FATAL , msg)
1962 end subroutine ext_pio_put_dom_ti_integer_sca
1964 subroutine ext_pio_put_dom_ti_double_arr(DataHandle,Element,Data,Count,Status)
1970 include 'wrf_status_codes.h'
1971 integer ,intent(in) :: DataHandle
1972 character*(*) ,intent(in) :: Element
1973 real*8, intent(in) :: Data(:)
1974 integer, intent(in) :: Count
1975 integer ,intent(out) :: Status
1976 type(wrf_data_handle) ,pointer :: DH
1979 real*8, dimension(1:Count) :: tmparr
1981 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1982 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1983 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
1986 tmparr(1:Count) = Data(1:Count)
1988 call GetDH(DataHandle,DH,Status)
1989 if(Status /= WRF_NO_ERR) then
1990 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
1991 call wrf_debug ( WARN , msg)
1995 ! Do nothing unless it is time to write time-independent domain metadata.
1996 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2000 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2001 Status = WRF_WARN_FILE_NOT_OPENED
2002 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2003 call wrf_debug ( WARN , msg)
2004 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2005 STATUS = WRF_WARN_WRITE_RONLY_FILE
2006 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2007 call wrf_debug ( WARN , msg)
2008 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2009 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,tmparr(1:Count))
2010 call netcdf_err(stat,Status)
2011 if(Status /= WRF_NO_ERR) then
2012 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2013 call wrf_debug ( WARN , msg)
2016 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2019 stat = pio_redef(DH%file_handle)
2020 call netcdf_err(stat,Status)
2021 if(Status /= WRF_NO_ERR) then
2022 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2023 call wrf_debug ( WARN , msg)
2028 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,tmparr(1:Count))
2029 call netcdf_err(stat,Status)
2030 if(Status /= WRF_NO_ERR) then
2031 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2032 call wrf_debug ( WARN , msg)
2036 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2037 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2038 call wrf_debug ( FATAL , msg)
2042 end subroutine ext_pio_put_dom_ti_double_arr
2044 subroutine ext_pio_put_dom_ti_double_sca(DataHandle,Element,Data,Count,Status)
2050 include 'wrf_status_codes.h'
2051 integer ,intent(in) :: DataHandle
2052 character*(*) ,intent(in) :: Element
2053 real*8, intent(in) :: Data
2054 integer, intent(in) :: Count
2055 integer ,intent(out) :: Status
2056 type(wrf_data_handle) ,pointer :: DH
2060 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2061 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2062 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2065 call GetDH(DataHandle,DH,Status)
2066 if(Status /= WRF_NO_ERR) then
2067 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2068 call wrf_debug ( WARN , msg)
2072 ! Do nothing unless it is time to write time-independent domain metadata.
2073 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2077 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2078 Status = WRF_WARN_FILE_NOT_OPENED
2079 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2080 call wrf_debug ( WARN , msg)
2081 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2082 STATUS = WRF_WARN_WRITE_RONLY_FILE
2083 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2084 call wrf_debug ( WARN , msg)
2085 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2086 stat = pio_put_att (DH%file_handle,PIO_GLOBAL,Element,Data)
2087 call netcdf_err(stat,Status)
2088 if(Status /= WRF_NO_ERR) then
2089 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2090 call wrf_debug ( WARN , msg)
2093 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2096 stat = pio_redef(DH%file_handle)
2097 call netcdf_err(stat,Status)
2098 if(Status /= WRF_NO_ERR) then
2099 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2100 call wrf_debug ( WARN , msg)
2105 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
2106 call netcdf_err(stat,Status)
2107 if(Status /= WRF_NO_ERR) then
2108 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2109 call wrf_debug ( WARN , msg)
2113 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2114 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2115 call wrf_debug ( FATAL , msg)
2119 end subroutine ext_pio_put_dom_ti_double_sca
2121 subroutine ext_pio_put_dom_ti_logical_arr(DataHandle,Element,Data,Count,Status)
2128 include 'wrf_status_codes.h'
2129 integer ,intent(in) :: DataHandle
2130 character*(*) ,intent(in) :: Element
2131 logical, intent(in) :: Data(:)
2132 integer, intent(in) :: Count
2133 integer ,intent(out) :: Status
2134 type(wrf_data_handle) ,pointer :: DH
2136 integer ,allocatable :: Buffer(:)
2139 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2140 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2141 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2144 call GetDH(DataHandle,DH,Status)
2145 if(Status /= WRF_NO_ERR) then
2146 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
2147 call wrf_debug ( WARN , msg)
2151 ! Do nothing unless it is time to write time-independent domain metadata.
2152 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2156 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2157 Status = WRF_WARN_FILE_NOT_OPENED
2158 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
2159 call wrf_debug ( WARN , msg)
2160 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2161 STATUS = WRF_WARN_WRITE_RONLY_FILE
2162 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
2163 call wrf_debug ( WARN , msg)
2164 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2165 allocate(Buffer(Count), STAT=stat)
2167 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
2168 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2169 call wrf_debug ( FATAL , msg)
2179 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Buffer)
2180 deallocate(Buffer, STAT=stat)
2182 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
2183 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2184 call wrf_debug ( FATAL , msg)
2187 call netcdf_err(stat,Status)
2188 if(Status /= WRF_NO_ERR) then
2189 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
2190 call wrf_debug ( WARN , msg)
2193 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2196 stat = pio_redef(DH%file_handle)
2197 call netcdf_err(stat,Status)
2198 if(Status /= WRF_NO_ERR) then
2199 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2200 call wrf_debug ( WARN , msg)
2205 allocate(Buffer(Count), STAT=stat)
2207 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
2208 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2209 call wrf_debug ( FATAL , msg)
2219 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Buffer)
2220 deallocate(Buffer, STAT=stat)
2222 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
2223 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2224 call wrf_debug ( FATAL , msg)
2227 call netcdf_err(stat,Status)
2228 if(Status /= WRF_NO_ERR) then
2229 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
2230 call wrf_debug ( WARN , msg)
2234 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2235 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
2236 call wrf_debug ( FATAL , msg)
2240 end subroutine ext_pio_put_dom_ti_logical_arr
2242 subroutine ext_pio_put_dom_ti_logical_sca(DataHandle,Element,Data,Count,Status)
2249 include 'wrf_status_codes.h'
2250 integer ,intent(in) :: DataHandle
2251 character*(*) ,intent(in) :: Element
2252 logical, intent(in) :: Data
2253 integer, intent(in) :: Count
2254 integer ,intent(out) :: Status
2255 type(wrf_data_handle) ,pointer :: DH
2257 integer ,allocatable :: Buffer(:)
2260 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2261 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2262 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2265 call GetDH(DataHandle,DH,Status)
2266 if(Status /= WRF_NO_ERR) then
2267 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
2268 call wrf_debug ( WARN , msg)
2272 ! Do nothing unless it is time to write time-independent domain metadata.
2273 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2277 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2278 Status = WRF_WARN_FILE_NOT_OPENED
2279 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
2280 call wrf_debug ( WARN , msg)
2281 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2282 STATUS = WRF_WARN_WRITE_RONLY_FILE
2283 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
2284 call wrf_debug ( WARN , msg)
2285 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2286 allocate(Buffer(Count), STAT=stat)
2288 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
2289 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2290 call wrf_debug ( FATAL , msg)
2298 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Buffer)
2299 deallocate(Buffer, STAT=stat)
2301 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
2302 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2303 call wrf_debug ( FATAL , msg)
2306 call netcdf_err(stat,Status)
2307 if(Status /= WRF_NO_ERR) then
2308 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
2309 call wrf_debug ( WARN , msg)
2312 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2315 stat = pio_redef(DH%file_handle)
2316 call netcdf_err(stat,Status)
2317 if(Status /= WRF_NO_ERR) then
2318 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2319 call wrf_debug ( WARN , msg)
2323 allocate(Buffer(Count), STAT=stat)
2325 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
2326 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2327 call wrf_debug ( FATAL , msg)
2335 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Buffer)
2336 deallocate(Buffer, STAT=stat)
2338 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
2339 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
2340 call wrf_debug ( FATAL , msg)
2343 call netcdf_err(stat,Status)
2344 if(Status /= WRF_NO_ERR) then
2345 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
2346 call wrf_debug ( WARN , msg)
2350 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2351 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
2352 call wrf_debug ( FATAL , msg)
2356 end subroutine ext_pio_put_dom_ti_logical_sca
2358 subroutine ext_pio_put_dom_ti_char_arr(DataHandle,Element,Data,Status)
2365 include 'wrf_status_codes.h'
2366 integer ,intent(in) :: DataHandle
2367 character*(*) ,intent(in) :: Element
2368 character*(*), intent(in) :: Data
2369 integer, parameter :: Count=1
2370 integer ,intent(out) :: Status
2371 type(wrf_data_handle) ,pointer :: DH
2375 call GetDH(DataHandle,DH,Status)
2376 if(Status /= WRF_NO_ERR) then
2377 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
2378 call wrf_debug ( WARN , msg)
2382 ! Do nothing unless it is time to write time-independent domain metadata.
2383 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2387 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2388 Status = WRF_WARN_FILE_NOT_OPENED
2389 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
2390 call wrf_debug ( WARN , msg)
2391 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2392 STATUS = WRF_WARN_WRITE_RONLY_FILE
2393 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
2394 call wrf_debug ( WARN , msg)
2395 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2396 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
2397 call netcdf_err(stat,Status)
2398 if(Status /= WRF_NO_ERR) then
2399 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
2400 call wrf_debug ( WARN , msg)
2403 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2406 stat = pio_redef(DH%file_handle)
2407 call netcdf_err(stat,Status)
2408 if(Status /= WRF_NO_ERR) then
2409 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2410 call wrf_debug ( WARN , msg)
2414 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
2415 call netcdf_err(stat,Status)
2416 if(Status /= WRF_NO_ERR) then
2417 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
2418 call wrf_debug ( WARN , msg)
2422 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2423 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
2424 call wrf_debug ( FATAL , msg)
2427 end subroutine ext_pio_put_dom_ti_char_arr
2429 subroutine ext_pio_put_dom_ti_char_sca(DataHandle,Element,Data,Status)
2436 include 'wrf_status_codes.h'
2437 integer ,intent(in) :: DataHandle
2438 character*(*) ,intent(in) :: Element
2439 character*(*), intent(in) :: Data
2440 integer, parameter :: Count=1
2441 integer ,intent(out) :: Status
2442 type(wrf_data_handle) ,pointer :: DH
2446 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2447 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2448 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2451 call GetDH(DataHandle,DH,Status)
2452 if(Status /= WRF_NO_ERR) then
2453 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
2454 call wrf_debug ( WARN , msg)
2458 ! Do nothing unless it is time to write time-independent domain metadata.
2459 IF(.not. ncd_ok_to_put_dom_ti( DataHandle ) ) THEN
2463 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2464 Status = WRF_WARN_FILE_NOT_OPENED
2465 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
2466 call wrf_debug ( WARN , msg)
2467 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2468 STATUS = WRF_WARN_WRITE_RONLY_FILE
2469 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
2470 call wrf_debug ( WARN , msg)
2471 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2472 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
2473 call netcdf_err(stat,Status)
2474 if(Status /= WRF_NO_ERR) then
2475 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
2476 call wrf_debug ( WARN , msg)
2479 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2482 stat = pio_redef(DH%file_handle)
2483 call netcdf_err(stat,Status)
2484 if(Status /= WRF_NO_ERR) then
2485 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2486 call wrf_debug ( WARN , msg)
2490 stat = pio_put_att(DH%file_handle,PIO_GLOBAL,Element,Data)
2491 call netcdf_err(stat,Status)
2492 if(Status /= WRF_NO_ERR) then
2493 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
2494 call wrf_debug ( WARN , msg)
2498 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2499 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
2500 call wrf_debug ( FATAL , msg)
2504 end subroutine ext_pio_put_dom_ti_char_sca
2506 subroutine ext_pio_put_var_ti_real_arr(DataHandle,Element,Var,Data,Count,Status)
2513 include 'wrf_status_codes.h'
2514 integer ,intent(in) :: DataHandle
2515 character*(*) ,intent(in) :: Element
2516 character*(*) ,intent(in) :: Var
2517 real, intent(in) :: Data(:)
2518 integer, intent(in) :: Count
2519 integer ,intent(out) :: Status
2520 type(wrf_data_handle) ,pointer :: DH
2521 character (VarNameLen) :: VarName
2527 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2528 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2529 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2534 call GetDH(DataHandle,DH,Status)
2535 if(Status /= WRF_NO_ERR) then
2536 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2537 call wrf_debug ( WARN , msg)
2540 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2541 Status = WRF_WARN_FILE_NOT_OPENED
2542 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2543 call wrf_debug ( WARN , msg)
2544 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2545 Status = WRF_WARN_WRITE_RONLY_FILE
2546 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2547 call wrf_debug ( WARN , msg)
2548 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2549 Status = WRF_WARN_MD_AFTER_OPEN
2550 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
2551 call wrf_debug ( WARN , msg)
2553 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2555 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
2557 elseif(NVar == MaxVars) then
2558 Status = WRF_WARN_VAR_NF
2559 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
2561 call wrf_debug ( WARN , msg)
2565 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Data)
2566 call netcdf_err(stat,Status)
2567 if(Status /= WRF_NO_ERR) then
2568 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
2569 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
2570 call wrf_debug ( WARN , msg)
2573 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2574 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2575 call wrf_debug ( FATAL , msg)
2580 end subroutine ext_pio_put_var_ti_real_arr
2582 subroutine ext_pio_put_var_ti_real_sca(DataHandle,Element,Var,Data,Count,Status)
2589 include 'wrf_status_codes.h'
2590 integer ,intent(in) :: DataHandle
2591 character*(*) ,intent(in) :: Element
2592 character*(*) ,intent(in) :: Var
2593 real, intent(in) :: Data
2594 integer, intent(in) :: Count
2595 integer ,intent(out) :: Status
2596 type(wrf_data_handle) ,pointer :: DH
2597 character (VarNameLen) :: VarName
2603 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2604 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2605 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2610 call GetDH(DataHandle,DH,Status)
2611 if(Status /= WRF_NO_ERR) then
2612 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2613 call wrf_debug ( WARN , msg)
2616 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2617 Status = WRF_WARN_FILE_NOT_OPENED
2618 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2619 call wrf_debug ( WARN , msg)
2620 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2621 Status = WRF_WARN_WRITE_RONLY_FILE
2622 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2623 call wrf_debug ( WARN , msg)
2624 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2625 Status = WRF_WARN_MD_AFTER_OPEN
2626 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
2627 call wrf_debug ( WARN , msg)
2629 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2631 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
2633 elseif(NVar == MaxVars) then
2634 Status = WRF_WARN_VAR_NF
2635 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
2637 call wrf_debug ( WARN , msg)
2641 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Data)
2642 call netcdf_err(stat,Status)
2643 if(Status /= WRF_NO_ERR) then
2644 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
2645 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
2646 call wrf_debug ( WARN , msg)
2649 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2650 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2651 call wrf_debug ( FATAL , msg)
2656 end subroutine ext_pio_put_var_ti_real_sca
2658 subroutine ext_pio_put_var_td_real_arr(DataHandle,Element,DateStr,Var,Data,Count,Status)
2665 include 'wrf_status_codes.h'
2666 integer ,intent(in) :: DataHandle
2667 character*(*) ,intent(in) :: Element
2668 character*(*) ,intent(in) :: DateStr
2669 character*(*) ,intent(in) :: Var
2670 real ,intent(in) :: Data(:)
2671 integer ,intent(in) :: Count
2672 integer ,intent(out) :: Status
2673 type(wrf_data_handle) ,pointer :: DH
2674 character (VarNameLen) :: VarName
2675 character (40+len(Element)) :: Name
2678 integer :: VDims (2)
2679 integer :: VStart(2)
2680 integer :: VCount(2)
2682 integer :: TimeIndex
2684 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2685 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2686 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2690 call DateCheck(DateStr,Status)
2691 if(Status /= WRF_NO_ERR) then
2692 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
2693 call wrf_debug ( WARN , msg)
2696 call GetDH(DataHandle,DH,Status)
2697 if(Status /= WRF_NO_ERR) then
2698 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2699 call wrf_debug ( WARN , msg)
2702 call GetName(Element, VarName, Name, Status)
2703 if(Status /= WRF_NO_ERR) then
2704 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2705 call wrf_debug ( WARN , msg)
2708 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2709 Status = WRF_WARN_FILE_NOT_OPENED
2710 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2711 call wrf_debug ( WARN , msg)
2712 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2713 Status = WRF_WARN_WRITE_RONLY_FILE
2714 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2715 call wrf_debug ( WARN , msg)
2716 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2718 Status = WRF_WARN_ZERO_LENGTH_PUT
2722 if(DH%VarNames(i) == Name) then
2723 Status = WRF_WARN_2DRYRUNS_1VARIABLE
2726 elseif(DH%VarNames(i) == NO_NAME) then
2727 DH%VarNames(i) = Name
2729 elseif(i == MaxVars) then
2730 Status = WRF_WARN_TOO_MANY_VARIABLES
2731 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
2732 call wrf_debug ( WARN , msg)
2737 if(DH%DimLengths(i) == Count) then
2739 elseif(DH%DimLengths(i) == NO_DIM) then
2740 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
2741 call netcdf_err(stat,Status)
2742 if(Status /= WRF_NO_ERR) then
2743 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2744 call wrf_debug ( WARN , msg)
2747 DH%DimLengths(i) = Count
2749 elseif(i == MaxDims) then
2750 Status = WRF_WARN_TOO_MANY_DIMS
2751 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
2752 call wrf_debug ( WARN , msg)
2756 DH%VarDimLens(1, NVar) = Count
2757 VDims(1) = DH%DimIDs(i)
2758 VDims(2) = DH%DimUnlimID
2759 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2760 write(unit=0, fmt='(3a,i6)') '2 Define Var <', trim(Var), '> as NVar:', NVar
2761 stat = pio_def_var(DH%file_handle,Name,PIO_REAL,DH%descVar(NVar))
2762 call netcdf_err(stat,Status)
2763 if(Status /= WRF_NO_ERR) then
2764 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2765 call wrf_debug ( WARN , msg)
2768 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2770 if(DH%VarNames(i) == Name) then
2773 elseif(DH%VarNames(i) == NO_NAME) then
2774 Status = WRF_WARN_MD_NF
2775 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
2776 call wrf_debug ( WARN , msg)
2778 elseif(i == MaxVars) then
2779 Status = WRF_WARN_TOO_MANY_VARIABLES
2780 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
2781 call wrf_debug ( WARN , msg)
2785 if(Count > DH%VarDimLens(1,NVar)) then
2786 Status = WRF_WARN_COUNT_TOO_LONG
2787 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
2788 call wrf_debug ( WARN , msg)
2790 elseif(Count < 1) then
2791 Status = WRF_WARN_ZERO_LENGTH_PUT
2792 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
2793 call wrf_debug ( WARN , msg)
2796 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
2797 if(Status /= WRF_NO_ERR) then
2798 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
2799 call wrf_debug ( WARN , msg)
2803 VStart(2) = TimeIndex
2806 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Data)
2807 call netcdf_err(stat,Status)
2808 if(Status /= WRF_NO_ERR) then
2809 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2810 call wrf_debug ( WARN , msg)
2814 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2815 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2816 call wrf_debug ( FATAL , msg)
2821 end subroutine ext_pio_put_var_td_real_arr
2823 subroutine ext_pio_put_var_td_real_sca(DataHandle,Element,DateStr,Var,Data,Count,Status)
2830 include 'wrf_status_codes.h'
2831 integer ,intent(in) :: DataHandle
2832 character*(*) ,intent(in) :: Element
2833 character*(*) ,intent(in) :: DateStr
2834 character*(*) ,intent(in) :: Var
2835 real ,intent(in) :: Data
2836 integer ,intent(in) :: Count
2837 integer ,intent(out) :: Status
2838 type(wrf_data_handle) ,pointer :: DH
2839 character (VarNameLen) :: VarName
2840 character (40+len(Element)) :: Name
2842 integer :: Buffer(1)
2844 integer :: VDims (2)
2845 integer :: VStart(2)
2846 integer :: VCount(2)
2848 integer :: TimeIndex
2850 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2851 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2852 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2856 call DateCheck(DateStr,Status)
2857 if(Status /= WRF_NO_ERR) then
2858 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
2859 call wrf_debug ( WARN , msg)
2862 call GetDH(DataHandle,DH,Status)
2863 if(Status /= WRF_NO_ERR) then
2864 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2865 call wrf_debug ( WARN , msg)
2868 call GetName(Element, VarName, Name, Status)
2869 if(Status /= WRF_NO_ERR) then
2870 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
2871 call wrf_debug ( WARN , msg)
2874 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
2875 Status = WRF_WARN_FILE_NOT_OPENED
2876 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
2877 call wrf_debug ( WARN , msg)
2878 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
2879 Status = WRF_WARN_WRITE_RONLY_FILE
2880 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
2881 call wrf_debug ( WARN , msg)
2882 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
2884 Status = WRF_WARN_ZERO_LENGTH_PUT
2888 if(DH%VarNames(i) == Name) then
2889 Status = WRF_WARN_2DRYRUNS_1VARIABLE
2892 elseif(DH%VarNames(i) == NO_NAME) then
2893 DH%VarNames(i) = Name
2895 elseif(i == MaxVars) then
2896 Status = WRF_WARN_TOO_MANY_VARIABLES
2897 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
2898 call wrf_debug ( WARN , msg)
2903 if(DH%DimLengths(i) == Count) then
2905 elseif(DH%DimLengths(i) == NO_DIM) then
2906 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
2907 call netcdf_err(stat,Status)
2908 if(Status /= WRF_NO_ERR) then
2909 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2910 call wrf_debug ( WARN , msg)
2913 DH%DimLengths(i) = Count
2915 elseif(i == MaxDims) then
2916 Status = WRF_WARN_TOO_MANY_DIMS
2917 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
2918 call wrf_debug ( WARN , msg)
2922 DH%VarDimLens(1,NVar) = Count
2923 VDims(1) = DH%DimIDs(i)
2924 VDims(2) = DH%DimUnlimID
2925 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
2926 write(unit=0, fmt='(3a,i6)') '3 Define Var <', trim(Var), '> as NVar:', NVar
2927 stat = pio_def_var(DH%file_handle,Name,PIO_REAL,DH%descVar(NVar))
2928 call netcdf_err(stat,Status)
2929 if(Status /= WRF_NO_ERR) then
2930 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2931 call wrf_debug ( WARN , msg)
2934 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
2936 if(DH%VarNames(NVar) == Name) then
2938 elseif(DH%VarNames(NVar) == NO_NAME) then
2939 Status = WRF_WARN_MD_NF
2940 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
2941 call wrf_debug ( WARN , msg)
2943 elseif(NVar == MaxVars) then
2944 Status = WRF_WARN_TOO_MANY_VARIABLES
2945 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
2946 call wrf_debug ( WARN , msg)
2950 if(Count > DH%VarDimLens(1,NVar)) then
2951 Status = WRF_WARN_COUNT_TOO_LONG
2952 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
2953 call wrf_debug ( WARN , msg)
2955 elseif(Count < 1) then
2956 Status = WRF_WARN_ZERO_LENGTH_PUT
2957 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
2958 call wrf_debug ( WARN , msg)
2961 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
2962 if(Status /= WRF_NO_ERR) then
2963 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
2964 call wrf_debug ( WARN , msg)
2968 VStart(2) = TimeIndex
2972 !stat = pio_put_var(DH%file_handle,DH%descMDVar(NVar),VStart,VCount,Buffer)
2973 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Buffer)
2974 call netcdf_err(stat,Status)
2975 if(Status /= WRF_NO_ERR) then
2976 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
2977 call wrf_debug ( WARN , msg)
2981 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
2982 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
2983 call wrf_debug ( FATAL , msg)
2988 end subroutine ext_pio_put_var_td_real_sca
2990 subroutine ext_pio_put_var_ti_double_arr(DataHandle,Element,Var,Data,Count,Status)
2996 include 'wrf_status_codes.h'
2997 integer ,intent(in) :: DataHandle
2998 character*(*) ,intent(in) :: Element
2999 character*(*) ,intent(in) :: Var
3000 real*8 ,intent(in) :: Data(:)
3001 integer ,intent(in) :: Count
3002 integer ,intent(out) :: Status
3003 type(wrf_data_handle) ,pointer :: DH
3004 character (VarNameLen) :: VarName
3012 call GetDH(DataHandle,DH,Status)
3013 if(Status /= WRF_NO_ERR) then
3014 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3015 call wrf_debug ( WARN , msg)
3018 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3019 Status = WRF_WARN_FILE_NOT_OPENED
3020 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3021 call wrf_debug ( WARN , msg)
3022 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3023 Status = WRF_WARN_WRITE_RONLY_FILE
3024 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3025 call wrf_debug ( WARN , msg)
3026 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3027 Status = WRF_WARN_MD_AFTER_OPEN
3028 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
3029 call wrf_debug ( WARN , msg)
3031 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3033 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
3035 elseif(NVar == MaxVars) then
3036 Status = WRF_WARN_VAR_NF
3037 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
3039 call wrf_debug ( WARN , msg)
3043 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Data )
3044 call netcdf_err(stat,Status)
3045 if(Status /= WRF_NO_ERR) then
3046 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
3047 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
3048 call wrf_debug ( WARN , msg)
3051 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3052 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3053 call wrf_debug ( FATAL , msg)
3057 end subroutine ext_pio_put_var_ti_double_arr
3059 subroutine ext_pio_put_var_ti_double_sca(DataHandle,Element,Var,Data,Count,Status)
3065 include 'wrf_status_codes.h'
3066 integer ,intent(in) :: DataHandle
3067 character*(*) ,intent(in) :: Element
3068 character*(*) ,intent(in) :: Var
3069 real*8 ,intent(in) :: Data
3070 integer ,intent(in) :: Count
3071 integer ,intent(out) :: Status
3072 type(wrf_data_handle) ,pointer :: DH
3073 character (VarNameLen) :: VarName
3082 call GetDH(DataHandle,DH,Status)
3083 if(Status /= WRF_NO_ERR) then
3084 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3085 call wrf_debug ( WARN , msg)
3088 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3089 Status = WRF_WARN_FILE_NOT_OPENED
3090 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3091 call wrf_debug ( WARN , msg)
3092 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3093 Status = WRF_WARN_WRITE_RONLY_FILE
3094 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3095 call wrf_debug ( WARN , msg)
3096 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3097 Status = WRF_WARN_MD_AFTER_OPEN
3098 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
3099 call wrf_debug ( WARN , msg)
3101 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3103 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
3105 elseif(NVar == MaxVars) then
3106 Status = WRF_WARN_VAR_NF
3107 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
3109 call wrf_debug ( WARN , msg)
3114 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Buffer)
3115 call netcdf_err(stat,Status)
3116 if(Status /= WRF_NO_ERR) then
3117 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
3118 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
3119 call wrf_debug ( WARN , msg)
3122 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3123 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3124 call wrf_debug ( FATAL , msg)
3128 end subroutine ext_pio_put_var_ti_double_sca
3130 subroutine ext_pio_put_var_td_double_arr(DataHandle,Element,DateStr,Var,Data,Count,Status)
3136 include 'wrf_status_codes.h'
3137 integer ,intent(in) :: DataHandle
3138 character*(*) ,intent(in) :: Element
3139 character*(*) ,intent(in) :: DateStr
3140 character*(*) ,intent(in) :: Var
3141 real*8 ,intent(in) :: Data(:)
3142 integer ,intent(in) :: Count
3143 integer ,intent(out) :: Status
3144 type(wrf_data_handle) ,pointer :: DH
3145 character (VarNameLen) :: VarName
3146 character (40+len(Element)) :: Name
3149 integer :: VDims (2)
3150 integer :: VStart(2)
3151 integer :: VCount(2)
3153 integer :: TimeIndex
3155 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3156 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3157 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3161 call DateCheck(DateStr,Status)
3162 if(Status /= WRF_NO_ERR) then
3163 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
3164 call wrf_debug ( WARN , msg)
3167 call GetDH(DataHandle,DH,Status)
3168 if(Status /= WRF_NO_ERR) then
3169 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3170 call wrf_debug ( WARN , msg)
3173 call GetName(Element, VarName, Name, Status)
3174 if(Status /= WRF_NO_ERR) then
3175 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3176 call wrf_debug ( WARN , msg)
3179 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3180 Status = WRF_WARN_FILE_NOT_OPENED
3181 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3182 call wrf_debug ( WARN , msg)
3183 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3184 Status = WRF_WARN_WRITE_RONLY_FILE
3185 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3186 call wrf_debug ( WARN , msg)
3187 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3189 Status = WRF_WARN_ZERO_LENGTH_PUT
3193 if(DH%VarNames(NVar) == Name) then
3194 Status = WRF_WARN_2DRYRUNS_1VARIABLE
3196 elseif(DH%VarNames(NVar) == NO_NAME) then
3197 DH%VarNames(NVar) = Name
3199 elseif(NVar == MaxVars) then
3200 Status = WRF_WARN_TOO_MANY_VARIABLES
3201 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3202 call wrf_debug ( WARN , msg)
3207 if(DH%DimLengths(i) == Count) then
3209 elseif(DH%DimLengths(i) == NO_DIM) then
3210 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
3211 call netcdf_err(stat,Status)
3212 if(Status /= WRF_NO_ERR) then
3213 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3214 call wrf_debug ( WARN , msg)
3217 DH%DimLengths(i) = Count
3219 elseif(i == MaxDims) then
3220 Status = WRF_WARN_TOO_MANY_DIMS
3221 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
3222 call wrf_debug ( WARN , msg)
3226 DH%VarDimLens(1,NVar) = Count
3227 VDims(1) = DH%DimIDs(i)
3228 VDims(2) = DH%DimUnlimID
3229 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3230 write(unit=0, fmt='(3a,i6)') '4 Define Var <', trim(Var), '> as NVvar:', NVar
3231 stat = pio_def_var(DH%file_handle,Name,PIO_DOUBLE,DH%descVar(NVar))
3232 call netcdf_err(stat,Status)
3233 if(Status /= WRF_NO_ERR) then
3234 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3235 call wrf_debug ( WARN , msg)
3238 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3240 if(DH%VarNames(NVar) == Name) then
3242 elseif(DH%VarNames(NVar) == NO_NAME) then
3243 Status = WRF_WARN_MD_NF
3244 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
3245 call wrf_debug ( WARN , msg)
3247 elseif(NVar == MaxVars) then
3248 Status = WRF_WARN_TOO_MANY_VARIABLES
3249 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3250 call wrf_debug ( WARN , msg)
3254 if(Count > DH%VarDimLens(1,NVar)) then
3255 Status = WRF_WARN_COUNT_TOO_LONG
3256 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
3257 call wrf_debug ( WARN , msg)
3259 elseif(Count < 1) then
3260 Status = WRF_WARN_ZERO_LENGTH_PUT
3261 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
3262 call wrf_debug ( WARN , msg)
3265 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
3266 if(Status /= WRF_NO_ERR) then
3267 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
3268 call wrf_debug ( WARN , msg)
3272 VStart(2) = TimeIndex
3275 !stat = pio_put_var(DH%file_handle,DH%descMDVar(NVar),VStart,VCount,Data)
3276 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Data)
3277 call netcdf_err(stat,Status)
3278 if(Status /= WRF_NO_ERR) then
3279 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3280 call wrf_debug ( WARN , msg)
3284 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3285 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3286 call wrf_debug ( FATAL , msg)
3291 end subroutine ext_pio_put_var_td_double_arr
3293 subroutine ext_pio_put_var_td_double_sca(DataHandle,Element,DateStr,Var,Data,Count,Status)
3299 include 'wrf_status_codes.h'
3300 integer ,intent(in) :: DataHandle
3301 character*(*) ,intent(in) :: Element
3302 character*(*) ,intent(in) :: DateStr
3303 character*(*) ,intent(in) :: Var
3304 real*8 ,intent(in) :: Data
3305 integer ,intent(in) :: Count
3306 integer ,intent(out) :: Status
3307 type(wrf_data_handle) ,pointer :: DH
3308 character (VarNameLen) :: VarName
3309 character (40+len(Element)) :: Name
3312 integer :: VDims (2)
3313 integer :: VStart(2)
3314 integer :: VCount(2)
3316 integer :: TimeIndex
3319 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3320 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3321 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3325 call DateCheck(DateStr,Status)
3326 if(Status /= WRF_NO_ERR) then
3327 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
3328 call wrf_debug ( WARN , msg)
3331 call GetDH(DataHandle,DH,Status)
3332 if(Status /= WRF_NO_ERR) then
3333 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3334 call wrf_debug ( WARN , msg)
3337 call GetName(Element, VarName, Name, Status)
3338 if(Status /= WRF_NO_ERR) then
3339 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3340 call wrf_debug ( WARN , msg)
3343 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3344 Status = WRF_WARN_FILE_NOT_OPENED
3345 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3346 call wrf_debug ( WARN , msg)
3347 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3348 Status = WRF_WARN_WRITE_RONLY_FILE
3349 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3350 call wrf_debug ( WARN , msg)
3351 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3353 Status = WRF_WARN_ZERO_LENGTH_PUT
3357 if(DH%VarNames(NVar) == Name) then
3358 Status = WRF_WARN_2DRYRUNS_1VARIABLE
3360 elseif(DH%VarNames(NVar) == NO_NAME) then
3361 DH%VarNames(NVar) = Name
3363 elseif(NVar == MaxVars) then
3364 Status = WRF_WARN_TOO_MANY_VARIABLES
3365 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3366 call wrf_debug ( WARN , msg)
3371 if(DH%DimLengths(i) == Count) then
3373 elseif(DH%DimLengths(i) == NO_DIM) then
3374 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
3375 call netcdf_err(stat,Status)
3376 if(Status /= WRF_NO_ERR) then
3377 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3378 call wrf_debug ( WARN , msg)
3381 DH%DimLengths(i) = Count
3383 elseif(i == MaxDims) then
3384 Status = WRF_WARN_TOO_MANY_DIMS
3385 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
3386 call wrf_debug ( WARN , msg)
3390 DH%VarDimLens(1,NVar) = Count
3391 VDims(1) = DH%DimIDs(i)
3392 VDims(2) = DH%DimUnlimID
3393 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3394 write(unit=0, fmt='(3a,i6)') '5 Define Var <', trim(Var), '> as NVar:', NVar
3395 stat = pio_def_var(DH%file_handle,Name,PIO_DOUBLE,DH%descVar(NVar))
3396 call netcdf_err(stat,Status)
3397 if(Status /= WRF_NO_ERR) then
3398 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3399 call wrf_debug ( WARN , msg)
3402 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3404 if(DH%VarNames(NVar) == Name) then
3406 elseif(DH%VarNames(NVar) == NO_NAME) then
3407 Status = WRF_WARN_MD_NF
3408 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
3409 call wrf_debug ( WARN , msg)
3411 elseif(NVar == MaxVars) then
3412 Status = WRF_WARN_TOO_MANY_VARIABLES
3413 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3414 call wrf_debug ( WARN , msg)
3418 if(Count > DH%VarDimLens(1,NVar)) then
3419 Status = WRF_WARN_COUNT_TOO_LONG
3420 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
3421 call wrf_debug ( WARN , msg)
3423 elseif(Count < 1) then
3424 Status = WRF_WARN_ZERO_LENGTH_PUT
3425 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
3426 call wrf_debug ( WARN , msg)
3429 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
3430 if(Status /= WRF_NO_ERR) then
3431 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
3432 call wrf_debug ( WARN , msg)
3436 VStart(2) = TimeIndex
3440 !stat = pio_put_var(DH%file_handle,DH%descMDVar(NVar),VStart,VCount,Buffer)
3441 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Buffer)
3442 call netcdf_err(stat,Status)
3443 if(Status /= WRF_NO_ERR) then
3444 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3445 call wrf_debug ( WARN , msg)
3449 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3450 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3451 call wrf_debug ( FATAL , msg)
3456 end subroutine ext_pio_put_var_td_double_sca
3458 subroutine ext_pio_put_var_ti_integer_arr(DataHandle,Element,Var,Data,Count,Status)
3464 include 'wrf_status_codes.h'
3465 integer ,intent(in) :: DataHandle
3466 character*(*) ,intent(in) :: Element
3467 character*(*) ,intent(in) :: Var
3468 integer, intent(in) :: Data(:)
3469 integer, intent(in) :: Count
3470 integer ,intent(out) :: Status
3471 type(wrf_data_handle) ,pointer :: DH
3472 character (VarNameLen) :: VarName
3478 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3479 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3480 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3485 call GetDH(DataHandle,DH,Status)
3486 if(Status /= WRF_NO_ERR) then
3487 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3490 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3491 Status = WRF_WARN_FILE_NOT_OPENED
3492 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3493 call wrf_debug ( WARN , msg)
3494 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3495 Status = WRF_WARN_WRITE_RONLY_FILE
3496 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3497 call wrf_debug ( WARN , msg)
3498 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3499 Status = WRF_WARN_MD_AFTER_OPEN
3500 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
3501 call wrf_debug ( WARN , msg)
3503 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3505 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
3507 elseif(NVar == MaxVars) then
3508 Status = WRF_WARN_VAR_NF
3509 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
3511 call wrf_debug ( WARN , msg)
3515 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Data)
3516 call netcdf_err(stat,Status)
3517 if(Status /= WRF_NO_ERR) then
3518 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
3519 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
3520 call wrf_debug ( WARN , msg)
3523 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3524 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3525 call wrf_debug ( FATAL , msg)
3530 end subroutine ext_pio_put_var_ti_integer_arr
3532 subroutine ext_pio_put_var_ti_integer_sca(DataHandle,Element,Var,Data,Count,Status)
3538 include 'wrf_status_codes.h'
3539 integer ,intent(in) :: DataHandle
3540 character*(*) ,intent(in) :: Element
3541 character*(*) ,intent(in) :: Var
3542 integer, intent(in) :: Data
3543 integer, intent(in) :: Count
3544 integer ,intent(out) :: Status
3545 type(wrf_data_handle) ,pointer :: DH
3546 character (VarNameLen) :: VarName
3548 integer :: Buffer(1)
3553 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3554 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3555 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3560 call GetDH(DataHandle,DH,Status)
3561 if(Status /= WRF_NO_ERR) then
3562 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3565 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3566 Status = WRF_WARN_FILE_NOT_OPENED
3567 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3568 call wrf_debug ( WARN , msg)
3569 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3570 Status = WRF_WARN_WRITE_RONLY_FILE
3571 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3572 call wrf_debug ( WARN , msg)
3573 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3574 Status = WRF_WARN_MD_AFTER_OPEN
3575 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,', line', __LINE__
3576 call wrf_debug ( WARN , msg)
3578 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3580 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
3582 elseif(NVar == MaxVars) then
3583 Status = WRF_WARN_VAR_NF
3584 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__ &
3586 call wrf_debug ( WARN , msg)
3591 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Buffer)
3592 call netcdf_err(stat,Status)
3593 if(Status /= WRF_NO_ERR) then
3594 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
3595 ' Element ',trim(Element),' in ',__FILE__,', line', __LINE__
3596 call wrf_debug ( WARN , msg)
3599 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3600 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3601 call wrf_debug ( FATAL , msg)
3606 end subroutine ext_pio_put_var_ti_integer_sca
3608 subroutine ext_pio_put_var_td_integer_arr(DataHandle,Element,DateStr,Var,Data,Count,Status)
3614 include 'wrf_status_codes.h'
3615 integer ,intent(in) :: DataHandle
3616 character*(*) ,intent(in) :: Element
3617 character*(*) ,intent(in) :: DateStr
3618 character*(*) ,intent(in) :: Var
3619 integer, intent(in) :: Data(:)
3620 integer, intent(in) :: Count
3621 integer ,intent(out) :: Status
3622 type(wrf_data_handle) ,pointer :: DH
3623 character (VarNameLen) :: VarName
3624 character (40+len(Element)) :: Name
3627 integer :: VDims (2)
3628 integer :: VStart(2)
3629 integer :: VCount(2)
3631 integer :: TimeIndex
3633 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3634 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3635 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3639 call DateCheck(DateStr,Status)
3640 if(Status /= WRF_NO_ERR) then
3641 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
3642 call wrf_debug ( WARN , msg)
3645 call GetDH(DataHandle,DH,Status)
3646 if(Status /= WRF_NO_ERR) then
3647 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3648 call wrf_debug ( WARN , msg)
3651 call GetName(Element, VarName, Name, Status)
3652 if(Status /= WRF_NO_ERR) then
3653 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3654 call wrf_debug ( WARN , msg)
3657 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3658 Status = WRF_WARN_FILE_NOT_OPENED
3659 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3660 call wrf_debug ( WARN , msg)
3661 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3662 Status = WRF_WARN_WRITE_RONLY_FILE
3663 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3664 call wrf_debug ( WARN , msg)
3665 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3667 Status = WRF_WARN_ZERO_LENGTH_PUT
3671 if(DH%VarNames(NVar) == Name) then
3672 Status = WRF_WARN_2DRYRUNS_1VARIABLE
3674 elseif(DH%VarNames(NVar) == NO_NAME) then
3675 DH%VarNames(NVar) = Name
3677 elseif(NVar == MaxVars) then
3678 Status = WRF_WARN_TOO_MANY_VARIABLES
3679 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3680 call wrf_debug ( WARN , msg)
3685 if(DH%DimLengths(i) == Count) then
3687 elseif(DH%DimLengths(i) == NO_DIM) then
3688 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
3689 call netcdf_err(stat,Status)
3690 if(Status /= WRF_NO_ERR) then
3691 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3692 call wrf_debug ( WARN , msg)
3695 DH%DimLengths(i) = Count
3697 elseif(i == MaxDims) then
3698 Status = WRF_WARN_TOO_MANY_DIMS
3699 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
3700 call wrf_debug ( WARN , msg)
3704 DH%VarDimLens(1,NVar) = Count
3705 VDims(1) = DH%DimIDs(i)
3706 VDims(2) = DH%DimUnlimID
3707 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3708 write(unit=0, fmt='(3a,i6)') '6 Define Var <', trim(Var), '> as NVar:', NVar
3709 stat = pio_def_var(DH%file_handle,Name,PIO_INT,DH%descVar(NVar))
3710 call netcdf_err(stat,Status)
3711 if(Status /= WRF_NO_ERR) then
3712 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3713 call wrf_debug ( WARN , msg)
3716 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3718 if(DH%VarNames(NVar) == Name) then
3720 elseif(DH%VarNames(NVar) == NO_NAME) then
3721 Status = WRF_WARN_MD_NF
3722 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
3723 call wrf_debug ( WARN , msg)
3725 elseif(NVar == MaxVars) then
3726 Status = WRF_WARN_TOO_MANY_VARIABLES
3727 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3728 call wrf_debug ( WARN , msg)
3732 if(Count > DH%VarDimLens(1,NVar)) then
3733 Status = WRF_WARN_COUNT_TOO_LONG
3734 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
3735 call wrf_debug ( WARN , msg)
3737 elseif(Count < 1) then
3738 Status = WRF_WARN_ZERO_LENGTH_PUT
3739 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
3740 call wrf_debug ( WARN , msg)
3743 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
3744 if(Status /= WRF_NO_ERR) then
3745 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
3746 call wrf_debug ( WARN , msg)
3750 VStart(2) = TimeIndex
3753 !stat = pio_put_var(DH%file_handle,DH%MDVarIDs(NVar),VStart,VCount,Data)
3754 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Data)
3755 call netcdf_err(stat,Status)
3756 if(Status /= WRF_NO_ERR) then
3757 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3758 call wrf_debug ( WARN , msg)
3762 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3763 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3764 call wrf_debug ( FATAL , msg)
3769 end subroutine ext_pio_put_var_td_integer_arr
3771 subroutine ext_pio_put_var_td_integer_sca(DataHandle,Element,DateStr,Var,Data,Count,Status)
3777 include 'wrf_status_codes.h'
3778 integer ,intent(in) :: DataHandle
3779 character*(*) ,intent(in) :: Element
3780 character*(*) ,intent(in) :: DateStr
3781 character*(*) ,intent(in) :: Var
3782 integer, intent(in) :: Data
3783 integer, intent(in) :: Count
3784 integer ,intent(out) :: Status
3785 type(wrf_data_handle) ,pointer :: DH
3786 character (VarNameLen) :: VarName
3787 character (40+len(Element)) :: Name
3790 integer :: VDims (2)
3791 integer :: VStart(2)
3792 integer :: VCount(2)
3794 integer :: TimeIndex
3795 integer :: Buffer(1)
3797 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3798 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3799 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3803 call DateCheck(DateStr,Status)
3804 if(Status /= WRF_NO_ERR) then
3805 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
3806 call wrf_debug ( WARN , msg)
3809 call GetDH(DataHandle,DH,Status)
3810 if(Status /= WRF_NO_ERR) then
3811 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3812 call wrf_debug ( WARN , msg)
3815 call GetName(Element, VarName, Name, Status)
3816 if(Status /= WRF_NO_ERR) then
3817 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
3818 call wrf_debug ( WARN , msg)
3821 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3822 Status = WRF_WARN_FILE_NOT_OPENED
3823 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
3824 call wrf_debug ( WARN , msg)
3825 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3826 Status = WRF_WARN_WRITE_RONLY_FILE
3827 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
3828 call wrf_debug ( WARN , msg)
3829 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3831 Status = WRF_WARN_ZERO_LENGTH_PUT
3835 if(DH%VarNames(NVar) == Name) then
3836 Status = WRF_WARN_2DRYRUNS_1VARIABLE
3838 elseif(DH%VarNames(NVar) == NO_NAME) then
3839 DH%VarNames(NVar) = Name
3841 elseif(NVar == MaxVars) then
3842 Status = WRF_WARN_TOO_MANY_VARIABLES
3843 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3844 call wrf_debug ( WARN , msg)
3849 if(DH%DimLengths(i) == Count) then
3851 elseif(DH%DimLengths(i) == NO_DIM) then
3852 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
3853 call netcdf_err(stat,Status)
3854 if(Status /= WRF_NO_ERR) then
3855 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3856 call wrf_debug ( WARN , msg)
3859 DH%DimLengths(i) = Count
3861 elseif(i == MaxDims) then
3862 Status = WRF_WARN_TOO_MANY_DIMS
3863 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
3864 call wrf_debug ( WARN , msg)
3868 DH%VarDimLens(1,NVar) = Count
3869 VDims(1) = DH%DimIDs(i)
3870 VDims(2) = DH%DimUnlimID
3871 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3872 write(unit=0, fmt='(3a,i6)') '7 Define Var <', trim(Var), '> as NVar:', NVar
3873 stat = pio_def_var(DH%file_handle,Name,PIO_INT,DH%descVar(NVar))
3874 call netcdf_err(stat,Status)
3875 if(Status /= WRF_NO_ERR) then
3876 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3877 call wrf_debug ( WARN , msg)
3880 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3882 if(DH%VarNames(NVar) == Name) then
3884 elseif(DH%VarNames(NVar) == NO_NAME) then
3885 Status = WRF_WARN_MD_NF
3886 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,', line', __LINE__
3887 call wrf_debug ( WARN , msg)
3889 elseif(NVar == MaxVars) then
3890 Status = WRF_WARN_TOO_MANY_VARIABLES
3891 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
3892 call wrf_debug ( WARN , msg)
3896 if(Count > DH%VarDimLens(1,NVar)) then
3897 Status = WRF_WARN_COUNT_TOO_LONG
3898 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,', line', __LINE__
3899 call wrf_debug ( WARN , msg)
3901 elseif(Count < 1) then
3902 Status = WRF_WARN_ZERO_LENGTH_PUT
3903 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,', line', __LINE__
3904 call wrf_debug ( WARN , msg)
3907 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
3908 if(Status /= WRF_NO_ERR) then
3909 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
3910 call wrf_debug ( WARN , msg)
3914 VStart(2) = TimeIndex
3918 !stat = pio_put_var(DH%file_handle,DH%MDVarIDs(NVar),VStart,VCount,Buffer)
3919 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Buffer)
3920 call netcdf_err(stat,Status)
3921 if(Status /= WRF_NO_ERR) then
3922 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
3923 call wrf_debug ( WARN , msg)
3927 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
3928 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
3929 call wrf_debug ( FATAL , msg)
3934 end subroutine ext_pio_put_var_td_integer_sca
3936 subroutine ext_pio_put_var_ti_logical_arr(DataHandle,Element,Var,Data,Count,Status)
3942 include 'wrf_status_codes.h'
3943 integer ,intent(in) :: DataHandle
3944 character*(*) ,intent(in) :: Element
3945 character*(*) ,intent(in) :: Var
3946 logical, intent(in) :: Data(:)
3947 integer, intent(in) :: Count
3948 integer ,intent(out) :: Status
3949 type(wrf_data_handle) ,pointer :: DH
3950 character (VarNameLen) :: VarName
3952 integer ,allocatable :: Buffer(:)
3957 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3958 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3959 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
3964 call GetDH(DataHandle,DH,Status)
3965 if(Status /= WRF_NO_ERR) then
3966 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
3967 call wrf_debug ( WARN , msg)
3970 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
3971 Status = WRF_WARN_FILE_NOT_OPENED
3972 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
3973 call wrf_debug ( WARN , msg)
3974 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
3975 Status = WRF_WARN_WRITE_RONLY_FILE
3976 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
3977 call wrf_debug ( WARN , msg)
3978 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
3979 Status = WRF_WARN_MD_AFTER_OPEN
3980 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,' ','LOGICAL',', line', __LINE__
3981 call wrf_debug ( WARN , msg)
3983 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
3985 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
3987 elseif(NVar == MaxVars) then
3988 Status = WRF_WARN_VAR_NF
3989 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__ &
3991 call wrf_debug ( WARN , msg)
3995 allocate(Buffer(Count), STAT=stat)
3997 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
3998 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
3999 call wrf_debug ( FATAL , msg)
4009 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Buffer)
4010 call netcdf_err(stat,Status)
4011 if(Status /= WRF_NO_ERR) then
4012 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
4013 ' Element ',trim(Element),' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4014 call wrf_debug ( WARN , msg)
4016 deallocate(Buffer, STAT=stat)
4018 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
4019 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4020 call wrf_debug ( FATAL , msg)
4024 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4025 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4026 call wrf_debug ( FATAL , msg)
4031 end subroutine ext_pio_put_var_ti_logical_arr
4033 subroutine ext_pio_put_var_ti_logical_sca(DataHandle,Element,Var,Data,Count,Status)
4039 include 'wrf_status_codes.h'
4040 integer ,intent(in) :: DataHandle
4041 character*(*) ,intent(in) :: Element
4042 character*(*) ,intent(in) :: Var
4043 logical, intent(in) :: Data
4044 integer, intent(in) :: Count
4045 integer ,intent(out) :: Status
4046 type(wrf_data_handle) ,pointer :: DH
4047 character (VarNameLen) :: VarName
4049 integer :: Buffer(1)
4054 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4055 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4056 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4061 call GetDH(DataHandle,DH,Status)
4062 if(Status /= WRF_NO_ERR) then
4063 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4064 call wrf_debug ( WARN , msg)
4067 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4068 Status = WRF_WARN_FILE_NOT_OPENED
4069 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
4070 call wrf_debug ( WARN , msg)
4071 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4072 Status = WRF_WARN_WRITE_RONLY_FILE
4073 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
4074 call wrf_debug ( WARN , msg)
4075 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4076 Status = WRF_WARN_MD_AFTER_OPEN
4077 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,' ','LOGICAL',', line', __LINE__
4078 call wrf_debug ( WARN , msg)
4080 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4082 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
4084 elseif(NVar == MaxVars) then
4085 Status = WRF_WARN_VAR_NF
4086 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__ &
4088 call wrf_debug ( WARN , msg)
4097 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),Buffer)
4098 call netcdf_err(stat,Status)
4099 if(Status /= WRF_NO_ERR) then
4100 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
4101 ' Element ',trim(Element),' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4102 call wrf_debug ( WARN , msg)
4105 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
4106 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4107 call wrf_debug ( FATAL , msg)
4111 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4112 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4113 call wrf_debug ( FATAL , msg)
4118 end subroutine ext_pio_put_var_ti_logical_sca
4120 subroutine ext_pio_put_var_td_logical_arr(DataHandle,Element,DateStr,Var,Data,Count,Status)
4126 include 'wrf_status_codes.h'
4127 integer ,intent(in) :: DataHandle
4128 character*(*) ,intent(in) :: Element
4129 character*(*) ,intent(in) :: DateStr
4130 character*(*) ,intent(in) :: Var
4131 logical, intent(in) :: Data(:)
4132 integer, intent(in) :: Count
4133 integer ,intent(out) :: Status
4134 type(wrf_data_handle) ,pointer :: DH
4135 character (VarNameLen) :: VarName
4136 character (40+len(Element)) :: Name
4138 integer ,allocatable :: Buffer(:)
4140 integer :: VDims (2)
4141 integer :: VStart(2)
4142 integer :: VCount(2)
4144 integer :: TimeIndex
4146 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4147 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4148 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4152 call DateCheck(DateStr,Status)
4153 if(Status /= WRF_NO_ERR) then
4154 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4155 call wrf_debug ( WARN , msg)
4158 call GetDH(DataHandle,DH,Status)
4159 if(Status /= WRF_NO_ERR) then
4160 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4161 call wrf_debug ( WARN , msg)
4164 call GetName(Element, VarName, Name, Status)
4165 if(Status /= WRF_NO_ERR) then
4166 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4167 call wrf_debug ( WARN , msg)
4170 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4171 Status = WRF_WARN_FILE_NOT_OPENED
4172 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
4173 call wrf_debug ( WARN , msg)
4174 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4175 Status = WRF_WARN_WRITE_RONLY_FILE
4176 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
4177 call wrf_debug ( WARN , msg)
4178 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4180 Status = WRF_WARN_ZERO_LENGTH_PUT
4184 if(DH%VarNames(NVar) == Name) then
4185 Status = WRF_WARN_2DRYRUNS_1VARIABLE
4187 elseif(DH%VarNames(NVar) == NO_NAME) then
4188 DH%VarNames(NVar) = Name
4190 elseif(NVar == MaxVars) then
4191 Status = WRF_WARN_TOO_MANY_VARIABLES
4192 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','LOGICAL',', line', __LINE__
4193 call wrf_debug ( WARN , msg)
4198 if(DH%DimLengths(i) == Count) then
4200 elseif(DH%DimLengths(i) == NO_DIM) then
4201 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
4202 call netcdf_err(stat,Status)
4203 if(Status /= WRF_NO_ERR) then
4204 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4205 call wrf_debug ( WARN , msg)
4208 DH%DimLengths(i) = Count
4210 elseif(i == MaxDims) then
4211 Status = WRF_WARN_TOO_MANY_DIMS
4212 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4213 call wrf_debug ( WARN , msg)
4217 DH%VarDimLens(1,NVar) = Count
4218 VDims(1) = DH%DimIDs(i)
4219 VDims(2) = DH%DimUnlimID
4220 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4221 write(unit=0, fmt='(3a,i6)') '8 Define Var <', trim(Var), '> as NVar:', NVar
4222 stat = pio_def_var(DH%file_handle,Name,PIO_INT,DH%descVar(NVar))
4223 call netcdf_err(stat,Status)
4224 if(Status /= WRF_NO_ERR) then
4225 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4226 call wrf_debug ( WARN , msg)
4229 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4231 if(DH%VarNames(NVar) == Name) then
4233 elseif(DH%VarNames(NVar) == NO_NAME) then
4234 Status = WRF_WARN_MD_NF
4235 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__
4236 call wrf_debug ( WARN , msg)
4238 elseif(NVar == MaxVars) then
4239 Status = WRF_WARN_TOO_MANY_VARIABLES
4240 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','LOGICAL',', line', __LINE__
4241 call wrf_debug ( WARN , msg)
4245 if(Count > DH%VarDimLens(1,NVar)) then
4246 Status = WRF_WARN_COUNT_TOO_LONG
4247 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,' ','LOGICAL',', line', __LINE__
4248 call wrf_debug ( WARN , msg)
4250 elseif(Count < 1) then
4251 Status = WRF_WARN_ZERO_LENGTH_PUT
4252 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,' ','LOGICAL',', line', __LINE__
4253 call wrf_debug ( WARN , msg)
4256 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
4257 if(Status /= WRF_NO_ERR) then
4258 write(msg,*) 'Warning in ',__FILE__,' ','LOGICAL',', line', __LINE__
4259 call wrf_debug ( WARN , msg)
4263 VStart(2) = TimeIndex
4266 allocate(Buffer(Count), STAT=stat)
4268 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
4269 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4270 call wrf_debug ( FATAL , msg)
4280 !stat = pio_put_var(DH%file_handle,DH%MDVarIDs(NVar),VStart,VCount,Buffer)
4281 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Buffer)
4282 deallocate(Buffer, STAT=stat)
4284 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
4285 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4286 call wrf_debug ( FATAL , msg)
4289 call netcdf_err(stat,Status)
4290 if(Status /= WRF_NO_ERR) then
4291 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4292 call wrf_debug ( WARN , msg)
4296 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4297 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4298 call wrf_debug ( FATAL , msg)
4303 end subroutine ext_pio_put_var_td_logical_arr
4305 subroutine ext_pio_put_var_td_logical_sca(DataHandle,Element,DateStr,Var,Data,Count,Status)
4311 include 'wrf_status_codes.h'
4312 integer ,intent(in) :: DataHandle
4313 character*(*) ,intent(in) :: Element
4314 character*(*) ,intent(in) :: DateStr
4315 character*(*) ,intent(in) :: Var
4316 logical, intent(in) :: Data
4317 integer, intent(in) :: Count
4318 integer ,intent(out) :: Status
4319 type(wrf_data_handle) ,pointer :: DH
4320 character (VarNameLen) :: VarName
4321 character (40+len(Element)) :: Name
4323 integer :: Buffer(1)
4325 integer :: VDims (2)
4326 integer :: VStart(2)
4327 integer :: VCount(2)
4329 integer :: TimeIndex
4331 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4332 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4333 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4337 call DateCheck(DateStr,Status)
4338 if(Status /= WRF_NO_ERR) then
4339 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
4340 call wrf_debug ( WARN , msg)
4343 call GetDH(DataHandle,DH,Status)
4344 if(Status /= WRF_NO_ERR) then
4345 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4346 call wrf_debug ( WARN , msg)
4349 call GetName(Element, VarName, Name, Status)
4350 if(Status /= WRF_NO_ERR) then
4351 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
4352 call wrf_debug ( WARN , msg)
4355 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4356 Status = WRF_WARN_FILE_NOT_OPENED
4357 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
4358 call wrf_debug ( WARN , msg)
4359 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4360 Status = WRF_WARN_WRITE_RONLY_FILE
4361 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
4362 call wrf_debug ( WARN , msg)
4363 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4365 Status = WRF_WARN_ZERO_LENGTH_PUT
4369 if(DH%VarNames(NVar) == Name) then
4370 Status = WRF_WARN_2DRYRUNS_1VARIABLE
4372 elseif(DH%VarNames(NVar) == NO_NAME) then
4373 DH%VarNames(NVar) = Name
4375 elseif(NVar == MaxVars) then
4376 Status = WRF_WARN_TOO_MANY_VARIABLES
4377 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','LOGICAL',', line', __LINE__
4378 call wrf_debug ( WARN , msg)
4383 if(DH%DimLengths(i) == Count) then
4385 elseif(DH%DimLengths(i) == NO_DIM) then
4386 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),Count,DH%DimIDs(i))
4387 call netcdf_err(stat,Status)
4388 if(Status /= WRF_NO_ERR) then
4389 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4390 call wrf_debug ( WARN , msg)
4393 DH%DimLengths(i) = Count
4395 elseif(i == MaxDims) then
4396 Status = WRF_WARN_TOO_MANY_DIMS
4397 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4398 call wrf_debug ( WARN , msg)
4402 DH%VarDimLens(1,NVar) = Count
4403 VDims(1) = DH%DimIDs(i)
4404 VDims(2) = DH%DimUnlimID
4405 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4406 write(unit=0, fmt='(3a,i6)') '9 Define Var <', trim(Var), '> as NVar:', NVar
4407 stat = pio_def_var(DH%file_handle,Name,PIO_INT,DH%descVar(NVar))
4408 call netcdf_err(stat,Status)
4409 if(Status /= WRF_NO_ERR) then
4410 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4411 call wrf_debug ( WARN , msg)
4414 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4416 if(DH%VarNames(NVar) == Name) then
4418 elseif(DH%VarNames(NVar) == NO_NAME) then
4419 Status = WRF_WARN_MD_NF
4420 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__
4421 call wrf_debug ( WARN , msg)
4423 elseif(NVar == MaxVars) then
4424 Status = WRF_WARN_TOO_MANY_VARIABLES
4425 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','LOGICAL',', line', __LINE__
4426 call wrf_debug ( WARN , msg)
4430 if(Count > DH%VarDimLens(1,NVar)) then
4431 Status = WRF_WARN_COUNT_TOO_LONG
4432 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,' ','LOGICAL',', line', __LINE__
4433 call wrf_debug ( WARN , msg)
4435 elseif(Count < 1) then
4436 Status = WRF_WARN_ZERO_LENGTH_PUT
4437 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,' ','LOGICAL',', line', __LINE__
4438 call wrf_debug ( WARN , msg)
4441 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
4442 if(Status /= WRF_NO_ERR) then
4443 write(msg,*) 'Warning in ',__FILE__,' ','LOGICAL',', line', __LINE__
4444 call wrf_debug ( WARN , msg)
4448 VStart(2) = TimeIndex
4456 !stat = pio_put_var(DH%file_handle,DH%MDVarIDs(NVar),VStart,VCount,Buffer)
4457 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,Buffer)
4458 call netcdf_err(stat,Status)
4459 if(Status /= WRF_NO_ERR) then
4460 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
4461 call wrf_debug ( WARN , msg)
4465 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4466 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
4467 call wrf_debug ( FATAL , msg)
4472 end subroutine ext_pio_put_var_td_logical_sca
4474 subroutine ext_pio_put_var_ti_char_arr(DataHandle,Element,Var,Data,Status)
4480 include 'wrf_status_codes.h'
4481 integer ,intent(in) :: DataHandle
4482 character*(*) ,intent(in) :: Element
4483 character*(*) ,intent(in) :: Var
4484 character*(*) ,intent(in) :: Data
4486 integer ,intent(out) :: Status
4487 type(wrf_data_handle) ,pointer :: DH
4488 character (VarNameLen) :: VarName
4492 character(len=1) :: null
4493 character(len=4096) :: tmpdata
4500 else if(4096 < length) then
4502 tmpdata = Data(1:4096)
4504 tmpdata = trim(Data)
4508 call GetDH(DataHandle,DH,Status)
4509 if(Status /= WRF_NO_ERR) then
4510 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4511 call wrf_debug ( WARN , msg)
4514 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4515 Status = WRF_WARN_FILE_NOT_OPENED
4516 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
4517 call wrf_debug ( WARN , msg)
4518 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4519 Status = WRF_WARN_WRITE_RONLY_FILE
4520 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
4521 call wrf_debug ( WARN , msg)
4522 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4523 Status = WRF_WARN_MD_AFTER_OPEN
4524 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,' ','CHAR',', line', __LINE__
4525 call wrf_debug ( WARN , msg)
4527 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4529 if(TRIM(DH%VarNames(i)) == TRIM(VarName)) then
4532 elseif(i == MaxVars) then
4533 Status = WRF_WARN_VAR_NF
4534 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__ &
4536 call wrf_debug ( WARN , msg)
4541 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4542 !write(unit=0, fmt='(6a)') 'Var: ', trim(Var), ', Data: ', trim(Data), ', tmpdata: ', trim(tmpdata)
4543 !write(unit=0, fmt='(3a,i6)') 'Element = ', trim(Element), ', NVar = ', NVar
4544 !write(unit=0, fmt='(2(a,i6))') 'DH%descVar(NVar)%VarID = ', DH%descVar(NVar)%VarID, &
4545 ! ', length = ', length
4549 stat = pio_redef(DH%file_handle)
4550 call netcdf_err(stat,Status)
4551 if(Status /= WRF_NO_ERR) then
4552 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
4553 call wrf_debug ( WARN , msg)
4559 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4560 !write(unit=0, fmt='(6a)') 'Var: ', trim(Var), ', Element: ', trim(Element), ', tmpdata: ', trim(tmpdata)
4561 !write(unit=0, fmt='(2(a,i6))') 'DH%descVar(NVar)%VarID = ', DH%descVar(NVar)%VarID, &
4562 ! ', length = ', length
4563 stat = pio_put_att(DH%file_handle,DH%descVar(NVar),trim(Element),null)
4565 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4566 !write(unit=0, fmt='(6a)') 'Var: ', trim(Var), ', Element: ', trim(Element), ', tmpdata: ', trim(tmpdata)
4567 !write(unit=0, fmt='(2(a,i6))') 'DH%descVar(NVar)%VarID = ', DH%descVar(NVar)%VarID, &
4568 ! ', length = ', length
4569 stat = pio_put_att(DH%file_handle,DH%descVar(NVar),trim(Element),tmpdata)
4571 call netcdf_err(stat,Status)
4572 if(Status /= WRF_NO_ERR) then
4573 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
4574 ' Element ',trim(Element),' in ',__FILE__,' ','CHAR',', line', __LINE__
4575 call wrf_debug ( WARN , msg)
4578 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4579 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
4580 call wrf_debug ( FATAL , msg)
4584 end subroutine ext_pio_put_var_ti_char_arr
4586 subroutine ext_pio_put_var_ti_char_sca(DataHandle,Element,Var,Data,Status)
4592 include 'wrf_status_codes.h'
4593 integer ,intent(in) :: DataHandle
4594 character*(*) ,intent(in) :: Element
4595 character*(*) ,intent(in) :: Var
4596 character*(*) ,intent(in) :: Data
4598 integer ,intent(out) :: Status
4599 type(wrf_data_handle) ,pointer :: DH
4600 character (VarNameLen) :: VarName
4606 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4607 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4608 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4613 call GetDH(DataHandle,DH,Status)
4614 if(Status /= WRF_NO_ERR) then
4615 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4616 call wrf_debug ( WARN , msg)
4619 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4620 Status = WRF_WARN_FILE_NOT_OPENED
4621 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
4622 call wrf_debug ( WARN , msg)
4623 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4624 Status = WRF_WARN_WRITE_RONLY_FILE
4625 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
4626 call wrf_debug ( WARN , msg)
4627 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4628 Status = WRF_WARN_MD_AFTER_OPEN
4629 write(msg,*) 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,' ','CHAR',', line', __LINE__
4630 call wrf_debug ( WARN , msg)
4632 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4634 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
4636 elseif(NVar == MaxVars) then
4637 Status = WRF_WARN_VAR_NF
4638 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__ &
4640 call wrf_debug ( WARN , msg)
4644 if(len_trim(Data).le.0) then
4645 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),null)
4647 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),trim(Data))
4649 call netcdf_err(stat,Status)
4650 if(Status /= WRF_NO_ERR) then
4651 write(msg,*) 'NetCDF error for Var ',TRIM(Var),&
4652 ' Element ',trim(Element),' in ',__FILE__,' ','CHAR',', line', __LINE__
4653 call wrf_debug ( WARN , msg)
4656 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4657 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
4658 call wrf_debug ( FATAL , msg)
4663 end subroutine ext_pio_put_var_ti_char_sca
4665 subroutine ext_pio_put_var_td_char_arr(DataHandle,Element,DateStr,Var,Data,Status)
4671 include 'wrf_status_codes.h'
4672 integer ,intent(in) :: DataHandle
4673 character*(*) ,intent(in) :: Element
4674 character*(*) ,intent(in) :: DateStr
4675 character*(*) ,intent(in) :: Var
4676 character*(*) ,intent(in) :: Data
4677 integer ,intent(out) :: Status
4678 type(wrf_data_handle) ,pointer :: DH
4679 character (VarNameLen) :: VarName
4680 character (40+len(Element)) :: Name
4683 integer :: VDims (2)
4684 integer :: VStart(2)
4685 integer :: VCount(2)
4687 integer :: TimeIndex
4688 character(len=4096) :: tmpdata(1)
4695 else if(4096 < length) then
4697 tmpdata(1) = Data(1:4096)
4699 tmpdata(1) = trim(Data)
4702 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4703 write(unit=0, fmt='(4a)') 'Var: ', trim(Var), ', Data: ', tmpdata(1)
4704 write(unit=0, fmt='(4a)') 'Name: ', trim(Name), ', Element = ', trim(Element)
4707 call DateCheck(DateStr,Status)
4708 if(Status /= WRF_NO_ERR) then
4709 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','CHAR',', line', __LINE__
4710 call wrf_debug ( WARN , msg)
4713 call GetDH(DataHandle,DH,Status)
4714 if(Status /= WRF_NO_ERR) then
4715 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4716 call wrf_debug ( WARN , msg)
4719 call GetName(Element, VarName, Name, Status)
4720 if(Status /= WRF_NO_ERR) then
4721 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4722 call wrf_debug ( WARN , msg)
4725 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4726 Status = WRF_WARN_FILE_NOT_OPENED
4727 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
4728 call wrf_debug ( WARN , msg)
4729 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4730 Status = WRF_WARN_WRITE_RONLY_FILE
4731 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
4732 call wrf_debug ( WARN , msg)
4733 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4734 if(len(Data) < 1) then
4735 Status = WRF_WARN_ZERO_LENGTH_PUT
4739 if(DH%VarNames(NVar) == Name) then
4740 Status = WRF_WARN_2DRYRUNS_1VARIABLE
4742 elseif(DH%VarNames(NVar) == NO_NAME) then
4743 DH%VarNames(NVar) = Name
4745 elseif(NVar == MaxVars) then
4746 Status = WRF_WARN_TOO_MANY_VARIABLES
4747 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','CHAR',', line', __LINE__
4748 call wrf_debug ( WARN , msg)
4753 if(DH%DimLengths(i) == len(Data)) then
4755 elseif(DH%DimLengths(i) == NO_DIM) then
4756 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),len(Data),DH%DimIDs(i))
4757 call netcdf_err(stat,Status)
4758 if(Status /= WRF_NO_ERR) then
4759 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
4760 call wrf_debug ( WARN , msg)
4763 DH%DimLengths(i) = len(Data)
4765 elseif(i == MaxDims) then
4766 Status = WRF_WARN_TOO_MANY_DIMS
4767 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,' ','CHAR',', line', __LINE__
4768 call wrf_debug ( WARN , msg)
4772 DH%VarDimLens(1,NVar) = len(Data)
4773 VDims(1) = DH%DimIDs(i)
4774 VDims(2) = DH%DimUnlimID
4775 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4776 write(unit=0, fmt='(3a,i6)') '10 Define Var <', trim(Var), '> as NVar:', NVar
4777 stat = pio_def_var(DH%file_handle,Name,PIO_CHAR,DH%descVar(NVar))
4778 call netcdf_err(stat,Status)
4779 if(Status /= WRF_NO_ERR) then
4780 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
4781 call wrf_debug ( WARN , msg)
4784 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4786 if(DH%VarNames(NVar) == Name) then
4788 elseif(DH%VarNames(NVar) == NO_NAME) then
4789 Status = WRF_WARN_MD_NF
4790 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__
4791 call wrf_debug ( WARN , msg)
4793 elseif(NVar == MaxVars) then
4794 Status = WRF_WARN_TOO_MANY_VARIABLES
4795 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','CHAR',', line', __LINE__
4796 call wrf_debug ( WARN , msg)
4800 if(len(Data) > DH%VarDimLens(1,NVar)) then
4801 Status = WRF_WARN_COUNT_TOO_LONG
4802 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,' ','CHAR',', line', __LINE__
4803 call wrf_debug ( WARN , msg)
4805 elseif(len(Data) < 1) then
4806 Status = WRF_WARN_ZERO_LENGTH_PUT
4807 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,' ','CHAR',', line', __LINE__
4808 call wrf_debug ( WARN , msg)
4811 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
4812 if(Status /= WRF_NO_ERR) then
4813 write(msg,*) 'Warning in ',__FILE__,' ','CHAR',', line', __LINE__
4814 call wrf_debug ( WARN , msg)
4818 VStart(2) = TimeIndex
4822 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,tmpdata)
4823 call netcdf_err(stat,Status)
4824 if(Status /= WRF_NO_ERR) then
4825 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
4826 call wrf_debug ( WARN , msg)
4830 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
4831 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line: ', __LINE__
4832 call wrf_debug ( FATAL , msg)
4836 end subroutine ext_pio_put_var_td_char_arr
4838 subroutine ext_pio_put_var_td_char_sca(DataHandle,Element,DateStr,Var,Data,Status)
4844 include 'wrf_status_codes.h'
4845 integer ,intent(in) :: DataHandle
4846 character*(*) ,intent(in) :: Element
4847 character*(*) ,intent(in) :: DateStr
4848 character*(*) ,intent(in) :: Var
4849 character*(*) ,intent(in) :: Data
4850 integer ,intent(out) :: Status
4851 type(wrf_data_handle) ,pointer :: DH
4852 character (VarNameLen) :: VarName
4853 character (40+len(Element)) :: Name
4856 integer :: VDims (2)
4857 integer :: VStart(2)
4858 integer :: VCount(2)
4860 integer :: TimeIndex
4861 character(len=DateStrLen) :: tmpdata(1)
4864 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4865 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4866 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4873 else if(4096 < length) then
4875 tmpdata(1) = Data(1:4096)
4877 tmpdata(1) = trim(Data)
4880 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4881 write(unit=0, fmt='(4a)') 'Var: ', trim(Var), ', Data: ', tmpdata(1)
4883 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4884 write(unit=0, fmt='(4a)') 'Var: ', trim(Var), ', Data: ', tmpdata(1)
4885 write(unit=0, fmt='(4a)') 'Name: ', trim(Name), ', Element = ', trim(Element)
4888 call DateCheck(DateStr,Status)
4889 if(Status /= WRF_NO_ERR) then
4890 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','CHAR',', line', __LINE__
4891 call wrf_debug ( WARN , msg)
4894 call GetDH(DataHandle,DH,Status)
4895 if(Status /= WRF_NO_ERR) then
4896 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4897 call wrf_debug ( WARN , msg)
4900 call GetName(Element, VarName, Name, Status)
4901 if(Status /= WRF_NO_ERR) then
4902 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
4903 call wrf_debug ( WARN , msg)
4906 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
4907 Status = WRF_WARN_FILE_NOT_OPENED
4908 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
4909 call wrf_debug ( WARN , msg)
4910 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
4911 Status = WRF_WARN_WRITE_RONLY_FILE
4912 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
4913 call wrf_debug ( WARN , msg)
4914 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
4915 if(len(Data) < 1) then
4916 Status = WRF_WARN_ZERO_LENGTH_PUT
4920 if(DH%VarNames(NVar) == Name) then
4921 Status = WRF_WARN_2DRYRUNS_1VARIABLE
4923 elseif(DH%VarNames(NVar) == NO_NAME) then
4924 DH%VarNames(NVar) = Name
4926 elseif(NVar == MaxVars) then
4927 Status = WRF_WARN_TOO_MANY_VARIABLES
4928 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','CHAR',', line', __LINE__
4929 call wrf_debug ( WARN , msg)
4934 if(DH%DimLengths(i) == len(Data)) then
4936 elseif(DH%DimLengths(i) == NO_DIM) then
4937 stat = pio_def_dim(DH%file_handle,DH%DimNames(i),len(Data),DH%DimIDs(i))
4938 call netcdf_err(stat,Status)
4939 if(Status /= WRF_NO_ERR) then
4940 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
4941 call wrf_debug ( WARN , msg)
4944 DH%DimLengths(i) = len(Data)
4946 elseif(i == MaxDims) then
4947 Status = WRF_WARN_TOO_MANY_DIMS
4948 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,' ','CHAR',', line', __LINE__
4949 call wrf_debug ( WARN , msg)
4953 DH%VarDimLens(1,NVar) = len(Data)
4954 VDims(1) = DH%DimIDs(i)
4955 VDims(2) = DH%DimUnlimID
4956 write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
4957 write(unit=0, fmt='(3a,i6)') '11 Define Var <', trim(Var), '> as NVar:', NVar
4958 stat = pio_def_var(DH%file_handle,Name,PIO_CHAR,DH%descVar(NVar))
4959 call netcdf_err(stat,Status)
4960 if(Status /= WRF_NO_ERR) then
4961 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
4962 call wrf_debug ( WARN , msg)
4965 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
4967 if(DH%VarNames(NVar) == Name) then
4969 elseif(DH%VarNames(NVar) == NO_NAME) then
4970 Status = WRF_WARN_MD_NF
4971 write(msg,*) 'Warning METADATA NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__
4972 call wrf_debug ( WARN , msg)
4974 elseif(NVar == MaxVars) then
4975 Status = WRF_WARN_TOO_MANY_VARIABLES
4976 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,' ','CHAR',', line', __LINE__
4977 call wrf_debug ( WARN , msg)
4981 if(len(Data) > DH%VarDimLens(1,NVar)) then
4982 Status = WRF_WARN_COUNT_TOO_LONG
4983 write(msg,*) 'Warning COUNT TOO LONG in ',__FILE__,' ','CHAR',', line', __LINE__
4984 call wrf_debug ( WARN , msg)
4986 elseif(len(Data) < 1) then
4987 Status = WRF_WARN_ZERO_LENGTH_PUT
4988 write(msg,*) 'Warning ZERO LENGTH PUT in ',__FILE__,' ','CHAR',', line', __LINE__
4989 call wrf_debug ( WARN , msg)
4992 call GetTimeIndex('write',DataHandle,DateStr,TimeIndex,Status)
4993 if(Status /= WRF_NO_ERR) then
4994 write(msg,*) 'Warning in ',__FILE__,' ','CHAR',', line', __LINE__
4995 call wrf_debug ( WARN , msg)
4999 VStart(2) = TimeIndex
5000 VCount(1) = len(Data)
5003 !stat = pio_put_var(DH%file_handle,DH%descMDVar(NVar),VStart,VCount,Data)
5004 stat = pio_put_var(DH%file_handle,DH%descVar(NVar),VStart,VCount,tmpdata)
5005 call netcdf_err(stat,Status)
5006 if(Status /= WRF_NO_ERR) then
5007 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
5008 call wrf_debug ( WARN , msg)
5012 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5013 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line: ', __LINE__
5014 call wrf_debug ( FATAL , msg)
5019 end subroutine ext_pio_put_var_td_char_sca
5021 subroutine ext_pio_get_var_ti_real_arr(DataHandle,Element,Var,Data,Count,OutCount,Status)
5027 include 'wrf_status_codes.h'
5028 integer ,intent(in) :: DataHandle
5029 character*(*) ,intent(in) :: Element
5030 character*(*) ,intent(in) :: Var
5031 real, intent(out) :: Data(:)
5032 integer, intent(in) :: Count
5033 integer, intent(out) :: OutCount
5034 integer ,intent(out) :: Status
5035 type(wrf_data_handle) ,pointer :: DH
5037 real, allocatable :: Buffer(:)
5038 character (VarNameLen) :: VarName
5044 Status = WRF_WARN_ZERO_LENGTH_GET
5045 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line: ', __LINE__
5046 call wrf_debug ( WARN , msg)
5050 call GetDH(DataHandle,DH,Status)
5051 if(Status /= WRF_NO_ERR) then
5052 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line: ', __LINE__
5053 call wrf_debug ( WARN , msg)
5056 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5057 Status = WRF_WARN_FILE_NOT_OPENED
5058 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line: ', __LINE__
5059 call wrf_debug ( WARN , msg)
5060 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5061 Status = WRF_WARN_DRYRUN_READ
5062 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5063 call wrf_debug ( WARN , msg)
5064 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5065 Status = WRF_WARN_READ_WONLY_FILE
5066 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5067 call wrf_debug ( WARN , msg)
5068 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5069 do NVar=1,DH%NumVars
5070 if(DH%VarNames(NVar) == VarName) then
5072 elseif(NVar == DH%NumVars) then
5073 Status = WRF_WARN_VAR_NF
5074 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
5075 call wrf_debug ( WARN , msg)
5079 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
5080 call netcdf_err(stat,Status)
5081 if(Status /= WRF_NO_ERR) then
5082 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5083 call wrf_debug ( WARN , msg)
5085 if(XType /= PIO_REAL) then
5086 Status = WRF_WARN_TYPE_MISMATCH
5087 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5088 call wrf_debug ( WARN , msg)
5091 allocate(Buffer(XLen), STAT=stat)
5093 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5094 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5095 call wrf_debug ( FATAL , msg)
5098 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
5099 call netcdf_err(stat,Status)
5100 if(Status /= WRF_NO_ERR) then
5101 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5102 call wrf_debug ( WARN , msg)
5104 Data(1:min(XLen,Count)) = Buffer(1:min(XLen,Count))
5105 deallocate(Buffer, STAT=stat)
5107 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5108 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5109 call wrf_debug ( FATAL , msg)
5112 if(XLen > Count) then
5114 Status = WRF_WARN_MORE_DATA_IN_FILE
5120 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5121 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5122 call wrf_debug ( FATAL , msg)
5126 end subroutine ext_pio_get_var_ti_real_arr
5128 subroutine ext_pio_get_var_ti_real_sca(DataHandle,Element,Var,Data,Count,OutCount,Status)
5134 include 'wrf_status_codes.h'
5135 integer ,intent(in) :: DataHandle
5136 character*(*) ,intent(in) :: Element
5137 character*(*) ,intent(in) :: Var
5138 real, intent(out) :: Data
5139 integer, intent(in) :: Count
5140 integer, intent(out) :: OutCount
5141 integer ,intent(out) :: Status
5142 type(wrf_data_handle) ,pointer :: DH
5144 real, allocatable :: Buffer(:)
5145 character (VarNameLen) :: VarName
5151 Status = WRF_WARN_ZERO_LENGTH_GET
5152 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line: ', __LINE__
5153 call wrf_debug ( WARN , msg)
5157 call GetDH(DataHandle,DH,Status)
5158 if(Status /= WRF_NO_ERR) then
5159 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line: ', __LINE__
5160 call wrf_debug ( WARN , msg)
5163 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5164 Status = WRF_WARN_FILE_NOT_OPENED
5165 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line: ', __LINE__
5166 call wrf_debug ( WARN , msg)
5167 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5168 Status = WRF_WARN_DRYRUN_READ
5169 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5170 call wrf_debug ( WARN , msg)
5171 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5172 Status = WRF_WARN_READ_WONLY_FILE
5173 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5174 call wrf_debug ( WARN , msg)
5175 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5176 do NVar=1,DH%NumVars
5177 if(DH%VarNames(NVar) == VarName) then
5179 elseif(NVar == DH%NumVars) then
5180 Status = WRF_WARN_VAR_NF
5181 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
5182 call wrf_debug ( WARN , msg)
5186 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
5187 call netcdf_err(stat,Status)
5188 if(Status /= WRF_NO_ERR) then
5189 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5190 call wrf_debug ( WARN , msg)
5192 if(XType /= PIO_REAL) then
5193 Status = WRF_WARN_TYPE_MISMATCH
5194 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5195 call wrf_debug ( WARN , msg)
5198 allocate(Buffer(XLen), STAT=stat)
5200 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5201 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5202 call wrf_debug ( FATAL , msg)
5205 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
5206 call netcdf_err(stat,Status)
5207 if(Status /= WRF_NO_ERR) then
5208 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5209 call wrf_debug ( WARN , msg)
5212 deallocate(Buffer, STAT=stat)
5214 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5215 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5216 call wrf_debug ( FATAL , msg)
5219 if(XLen > Count) then
5221 Status = WRF_WARN_MORE_DATA_IN_FILE
5227 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5228 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5229 call wrf_debug ( FATAL , msg)
5233 end subroutine ext_pio_get_var_ti_real_sca
5235 subroutine ext_pio_get_var_td_real_arr(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
5241 include 'wrf_status_codes.h'
5242 integer ,intent(in) :: DataHandle
5243 character*(*) ,intent(in) :: Element
5244 character (DateStrLen),intent(in) :: DateStr
5245 character*(*) ,intent(in) :: Var
5246 real ,intent(out) :: Data(:)
5247 integer ,intent(in) :: Count
5248 integer ,intent(out) :: OutCount
5249 integer ,intent(out) :: Status
5250 type(wrf_data_handle) ,pointer :: DH
5251 character (VarNameLen) :: VarName
5252 character (40+len(Element)) :: Name
5253 character (40+len(Element)) :: FName
5255 real ,allocatable :: Buffer(:)
5257 integer :: VDims (2)
5258 integer :: VStart(2)
5259 integer :: VCount(2)
5261 integer :: TimeIndex
5262 integer :: DimIDs(2)
5270 Status = WRF_WARN_ZERO_LENGTH_GET
5271 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5272 call wrf_debug ( WARN , msg)
5276 call DateCheck(DateStr,Status)
5277 if(Status /= WRF_NO_ERR) then
5278 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
5279 call wrf_debug ( WARN , msg)
5282 call GetDH(DataHandle,DH,Status)
5283 if(Status /= WRF_NO_ERR) then
5284 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5285 call wrf_debug ( WARN , msg)
5288 call GetName(Element, VarName, Name, Status)
5289 if(Status /= WRF_NO_ERR) then
5290 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5291 call wrf_debug ( WARN , msg)
5294 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5295 Status = WRF_WARN_FILE_NOT_OPENED
5296 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5297 call wrf_debug ( WARN , msg)
5298 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5299 Status = WRF_WARN_DRYRUN_READ
5300 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5301 call wrf_debug ( WARN , msg)
5302 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5303 Status = WRF_WARN_READ_WONLY_FILE
5304 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5305 call wrf_debug ( WARN , msg)
5306 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5307 stat = pio_inq_varid(DH%file_handle,Name,VarID)
5308 call netcdf_err(stat,Status)
5309 if(Status /= WRF_NO_ERR) then
5310 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5311 call wrf_debug ( WARN , msg)
5314 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5315 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5316 call netcdf_err(stat,Status)
5317 if(Status /= WRF_NO_ERR) then
5318 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5319 call wrf_debug ( WARN , msg)
5322 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5323 Status = WRF_WARN_TYPE_MISMATCH
5324 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5325 call wrf_debug ( WARN , msg)
5328 if(NDims /= NMDVarDims) then
5329 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
5330 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
5331 call wrf_debug ( FATAL , msg)
5334 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
5335 call netcdf_err(stat,Status)
5336 if(Status /= WRF_NO_ERR) then
5337 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
5338 call wrf_debug ( WARN , msg)
5341 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
5342 if(Status /= WRF_NO_ERR) then
5343 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
5344 call wrf_debug ( WARN , msg)
5348 VStart(2) = TimeIndex
5349 VCount(1) = min(Count,Len1)
5351 allocate(Buffer(VCount(1)), STAT=stat)
5353 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5354 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5355 call wrf_debug ( FATAL , msg)
5358 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
5359 call netcdf_err(stat,Status)
5360 if(Status /= WRF_NO_ERR) then
5361 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
5362 call wrf_debug ( WARN , msg)
5365 Data(1:min(Len1,Count)) = Buffer(1:min(Len1,Count))
5366 deallocate(Buffer, STAT=stat)
5368 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5369 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5370 call wrf_debug ( FATAL , msg)
5373 if(Len1 > Count) then
5375 Status = WRF_WARN_MORE_DATA_IN_FILE
5381 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5382 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5383 call wrf_debug ( FATAL , msg)
5386 end subroutine ext_pio_get_var_td_real_arr
5388 subroutine ext_pio_get_var_td_real_sca(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
5394 include 'wrf_status_codes.h'
5395 integer ,intent(in) :: DataHandle
5396 character*(*) ,intent(in) :: Element
5397 character (DateStrLen),intent(in) :: DateStr
5398 character*(*) ,intent(in) :: Var
5399 real ,intent(out) :: Data
5400 integer ,intent(in) :: Count
5401 integer ,intent(out) :: OutCount
5402 integer ,intent(out) :: Status
5403 type(wrf_data_handle) ,pointer :: DH
5404 character (VarNameLen) :: VarName
5405 character (40+len(Element)) :: Name
5406 character (40+len(Element)) :: FName
5408 real ,allocatable :: Buffer(:)
5410 integer :: VDims (2)
5411 integer :: VStart(2)
5412 integer :: VCount(2)
5414 integer :: TimeIndex
5415 integer :: DimIDs(2)
5423 Status = WRF_WARN_ZERO_LENGTH_GET
5424 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5425 call wrf_debug ( WARN , msg)
5429 call DateCheck(DateStr,Status)
5430 if(Status /= WRF_NO_ERR) then
5431 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
5432 call wrf_debug ( WARN , msg)
5435 call GetDH(DataHandle,DH,Status)
5436 if(Status /= WRF_NO_ERR) then
5437 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5438 call wrf_debug ( WARN , msg)
5441 call GetName(Element, VarName, Name, Status)
5442 if(Status /= WRF_NO_ERR) then
5443 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5444 call wrf_debug ( WARN , msg)
5447 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5448 Status = WRF_WARN_FILE_NOT_OPENED
5449 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5450 call wrf_debug ( WARN , msg)
5451 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5452 Status = WRF_WARN_DRYRUN_READ
5453 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5454 call wrf_debug ( WARN , msg)
5455 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5456 Status = WRF_WARN_READ_WONLY_FILE
5457 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5458 call wrf_debug ( WARN , msg)
5459 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5460 stat = pio_inq_varid(DH%file_handle,Name,VarID)
5461 call netcdf_err(stat,Status)
5462 if(Status /= WRF_NO_ERR) then
5463 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5464 call wrf_debug ( WARN , msg)
5467 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5468 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5469 call netcdf_err(stat,Status)
5470 if(Status /= WRF_NO_ERR) then
5471 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5472 call wrf_debug ( WARN , msg)
5475 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5476 Status = WRF_WARN_TYPE_MISMATCH
5477 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5478 call wrf_debug ( WARN , msg)
5481 if(NDims /= NMDVarDims) then
5482 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
5483 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
5484 call wrf_debug ( FATAL , msg)
5487 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
5488 call netcdf_err(stat,Status)
5489 if(Status /= WRF_NO_ERR) then
5490 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
5491 call wrf_debug ( WARN , msg)
5494 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
5495 if(Status /= WRF_NO_ERR) then
5496 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
5497 call wrf_debug ( WARN , msg)
5501 VStart(2) = TimeIndex
5502 VCount(1) = min(Count,Len1)
5504 allocate(Buffer(VCount(1)), STAT=stat)
5506 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5507 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5508 call wrf_debug ( FATAL , msg)
5511 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
5512 call netcdf_err(stat,Status)
5513 if(Status /= WRF_NO_ERR) then
5514 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
5515 call wrf_debug ( WARN , msg)
5519 deallocate(Buffer, STAT=stat)
5521 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5522 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5523 call wrf_debug ( FATAL , msg)
5526 if(Len1 > Count) then
5528 Status = WRF_WARN_MORE_DATA_IN_FILE
5534 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5535 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5536 call wrf_debug ( FATAL , msg)
5539 end subroutine ext_pio_get_var_td_real_sca
5541 subroutine ext_pio_get_var_ti_double_arr(DataHandle,Element,Var,Data,Count,OutCount,Status)
5547 include 'wrf_status_codes.h'
5548 integer ,intent(in) :: DataHandle
5549 character*(*) ,intent(in) :: Element
5550 character*(*) ,intent(in) :: Var
5551 real*8, intent(out) :: Data(:)
5552 integer, intent(in) :: Count
5553 integer, intent(out) :: OutCount
5554 integer ,intent(out) :: Status
5555 type(wrf_data_handle) ,pointer :: DH
5557 real*8, allocatable :: Buffer(:)
5558 character (VarNameLen) :: VarName
5564 Status = WRF_WARN_ZERO_LENGTH_GET
5565 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5566 call wrf_debug ( WARN , msg)
5570 call GetDH(DataHandle,DH,Status)
5571 if(Status /= WRF_NO_ERR) then
5572 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5573 call wrf_debug ( WARN , msg)
5576 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5577 Status = WRF_WARN_FILE_NOT_OPENED
5578 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5579 call wrf_debug ( WARN , msg)
5580 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5581 Status = WRF_WARN_DRYRUN_READ
5582 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5583 call wrf_debug ( WARN , msg)
5584 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5585 Status = WRF_WARN_READ_WONLY_FILE
5586 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5587 call wrf_debug ( WARN , msg)
5588 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5589 do NVar=1,DH%NumVars
5590 if(DH%VarNames(NVar) == VarName) then
5592 elseif(NVar == DH%NumVars) then
5593 Status = WRF_WARN_VAR_NF
5594 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
5595 call wrf_debug ( WARN , msg)
5599 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
5600 call netcdf_err(stat,Status)
5601 if(Status /= WRF_NO_ERR) then
5602 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5603 call wrf_debug ( WARN , msg)
5605 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5606 Status = WRF_WARN_TYPE_MISMATCH
5607 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5608 call wrf_debug ( WARN , msg)
5611 allocate(Buffer(XLen), STAT=stat)
5613 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5614 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5615 call wrf_debug ( FATAL , msg)
5618 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
5619 call netcdf_err(stat,Status)
5620 if(Status /= WRF_NO_ERR) then
5621 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5622 call wrf_debug ( WARN , msg)
5624 Data(1:min(XLen,Count)) = Buffer(1:min(XLen,Count))
5625 deallocate(Buffer, STAT=stat)
5627 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5628 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5629 call wrf_debug ( FATAL , msg)
5632 if(XLen > Count) then
5634 Status = WRF_WARN_MORE_DATA_IN_FILE
5640 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5641 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5642 call wrf_debug ( FATAL , msg)
5646 end subroutine ext_pio_get_var_ti_double_arr
5648 subroutine ext_pio_get_var_ti_double_sca(DataHandle,Element,Var,Data,Count,OutCount,Status)
5654 include 'wrf_status_codes.h'
5655 integer ,intent(in) :: DataHandle
5656 character*(*) ,intent(in) :: Element
5657 character*(*) ,intent(in) :: Var
5658 real*8, intent(out) :: Data
5659 integer, intent(in) :: Count
5660 integer, intent(out) :: OutCount
5661 integer ,intent(out) :: Status
5662 type(wrf_data_handle) ,pointer :: DH
5664 real*8, allocatable :: Buffer(:)
5665 character (VarNameLen) :: VarName
5671 Status = WRF_WARN_ZERO_LENGTH_GET
5672 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5673 call wrf_debug ( WARN , msg)
5677 call GetDH(DataHandle,DH,Status)
5678 if(Status /= WRF_NO_ERR) then
5679 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5680 call wrf_debug ( WARN , msg)
5683 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5684 Status = WRF_WARN_FILE_NOT_OPENED
5685 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5686 call wrf_debug ( WARN , msg)
5687 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5688 Status = WRF_WARN_DRYRUN_READ
5689 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5690 call wrf_debug ( WARN , msg)
5691 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5692 Status = WRF_WARN_READ_WONLY_FILE
5693 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5694 call wrf_debug ( WARN , msg)
5695 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5696 do NVar=1,DH%NumVars
5697 if(DH%VarNames(NVar) == VarName) then
5699 elseif(NVar == DH%NumVars) then
5700 Status = WRF_WARN_VAR_NF
5701 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
5702 call wrf_debug ( WARN , msg)
5706 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
5707 call netcdf_err(stat,Status)
5708 if(Status /= WRF_NO_ERR) then
5709 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5710 call wrf_debug ( WARN , msg)
5712 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5713 Status = WRF_WARN_TYPE_MISMATCH
5714 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5715 call wrf_debug ( WARN , msg)
5718 allocate(Buffer(XLen), STAT=stat)
5720 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5721 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5722 call wrf_debug ( FATAL , msg)
5725 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
5726 call netcdf_err(stat,Status)
5727 if(Status /= WRF_NO_ERR) then
5728 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5729 call wrf_debug ( WARN , msg)
5732 deallocate(Buffer, STAT=stat)
5734 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5735 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5736 call wrf_debug ( FATAL , msg)
5739 if(XLen > Count) then
5741 Status = WRF_WARN_MORE_DATA_IN_FILE
5747 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5748 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5749 call wrf_debug ( FATAL , msg)
5753 end subroutine ext_pio_get_var_ti_double_sca
5755 subroutine ext_pio_get_var_td_double_arr(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
5761 include 'wrf_status_codes.h'
5762 integer ,intent(in) :: DataHandle
5763 character*(*) ,intent(in) :: Element
5764 character (DateStrLen),intent(in) :: DateStr
5765 character*(*) ,intent(in) :: Var
5766 real*8, intent(out) :: Data(:)
5767 integer, intent(in) :: Count
5768 integer, intent(out) :: OutCount
5769 integer ,intent(out) :: Status
5770 type(wrf_data_handle) ,pointer :: DH
5771 character (VarNameLen) :: VarName
5772 character (40+len(Element)) :: Name
5773 character (40+len(Element)) :: FName
5775 real*8, allocatable :: Buffer(:)
5777 integer :: VDims (2)
5778 integer :: VStart(2)
5779 integer :: VCount(2)
5781 integer :: TimeIndex
5782 integer :: DimIDs(2)
5790 Status = WRF_WARN_ZERO_LENGTH_GET
5791 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5792 call wrf_debug ( WARN , msg)
5796 call DateCheck(DateStr,Status)
5797 if(Status /= WRF_NO_ERR) then
5798 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
5799 call wrf_debug ( WARN , msg)
5802 call GetDH(DataHandle,DH,Status)
5803 if(Status /= WRF_NO_ERR) then
5804 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5805 call wrf_debug ( WARN , msg)
5808 call GetName(Element, VarName, Name, Status)
5809 if(Status /= WRF_NO_ERR) then
5810 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5811 call wrf_debug ( WARN , msg)
5814 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5815 Status = WRF_WARN_FILE_NOT_OPENED
5816 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5817 call wrf_debug ( WARN , msg)
5818 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5819 Status = WRF_WARN_DRYRUN_READ
5820 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5821 call wrf_debug ( WARN , msg)
5822 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5823 Status = WRF_WARN_READ_WONLY_FILE
5824 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5825 call wrf_debug ( WARN , msg)
5826 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5827 stat = pio_inq_varid(DH%file_handle,Name,VarID)
5828 call netcdf_err(stat,Status)
5829 if(Status /= WRF_NO_ERR) then
5830 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5831 call wrf_debug ( WARN , msg)
5834 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5835 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5836 call netcdf_err(stat,Status)
5837 if(Status /= WRF_NO_ERR) then
5838 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5839 call wrf_debug ( WARN , msg)
5842 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5843 Status = WRF_WARN_TYPE_MISMATCH
5844 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5845 call wrf_debug ( WARN , msg)
5848 if(NDims /= NMDVarDims) then
5849 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
5850 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
5851 call wrf_debug ( FATAL , msg)
5854 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
5855 call netcdf_err(stat,Status)
5856 if(Status /= WRF_NO_ERR) then
5857 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
5858 call wrf_debug ( WARN , msg)
5861 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
5862 if(Status /= WRF_NO_ERR) then
5863 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
5864 call wrf_debug ( WARN , msg)
5868 VStart(2) = TimeIndex
5869 VCount(1) = min(Count,Len1)
5871 allocate(Buffer(VCount(1)), STAT=stat)
5873 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
5874 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
5875 call wrf_debug ( FATAL , msg)
5878 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
5879 call netcdf_err(stat,Status)
5880 if(Status /= WRF_NO_ERR) then
5881 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
5882 call wrf_debug ( WARN , msg)
5885 Data(1:min(Len1,Count)) = Buffer(1:min(Len1,Count))
5886 deallocate(Buffer, STAT=stat)
5888 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
5889 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
5890 call wrf_debug ( FATAL , msg)
5893 if(Len1 > Count) then
5895 Status = WRF_WARN_MORE_DATA_IN_FILE
5901 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
5902 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
5903 call wrf_debug ( FATAL , msg)
5906 end subroutine ext_pio_get_var_td_double_arr
5908 subroutine ext_pio_get_var_td_double_sca(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
5914 include 'wrf_status_codes.h'
5915 integer ,intent(in) :: DataHandle
5916 character*(*) ,intent(in) :: Element
5917 character (DateStrLen),intent(in) :: DateStr
5918 character*(*) ,intent(in) :: Var
5919 real*8, intent(out) :: Data
5920 integer, intent(in) :: Count
5921 integer, intent(out) :: OutCount
5922 integer ,intent(out) :: Status
5923 type(wrf_data_handle) ,pointer :: DH
5924 character (VarNameLen) :: VarName
5925 character (40+len(Element)) :: Name
5926 character (40+len(Element)) :: FName
5928 real*8, allocatable :: Buffer(:)
5930 integer :: VDims (2)
5931 integer :: VStart(2)
5932 integer :: VCount(2)
5934 integer :: TimeIndex
5935 integer :: DimIDs(2)
5943 Status = WRF_WARN_ZERO_LENGTH_GET
5944 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
5945 call wrf_debug ( WARN , msg)
5949 call DateCheck(DateStr,Status)
5950 if(Status /= WRF_NO_ERR) then
5951 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
5952 call wrf_debug ( WARN , msg)
5955 call GetDH(DataHandle,DH,Status)
5956 if(Status /= WRF_NO_ERR) then
5957 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5958 call wrf_debug ( WARN , msg)
5961 call GetName(Element, VarName, Name, Status)
5962 if(Status /= WRF_NO_ERR) then
5963 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
5964 call wrf_debug ( WARN , msg)
5967 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
5968 Status = WRF_WARN_FILE_NOT_OPENED
5969 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
5970 call wrf_debug ( WARN , msg)
5971 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
5972 Status = WRF_WARN_DRYRUN_READ
5973 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
5974 call wrf_debug ( WARN , msg)
5975 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
5976 Status = WRF_WARN_READ_WONLY_FILE
5977 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
5978 call wrf_debug ( WARN , msg)
5979 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
5980 stat = pio_inq_varid(DH%file_handle,Name,VarID)
5981 call netcdf_err(stat,Status)
5982 if(Status /= WRF_NO_ERR) then
5983 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5984 call wrf_debug ( WARN , msg)
5987 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5988 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
5989 call netcdf_err(stat,Status)
5990 if(Status /= WRF_NO_ERR) then
5991 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
5992 call wrf_debug ( WARN , msg)
5995 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
5996 Status = WRF_WARN_TYPE_MISMATCH
5997 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
5998 call wrf_debug ( WARN , msg)
6001 if(NDims /= NMDVarDims) then
6002 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
6003 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
6004 call wrf_debug ( FATAL , msg)
6007 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
6008 call netcdf_err(stat,Status)
6009 if(Status /= WRF_NO_ERR) then
6010 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
6011 call wrf_debug ( WARN , msg)
6014 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
6015 if(Status /= WRF_NO_ERR) then
6016 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
6017 call wrf_debug ( WARN , msg)
6021 VStart(2) = TimeIndex
6022 VCount(1) = min(Count,Len1)
6024 allocate(Buffer(VCount(1)), STAT=stat)
6026 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6027 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
6028 call wrf_debug ( FATAL , msg)
6031 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
6032 call netcdf_err(stat,Status)
6033 if(Status /= WRF_NO_ERR) then
6034 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
6035 call wrf_debug ( WARN , msg)
6039 deallocate(Buffer, STAT=stat)
6041 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6042 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
6043 call wrf_debug ( FATAL , msg)
6046 if(Len1 > Count) then
6048 Status = WRF_WARN_MORE_DATA_IN_FILE
6054 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6055 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
6056 call wrf_debug ( FATAL , msg)
6059 end subroutine ext_pio_get_var_td_double_sca
6061 subroutine ext_pio_get_var_ti_integer_arr(DataHandle,Element,Var,Data,Count,OutCount,Status)
6067 include 'wrf_status_codes.h'
6068 integer ,intent(in) :: DataHandle
6069 character*(*) ,intent(in) :: Element
6070 character*(*) ,intent(in) :: Var
6071 integer, intent(out) :: Data(:)
6072 integer, intent(in) :: Count
6073 integer, intent(out) :: OutCount
6074 integer ,intent(out) :: Status
6075 type(wrf_data_handle) ,pointer :: DH
6077 integer, allocatable :: Buffer(:)
6078 character (VarNameLen) :: VarName
6084 Status = WRF_WARN_ZERO_LENGTH_GET
6085 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
6086 call wrf_debug ( WARN , msg)
6090 call GetDH(DataHandle,DH,Status)
6091 if(Status /= WRF_NO_ERR) then
6092 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6093 call wrf_debug ( WARN , msg)
6096 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6097 Status = WRF_WARN_FILE_NOT_OPENED
6098 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
6099 call wrf_debug ( WARN , msg)
6100 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6101 Status = WRF_WARN_DRYRUN_READ
6102 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
6103 call wrf_debug ( WARN , msg)
6104 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6105 Status = WRF_WARN_READ_WONLY_FILE
6106 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
6107 call wrf_debug ( WARN , msg)
6108 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6109 do NVar=1,DH%NumVars
6110 if(DH%VarNames(NVar) == VarName) then
6112 elseif(NVar == DH%NumVars) then
6113 Status = WRF_WARN_VAR_NF
6114 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
6115 call wrf_debug ( WARN , msg)
6119 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
6120 call netcdf_err(stat,Status)
6121 if(Status /= WRF_NO_ERR) then
6122 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6123 call wrf_debug ( WARN , msg)
6125 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
6126 Status = WRF_WARN_TYPE_MISMATCH
6127 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
6128 call wrf_debug ( WARN , msg)
6131 allocate(Buffer(XLen), STAT=stat)
6133 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6134 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
6135 call wrf_debug ( FATAL , msg)
6138 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
6139 call netcdf_err(stat,Status)
6140 if(Status /= WRF_NO_ERR) then
6141 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6142 call wrf_debug ( WARN , msg)
6144 Data(1:min(XLen,Count)) = Buffer(1:min(XLen,Count))
6145 deallocate(Buffer, STAT=stat)
6147 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6148 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
6149 call wrf_debug ( FATAL , msg)
6152 if(XLen > Count) then
6154 Status = WRF_WARN_MORE_DATA_IN_FILE
6160 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6161 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
6162 call wrf_debug ( FATAL , msg)
6166 end subroutine ext_pio_get_var_ti_integer_arr
6168 subroutine ext_pio_get_var_ti_integer_sca(DataHandle,Element,Var,Data,Count,OutCount,Status)
6174 include 'wrf_status_codes.h'
6175 integer ,intent(in) :: DataHandle
6176 character*(*) ,intent(in) :: Element
6177 character*(*) ,intent(in) :: Var
6178 integer, intent(out) :: Data
6179 integer, intent(in) :: Count
6180 integer, intent(out) :: OutCount
6181 integer ,intent(out) :: Status
6182 type(wrf_data_handle) ,pointer :: DH
6184 integer, allocatable :: Buffer(:)
6185 character (VarNameLen) :: VarName
6191 Status = WRF_WARN_ZERO_LENGTH_GET
6192 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
6193 call wrf_debug ( WARN , msg)
6197 call GetDH(DataHandle,DH,Status)
6198 if(Status /= WRF_NO_ERR) then
6199 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6200 call wrf_debug ( WARN , msg)
6203 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6204 Status = WRF_WARN_FILE_NOT_OPENED
6205 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
6206 call wrf_debug ( WARN , msg)
6207 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6208 Status = WRF_WARN_DRYRUN_READ
6209 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
6210 call wrf_debug ( WARN , msg)
6211 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6212 Status = WRF_WARN_READ_WONLY_FILE
6213 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
6214 call wrf_debug ( WARN , msg)
6215 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6216 do NVar=1,DH%NumVars
6217 if(DH%VarNames(NVar) == VarName) then
6219 elseif(NVar == DH%NumVars) then
6220 Status = WRF_WARN_VAR_NF
6221 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
6222 call wrf_debug ( WARN , msg)
6226 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
6227 call netcdf_err(stat,Status)
6228 if(Status /= WRF_NO_ERR) then
6229 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6230 call wrf_debug ( WARN , msg)
6232 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
6233 Status = WRF_WARN_TYPE_MISMATCH
6234 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
6235 call wrf_debug ( WARN , msg)
6238 allocate(Buffer(XLen), STAT=stat)
6240 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6241 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
6242 call wrf_debug ( FATAL , msg)
6245 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
6246 call netcdf_err(stat,Status)
6247 if(Status /= WRF_NO_ERR) then
6248 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6249 call wrf_debug ( WARN , msg)
6252 deallocate(Buffer, STAT=stat)
6254 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6255 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
6256 call wrf_debug ( FATAL , msg)
6259 if(XLen > Count) then
6261 Status = WRF_WARN_MORE_DATA_IN_FILE
6267 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6268 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
6269 call wrf_debug ( FATAL , msg)
6273 end subroutine ext_pio_get_var_ti_integer_sca
6275 subroutine ext_pio_get_var_td_integer_arr(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
6281 include 'wrf_status_codes.h'
6282 integer ,intent(in) :: DataHandle
6283 character*(*) ,intent(in) :: Element
6284 character (DateStrLen),intent(in) :: DateStr
6285 character*(*) ,intent(in) :: Var
6286 integer, intent(out) :: Data(:)
6287 integer, intent(in) :: Count
6288 integer, intent(out) :: OutCount
6289 integer ,intent(out) :: Status
6290 type(wrf_data_handle) ,pointer :: DH
6291 character (VarNameLen) :: VarName
6292 character (40+len(Element)) :: Name
6293 character (40+len(Element)) :: FName
6295 integer ,allocatable :: Buffer(:)
6297 integer :: VDims (2)
6298 integer :: VStart(2)
6299 integer :: VCount(2)
6301 integer :: TimeIndex
6302 integer :: DimIDs(2)
6310 Status = WRF_WARN_ZERO_LENGTH_GET
6311 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
6312 call wrf_debug ( WARN , msg)
6316 call DateCheck(DateStr,Status)
6317 if(Status /= WRF_NO_ERR) then
6318 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
6319 call wrf_debug ( WARN , msg)
6322 call GetDH(DataHandle,DH,Status)
6323 if(Status /= WRF_NO_ERR) then
6324 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6325 call wrf_debug ( WARN , msg)
6328 call GetName(Element, VarName, Name, Status)
6329 if(Status /= WRF_NO_ERR) then
6330 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6331 call wrf_debug ( WARN , msg)
6334 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6335 Status = WRF_WARN_FILE_NOT_OPENED
6336 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
6337 call wrf_debug ( WARN , msg)
6338 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6339 Status = WRF_WARN_DRYRUN_READ
6340 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
6341 call wrf_debug ( WARN , msg)
6342 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6343 Status = WRF_WARN_READ_WONLY_FILE
6344 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
6345 call wrf_debug ( WARN , msg)
6346 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6347 stat = pio_inq_varid(DH%file_handle,Name,VarID)
6348 call netcdf_err(stat,Status)
6349 if(Status /= WRF_NO_ERR) then
6350 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6351 call wrf_debug ( WARN , msg)
6354 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
6355 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
6356 call netcdf_err(stat,Status)
6357 if(Status /= WRF_NO_ERR) then
6358 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6359 call wrf_debug ( WARN , msg)
6362 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
6363 Status = WRF_WARN_TYPE_MISMATCH
6364 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
6365 call wrf_debug ( WARN , msg)
6368 if(NDims /= NMDVarDims) then
6369 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
6370 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
6371 call wrf_debug ( FATAL , msg)
6374 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
6375 call netcdf_err(stat,Status)
6376 if(Status /= WRF_NO_ERR) then
6377 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
6378 call wrf_debug ( WARN , msg)
6381 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
6382 if(Status /= WRF_NO_ERR) then
6383 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
6384 call wrf_debug ( WARN , msg)
6388 VStart(2) = TimeIndex
6389 VCount(1) = min(Count,Len1)
6391 allocate(Buffer(VCount(1)), STAT=stat)
6393 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6394 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
6395 call wrf_debug ( FATAL , msg)
6398 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
6399 call netcdf_err(stat,Status)
6400 if(Status /= WRF_NO_ERR) then
6401 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
6402 call wrf_debug ( WARN , msg)
6405 Data(1:min(Len1,Count)) = Buffer(1:min(Len1,Count))
6406 deallocate(Buffer, STAT=stat)
6408 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6409 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
6410 call wrf_debug ( FATAL , msg)
6413 if(Len1 > Count) then
6415 Status = WRF_WARN_MORE_DATA_IN_FILE
6421 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6422 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
6423 call wrf_debug ( FATAL , msg)
6426 end subroutine ext_pio_get_var_td_integer_arr
6428 subroutine ext_pio_get_var_td_integer_sca(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
6434 include 'wrf_status_codes.h'
6435 integer ,intent(in) :: DataHandle
6436 character*(*) ,intent(in) :: Element
6437 character (DateStrLen),intent(in) :: DateStr
6438 character*(*) ,intent(in) :: Var
6439 integer, intent(out) :: Data
6440 integer, intent(in) :: Count
6441 integer, intent(out) :: OutCount
6442 integer ,intent(out) :: Status
6443 type(wrf_data_handle) ,pointer :: DH
6444 character (VarNameLen) :: VarName
6445 character (40+len(Element)) :: Name
6446 character (40+len(Element)) :: FName
6448 integer ,allocatable :: Buffer(:)
6450 integer :: VDims (2)
6451 integer :: VStart(2)
6452 integer :: VCount(2)
6454 integer :: TimeIndex
6455 integer :: DimIDs(2)
6463 Status = WRF_WARN_ZERO_LENGTH_GET
6464 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,', line', __LINE__
6465 call wrf_debug ( WARN , msg)
6469 call DateCheck(DateStr,Status)
6470 if(Status /= WRF_NO_ERR) then
6471 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
6472 call wrf_debug ( WARN , msg)
6475 call GetDH(DataHandle,DH,Status)
6476 if(Status /= WRF_NO_ERR) then
6477 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6478 call wrf_debug ( WARN , msg)
6481 call GetName(Element, VarName, Name, Status)
6482 if(Status /= WRF_NO_ERR) then
6483 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
6484 call wrf_debug ( WARN , msg)
6487 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6488 Status = WRF_WARN_FILE_NOT_OPENED
6489 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
6490 call wrf_debug ( WARN , msg)
6491 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6492 Status = WRF_WARN_DRYRUN_READ
6493 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
6494 call wrf_debug ( WARN , msg)
6495 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6496 Status = WRF_WARN_READ_WONLY_FILE
6497 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,', line', __LINE__
6498 call wrf_debug ( WARN , msg)
6499 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6500 stat = pio_inq_varid(DH%file_handle,Name,VarID)
6501 call netcdf_err(stat,Status)
6502 if(Status /= WRF_NO_ERR) then
6503 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6504 call wrf_debug ( WARN , msg)
6507 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
6508 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
6509 call netcdf_err(stat,Status)
6510 if(Status /= WRF_NO_ERR) then
6511 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Element ',Element
6512 call wrf_debug ( WARN , msg)
6515 if( .NOT. ( XType==PIO_REAL .OR. XType==PIO_DOUBLE) ) then
6516 Status = WRF_WARN_TYPE_MISMATCH
6517 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
6518 call wrf_debug ( WARN , msg)
6521 if(NDims /= NMDVarDims) then
6522 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
6523 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,', line', __LINE__
6524 call wrf_debug ( FATAL , msg)
6527 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
6528 call netcdf_err(stat,Status)
6529 if(Status /= WRF_NO_ERR) then
6530 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' DimIDs(1) ',DimIDs(1)
6531 call wrf_debug ( WARN , msg)
6534 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
6535 if(Status /= WRF_NO_ERR) then
6536 write(msg,*) 'Warning in ',__FILE__,', line', __LINE__
6537 call wrf_debug ( WARN , msg)
6541 VStart(2) = TimeIndex
6542 VCount(1) = min(Count,Len1)
6544 allocate(Buffer(VCount(1)), STAT=stat)
6546 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6547 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
6548 call wrf_debug ( FATAL , msg)
6551 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
6552 call netcdf_err(stat,Status)
6553 if(Status /= WRF_NO_ERR) then
6554 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
6555 call wrf_debug ( WARN , msg)
6559 deallocate(Buffer, STAT=stat)
6561 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6562 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
6563 call wrf_debug ( FATAL , msg)
6566 if(Len1 > Count) then
6568 Status = WRF_WARN_MORE_DATA_IN_FILE
6574 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6575 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
6576 call wrf_debug ( FATAL , msg)
6579 end subroutine ext_pio_get_var_td_integer_sca
6581 subroutine ext_pio_get_var_ti_logical_arr(DataHandle,Element,Var,Data,Count,OutCount,Status)
6587 include 'wrf_status_codes.h'
6588 integer ,intent(in) :: DataHandle
6589 character*(*) ,intent(in) :: Element
6590 character*(*) ,intent(in) :: Var
6591 logical, intent(out) :: Data(:)
6592 integer, intent(in) :: Count
6593 integer, intent(out) :: OutCount
6594 integer ,intent(out) :: Status
6595 type(wrf_data_handle) ,pointer :: DH
6597 integer, allocatable :: Buffer(:)
6598 character (VarNameLen) :: VarName
6604 Status = WRF_WARN_ZERO_LENGTH_GET
6605 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','LOGICAL',', line', __LINE__
6606 call wrf_debug ( WARN , msg)
6610 call GetDH(DataHandle,DH,Status)
6611 if(Status /= WRF_NO_ERR) then
6612 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
6613 call wrf_debug ( WARN , msg)
6616 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6617 Status = WRF_WARN_FILE_NOT_OPENED
6618 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
6619 call wrf_debug ( WARN , msg)
6620 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6621 Status = WRF_WARN_DRYRUN_READ
6622 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
6623 call wrf_debug ( WARN , msg)
6624 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6625 Status = WRF_WARN_READ_WONLY_FILE
6626 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
6627 call wrf_debug ( WARN , msg)
6628 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6629 do NVar=1,DH%NumVars
6630 if(DH%VarNames(NVar) == VarName) then
6632 elseif(NVar == DH%NumVars) then
6633 Status = WRF_WARN_VAR_NF
6634 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__
6635 call wrf_debug ( WARN , msg)
6639 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
6640 call netcdf_err(stat,Status)
6641 if(Status /= WRF_NO_ERR) then
6642 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6643 call wrf_debug ( WARN , msg)
6645 if(XType /= PIO_INT) then
6646 Status = WRF_WARN_TYPE_MISMATCH
6647 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__
6648 call wrf_debug ( WARN , msg)
6651 allocate(Buffer(XLen), STAT=stat)
6653 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6654 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6655 call wrf_debug ( FATAL , msg)
6658 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
6659 call netcdf_err(stat,Status)
6660 if(Status /= WRF_NO_ERR) then
6661 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6662 call wrf_debug ( WARN , msg)
6664 Data(1:min(XLen,Count)) = Buffer(1:min(XLen,Count))==1
6665 deallocate(Buffer, STAT=stat)
6667 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6668 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6669 call wrf_debug ( FATAL , msg)
6672 if(XLen > Count) then
6674 Status = WRF_WARN_MORE_DATA_IN_FILE
6680 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6681 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
6682 call wrf_debug ( FATAL , msg)
6686 end subroutine ext_pio_get_var_ti_logical_arr
6688 subroutine ext_pio_get_var_ti_logical_sca(DataHandle,Element,Var,Data,Count,OutCount,Status)
6694 include 'wrf_status_codes.h'
6695 integer ,intent(in) :: DataHandle
6696 character*(*) ,intent(in) :: Element
6697 character*(*) ,intent(in) :: Var
6698 logical, intent(out) :: Data
6699 integer, intent(in) :: Count
6700 integer, intent(out) :: OutCount
6701 integer ,intent(out) :: Status
6702 type(wrf_data_handle) ,pointer :: DH
6704 integer, allocatable :: Buffer(:)
6705 character (VarNameLen) :: VarName
6711 Status = WRF_WARN_ZERO_LENGTH_GET
6712 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','LOGICAL',', line', __LINE__
6713 call wrf_debug ( WARN , msg)
6717 call GetDH(DataHandle,DH,Status)
6718 if(Status /= WRF_NO_ERR) then
6719 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
6720 call wrf_debug ( WARN , msg)
6723 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6724 Status = WRF_WARN_FILE_NOT_OPENED
6725 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
6726 call wrf_debug ( WARN , msg)
6727 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6728 Status = WRF_WARN_DRYRUN_READ
6729 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
6730 call wrf_debug ( WARN , msg)
6731 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6732 Status = WRF_WARN_READ_WONLY_FILE
6733 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
6734 call wrf_debug ( WARN , msg)
6735 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6736 do NVar=1,DH%NumVars
6737 if(DH%VarNames(NVar) == VarName) then
6739 elseif(NVar == DH%NumVars) then
6740 Status = WRF_WARN_VAR_NF
6741 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','LOGICAL',', line', __LINE__
6742 call wrf_debug ( WARN , msg)
6746 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
6747 call netcdf_err(stat,Status)
6748 if(Status /= WRF_NO_ERR) then
6749 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6750 call wrf_debug ( WARN , msg)
6752 if(XType /= PIO_INT) then
6753 Status = WRF_WARN_TYPE_MISMATCH
6754 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__
6755 call wrf_debug ( WARN , msg)
6758 allocate(Buffer(XLen), STAT=stat)
6760 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6761 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6762 call wrf_debug ( FATAL , msg)
6765 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Buffer )
6766 call netcdf_err(stat,Status)
6767 if(Status /= WRF_NO_ERR) then
6768 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6769 call wrf_debug ( WARN , msg)
6772 deallocate(Buffer, STAT=stat)
6774 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6775 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6776 call wrf_debug ( FATAL , msg)
6779 if(XLen > Count) then
6781 Status = WRF_WARN_MORE_DATA_IN_FILE
6787 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6788 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
6789 call wrf_debug ( FATAL , msg)
6793 end subroutine ext_pio_get_var_ti_logical_sca
6795 subroutine ext_pio_get_var_td_logical_arr(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
6801 include 'wrf_status_codes.h'
6802 integer ,intent(in) :: DataHandle
6803 character*(*) ,intent(in) :: Element
6804 character (DateStrLen),intent(in) :: DateStr
6805 character*(*) ,intent(in) :: Var
6806 logical, intent(out) :: Data(:)
6807 integer, intent(in) :: Count
6808 integer, intent(out) :: OutCount
6809 integer ,intent(out) :: Status
6810 type(wrf_data_handle) ,pointer :: DH
6811 character (VarNameLen) :: VarName
6812 character (40+len(Element)) :: Name
6813 character (40+len(Element)) :: FName
6815 integer ,allocatable :: Buffer(:)
6817 integer :: VDims (2)
6818 integer :: VStart(2)
6819 integer :: VCount(2)
6821 integer :: TimeIndex
6822 integer :: DimIDs(2)
6830 Status = WRF_WARN_ZERO_LENGTH_GET
6831 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','LOGICAL',', line', __LINE__
6832 call wrf_debug ( WARN , msg)
6836 call DateCheck(DateStr,Status)
6837 if(Status /= WRF_NO_ERR) then
6838 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6839 call wrf_debug ( WARN , msg)
6842 call GetDH(DataHandle,DH,Status)
6843 if(Status /= WRF_NO_ERR) then
6844 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
6845 call wrf_debug ( WARN , msg)
6848 call GetName(Element, VarName, Name, Status)
6849 if(Status /= WRF_NO_ERR) then
6850 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
6851 call wrf_debug ( WARN , msg)
6854 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
6855 Status = WRF_WARN_FILE_NOT_OPENED
6856 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
6857 call wrf_debug ( WARN , msg)
6858 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
6859 Status = WRF_WARN_DRYRUN_READ
6860 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
6861 call wrf_debug ( WARN , msg)
6862 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
6863 Status = WRF_WARN_READ_WONLY_FILE
6864 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
6865 call wrf_debug ( WARN , msg)
6866 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
6867 stat = pio_inq_varid(DH%file_handle,Name,VarID)
6868 call netcdf_err(stat,Status)
6869 if(Status /= WRF_NO_ERR) then
6870 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6871 call wrf_debug ( WARN , msg)
6874 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
6875 call netcdf_err(stat,Status)
6876 if(Status /= WRF_NO_ERR) then
6877 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
6878 call wrf_debug ( WARN , msg)
6881 if(XType /= PIO_INT) then
6882 Status = WRF_WARN_TYPE_MISMATCH
6883 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__
6884 call wrf_debug ( WARN , msg)
6887 if(NDims /= NMDVarDims) then
6888 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
6889 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,' ','LOGICAL',', line', __LINE__
6890 call wrf_debug ( FATAL , msg)
6893 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
6894 call netcdf_err(stat,Status)
6895 if(Status /= WRF_NO_ERR) then
6896 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' DimIDs(1) ',DimIDs(1)
6897 call wrf_debug ( WARN , msg)
6900 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
6901 if(Status /= WRF_NO_ERR) then
6902 write(msg,*) 'Warning in ',__FILE__,' ','LOGICAL',', line', __LINE__
6903 call wrf_debug ( WARN , msg)
6907 VStart(2) = TimeIndex
6908 VCount(1) = min(Count,Len1)
6910 allocate(Buffer(VCount(1)), STAT=stat)
6912 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
6913 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6914 call wrf_debug ( FATAL , msg)
6917 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
6918 call netcdf_err(stat,Status)
6919 if(Status /= WRF_NO_ERR) then
6920 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__
6921 call wrf_debug ( WARN , msg)
6924 Data(1:min(Len1,Count)) = Buffer(1:min(Len1,Count))==1
6925 deallocate(Buffer, STAT=stat)
6927 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
6928 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6929 call wrf_debug ( FATAL , msg)
6932 if(Len1 > Count) then
6934 Status = WRF_WARN_MORE_DATA_IN_FILE
6940 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
6941 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
6942 call wrf_debug ( FATAL , msg)
6945 end subroutine ext_pio_get_var_td_logical_arr
6947 subroutine ext_pio_get_var_td_logical_sca(DataHandle,Element,DateStr,Var,Data,Count,OutCount,Status)
6953 include 'wrf_status_codes.h'
6954 integer ,intent(in) :: DataHandle
6955 character*(*) ,intent(in) :: Element
6956 character (DateStrLen),intent(in) :: DateStr
6957 character*(*) ,intent(in) :: Var
6958 logical, intent(out) :: Data
6959 integer, intent(in) :: Count
6960 integer, intent(out) :: OutCount
6961 integer ,intent(out) :: Status
6962 type(wrf_data_handle) ,pointer :: DH
6963 character (VarNameLen) :: VarName
6964 character (40+len(Element)) :: Name
6965 character (40+len(Element)) :: FName
6967 integer ,allocatable :: Buffer(:)
6969 integer :: VDims (2)
6970 integer :: VStart(2)
6971 integer :: VCount(2)
6973 integer :: TimeIndex
6974 integer :: DimIDs(2)
6982 Status = WRF_WARN_ZERO_LENGTH_GET
6983 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','LOGICAL',', line', __LINE__
6984 call wrf_debug ( WARN , msg)
6988 call DateCheck(DateStr,Status)
6989 if(Status /= WRF_NO_ERR) then
6990 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
6991 call wrf_debug ( WARN , msg)
6994 call GetDH(DataHandle,DH,Status)
6995 if(Status /= WRF_NO_ERR) then
6996 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
6997 call wrf_debug ( WARN , msg)
7000 call GetName(Element, VarName, Name, Status)
7001 if(Status /= WRF_NO_ERR) then
7002 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','LOGICAL',', line', __LINE__
7003 call wrf_debug ( WARN , msg)
7006 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7007 Status = WRF_WARN_FILE_NOT_OPENED
7008 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','LOGICAL',', line', __LINE__
7009 call wrf_debug ( WARN , msg)
7010 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7011 Status = WRF_WARN_DRYRUN_READ
7012 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','LOGICAL',', line', __LINE__
7013 call wrf_debug ( WARN , msg)
7014 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
7015 Status = WRF_WARN_READ_WONLY_FILE
7016 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','LOGICAL',', line', __LINE__
7017 call wrf_debug ( WARN , msg)
7018 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7019 stat = pio_inq_varid(DH%file_handle,Name,VarID)
7020 call netcdf_err(stat,Status)
7021 if(Status /= WRF_NO_ERR) then
7022 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
7023 call wrf_debug ( WARN , msg)
7026 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
7027 call netcdf_err(stat,Status)
7028 if(Status /= WRF_NO_ERR) then
7029 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' Element ',Element
7030 call wrf_debug ( WARN , msg)
7033 if(XType /= PIO_INT) then
7034 Status = WRF_WARN_TYPE_MISMATCH
7035 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','LOGICAL',', line', __LINE__
7036 call wrf_debug ( WARN , msg)
7039 if(NDims /= NMDVarDims) then
7040 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
7041 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,' ','LOGICAL',', line', __LINE__
7042 call wrf_debug ( FATAL , msg)
7045 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
7046 call netcdf_err(stat,Status)
7047 if(Status /= WRF_NO_ERR) then
7048 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__,' DimIDs(1) ',DimIDs(1)
7049 call wrf_debug ( WARN , msg)
7052 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
7053 if(Status /= WRF_NO_ERR) then
7054 write(msg,*) 'Warning in ',__FILE__,' ','LOGICAL',', line', __LINE__
7055 call wrf_debug ( WARN , msg)
7059 VStart(2) = TimeIndex
7060 VCount(1) = min(Count,Len1)
7062 allocate(Buffer(VCount(1)), STAT=stat)
7064 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
7065 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
7066 call wrf_debug ( FATAL , msg)
7069 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
7070 call netcdf_err(stat,Status)
7071 if(Status /= WRF_NO_ERR) then
7072 write(msg,*) 'NetCDF error in ',__FILE__,' ','LOGICAL',', line', __LINE__
7073 call wrf_debug ( WARN , msg)
7077 deallocate(Buffer, STAT=stat)
7079 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
7080 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ','LOGICAL',', line', __LINE__
7081 call wrf_debug ( FATAL , msg)
7084 if(Len1 > Count) then
7086 Status = WRF_WARN_MORE_DATA_IN_FILE
7092 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
7093 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','LOGICAL',', line', __LINE__
7094 call wrf_debug ( FATAL , msg)
7097 end subroutine ext_pio_get_var_td_logical_sca
7099 subroutine ext_pio_get_var_ti_char_arr(DataHandle,Element,Var,Data,Status)
7105 include 'wrf_status_codes.h'
7106 integer ,intent(in) :: DataHandle
7107 character*(*) ,intent(in) :: Element
7108 character*(*) ,intent(in) :: Var
7109 character*(*) ,intent(out) :: Data
7110 integer :: Count = 1
7112 integer ,intent(out) :: Status
7113 type(wrf_data_handle) ,pointer :: DH
7116 character (VarNameLen) :: VarName
7122 Status = WRF_WARN_ZERO_LENGTH_GET
7123 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','CHAR',', line', __LINE__
7124 call wrf_debug ( WARN , msg)
7128 call GetDH(DataHandle,DH,Status)
7129 if(Status /= WRF_NO_ERR) then
7130 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7131 call wrf_debug ( WARN , msg)
7134 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7135 Status = WRF_WARN_FILE_NOT_OPENED
7136 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
7137 call wrf_debug ( WARN , msg)
7138 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7139 Status = WRF_WARN_DRYRUN_READ
7140 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
7141 call wrf_debug ( WARN , msg)
7142 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
7143 Status = WRF_WARN_READ_WONLY_FILE
7144 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
7145 call wrf_debug ( WARN , msg)
7146 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7147 do NVar=1,DH%NumVars
7148 if(DH%VarNames(NVar) == VarName) then
7150 elseif(NVar == DH%NumVars) then
7151 Status = WRF_WARN_VAR_NF
7152 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__
7153 call wrf_debug ( WARN , msg)
7157 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
7158 call netcdf_err(stat,Status)
7159 if(Status /= WRF_NO_ERR) then
7160 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7161 call wrf_debug ( WARN , msg)
7163 if(XType /= PIO_CHAR) then
7164 Status = WRF_WARN_TYPE_MISMATCH
7165 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','CHAR',', line', __LINE__
7168 if(XLen > len(Data)) then
7169 Status = WRF_WARN_CHARSTR_GT_LENDATA
7170 write(msg,*) 'Warning LEN CHAR STRING > LEN DATA in ',__FILE__,' ','CHAR',', line', __LINE__
7171 call wrf_debug ( WARN , msg)
7174 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Data )
7175 call netcdf_err(stat,Status)
7176 if(Status /= WRF_NO_ERR) then
7177 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7178 call wrf_debug ( WARN , msg)
7182 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
7183 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
7184 call wrf_debug ( FATAL , msg)
7188 end subroutine ext_pio_get_var_ti_char_arr
7190 subroutine ext_pio_get_var_ti_char_sca(DataHandle,Element,Var,Data,Status)
7196 include 'wrf_status_codes.h'
7197 integer ,intent(in) :: DataHandle
7198 character*(*) ,intent(in) :: Element
7199 character*(*) ,intent(in) :: Var
7200 character*(*) ,intent(out) :: Data
7201 integer :: Count = 1
7203 integer ,intent(out) :: Status
7204 type(wrf_data_handle) ,pointer :: DH
7207 character (VarNameLen) :: VarName
7213 Status = WRF_WARN_ZERO_LENGTH_GET
7214 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','CHAR',', line', __LINE__
7215 call wrf_debug ( WARN , msg)
7219 call GetDH(DataHandle,DH,Status)
7220 if(Status /= WRF_NO_ERR) then
7221 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7222 call wrf_debug ( WARN , msg)
7225 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7226 Status = WRF_WARN_FILE_NOT_OPENED
7227 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
7228 call wrf_debug ( WARN , msg)
7229 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7230 Status = WRF_WARN_DRYRUN_READ
7231 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
7232 call wrf_debug ( WARN , msg)
7233 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
7234 Status = WRF_WARN_READ_WONLY_FILE
7235 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
7236 call wrf_debug ( WARN , msg)
7237 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7238 do NVar=1,DH%NumVars
7239 if(DH%VarNames(NVar) == VarName) then
7241 elseif(NVar == DH%NumVars) then
7242 Status = WRF_WARN_VAR_NF
7243 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,' ','CHAR',', line', __LINE__
7244 call wrf_debug ( WARN , msg)
7248 stat = pio_inq_att(DH%file_handle,DH%descVar(NVar),trim(Element),XType,XLen)
7249 call netcdf_err(stat,Status)
7250 if(Status /= WRF_NO_ERR) then
7251 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7252 call wrf_debug ( WARN , msg)
7254 if(XType /= PIO_CHAR) then
7255 Status = WRF_WARN_TYPE_MISMATCH
7256 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','CHAR',', line', __LINE__
7259 if(XLen > len(Data)) then
7260 Status = WRF_WARN_CHARSTR_GT_LENDATA
7261 write(msg,*) 'Warning LEN CHAR STRING > LEN DATA in ',__FILE__,' ','CHAR',', line', __LINE__
7262 call wrf_debug ( WARN , msg)
7265 stat = pio_get_att(DH%file_handle,DH%descVar(NVar),trim(Element), Data )
7266 call netcdf_err(stat,Status)
7267 if(Status /= WRF_NO_ERR) then
7268 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7269 call wrf_debug ( WARN , msg)
7273 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
7274 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
7275 call wrf_debug ( FATAL , msg)
7279 end subroutine ext_pio_get_var_ti_char_sca
7281 subroutine ext_pio_get_var_td_char_arr(DataHandle,Element,DateStr,Var,Data,Status)
7287 include 'wrf_status_codes.h'
7288 integer ,intent(in) :: DataHandle
7289 character*(*) ,intent(in) :: Element
7290 character (DateStrLen),intent(in) :: DateStr
7291 character*(*) ,intent(in) :: Var
7292 character*(*) ,intent(out) :: Data
7294 integer ,intent(out) :: Status
7295 type(wrf_data_handle) ,pointer :: DH
7296 character (VarNameLen) :: VarName
7297 character (40+len(Element)) :: Name
7298 character (40+len(Element)) :: FName
7301 integer :: VDims (2)
7302 integer :: VStart(2)
7303 integer :: VCount(2)
7305 integer :: TimeIndex
7306 integer :: DimIDs(2)
7312 integer, parameter :: Count = 1
7313 character(DateStrLen) :: Buffer(1)
7316 Status = WRF_WARN_ZERO_LENGTH_GET
7317 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','CHAR',', line', __LINE__
7318 call wrf_debug ( WARN , msg)
7322 call DateCheck(DateStr,Status)
7323 if(Status /= WRF_NO_ERR) then
7324 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','CHAR',', line', __LINE__
7325 call wrf_debug ( WARN , msg)
7328 call GetDH(DataHandle,DH,Status)
7329 if(Status /= WRF_NO_ERR) then
7330 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7331 call wrf_debug ( WARN , msg)
7334 call GetName(Element, VarName, Name, Status)
7335 if(Status /= WRF_NO_ERR) then
7336 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7337 call wrf_debug ( WARN , msg)
7340 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7341 Status = WRF_WARN_FILE_NOT_OPENED
7342 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
7343 call wrf_debug ( WARN , msg)
7344 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7345 Status = WRF_WARN_DRYRUN_READ
7346 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
7347 call wrf_debug ( WARN , msg)
7348 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
7349 Status = WRF_WARN_READ_WONLY_FILE
7350 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
7351 call wrf_debug ( WARN , msg)
7352 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7353 stat = pio_inq_varid(DH%file_handle,Name,VarID)
7354 call netcdf_err(stat,Status)
7355 if(Status /= WRF_NO_ERR) then
7356 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7357 call wrf_debug ( WARN , msg)
7360 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
7361 call netcdf_err(stat,Status)
7362 if(Status /= WRF_NO_ERR) then
7363 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7364 call wrf_debug ( WARN , msg)
7367 if(XType /= PIO_CHAR) then
7368 Status = WRF_WARN_TYPE_MISMATCH
7369 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','CHAR',', line', __LINE__
7370 call wrf_debug ( WARN , msg)
7373 if(NDims /= NMDVarDims) then
7374 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
7375 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,' ','CHAR',', line', __LINE__
7376 call wrf_debug ( FATAL , msg)
7379 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
7380 call netcdf_err(stat,Status)
7381 if(Status /= WRF_NO_ERR) then
7382 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' DimIDs(1) ',DimIDs(1)
7383 call wrf_debug ( WARN , msg)
7386 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
7387 if(Status /= WRF_NO_ERR) then
7388 write(msg,*) 'Warning in ',__FILE__,' ','CHAR',', line', __LINE__
7389 call wrf_debug ( WARN , msg)
7393 VStart(2) = TimeIndex
7396 if(Len1 > len(Data)) then
7397 Status = WRF_WARN_CHARSTR_GT_LENDATA
7398 write(msg,*) 'Warning LEN CHAR STRING > LEN DATA in ',__FILE__,' ','CHAR',', line', __LINE__
7399 call wrf_debug ( WARN , msg)
7403 stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Buffer)
7404 !stat = pio_get_var(DH%file_handle,VarID,Buffer)
7405 call netcdf_err(stat,Status)
7406 if(Status /= WRF_NO_ERR) then
7407 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__
7408 call wrf_debug ( WARN , msg)
7413 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
7414 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
7417 end subroutine ext_pio_get_var_td_char_arr
7419 subroutine ext_pio_get_var_td_char_sca(DataHandle,Element,DateStr,Var,Data,Status)
7425 include 'wrf_status_codes.h'
7426 integer ,intent(in) :: DataHandle
7427 character*(*) ,intent(in) :: Element
7428 character (DateStrLen),intent(in) :: DateStr
7429 character*(*) ,intent(in) :: Var
7430 character*(*) ,intent(out) :: Data
7432 integer ,intent(out) :: Status
7433 type(wrf_data_handle) ,pointer :: DH
7434 character (VarNameLen) :: VarName
7435 character (40+len(Element)) :: Name
7436 character (40+len(Element)) :: FName
7438 character (80) ,allocatable :: Buffer(:)
7440 integer :: VDims (2)
7441 integer :: VStart(2)
7442 integer :: VCount(2)
7444 integer :: TimeIndex
7445 integer :: DimIDs(2)
7451 integer, parameter :: Count = 1
7454 Status = WRF_WARN_ZERO_LENGTH_GET
7455 write(msg,*) 'Warning ZERO LENGTH GET in ',__FILE__,' ','CHAR',', line', __LINE__
7456 call wrf_debug ( WARN , msg)
7460 call DateCheck(DateStr,Status)
7461 if(Status /= WRF_NO_ERR) then
7462 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,' ','CHAR',', line', __LINE__
7463 call wrf_debug ( WARN , msg)
7466 call GetDH(DataHandle,DH,Status)
7467 if(Status /= WRF_NO_ERR) then
7468 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7469 call wrf_debug ( WARN , msg)
7472 call GetName(Element, VarName, Name, Status)
7473 if(Status /= WRF_NO_ERR) then
7474 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,' ','CHAR',', line', __LINE__
7475 call wrf_debug ( WARN , msg)
7478 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7479 Status = WRF_WARN_FILE_NOT_OPENED
7480 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,' ','CHAR',', line', __LINE__
7481 call wrf_debug ( WARN , msg)
7482 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7483 Status = WRF_WARN_DRYRUN_READ
7484 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,' ','CHAR',', line', __LINE__
7485 call wrf_debug ( WARN , msg)
7486 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
7487 Status = WRF_WARN_READ_WONLY_FILE
7488 write(msg,*) 'Warning READ WONLY FILE in ',__FILE__,' ','CHAR',', line', __LINE__
7489 call wrf_debug ( WARN , msg)
7490 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7491 stat = pio_inq_varid(DH%file_handle,Name,VarID)
7492 call netcdf_err(stat,Status)
7493 if(Status /= WRF_NO_ERR) then
7494 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7495 call wrf_debug ( WARN , msg)
7498 !stat = NFMPI_INQ_VAR(file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
7499 stat = pio_inquire_variable(DH%file_handle,VarID,FName,XType,NDims,DimIDs,NAtts)
7500 call netcdf_err(stat,Status)
7501 if(Status /= WRF_NO_ERR) then
7502 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' Element ',Element
7503 call wrf_debug ( WARN , msg)
7506 if(XType /= PIO_CHAR) then
7507 Status = WRF_WARN_TYPE_MISMATCH
7508 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,' ','CHAR',', line', __LINE__
7509 call wrf_debug ( WARN , msg)
7512 if(NDims /= NMDVarDims) then
7513 Status = WRF_ERR_FATAL_MDVAR_DIM_NOT_1D
7514 write(msg,*) 'Fatal MDVAR DIM NOT 1D in ',__FILE__,' ','CHAR',', line', __LINE__
7515 call wrf_debug ( FATAL , msg)
7518 stat = pio_inq_dimlen(DH%file_handle,DimIDs(1),Len1)
7519 call netcdf_err(stat,Status)
7520 if(Status /= WRF_NO_ERR) then
7521 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__,' DimIDs(1) ',DimIDs(1)
7522 call wrf_debug ( WARN , msg)
7525 call GetTimeIndex('read',DataHandle,DateStr,TimeIndex,Status)
7526 if(Status /= WRF_NO_ERR) then
7527 write(msg,*) 'Warning in ',__FILE__,' ','CHAR',', line', __LINE__
7528 call wrf_debug ( WARN , msg)
7532 VStart(2) = TimeIndex
7535 if(Len1 > len(Data)) then
7536 Status = WRF_WARN_CHARSTR_GT_LENDATA
7537 write(msg,*) 'Warning LEN CHAR STRING > LEN DATA in ',__FILE__,' ','CHAR',', line', __LINE__
7538 call wrf_debug ( WARN , msg)
7542 !stat = pio_get_var(DH%file_handle,VarID,VStart,VCount,Data)
7543 stat = pio_get_var(DH%file_handle,VarID,Data)
7544 call netcdf_err(stat,Status)
7545 if(Status /= WRF_NO_ERR) then
7546 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__
7547 call wrf_debug ( WARN , msg)
7551 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
7552 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,' ','CHAR',', line', __LINE__
7555 end subroutine ext_pio_get_var_td_char_sca
7557 subroutine ext_pio_put_dom_td_real_arr(DataHandle,Element,DateStr,Data,Count,Status)
7558 integer ,intent(in) :: DataHandle
7559 character*(*) ,intent(in) :: Element
7560 character*(*) ,intent(in) :: DateStr
7561 real ,intent(in) :: Data(:)
7562 integer ,intent(in) :: Count
7563 integer ,intent(out) :: Status
7565 call ext_pio_put_var_td_real_arr(DataHandle,Element,DateStr, &
7566 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7568 end subroutine ext_pio_put_dom_td_real_arr
7570 subroutine ext_pio_put_dom_td_real_sca(DataHandle,Element,DateStr,Data,Count,Status)
7571 integer ,intent(in) :: DataHandle
7572 character*(*) ,intent(in) :: Element
7573 character*(*) ,intent(in) :: DateStr
7574 real ,intent(in) :: Data
7575 integer ,intent(in) :: Count
7576 integer ,intent(out) :: Status
7578 call ext_pio_put_var_td_real_sca(DataHandle,Element,DateStr, &
7579 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7581 end subroutine ext_pio_put_dom_td_real_sca
7583 subroutine ext_pio_put_dom_td_integer_arr(DataHandle,Element,DateStr,Data,Count,Status)
7584 integer ,intent(in) :: DataHandle
7585 character*(*) ,intent(in) :: Element
7586 character*(*) ,intent(in) :: DateStr
7587 integer ,intent(in) :: Data(:)
7588 integer ,intent(in) :: Count
7589 integer ,intent(out) :: Status
7591 call ext_pio_put_var_td_integer_arr(DataHandle,Element,DateStr, &
7592 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7594 end subroutine ext_pio_put_dom_td_integer_arr
7596 subroutine ext_pio_put_dom_td_integer_sca(DataHandle,Element,DateStr,Data,Count,Status)
7597 integer ,intent(in) :: DataHandle
7598 character*(*) ,intent(in) :: Element
7599 character*(*) ,intent(in) :: DateStr
7600 integer ,intent(in) :: Data
7601 integer ,intent(in) :: Count
7602 integer ,intent(out) :: Status
7604 call ext_pio_put_var_td_integer_sca(DataHandle,Element,DateStr, &
7605 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7607 end subroutine ext_pio_put_dom_td_integer_sca
7609 subroutine ext_pio_put_dom_td_double_arr(DataHandle,Element,DateStr,Data,Count,Status)
7610 integer ,intent(in) :: DataHandle
7611 character*(*) ,intent(in) :: Element
7612 character*(*) ,intent(in) :: DateStr
7613 real*8 ,intent(in) :: Data(:)
7614 integer ,intent(in) :: Count
7615 integer ,intent(out) :: Status
7617 call ext_pio_put_var_td_double_arr(DataHandle,Element,DateStr, &
7618 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7620 end subroutine ext_pio_put_dom_td_double_arr
7622 subroutine ext_pio_put_dom_td_double_sca(DataHandle,Element,DateStr,Data,Count,Status)
7623 integer ,intent(in) :: DataHandle
7624 character*(*) ,intent(in) :: Element
7625 character*(*) ,intent(in) :: DateStr
7626 real*8 ,intent(in) :: Data
7627 integer ,intent(in) :: Count
7628 integer ,intent(out) :: Status
7630 call ext_pio_put_var_td_double_sca(DataHandle,Element,DateStr, &
7631 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7633 end subroutine ext_pio_put_dom_td_double_sca
7635 subroutine ext_pio_put_dom_td_logical_arr(DataHandle,Element,DateStr,Data,Count,Status)
7636 integer ,intent(in) :: DataHandle
7637 character*(*) ,intent(in) :: Element
7638 character*(*) ,intent(in) :: DateStr
7639 logical ,intent(in) :: Data(:)
7640 integer ,intent(in) :: Count
7641 integer ,intent(out) :: Status
7643 call ext_pio_put_var_td_logical_arr(DataHandle,Element,DateStr, &
7644 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7646 end subroutine ext_pio_put_dom_td_logical_arr
7648 subroutine ext_pio_put_dom_td_logical_sca(DataHandle,Element,DateStr,Data,Count,Status)
7649 integer ,intent(in) :: DataHandle
7650 character*(*) ,intent(in) :: Element
7651 character*(*) ,intent(in) :: DateStr
7652 logical ,intent(in) :: Data
7653 integer ,intent(in) :: Count
7654 integer ,intent(out) :: Status
7656 call ext_pio_put_var_td_logical_sca(DataHandle,Element,DateStr, &
7657 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,Status)
7659 end subroutine ext_pio_put_dom_td_logical_sca
7661 subroutine ext_pio_put_dom_td_char_arr(DataHandle,Element,DateStr,Data,Status)
7662 integer ,intent(in) :: DataHandle
7663 character*(*) ,intent(in) :: Element
7664 character*(*) ,intent(in) :: DateStr
7665 character*(*) ,intent(in) :: Data
7666 integer ,intent(out) :: Status
7668 call ext_pio_put_var_td_char_arr(DataHandle,Element,DateStr, &
7669 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Status)
7671 end subroutine ext_pio_put_dom_td_char_arr
7673 subroutine ext_pio_put_dom_td_char_sca(DataHandle,Element,DateStr,Data,Status)
7674 integer ,intent(in) :: DataHandle
7675 character*(*) ,intent(in) :: Element
7676 character*(*) ,intent(in) :: DateStr
7677 character*(*) ,intent(in) :: Data
7678 integer ,intent(out) :: Status
7680 call ext_pio_put_var_td_char_sca(DataHandle,Element,DateStr, &
7681 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Status)
7683 end subroutine ext_pio_put_dom_td_char_sca
7685 subroutine ext_pio_get_dom_td_real_arr(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7686 integer ,intent(in) :: DataHandle
7687 character*(*) ,intent(in) :: Element
7688 character*(*) ,intent(in) :: DateStr
7689 real ,intent(out) :: Data(:)
7690 integer ,intent(in) :: Count
7691 integer ,intent(out) :: OutCount
7692 integer ,intent(out) :: Status
7693 call ext_pio_get_var_td_real_arr(DataHandle,Element,DateStr, &
7694 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7696 end subroutine ext_pio_get_dom_td_real_arr
7698 subroutine ext_pio_get_dom_td_real_sca(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7699 integer ,intent(in) :: DataHandle
7700 character*(*) ,intent(in) :: Element
7701 character*(*) ,intent(in) :: DateStr
7702 real ,intent(out) :: Data
7703 integer ,intent(in) :: Count
7704 integer ,intent(out) :: OutCount
7705 integer ,intent(out) :: Status
7706 call ext_pio_get_var_td_real_sca(DataHandle,Element,DateStr, &
7707 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7709 end subroutine ext_pio_get_dom_td_real_sca
7711 subroutine ext_pio_get_dom_td_integer_arr(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7712 integer ,intent(in) :: DataHandle
7713 character*(*) ,intent(in) :: Element
7714 character*(*) ,intent(in) :: DateStr
7715 integer ,intent(out) :: Data(:)
7716 integer ,intent(in) :: Count
7717 integer ,intent(out) :: OutCount
7718 integer ,intent(out) :: Status
7719 call ext_pio_get_var_td_integer_arr(DataHandle,Element,DateStr, &
7720 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7722 end subroutine ext_pio_get_dom_td_integer_arr
7724 subroutine ext_pio_get_dom_td_integer_sca(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7725 integer ,intent(in) :: DataHandle
7726 character*(*) ,intent(in) :: Element
7727 character*(*) ,intent(in) :: DateStr
7728 integer ,intent(out) :: Data
7729 integer ,intent(in) :: Count
7730 integer ,intent(out) :: OutCount
7731 integer ,intent(out) :: Status
7732 call ext_pio_get_var_td_integer_sca(DataHandle,Element,DateStr, &
7733 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7735 end subroutine ext_pio_get_dom_td_integer_sca
7737 subroutine ext_pio_get_dom_td_double_arr(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7738 integer ,intent(in) :: DataHandle
7739 character*(*) ,intent(in) :: Element
7740 character*(*) ,intent(in) :: DateStr
7741 real*8 ,intent(out) :: Data(:)
7742 integer ,intent(in) :: Count
7743 integer ,intent(out) :: OutCount
7744 integer ,intent(out) :: Status
7745 call ext_pio_get_var_td_double_arr(DataHandle,Element,DateStr, &
7746 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7748 end subroutine ext_pio_get_dom_td_double_arr
7750 subroutine ext_pio_get_dom_td_double_sca(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7751 integer ,intent(in) :: DataHandle
7752 character*(*) ,intent(in) :: Element
7753 character*(*) ,intent(in) :: DateStr
7754 real*8 ,intent(out) :: Data
7755 integer ,intent(in) :: Count
7756 integer ,intent(out) :: OutCount
7757 integer ,intent(out) :: Status
7758 call ext_pio_get_var_td_double_sca(DataHandle,Element,DateStr, &
7759 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7761 end subroutine ext_pio_get_dom_td_double_sca
7763 subroutine ext_pio_get_dom_td_logical_arr(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7764 integer ,intent(in) :: DataHandle
7765 character*(*) ,intent(in) :: Element
7766 character*(*) ,intent(in) :: DateStr
7767 logical ,intent(out) :: Data(:)
7768 integer ,intent(in) :: Count
7769 integer ,intent(out) :: OutCount
7770 integer ,intent(out) :: Status
7771 call ext_pio_get_var_td_logical_arr(DataHandle,Element,DateStr, &
7772 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7774 end subroutine ext_pio_get_dom_td_logical_arr
7776 subroutine ext_pio_get_dom_td_logical_sca(DataHandle,Element,DateStr,Data,Count,OutCount,Status)
7777 integer ,intent(in) :: DataHandle
7778 character*(*) ,intent(in) :: Element
7779 character*(*) ,intent(in) :: DateStr
7780 logical ,intent(out) :: Data(:)
7781 integer ,intent(in) :: Count
7782 integer ,intent(out) :: OutCount
7783 integer ,intent(out) :: Status
7784 call ext_pio_get_var_td_logical_sca(DataHandle,Element,DateStr, &
7785 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Count,OutCount,Status)
7787 end subroutine ext_pio_get_dom_td_logical_sca
7789 subroutine ext_pio_get_dom_td_char_arr(DataHandle,Element,DateStr,Data,Status)
7790 integer ,intent(in) :: DataHandle
7791 character*(*) ,intent(in) :: Element
7792 character*(*) ,intent(in) :: DateStr
7793 character*(*) ,intent(out) :: Data
7794 integer ,intent(out) :: Status
7795 call ext_pio_get_var_td_char_arr(DataHandle,Element,DateStr, &
7796 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Status)
7798 end subroutine ext_pio_get_dom_td_char_arr
7800 subroutine ext_pio_get_dom_td_char_sca(DataHandle,Element,DateStr,Data,Status)
7801 integer ,intent(in) :: DataHandle
7802 character*(*) ,intent(in) :: Element
7803 character*(*) ,intent(in) :: DateStr
7804 character*(*) ,intent(out) :: Data
7805 integer ,intent(out) :: Status
7806 call ext_pio_get_var_td_char_sca(DataHandle,Element,DateStr, &
7807 'E_X_T_D_O_M_A_I_N_M_E_T_A_DATA_' ,Data,Status)
7809 end subroutine ext_pio_get_dom_td_char_sca
7811 subroutine ext_pio_write_field(DataHandle,DateStr,Var,Field,FieldType,grid, &
7812 DomainDesc, MemoryOrdIn, Stagger, DimNames, &
7813 DomainStart, DomainEnd, MemoryStart, MemoryEnd, &
7814 PatchStart, PatchEnd, Status)
7819 include 'wrf_status_codes.h'
7820 integer ,intent(in) :: DataHandle
7821 character*(*) ,intent(in) :: DateStr
7822 character*(*) ,intent(in) :: Var
7823 integer ,intent(inout) :: Field(*)
7824 integer ,intent(in) :: FieldType
7825 type(domain) :: grid
7826 integer ,intent(in) :: DomainDesc
7827 character*(*) ,intent(in) :: MemoryOrdIn
7828 character*(*) ,intent(in) :: Stagger
7829 character*(*) ,dimension(*) ,intent(in) :: DimNames
7830 integer ,dimension(*) ,intent(in) :: DomainStart, DomainEnd
7831 integer ,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
7832 integer ,dimension(*) ,intent(in) :: PatchStart, PatchEnd
7833 integer ,intent(out) :: Status
7834 character (3) :: MemoryOrder
7835 type(wrf_data_handle) ,pointer :: DH
7837 character (VarNameLen) :: VarName
7838 character (3) :: MemO
7839 character (3) :: UCMemO
7840 integer ,dimension(NVarDims) :: Length_global
7841 integer ,dimension(NVarDims) :: Length
7842 integer ,dimension(NVarDims) :: VDimIDs
7843 character(80),dimension(NVarDims) :: RODimNames
7844 integer ,dimension(NVarDims) :: VStart
7845 integer ,dimension(NVarDims) :: VCount
7848 integer :: i,j,n,fldsize
7850 character (80) :: NullName
7852 integer, dimension(1,1) :: tmp0dint
7853 integer, dimension(:,:,:), allocatable :: tmp2dint
7855 !Local, possibly adjusted, copies of MemoryStart and MemoryEnd
7856 MemoryOrder = trim(adjustl(MemoryOrdIn))
7858 call GetDim(MemoryOrder,NDim,Status)
7859 if(Status /= WRF_NO_ERR) then
7860 write(msg,*) 'Warning BAD MEMORY ORDER |',MemoryOrder,'| in ',__FILE__,', line', __LINE__
7861 call wrf_debug ( WARN , TRIM(msg))
7865 !call pio_setdebuglevel(1)
7867 call DateCheck(DateStr,Status)
7868 if(Status /= WRF_NO_ERR) then
7869 write(msg,*) 'Warning DATE STRING ERROR |',DateStr,'| in ',__FILE__,', line', __LINE__
7870 call wrf_debug ( WARN , TRIM(msg))
7874 call GetDH(DataHandle,DH,Status)
7875 if(Status /= WRF_NO_ERR) then
7876 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
7877 call wrf_debug ( WARN , TRIM(msg))
7881 write(msg,*)'ext_pio_write_field: called for ',TRIM(Var)
7882 CALL wrf_debug( 100, msg )
7884 VCount(1:NDim) = PatchEnd(1:NDim)-PatchStart(1:NDim)+1
7885 Length_global(1:NDim) = DomainEnd(1:NDim)-DomainStart(1:NDim)+1
7887 call ExtOrder(MemoryOrder,VCount,Status)
7888 call ExtOrder(MemoryOrder,Length_global,Status)
7890 call ExtOrderStr(MemoryOrder,DimNames,RODimNames,Status)
7892 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
7893 Status = WRF_WARN_FILE_NOT_OPENED
7894 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
7895 call wrf_debug ( WARN , TRIM(msg))
7896 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
7897 Status = WRF_WARN_WRITE_RONLY_FILE
7898 write(msg,*) 'Warning WRITE READ ONLY FILE in ',__FILE__,', line', __LINE__
7899 call wrf_debug ( WARN , TRIM(msg))
7900 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
7903 if(DH%VarNames(NVar) == VarName ) then
7904 Status = WRF_WARN_2DRYRUNS_1VARIABLE
7905 write(msg,*) 'Warning 2 DRYRUNS 1 VARIABLE (',TRIM(VarName),') in ',__FILE__,', line', __LINE__
7906 call wrf_debug ( WARN , TRIM(msg))
7908 elseif(DH%VarNames(NVar) == NO_NAME) then
7909 DH%VarNames(NVar) = VarName
7911 DH%CurrentVariable= NVar
7913 elseif(NVar == MaxVars) then
7914 Status = WRF_WARN_TOO_MANY_VARIABLES
7915 write(msg,*) 'Warning TOO MANY VARIABLES in ',__FILE__,', line', __LINE__
7916 call wrf_debug ( WARN , TRIM(msg))
7923 stat = pio_redef(DH%file_handle)
7924 call netcdf_err(stat,Status)
7925 if(Status /= WRF_NO_ERR) then
7926 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
7927 call wrf_debug ( WARN , TRIM(msg))
7934 if(RODimNames(j) == NullName .or. RODimNames(j) == '') then
7936 if(DH%DimLengths(i) == Length_global(j)) then
7937 VDimIDs(j) = DH%DimIDs(i)
7939 elseif(DH%DimLengths(i) == NO_DIM) then
7940 DH%DimLengths(i) = Length_global(j)
7941 stat = pio_def_dim(DH%file_handle, DH%DimNames(i), DH%DimLengths(i), DH%DimIDs(i))
7942 call netcdf_err(stat,Status)
7943 if(Status /= WRF_NO_ERR) then
7944 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
7945 call wrf_debug ( WARN , TRIM(msg))
7948 VDimIDs(j) = DH%DimIDs(i)
7950 elseif(i == MaxDims) then
7951 Status = WRF_WARN_TOO_MANY_DIMS
7952 write(msg,*) 'Warning TOO MANY DIMENSIONS (',i,') in (',TRIM(VarName),') ',__FILE__,', line', __LINE__
7953 call wrf_debug ( WARN , TRIM(msg))
7957 else !look for input name and check if already defined
7960 if (DH%DimNames(i) == RODimNames(j)) then
7961 if (DH%DimLengths(i) == Length_global(j)) then
7962 VDimIDs(j) = DH%DimIDs(i)
7966 Status = WRF_WARN_DIMNAME_REDEFINED
7967 write(msg,*) 'Warning DIM ',i,', NAME ',TRIM(DH%DimNames(i)),' REDEFINED by var ', &
7968 TRIM(Var),' ',DH%DimLengths(i),Length_global(j) ,' in ', __FILE__ ,' line', __LINE__
7969 call wrf_debug ( WARN , TRIM(msg))
7976 if (DH%DimLengths(i) == NO_DIM) then
7977 DH%DimNames(i) = RODimNames(j)
7978 DH%DimLengths(i) = Length_global(j)
7979 stat = pio_def_dim(DH%file_handle, DH%DimNames(i), DH%DimLengths(i), DH%DimIDs(i))
7980 call netcdf_err(stat,Status)
7981 if(Status /= WRF_NO_ERR) then
7982 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
7983 call wrf_debug ( WARN , TRIM(msg))
7986 VDimIDs(j) = DH%DimIDs(i)
7988 elseif(i == MaxDims) then
7989 Status = WRF_WARN_TOO_MANY_DIMS
7990 write(msg,*) 'Warning TOO MANY DIMENSIONS in ',__FILE__,', line', __LINE__
7991 call wrf_debug ( WARN , TRIM(msg))
7997 DH%VarDimLens(j,DH%NumVars) = Length_global(j)
8000 select case (FieldType)
8010 Status = WRF_WARN_DATA_TYPE_NOT_FOUND
8011 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
8012 call wrf_debug ( WARN , TRIM(msg))
8016 VDimIDs(NDim+1) = DH%DimUnlimID
8017 !write(unit=0, fmt='(/3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
8018 !write(unit=0, fmt='(3a,i6)') '1 Define Var <', trim(Var), '> as NVar:', DH%NumVars
8019 stat = pio_def_var(DH%file_handle,VarName,XType,VDimIDs(1:NDim+1),DH%descVar(DH%NumVars))
8020 call netcdf_err(stat,Status)
8021 if(Status /= WRF_NO_ERR) then
8022 write(msg,*) 'ext_pio_write_field: NetCDF error for ',TRIM(VarName),' in ',__FILE__,', line', __LINE__
8023 call wrf_debug ( WARN , TRIM(msg))
8026 !write(unit=0, fmt='(3a,i6)') 'file: ', __FILE__, ', line: ', __LINE__
8027 !write(unit=0, fmt='(a,i6)') 'DH%descVar(DH%NumVars)%VarID = ', DH%descVar(DH%NumVars)%VarID
8029 stat = pio_put_att(DH%file_handle,DH%descVar(DH%NumVars),'FieldType',FieldType)
8030 call netcdf_err(stat,Status)
8031 if(Status /= WRF_NO_ERR) then
8032 write(msg,*) 'ext_pio_write_field: NetCDF error in ',__FILE__,', line', __LINE__
8033 call wrf_debug ( WARN , TRIM(msg))
8036 call reorder(MemoryOrder,MemO)
8037 call uppercase(MemO,UCMemO)
8038 stat = pio_put_att(DH%file_handle,DH%descVar(DH%NumVars),'MemoryOrder',UCMemO)
8039 call netcdf_err(stat,Status)
8040 if(Status /= WRF_NO_ERR) then
8041 write(msg,*) 'ext_pio_write_field: NetCDF error in ',__FILE__,', line', __LINE__
8042 call wrf_debug ( WARN , TRIM(msg))
8045 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE .OR. DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE) then
8046 if(.not. DH%Write) then
8048 stat = pio_enddef(DH%file_handle)
8049 call netcdf_err(stat,Status)
8050 if(Status /= WRF_NO_ERR) then
8051 write(msg,*) 'NetCDF error (',stat,') in file ',__FILE__,', line', __LINE__
8052 call wrf_debug ( WARN , TRIM(msg))
8057 do NVar=1,DH%NumVars
8058 if(DH%VarNames(NVar) == VarName) then
8059 DH%CurrentVariable = NVar
8061 elseif(NVar == DH%NumVars) then
8062 Status = WRF_WARN_VAR_NF
8063 write(msg,*) 'Warning VARIABLE NOT FOUND in ',__FILE__,', line', __LINE__
8064 call wrf_debug ( WARN , TRIM(msg))
8069 DH%vartype(DH%CurrentVariable) = NOT_LAND_SOIL_VAR
8073 if(Length_global(j) /= DH%VarDimLens(j,DH%CurrentVariable) .AND. DH%FileStatus /= WRF_FILE_OPENED_FOR_UPDATE ) then
8074 Status = WRF_WARN_WRTLEN_NE_DRRUNLEN
8075 write(msg,*) 'Warning LENGTH != DRY RUN LENGTH for |', &
8076 VarName,'| dim ',j,' in ',__FILE__,', line', __LINE__
8077 call wrf_debug ( WARN , TRIM(msg))
8078 write(msg,*) ' LENGTH ',Length_global(j),' DRY RUN LENGTH ',DH%VarDimLens(j,DH%CurrentVariable)
8079 call wrf_debug ( WARN , TRIM(msg))
8081 elseif(PatchStart(j) < MemoryStart(j)) then
8082 Status = WRF_WARN_DIMENSION_ERROR
8083 write(msg,*) 'Warning DIMENSION ERROR for |',VarName, &
8084 '| in ',__FILE__,', line', __LINE__
8085 call wrf_debug ( WARN , TRIM(msg))
8091 VStart(1:NDim) = PatchStart(1:NDim)
8092 call ExtOrder(MemoryOrder,VStart,Status)
8097 if(DH%DimLengths(i) == Length_global(n)) then
8098 VDimIDs(n) = DH%DimIDs(i)
8103 Length(n) = MemoryEnd(n) - MemoryStart(n) + 1
8104 fldsize = fldsize * Length(n)
8106 if("land_cat_stag" == DimNames(n)) then
8107 DH%vartype(DH%CurrentVariable) = LAND_CAT_VAR
8108 else if("soil_cat_stag" == DimNames(n)) then
8109 DH%vartype(DH%CurrentVariable) = SOIL_CAT_VAR
8110 else if("soil_layers_stag" == DimNames(n)) then
8111 DH%vartype(DH%CurrentVariable) = SOIL_LAYERS_VAR
8112 else if("num_ext_model_couple_dom_stag" == DimNames(n)) then
8113 DH%vartype(DH%CurrentVariable) = MDL_CPL_VAR
8114 else if("ensemble_stag" == DimNames(n)) then
8115 DH%vartype(DH%CurrentVariable) = ENSEMBLE_VAR
8120 call FieldIO('write',DataHandle,DateStr,Length_global,VStart,VCount,Length,MemoryOrder, &
8121 Stagger,FieldType,Field,Status)
8123 if(WRF_INTEGER == FieldType) then
8124 if(1 == fldsize) then
8125 tmp0dint(1,1) = Field(1)
8126 stat = pio_put_var(DH%file_handle,DH%descVar(DH%CurrentVariable),tmp0dint)
8127 call netcdf_err(stat,Status)
8128 else if(2 == Ndim) then
8129 allocate(tmp2dint(Length(1),Length(2),1), stat=Status)
8134 tmp2dint(i,j,1) = Field(n)
8137 call pio_write_darray(DH%file_handle, DH%descVar(DH%CurrentVariable), &
8138 DH%iodesc2d_m_int, tmp2dint, Status)
8139 deallocate(tmp2dint)
8141 call FieldIO('write',DataHandle,DateStr,Length_global,VStart,VCount,Length,MemoryOrder, &
8142 Stagger,FieldType,Field,Status)
8145 call FieldIO('write',DataHandle,DateStr,Length_global,VStart,VCount,Length,MemoryOrder, &
8146 Stagger,FieldType,Field,Status)
8149 if(Status /= WRF_NO_ERR) then
8150 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8151 call wrf_debug ( WARN , TRIM(msg))
8155 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8156 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8157 call wrf_debug ( FATAL , TRIM(msg))
8160 end subroutine ext_pio_write_field
8162 subroutine ext_pio_read_field(DataHandle,DateStr,Var,Field,FieldType,grid, &
8163 DomainDesc, MemoryOrdIn, Stagger, DimNames, &
8164 DomainStart,DomainEnd,MemoryStart,MemoryEnd, &
8165 PatchStart,PatchEnd,Status)
8171 include 'wrf_status_codes.h'
8172 integer ,intent(in) :: DataHandle
8173 character*(*) ,intent(in) :: DateStr
8174 character*(*) ,intent(in) :: Var
8175 integer ,intent(out) :: Field(*)
8176 integer ,intent(in) :: FieldType
8177 type(domain) :: grid
8178 integer ,intent(in) :: DomainDesc
8179 character*(*) ,intent(in) :: MemoryOrdIn
8180 character*(*) ,intent(in) :: Stagger ! Dummy for now
8181 character*(*) , dimension (*) ,intent(in) :: DimNames
8182 integer ,dimension(*) ,intent(in) :: DomainStart, DomainEnd
8183 integer ,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
8184 integer ,dimension(*) ,intent(in) :: PatchStart, PatchEnd
8185 integer ,intent(out) :: Status
8186 character (3) :: MemoryOrder
8187 character(PIO_MAX_NAME) :: dimname
8188 type(wrf_data_handle) ,pointer :: DH
8190 character (VarNameLen) :: VarName
8191 integer ,dimension(NVarDims) :: VCount
8192 integer ,dimension(NVarDims) :: VStart
8193 integer ,dimension(NVarDims) :: VDimen
8194 integer ,dimension(NVarDims) :: Length
8196 integer ,dimension(NVarDims) :: StoredLen
8198 integer ,dimension(NVarDims) :: VDimIDs
8199 integer ,dimension(NVarDims) :: MemS
8200 integer ,dimension(NVarDims) :: MemE
8202 character (VarNameLen) :: Name
8204 integer :: StoredDim
8208 integer(KIND=PIO_OFFSET) :: Len
8210 integer :: i, j, n, fldsize
8213 integer, dimension(:,:,:), allocatable :: tmp2dint
8214 character (len=2) :: readinStagger
8216 MemoryOrder = trim(adjustl(MemoryOrdIn))
8218 call GetDim(MemoryOrder,NDim,Status)
8219 if(Status /= WRF_NO_ERR) then
8220 write(msg,*) 'Warning BAD MEMORY ORDER |',TRIM(MemoryOrder),'| for |', &
8221 TRIM(Var),'| in ext_pio_read_field ',__FILE__,', line', __LINE__
8222 call wrf_debug ( WARN , TRIM(msg))
8225 call DateCheck(DateStr,Status)
8226 if(Status /= WRF_NO_ERR) then
8227 write(msg,*) 'Warning DATE STRING ERROR |',TRIM(DateStr),'| for |',TRIM(Var), &
8228 '| in ext_pio_read_field ',__FILE__,', line', __LINE__
8229 call wrf_debug ( WARN , TRIM(msg))
8232 call GetDH(DataHandle,DH,Status)
8233 if(Status /= WRF_NO_ERR) then
8234 write(msg,*) 'Warning Status = ',Status,' in ext_pio_read_field ',__FILE__,', line', __LINE__
8235 call wrf_debug ( WARN , TRIM(msg))
8240 DH%CurrentVariable = DH%CurrentVariable + 1
8241 DH%VarNames(DH%CurrentVariable) = VarName
8243 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8244 Status = WRF_WARN_FILE_NOT_OPENED
8245 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8246 call wrf_debug ( WARN , TRIM(msg))
8247 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8249 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8250 Status = WRF_WARN_READ_WONLY_FILE
8251 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8252 call wrf_debug ( WARN , TRIM(msg))
8253 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ .OR. DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE ) then
8254 !call pio_seterrorhandling(DH%file_handle, PIO_BCAST_ERROR)
8255 stat = pio_inq_varid(DH%file_handle,VarName,DH%descVar(DH%CurrentVariable))
8256 !call pio_seterrorhandling(DH%file_handle, PIO_INTERNAL_ERROR)
8257 !if(stat /= PIO_NOERR) then
8258 ! DH%descVar(DH%CurrentVariable)%varID = 0
8259 ! write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Varname, ',Varname, ' not found in file.'
8260 ! call wrf_debug ( WARN , TRIM(msg))
8264 call netcdf_err(stat,Status)
8265 if(Status /= WRF_NO_ERR) then
8266 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__,' Varname ',Varname
8267 call wrf_debug ( WARN , TRIM(msg))
8271 stat = pio_inquire_variable(DH%file_handle,DH%descVar(DH%CurrentVariable), &
8272 Name,XType,StoredDim,VDimIDs,NAtts)
8274 call netcdf_err(stat,Status)
8275 if(Status /= WRF_NO_ERR) then
8276 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8277 call wrf_debug ( WARN , TRIM(msg))
8280 stat = pio_get_att(DH%file_handle,DH%descVar(DH%CurrentVariable),'FieldType',FType)
8281 call netcdf_err(stat,Status)
8282 if(Status /= WRF_NO_ERR) then
8283 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8284 call wrf_debug ( WARN , TRIM(msg))
8289 stat = pio_get_att(DH%file_handle,DH%descVar(DH%CurrentVariable),'stagger',readinStagger)
8290 call netcdf_err(stat,Status)
8291 if(Status /= WRF_NO_ERR) then
8292 write(msg,*) 'NetCDF error in ',__FILE__,' ','CHAR',', line', __LINE__
8293 call wrf_debug ( WARN , msg)
8297 !---allow coercion between double and single prec real
8298 if( (FieldType == WRF_REAL .OR. FieldType == WRF_DOUBLE) ) then
8299 if ( .NOT. (Ftype == WRF_REAL .OR. Ftype == WRF_DOUBLE )) then
8300 Status = WRF_WARN_TYPE_MISMATCH
8301 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
8302 call wrf_debug ( WARN , TRIM(msg))
8305 else if(FieldType /= Ftype) then
8306 Status = WRF_WARN_TYPE_MISMATCH
8307 write(msg,*) 'Warning TYPE MISMATCH in ',__FILE__,', line', __LINE__
8308 call wrf_debug ( WARN , TRIM(msg))
8311 select case (FieldType)
8313 !allow coercion between double and single prec real
8314 if(.NOT. (XType == PIO_REAL .OR. XType == PIO_DOUBLE) ) then
8315 Status = WRF_WARN_TYPE_MISMATCH
8316 write(msg,*) 'Warning REAL TYPE MISMATCH in ',__FILE__,', line', __LINE__
8319 !allow coercion between double and single prec real
8320 if(.NOT. (XType == PIO_REAL .OR. XType == PIO_DOUBLE) ) then
8321 Status = WRF_WARN_TYPE_MISMATCH
8322 write(msg,*) 'Warning DOUBLE TYPE MISMATCH in ',__FILE__,', line', __LINE__
8325 if(XType /= PIO_INT) then
8326 Status = WRF_WARN_TYPE_MISMATCH
8327 write(msg,*) 'Warning INTEGER TYPE MISMATCH in ',__FILE__,', line', __LINE__
8330 if(XType /= PIO_INT) then
8331 Status = WRF_WARN_TYPE_MISMATCH
8332 write(msg,*) 'Warning LOGICAL TYPE MISMATCH in ',__FILE__,', line', __LINE__
8335 Status = WRF_WARN_DATA_TYPE_NOT_FOUND
8336 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
8338 if(Status /= WRF_NO_ERR) then
8339 call wrf_debug ( WARN , TRIM(msg))
8342 ! NDim=0 for scalars. Handle read of old NDim=1 files. TBH: 20060502
8343 IF ( ( NDim == 0 ) .AND. ( StoredDim == 2 ) ) THEN
8344 stat = pio_inq_dimname(DH%file_handle,VDimIDs(1),dimname)
8345 call netcdf_err(stat,Status)
8346 if(Status /= WRF_NO_ERR) then
8347 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8348 call wrf_debug ( WARN , TRIM(msg))
8351 IF ( dimname(1:10) == 'ext_scalar' ) THEN
8356 if(StoredDim /= NDim+1) then
8357 Status = WRF_ERR_FATAL_BAD_VARIABLE_DIM
8358 write(msg,*) 'Fatal error BAD VARIABLE DIMENSION in ext_pio_read_field ',TRIM(Var),TRIM(DateStr)
8359 call wrf_debug ( FATAL , msg)
8360 write(msg,*) ' StoredDim ', StoredDim, ' .NE. NDim+1 ', NDim+1
8361 call wrf_debug ( FATAL , msg)
8366 stat = pio_inq_dimlen(DH%file_handle,VDimIDs(n),StoredLen(n))
8367 call netcdf_err(stat,Status)
8368 if(Status /= WRF_NO_ERR) then
8369 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8370 call wrf_debug ( WARN , TRIM(msg))
8373 if(VCount(n) > StoredLen(n)) then
8374 Status = WRF_WARN_READ_PAST_EOF
8375 write(msg,*) 'Warning READ PAST EOF in ext_pio_read_field of ',TRIM(Var),VCount(n),'>',StoredLen(n)
8376 call wrf_debug ( WARN , TRIM(msg))
8378 elseif(VCount(n) <= 0) then
8379 Status = WRF_WARN_ZERO_LENGTH_READ
8380 write(msg,*) 'Warning ZERO LENGTH READ in ',__FILE__,', line', __LINE__
8381 call wrf_debug ( WARN , TRIM(msg))
8386 !write(unit=0, fmt='(//3a,i6)') 'file: ',__FILE__,', line', __LINE__
8387 !write(unit=0, fmt='(4x,a,i6,2a)') 'DH%CurrentVariable = ', DH%CurrentVariable, ', name: ', trim(VarName)
8389 VStart(1:NDim) = PatchStart(1:NDim)
8390 VCount(1:NDim) = PatchEnd(1:NDim) - PatchStart(1:NDim) + 1
8391 VDimen(1:NDim) = DomainEnd(1:NDim) - DomainStart(1:NDim) + 1
8394 ! write(unit=0, fmt='(4x,8(a,i2,a,i6))') &
8395 ! 'DomainStart(', n, ')=', DomainStart(n), ', DomainEnd(', n, ')=', DomainEnd(n), &
8396 ! ', MemoryStart(', n, ')=', MemoryStart(n), ', MemoryEnd(', n, ')=', MemoryEnd(n), &
8397 ! ', PatchStart(', n, ')=', PatchStart(n), ', PatchEnd(', n, ')=', PatchEnd(n), &
8398 ! ', VStart(', n, ')=', VStart(n), ', VCount(', n, ')=', VCount(n)
8401 call ExtOrder(MemoryOrder,VStart,Status)
8402 call ExtOrder(MemoryOrder,VCount,Status)
8403 call ExtOrder(MemoryOrder,VDimen,Status)
8405 DH%vartype(DH%CurrentVariable) = NOT_LAND_SOIL_VAR
8408 Length(n) = MemoryEnd(n) - MemoryStart(n) + 1
8409 fldsize = fldsize * Length(n)
8411 !write(unit=0, fmt='(4x,2(a,i2,a,i6))') &
8412 ! 'VStart(', n, ')=', VStart(n), ', VCount(', n, ')=', VCount(n)
8414 if("land_cat_stag" == DH%DimNames(VDimIDs(n))) then
8415 DH%vartype(DH%CurrentVariable) = LAND_CAT_VAR
8416 else if("soil_cat_stag" == DH%DimNames(VDimIDs(n))) then
8417 DH%vartype(DH%CurrentVariable) = SOIL_CAT_VAR
8418 else if("soil_layers_stag" == DH%DimNames(VDimIDs(n))) then
8419 DH%vartype(DH%CurrentVariable) = SOIL_LAYERS_VAR
8420 else if("num_ext_model_couple_dom_stag" == DH%DimNames(VDimIDs(n))) then
8421 DH%vartype(DH%CurrentVariable) = MDL_CPL_VAR
8422 else if("ensemble_stag" == DH%DimNames(VDimIDs(n))) then
8423 DH%vartype(DH%CurrentVariable) = ENSEMBLE_VAR
8428 isbdy = is_boundary(MemoryOrder)
8430 !write(unit=0, fmt='(//3a,i6)') 'file: ',__FILE__,', line', __LINE__
8431 !write(unit=0, fmt='(4x,a,i6,2a)') 'DH%CurrentVariable = ',
8432 !DH%CurrentVariable, ', name: ', trim(VarName)
8434 call FieldBDY('read',DataHandle,DateStr,NDim,VDimen, &
8435 MemoryStart,MemoryEnd,PatchStart,PatchEnd, &
8436 FieldType,Field,Status)
8438 !if((WRF_INTEGER == FieldType) .and. (1 == fldsize)) then
8439 ! Status = pio_get_var(DH%file_handle,DH%descVar(DH%CurrentVariable),VCount(1:1))
8440 ! Field(1) = VCount(1)
8442 call FieldIO('read',DataHandle,DateStr,VDimen,VStart,VCount,Length,MemoryOrder, &
8443 readinStagger,FieldType,Field,Status)
8447 if(WRF_INTEGER == FieldType) then
8448 if(1 == fldsize) then
8449 Status = pio_get_var(DH%file_handle,DH%descVar(DH%CurrentVariable),VCount(1:1))
8450 Field(1) = VCount(1)
8451 else if(2 == Ndim) then
8452 allocate(tmp2dint(Length(1),Length(2),1), stat=Status)
8453 call pio_read_darray(DH%file_handle, DH%descVar(DH%CurrentVariable), &
8454 DH%iodesc2d_m_int, tmp2dint, Status)
8455 ! DH%ioVar(DH%CurrentVariable), tmp2dint, Status)
8460 Field(n) = tmp2dint(i,j,1)
8463 deallocate(tmp2dint)
8465 call FieldIO('read',DataHandle,DateStr,VDimen,VStart,VCount,Length,MemoryOrder, &
8466 readinStagger,FieldType,Field,Status)
8469 isbdy = is_boundary(MemoryOrder)
8471 !write(unit=0, fmt='(//3a,i6)') 'file: ',__FILE__,', line', __LINE__
8472 !write(unit=0, fmt='(4x,a,i6,2a)') 'DH%CurrentVariable = ', DH%CurrentVariable, ', name: ', trim(VarName)
8474 call FieldBDY('read',DataHandle,DateStr,NDim,VDimen, &
8475 MemoryStart,MemoryEnd,PatchStart,PatchEnd, &
8476 FieldType,Field,Status)
8478 call FieldIO('read',DataHandle,DateStr,VDimen,VStart,VCount,Length,MemoryOrder, &
8479 readinStagger,FieldType,Field,Status)
8484 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8485 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8486 call wrf_debug ( FATAL , msg)
8489 end subroutine ext_pio_read_field
8491 subroutine ext_pio_inquire_opened( DataHandle, FileName , FileStatus, Status )
8495 include 'wrf_status_codes.h'
8496 integer ,intent(in) :: DataHandle
8497 character*(*) ,intent(inout) :: FileName
8498 integer ,intent(out) :: FileStatus
8499 integer ,intent(out) :: Status
8500 type(wrf_data_handle) ,pointer :: DH
8502 call upgrade_filename(FileName)
8503 !call upgrade_filename(DH%FileName)
8505 call GetDH(DataHandle,DH,Status)
8506 if(Status /= WRF_NO_ERR) then
8507 FileStatus = WRF_FILE_NOT_OPENED
8510 if(trim(FileName) /= trim(DH%FileName)) then
8511 FileStatus = WRF_FILE_NOT_OPENED
8513 FileStatus = DH%FileStatus
8517 end subroutine ext_pio_inquire_opened
8519 subroutine ext_pio_inquire_filename( Datahandle, FileName, FileStatus, Status )
8523 include 'wrf_status_codes.h'
8524 integer ,intent(in) :: DataHandle
8525 character*(*) ,intent(out) :: FileName
8526 integer ,intent(out) :: FileStatus
8527 integer ,intent(out) :: Status
8528 type(wrf_data_handle) ,pointer :: DH
8529 FileStatus = WRF_FILE_NOT_OPENED
8530 call GetDH(DataHandle,DH,Status)
8531 if(Status /= WRF_NO_ERR) then
8532 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8533 call wrf_debug ( WARN , TRIM(msg))
8536 FileName = trim(DH%FileName)
8537 !call upgrade_filename(FileName)
8538 FileStatus = DH%FileStatus
8541 end subroutine ext_pio_inquire_filename
8543 subroutine ext_pio_set_time(DataHandle, DateStr, Status)
8547 include 'wrf_status_codes.h'
8548 integer ,intent(in) :: DataHandle
8549 character*(*) ,intent(in) :: DateStr
8550 integer ,intent(out) :: Status
8551 type(wrf_data_handle) ,pointer :: DH
8554 call DateCheck(DateStr,Status)
8555 if(Status /= WRF_NO_ERR) then
8556 write(msg,*) 'Warning DATE STRING ERROR in ',__FILE__,', line', __LINE__
8557 call wrf_debug ( WARN , TRIM(msg))
8560 call GetDH(DataHandle,DH,Status)
8561 if(Status /= WRF_NO_ERR) then
8562 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8563 call wrf_debug ( WARN , TRIM(msg))
8566 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8567 Status = WRF_WARN_FILE_NOT_OPENED
8568 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8569 call wrf_debug ( WARN , TRIM(msg))
8570 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8571 Status = WRF_WARN_FILE_NOT_COMMITTED
8572 write(msg,*) 'Warning FILE NOT COMMITTED in ',__FILE__,', line', __LINE__
8573 call wrf_debug ( WARN , TRIM(msg))
8574 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8575 Status = WRF_WARN_READ_WONLY_FILE
8576 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8577 call wrf_debug ( WARN , TRIM(msg))
8578 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
8580 if(DH%Times(i)==DateStr) then
8584 if(i==MaxTimes) then
8585 Status = WRF_WARN_TIME_NF
8589 DH%CurrentVariable = 0
8592 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8593 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8594 call wrf_debug ( FATAL , msg)
8597 end subroutine ext_pio_set_time
8599 subroutine ext_pio_get_next_time(DataHandle, DateStr, Status)
8603 include 'wrf_status_codes.h'
8604 integer ,intent(in) :: DataHandle
8605 character*(*) ,intent(out) :: DateStr
8606 integer ,intent(out) :: Status
8607 type(wrf_data_handle) ,pointer :: DH
8609 call GetDH(DataHandle,DH,Status)
8610 if(Status /= WRF_NO_ERR) then
8611 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8612 call wrf_debug ( WARN , TRIM(msg))
8615 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8616 Status = WRF_WARN_FILE_NOT_OPENED
8617 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8618 call wrf_debug ( WARN , TRIM(msg))
8619 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8620 Status = WRF_WARN_DRYRUN_READ
8621 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
8622 call wrf_debug ( WARN , TRIM(msg))
8623 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8624 Status = WRF_WARN_READ_WONLY_FILE
8625 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8626 call wrf_debug ( WARN , TRIM(msg))
8627 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ .OR. DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE ) then
8628 if(DH%CurrentTime >= DH%NumberTimes) then
8629 write(msg,*) 'Warning ext_pio_get_next_time: DH%CurrentTime >= DH%NumberTimes ',DH%CurrentTime,DH%NumberTimes
8630 call wrf_debug ( WARN , TRIM(msg))
8631 Status = WRF_WARN_TIME_EOF
8634 DH%CurrentTime = DH%CurrentTime +1
8635 DateStr = DH%Times(DH%CurrentTime)
8636 DH%CurrentVariable = 0
8639 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8640 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8641 call wrf_debug ( FATAL , msg)
8644 end subroutine ext_pio_get_next_time
8646 subroutine ext_pio_get_previous_time(DataHandle, DateStr, Status)
8650 include 'wrf_status_codes.h'
8651 integer ,intent(in) :: DataHandle
8652 character*(*) ,intent(out) :: DateStr
8653 integer ,intent(out) :: Status
8654 type(wrf_data_handle) ,pointer :: DH
8656 call GetDH(DataHandle,DH,Status)
8657 if(Status /= WRF_NO_ERR) then
8658 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8659 call wrf_debug ( WARN , TRIM(msg))
8662 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8663 Status = WRF_WARN_FILE_NOT_OPENED
8664 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8665 call wrf_debug ( WARN , TRIM(msg))
8666 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8667 Status = WRF_WARN_DRYRUN_READ
8668 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
8669 call wrf_debug ( WARN , TRIM(msg))
8670 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8671 Status = WRF_WARN_READ_WONLY_FILE
8672 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8673 call wrf_debug ( WARN , TRIM(msg))
8674 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
8675 if(DH%CurrentTime.GT.0) then
8676 DH%CurrentTime = DH%CurrentTime -1
8678 DateStr = DH%Times(DH%CurrentTime)
8679 DH%CurrentVariable = 0
8682 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8683 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8684 call wrf_debug ( FATAL , msg)
8687 end subroutine ext_pio_get_previous_time
8689 subroutine ext_pio_get_next_var(DataHandle, VarName, Status)
8693 include 'wrf_status_codes.h'
8694 integer ,intent(in) :: DataHandle
8695 character*(*) ,intent(out) :: VarName
8696 integer ,intent(out) :: Status
8697 type(wrf_data_handle) ,pointer :: DH
8699 character (80) :: Name
8701 call GetDH(DataHandle,DH,Status)
8702 if(Status /= WRF_NO_ERR) then
8703 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8704 call wrf_debug ( WARN , TRIM(msg))
8707 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8708 Status = WRF_WARN_FILE_NOT_OPENED
8709 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8710 call wrf_debug ( WARN , TRIM(msg))
8711 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8712 Status = WRF_WARN_DRYRUN_READ
8713 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
8714 call wrf_debug ( WARN , TRIM(msg))
8715 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8716 Status = WRF_WARN_READ_WONLY_FILE
8717 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8718 call wrf_debug ( WARN , TRIM(msg))
8719 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ .OR. DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE) then
8721 DH%CurrentVariable = DH%CurrentVariable +1
8722 if(DH%CurrentVariable > DH%NumVars) then
8723 Status = WRF_WARN_VAR_EOF
8726 VarName = DH%VarNames(DH%CurrentVariable)
8729 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8730 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8731 call wrf_debug ( FATAL , msg)
8734 end subroutine ext_pio_get_next_var
8736 subroutine ext_pio_end_of_frame(DataHandle, Status)
8741 include 'wrf_status_codes.h'
8742 integer ,intent(in) :: DataHandle
8743 integer ,intent(out) :: Status
8744 type(wrf_data_handle) ,pointer :: DH
8746 call GetDH(DataHandle,DH,Status)
8748 end subroutine ext_pio_end_of_frame
8750 ! NOTE: For scalar variables NDim is set to zero and DomainStart and
8751 ! NOTE: DomainEnd are left unmodified.
8752 subroutine ext_pio_get_var_info(DataHandle,Name,NDim,MemoryOrder,Stagger,DomainStart,DomainEnd,WrfType,Status)
8756 include 'wrf_status_codes.h'
8757 integer ,intent(in) :: DataHandle
8758 character*(*) ,intent(in) :: Name
8759 integer ,intent(out) :: NDim
8760 character*(*) ,intent(out) :: MemoryOrder
8761 character*(*) :: Stagger ! Dummy for now
8762 integer ,dimension(*) ,intent(out) :: DomainStart, DomainEnd
8763 integer ,intent(out) :: WrfType
8764 integer ,intent(out) :: Status
8765 type(wrf_data_handle) ,pointer :: DH
8767 integer ,dimension(NVarDims) :: VDimIDs
8772 call GetDH(DataHandle,DH,Status)
8773 if(Status /= WRF_NO_ERR) then
8774 write(msg,*) 'Warning Status = ',Status,' in ',__FILE__,', line', __LINE__
8775 call wrf_debug ( WARN , TRIM(msg))
8778 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
8779 Status = WRF_WARN_FILE_NOT_OPENED
8780 write(msg,*) 'Warning FILE NOT OPENED in ',__FILE__,', line', __LINE__
8781 call wrf_debug ( WARN , TRIM(msg))
8783 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
8784 Status = WRF_WARN_DRYRUN_READ
8785 write(msg,*) 'Warning DRYRUN READ in ',__FILE__,', line', __LINE__
8786 call wrf_debug ( WARN , TRIM(msg))
8788 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
8789 Status = WRF_WARN_READ_WONLY_FILE
8790 write(msg,*) 'Warning READ WRITE ONLY FILE in ',__FILE__,', line', __LINE__
8791 call wrf_debug ( WARN , TRIM(msg))
8793 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ .OR. DH%FileStatus == WRF_FILE_OPENED_FOR_UPDATE) then
8794 stat = pio_inq_varid(DH%file_handle,Name,VarID)
8795 call netcdf_err(stat,Status)
8796 if(Status /= WRF_NO_ERR) then
8797 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8798 call wrf_debug ( WARN , TRIM(msg))
8801 stat = pio_inq_vartype(DH%file_handle,VarID,XType)
8802 call netcdf_err(stat,Status)
8803 if(Status /= WRF_NO_ERR) then
8804 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8805 call wrf_debug ( WARN , TRIM(msg))
8808 stat = pio_get_att(DH%file_handle,VarID,'FieldType',WrfType)
8809 call netcdf_err(stat,Status)
8810 if(Status /= WRF_NO_ERR) then
8811 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8812 call wrf_debug ( WARN , TRIM(msg))
8817 ! Status = WRF_WARN_BAD_DATA_TYPE
8818 ! write(msg,*) 'Warning BYTE IS BAD DATA TYPE in ',__FILE__,', line', __LINE__
8819 ! call wrf_debug ( WARN , TRIM(msg))
8822 Status = WRF_WARN_BAD_DATA_TYPE
8823 write(msg,*) 'Warning CHAR IS BAD DATA TYPE in ',__FILE__,', line', __LINE__
8824 call wrf_debug ( WARN , TRIM(msg))
8827 ! Status = WRF_WARN_BAD_DATA_TYPE
8828 ! write(msg,*) 'Warning SHORT IS BAD DATA TYPE in ',__FILE__,', line', __LINE__
8829 ! call wrf_debug ( WARN , TRIM(msg))
8832 if(WrfType /= WRF_INTEGER .and. WrfType /= WRF_LOGICAL) then
8833 Status = WRF_WARN_BAD_DATA_TYPE
8834 write(msg,*) 'Warning BAD DATA TYPE in ',__FILE__,', line', __LINE__
8835 call wrf_debug ( WARN , TRIM(msg))
8839 if(WrfType /= WRF_REAL) then
8840 Status = WRF_WARN_BAD_DATA_TYPE
8841 write(msg,*) 'Warning BAD DATA TYPE in ',__FILE__,', line', __LINE__
8842 call wrf_debug ( WARN , TRIM(msg))
8846 if(WrfType /= WRF_DOUBLE) then
8847 Status = WRF_WARN_BAD_DATA_TYPE
8848 write(msg,*) 'Warning BAD DATA TYPE in ',__FILE__,', line', __LINE__
8849 call wrf_debug ( WARN , TRIM(msg))
8853 Status = WRF_WARN_DATA_TYPE_NOT_FOUND
8854 write(msg,*) 'Warning DATA TYPE NOT FOUND in ',__FILE__,', line', __LINE__
8855 call wrf_debug ( WARN , TRIM(msg))
8859 stat = pio_get_att(DH%file_handle,VarID,'MemoryOrder',MemoryOrder)
8860 call netcdf_err(stat,Status)
8861 if(Status /= WRF_NO_ERR) then
8862 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8863 call wrf_debug ( WARN , TRIM(msg))
8866 call GetDim(MemoryOrder,NDim,Status)
8867 if(Status /= WRF_NO_ERR) then
8868 write(msg,*) 'Warning BAD MEMORY ORDER ',TRIM(MemoryOrder),' in ',__FILE__,', line', __LINE__
8869 call wrf_debug ( WARN , TRIM(msg))
8872 stat = pio_inq_vardimid(DH%file_handle,VarID,VDimIDs)
8873 call netcdf_err(stat,Status)
8874 if(Status /= WRF_NO_ERR) then
8875 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8876 call wrf_debug ( WARN , TRIM(msg))
8881 stat = pio_inq_dimlen(DH%file_handle,VDimIDs(j),DomainEnd(j))
8882 call netcdf_err(stat,Status)
8883 if(Status /= WRF_NO_ERR) then
8884 write(msg,*) 'NetCDF error in ',__FILE__,', line', __LINE__
8885 call wrf_debug ( WARN , TRIM(msg))
8890 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
8891 write(msg,*) 'Fatal error BAD FILE STATUS in ',__FILE__,', line', __LINE__
8892 call wrf_debug ( FATAL , msg)
8895 end subroutine ext_pio_get_var_info
8897 subroutine ext_pio_warning_str( Code, ReturnString, Status)
8901 include 'wrf_status_codes.h'
8903 integer , intent(in) ::Code
8904 character *(*), intent(out) :: ReturnString
8905 integer, intent(out) ::Status
8909 ReturnString='No error'
8913 ReturnString= 'File not found (or file is incomplete)'
8917 ReturnString='Metadata not found'
8921 ReturnString= 'Timestamp not found'
8925 ReturnString= 'No more timestamps'
8929 ReturnString= 'Variable not found'
8933 ReturnString= 'No more variables for the current time'
8937 ReturnString= 'Too many open files'
8941 ReturnString= 'Data type mismatch'
8945 ReturnString= 'Attempt to write read-only file'
8949 ReturnString= 'Attempt to read write-only file'
8953 ReturnString= 'Attempt to access unopened file'
8957 ReturnString= 'Attempt to do 2 trainings for 1 variable'
8961 ReturnString= 'Attempt to read past EOF'
8965 ReturnString= 'Bad data handle'
8969 ReturnString= 'Write length not equal to training length'
8973 ReturnString= 'More dimensions requested than training'
8977 ReturnString= 'Attempt to read more data than exists'
8981 ReturnString= 'Input dimensions inconsistent'
8985 ReturnString= 'Input MemoryOrder not recognized'
8989 ReturnString= 'A dimension name with 2 different lengths'
8993 ReturnString= 'String longer than provided storage'
8997 ReturnString= 'Function not supportable'
9001 ReturnString= 'Package implements this routine as NOOP'
9005 !netcdf-specific warning messages
9007 ReturnString= 'Bad data type'
9011 ReturnString= 'File not committed'
9015 ReturnString= 'File is opened for reading'
9019 ReturnString= 'Attempt to write metadata after open commit'
9023 ReturnString= 'I/O not initialized'
9027 ReturnString= 'Too many variables requested'
9031 ReturnString= 'Attempt to close file during a dry run'
9035 ReturnString= 'Date string not 19 characters in length'
9039 ReturnString= 'Attempt to read zero length words'
9043 ReturnString= 'Data type not found'
9047 ReturnString= 'Badly formatted date string'
9051 ReturnString= 'Attempt at read during a dry run'
9055 ReturnString= 'Attempt to get zero words'
9059 ReturnString= 'Attempt to put zero length words'
9063 ReturnString= 'NetCDF error'
9067 ReturnString= 'Requested length <= 1'
9071 ReturnString= 'More data available than requested'
9075 ReturnString= 'New date less than previous date'
9080 ReturnString= 'This warning code is not supported or handled directly by WRF and NetCDF. &
9081 & Might be an erroneous number, or specific to an i/o package other than NetCDF; you may need &
9082 & to be calling a package-specific routine to return a message for this warning code.'
9087 end subroutine ext_pio_warning_str
9090 !returns message string for all WRF and netCDF warning/error status codes
9091 !Other i/o packages must provide their own routines to return their own status messages
9092 subroutine ext_pio_error_str( Code, ReturnString, Status)
9096 include 'wrf_status_codes.h'
9098 integer , intent(in) ::Code
9099 character *(*), intent(out) :: ReturnString
9100 integer, intent(out) ::Status
9104 ReturnString= 'Allocation Error'
9108 ReturnString= 'Deallocation Error'
9112 ReturnString= 'Bad File Status'
9116 ReturnString= 'Variable on disk is not 3D'
9120 ReturnString= 'Metadata on disk is not 1D'
9124 ReturnString= 'Time dimension too small'
9128 ReturnString= 'This error code is not supported or handled directly by WRF and NetCDF. &
9129 & Might be an erroneous number, or specific to an i/o package other than NetCDF; you may need &
9130 & to be calling a package-specific routine to return a message for this error code.'
9135 end subroutine ext_pio_error_str
9138 subroutine ext_pio_end_independent_mode(DataHandle, Status)
9141 include 'wrf_status_codes.h'
9142 integer ,intent(in) :: DataHandle
9143 integer ,intent(out) :: Status
9144 type(wrf_data_handle) ,pointer :: DH
9147 DH => WrfDataHandles(DataHandle)
9149 end subroutine ext_pio_end_independent_mode
9151 subroutine ext_pio_start_independent_mode(DataHandle, Status)
9154 include 'wrf_status_codes.h'
9155 integer ,intent(in) :: DataHandle
9156 integer ,intent(out) :: Status
9157 type(wrf_data_handle) ,pointer :: DH
9160 DH => WrfDataHandles(DataHandle)
9162 end subroutine ext_pio_start_independent_mode