1 !*-----------------------------------------------------------------------------
9 !*-----------------------------------------------------------------------------
12 !* This io_grib1 API is designed to read WRF input and write WRF output data
13 !* in grib version 1 format.
20 !* This module will hold data internal to this I/O implementation.
21 !* The variables will be accessible by all functions (provided they have a
22 !* "USE gr1_data_info" line).
25 integer , parameter :: FATAL = 1
26 integer , parameter :: DEBUG = 100
27 integer , parameter :: DateStrLen = 19
29 integer , parameter :: firstFileHandle = 8
30 integer , parameter :: maxFileHandles = 30
31 integer , parameter :: maxLevels = 1000
32 integer , parameter :: maxSoilLevels = 100
33 integer , parameter :: maxDomains = 500
35 logical , dimension(maxFileHandles) :: committed, opened, used
36 character*128, dimension(maxFileHandles) :: DataFile
37 integer, dimension(maxFileHandles) :: FileFd
38 integer, dimension(maxFileHandles) :: FileStatus
39 REAL, dimension(maxLevels) :: half_eta, full_eta
40 REAL, dimension(maxSoilLevels) :: soil_depth, soil_thickness
41 character*24 :: StartDate = ''
42 character*24 :: InputProgramName = ''
46 real :: truelat1, truelat2
47 real :: center_lat, center_lon
48 real :: proj_central_lon
50 character, dimension(:), pointer :: grib_tables
51 logical :: table_filled = .FALSE.
52 character, dimension(:), pointer :: grid_info
53 integer :: full_xsize, full_ysize
54 integer, dimension(maxDomains) :: domains = -1
55 integer :: this_domain = 0
56 integer :: max_domain = 0
59 character, dimension(:), pointer :: fileindex(:)
60 integer :: CurrentTime
61 integer :: NumberTimes
62 character (DateStrLen), dimension(:),pointer :: Times(:)
64 TYPE (HandleVar), dimension(maxFileHandles) :: fileinfo
67 integer :: fcst_secs_rainc
68 integer :: fcst_secs_rainnc
69 real, dimension(:,:), pointer :: rainc, rainnc
71 TYPE (prevdata), DIMENSION(500) :: lastdata
74 real, dimension(:,:), pointer :: snod
77 TYPE (initdata), dimension(maxDomains) :: firstdata
80 real, dimension(:,:,:), pointer :: vals
82 character*120 :: lastDateStr
85 character*120, dimension(maxDomains) :: lastDateStr
87 TYPE (prestype), dimension(maxDomains) :: pressure
88 TYPE (prestype), dimension(maxDomains) :: geopotential
90 integer :: center, subcenter, parmtbl
92 character(len=15000), dimension(firstFileHandle:maxFileHandles) :: td_output
93 character(len=15000), dimension(firstFileHandle:maxFileHandles) :: ti_output
95 logical :: WrfIOnotInitialized = .true.
97 end module gr1_data_info
100 subroutine ext_gr1_ioinit(SysDepInfo,Status)
104 #include "wrf_status_codes.h"
105 #include "wrf_io_flags.h"
106 CHARACTER*(*), INTENT(IN) :: SysDepInfo
107 integer ,intent(out) :: Status
109 integer :: size, istat
110 CHARACTER (LEN=300) :: wrf_err_message
112 call wrf_debug ( DEBUG , 'Entering ext_gr1_ioinit')
114 do i=firstFileHandle, maxFileHandles
116 committed(i) = .false.
124 pressure(i)%newtime = .false.
125 pressure(i)%lastDateStr = ''
126 geopotential(i)%newtime = .false.
127 geopotential(i)%lastDateStr = ''
131 lastdata%fcst_secs_rainc = 0
132 lastdata%fcst_secs_rainnc = 0
133 FileStatus(1:maxFileHandles) = WRF_FILE_NOT_OPENED
134 WrfIOnotInitialized = .false.
139 end subroutine ext_gr1_ioinit
141 !*****************************************************************************
143 subroutine ext_gr1_ioexit(Status)
147 #include "wrf_status_codes.h"
149 integer ,intent(out) :: Status
151 call wrf_debug ( DEBUG , 'Entering ext_gr1_ioexit')
153 if (table_filled) then
154 CALL free_gribmap(grib_tables)
155 DEALLOCATE(grib_tables, stat=istat)
156 table_filled = .FALSE.
158 IF ( ASSOCIATED ( grid_info ) ) THEN
159 DEALLOCATE(grid_info, stat=istat)
166 end subroutine ext_gr1_ioexit
168 !*****************************************************************************
170 SUBROUTINE ext_gr1_open_for_read_begin ( FileName , Comm_compute, Comm_io, &
171 SysDepInfo, DataHandle , Status )
175 #include "wrf_status_codes.h"
176 #include "wrf_io_flags.h"
177 CHARACTER*(*) :: FileName
178 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
179 CHARACTER*(*) :: SysDepInfo
180 INTEGER , INTENT(OUT) :: DataHandle
181 INTEGER , INTENT(OUT) :: Status
186 integer :: dpth_parmid
187 integer :: thk_parmid
189 integer , DIMENSION(1000) :: indices
190 integer :: numindices
191 real , DIMENSION(1000) :: levels
196 integer :: level1, level2
200 integer :: last_grb_index
201 CHARACTER (LEN=300) :: wrf_err_message
203 call wrf_debug ( DEBUG , 'Entering ext_gr1_open_for_read_begin')
205 CALL gr1_get_new_handle(DataHandle)
207 if (DataHandle .GT. 0) then
208 CALL open_file(TRIM(FileName), 'r', FileFd(DataHandle), ierr)
209 if (ierr .ne. 0) then
210 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
212 opened(DataHandle) = .true.
213 DataFile(DataHandle) = TRIM(FileName)
214 FileStatus(DataHandle) = WRF_FILE_OPENED_NOT_COMMITTED
217 Status = WRF_WARN_TOO_MANY_FILES
221 ! Read the grib index file first
222 if (.NOT. table_filled) then
223 table_filled = .TRUE.
224 CALL GET_GRIB1_TABLES_SIZE(size)
225 ALLOCATE(grib_tables(1:size), STAT=ierr)
226 CALL LOAD_GRIB1_TABLES ("gribmap.txt", grib_tables, ierr)
227 if (ierr .ne. 0) then
228 DEALLOCATE(grib_tables)
229 WRITE( wrf_err_message , * ) &
230 'Could not open file gribmap.txt '
231 CALL wrf_error_fatal ( TRIM ( wrf_err_message ) )
232 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
237 ! Begin by indexing file and reading metadata into structure.
238 CALL GET_FILEINDEX_SIZE(size)
239 ALLOCATE(fileinfo(DataHandle)%fileindex(1:size), STAT=ierr)
241 CALL ALLOC_INDEX_FILE(fileinfo(DataHandle)%fileindex(:))
242 CALL INDEX_FILE(FileFd(DataHandle),fileinfo(DataHandle)%fileindex(:))
244 ! Get times into Times variable
245 CALL GET_NUM_TIMES(fileinfo(DataHandle)%fileindex(:), &
246 fileinfo(DataHandle)%NumberTimes);
248 ALLOCATE(fileinfo(DataHandle)%Times(1:fileinfo(DataHandle)%NumberTimes), STAT=ierr)
249 do idx = 1,fileinfo(DataHandle)%NumberTimes
250 CALL GET_TIME(fileinfo(DataHandle)%fileindex(:),idx, &
251 fileinfo(DataHandle)%Times(idx))
254 ! CurrentTime starts as 0. The first time in the file is 1. So,
255 ! until set_time or get_next_time is called, the current time
257 fileinfo(DataHandle)%CurrentTime = 0
259 CALL gr1_fill_eta_levels(fileinfo(DataHandle)%fileindex(:), &
260 FileFd(DataHandle), &
261 grib_tables, "ZNW", full_eta)
262 CALL gr1_fill_eta_levels(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), &
263 grib_tables, "ZNU", half_eta)
266 ! Now, get the soil levels
268 CALL GET_GRIB_PARAM(grib_tables, "ZS", center, subcenter, parmtbl, &
269 tablenum, dpth_parmid)
270 CALL GET_GRIB_PARAM(grib_tables,"DZS", center, subcenter, parmtbl, &
271 tablenum, thk_parmid)
272 if (dpth_parmid == -1) then
273 call wrf_message ('Error getting grib parameter')
278 CALL GET_GRIB_INDICES(fileinfo(DataHandle)%fileindex(:),center, subcenter, parmtbl, &
279 dpth_parmid,"*",leveltype, &
280 -HUGE(1),-HUGE(1), -HUGE(1),-HUGE(1),indices,numindices)
283 do idx = 1,numindices
284 CALL READ_GRIB(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), &
285 indices(idx), soil_depth(idx))
287 ! Now read the soil thickenesses
289 CALL GET_LEVEL1(fileinfo(DataHandle)%fileindex(:),indices(idx),level1)
290 CALL GET_LEVEL2(fileinfo(DataHandle)%fileindex(:),indices(idx),level2)
291 CALL GET_GRIB_INDEX_GUESS(fileinfo(DataHandle)%fileindex(:), &
292 center, subcenter, parmtbl, thk_parmid,"*",leveltype, &
293 level1,level2,-HUGE(1),-HUGE(1), last_grb_index+1, grb_index)
294 CALL READ_GRIB(fileinfo(DataHandle)%fileindex(:),FileFd(DataHandle),grb_index, &
297 last_grb_index = grb_index
303 ! Fill up any variables that need to be retrieved from Metadata
305 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), 'PROGRAM_NAME', "none", &
306 "none", InputProgramName, stat)
308 CALL wrf_debug (DEBUG , "PROGRAM_NAME not found in input METADATA")
310 endchar = SCAN(InputProgramName," ")
311 InputProgramName = InputProgramName(1:endchar)
314 call wrf_debug ( DEBUG , 'Exiting ext_gr1_open_for_read_begin')
317 END SUBROUTINE ext_gr1_open_for_read_begin
319 !*****************************************************************************
321 SUBROUTINE ext_gr1_open_for_read_commit( DataHandle , Status )
325 #include "wrf_status_codes.h"
326 #include "wrf_io_flags.h"
327 character(len=1000) :: msg
328 INTEGER , INTENT(IN ) :: DataHandle
329 INTEGER , INTENT(OUT) :: Status
331 call wrf_debug ( DEBUG , 'Entering ext_gr1_open_for_read_commit')
334 if(WrfIOnotInitialized) then
335 Status = WRF_IO_NOT_INITIALIZED
336 write(msg,*) 'ext_gr1_ioinit was not called ',__FILE__,', line', __LINE__
337 call wrf_debug ( FATAL , msg)
340 committed(DataHandle) = .true.
341 FileStatus(DataHandle) = WRF_FILE_OPENED_FOR_READ
346 END SUBROUTINE ext_gr1_open_for_read_commit
348 !*****************************************************************************
350 SUBROUTINE ext_gr1_open_for_read ( FileName , Comm_compute, Comm_io, &
351 SysDepInfo, DataHandle , Status )
355 #include "wrf_status_codes.h"
356 #include "wrf_io_flags.h"
357 CHARACTER*(*) :: FileName
358 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
359 CHARACTER*(*) :: SysDepInfo
360 INTEGER , INTENT(OUT) :: DataHandle
361 INTEGER , INTENT(OUT) :: Status
364 call wrf_debug ( DEBUG , 'Entering ext_gr1_open_for_read')
366 DataHandle = 0 ! dummy setting to quiet warning message
367 CALL ext_gr1_open_for_read_begin( FileName, Comm_compute, Comm_io, &
368 SysDepInfo, DataHandle, Status )
369 IF ( Status .EQ. WRF_NO_ERR ) THEN
370 FileStatus(DataHandle) = WRF_FILE_OPENED_NOT_COMMITTED
371 CALL ext_gr1_open_for_read_commit( DataHandle, Status )
376 END SUBROUTINE ext_gr1_open_for_read
378 !*****************************************************************************
380 SUBROUTINE ext_gr1_open_for_write_begin(FileName, Comm, IOComm, SysDepInfo, &
385 #include "wrf_status_codes.h"
386 #include "wrf_io_flags.h"
388 character*(*) ,intent(in) :: FileName
389 integer ,intent(in) :: Comm
390 integer ,intent(in) :: IOComm
391 character*(*) ,intent(in) :: SysDepInfo
392 integer ,intent(out) :: DataHandle
393 integer ,intent(out) :: Status
395 CHARACTER (LEN=300) :: wrf_err_message
398 call wrf_debug ( DEBUG , 'Entering ext_gr1_open_for_write_begin')
400 if (.NOT. table_filled) then
401 table_filled = .TRUE.
402 CALL GET_GRIB1_TABLES_SIZE(size)
403 ALLOCATE(grib_tables(1:size), STAT=ierr)
404 CALL LOAD_GRIB1_TABLES ("gribmap.txt", grib_tables, ierr)
405 if (ierr .ne. 0) then
406 DEALLOCATE(grib_tables)
407 WRITE( wrf_err_message , * ) &
408 'Could not open file gribmap.txt '
409 CALL wrf_error_fatal ( TRIM ( wrf_err_message ) )
410 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
416 CALL gr1_get_new_handle(DataHandle)
417 if (DataHandle .GT. 0) then
418 CALL open_file(TRIM(FileName), 'w', FileFd(DataHandle), ierr)
419 if (ierr .ne. 0) then
420 Status = WRF_WARN_WRITE_RONLY_FILE
422 opened(DataHandle) = .true.
423 DataFile(DataHandle) = TRIM(FileName)
424 FileStatus(DataHandle) = WRF_FILE_OPENED_NOT_COMMITTED
426 committed(DataHandle) = .false.
427 td_output(DataHandle) = ''
429 Status = WRF_WARN_TOO_MANY_FILES
433 END SUBROUTINE ext_gr1_open_for_write_begin
435 !*****************************************************************************
437 SUBROUTINE ext_gr1_open_for_write_commit( DataHandle , Status )
441 #include "wrf_status_codes.h"
442 #include "wrf_io_flags.h"
443 INTEGER , INTENT(IN ) :: DataHandle
444 INTEGER , INTENT(OUT) :: Status
446 call wrf_debug ( DEBUG , 'Entering ext_gr1_open_for_write_commit')
448 IF ( opened( DataHandle ) ) THEN
449 IF ( used( DataHandle ) ) THEN
450 committed(DataHandle) = .true.
451 FileStatus(DataHandle) = WRF_FILE_OPENED_FOR_WRITE
458 END SUBROUTINE ext_gr1_open_for_write_commit
460 !*****************************************************************************
462 subroutine ext_gr1_inquiry (Inquiry, Result, Status)
465 #include "wrf_status_codes.h"
466 character *(*), INTENT(IN) :: Inquiry
467 character *(*), INTENT(OUT) :: Result
468 integer ,INTENT(INOUT) :: Status
469 SELECT CASE (Inquiry)
470 CASE ("RANDOM_WRITE","RANDOM_READ")
472 CASE ("SEQUENTIAL_WRITE","SEQUENTIAL_READ")
474 CASE ("OPEN_READ", "OPEN_WRITE", "OPEN_COMMIT_WRITE")
476 CASE ("OPEN_COMMIT_READ","PARALLEL_IO")
478 CASE ("SELF_DESCRIBING","SUPPORT_METADATA","SUPPORT_3D_FIELDS")
483 Result = 'No Result for that inquiry!'
487 end subroutine ext_gr1_inquiry
489 !*****************************************************************************
491 SUBROUTINE ext_gr1_inquire_opened ( DataHandle, FileName , FileStat, Status )
495 #include "wrf_status_codes.h"
496 #include "wrf_io_flags.h"
497 INTEGER , INTENT(IN) :: DataHandle
498 CHARACTER*(*) :: FileName
499 INTEGER , INTENT(OUT) :: FileStat
500 INTEGER , INTENT(OUT) :: Status
502 call wrf_debug ( DEBUG , 'Entering ext_gr1_inquire_opened')
504 FileStat = WRF_NO_ERR
505 if ((DataHandle .ge. firstFileHandle) .and. &
506 (DataHandle .le. maxFileHandles)) then
507 FileStat = FileStatus(DataHandle)
509 FileStat = WRF_FILE_NOT_OPENED
515 END SUBROUTINE ext_gr1_inquire_opened
517 !*****************************************************************************
519 SUBROUTINE ext_gr1_ioclose ( DataHandle, Status )
523 #include "wrf_status_codes.h"
524 INTEGER DataHandle, Status
527 character(len=1000) :: outstring
531 call wrf_debug ( DEBUG , 'Entering ext_gr1_ioclose')
535 CALL write_file(FileFd(DataHandle), lf//'<METADATA>'//lf,ierr)
537 '<!-- The following are fields that were supplied to the WRF I/O API.'//lf//&
538 'Many variables (but not all) are redundant with the variables within '//lf//&
539 'the grib headers. They are stored here, as METADATA, so that the '//lf//&
540 'WRF I/O API has simple access to these variables.-->'
541 CALL write_file(FileFd(DataHandle), trim(outstring), ierr)
542 if (trim(ti_output(DataHandle)) /= '') then
543 CALL write_file(FileFd(DataHandle), trim(ti_output(DataHandle)), ierr)
544 CALL write_file(FileFd(DataHandle), lf, ierr)
546 if (trim(td_output(DataHandle)) /= '') then
547 CALL write_file(FileFd(DataHandle), trim(td_output(DataHandle)), ierr)
548 CALL write_file(FileFd(DataHandle), lf, ierr)
550 CALL write_file(FileFd(DataHandle), '</METADATA>'//lf,ierr)
551 ti_output(DataHandle) = ''
552 td_output(DataHandle) = ''
553 if (ierr .ne. 0) then
554 Status = WRF_WARN_WRITE_RONLY_FILE
556 CALL close_file(FileFd(DataHandle))
558 used(DataHandle) = .false.
561 END SUBROUTINE ext_gr1_ioclose
563 !*****************************************************************************
565 SUBROUTINE ext_gr1_write_field( DataHandle , DateStrIn , VarName , &
566 Field , FieldType , Comm , IOComm, &
567 DomainDesc , MemoryOrder , Stagger , &
569 DomainStart , DomainEnd , &
570 MemoryStart , MemoryEnd , &
571 PatchStart , PatchEnd , &
576 #include "wrf_status_codes.h"
577 #include "wrf_io_flags.h"
578 #include "wrf_projection.h"
579 INTEGER , INTENT(IN) :: DataHandle
580 CHARACTER*(*) :: DateStrIn
581 CHARACTER(DateStrLen) :: DateStr
582 CHARACTER*(*) :: VarName
583 CHARACTER*120 :: OutName
584 CHARACTER(120) :: TmpVarName
585 integer ,intent(in) :: FieldType
586 integer ,intent(inout) :: Comm
587 integer ,intent(inout) :: IOComm
588 integer ,intent(in) :: DomainDesc
589 character*(*) ,intent(in) :: MemoryOrder
590 character*(*) ,intent(in) :: Stagger
591 character*(*) , dimension (*) ,intent(in) :: DimNames
592 integer ,dimension(*) ,intent(in) :: DomainStart, DomainEnd
593 integer ,dimension(*) ,intent(in) :: MemoryStart, MemoryEnd
594 integer ,dimension(*) ,intent(in) :: PatchStart, PatchEnd
595 integer ,intent(out) :: Status
597 character (120) :: msg
598 integer :: xsize, ysize, zsize
600 integer :: x_start,x_end,y_start,y_end,z_start,z_end,ndim
602 integer :: proj_center_flag
603 logical :: vert_stag = .false.
605 real, DIMENSION(:,:), POINTER :: data,tmpdata
606 integer, DIMENSION(:), POINTER :: mold
608 integer :: accum_period
610 integer, dimension(1000) :: level1, level2
611 real, DIMENSION( 1:1,MemoryStart(1):MemoryEnd(1), &
612 MemoryStart(2):MemoryEnd(2), &
613 MemoryStart(3):MemoryEnd(3) ) :: Field
615 logical :: soil_layers, fraction
617 integer :: abc(2,2,2)
619 logical :: output = .true.
620 integer :: idx1, idx2, idx3
621 logical :: new_domain
622 real :: region_center_lat, region_center_lon
623 integer :: dom_xsize, dom_ysize;
625 logical :: already_have_domain
627 call wrf_debug ( DEBUG , 'Entering ext_gr1_write_field for parameter'//VarName)
630 ! If DateStr is all 0's, we reset it to StartDate (if StartDate exists).
632 ! in idealized simulations, StartDate is 0001-01-01_00:00:00 while
633 ! the first DateStr is 0000-00-00_00:00:00.
635 if (DateStrIn .eq. '0000-00-00_00:00:00') then
636 if (StartDate .ne. '') then
637 DateStr = TRIM(StartDate)
639 DateStr = '0001-01-01_00:00:00'
646 ! Check if this is a domain that we haven't seen yet. If so, add it to
647 ! the list of domains.
650 already_have_domain = .false.
651 do idx = 1, max_domain
652 if (this_domain .eq. domains(idx)) then
653 already_have_domain = .true.
656 if (.NOT. already_have_domain) then
657 max_domain = max_domain + 1
658 domains(max_domain) = this_domain
663 ! If the time has changed, we open a new file. This is a kludge to get
664 ! around slowness in WRF that occurs when opening a new data file the
667 #ifdef GRIB_ONE_TIME_PER_FILE
668 if (lastDateStr(this_domain) .ne. DateStr) then
669 write(DataFile(DataHandle),'(A8,i2.2,A1,A19)') 'wrfout_d',this_domain,'_',DateStr
670 call ext_gr1_ioclose ( DataHandle, Status )
671 CALL open_file(TRIM(DataFile(DataHandle)), 'w', FileFd(DataHandle), ierr)
672 if (ierr .ne. 0) then
673 print *,'Could not open new file: ',DataFile(DataHandle)
674 print *,' Appending to old file.'
676 ! Just set used back to .true. here, since ioclose set it to false.
677 used(DataHandle) = .true.
679 td_output(DataHandle) = ''
681 lastDateStr(this_domain) = DateStr
689 soil_layers = .false.
692 ! First, handle then special cases for the boundary data.
694 CALL get_dims(MemoryOrder, PatchStart, PatchEnd, ndim, x_start, x_end, &
695 y_start, y_end,z_start,z_end)
696 xsize = x_end - x_start + 1
697 ysize = y_end - y_start + 1
698 zsize = z_end - z_start + 1
700 do idx = 1, len(MemoryOrder)
701 if ((MemoryOrder(idx:idx) .eq. 'Z') .and. &
702 (DimNames(idx) .eq. 'soil_layers_stag')) then
704 else if ((OutName .eq. 'LANDUSEF') .or. (OutName .eq. 'SOILCBOT') .or. &
705 (OutName .eq. 'SOILCTOP')) then
710 if (.not. ASSOCIATED(grid_info)) then
711 CALL get_grid_info_size(size)
712 ALLOCATE(grid_info(1:size), STAT=istat)
713 if (istat .eq. -1) then
714 DEALLOCATE(grid_info)
715 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
722 ALLOCATE(firstdata(this_domain)%snod(xsize,ysize))
723 firstdata(this_domain)%snod(:,:) = 0.0
724 ALLOCATE(lastdata(this_domain)%rainc(xsize,ysize))
725 lastdata(this_domain)%rainc(:,:) = 0.0
726 ALLOCATE(lastdata(this_domain)%rainnc(xsize,ysize))
727 lastdata(this_domain)%rainnc(:,:) = 0.0
730 if (zsize .eq. 0) then
734 ALLOCATE(data(1:xsize,1:ysize), STAT=istat)
735 ALLOCATE(mold(1:ysize), STAT=istat)
736 ALLOCATE(tmpdata(1:xsize,1:ysize), STAT=istat)
738 if (OutName .eq. 'ZNU') then
740 half_eta(idx) = Field(1,idx,1,1)
744 if (OutName .eq. 'ZNW') then
746 full_eta(idx) = Field(1,idx,1,1)
750 if (OutName .eq. 'ZS') then
752 soil_depth(idx) = Field(1,idx,1,1)
756 if (OutName .eq. 'DZS') then
758 soil_thickness(idx) = Field(1,idx,1,1)
763 if ((xsize .lt. 1) .or. (ysize .lt. 1)) then
764 write(msg,*) 'Cannot output field with memory order: ', &
766 call wrf_message(msg)
770 call get_vert_stag(OutName,Stagger,vert_stag)
773 call gr1_get_levels(OutName, idx, zsize, soil_layers, vert_stag, fraction, &
774 vert_unit, level1(idx), level2(idx))
778 ! Get the center lat/lon for the area being output. For some cases (such
779 ! as for boundary areas, the center of the area is different from the
780 ! center of the model grid.
782 if (index(Stagger,'X') .le. 0) then
783 dom_xsize = full_xsize - 1
785 dom_xsize = full_xsize
787 if (index(Stagger,'Y') .le. 0) then
788 dom_ysize = full_ysize - 1
790 dom_ysize = full_ysize
794 ! Handle case of polare stereographic centered on pole. In that case,
795 ! always set center lon to be the projection central longitude.
797 if ((projection .eq. WRF_POLAR_STEREO) .AND. &
798 (abs(center_lat - 90.0) < 0.01)) then
799 center_lon = proj_central_lon
802 CALL get_region_center(MemoryOrder, projection, center_lat, center_lon, &
803 dom_xsize, dom_ysize, dx, dy, proj_central_lon, proj_center_flag, &
804 truelat1, truelat2, xsize, ysize, region_center_lat, region_center_lon)
806 if ( .not. opened(DataHandle)) then
807 Status = WRF_WARN_FILE_NOT_OPENED
812 if (opened(DataHandle) .and. committed(DataHandle)) then
815 #ifdef OUTPUT_FULL_PRESSURE
818 ! The following is a kludge to output full pressure instead of the two
819 ! fields of base-state pressure and pressure perturbation.
821 ! This code can be turned on by adding -DOUTPUT_FULL_PRESSURE to the
825 if ((OutName .eq. 'P') .or. (OutName.eq.'PB')) then
826 do idx = 1, len(MemoryOrder)
827 if (MemoryOrder(idx:idx) .eq. 'X') then
830 if (MemoryOrder(idx:idx) .eq. 'Y') then
833 if (MemoryOrder(idx:idx) .eq. 'Z') then
839 ! Allocate space for pressure values (this variable holds
840 ! base-state pressure or pressure perturbation to be used
841 ! later to sum base-state and perturbation pressure to get full
845 if (.not. ASSOCIATED(pressure(this_domain)%vals)) then
846 ALLOCATE(pressure(this_domain)%vals(MemoryStart(1):MemoryEnd(1), &
847 MemoryStart(2):MemoryEnd(2),MemoryStart(3):MemoryEnd(3)))
850 pressure(this_domain)%lastDateStr) then
851 pressure(this_domain)%newtime = .true.
853 if (pressure(this_domain)%newtime) then
854 pressure(this_domain)%vals = Field(1,:,:,:)
855 pressure(this_domain)%newtime = .false.
860 pressure(this_domain)%lastDateStr=DateStr
864 #ifdef OUTPUT_FULL_GEOPOTENTIAL
867 ! The following is a kludge to output full geopotential height instead
868 ! of the two fields of base-state geopotential and perturbation
871 ! This code can be turned on by adding -DOUTPUT_FULL_GEOPOTENTIAL to the
875 if ((OutName .eq. 'PHB') .or. (OutName.eq.'PH')) then
876 do idx = 1, len(MemoryOrder)
877 if (MemoryOrder(idx:idx) .eq. 'X') then
880 if (MemoryOrder(idx:idx) .eq. 'Y') then
883 if (MemoryOrder(idx:idx) .eq. 'Z') then
889 ! Allocate space for geopotential values (this variable holds
890 ! geopotential to be used
891 ! later to sum base-state and perturbation to get full
895 if (.not. ASSOCIATED(geopotential(this_domain)%vals)) then
896 ALLOCATE(geopotential(this_domain)%vals(MemoryStart(1):MemoryEnd(1), &
897 MemoryStart(2):MemoryEnd(2),MemoryStart(3):MemoryEnd(3)))
900 geopotential(this_domain)%lastDateStr) then
901 geopotential(this_domain)%newtime = .true.
903 if (geopotential(this_domain)%newtime) then
904 geopotential(this_domain)%vals = Field(1,:,:,:)
905 geopotential(this_domain)%newtime = .false.
910 geopotential(this_domain)%lastDateStr=DateStr
915 if (StartDate == '') then
918 CALL geth_idts(DateStr,StartDate,fcst_secs)
920 if (center_lat .lt. 0) then
927 SELECT CASE (MemoryOrder)
929 data = Field(1,1:xsize,1:ysize,z)
931 data = Field(1,1:xsize,z,1:ysize)
935 data(x,y) = Field(1,y,x,z)
941 data(x,y) = Field(1,y,z,x)
945 data = Field(1,z,1:xsize,1:ysize)
949 data(x,y) = Field(1,z,y,x)
953 data = Field(1,1:xsize,1:ysize,1)
957 data(x,y) = Field(1,y,x,1)
964 data(x,y) = Field(1,y,z,x)
970 data(x,y) = Field(1,y,z,x)
976 data(x,y) = Field(1,x,z,y)
982 data(x,y) = Field(1,x,z,y)
989 data(x,y) = Field(1,y,x,1)
995 data(x,y) = Field(1,y,x,1)
1001 data(x,y) = Field(1,x,y,1)
1007 data(x,y) = Field(1,x,y,1)
1012 data(1,1) = Field(1,z,1,1)
1014 data(1,1) = Field(1,z,1,1)
1016 data = Field(1,1:xsize,1:ysize,z)
1018 data = Field(1,1:xsize,1:ysize,z)
1020 data(1,1) = Field(1,1,1,1)
1024 ! Here, we convert any integer fields to real
1026 if (FieldType == WRF_INTEGER) then
1030 ! The parentheses around data(idx,:) are needed in order
1031 ! to fix a bug with transfer with the xlf compiler on NCAR's
1034 data(idx,:)=transfer((data(idx,:)),mold)
1038 ! Here, we do any necessary conversions to the data.
1041 ! Potential temperature is sometimes passed in as perturbation
1042 ! potential temperature (i.e., POT-300). Other times (i.e., from
1043 ! WRF SI), it is passed in as full potential temperature.
1044 ! Here, we convert to full potential temperature by adding 300
1045 ! only if POT < 200 K.
1047 if (OutName == 'T') then
1048 if (data(1,1) < 200) then
1054 ! For precip, we setup the accumulation period, and output a precip
1055 ! rate for time-step precip.
1057 if (OutName .eq. 'RAINNCV') then
1058 ! Convert time-step precip to precip rate.
1059 data = data/timestep
1065 #ifdef OUTPUT_FULL_PRESSURE
1067 ! Computation of full-pressure off by default since there are
1068 ! uses for base-state and perturbation (i.e., restarts
1070 if ((OutName .eq. 'P') .or. (OutName.eq.'PB')) then
1071 if (idx3 .eq. 1) then
1073 pressure(this_domain)%vals(z, &
1074 patchstart(2):patchend(2),patchstart(3):patchend(3))
1075 elseif (idx3 .eq. 2) then
1077 pressure(this_domain)%vals(patchstart(1):patchend(1), &
1078 z,patchstart(3):patchend(3))
1079 elseif (idx3 .eq. 3) then
1081 pressure(this_domain)%vals(patchstart(1):patchend(1), &
1082 patchstart(2):patchend(2),z)
1084 call wrf_message ('error in idx3, continuing')
1091 #ifdef OUTPUT_FULL_GEOPOTENTIAL
1093 ! Computation of full-geopotential off by default since there are
1094 ! uses for base-state and perturbation (i.e., restarts
1096 if ((OutName .eq. 'PHB') .or. (OutName.eq.'PH')) then
1097 if (idx3 .eq. 1) then
1099 geopotential(this_domain)%vals(z, &
1100 patchstart(2):patchend(2),patchstart(3):patchend(3))
1101 elseif (idx3 .eq. 2) then
1103 geopotential(this_domain)%vals(patchstart(1):patchend(1), &
1104 z,patchstart(3):patchend(3))
1105 elseif (idx3 .eq. 3) then
1107 geopotential(this_domain)%vals(patchstart(1):patchend(1), &
1108 patchstart(2):patchend(2),z)
1110 call wrf_message ('error in idx3, continuing')
1118 ! Output current level
1120 CALL load_grid_info(OutName, StartDate, vert_unit, level1(z), &
1121 level2(z), fcst_secs, accum_period, wg_grid_id, projection, &
1122 xsize, ysize, region_center_lat, region_center_lon, dx, dy, &
1123 proj_central_lon, proj_center_flag, truelat1, truelat2, &
1124 grib_tables, grid_info)
1127 ! Here, we copy data to a temporary array. After write_grib,
1128 ! we copy back from the temporary array to the permanent
1129 ! array. write_grib modifies data. For certain fields that
1130 ! we use below, we want the original (unmodified) data
1131 ! values. This kludge assures that we have the original
1135 if ((OutName .eq. 'RAINC') .or. (OutName .eq. 'RAINNC') .or. &
1136 (OutName .eq. 'SNOWH')) then
1137 tmpdata(:,:) = data(:,:)
1140 CALL write_grib(grid_info, FileFd(DataHandle), data)
1142 if ((OutName .eq. 'RAINC') .or. (OutName .eq. 'RAINNC') .or. &
1143 (OutName .eq. 'SNOWH')) then
1144 data(:,:) = tmpdata(:,:)
1147 CALL free_grid_info(grid_info)
1150 ! If this is the total accumulated rain, call write_grib again
1151 ! to output the accumulation since the last output time as well.
1152 ! This is somewhat of a kludge to meet the requirements of PF.
1154 if ((OutName .eq. 'RAINC') .or. (OutName .eq. 'RAINNC') .or. &
1155 (OutName .eq. 'SNOWH')) then
1156 if (OutName .eq. 'RAINC') then
1157 data(:,:) = data(:,:) - lastdata(this_domain)%rainc(:,:)
1158 lastdata(this_domain)%rainc(:,:) = tmpdata(:,:)
1159 accum_period = fcst_secs - &
1160 lastdata(this_domain)%fcst_secs_rainc
1161 lastdata(this_domain)%fcst_secs_rainc = fcst_secs
1162 TmpVarName = 'ACPCP'
1163 else if (OutName .eq. 'RAINNC') then
1164 tmpdata(:,:) = data(:,:)
1165 data(:,:) = data(:,:) - lastdata(this_domain)%rainnc(:,:)
1166 lastdata(this_domain)%rainnc(:,:) = tmpdata(:,:)
1167 accum_period = fcst_secs - &
1168 lastdata(this_domain)%fcst_secs_rainnc
1169 lastdata(this_domain)%fcst_secs_rainnc = fcst_secs
1170 TmpVarName = 'NCPCP'
1171 else if (OutName .eq. 'SNOWH') then
1172 if (fcst_secs .eq. 0) then
1173 firstdata(this_domain)%snod(:,:) = data(:,:)
1175 data(:,:) = data(:,:) - firstdata(this_domain)%snod(:,:)
1176 TmpVarName = 'SNOWCU'
1179 CALL load_grid_info(TmpVarName, StartDate, vert_unit, level1(z),&
1180 level2(z), fcst_secs, accum_period, wg_grid_id, &
1181 projection, xsize, ysize, region_center_lat, &
1182 region_center_lon, dx, dy, proj_central_lon, &
1183 proj_center_flag, truelat1, truelat2, grib_tables, &
1186 CALL write_grib(grid_info, FileFd(DataHandle), data)
1187 CALL free_grid_info(grid_info)
1194 deallocate(data, STAT = istat)
1195 deallocate(mold, STAT = istat)
1196 deallocate(tmpdata, STAT = istat)
1200 call wrf_debug ( DEBUG , 'Leaving ext_gr1_write_field')
1203 END SUBROUTINE ext_gr1_write_field
1205 !*****************************************************************************
1207 SUBROUTINE ext_gr1_read_field ( DataHandle , DateStr , VarName , Field , &
1208 FieldType , Comm , IOComm, DomainDesc , MemoryOrder , Stagger , &
1209 DimNames , DomainStart , DomainEnd , MemoryStart , MemoryEnd , &
1210 PatchStart , PatchEnd , Status )
1214 #include "wrf_status_codes.h"
1215 #include "wrf_io_flags.h"
1216 INTEGER , INTENT(IN) :: DataHandle
1217 CHARACTER*(*) :: DateStr
1218 CHARACTER*(*) :: VarName
1219 CHARACTER (len=400) :: msg
1220 integer ,intent(inout) :: FieldType
1221 integer ,intent(inout) :: Comm
1222 integer ,intent(inout) :: IOComm
1223 integer ,intent(inout) :: DomainDesc
1224 character*(*) ,intent(inout) :: MemoryOrder
1225 character*(*) ,intent(inout) :: Stagger
1226 character*(*) , dimension (*) ,intent(inout) :: DimNames
1227 integer ,dimension(*) ,intent(inout) :: DomainStart, DomainEnd
1228 integer ,dimension(*) ,intent(inout) :: MemoryStart, MemoryEnd
1229 integer ,dimension(*) ,intent(inout) :: PatchStart, PatchEnd
1230 integer ,intent(out) :: Status
1231 INTEGER ,intent(out) :: Field(*)
1232 integer :: ndim,x_start,x_end,y_start,y_end,z_start,z_end
1234 REAL, DIMENSION(:,:), POINTER :: data
1235 logical :: vert_stag
1236 logical :: soil_layers
1237 integer :: level1,level2
1240 integer :: vert_unit
1241 integer :: grb_index
1242 integer :: numcols, numrows
1243 integer :: data_allocated
1247 integer :: last_grb_index
1249 call wrf_debug ( DEBUG , 'Entering ext_gr1_read_field')
1252 ! Get dimensions of data.
1253 ! Assume that the domain size in the input data is the same as the Domain
1254 ! Size from the input arguments.
1257 CALL get_dims(MemoryOrder,DomainStart,DomainEnd,ndim,x_start,x_end,y_start, &
1258 y_end,z_start,z_end)
1261 ! Get grib parameter id
1263 CALL GET_GRIB_PARAM(grib_tables, VarName, center, subcenter, parmtbl, &
1267 ! Setup the vertical unit and levels
1269 CALL get_vert_stag(VarName,Stagger,vert_stag)
1270 CALL get_soil_layers(VarName,soil_layers)
1273 ! Loop over levels, grabbing data from each level, then assembling into a
1278 do zidx = z_start,z_end
1280 CALL gr1_get_levels(VarName,zidx,z_end-z_start,soil_layers,vert_stag, &
1281 .false., vert_unit,level1,level2)
1283 CALL GET_GRIB_INDEX_VALIDTIME_GUESS(fileinfo(DataHandle)%fileindex(:), center, &
1284 subcenter, parmtbl, parmid,DateStr,vert_unit,level1, &
1285 level2, last_grb_index + 1, grb_index)
1286 if (grb_index < 0) then
1287 write(msg,*)'Field not found: parmid: ',VarName,parmid,DateStr, &
1288 vert_unit,level1,level2
1289 call wrf_debug (DEBUG , msg)
1293 if (data_allocated .eq. 0) then
1294 CALL GET_SIZEOF_GRID(fileinfo(DataHandle)%fileindex(:),grb_index,numcols,numrows)
1295 allocate(data(z_start:z_end,1:numcols*numrows),stat=istat)
1299 CALL READ_GRIB(fileinfo(DataHandle)%fileindex(:), FileFd(DataHandle), grb_index, &
1303 ! Transpose data into the order specified by MemoryOrder, setting only
1304 ! entries within the memory dimensions
1306 CALL get_dims(MemoryOrder, MemoryStart, MemoryEnd, ndim, x_start, x_end, &
1307 y_start, y_end,z_start,z_end)
1309 if(FieldType == WRF_DOUBLE) then
1316 ! Here, we do any necessary conversions to the data.
1318 ! The WRF executable (wrf.exe) expects perturbation potential
1319 ! temperature. However, real.exe expects full potential T.
1320 ! So, if the program is WRF, subtract 300 from Potential Temperature
1321 ! to get perturbation potential temperature.
1323 if (VarName == 'T') then
1325 (InputProgramName .eq. 'REAL_EM') .or. &
1326 (InputProgramName .eq. 'IDEAL') .or. &
1327 (InputProgramName .eq. 'NDOWN_EM')) then
1328 data(zidx,:) = data(zidx,:) - 300
1332 CALL Transpose_grib(MemoryOrder, di, FieldType, Field, &
1333 MemoryStart(1), MemoryEnd(1), MemoryStart(2), MemoryEnd(2), &
1334 MemoryStart(3), MemoryEnd(3), &
1335 data(zidx,:), zidx, numrows, numcols)
1337 if (zidx .eq. z_end) then
1342 last_grb_index = grb_index
1347 if (grb_index < 0) Status = WRF_WARN_VAR_NF
1348 call wrf_debug ( DEBUG , 'Leaving ext_gr1_read_field')
1351 END SUBROUTINE ext_gr1_read_field
1353 !*****************************************************************************
1355 SUBROUTINE ext_gr1_get_next_var ( DataHandle, VarName, Status )
1359 #include "wrf_status_codes.h"
1360 INTEGER , INTENT(IN) :: DataHandle
1361 CHARACTER*(*) :: VarName
1362 INTEGER , INTENT(OUT) :: Status
1364 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_next_var')
1366 call wrf_message ( 'WARNING: ext_gr1_get_next_var is not supported.')
1368 Status = WRF_WARN_NOOP
1371 END SUBROUTINE ext_gr1_get_next_var
1373 !*****************************************************************************
1375 subroutine ext_gr1_end_of_frame(DataHandle, Status)
1379 #include "wrf_status_codes.h"
1380 integer ,intent(in) :: DataHandle
1381 integer ,intent(out) :: Status
1383 call wrf_debug ( DEBUG , 'Entering ext_gr1_end_of_frame')
1385 Status = WRF_WARN_NOOP
1388 end subroutine ext_gr1_end_of_frame
1390 !*****************************************************************************
1392 SUBROUTINE ext_gr1_iosync ( DataHandle, Status )
1396 #include "wrf_status_codes.h"
1397 INTEGER , INTENT(IN) :: DataHandle
1398 INTEGER , INTENT(OUT) :: Status
1400 call wrf_debug ( DEBUG , 'Entering ext_gr1_iosync')
1403 if (DataHandle .GT. 0) then
1404 CALL flush_file(FileFd(DataHandle))
1406 Status = WRF_WARN_TOO_MANY_FILES
1410 END SUBROUTINE ext_gr1_iosync
1412 !*****************************************************************************
1414 SUBROUTINE ext_gr1_inquire_filename ( DataHandle, FileName , FileStat, &
1419 #include "wrf_status_codes.h"
1420 #include "wrf_io_flags.h"
1421 INTEGER , INTENT(IN) :: DataHandle
1422 CHARACTER*(*) :: FileName
1423 INTEGER , INTENT(OUT) :: FileStat
1424 INTEGER , INTENT(OUT) :: Status
1425 CHARACTER *80 SysDepInfo
1427 call wrf_debug ( DEBUG , 'Entering ext_gr1_inquire_filename')
1429 FileName = DataFile(DataHandle)
1431 if ((DataHandle .ge. firstFileHandle) .and. &
1432 (DataHandle .le. maxFileHandles)) then
1433 FileStat = FileStatus(DataHandle)
1435 FileStat = WRF_FILE_NOT_OPENED
1441 END SUBROUTINE ext_gr1_inquire_filename
1443 !*****************************************************************************
1445 SUBROUTINE ext_gr1_get_var_info ( DataHandle , VarName , NDim , &
1446 MemoryOrder , Stagger , DomainStart , DomainEnd , WrfType, Status )
1450 #include "wrf_status_codes.h"
1451 integer ,intent(in) :: DataHandle
1452 character*(*) ,intent(in) :: VarName
1453 integer ,intent(out) :: NDim
1454 character*(*) ,intent(out) :: MemoryOrder
1455 character*(*) ,intent(out) :: Stagger
1456 integer ,dimension(*) ,intent(out) :: DomainStart, DomainEnd
1457 integer ,intent(out) :: WrfType
1458 integer ,intent(out) :: Status
1460 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_info')
1462 CALL wrf_message('ext_gr1_get_var_info not supported for grib version1 data')
1466 END SUBROUTINE ext_gr1_get_var_info
1468 !*****************************************************************************
1470 SUBROUTINE ext_gr1_set_time ( DataHandle, DateStr, Status )
1474 #include "wrf_status_codes.h"
1475 INTEGER , INTENT(IN) :: DataHandle
1476 CHARACTER*(*) :: DateStr
1477 INTEGER , INTENT(OUT) :: Status
1478 integer :: found_time
1481 call wrf_debug ( DEBUG , 'Entering ext_gr1_set_time')
1484 do idx = 1,fileinfo(DataHandle)%NumberTimes
1485 if (fileinfo(DataHandle)%Times(idx) == DateStr) then
1487 fileinfo(DataHandle)%CurrentTime = idx
1490 if (found_time == 0) then
1491 Status = WRF_WARN_TIME_NF
1497 END SUBROUTINE ext_gr1_set_time
1499 !*****************************************************************************
1501 SUBROUTINE ext_gr1_get_next_time ( DataHandle, DateStr, Status )
1505 #include "wrf_status_codes.h"
1506 INTEGER , INTENT(IN) :: DataHandle
1507 CHARACTER*(*) , INTENT(OUT) :: DateStr
1508 INTEGER , INTENT(OUT) :: Status
1510 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_next_time')
1512 if (fileinfo(DataHandle)%CurrentTime == fileinfo(DataHandle)%NumberTimes) then
1513 Status = WRF_WARN_TIME_EOF
1515 fileinfo(DataHandle)%CurrentTime = fileinfo(DataHandle)%CurrentTime + 1
1516 DateStr = fileinfo(DataHandle)%Times(fileinfo(DataHandle)%CurrentTime)
1521 END SUBROUTINE ext_gr1_get_next_time
1523 !*****************************************************************************
1525 SUBROUTINE ext_gr1_get_previous_time ( DataHandle, DateStr, Status )
1529 #include "wrf_status_codes.h"
1530 INTEGER , INTENT(IN) :: DataHandle
1531 CHARACTER*(*) :: DateStr
1532 INTEGER , INTENT(OUT) :: Status
1534 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_previous_time')
1536 if (fileinfo(DataHandle)%CurrentTime <= 0) then
1537 Status = WRF_WARN_TIME_EOF
1539 fileinfo(DataHandle)%CurrentTime = fileinfo(DataHandle)%CurrentTime - 1
1540 DateStr = fileinfo(DataHandle)%Times(fileinfo(DataHandle)%CurrentTime)
1545 END SUBROUTINE ext_gr1_get_previous_time
1547 !******************************************************************************
1548 !* Start of get_var_ti_* routines
1549 !******************************************************************************
1551 SUBROUTINE ext_gr1_get_var_ti_real ( DataHandle,Element, Varname, Data, &
1552 Count, Outcount, Status )
1556 #include "wrf_status_codes.h"
1557 INTEGER , INTENT(IN) :: DataHandle
1558 CHARACTER*(*) :: Element
1559 CHARACTER*(*) :: VarName
1560 real , INTENT(OUT) :: Data(*)
1561 INTEGER , INTENT(IN) :: Count
1562 INTEGER , INTENT(OUT) :: OutCount
1563 INTEGER , INTENT(OUT) :: Status
1566 CHARACTER*(1000) :: VALUE
1568 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_real')
1572 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
1573 Varname, Value, stat)
1575 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1576 Status = WRF_WARN_VAR_NF
1580 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
1581 if (stat .ne. 0) then
1582 CALL wrf_message("Reading data from"//Value//"failed")
1583 Status = WRF_WARN_COUNT_TOO_LONG
1589 END SUBROUTINE ext_gr1_get_var_ti_real
1591 !*****************************************************************************
1593 SUBROUTINE ext_gr1_get_var_ti_real8 ( DataHandle,Element, Varname, Data, &
1594 Count, Outcount, Status )
1598 #include "wrf_status_codes.h"
1599 INTEGER , INTENT(IN) :: DataHandle
1600 CHARACTER*(*) :: Element
1601 CHARACTER*(*) :: VarName
1602 real*8 , INTENT(OUT) :: Data(*)
1603 INTEGER , INTENT(IN) :: Count
1604 INTEGER , INTENT(OUT) :: OutCount
1605 INTEGER , INTENT(OUT) :: Status
1608 CHARACTER*(1000) :: VALUE
1610 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_real8')
1614 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:),TRIM(Element),&
1615 "none",Varname,Value,stat)
1617 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1618 Status = WRF_WARN_VAR_NF
1622 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
1623 if (stat .ne. 0) then
1624 CALL wrf_message("Reading data from"//Value//"failed")
1625 Status = WRF_WARN_COUNT_TOO_LONG
1631 END SUBROUTINE ext_gr1_get_var_ti_real8
1633 !*****************************************************************************
1635 SUBROUTINE ext_gr1_get_var_ti_double ( DataHandle,Element, Varname, Data, &
1636 Count, Outcount, Status )
1639 #include "wrf_status_codes.h"
1640 INTEGER , INTENT(IN) :: DataHandle
1641 CHARACTER*(*) , INTENT(IN) :: Element
1642 CHARACTER*(*) , INTENT(IN) :: VarName
1643 real*8 , INTENT(OUT) :: Data(*)
1644 INTEGER , INTENT(IN) :: Count
1645 INTEGER , INTENT(OUT) :: OutCount
1646 INTEGER , INTENT(OUT) :: Status
1649 CHARACTER*(1000) :: VALUE
1651 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_double')
1655 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), &
1659 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1660 Status = WRF_WARN_VAR_NF
1664 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
1665 if (stat .ne. 0) then
1666 CALL wrf_message("Reading data from"//Value//"failed")
1667 Status = WRF_WARN_COUNT_TOO_LONG
1673 END SUBROUTINE ext_gr1_get_var_ti_double
1675 !*****************************************************************************
1677 SUBROUTINE ext_gr1_get_var_ti_integer ( DataHandle,Element, Varname, Data, &
1678 Count, Outcount, Status )
1682 #include "wrf_status_codes.h"
1683 INTEGER , INTENT(IN) :: DataHandle
1684 CHARACTER*(*) :: Element
1685 CHARACTER*(*) :: VarName
1686 integer , INTENT(OUT) :: Data(*)
1687 INTEGER , INTENT(IN) :: Count
1688 INTEGER , INTENT(OUT) :: OutCount
1689 INTEGER , INTENT(OUT) :: Status
1692 CHARACTER*(1000) :: VALUE
1694 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_integer')
1698 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), &
1699 "none", Varname, Value, stat)
1701 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1702 Status = WRF_WARN_VAR_NF
1706 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
1707 if (stat .ne. 0) then
1708 CALL wrf_message("Reading data from"//Value//"failed")
1709 Status = WRF_WARN_COUNT_TOO_LONG
1715 END SUBROUTINE ext_gr1_get_var_ti_integer
1717 !*****************************************************************************
1719 SUBROUTINE ext_gr1_get_var_ti_logical ( DataHandle,Element, Varname, Data, &
1720 Count, Outcount, Status )
1724 #include "wrf_status_codes.h"
1725 INTEGER , INTENT(IN) :: DataHandle
1726 CHARACTER*(*) :: Element
1727 CHARACTER*(*) :: VarName
1728 logical , INTENT(OUT) :: Data(*)
1729 INTEGER , INTENT(IN) :: Count
1730 INTEGER , INTENT(OUT) :: OutCount
1731 INTEGER , INTENT(OUT) :: Status
1734 CHARACTER*(1000) :: VALUE
1736 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_logical')
1740 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), &
1741 "none", Varname, Value,stat)
1743 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1744 Status = WRF_WARN_VAR_NF
1748 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
1749 if (stat .ne. 0) then
1750 CALL wrf_message("Reading data from"//Value//"failed")
1751 Status = WRF_WARN_COUNT_TOO_LONG
1757 END SUBROUTINE ext_gr1_get_var_ti_logical
1759 !*****************************************************************************
1761 SUBROUTINE ext_gr1_get_var_ti_char ( DataHandle,Element, Varname, Data, &
1766 #include "wrf_status_codes.h"
1767 INTEGER , INTENT(IN) :: DataHandle
1768 CHARACTER*(*) :: Element
1769 CHARACTER*(*) :: VarName
1770 CHARACTER*(*) :: Data
1771 INTEGER , INTENT(OUT) :: Status
1776 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_ti_char')
1778 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), &
1779 "none", Varname, Data,stat)
1781 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
1782 Status = WRF_WARN_VAR_NF
1787 END SUBROUTINE ext_gr1_get_var_ti_char
1789 !******************************************************************************
1790 !* End of get_var_ti_* routines
1791 !******************************************************************************
1794 !******************************************************************************
1795 !* Start of put_var_ti_* routines
1796 !******************************************************************************
1798 SUBROUTINE ext_gr1_put_var_ti_real ( DataHandle,Element, Varname, Data, &
1803 #include "wrf_status_codes.h"
1804 INTEGER , INTENT(IN) :: DataHandle
1805 CHARACTER*(*) :: Element
1806 CHARACTER*(*) :: VarName
1807 real , INTENT(IN) :: Data(*)
1808 INTEGER , INTENT(IN) :: Count
1809 INTEGER , INTENT(OUT) :: Status
1810 CHARACTER(len=1000) :: tmpstr(1000)
1813 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_real')
1815 if (committed(DataHandle)) then
1818 write(tmpstr(idx),'(G17.10)')Data(idx)
1821 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
1826 END SUBROUTINE ext_gr1_put_var_ti_real
1828 !*****************************************************************************
1830 SUBROUTINE ext_gr1_put_var_ti_double ( DataHandle,Element, Varname, Data, &
1834 #include "wrf_status_codes.h"
1835 INTEGER , INTENT(IN) :: DataHandle
1836 CHARACTER*(*) , INTENT(IN) :: Element
1837 CHARACTER*(*) , INTENT(IN) :: VarName
1838 real*8 , INTENT(IN) :: Data(*)
1839 INTEGER , INTENT(IN) :: Count
1840 INTEGER , INTENT(OUT) :: Status
1841 CHARACTER(len=1000) :: tmpstr(1000)
1844 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_double')
1846 if (committed(DataHandle)) then
1849 write(tmpstr(idx),'(G17.10)')Data(idx)
1852 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
1856 END SUBROUTINE ext_gr1_put_var_ti_double
1858 !*****************************************************************************
1860 SUBROUTINE ext_gr1_put_var_ti_real8 ( DataHandle,Element, Varname, Data, &
1865 #include "wrf_status_codes.h"
1866 INTEGER , INTENT(IN) :: DataHandle
1867 CHARACTER*(*) :: Element
1868 CHARACTER*(*) :: VarName
1869 real*8 , INTENT(IN) :: Data(*)
1870 INTEGER , INTENT(IN) :: Count
1871 INTEGER , INTENT(OUT) :: Status
1872 CHARACTER(len=1000) :: tmpstr(1000)
1875 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_real8')
1877 if (committed(DataHandle)) then
1880 write(tmpstr(idx),'(G17.10)')Data(idx)
1883 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
1887 END SUBROUTINE ext_gr1_put_var_ti_real8
1889 !*****************************************************************************
1891 SUBROUTINE ext_gr1_put_var_ti_integer ( DataHandle,Element, Varname, Data, &
1896 #include "wrf_status_codes.h"
1897 INTEGER , INTENT(IN) :: DataHandle
1898 CHARACTER*(*) :: Element
1899 CHARACTER*(*) :: VarName
1900 integer , INTENT(IN) :: Data(*)
1901 INTEGER , INTENT(IN) :: Count
1902 INTEGER , INTENT(OUT) :: Status
1903 CHARACTER(len=1000) :: tmpstr(1000)
1906 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_integer')
1908 if (committed(DataHandle)) then
1911 write(tmpstr(idx),'(G17.10)')Data(idx)
1914 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
1918 END SUBROUTINE ext_gr1_put_var_ti_integer
1920 !*****************************************************************************
1922 SUBROUTINE ext_gr1_put_var_ti_logical ( DataHandle,Element, Varname, Data, &
1927 #include "wrf_status_codes.h"
1928 INTEGER , INTENT(IN) :: DataHandle
1929 CHARACTER*(*) :: Element
1930 CHARACTER*(*) :: VarName
1931 logical , INTENT(IN) :: Data(*)
1932 INTEGER , INTENT(IN) :: Count
1933 INTEGER , INTENT(OUT) :: Status
1934 CHARACTER(len=1000) :: tmpstr(1000)
1937 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_logical')
1939 if (committed(DataHandle)) then
1942 write(tmpstr(idx),'(G17.10)')Data(idx)
1945 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
1950 END SUBROUTINE ext_gr1_put_var_ti_logical
1952 !*****************************************************************************
1954 SUBROUTINE ext_gr1_put_var_ti_char ( DataHandle,Element, Varname, Data, &
1959 #include "wrf_status_codes.h"
1960 INTEGER , INTENT(IN) :: DataHandle
1961 CHARACTER(len=*) :: Element
1962 CHARACTER(len=*) :: VarName
1963 CHARACTER(len=*) :: Data
1964 INTEGER , INTENT(OUT) :: Status
1967 CHARACTER(len=1000) :: tmpstr(1)
1970 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_ti_char')
1972 if (committed(DataHandle)) then
1974 write(tmpstr(1),*)trim(Data)
1976 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, 1, Status)
1981 END SUBROUTINE ext_gr1_put_var_ti_char
1983 !******************************************************************************
1984 !* End of put_var_ti_* routines
1985 !******************************************************************************
1987 !******************************************************************************
1988 !* Start of get_var_td_* routines
1989 !******************************************************************************
1991 SUBROUTINE ext_gr1_get_var_td_double ( DataHandle,Element, DateStr, &
1992 Varname, Data, Count, Outcount, Status )
1995 #include "wrf_status_codes.h"
1996 INTEGER , INTENT(IN) :: DataHandle
1997 CHARACTER*(*) , INTENT(IN) :: Element
1998 CHARACTER*(*) , INTENT(IN) :: DateStr
1999 CHARACTER*(*) , INTENT(IN) :: VarName
2000 real*8 , INTENT(OUT) :: Data(*)
2001 INTEGER , INTENT(IN) :: Count
2002 INTEGER , INTENT(OUT) :: OutCount
2003 INTEGER , INTENT(OUT) :: Status
2006 CHARACTER*(1000) :: VALUE
2008 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_double')
2012 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:),TRIM(Element),DateStr,&
2015 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2016 Status = WRF_WARN_VAR_NF
2020 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2021 if (stat .ne. 0) then
2022 CALL wrf_message("Reading data from"//Value//"failed")
2023 Status = WRF_WARN_COUNT_TOO_LONG
2029 END SUBROUTINE ext_gr1_get_var_td_double
2031 !*****************************************************************************
2033 SUBROUTINE ext_gr1_get_var_td_real ( DataHandle,Element, DateStr,Varname, &
2034 Data, Count, Outcount, Status )
2038 #include "wrf_status_codes.h"
2039 INTEGER , INTENT(IN) :: DataHandle
2040 CHARACTER*(*) :: Element
2041 CHARACTER*(*) :: DateStr
2042 CHARACTER*(*) :: VarName
2043 real , INTENT(OUT) :: Data(*)
2044 INTEGER , INTENT(IN) :: Count
2045 INTEGER , INTENT(OUT) :: OutCount
2046 INTEGER , INTENT(OUT) :: Status
2049 CHARACTER*(1000) :: VALUE
2051 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_real')
2055 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2056 Varname, Value, stat)
2058 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2059 Status = WRF_WARN_VAR_NF
2063 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2064 if (stat .ne. 0) then
2065 CALL wrf_message("Reading data from"//Value//"failed")
2066 Status = WRF_WARN_COUNT_TOO_LONG
2072 END SUBROUTINE ext_gr1_get_var_td_real
2074 !*****************************************************************************
2076 SUBROUTINE ext_gr1_get_var_td_real8 ( DataHandle,Element, DateStr,Varname, &
2077 Data, Count, Outcount, Status )
2081 #include "wrf_status_codes.h"
2082 INTEGER , INTENT(IN) :: DataHandle
2083 CHARACTER*(*) :: Element
2084 CHARACTER*(*) :: DateStr
2085 CHARACTER*(*) :: VarName
2086 real*8 , INTENT(OUT) :: Data(*)
2087 INTEGER , INTENT(IN) :: Count
2088 INTEGER , INTENT(OUT) :: OutCount
2089 INTEGER , INTENT(OUT) :: Status
2092 CHARACTER*(1000) :: VALUE
2094 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_real8')
2098 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:),TRIM(Element),DateStr,&
2101 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2102 Status = WRF_WARN_VAR_NF
2106 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2107 if (stat .ne. 0) then
2108 CALL wrf_message("Reading data from"//Value//"failed")
2109 Status = WRF_WARN_COUNT_TOO_LONG
2115 END SUBROUTINE ext_gr1_get_var_td_real8
2117 !*****************************************************************************
2119 SUBROUTINE ext_gr1_get_var_td_integer ( DataHandle,Element, DateStr,Varname, &
2120 Data, Count, Outcount, Status )
2124 #include "wrf_status_codes.h"
2125 INTEGER , INTENT(IN) :: DataHandle
2126 CHARACTER*(*) :: Element
2127 CHARACTER*(*) :: DateStr
2128 CHARACTER*(*) :: VarName
2129 integer , INTENT(OUT) :: Data(*)
2130 INTEGER , INTENT(IN) :: Count
2131 INTEGER , INTENT(OUT) :: OutCount
2132 INTEGER , INTENT(OUT) :: Status
2135 CHARACTER*(1000) :: VALUE
2137 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_integer')
2141 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2142 Varname, Value,stat)
2144 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2145 Status = WRF_WARN_VAR_NF
2149 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2150 if (stat .ne. 0) then
2151 CALL wrf_message("Reading data from"//Value//"failed")
2152 Status = WRF_WARN_COUNT_TOO_LONG
2158 END SUBROUTINE ext_gr1_get_var_td_integer
2160 !*****************************************************************************
2162 SUBROUTINE ext_gr1_get_var_td_logical ( DataHandle,Element, DateStr,Varname, &
2163 Data, Count, Outcount, Status )
2167 #include "wrf_status_codes.h"
2168 INTEGER , INTENT(IN) :: DataHandle
2169 CHARACTER*(*) :: Element
2170 CHARACTER*(*) :: DateStr
2171 CHARACTER*(*) :: VarName
2172 logical , INTENT(OUT) :: Data(*)
2173 INTEGER , INTENT(IN) :: Count
2174 INTEGER , INTENT(OUT) :: OutCount
2175 INTEGER , INTENT(OUT) :: Status
2178 CHARACTER*(1000) :: VALUE
2180 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_logical')
2184 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2185 Varname, Value,stat)
2187 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2188 Status = WRF_WARN_VAR_NF
2192 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2193 if (stat .ne. 0) then
2194 CALL wrf_message("Reading data from"//Value//"failed")
2195 Status = WRF_WARN_COUNT_TOO_LONG
2201 END SUBROUTINE ext_gr1_get_var_td_logical
2203 !*****************************************************************************
2205 SUBROUTINE ext_gr1_get_var_td_char ( DataHandle,Element, DateStr,Varname, &
2210 #include "wrf_status_codes.h"
2211 INTEGER , INTENT(IN) :: DataHandle
2212 CHARACTER*(*) :: Element
2213 CHARACTER*(*) :: DateStr
2214 CHARACTER*(*) :: VarName
2215 CHARACTER*(*) :: Data
2216 INTEGER , INTENT(OUT) :: Status
2221 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_var_td_char')
2223 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2226 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2227 Status = WRF_WARN_VAR_NF
2232 END SUBROUTINE ext_gr1_get_var_td_char
2234 !******************************************************************************
2235 !* End of get_var_td_* routines
2236 !******************************************************************************
2238 !******************************************************************************
2239 !* Start of put_var_td_* routines
2240 !******************************************************************************
2242 SUBROUTINE ext_gr1_put_var_td_double ( DataHandle, Element, DateStr, Varname, &
2243 Data, Count, Status )
2246 #include "wrf_status_codes.h"
2247 INTEGER , INTENT(IN) :: DataHandle
2248 CHARACTER*(*) , INTENT(IN) :: Element
2249 CHARACTER*(*) , INTENT(IN) :: DateStr
2250 CHARACTER*(*) , INTENT(IN) :: VarName
2251 real*8 , INTENT(IN) :: Data(*)
2252 INTEGER , INTENT(IN) :: Count
2253 INTEGER , INTENT(OUT) :: Status
2254 CHARACTER(len=1000) :: tmpstr(1000)
2257 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_double')
2260 if (committed(DataHandle)) then
2263 write(tmpstr(idx),'(G17.10)')Data(idx)
2266 CALL gr1_build_string (td_output(DataHandle), &
2267 Varname//';'//DateStr//';'//Element, tmpstr, Count, Status)
2272 END SUBROUTINE ext_gr1_put_var_td_double
2274 !*****************************************************************************
2276 SUBROUTINE ext_gr1_put_var_td_integer ( DataHandle,Element, DateStr, &
2277 Varname, Data, Count, Status )
2281 #include "wrf_status_codes.h"
2282 INTEGER , INTENT(IN) :: DataHandle
2283 CHARACTER*(*) :: Element
2284 CHARACTER*(*) :: DateStr
2285 CHARACTER*(*) :: VarName
2286 integer , INTENT(IN) :: Data(*)
2287 INTEGER , INTENT(IN) :: Count
2288 INTEGER , INTENT(OUT) :: Status
2289 CHARACTER(len=1000) :: tmpstr(1000)
2292 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_integer')
2294 if (committed(DataHandle)) then
2297 write(tmpstr(idx),'(G17.10)')Data(idx)
2300 CALL gr1_build_string (td_output(DataHandle), &
2301 Varname//';'//DateStr//';'//Element, tmpstr, Count, Status)
2306 END SUBROUTINE ext_gr1_put_var_td_integer
2308 !*****************************************************************************
2310 SUBROUTINE ext_gr1_put_var_td_real ( DataHandle,Element, DateStr,Varname, &
2311 Data, Count, Status )
2315 #include "wrf_status_codes.h"
2316 INTEGER , INTENT(IN) :: DataHandle
2317 CHARACTER*(*) :: Element
2318 CHARACTER*(*) :: DateStr
2319 CHARACTER*(*) :: VarName
2320 real , INTENT(IN) :: Data(*)
2321 INTEGER , INTENT(IN) :: Count
2322 INTEGER , INTENT(OUT) :: Status
2323 CHARACTER(len=1000) :: tmpstr(1000)
2326 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_real')
2328 if (committed(DataHandle)) then
2331 write(tmpstr(idx),'(G17.10)')Data(idx)
2334 CALL gr1_build_string (td_output(DataHandle), &
2335 Varname//';'//DateStr//';'//Element, tmpstr, Count, Status)
2340 END SUBROUTINE ext_gr1_put_var_td_real
2342 !*****************************************************************************
2344 SUBROUTINE ext_gr1_put_var_td_real8 ( DataHandle,Element, DateStr,Varname, &
2345 Data, Count, Status )
2349 #include "wrf_status_codes.h"
2350 INTEGER , INTENT(IN) :: DataHandle
2351 CHARACTER*(*) :: Element
2352 CHARACTER*(*) :: DateStr
2353 CHARACTER*(*) :: VarName
2354 real*8 , INTENT(IN) :: Data(*)
2355 INTEGER , INTENT(IN) :: Count
2356 INTEGER , INTENT(OUT) :: Status
2357 CHARACTER(len=1000) :: tmpstr(1000)
2360 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_real8')
2362 if (committed(DataHandle)) then
2364 write(tmpstr(idx),'(G17.10)')Data(idx)
2367 CALL gr1_build_string (td_output(DataHandle), &
2368 Varname//';'//DateStr//';'//Element, tmpstr, Count, Status)
2372 END SUBROUTINE ext_gr1_put_var_td_real8
2374 !*****************************************************************************
2376 SUBROUTINE ext_gr1_put_var_td_logical ( DataHandle,Element, DateStr, &
2377 Varname, Data, Count, Status )
2381 #include "wrf_status_codes.h"
2382 INTEGER , INTENT(IN) :: DataHandle
2383 CHARACTER*(*) :: Element
2384 CHARACTER*(*) :: DateStr
2385 CHARACTER*(*) :: VarName
2386 logical , INTENT(IN) :: Data(*)
2387 INTEGER , INTENT(IN) :: Count
2388 INTEGER , INTENT(OUT) :: Status
2389 CHARACTER(len=1000) :: tmpstr(1000)
2392 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_logical')
2394 if (committed(DataHandle)) then
2397 write(tmpstr(idx),'(G17.10)')Data(idx)
2400 CALL gr1_build_string (td_output(DataHandle), &
2401 Varname//';'//DateStr//';'//Element, tmpstr, Count, Status)
2406 END SUBROUTINE ext_gr1_put_var_td_logical
2408 !*****************************************************************************
2410 SUBROUTINE ext_gr1_put_var_td_char ( DataHandle,Element, DateStr,Varname, &
2415 #include "wrf_status_codes.h"
2416 INTEGER , INTENT(IN) :: DataHandle
2417 CHARACTER*(*) :: Element
2418 CHARACTER*(*) :: DateStr
2419 CHARACTER*(*) :: VarName
2420 CHARACTER*(*) :: Data
2421 INTEGER , INTENT(OUT) :: Status
2422 CHARACTER(len=1000) :: tmpstr
2425 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_var_td_char')
2427 if (committed(DataHandle)) then
2431 tmpstr(idx:idx)=Data(idx:idx)
2433 DO idx=LEN(Data)+1,1000
2437 CALL gr1_build_string (td_output(DataHandle), &
2438 Varname//';'//DateStr//';'//Element, tmpstr, 1, Status)
2443 END SUBROUTINE ext_gr1_put_var_td_char
2445 !******************************************************************************
2446 !* End of put_var_td_* routines
2447 !******************************************************************************
2450 !******************************************************************************
2451 !* Start of get_dom_ti_* routines
2452 !******************************************************************************
2454 SUBROUTINE ext_gr1_get_dom_ti_real ( DataHandle,Element, Data, Count, &
2459 #include "wrf_status_codes.h"
2460 INTEGER , INTENT(IN) :: DataHandle
2461 CHARACTER*(*) :: Element
2462 real , INTENT(OUT) :: Data(*)
2463 INTEGER , INTENT(IN) :: Count
2464 INTEGER , INTENT(OUT) :: Outcount
2465 INTEGER , INTENT(OUT) :: Status
2468 CHARACTER*(1000) :: VALUE
2470 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_real')
2474 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2477 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2478 Status = WRF_WARN_VAR_NF
2482 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2483 if (stat .ne. 0) then
2484 CALL wrf_message("Reading data from"//Value//"failed")
2485 Status = WRF_WARN_COUNT_TOO_LONG
2491 END SUBROUTINE ext_gr1_get_dom_ti_real
2493 !*****************************************************************************
2495 SUBROUTINE ext_gr1_get_dom_ti_real8 ( DataHandle,Element, Data, Count, &
2500 #include "wrf_status_codes.h"
2501 INTEGER , INTENT(IN) :: DataHandle
2502 CHARACTER*(*) :: Element
2503 real*8 , INTENT(OUT) :: Data(*)
2504 INTEGER , INTENT(IN) :: Count
2505 INTEGER , INTENT(OUT) :: OutCount
2506 INTEGER , INTENT(OUT) :: Status
2509 CHARACTER*(1000) :: VALUE
2511 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_real8')
2515 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2518 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2519 Status = WRF_WARN_VAR_NF
2523 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2524 if (stat .ne. 0) then
2525 CALL wrf_message("Reading data from"//Value//"failed")
2526 Status = WRF_WARN_COUNT_TOO_LONG
2532 END SUBROUTINE ext_gr1_get_dom_ti_real8
2534 !*****************************************************************************
2536 SUBROUTINE ext_gr1_get_dom_ti_integer ( DataHandle,Element, Data, Count, &
2541 #include "wrf_status_codes.h"
2542 INTEGER , INTENT(IN) :: DataHandle
2543 CHARACTER*(*) :: Element
2544 integer , INTENT(OUT) :: Data(*)
2545 INTEGER , INTENT(IN) :: Count
2546 INTEGER , INTENT(OUT) :: OutCount
2547 INTEGER , INTENT(OUT) :: Status
2550 CHARACTER*(1000) :: VALUE
2552 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_integer Element: '//Element)
2554 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2557 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2558 Status = WRF_WARN_VAR_NF
2562 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2563 if (stat .ne. 0) then
2564 CALL wrf_message("Reading data from"//Value//"failed")
2565 Status = WRF_WARN_COUNT_TOO_LONG
2571 END SUBROUTINE ext_gr1_get_dom_ti_integer
2573 !*****************************************************************************
2575 SUBROUTINE ext_gr1_get_dom_ti_logical ( DataHandle,Element, Data, Count, &
2580 #include "wrf_status_codes.h"
2581 INTEGER , INTENT(IN) :: DataHandle
2582 CHARACTER*(*) :: Element
2583 logical , INTENT(OUT) :: Data(*)
2584 INTEGER , INTENT(IN) :: Count
2585 INTEGER , INTENT(OUT) :: OutCount
2586 INTEGER , INTENT(OUT) :: Status
2589 CHARACTER*(1000) :: VALUE
2591 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_logical')
2595 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2598 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2599 Status = WRF_WARN_VAR_NF
2603 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2604 if (stat .ne. 0) then
2605 CALL wrf_message("Reading data from"//Value//"failed")
2606 Status = WRF_WARN_COUNT_TOO_LONG
2612 END SUBROUTINE ext_gr1_get_dom_ti_logical
2614 !*****************************************************************************
2616 SUBROUTINE ext_gr1_get_dom_ti_char ( DataHandle,Element, Data, Status )
2620 #include "wrf_status_codes.h"
2621 INTEGER , INTENT(IN) :: DataHandle
2622 CHARACTER*(*) :: Element
2623 CHARACTER*(*) :: Data
2624 INTEGER , INTENT(OUT) :: Status
2630 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_char')
2632 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2635 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2636 Status = WRF_WARN_VAR_NF
2641 END SUBROUTINE ext_gr1_get_dom_ti_char
2643 !*****************************************************************************
2645 SUBROUTINE ext_gr1_get_dom_ti_double ( DataHandle,Element, Data, Count, &
2649 #include "wrf_status_codes.h"
2650 INTEGER , INTENT(IN) :: DataHandle
2651 CHARACTER*(*) , INTENT(IN) :: Element
2652 real*8 , INTENT(OUT) :: Data(*)
2653 INTEGER , INTENT(IN) :: Count
2654 INTEGER , INTENT(OUT) :: OutCount
2655 INTEGER , INTENT(OUT) :: Status
2658 CHARACTER*(1000) :: VALUE
2660 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_ti_double')
2664 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), "none", &
2665 "none", Value, stat)
2667 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2668 Status = WRF_WARN_VAR_NF
2672 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2673 if (stat .ne. 0) then
2674 CALL wrf_message("Reading data from"//Value//"failed")
2675 Status = WRF_WARN_COUNT_TOO_LONG
2681 END SUBROUTINE ext_gr1_get_dom_ti_double
2683 !******************************************************************************
2684 !* End of get_dom_ti_* routines
2685 !******************************************************************************
2688 !******************************************************************************
2689 !* Start of put_dom_ti_* routines
2690 !******************************************************************************
2692 SUBROUTINE ext_gr1_put_dom_ti_real ( DataHandle,Element, Data, Count, &
2697 #include "wrf_status_codes.h"
2698 INTEGER , INTENT(IN) :: DataHandle
2699 CHARACTER*(*) :: Element
2700 real , INTENT(IN) :: Data(*)
2701 INTEGER , INTENT(IN) :: Count
2702 INTEGER , INTENT(OUT) :: Status
2704 CHARACTER(len=1000) :: tmpstr(1000)
2705 character(len=2) :: lf
2708 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_real')
2710 if (Element .eq. 'DX') then
2713 if (Element .eq. 'DY') then
2716 if (Element .eq. 'CEN_LAT') then
2717 center_lat = Data(1)
2719 if (Element .eq. 'CEN_LON') then
2720 center_lon = Data(1)
2722 if (Element .eq. 'TRUELAT1') then
2725 if (Element .eq. 'TRUELAT2') then
2728 if (Element == 'STAND_LON') then
2729 proj_central_lon = Data(1)
2731 if (Element == 'DT') then
2735 if (committed(DataHandle)) then
2738 write(tmpstr(idx),'(G17.10)')Data(idx)
2741 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
2746 END SUBROUTINE ext_gr1_put_dom_ti_real
2748 !*****************************************************************************
2750 SUBROUTINE ext_gr1_put_dom_ti_real8 ( DataHandle,Element, Data, Count, &
2755 #include "wrf_status_codes.h"
2756 INTEGER , INTENT(IN) :: DataHandle
2757 CHARACTER*(*) :: Element
2758 real*8 , INTENT(IN) :: Data(*)
2759 INTEGER , INTENT(IN) :: Count
2760 INTEGER , INTENT(OUT) :: Status
2761 CHARACTER(len=1000) :: tmpstr(1000)
2764 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_real8')
2766 if (committed(DataHandle)) then
2769 write(tmpstr(idx),'(G17.10)')Data(idx)
2772 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
2777 END SUBROUTINE ext_gr1_put_dom_ti_real8
2779 !*****************************************************************************
2781 SUBROUTINE ext_gr1_put_dom_ti_integer ( DataHandle,Element, Data, Count, &
2786 #include "wrf_status_codes.h"
2787 INTEGER , INTENT(IN) :: DataHandle
2788 CHARACTER*(*) :: Element
2789 INTEGER , INTENT(IN) :: Data(*)
2790 INTEGER , INTENT(IN) :: Count
2791 INTEGER , INTENT(OUT) :: Status
2793 CHARACTER(len=1000) :: tmpstr(1000)
2797 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_integer')
2799 if (Element == 'WEST-EAST_GRID_DIMENSION') then
2800 full_xsize = Data(1)
2801 else if (Element == 'SOUTH-NORTH_GRID_DIMENSION') then
2802 full_ysize = Data(1)
2803 else if (Element == 'MAP_PROJ') then
2804 projection = Data(1)
2805 else if (Element == 'WG_GRID_ID') then
2806 wg_grid_id = Data(1)
2807 else if (Element == 'GRID_ID') then
2808 this_domain = Data(1)
2811 if (committed(DataHandle)) then
2814 write(tmpstr(idx),'(G17.10)')Data(idx)
2817 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
2821 call wrf_debug ( DEBUG , 'Leaving ext_gr1_put_dom_ti_integer')
2824 END SUBROUTINE ext_gr1_put_dom_ti_integer
2826 !*****************************************************************************
2828 SUBROUTINE ext_gr1_put_dom_ti_logical ( DataHandle,Element, Data, Count, &
2833 #include "wrf_status_codes.h"
2834 INTEGER , INTENT(IN) :: DataHandle
2835 CHARACTER*(*) :: Element
2836 logical , INTENT(IN) :: Data(*)
2837 INTEGER , INTENT(IN) :: Count
2838 INTEGER , INTENT(OUT) :: Status
2839 CHARACTER(len=1000) :: tmpstr(1000)
2842 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_logical')
2844 if (committed(DataHandle)) then
2847 write(tmpstr(idx),'(G17.10)')Data(idx)
2850 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
2855 END SUBROUTINE ext_gr1_put_dom_ti_logical
2857 !*****************************************************************************
2859 SUBROUTINE ext_gr1_put_dom_ti_char ( DataHandle,Element, Data, &
2864 #include "wrf_status_codes.h"
2865 INTEGER , INTENT(IN) :: DataHandle
2866 CHARACTER*(*) :: Element
2867 CHARACTER*(*), INTENT(IN) :: Data
2868 INTEGER , INTENT(OUT) :: Status
2870 CHARACTER(len=1000) :: tmpstr(1000)
2872 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_char')
2874 if (Element .eq. 'START_DATE') then
2878 if (committed(DataHandle)) then
2880 write(tmpstr(1),*)trim(Data)
2882 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, 1, Status)
2887 END SUBROUTINE ext_gr1_put_dom_ti_char
2889 !*****************************************************************************
2891 SUBROUTINE ext_gr1_put_dom_ti_double ( DataHandle,Element, Data, Count, &
2895 #include "wrf_status_codes.h"
2896 INTEGER , INTENT(IN) :: DataHandle
2897 CHARACTER*(*) , INTENT(IN) :: Element
2898 real*8 , INTENT(IN) :: Data(*)
2899 INTEGER , INTENT(IN) :: Count
2900 INTEGER , INTENT(OUT) :: Status
2901 CHARACTER(len=1000) :: tmpstr(1000)
2904 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_ti_double')
2906 if (committed(DataHandle)) then
2909 write(tmpstr(idx),'(G17.10)')Data(idx)
2912 CALL gr1_build_string (ti_output(DataHandle), Element, tmpstr, Count, Status)
2917 END SUBROUTINE ext_gr1_put_dom_ti_double
2919 !******************************************************************************
2920 !* End of put_dom_ti_* routines
2921 !******************************************************************************
2924 !******************************************************************************
2925 !* Start of get_dom_td_* routines
2926 !******************************************************************************
2928 SUBROUTINE ext_gr1_get_dom_td_real ( DataHandle,Element, DateStr, Data, &
2929 Count, Outcount, Status )
2933 #include "wrf_status_codes.h"
2934 INTEGER , INTENT(IN) :: DataHandle
2935 CHARACTER*(*) :: Element
2936 CHARACTER*(*) :: DateStr
2937 real , INTENT(OUT) :: Data(*)
2938 INTEGER , INTENT(IN) :: Count
2939 INTEGER , INTENT(OUT) :: OutCount
2940 INTEGER , INTENT(OUT) :: Status
2943 CHARACTER*(1000) :: VALUE
2945 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_real')
2949 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2950 "none", Value, stat)
2952 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2953 Status = WRF_WARN_VAR_NF
2957 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
2958 if (stat .ne. 0) then
2959 CALL wrf_message("Reading data from"//Value//"failed")
2960 Status = WRF_WARN_COUNT_TOO_LONG
2966 END SUBROUTINE ext_gr1_get_dom_td_real
2968 !*****************************************************************************
2970 SUBROUTINE ext_gr1_get_dom_td_real8 ( DataHandle,Element, DateStr, Data, &
2971 Count, Outcount, Status )
2975 #include "wrf_status_codes.h"
2976 INTEGER , INTENT(IN) :: DataHandle
2977 CHARACTER*(*) :: Element
2978 CHARACTER*(*) :: DateStr
2979 real*8 , INTENT(OUT) :: Data(*)
2980 INTEGER , INTENT(IN) :: Count
2981 INTEGER , INTENT(OUT) :: OutCount
2982 INTEGER , INTENT(OUT) :: Status
2985 CHARACTER*(1000) :: VALUE
2987 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_real8')
2991 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
2992 "none", Value, stat)
2994 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
2995 Status = WRF_WARN_VAR_NF
2999 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
3000 if (stat .ne. 0) then
3001 CALL wrf_message("Reading data from"//Value//"failed")
3002 Status = WRF_WARN_COUNT_TOO_LONG
3008 END SUBROUTINE ext_gr1_get_dom_td_real8
3010 !*****************************************************************************
3012 SUBROUTINE ext_gr1_get_dom_td_integer ( DataHandle,Element, DateStr, Data, &
3013 Count, Outcount, Status )
3017 #include "wrf_status_codes.h"
3018 INTEGER , INTENT(IN) :: DataHandle
3019 CHARACTER*(*) :: Element
3020 CHARACTER*(*) :: DateStr
3021 integer , INTENT(OUT) :: Data(*)
3022 INTEGER , INTENT(IN) :: Count
3023 INTEGER , INTENT(OUT) :: OutCount
3024 INTEGER , INTENT(OUT) :: Status
3027 CHARACTER*(1000) :: VALUE
3029 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_integer')
3033 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
3036 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
3037 Status = WRF_WARN_VAR_NF
3041 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
3042 if (stat .ne. 0) then
3043 CALL wrf_message("Reading data from"//Value//"failed")
3044 Status = WRF_WARN_COUNT_TOO_LONG
3050 END SUBROUTINE ext_gr1_get_dom_td_integer
3052 !*****************************************************************************
3054 SUBROUTINE ext_gr1_get_dom_td_logical ( DataHandle,Element, DateStr, Data, &
3055 Count, Outcount, Status )
3059 #include "wrf_status_codes.h"
3060 INTEGER , INTENT(IN) :: DataHandle
3061 CHARACTER*(*) :: Element
3062 CHARACTER*(*) :: DateStr
3063 logical , INTENT(OUT) :: Data(*)
3064 INTEGER , INTENT(IN) :: Count
3065 INTEGER , INTENT(OUT) :: OutCount
3066 INTEGER , INTENT(OUT) :: Status
3069 CHARACTER*(1000) :: VALUE
3071 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_logical')
3075 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
3076 "none", Value, stat)
3078 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
3079 Status = WRF_WARN_VAR_NF
3083 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
3084 if (stat .ne. 0) then
3085 CALL wrf_message("Reading data from"//Value//"failed")
3086 Status = WRF_WARN_COUNT_TOO_LONG
3092 END SUBROUTINE ext_gr1_get_dom_td_logical
3094 !*****************************************************************************
3096 SUBROUTINE ext_gr1_get_dom_td_char ( DataHandle,Element, DateStr, Data, &
3101 #include "wrf_status_codes.h"
3102 INTEGER , INTENT(IN) :: DataHandle
3103 CHARACTER*(*) :: Element
3104 CHARACTER*(*) :: DateStr
3105 CHARACTER*(*) :: Data
3106 INTEGER , INTENT(OUT) :: Status
3111 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_char')
3113 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
3116 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
3117 Status = WRF_WARN_VAR_NF
3122 END SUBROUTINE ext_gr1_get_dom_td_char
3124 !*****************************************************************************
3126 SUBROUTINE ext_gr1_get_dom_td_double ( DataHandle,Element, DateStr, Data, &
3127 Count, Outcount, Status )
3130 #include "wrf_status_codes.h"
3131 INTEGER , INTENT(IN) :: DataHandle
3132 CHARACTER*(*) , INTENT(IN) :: Element
3133 CHARACTER*(*) , INTENT(IN) :: DateStr
3134 real*8 , INTENT(OUT) :: Data(*)
3135 INTEGER , INTENT(IN) :: Count
3136 INTEGER , INTENT(OUT) :: OutCount
3137 INTEGER , INTENT(OUT) :: Status
3140 CHARACTER*(1000) :: VALUE
3142 call wrf_debug ( DEBUG , 'Entering ext_gr1_get_dom_td_double')
3146 CALL GET_METADATA_VALUE(fileinfo(DataHandle)%fileindex(:), TRIM(Element), DateStr, &
3147 "none", Value, stat)
3149 CALL wrf_debug ( DEBUG , "GET_METADATA_VALUE failed for "//Element)
3150 Status = WRF_WARN_VAR_NF
3154 READ(Value,*,IOSTAT=stat)(Data(idx),idx=1,Count)
3155 if (stat .ne. 0) then
3156 CALL wrf_message("Reading data from"//Value//"failed")
3157 Status = WRF_WARN_COUNT_TOO_LONG
3163 END SUBROUTINE ext_gr1_get_dom_td_double
3165 !******************************************************************************
3166 !* End of get_dom_td_* routines
3167 !******************************************************************************
3170 !******************************************************************************
3171 !* Start of put_dom_td_* routines
3172 !******************************************************************************
3175 SUBROUTINE ext_gr1_put_dom_td_real8 ( DataHandle,Element, DateStr, Data, &
3180 #include "wrf_status_codes.h"
3181 INTEGER , INTENT(IN) :: DataHandle
3182 CHARACTER*(*) :: Element
3183 CHARACTER*(*) :: DateStr
3184 real*8 , INTENT(IN) :: Data(*)
3185 INTEGER , INTENT(IN) :: Count
3186 INTEGER , INTENT(OUT) :: Status
3187 CHARACTER(len=1000) :: tmpstr(1000)
3190 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_real8')
3192 if (committed(DataHandle)) then
3195 write(tmpstr(idx),'(G17.10)')Data(idx)
3198 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3204 END SUBROUTINE ext_gr1_put_dom_td_real8
3206 !*****************************************************************************
3208 SUBROUTINE ext_gr1_put_dom_td_integer ( DataHandle,Element, DateStr, Data, &
3213 #include "wrf_status_codes.h"
3214 INTEGER , INTENT(IN) :: DataHandle
3215 CHARACTER*(*) :: Element
3216 CHARACTER*(*) :: DateStr
3217 integer , INTENT(IN) :: Data(*)
3218 INTEGER , INTENT(IN) :: Count
3219 INTEGER , INTENT(OUT) :: Status
3220 CHARACTER(len=1000) :: tmpstr(1000)
3223 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_integer')
3225 if (committed(DataHandle)) then
3228 write(tmpstr(idx),'(G17.10)')Data(idx)
3231 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3237 END SUBROUTINE ext_gr1_put_dom_td_integer
3239 !*****************************************************************************
3241 SUBROUTINE ext_gr1_put_dom_td_logical ( DataHandle,Element, DateStr, Data, &
3246 #include "wrf_status_codes.h"
3247 INTEGER , INTENT(IN) :: DataHandle
3248 CHARACTER*(*) :: Element
3249 CHARACTER*(*) :: DateStr
3250 logical , INTENT(IN) :: Data(*)
3251 INTEGER , INTENT(IN) :: Count
3252 INTEGER , INTENT(OUT) :: Status
3253 CHARACTER(len=1000) :: tmpstr(1000)
3256 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_logical')
3258 if (committed(DataHandle)) then
3261 write(tmpstr(idx),'(G17.10)')Data(idx)
3264 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3270 END SUBROUTINE ext_gr1_put_dom_td_logical
3272 !*****************************************************************************
3274 SUBROUTINE ext_gr1_put_dom_td_char ( DataHandle,Element, DateStr, Data, &
3279 #include "wrf_status_codes.h"
3280 INTEGER , INTENT(IN) :: DataHandle
3281 CHARACTER*(*) :: Element
3282 CHARACTER*(*) :: DateStr
3283 CHARACTER(len=*), INTENT(IN) :: Data
3284 INTEGER , INTENT(OUT) :: Status
3285 CHARACTER(len=1000) :: tmpstr(1)
3287 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_char')
3289 if (committed(DataHandle)) then
3291 write(tmpstr(1),*)Data
3293 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3299 END SUBROUTINE ext_gr1_put_dom_td_char
3301 !*****************************************************************************
3303 SUBROUTINE ext_gr1_put_dom_td_double ( DataHandle,Element, DateStr, Data, &
3307 #include "wrf_status_codes.h"
3308 INTEGER , INTENT(IN) :: DataHandle
3309 CHARACTER*(*) , INTENT(IN) :: Element
3310 CHARACTER*(*) , INTENT(IN) :: DateStr
3311 real*8 , INTENT(IN) :: Data(*)
3312 INTEGER , INTENT(IN) :: Count
3313 INTEGER , INTENT(OUT) :: Status
3314 CHARACTER(len=1000) :: tmpstr(1000)
3317 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_double')
3319 if (committed(DataHandle)) then
3322 write(tmpstr(idx),'(G17.10)')Data(idx)
3325 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3331 END SUBROUTINE ext_gr1_put_dom_td_double
3333 !*****************************************************************************
3335 SUBROUTINE ext_gr1_put_dom_td_real ( DataHandle,Element, DateStr, Data, &
3340 #include "wrf_status_codes.h"
3341 INTEGER , INTENT(IN) :: DataHandle
3342 CHARACTER*(*) :: Element
3343 CHARACTER*(*) :: DateStr
3344 real , INTENT(IN) :: Data(*)
3345 INTEGER , INTENT(IN) :: Count
3346 INTEGER , INTENT(OUT) :: Status
3347 CHARACTER(len=1000) :: tmpstr(1000)
3350 call wrf_debug ( DEBUG , 'Entering ext_gr1_put_dom_td_real')
3352 if (committed(DataHandle)) then
3355 write(tmpstr(idx),'(G17.10)')Data(idx)
3358 CALL gr1_build_string (td_output(DataHandle), DateStr//';'//Element, tmpstr, &
3364 END SUBROUTINE ext_gr1_put_dom_td_real
3367 !******************************************************************************
3368 !* End of put_dom_td_* routines
3369 !******************************************************************************
3372 !*****************************************************************************
3374 SUBROUTINE gr1_build_string (string, Element, Value, Count, Status)
3377 #include "wrf_status_codes.h"
3379 CHARACTER (LEN=*) , INTENT(INOUT) :: string
3380 CHARACTER (LEN=*) , INTENT(IN) :: Element
3381 CHARACTER (LEN=*) , INTENT(IN) :: Value(*)
3382 INTEGER , INTENT(IN) :: Count
3383 INTEGER , INTENT(OUT) :: Status
3385 CHARACTER (LEN=2) :: lf
3389 if (len_trim(string) == 0) then
3390 string = lf//Element//' = '
3392 string = trim(string)//lf//Element//' = '
3396 string = trim(string)//','
3398 string = trim(string)//' '//trim(adjustl(Value(idx)))
3403 END SUBROUTINE gr1_build_string
3405 !*****************************************************************************
3407 SUBROUTINE gr1_get_new_handle(DataHandle)
3411 INTEGER , INTENT(OUT) :: DataHandle
3415 do i=firstFileHandle, maxFileHandles
3416 if (.NOT. used(i)) then
3424 END SUBROUTINE gr1_get_new_handle
3427 !******************************************************************************
3430 SUBROUTINE gr1_get_levels(VarName, zidx, zsize, soil_layers, vert_stag, fraction, &
3431 vert_unit, level1, level2)
3438 logical :: soil_layers
3439 logical :: vert_stag
3441 integer :: vert_unit
3444 character (LEN=*) :: VarName
3446 ! Setup vert_unit, and vertical levels in grib units
3448 if ((VarName .eq. 'LANDUSEF') .or. (VarName .eq. 'SOILCTOP') &
3449 .or. (VarName .eq. 'SOILCBOT')) then
3453 else if ((zsize .gt. 1) .and. (.not. soil_layers) .and. (.not. fraction)) &
3457 level1 = (10000*full_eta(zidx)+0.5)
3459 level1 = (10000*half_eta(zidx)+0.5)
3463 ! Set the vertical coordinate and level for soil and 2D fields
3468 else if (soil_layers) then
3470 level1 = 100*(soil_depth(zidx) - 0.5*soil_thickness(zidx))+0.5
3471 level2 = 100*(soil_depth(zidx) + 0.5*soil_thickness(zidx))+0.5
3472 else if (VarName .eq. 'mu') then
3476 else if ((VarName .eq. 'Q2') .or. (VarName .eq. 'TH2') .or. &
3477 (VarName .eq. 'T2')) then
3481 else if ((VarName .eq. 'Q10') .or. (VarName .eq. 'TH10') .or. &
3482 (VarName .eq. 'U10') .or. (VarName .eq. 'V10')) then
3493 end SUBROUTINE gr1_get_levels
3495 !*****************************************************************************
3498 SUBROUTINE gr1_fill_eta_levels(fileindex, FileFd, grib_tables, VarName, eta_levels)
3501 CHARACTER (len=*) :: fileindex
3503 CHARACTER (len=*) :: grib_tables
3504 character (len=*) :: VarName
3505 REAL,DIMENSION(*) :: eta_levels
3507 INTEGER :: center, subcenter, parmtbl
3509 INTEGER :: leveltype
3514 INTEGER :: numindices
3515 integer , DIMENSION(1000) :: indices
3518 ! Read the levels from the grib file
3520 CALL GET_GRIB_PARAM(grib_tables, VarName, center, subcenter, parmtbl, &
3523 if (parmid == -1) then
3524 call wrf_message ('Error getting grib parameter')
3529 CALL GET_GRIB_INDICES(fileindex(:), center, subcenter, parmtbl, &
3530 parmid, "*", leveltype, &
3531 -HUGE(1), -HUGE(1), -HUGE(1), -HUGE(1), indices, numindices)
3533 do idx = 1,numindices
3534 CALL READ_GRIB(fileindex(:),FileFd,indices(idx),eta_levels(idx))
3538 ! Sort the levels--from highest (bottom) to lowest (top)
3542 if (swapped /= 1) exit sortloop
3544 do idx=2, numindices
3546 ! Remove duplicate levels, caused by multiple time periods in a
3549 if (eta_levels(idx) == eta_levels(idx-1)) eta_levels(idx) = 0.0
3550 if (eta_levels(idx) > eta_levels(idx-1)) then
3551 tmp = eta_levels(idx)
3552 eta_levels(idx) = eta_levels(idx - 1)
3553 eta_levels(idx - 1) = tmp
3559 end subroutine gr1_fill_eta_levels