1 ! (old comment from when this file was a template)
2 ! This is a template for adding a package-dependent implemetnation of
3 ! the I/O API. You can use the name xxx since that is already set up
4 ! as a placeholder in module_io.F, md_calls.m4, and the Registry, or
5 ! you can change the name here and in those other places. For additional
6 ! information on adding a package to WRF, see the latest version of the
7 ! WRF Design and Implementation Document 1.1 (Draft). June 21, 2001
9 ! Uses header manipulation routines in module_io_quilt.F
12 MODULE module_ext_internal
14 USE module_internal_header_util
16 INTEGER, PARAMETER :: int_num_handles = 99
17 LOGICAL, DIMENSION(int_num_handles) :: okay_for_io, int_handle_in_use, okay_to_commit
18 INTEGER, DIMENSION(int_num_handles) :: int_num_bytes_to_write
19 ! first_operation is set to .TRUE. when a new handle is allocated
20 ! or when open-for-write or open-for-read are committed. It is set
21 ! to .FALSE. when the first field is read or written.
22 LOGICAL, DIMENSION(int_num_handles) :: first_operation
23 ! TBH: file_status is checked by routines that call the WRF IOAPI. It is not
24 ! TBH: yet cleanly integrated with okay_for_io, int_handle_in_use,
25 ! TBH: okay_to_commit. Fix this later...
26 INTEGER, DIMENSION(int_num_handles) :: file_status
27 ! TBH: This flag goes along with file_status and is set as early as possible.
28 LOGICAL, DIMENSION(int_num_handles) :: file_read_only
29 CHARACTER*128, DIMENSION(int_num_handles) :: CurrentDateInFile
30 REAL, POINTER :: int_local_output_buffer(:)
31 INTEGER :: int_local_output_cursor
33 INTEGER, PARAMETER :: onebyte = 1
34 INTEGER comm_io_servers, iserver, hdrbufsize, obufsize
35 INTEGER itypesize, rtypesize, typesize
36 INTEGER, DIMENSION(512) :: hdrbuf
37 INTEGER, DIMENSION(int_num_handles) :: handle
38 INTEGER, DIMENSION(512, int_num_handles) :: open_file_descriptors
40 CHARACTER*132 last_next_var( int_num_handles )
44 LOGICAL FUNCTION int_valid_handle( handle )
46 INTEGER, INTENT(IN) :: handle
47 int_valid_handle = ( handle .ge. 8 .and. handle .le. int_num_handles )
48 END FUNCTION int_valid_handle
50 SUBROUTINE int_get_fresh_handle( retval )
51 #include "wrf_io_flags.h"
54 ! dont use first 8 handles
55 DO i = 8, int_num_handles
56 IF ( .NOT. int_handle_in_use(i) ) THEN
62 IF ( retval < 0 ) THEN
63 CALL wrf_error_fatal("io_int.F90: int_get_fresh_handle() can not get new handle")
65 int_handle_in_use(i) = .TRUE.
66 first_operation(i) = .TRUE.
67 file_status(i) = WRF_FILE_NOT_OPENED
68 NULLIFY ( int_local_output_buffer )
69 END SUBROUTINE int_get_fresh_handle
71 SUBROUTINE release_handle( i )
72 #include "wrf_io_flags.h"
73 INTEGER, INTENT(IN) :: i
74 IF ( i .LT. 8 .OR. i .GT. int_num_handles ) RETURN
75 IF ( .NOT. int_handle_in_use(i) ) RETURN
76 int_handle_in_use(i) = .FALSE.
78 END SUBROUTINE release_handle
83 SUBROUTINE init_module_ext_internal
86 CALL wrf_sizeof_integer( itypesize )
87 CALL wrf_sizeof_real ( rtypesize )
88 DO i = 1, int_num_handles
89 last_next_var( i ) = ' '
91 END SUBROUTINE init_module_ext_internal
93 ! Returns .TRUE. iff it is OK to write time-independent domain metadata to the
94 ! file referenced by DataHandle. If DataHandle is invalid, .FALSE. is
96 LOGICAL FUNCTION int_ok_to_put_dom_ti( DataHandle )
97 #include "wrf_io_flags.h"
98 INTEGER, INTENT(IN) :: DataHandle
99 CHARACTER*256 :: fname
102 LOGICAL :: dryrun, first_output, retval
103 call ext_int_inquire_filename( DataHandle, fname, filestate, Status )
104 IF ( Status /= 0 ) THEN
107 dryrun = ( filestate .EQ. WRF_FILE_OPENED_NOT_COMMITTED )
108 first_output = int_is_first_operation( DataHandle )
109 ! Note that we want to REPLICATE time-independent domain metadata in the
110 ! output files so the metadata is available during reads. Fortran
111 ! unformatted I/O must be sequential because we don't have fixed record
113 ! retval = .NOT. dryrun .AND. first_output
114 retval = .NOT. dryrun
116 int_ok_to_put_dom_ti = retval
118 END FUNCTION int_ok_to_put_dom_ti
120 ! Returns .TRUE. iff it is OK to read time-independent domain metadata from the
121 ! file referenced by DataHandle. If DataHandle is invalid, .FALSE. is
123 LOGICAL FUNCTION int_ok_to_get_dom_ti( DataHandle )
124 #include "wrf_io_flags.h"
125 INTEGER, INTENT(IN) :: DataHandle
126 CHARACTER*256 :: fname
129 LOGICAL :: dryrun, retval
130 call ext_int_inquire_filename( DataHandle, fname, filestate, Status )
131 IF ( Status /= 0 ) THEN
134 dryrun = ( filestate .EQ. WRF_FILE_OPENED_NOT_COMMITTED )
135 retval = .NOT. dryrun
137 int_ok_to_get_dom_ti = retval
139 END FUNCTION int_ok_to_get_dom_ti
141 ! Returns .TRUE. iff nothing has been read from or written to the file
142 ! referenced by DataHandle. If DataHandle is invalid, .FALSE. is returned.
143 LOGICAL FUNCTION int_is_first_operation( DataHandle )
144 INTEGER, INTENT(IN) :: DataHandle
147 IF ( int_valid_handle ( DataHandle ) ) THEN
148 IF ( int_handle_in_use( DataHandle ) ) THEN
149 retval = first_operation( DataHandle )
152 int_is_first_operation = retval
154 END FUNCTION int_is_first_operation
156 END MODULE module_ext_internal
158 SUBROUTINE ext_int_ioinit( SysDepInfo, Status )
159 USE module_ext_internal
161 CHARACTER*(*), INTENT(IN) :: SysDepInfo
163 CALL init_module_ext_internal
164 END SUBROUTINE ext_int_ioinit
167 SUBROUTINE ext_int_open_for_write( FileName , Comm_compute, Comm_io, SysDepInfo, &
168 DataHandle , Status )
169 USE module_ext_internal
171 INCLUDE 'intio_tags.h'
172 CHARACTER*(*) :: FileName
173 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
174 CHARACTER*(*) :: SysDepInfo
175 INTEGER , INTENT(OUT) :: DataHandle
176 INTEGER , INTENT(OUT) :: Status
178 CALL ext_int_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
179 DataHandle , Status )
180 IF ( Status .NE. 0 ) RETURN
181 CALL ext_int_open_for_write_commit( DataHandle , Status )
183 END SUBROUTINE ext_int_open_for_write
185 !--- open_for_write_begin
186 SUBROUTINE ext_int_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
187 DataHandle , Status )
188 USE module_ext_internal
190 INCLUDE 'intio_tags.h'
191 #include "wrf_io_flags.h"
192 CHARACTER*(*) :: FileName
193 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
194 CHARACTER*(*) :: SysDepInfo
195 INTEGER , INTENT(OUT) :: DataHandle
196 INTEGER , INTENT(OUT) :: Status
197 INTEGER i, tasks_in_group, ierr, comm_io_group
200 CHARACTER*256 :: fname
202 CALL int_get_fresh_handle(i)
203 okay_for_io(i) = .false.
206 io_form = 100 ! dummy value
207 fname = TRIM(FileName)
208 CALL int_gen_ofwb_header( open_file_descriptors(1,i), hdrbufsize, itypesize, &
209 fname,SysDepInfo,io_form,DataHandle )
211 OPEN ( unit=DataHandle, file=TRIM(FileName), form='unformatted', iostat=Status )
213 file_status(DataHandle) = WRF_FILE_OPENED_NOT_COMMITTED
214 file_read_only(DataHandle) = .FALSE.
218 END SUBROUTINE ext_int_open_for_write_begin
220 !--- open_for_write_commit
221 SUBROUTINE ext_int_open_for_write_commit( DataHandle , Status )
222 USE module_ext_internal
224 INCLUDE 'intio_tags.h'
225 #include "wrf_io_flags.h"
226 INTEGER , INTENT(IN ) :: DataHandle
227 INTEGER , INTENT(OUT) :: Status
230 IF ( int_valid_handle ( DataHandle ) ) THEN
231 IF ( int_handle_in_use( DataHandle ) ) THEN
232 okay_for_io( DataHandle ) = .true.
236 first_operation( DataHandle ) = .TRUE.
237 file_status(DataHandle) = WRF_FILE_OPENED_FOR_WRITE
242 END SUBROUTINE ext_int_open_for_write_commit
245 SUBROUTINE ext_int_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
246 DataHandle , Status )
247 USE module_ext_internal
249 #include "wrf_io_flags.h"
250 CHARACTER*(*) :: FileName
251 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
252 CHARACTER*(*) :: SysDepInfo
253 INTEGER , INTENT(OUT) :: DataHandle
254 INTEGER , INTENT(OUT) :: Status
256 CHARACTER*256 :: fname
258 CALL int_get_fresh_handle(i)
260 CurrentDateInFile(i) = ""
261 fname = TRIM(FileName)
263 CALL int_gen_ofr_header( open_file_descriptors(1,i), hdrbufsize, itypesize, &
264 fname,SysDepInfo,DataHandle )
266 OPEN ( unit=DataHandle, status="old", file=TRIM(FileName), form='unformatted', iostat=Status )
267 okay_for_io(DataHandle) = .true.
268 file_status(DataHandle) = WRF_FILE_OPENED_FOR_READ
269 file_read_only(DataHandle) = .TRUE.
272 END SUBROUTINE ext_int_open_for_read
275 SUBROUTINE ext_int_inquire_opened ( DataHandle, FileName , FileStatus, Status )
276 USE module_ext_internal
278 #include "wrf_io_flags.h"
279 INTEGER , INTENT(IN) :: DataHandle
280 CHARACTER*(*) :: FileName
281 INTEGER , INTENT(OUT) :: FileStatus
282 INTEGER , INTENT(OUT) :: Status
283 CHARACTER*256 :: fname
287 CALL ext_int_inquire_filename ( DataHandle, fname, FileStatus, Status )
288 IF ( fname /= TRIM(FileName) ) THEN
289 FileStatus = WRF_FILE_NOT_OPENED
295 END SUBROUTINE ext_int_inquire_opened
297 !--- inquire_filename
298 SUBROUTINE ext_int_inquire_filename ( DataHandle, FileName , FileStatus, Status )
299 USE module_ext_internal
301 #include "wrf_io_flags.h"
302 INTEGER , INTENT(IN) :: DataHandle
303 CHARACTER*(*) :: FileName
304 INTEGER , INTENT(OUT) :: FileStatus
305 INTEGER , INTENT(OUT) :: Status
306 CHARACTER *4096 SysDepInfo
307 INTEGER locDataHandle
308 CHARACTER*256 :: fname
312 FileStatus = WRF_FILE_NOT_OPENED
314 IF ( int_valid_handle( DataHandle ) ) THEN
315 IF ( int_handle_in_use( DataHandle ) ) THEN
316 ! Note that the formats for these headers differ.
317 IF ( file_read_only(DataHandle) ) THEN
318 CALL int_get_ofr_header( open_file_descriptors(1,DataHandle), hdrbufsize, itypesize, &
319 fname,SysDepInfo,locDataHandle )
321 CALL int_get_ofwb_header( open_file_descriptors(1,DataHandle), hdrbufsize, itypesize, &
322 fname,SysDepInfo,io_form,locDataHandle )
324 FileName = TRIM(fname)
325 FileStatus = file_status(DataHandle)
329 END SUBROUTINE ext_int_inquire_filename
332 SUBROUTINE ext_int_iosync ( DataHandle, Status )
333 USE module_ext_internal
335 INTEGER , INTENT(IN) :: DataHandle
336 INTEGER , INTENT(OUT) :: Status
340 END SUBROUTINE ext_int_iosync
343 SUBROUTINE ext_int_ioclose ( DataHandle, Status )
344 USE module_ext_internal
346 INTEGER DataHandle, Status
348 IF ( int_valid_handle (DataHandle) ) THEN
349 IF ( int_handle_in_use( DataHandle ) ) THEN
352 CALL release_handle(DataHandle)
358 END SUBROUTINE ext_int_ioclose
361 SUBROUTINE ext_int_ioexit( Status )
363 USE module_ext_internal
365 INCLUDE 'intio_tags.h'
366 INTEGER , INTENT(OUT) :: Status
367 INTEGER :: DataHandle
372 END SUBROUTINE ext_int_ioexit
375 SUBROUTINE ext_int_get_next_time ( DataHandle, DateStr, Status )
376 USE module_ext_internal
378 INCLUDE 'intio_tags.h'
379 INTEGER , INTENT(IN) :: DataHandle
380 CHARACTER*(*) :: DateStr
381 INTEGER , INTENT(OUT) :: Status
383 CHARACTER*132 locElement, dummyvar
387 INTEGER :: locDataHandle
388 CHARACTER*132 :: locDateStr
389 CHARACTER*132 :: locData
390 CHARACTER*132 :: locVarName
391 integer :: locFieldType
394 integer :: locDomainDesc
395 character*132 :: locMemoryOrder
396 character*132 :: locStagger
397 character*132 , dimension (3) :: locDimNames
398 integer ,dimension(3) :: locDomainStart, locDomainEnd
399 integer ,dimension(3) :: locMemoryStart, locMemoryEnd
400 integer ,dimension(3) :: locPatchStart, locPatchEnd
404 integer ii,jj,kk,myrank
405 INTEGER inttypesize, realtypesize
406 REAL, DIMENSION(1) :: Field ! dummy
408 IF ( .NOT. int_valid_handle( DataHandle ) ) THEN
409 CALL wrf_error_fatal("io_int.F90: ext_int_get_next_time: invalid data handle" )
411 IF ( .NOT. int_handle_in_use( DataHandle ) ) THEN
412 CALL wrf_error_fatal("io_int.F90: ext_int_get_next_time: DataHandle not opened" )
414 inttypesize = itypesize
415 realtypesize = rtypesize
417 READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows
418 IF ( istat .EQ. 0 ) THEN
420 IF ( code .EQ. int_field ) THEN
421 CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, &
422 locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, &
423 locDomainDesc , locMemoryOrder , locStagger , locDimNames , &
424 locDomainStart , locDomainEnd , &
425 locMemoryStart , locMemoryEnd , &
426 locPatchStart , locPatchEnd )
427 IF ( TRIM(locDateStr) .NE. TRIM(CurrentDateInFile(DataHandle) ) ) THEN ! control break, return this date
428 DateStr = TRIM(locDateStr)
429 CurrentDateInFile(DataHandle) = TRIM(DateStr)
430 BACKSPACE ( unit=DataHandle )
434 READ( unit=DataHandle, iostat=istat )
436 ELSE IF ( code .EQ. int_dom_td_char ) THEN
437 CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, &
438 locDataHandle, locDateStr, locElement, locData, loccode )
439 IF ( TRIM(locDateStr) .NE. TRIM(CurrentDateInFile(DataHandle) ) ) THEN ! control break, return this date
440 DateStr = TRIM(locDateStr)
441 CurrentDateInFile(DataHandle) = TRIM(DateStr)
442 BACKSPACE ( unit=DataHandle )
446 READ( unit=DataHandle, iostat=istat )
457 END SUBROUTINE ext_int_get_next_time
460 SUBROUTINE ext_int_set_time ( DataHandle, DateStr, Status )
461 USE module_ext_internal
463 INCLUDE 'intio_tags.h'
464 INTEGER , INTENT(IN) :: DataHandle
465 CHARACTER*(*) :: DateStr
466 INTEGER , INTENT(OUT) :: Status
468 CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
469 DataHandle, "TIMESTAMP", "", TRIM(DateStr), int_set_time )
470 WRITE( unit=DataHandle ) hdrbuf
473 END SUBROUTINE ext_int_set_time
476 SUBROUTINE ext_int_get_var_info ( DataHandle , VarName , NDim , MemoryOrder , Stagger , &
477 DomainStart , DomainEnd , WrfType, Status )
478 USE module_ext_internal
480 INCLUDE 'intio_tags.h'
481 integer ,intent(in) :: DataHandle
482 character*(*) ,intent(in) :: VarName
483 integer ,intent(out) :: NDim
484 character*(*) ,intent(out) :: MemoryOrder
485 character*(*) ,intent(out) :: Stagger
486 integer ,dimension(*) ,intent(out) :: DomainStart, DomainEnd
487 integer ,intent(out) :: WrfType
488 integer ,intent(out) :: Status
491 INTEGER :: locDataHandle
492 CHARACTER*132 :: locDateStr
493 CHARACTER*132 :: locVarName
494 integer :: locFieldType
497 integer :: locDomainDesc
498 character*132 :: locMemoryOrder
499 character*132 :: locStagger
500 character*132 , dimension (3) :: locDimNames
501 integer ,dimension(3) :: locDomainStart, locDomainEnd
502 integer ,dimension(3) :: locMemoryStart, locMemoryEnd
503 integer ,dimension(3) :: locPatchStart, locPatchEnd
506 integer ii,jj,kk,myrank
507 INTEGER inttypesize, realtypesize, istat, code
508 REAL, DIMENSION(1) :: Field ! dummy
510 IF ( .NOT. int_valid_handle( DataHandle ) ) THEN
511 CALL wrf_error_fatal("io_int.F90: ext_int_get_var_info: invalid data handle" )
513 IF ( .NOT. int_handle_in_use( DataHandle ) ) THEN
514 CALL wrf_error_fatal("io_int.F90: ext_int_get_var_info: DataHandle not opened" )
516 inttypesize = itypesize
517 realtypesize = rtypesize
519 READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows
520 IF ( istat .EQ. 0 ) THEN
522 IF ( code .EQ. int_field ) THEN
523 CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, &
524 locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, &
525 locDomainDesc , MemoryOrder , locStagger , locDimNames , &
526 locDomainStart , locDomainEnd , &
527 locMemoryStart , locMemoryEnd , &
528 locPatchStart , locPatchEnd )
530 IF ( LEN(TRIM(MemoryOrder)) .EQ. 3 ) THEN
532 ELSE IF ( LEN(TRIM(MemoryOrder)) .EQ. 2 ) THEN
534 ELSE IF ( TRIM(MemoryOrder) .EQ. '0' ) THEN
540 DomainStart(1:3) = locDomainStart(1:3)
541 DomainEnd(1:3) = locDomainEnd(1:3)
542 WrfType = locFieldType
543 BACKSPACE ( unit=DataHandle )
555 END SUBROUTINE ext_int_get_var_info
558 SUBROUTINE ext_int_get_next_var ( DataHandle, VarName, Status )
559 USE module_ext_internal
561 include 'intio_tags.h'
562 include 'wrf_status_codes.h'
563 INTEGER , INTENT(IN) :: DataHandle
564 CHARACTER*(*) :: VarName
565 INTEGER , INTENT(OUT) :: Status
568 INTEGER :: locDataHandle
569 CHARACTER*132 :: locDateStr
570 CHARACTER*132 :: locVarName
571 integer :: locFieldType
574 integer :: locDomainDesc
575 character*132 :: locMemoryOrder
576 character*132 :: locStagger
577 character*132 , dimension (3) :: locDimNames
578 integer ,dimension(3) :: locDomainStart, locDomainEnd
579 integer ,dimension(3) :: locMemoryStart, locMemoryEnd
580 integer ,dimension(3) :: locPatchStart, locPatchEnd
582 character*128 locElement, strData, dumstr
583 integer loccode, loccount
588 integer ii,jj,kk,myrank
589 INTEGER inttypesize, realtypesize, istat, code
590 REAL, DIMENSION(1) :: Field ! dummy
592 IF ( .NOT. int_valid_handle( DataHandle ) ) THEN
593 CALL wrf_error_fatal("io_int.F90: ext_int_get_next_var: invalid data handle" )
595 IF ( .NOT. int_handle_in_use( DataHandle ) ) THEN
596 CALL wrf_error_fatal("io_int.F90: ext_int_get_next_var: DataHandle not opened" )
598 inttypesize = itypesize
599 realtypesize = rtypesize
602 READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows
603 IF ( istat .EQ. 0 ) THEN
606 IF ( code .EQ. int_dom_ti_char ) THEN
607 CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
608 locDataHandle, locElement, dumstr, strData, loccode )
610 IF ( code .EQ. int_dom_ti_integer ) THEN
611 CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, &
612 locDataHandle, locElement, iData, loccount, code )
614 IF ( code .EQ. int_dom_ti_real ) THEN
615 CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, &
616 locDataHandle, locElement, rData, loccount, code )
619 IF ( code .EQ. int_field ) THEN
620 CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, &
621 locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, &
622 locDomainDesc , locMemoryOrder , locStagger , locDimNames , &
623 locDomainStart , locDomainEnd , &
624 locMemoryStart , locMemoryEnd , &
625 locPatchStart , locPatchEnd )
627 IF (TRIM(locDateStr) .NE. TRIM(CurrentDateInFile(DataHandle))) THEN
628 Status = WRF_WARN_VAR_EOF !-6 ! signal past last var in time frame
629 BACKSPACE ( unit=DataHandle )
630 last_next_var( DataHandle ) = ""
633 VarName = TRIM(locVarName)
634 IF ( last_next_var( DataHandle ) .NE. VarName ) THEN
635 BACKSPACE ( unit=DataHandle )
636 last_next_var( DataHandle ) = VarName
638 READ( unit=DataHandle, iostat=istat )
654 END SUBROUTINE ext_int_get_next_var
657 SUBROUTINE ext_int_get_dom_ti_real ( DataHandle,Element, Data, Count, Outcount, Status )
658 USE module_ext_internal
660 INCLUDE 'intio_tags.h'
661 INTEGER , INTENT(IN) :: DataHandle
662 CHARACTER*(*) :: Element
663 REAL , INTENT(OUT) :: Data(*)
664 INTEGER , INTENT(IN) :: Count
665 INTEGER , INTENT(OUT) :: Outcount
666 INTEGER , INTENT(OUT) :: Status
667 INTEGER loccount, code, istat, locDataHandle
668 CHARACTER*132 :: locElement, mess
672 IF ( int_valid_handle( DataHandle ) ) THEN
673 IF ( int_handle_in_use( DataHandle ) ) THEN
674 ! Do nothing unless it is time to read time-independent domain metadata.
675 IF ( int_ok_to_get_dom_ti( DataHandle ) ) THEN
677 DO WHILE ( keepgoing )
678 READ( unit=DataHandle , iostat = istat ) hdrbuf
679 IF ( istat .EQ. 0 ) THEN
681 IF ( code .EQ. int_dom_ti_real ) THEN
682 CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, &
683 locDataHandle, locElement, Data, loccount, code )
684 IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN
685 IF ( loccount .GT. Count ) THEN
686 CALL wrf_error_fatal( 'io_int.F90: ext_int_get_dom_ti_real: loccount .GT. Count' )
688 keepgoing = .false. ; Status = 0
690 ELSE IF ( .NOT. ( code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_logical .OR. &
691 code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. &
692 code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_logical .OR. &
693 code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. &
694 code .EQ. int_dom_td_real ) ) THEN
695 BACKSPACE ( unit=DataHandle )
696 keepgoing = .false. ; Status = 2
699 keepgoing = .false. ; Status = 1
706 END SUBROUTINE ext_int_get_dom_ti_real
709 SUBROUTINE ext_int_put_dom_ti_real ( DataHandle,Element, Data, Count, Status )
710 USE module_ext_internal
712 INCLUDE 'intio_tags.h'
713 INTEGER , INTENT(IN) :: DataHandle
714 CHARACTER*(*) :: Element
715 REAL , INTENT(IN) :: Data(*)
716 INTEGER , INTENT(IN) :: Count
717 INTEGER , INTENT(OUT) :: Status
721 IF ( int_valid_handle( DataHandle ) ) THEN
722 IF ( int_handle_in_use( DataHandle ) ) THEN
723 ! Do nothing unless it is time to write time-independent domain metadata.
724 IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN
725 CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, &
726 DataHandle, Element, Data, Count, int_dom_ti_real )
727 WRITE( unit=DataHandle ) hdrbuf
733 END SUBROUTINE ext_int_put_dom_ti_real
735 !--- get_dom_ti_double
736 SUBROUTINE ext_int_get_dom_ti_double ( DataHandle,Element, Data, Count, Outcount, Status )
737 USE module_ext_internal
739 INTEGER , INTENT(IN) :: DataHandle
740 CHARACTER*(*) :: Element
741 real*8 , INTENT(OUT) :: Data(*)
742 INTEGER , INTENT(IN) :: Count
743 INTEGER , INTENT(OUT) :: OutCount
744 INTEGER , INTENT(OUT) :: Status
745 ! Do nothing unless it is time to read time-independent domain metadata.
746 IF ( int_ok_to_get_dom_ti( DataHandle ) ) THEN
747 CALL wrf_error_fatal('ext_int_get_dom_ti_double not supported yet')
750 END SUBROUTINE ext_int_get_dom_ti_double
752 !--- put_dom_ti_double
753 SUBROUTINE ext_int_put_dom_ti_double ( DataHandle,Element, Data, Count, Status )
754 USE module_ext_internal
756 INTEGER , INTENT(IN) :: DataHandle
757 CHARACTER*(*) :: Element
758 real*8 , INTENT(IN) :: Data(*)
759 INTEGER , INTENT(IN) :: Count
760 INTEGER , INTENT(OUT) :: Status
761 ! Do nothing unless it is time to write time-independent domain metadata.
762 IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN
763 CALL wrf_error_fatal('ext_int_put_dom_ti_double not supported yet')
766 END SUBROUTINE ext_int_put_dom_ti_double
768 !--- get_dom_ti_integer
769 SUBROUTINE ext_int_get_dom_ti_integer ( DataHandle,Element, Data, Count, Outcount, Status )
770 USE module_ext_internal
772 INCLUDE 'intio_tags.h'
773 INTEGER , INTENT(IN) :: DataHandle
774 CHARACTER*(*) :: Element
775 integer , INTENT(OUT) :: Data(*)
776 INTEGER , INTENT(IN) :: Count
777 INTEGER , INTENT(OUT) :: OutCount
778 INTEGER , INTENT(OUT) :: Status
779 INTEGER loccount, code, istat, locDataHandle
780 CHARACTER*132 locElement, mess
784 IF ( int_valid_handle( DataHandle ) ) THEN
785 IF ( int_handle_in_use( DataHandle ) ) THEN
786 ! Do nothing unless it is time to read time-independent domain metadata.
787 IF ( int_ok_to_get_dom_ti( DataHandle ) ) THEN
789 DO WHILE ( keepgoing )
790 READ( unit=DataHandle , iostat = istat ) hdrbuf
791 IF ( istat .EQ. 0 ) THEN
793 IF ( code .EQ. int_dom_ti_integer ) THEN
794 CALL int_get_ti_header( hdrbuf, hdrbufsize, itypesize, rtypesize, &
795 locDataHandle, locElement, Data, loccount, code )
796 IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN
797 IF ( loccount .GT. Count ) THEN
798 CALL wrf_error_fatal( 'io_int.F90: ext_int_get_dom_ti_integer: loccount .GT. Count' )
800 keepgoing = .false. ; Status = 0
803 ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. &
804 code .EQ. int_dom_ti_char .OR. code .EQ. int_dom_ti_double .OR. &
805 code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. &
806 code .EQ. int_dom_td_char .OR. code .EQ. int_dom_td_double .OR. &
807 code .EQ. int_dom_td_integer ) ) THEN
808 BACKSPACE ( unit=DataHandle )
809 keepgoing = .false. ; Status = 1
812 keepgoing = .false. ; Status = 1
819 END SUBROUTINE ext_int_get_dom_ti_integer
821 !--- put_dom_ti_integer
822 SUBROUTINE ext_int_put_dom_ti_integer ( DataHandle,Element, Data, Count, Status )
823 USE module_ext_internal
825 INCLUDE 'intio_tags.h'
826 INTEGER , INTENT(IN) :: DataHandle
827 CHARACTER*(*) :: Element
828 INTEGER , INTENT(IN) :: Data(*)
829 INTEGER , INTENT(IN) :: Count
830 INTEGER , INTENT(OUT) :: Status
833 IF ( int_valid_handle ( Datahandle ) ) THEN
834 IF ( int_handle_in_use( DataHandle ) ) THEN
835 ! Do nothing unless it is time to write time-independent domain metadata.
836 IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN
837 CALL int_gen_ti_header( hdrbuf, hdrbufsize, itypesize, itypesize, &
838 DataHandle, Element, Data, Count, int_dom_ti_integer )
839 WRITE( unit=DataHandle ) hdrbuf
845 END SUBROUTINE ext_int_put_dom_ti_integer
847 !--- get_dom_ti_logical
848 SUBROUTINE ext_int_get_dom_ti_logical ( DataHandle,Element, Data, Count, Outcount, Status )
849 USE module_ext_internal
851 INTEGER , INTENT(IN) :: DataHandle
852 CHARACTER*(*) :: Element
853 logical , INTENT(OUT) :: Data(*)
854 INTEGER , INTENT(IN) :: Count
855 INTEGER , INTENT(OUT) :: OutCount
856 INTEGER , INTENT(OUT) :: Status
857 ! Do nothing unless it is time to read time-independent domain metadata.
858 IF ( int_ok_to_get_dom_ti( DataHandle ) ) THEN
859 CALL wrf_message('ext_int_get_dom_ti_logical not supported yet')
862 END SUBROUTINE ext_int_get_dom_ti_logical
864 !--- put_dom_ti_logical
865 SUBROUTINE ext_int_put_dom_ti_logical ( DataHandle,Element, Data, Count, Status )
866 USE module_ext_internal
868 INTEGER , INTENT(IN) :: DataHandle
869 CHARACTER*(*) :: Element
870 logical , INTENT(IN) :: Data(*)
871 INTEGER , INTENT(IN) :: Count
872 INTEGER , INTENT(OUT) :: Status
873 ! Do nothing unless it is time to write time-independent domain metadata.
874 IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN
875 CALL wrf_message('ext_int_put_dom_ti_logical not supported yet')
878 END SUBROUTINE ext_int_put_dom_ti_logical
881 SUBROUTINE ext_int_get_dom_ti_char ( DataHandle,Element, Data, Status )
882 USE module_ext_internal
884 INCLUDE 'intio_tags.h'
885 INTEGER , INTENT(IN) :: DataHandle
886 CHARACTER*(*) :: Element
887 CHARACTER*(*) :: Data
888 INTEGER , INTENT(OUT) :: Status
889 INTEGER istat, code, i
890 CHARACTER*79 dumstr, locElement
891 INTEGER locDataHandle
895 IF ( int_valid_handle( DataHandle ) ) THEN
896 IF ( int_handle_in_use( DataHandle ) ) THEN
897 ! Do nothing unless it is time to read time-independent domain metadata.
898 IF ( int_ok_to_get_dom_ti( DataHandle ) ) THEN
900 DO WHILE ( keepgoing )
901 READ( unit=DataHandle , iostat = istat ) hdrbuf
903 IF ( istat .EQ. 0 ) THEN
905 IF ( code .EQ. int_dom_ti_char ) THEN
906 CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
907 locDataHandle, locElement, dumstr, Data, code )
908 IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN
909 keepgoing = .false. ; Status = 0
911 ELSE IF ( .NOT. ( code .EQ. int_dom_ti_real .OR. code .EQ. int_dom_ti_logical .OR. &
912 code .EQ. int_dom_ti_integer .OR. code .EQ. int_dom_ti_double .OR. &
913 code .EQ. int_dom_td_real .OR. code .EQ. int_dom_td_logical .OR. &
914 code .EQ. int_dom_td_integer .OR. code .EQ. int_dom_td_double .OR. &
915 code .EQ. int_dom_td_char ) ) THEN
916 BACKSPACE ( unit=DataHandle )
917 keepgoing = .false. ; Status = 1
920 keepgoing = .false. ; Status = 1
927 END SUBROUTINE ext_int_get_dom_ti_char
930 SUBROUTINE ext_int_put_dom_ti_char ( DataHandle, Element, Data, Status )
931 USE module_ext_internal
933 INCLUDE 'intio_tags.h'
934 INTEGER , INTENT(IN) :: DataHandle
935 CHARACTER*(*) :: Element
936 CHARACTER*(*) :: Data
937 INTEGER , INTENT(OUT) :: Status
942 IF ( int_valid_handle ( Datahandle ) ) THEN
943 IF ( int_handle_in_use( DataHandle ) ) THEN
944 ! Do nothing unless it is time to write time-independent domain metadata.
945 IF ( int_ok_to_put_dom_ti( DataHandle ) ) THEN
946 CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
947 DataHandle, Element, "", Data, int_dom_ti_char )
948 WRITE( unit=DataHandle ) hdrbuf
954 END SUBROUTINE ext_int_put_dom_ti_char
957 SUBROUTINE ext_int_get_dom_td_real ( DataHandle,Element, DateStr, Data, Count, Outcount, Status )
959 INTEGER , INTENT(IN) :: DataHandle
960 CHARACTER*(*) :: Element
961 CHARACTER*(*) :: DateStr
962 real , INTENT(OUT) :: Data(*)
963 INTEGER , INTENT(IN) :: Count
964 INTEGER , INTENT(OUT) :: OutCount
965 INTEGER , INTENT(OUT) :: Status
967 END SUBROUTINE ext_int_get_dom_td_real
970 SUBROUTINE ext_int_put_dom_td_real ( DataHandle,Element, DateStr, Data, Count, Status )
972 INTEGER , INTENT(IN) :: DataHandle
973 CHARACTER*(*) :: Element
974 CHARACTER*(*) :: DateStr
975 real , INTENT(IN) :: Data(*)
976 INTEGER , INTENT(IN) :: Count
977 INTEGER , INTENT(OUT) :: Status
979 END SUBROUTINE ext_int_put_dom_td_real
981 !--- get_dom_td_double
982 SUBROUTINE ext_int_get_dom_td_double ( DataHandle,Element, DateStr, Data, Count, Outcount, Status )
984 INTEGER , INTENT(IN) :: DataHandle
985 CHARACTER*(*) :: Element
986 CHARACTER*(*) :: DateStr
987 real*8 , INTENT(OUT) :: Data(*)
988 INTEGER , INTENT(IN) :: Count
989 INTEGER , INTENT(OUT) :: OutCount
990 INTEGER , INTENT(OUT) :: Status
991 CALL wrf_error_fatal('ext_int_get_dom_td_double not supported yet')
993 END SUBROUTINE ext_int_get_dom_td_double
995 !--- put_dom_td_double
996 SUBROUTINE ext_int_put_dom_td_double ( DataHandle,Element, DateStr, Data, Count, Status )
998 INTEGER , INTENT(IN) :: DataHandle
999 CHARACTER*(*) :: Element
1000 CHARACTER*(*) :: DateStr
1001 real*8 , INTENT(IN) :: Data(*)
1002 INTEGER , INTENT(IN) :: Count
1003 INTEGER , INTENT(OUT) :: Status
1004 CALL wrf_error_fatal('ext_int_get_dom_td_double not supported yet')
1006 END SUBROUTINE ext_int_put_dom_td_double
1008 !--- get_dom_td_integer
1009 SUBROUTINE ext_int_get_dom_td_integer ( DataHandle,Element, DateStr, Data, Count, Outcount, Status )
1011 INTEGER , INTENT(IN) :: DataHandle
1012 CHARACTER*(*) :: Element
1013 CHARACTER*(*) :: DateStr
1014 integer , INTENT(OUT) :: Data(*)
1015 INTEGER , INTENT(IN) :: Count
1016 INTEGER , INTENT(OUT) :: OutCount
1017 INTEGER , INTENT(OUT) :: Status
1019 END SUBROUTINE ext_int_get_dom_td_integer
1021 !--- put_dom_td_integer
1022 SUBROUTINE ext_int_put_dom_td_integer ( DataHandle,Element, DateStr, Data, Count, Status )
1024 INTEGER , INTENT(IN) :: DataHandle
1025 CHARACTER*(*) :: Element
1026 CHARACTER*(*) :: DateStr
1027 integer , INTENT(IN) :: Data(*)
1028 INTEGER , INTENT(IN) :: Count
1029 INTEGER , INTENT(OUT) :: Status
1031 END SUBROUTINE ext_int_put_dom_td_integer
1033 !--- get_dom_td_logical
1034 SUBROUTINE ext_int_get_dom_td_logical ( DataHandle,Element, DateStr, Data, Count, Outcount, Status )
1036 INTEGER , INTENT(IN) :: DataHandle
1037 CHARACTER*(*) :: Element
1038 CHARACTER*(*) :: DateStr
1039 logical , INTENT(OUT) :: Data(*)
1040 INTEGER , INTENT(IN) :: Count
1041 INTEGER , INTENT(OUT) :: OutCount
1042 INTEGER , INTENT(OUT) :: Status
1044 END SUBROUTINE ext_int_get_dom_td_logical
1046 !--- put_dom_td_logical
1047 SUBROUTINE ext_int_put_dom_td_logical ( DataHandle,Element, DateStr, Data, Count, Status )
1049 INTEGER , INTENT(IN) :: DataHandle
1050 CHARACTER*(*) :: Element
1051 CHARACTER*(*) :: DateStr
1052 logical , INTENT(IN) :: Data(*)
1053 INTEGER , INTENT(IN) :: Count
1054 INTEGER , INTENT(OUT) :: Status
1056 END SUBROUTINE ext_int_put_dom_td_logical
1058 !--- get_dom_td_char
1059 SUBROUTINE ext_int_get_dom_td_char ( DataHandle,Element, DateStr, Data, Status )
1060 USE module_ext_internal
1062 INCLUDE 'intio_tags.h'
1063 INTEGER , INTENT(IN) :: DataHandle
1064 CHARACTER*(*) :: Element
1065 CHARACTER*(*) :: Data, DateStr
1066 INTEGER , INTENT(OUT) :: Status
1067 INTEGER istat, code, i
1068 CHARACTER*79 dumstr, locElement, locDatestr
1069 INTEGER locDataHandle
1072 IF ( int_valid_handle( DataHandle ) ) THEN
1073 IF ( int_handle_in_use( DataHandle ) ) THEN
1075 DO WHILE ( keepgoing )
1076 READ( unit=DataHandle , iostat = istat ) hdrbuf
1078 IF ( istat .EQ. 0 ) THEN
1080 IF ( code .EQ. int_dom_td_char ) THEN
1081 CALL int_get_td_header_char( hdrbuf, hdrbufsize, itypesize, &
1082 locDataHandle, locDateStr, locElement, Data, code )
1083 IF ( TRIM(locElement) .EQ. TRIM(Element) ) THEN
1084 keepgoing = .false. ; Status = 0
1087 BACKSPACE ( unit=DataHandle )
1088 keepgoing = .false. ; Status = 1
1091 keepgoing = .false. ; Status = 1
1097 END SUBROUTINE ext_int_get_dom_td_char
1099 !--- put_dom_td_char
1100 SUBROUTINE ext_int_put_dom_td_char ( DataHandle,Element, DateStr, Data, Status )
1101 USE module_ext_internal
1103 INCLUDE 'intio_tags.h'
1104 INTEGER , INTENT(IN) :: DataHandle
1105 CHARACTER*(*) :: Element
1106 CHARACTER*(*) :: Data, DateStr
1107 INTEGER , INTENT(OUT) :: Status
1111 IF ( int_valid_handle ( Datahandle ) ) THEN
1112 IF ( int_handle_in_use( DataHandle ) ) THEN
1113 CALL int_gen_td_header_char( hdrbuf, hdrbufsize, itypesize, &
1114 DataHandle, DateStr, Element, Data, int_dom_td_char )
1115 WRITE( unit=DataHandle ) hdrbuf
1120 END SUBROUTINE ext_int_put_dom_td_char
1122 !--- get_var_ti_real
1123 SUBROUTINE ext_int_get_var_ti_real ( DataHandle,Element, Varname, Data, Count, Outcount, Status )
1125 INTEGER , INTENT(IN) :: DataHandle
1126 CHARACTER*(*) :: Element
1127 CHARACTER*(*) :: VarName
1128 real , INTENT(OUT) :: Data(*)
1129 INTEGER , INTENT(IN) :: Count
1130 INTEGER , INTENT(OUT) :: OutCount
1131 INTEGER , INTENT(OUT) :: Status
1133 END SUBROUTINE ext_int_get_var_ti_real
1135 !--- put_var_ti_real
1136 SUBROUTINE ext_int_put_var_ti_real ( DataHandle,Element, Varname, Data, Count, Status )
1138 INTEGER , INTENT(IN) :: DataHandle
1139 CHARACTER*(*) :: Element
1140 CHARACTER*(*) :: VarName
1141 real , INTENT(IN) :: Data(*)
1142 INTEGER , INTENT(IN) :: Count
1143 INTEGER , INTENT(OUT) :: Status
1145 END SUBROUTINE ext_int_put_var_ti_real
1147 !--- get_var_ti_double
1148 SUBROUTINE ext_int_get_var_ti_double ( DataHandle,Element, Varname, Data, Count, Outcount, Status )
1150 INTEGER , INTENT(IN) :: DataHandle
1151 CHARACTER*(*) :: Element
1152 CHARACTER*(*) :: VarName
1153 real*8 , INTENT(OUT) :: Data(*)
1154 INTEGER , INTENT(IN) :: Count
1155 INTEGER , INTENT(OUT) :: OutCount
1156 INTEGER , INTENT(OUT) :: Status
1157 CALL wrf_error_fatal('ext_int_get_var_ti_double not supported yet')
1159 END SUBROUTINE ext_int_get_var_ti_double
1161 !--- put_var_ti_double
1162 SUBROUTINE ext_int_put_var_ti_double ( DataHandle,Element, Varname, Data, Count, Status )
1164 INTEGER , INTENT(IN) :: DataHandle
1165 CHARACTER*(*) :: Element
1166 CHARACTER*(*) :: VarName
1167 real*8 , INTENT(IN) :: Data(*)
1168 INTEGER , INTENT(IN) :: Count
1169 INTEGER , INTENT(OUT) :: Status
1170 CALL wrf_error_fatal('ext_int_put_var_ti_double not supported yet')
1172 END SUBROUTINE ext_int_put_var_ti_double
1174 !--- get_var_ti_integer
1175 SUBROUTINE ext_int_get_var_ti_integer ( DataHandle,Element, Varname, Data, Count, Outcount, Status )
1177 INTEGER , INTENT(IN) :: DataHandle
1178 CHARACTER*(*) :: Element
1179 CHARACTER*(*) :: VarName
1180 integer , INTENT(OUT) :: Data(*)
1181 INTEGER , INTENT(IN) :: Count
1182 INTEGER , INTENT(OUT) :: OutCount
1183 INTEGER , INTENT(OUT) :: Status
1185 END SUBROUTINE ext_int_get_var_ti_integer
1187 !--- put_var_ti_integer
1188 SUBROUTINE ext_int_put_var_ti_integer ( DataHandle,Element, Varname, Data, Count, Status )
1190 INTEGER , INTENT(IN) :: DataHandle
1191 CHARACTER*(*) :: Element
1192 CHARACTER*(*) :: VarName
1193 integer , INTENT(IN) :: Data(*)
1194 INTEGER , INTENT(IN) :: Count
1195 INTEGER , INTENT(OUT) :: Status
1197 END SUBROUTINE ext_int_put_var_ti_integer
1199 !--- get_var_ti_logical
1200 SUBROUTINE ext_int_get_var_ti_logical ( DataHandle,Element, Varname, Data, Count, Outcount, Status )
1202 INTEGER , INTENT(IN) :: DataHandle
1203 CHARACTER*(*) :: Element
1204 CHARACTER*(*) :: VarName
1205 logical , INTENT(OUT) :: Data(*)
1206 INTEGER , INTENT(IN) :: Count
1207 INTEGER , INTENT(OUT) :: OutCount
1208 INTEGER , INTENT(OUT) :: Status
1210 END SUBROUTINE ext_int_get_var_ti_logical
1212 !--- put_var_ti_logical
1213 SUBROUTINE ext_int_put_var_ti_logical ( DataHandle,Element, Varname, Data, Count, Status )
1215 INTEGER , INTENT(IN) :: DataHandle
1216 CHARACTER*(*) :: Element
1217 CHARACTER*(*) :: VarName
1218 logical , INTENT(IN) :: Data(*)
1219 INTEGER , INTENT(IN) :: Count
1220 INTEGER , INTENT(OUT) :: Status
1222 END SUBROUTINE ext_int_put_var_ti_logical
1224 !--- get_var_ti_char
1225 SUBROUTINE ext_int_get_var_ti_char ( DataHandle,Element, Varname, Data, Status )
1226 USE module_ext_internal
1228 INCLUDE 'intio_tags.h'
1229 INTEGER , INTENT(IN) :: DataHandle
1230 CHARACTER*(*) :: Element
1231 CHARACTER*(*) :: VarName
1232 CHARACTER*(*) :: Data
1233 INTEGER , INTENT(OUT) :: Status
1234 INTEGER locDataHandle, code
1235 CHARACTER*132 locElement, locVarName
1236 IF ( int_valid_handle (DataHandle) ) THEN
1237 IF ( int_handle_in_use( DataHandle ) ) THEN
1238 READ( unit=DataHandle ) hdrbuf
1239 IF ( hdrbuf(2) .EQ. int_var_ti_char ) THEN
1240 CALL int_get_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
1241 locDataHandle, locElement, locVarName, Data, code )
1242 IF ( .NOT. ( code .EQ. int_var_ti_real .OR. code .EQ. int_var_ti_logical .OR. &
1243 code .EQ. int_var_ti_char .OR. code .EQ. int_var_ti_double ) ) THEN
1244 BACKSPACE ( unit=DataHandle )
1249 BACKSPACE ( unit=DataHandle )
1263 END SUBROUTINE ext_int_get_var_ti_char
1265 !--- put_var_ti_char
1266 SUBROUTINE ext_int_put_var_ti_char ( DataHandle,Element, Varname, Data, Status )
1267 USE module_ext_internal
1269 INCLUDE 'intio_tags.h'
1270 INTEGER , INTENT(IN) :: DataHandle
1271 CHARACTER*(*) :: Element
1272 CHARACTER*(*) :: VarName
1273 CHARACTER*(*) :: Data
1274 INTEGER , INTENT(OUT) :: Status
1277 IF ( int_valid_handle (DataHandle) ) THEN
1278 IF ( int_handle_in_use( DataHandle ) ) THEN
1279 CALL int_gen_ti_header_char( hdrbuf, hdrbufsize, itypesize, &
1280 DataHandle, TRIM(Element), TRIM(VarName), TRIM(Data), int_var_ti_char )
1281 WRITE( unit=DataHandle ) hdrbuf
1286 END SUBROUTINE ext_int_put_var_ti_char
1288 !--- get_var_td_real
1289 SUBROUTINE ext_int_get_var_td_real ( DataHandle,Element, DateStr,Varname, Data, Count, Outcount, Status )
1291 INTEGER , INTENT(IN) :: DataHandle
1292 CHARACTER*(*) :: Element
1293 CHARACTER*(*) :: DateStr
1294 CHARACTER*(*) :: VarName
1295 real , INTENT(OUT) :: Data(*)
1296 INTEGER , INTENT(IN) :: Count
1297 INTEGER , INTENT(OUT) :: OutCount
1298 INTEGER , INTENT(OUT) :: Status
1300 END SUBROUTINE ext_int_get_var_td_real
1302 !--- put_var_td_real
1303 SUBROUTINE ext_int_put_var_td_real ( DataHandle,Element, DateStr,Varname, Data, Count, Status )
1305 INTEGER , INTENT(IN) :: DataHandle
1306 CHARACTER*(*) :: Element
1307 CHARACTER*(*) :: DateStr
1308 CHARACTER*(*) :: VarName
1309 real , INTENT(IN) :: Data(*)
1310 INTEGER , INTENT(IN) :: Count
1311 INTEGER , INTENT(OUT) :: Status
1313 END SUBROUTINE ext_int_put_var_td_real
1315 !--- get_var_td_double
1316 SUBROUTINE ext_int_get_var_td_double ( DataHandle,Element, DateStr,Varname, Data, Count, Outcount, Status )
1318 INTEGER , INTENT(IN) :: DataHandle
1319 CHARACTER*(*) :: Element
1320 CHARACTER*(*) :: DateStr
1321 CHARACTER*(*) :: VarName
1322 real*8 , INTENT(OUT) :: Data(*)
1323 INTEGER , INTENT(IN) :: Count
1324 INTEGER , INTENT(OUT) :: OutCount
1325 INTEGER , INTENT(OUT) :: Status
1326 CALL wrf_error_fatal('ext_int_get_var_td_double not supported yet')
1328 END SUBROUTINE ext_int_get_var_td_double
1330 !--- put_var_td_double
1331 SUBROUTINE ext_int_put_var_td_double ( DataHandle,Element, DateStr,Varname, Data, Count, Status )
1333 INTEGER , INTENT(IN) :: DataHandle
1334 CHARACTER*(*) :: Element
1335 CHARACTER*(*) :: DateStr
1336 CHARACTER*(*) :: VarName
1337 real*8 , INTENT(IN) :: Data(*)
1338 INTEGER , INTENT(IN) :: Count
1339 INTEGER , INTENT(OUT) :: Status
1340 CALL wrf_error_fatal('ext_int_put_var_td_double not supported yet')
1342 END SUBROUTINE ext_int_put_var_td_double
1344 !--- get_var_td_integer
1345 SUBROUTINE ext_int_get_var_td_integer ( DataHandle,Element, DateStr,Varname, Data, Count, Outcount, Status )
1347 INTEGER , INTENT(IN) :: DataHandle
1348 CHARACTER*(*) :: Element
1349 CHARACTER*(*) :: DateStr
1350 CHARACTER*(*) :: VarName
1351 integer , INTENT(OUT) :: Data(*)
1352 INTEGER , INTENT(IN) :: Count
1353 INTEGER , INTENT(OUT) :: OutCount
1354 INTEGER , INTENT(OUT) :: Status
1356 END SUBROUTINE ext_int_get_var_td_integer
1358 !--- put_var_td_integer
1359 SUBROUTINE ext_int_put_var_td_integer ( DataHandle,Element, DateStr,Varname, Data, Count, Status )
1361 INTEGER , INTENT(IN) :: DataHandle
1362 CHARACTER*(*) :: Element
1363 CHARACTER*(*) :: DateStr
1364 CHARACTER*(*) :: VarName
1365 integer , INTENT(IN) :: Data(*)
1366 INTEGER , INTENT(IN) :: Count
1367 INTEGER , INTENT(OUT) :: Status
1369 END SUBROUTINE ext_int_put_var_td_integer
1371 !--- get_var_td_logical
1372 SUBROUTINE ext_int_get_var_td_logical ( DataHandle,Element, DateStr,Varname, Data, Count, Outcount, Status )
1374 INTEGER , INTENT(IN) :: DataHandle
1375 CHARACTER*(*) :: Element
1376 CHARACTER*(*) :: DateStr
1377 CHARACTER*(*) :: VarName
1378 logical , INTENT(OUT) :: Data(*)
1379 INTEGER , INTENT(IN) :: Count
1380 INTEGER , INTENT(OUT) :: OutCount
1381 INTEGER , INTENT(OUT) :: Status
1383 END SUBROUTINE ext_int_get_var_td_logical
1385 !--- put_var_td_logical
1386 SUBROUTINE ext_int_put_var_td_logical ( DataHandle,Element, DateStr,Varname, Data, Count, Status )
1388 INTEGER , INTENT(IN) :: DataHandle
1389 CHARACTER*(*) :: Element
1390 CHARACTER*(*) :: DateStr
1391 CHARACTER*(*) :: VarName
1392 logical , INTENT(IN) :: Data(*)
1393 INTEGER , INTENT(IN) :: Count
1394 INTEGER , INTENT(OUT) :: Status
1396 END SUBROUTINE ext_int_put_var_td_logical
1398 !--- get_var_td_char
1399 SUBROUTINE ext_int_get_var_td_char ( DataHandle,Element, DateStr,Varname, Data, Status )
1401 INTEGER , INTENT(IN) :: DataHandle
1402 CHARACTER*(*) :: Element
1403 CHARACTER*(*) :: DateStr
1404 CHARACTER*(*) :: VarName
1405 CHARACTER*(*) :: Data
1406 INTEGER , INTENT(OUT) :: Status
1408 END SUBROUTINE ext_int_get_var_td_char
1410 !--- put_var_td_char
1411 SUBROUTINE ext_int_put_var_td_char ( DataHandle,Element, DateStr,Varname, Data, Status )
1413 INTEGER , INTENT(IN) :: DataHandle
1414 CHARACTER*(*) :: Element
1415 CHARACTER*(*) :: DateStr
1416 CHARACTER*(*) :: VarName
1417 CHARACTER*(*) :: Data
1418 INTEGER , INTENT(OUT) :: Status
1420 END SUBROUTINE ext_int_put_var_td_char
1423 SUBROUTINE ext_int_read_field ( DataHandle , DateStr , VarName , Field , FieldType , Comm , IOComm, &
1424 DomainDesc , MemoryOrder , Stagger , DimNames , &
1425 DomainStart , DomainEnd , &
1426 MemoryStart , MemoryEnd , &
1427 PatchStart , PatchEnd , &
1429 USE module_ext_internal
1431 #include "wrf_io_flags.h"
1432 include 'intio_tags.h'
1433 INTEGER , INTENT(IN) :: DataHandle
1434 CHARACTER*(*) :: DateStr
1435 CHARACTER*(*) :: VarName
1436 integer ,intent(inout) :: FieldType
1437 integer ,intent(inout) :: Comm
1438 integer ,intent(inout) :: IOComm
1439 integer ,intent(inout) :: DomainDesc
1440 character*(*) ,intent(inout) :: MemoryOrder
1441 character*(*) ,intent(inout) :: Stagger
1442 character*(*) , dimension (*) ,intent(inout) :: DimNames
1443 integer ,dimension(*) ,intent(inout) :: DomainStart, DomainEnd
1444 integer ,dimension(*) ,intent(inout) :: MemoryStart, MemoryEnd
1445 integer ,dimension(*) ,intent(inout) :: PatchStart, PatchEnd
1446 integer ,intent(out) :: Status
1449 INTEGER :: locDataHandle
1450 CHARACTER*132 :: locDateStr
1451 CHARACTER*132 :: locVarName
1452 integer :: locFieldType
1454 integer :: locIOComm
1455 integer :: locDomainDesc
1456 character*132 :: locMemoryOrder
1457 character*132 :: locStagger
1458 character*132 , dimension (3) :: locDimNames
1459 integer ,dimension(3) :: locDomainStart, locDomainEnd
1460 integer ,dimension(3) :: locMemoryStart, locMemoryEnd
1461 integer ,dimension(3) :: locPatchStart, locPatchEnd
1465 integer ii,jj,kk,myrank
1468 REAL, DIMENSION(*) :: Field
1470 INTEGER inttypesize, realtypesize, istat, code
1472 IF ( .NOT. int_valid_handle( DataHandle ) ) THEN
1473 CALL wrf_error_fatal("io_int.F90: ext_int_read_field: invalid data handle" )
1475 IF ( .NOT. int_handle_in_use( DataHandle ) ) THEN
1476 CALL wrf_error_fatal("io_int.F90: ext_int_read_field: DataHandle not opened" )
1479 inttypesize = itypesize
1480 realtypesize = rtypesize
1483 READ( unit=DataHandle, iostat=istat ) hdrbuf ! this is okay as long as no other record type has data that follows
1484 IF ( istat .EQ. 0 ) THEN
1486 IF ( code .EQ. int_field ) THEN
1487 CALL int_get_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, &
1488 locDataHandle , locDateStr , locVarName , Field , locFieldType , locComm , locIOComm, &
1489 locDomainDesc , locMemoryOrder , locStagger , locDimNames , &
1490 locDomainStart , locDomainEnd , &
1491 locMemoryStart , locMemoryEnd , &
1492 locPatchStart , locPatchEnd )
1493 IF ( TRIM(locVarName) .EQ. TRIM(VarName) ) THEN
1494 IF ( FieldType .EQ. WRF_REAL ) THEN
1495 CALL rfieldread( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1496 ELSE IF ( FieldType .EQ. WRF_INTEGER ) THEN
1497 CALL ifieldread( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1499 CALL wrf_message('io_int.F90: ext_int_read_field: types other than WRF_REAL not supported yet')
1500 READ( unit=DataHandle )
1503 WRITE(mess,*)'ext_int_read_field: ',TRIM(locVarName),' NE ',TRIM(VarName)
1504 CALL wrf_message(mess)
1505 READ( unit=DataHandle )
1518 first_operation( DataHandle ) = .FALSE.
1521 END SUBROUTINE ext_int_read_field
1524 SUBROUTINE ext_int_write_field ( DataHandle , DateStr , VarName , Field , FieldType , Comm , IOComm, &
1525 DomainDesc , MemoryOrder , Stagger , DimNames , &
1526 DomainStart , DomainEnd , &
1527 MemoryStart , MemoryEnd , &
1528 PatchStart , PatchEnd , &
1530 USE module_ext_internal
1532 #include "wrf_io_flags.h"
1533 INTEGER , INTENT(IN) :: DataHandle
1534 CHARACTER*(*) :: DateStr
1535 CHARACTER*(*) :: VarName
1536 integer ,intent(in) :: FieldType
1537 integer ,intent(inout) :: Comm
1538 integer ,intent(inout) :: IOComm
1539 integer ,intent(in) :: DomainDesc
1540 character*(*) ,intent(in) :: MemoryOrder
1541 character*(*) ,intent(in) :: Stagger
1542 character*(*) , dimension (*) ,intent(in) :: DimNames
1543 integer ,dimension(*) ,intent(in) :: DomainStart, DomainEnd
1544 integer ,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
1545 integer ,dimension(*) ,intent(in) :: PatchStart, PatchEnd
1546 integer ,intent(out) :: Status
1548 integer ii,jj,kk,myrank
1550 ! REAL, DIMENSION( MemoryStart(1):MemoryEnd(1), &
1551 ! MemoryStart(2):MemoryEnd(2), &
1552 ! MemoryStart(3):MemoryEnd(3) ) :: Field
1554 REAL, DIMENSION(*) :: Field
1556 INTEGER inttypesize, realtypesize
1558 IF ( .NOT. int_valid_handle( DataHandle ) ) THEN
1559 CALL wrf_error_fatal("io_int.F90: ext_int_write_field: invalid data handle" )
1561 IF ( .NOT. int_handle_in_use( DataHandle ) ) THEN
1562 CALL wrf_error_fatal("io_int.F90: ext_int_write_field: DataHandle not opened" )
1565 inttypesize = itypesize
1566 realtypesize = rtypesize
1567 IF ( FieldType .EQ. WRF_REAL .OR. FieldType .EQ. WRF_DOUBLE) THEN
1568 typesize = rtypesize
1569 ELSE IF ( FieldType .EQ. WRF_DOUBLE ) THEN
1570 CALL wrf_error_fatal( 'io_int.F90: ext_int_write_field, WRF_DOUBLE not yet supported')
1571 ELSE IF ( FieldType .EQ. WRF_INTEGER ) THEN
1572 typesize = itypesize
1573 ELSE IF ( FieldType .EQ. WRF_LOGICAL ) THEN
1574 CALL wrf_error_fatal( 'io_int.F90: ext_int_write_field, WRF_LOGICAL not yet supported')
1577 IF ( okay_for_io( DataHandle ) ) THEN
1579 CALL int_gen_write_field_header ( hdrbuf, hdrbufsize, inttypesize, typesize, &
1580 DataHandle , DateStr , VarName , Field , FieldType , Comm , IOComm, &
1581 DomainDesc , MemoryOrder , Stagger , DimNames , &
1582 DomainStart , DomainEnd , &
1583 MemoryStart , MemoryEnd , &
1584 PatchStart , PatchEnd )
1585 WRITE( unit=DataHandle ) hdrbuf
1586 IF ( FieldType .EQ. WRF_REAL ) THEN
1587 CALL rfieldwrite( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1588 ELSE IF ( FieldType .EQ. WRF_INTEGER ) THEN
1589 CALL ifieldwrite( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1592 first_operation( DataHandle ) = .FALSE.
1595 END SUBROUTINE ext_int_write_field
1597 SUBROUTINE rfieldwrite( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1598 INTEGER , INTENT(IN) :: DataHandle
1599 INTEGER ,DIMENSION(*) ,INTENT(IN) :: MemoryStart, MemoryEnd
1600 INTEGER ,DIMENSION(*) ,INTENT(IN) :: PatchStart, PatchEnd
1601 REAL, DIMENSION( MemoryStart(1):MemoryEnd(1), &
1602 MemoryStart(2):MemoryEnd(2), &
1603 MemoryStart(3):MemoryEnd(3) ) :: Field
1604 WRITE( unit=DataHandle ) Field(PatchStart(1):PatchEnd(1),PatchStart(2):PatchEnd(2),PatchStart(3):PatchEnd(3))
1606 END SUBROUTINE rfieldwrite
1608 SUBROUTINE ifieldwrite( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1609 INTEGER , INTENT(IN) :: DataHandle
1610 INTEGER ,DIMENSION(*) ,INTENT(IN) :: MemoryStart, MemoryEnd
1611 INTEGER ,DIMENSION(*) ,INTENT(IN) :: PatchStart, PatchEnd
1612 INTEGER, DIMENSION( MemoryStart(1):MemoryEnd(1), &
1613 MemoryStart(2):MemoryEnd(2), &
1614 MemoryStart(3):MemoryEnd(3) ) :: Field
1615 WRITE( unit=DataHandle ) Field(PatchStart(1):PatchEnd(1),PatchStart(2):PatchEnd(2),PatchStart(3):PatchEnd(3))
1617 END SUBROUTINE ifieldwrite
1619 SUBROUTINE rfieldread( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1620 INTEGER , INTENT(IN) :: DataHandle
1621 INTEGER ,DIMENSION(*) ,INTENT(IN) :: MemoryStart, MemoryEnd
1622 INTEGER ,DIMENSION(*) ,INTENT(IN) :: PatchStart, PatchEnd
1623 REAL, DIMENSION( MemoryStart(1):MemoryEnd(1), &
1624 MemoryStart(2):MemoryEnd(2), &
1625 MemoryStart(3):MemoryEnd(3) ) :: Field
1626 READ( unit=DataHandle ) Field(PatchStart(1):PatchEnd(1),PatchStart(2):PatchEnd(2),PatchStart(3):PatchEnd(3))
1628 END SUBROUTINE rfieldread
1630 SUBROUTINE ifieldread( DataHandle, Field, MemoryStart, MemoryEnd, PatchStart, PatchEnd )
1631 INTEGER , INTENT(IN) :: DataHandle
1632 INTEGER ,DIMENSION(*) ,INTENT(IN) :: MemoryStart, MemoryEnd
1633 INTEGER ,DIMENSION(*) ,INTENT(IN) :: PatchStart, PatchEnd
1634 INTEGER, DIMENSION( MemoryStart(1):MemoryEnd(1), &
1635 MemoryStart(2):MemoryEnd(2), &
1636 MemoryStart(3):MemoryEnd(3) ) :: Field
1637 READ( unit=DataHandle ) Field(PatchStart(1):PatchEnd(1),PatchStart(2):PatchEnd(2),PatchStart(3):PatchEnd(3))
1639 END SUBROUTINE ifieldread