PageRenderTime 60ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/wrfv2_fire/frame/module_io.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 4109 lines | 2594 code | 288 blank | 1227 comment | 5 complexity | 9a0c386588802cefdf14e6b9e8dcc79a MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. !WRF:DRIVER_LAYER:IO
  2. !
  3. #define DEBUG_LVL 500
  4. MODULE module_io
  5. !<DESCRIPTION>
  6. !<PRE>
  7. ! WRF-specific package-independent interface to package-dependent WRF-specific
  8. ! I/O packages.
  9. !
  10. ! These routines have the same names as those specified in the WRF I/O API
  11. ! except that:
  12. ! - Routines defined in this file and called by users of this module have
  13. ! the "wrf_" prefix.
  14. ! - Routines defined in the I/O packages and called from routines in this
  15. ! file have the "ext_" prefix.
  16. ! - Routines called from routines in this file to initiate communication
  17. ! with I/O quilt servers have the "wrf_quilt_" prefix.
  18. !
  19. ! See http://www.mmm.ucar.edu/wrf/WG2/software_2.0/IOAPI.doc for the latest
  20. ! version of the WRF I/O API. This document includes detailed descriptions
  21. ! of subroutines and their arguments that are not duplicated in this file.
  22. !
  23. ! We wish to be able to link to different packages depending on whether
  24. ! the I/O is restart, initial, history, or boundary.
  25. !</PRE>
  26. !</DESCRIPTION>
  27. USE module_configure
  28. LOGICAL :: is_inited = .FALSE.
  29. INTEGER, PARAMETER, PRIVATE :: MAX_WRF_IO_HANDLE = 1000
  30. INTEGER :: wrf_io_handles(MAX_WRF_IO_HANDLE), how_opened(MAX_WRF_IO_HANDLE)
  31. LOGICAL :: for_output(MAX_WRF_IO_HANDLE), first_operation(MAX_WRF_IO_HANDLE)
  32. INTEGER :: filtno = 0
  33. LOGICAL, PRIVATE :: bdy_dist_flag = .TRUE. ! false is old style undecomposed boundary data structs,
  34. ! true is new style decomposed boundary data structs
  35. ! are_bdys_distributed, bdys_are_distributed and
  36. ! bdys_not_distributed routines access this flag
  37. CHARACTER*256 extradims
  38. !<DESCRIPTION>
  39. !<PRE>
  40. !
  41. ! include the file generated from md_calls.m4 using the m4 preprocessor
  42. ! note that this file also includes the CONTAINS declaration for the module
  43. !
  44. !</PRE>
  45. !</DESCRIPTION>
  46. #include "md_calls.inc"
  47. !--- registry-generated routine that gets the io format being used for a dataset
  48. INTEGER FUNCTION io_form_for_dataset ( DataSet )
  49. IMPLICIT NONE
  50. CHARACTER*(*), INTENT(IN) :: DataSet
  51. INTEGER :: io_form
  52. #include "io_form_for_dataset.inc"
  53. io_form_for_dataset = io_form
  54. RETURN
  55. END FUNCTION io_form_for_dataset
  56. INTEGER FUNCTION io_form_for_stream ( stream )
  57. USE module_streams
  58. IMPLICIT NONE
  59. INTEGER, INTENT(IN) :: stream
  60. INTEGER :: io_form
  61. #include "io_form_for_stream.inc"
  62. io_form_for_stream = io_form
  63. RETURN
  64. END FUNCTION io_form_for_stream
  65. !--- ioinit
  66. SUBROUTINE wrf_ioinit( Status )
  67. !<DESCRIPTION>
  68. !<PRE>
  69. ! Initialize the WRF I/O system.
  70. !</PRE>
  71. !</DESCRIPTION>
  72. IMPLICIT NONE
  73. INTEGER, INTENT(INOUT) :: Status
  74. !Local
  75. CHARACTER(len=80) :: SysDepInfo
  76. INTEGER :: ierr(10), minerr, maxerr
  77. !
  78. Status = 0
  79. ierr = 0
  80. SysDepInfo = " "
  81. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_ioinit' )
  82. CALL init_io_handles ! defined below
  83. #ifdef NETCDF
  84. CALL ext_ncd_ioinit( SysDepInfo, ierr(1) )
  85. #endif
  86. #ifdef INTIO
  87. CALL ext_int_ioinit( SysDepInfo, ierr(2) )
  88. #endif
  89. #ifdef PHDF5
  90. CALL ext_phdf5_ioinit( SysDepInfo, ierr(3) )
  91. #endif
  92. #ifdef PNETCDF
  93. CALL ext_pnc_ioinit( SysDepInfo, ierr(3) )
  94. #endif
  95. #ifdef MCELIO
  96. CALL ext_mcel_ioinit( SysDepInfo, ierr(4) )
  97. #endif
  98. #ifdef XXX
  99. CALL ext_xxx_ioinit( SysDepInfo, ierr(5) )
  100. #endif
  101. #ifdef YYY
  102. CALL ext_yyy_ioinit( SysDepInfo, ierr(6) )
  103. #endif
  104. #ifdef ZZZ
  105. CALL ext_zzz_ioinit( SysDepInfo, ierr(7) )
  106. #endif
  107. #ifdef ESMFIO
  108. CALL ext_esmf_ioinit( SysDepInfo, ierr(8) )
  109. #endif
  110. #ifdef GRIB1
  111. CALL ext_gr1_ioinit( SysDepInfo, ierr(9) )
  112. #endif
  113. #ifdef GRIB2
  114. CALL ext_gr2_ioinit( SysDepInfo, ierr(10) )
  115. #endif
  116. minerr = MINVAL(ierr)
  117. maxerr = MAXVAL(ierr)
  118. IF ( minerr < 0 ) THEN
  119. Status = minerr
  120. ELSE IF ( maxerr > 0 ) THEN
  121. Status = maxerr
  122. ELSE
  123. Status = 0
  124. ENDIF
  125. END SUBROUTINE wrf_ioinit
  126. !--- ioexit
  127. SUBROUTINE wrf_ioexit( Status )
  128. !<DESCRIPTION>
  129. !<PRE>
  130. ! Shut down the WRF I/O system.
  131. !</PRE>
  132. !</DESCRIPTION>
  133. IMPLICIT NONE
  134. INTEGER, INTENT(INOUT) :: Status
  135. !Local
  136. LOGICAL, EXTERNAL :: use_output_servers
  137. INTEGER :: ierr(11), minerr, maxerr
  138. !
  139. Status = 0
  140. ierr = 0
  141. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_ioexit' )
  142. #ifdef NETCDF
  143. CALL ext_ncd_ioexit( ierr(1) )
  144. #endif
  145. #ifdef INTIO
  146. CALL ext_int_ioexit( ierr(2) )
  147. #endif
  148. #ifdef PHDF5
  149. CALL ext_phdf5_ioexit(ierr(3) )
  150. #endif
  151. #ifdef PNETCDF
  152. CALL ext_pnc_ioexit(ierr(3) )
  153. #endif
  154. #ifdef MCELIO
  155. CALL ext_mcel_ioexit( ierr(4) )
  156. #endif
  157. #ifdef XXX
  158. CALL ext_xxx_ioexit( ierr(5) )
  159. #endif
  160. #ifdef YYY
  161. CALL ext_yyy_ioexit( ierr(6) )
  162. #endif
  163. #ifdef ZZZ
  164. CALL ext_zzz_ioexit( ierr(7) )
  165. #endif
  166. #ifdef ESMFIO
  167. CALL ext_esmf_ioexit( ierr(8) )
  168. #endif
  169. #ifdef GRIB1
  170. CALL ext_gr1_ioexit( ierr(9) )
  171. #endif
  172. #ifdef GRIB2
  173. CALL ext_gr2_ioexit( ierr(10) )
  174. #endif
  175. IF ( use_output_servers() ) CALL wrf_quilt_ioexit( ierr(11) )
  176. minerr = MINVAL(ierr)
  177. maxerr = MAXVAL(ierr)
  178. IF ( minerr < 0 ) THEN
  179. Status = minerr
  180. ELSE IF ( maxerr > 0 ) THEN
  181. Status = maxerr
  182. ELSE
  183. Status = 0
  184. ENDIF
  185. END SUBROUTINE wrf_ioexit
  186. !--- open_for_write_begin
  187. SUBROUTINE wrf_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
  188. DataHandle , Status )
  189. !<DESCRIPTION>
  190. !<PRE>
  191. ! Begin data definition ("training") phase for writing to WRF dataset
  192. ! FileName.
  193. !</PRE>
  194. !</DESCRIPTION>
  195. USE module_state_description
  196. #ifdef DM_PARALLEL
  197. USE module_dm, ONLY : ntasks_x, mytask_x, local_communicator_x
  198. #endif
  199. IMPLICIT NONE
  200. #include "wrf_io_flags.h"
  201. CHARACTER*(*) :: FileName
  202. INTEGER , INTENT(IN) :: Comm_compute , Comm_io
  203. CHARACTER*(*), INTENT(INOUT):: SysDepInfo
  204. INTEGER , INTENT(OUT) :: DataHandle
  205. INTEGER , INTENT(OUT) :: Status
  206. !Local
  207. CHARACTER*128 :: DataSet
  208. INTEGER :: io_form
  209. INTEGER :: Hndl
  210. INTEGER, EXTERNAL :: use_package
  211. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  212. CHARACTER*128 :: LocFilename ! for appending the process ID if necessary
  213. INTEGER :: myproc
  214. CHARACTER*128 :: mess
  215. CHARACTER*1028 :: tstr, t1
  216. INTEGER i,j
  217. WRITE(mess,*) 'module_io.F: in wrf_open_for_write_begin, FileName = ',TRIM(FileName)
  218. CALL wrf_debug( DEBUG_LVL, mess )
  219. CALL get_value_from_pairs ( "DATASET" , SysDepInfo , DataSet )
  220. io_form = io_form_for_dataset( DataSet )
  221. Status = 0
  222. Hndl = -1
  223. IF ( multi_files( io_form ) .OR. .NOT. use_output_servers() ) THEN
  224. SELECT CASE ( use_package(io_form) )
  225. #ifdef NETCDF
  226. CASE ( IO_NETCDF )
  227. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  228. IF ( multi_files(io_form) ) THEN
  229. CALL wrf_get_myproc ( myproc )
  230. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  231. ELSE
  232. LocFilename = FileName
  233. ENDIF
  234. CALL ext_ncd_open_for_write_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  235. Hndl , Status )
  236. ENDIF
  237. IF ( .NOT. multi_files(io_form) ) THEN
  238. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  239. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  240. ENDIF
  241. #endif
  242. #ifdef PHDF5
  243. CASE (IO_PHDF5 )
  244. CALL ext_phdf5_open_for_write_begin( FileName, Comm_compute, Comm_io, SysDepInfo, &
  245. Hndl, Status)
  246. #endif
  247. #ifdef PNETCDF
  248. CASE (IO_PNETCDF )
  249. WRITE(tstr,"(A,',NTASKS_X=',i10,',MYTASK_X=',i10,',LOCAL_COMMUNICATOR_X=',i10)") TRIM(SysDepInfo),ntasks_x,mytask_x,local_communicator_x
  250. j=1
  251. t1 = " "
  252. DO i=1,len(TRIM(tstr))
  253. IF ( tstr(i:i) .NE. ' ' ) THEN
  254. t1(j:j) = tstr(i:i)
  255. j = j + 1
  256. ENDIF
  257. ENDDO
  258. tstr = t1
  259. CALL ext_pnc_open_for_write_begin( FileName, Comm_compute, Comm_io, tstr, &
  260. Hndl, Status)
  261. #endif
  262. #ifdef XXX
  263. CASE ( IO_XXX )
  264. CALL ext_xxx_open_for_write_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  265. Hndl , Status )
  266. #endif
  267. #ifdef YYY
  268. CASE ( IO_YYY )
  269. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  270. IF ( multi_files(io_form) ) THEN
  271. CALL wrf_get_myproc ( myproc )
  272. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  273. ELSE
  274. LocFilename = FileName
  275. ENDIF
  276. CALL ext_yyy_open_for_write_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  277. Hndl , Status )
  278. ENDIF
  279. IF ( .NOT. multi_files(io_form) ) THEN
  280. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  281. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  282. ENDIF
  283. #endif
  284. #ifdef ZZZ
  285. CASE ( IO_ZZZ )
  286. CALL ext_zzz_open_for_write_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  287. Hndl , Status )
  288. #endif
  289. #ifdef GRIB1
  290. CASE ( IO_GRIB1 )
  291. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  292. IF ( multi_files(io_form) ) THEN
  293. CALL wrf_get_myproc ( myproc )
  294. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  295. ELSE
  296. LocFilename = FileName
  297. ENDIF
  298. CALL ext_gr1_open_for_write_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  299. Hndl , Status )
  300. ENDIF
  301. IF ( .NOT. multi_files(io_form) ) THEN
  302. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  303. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  304. ENDIF
  305. #endif
  306. #ifdef GRIB2
  307. CASE ( IO_GRIB2 )
  308. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  309. IF ( multi_files(io_form) ) THEN
  310. CALL wrf_get_myproc ( myproc )
  311. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  312. ELSE
  313. LocFilename = FileName
  314. ENDIF
  315. CALL ext_gr2_open_for_write_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  316. Hndl , Status )
  317. ENDIF
  318. IF ( .NOT. multi_files(io_form) ) THEN
  319. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  320. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  321. ENDIF
  322. #endif
  323. #ifdef MCELIO
  324. CASE ( IO_MCEL )
  325. IF ( wrf_dm_on_monitor() ) THEN
  326. tstr = TRIM(SysDepInfo) // ',' // 'LAT_R=XLAT,LON_R=XLONG,LANDMASK_I=LU_MASK'
  327. CALL ext_mcel_open_for_write_begin ( FileName , Comm_compute, Comm_io, tstr, &
  328. Hndl , Status )
  329. ENDIF
  330. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  331. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  332. #endif
  333. #ifdef ESMFIO
  334. CASE ( IO_ESMF )
  335. CALL ext_esmf_open_for_write_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  336. Hndl , Status )
  337. #endif
  338. #ifdef INTIO
  339. CASE ( IO_INTIO )
  340. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  341. IF ( multi_files(io_form) ) THEN
  342. CALL wrf_get_myproc ( myproc )
  343. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  344. ELSE
  345. LocFilename = FileName
  346. ENDIF
  347. CALL ext_int_open_for_write_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  348. Hndl , Status )
  349. ENDIF
  350. IF ( .NOT. multi_files(io_form) ) THEN
  351. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  352. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  353. ENDIF
  354. #endif
  355. CASE DEFAULT
  356. IF ( io_form .NE. 0 ) THEN
  357. WRITE(mess,*)'Tried to open ',FileName,' writing: no valid io_form (',io_form,')'
  358. CALL wrf_debug(1, mess)
  359. Status = WRF_FILE_NOT_OPENED
  360. ENDIF
  361. END SELECT
  362. ELSE IF ( use_output_servers() ) THEN
  363. IF ( io_form .GT. 0 ) THEN
  364. CALL wrf_quilt_open_for_write_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  365. Hndl , io_form, Status )
  366. ENDIF
  367. ELSE
  368. Status = 0
  369. ENDIF
  370. CALL add_new_handle( Hndl, io_form, .TRUE., DataHandle )
  371. END SUBROUTINE wrf_open_for_write_begin
  372. !--- open_for_write_commit
  373. SUBROUTINE wrf_open_for_write_commit( DataHandle , Status )
  374. !<DESCRIPTION>
  375. !<PRE>
  376. ! This routine switches an internal flag to enable output for the data set
  377. ! referenced by DataHandle. The call to wrf_open_for_write_commit() must be
  378. ! paired with a call to wrf_open_for_write_begin().
  379. !</PRE>
  380. !</DESCRIPTION>
  381. USE module_state_description
  382. IMPLICIT NONE
  383. INTEGER , INTENT(IN ) :: DataHandle
  384. INTEGER , INTENT(OUT) :: Status
  385. CHARACTER (128) :: DataSet
  386. INTEGER :: io_form
  387. INTEGER :: Hndl
  388. LOGICAL :: for_out
  389. INTEGER, EXTERNAL :: use_package
  390. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  391. #include "wrf_io_flags.h"
  392. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_open_for_write_commit' )
  393. Status = 0
  394. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  395. CALL set_first_operation( DataHandle )
  396. IF ( Hndl .GT. -1 ) THEN
  397. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  398. SELECT CASE ( use_package(io_form) )
  399. #ifdef NETCDF
  400. CASE ( IO_NETCDF )
  401. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  402. CALL ext_ncd_open_for_write_commit ( Hndl , Status )
  403. ENDIF
  404. IF ( .NOT. multi_files(io_form) ) CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  405. #endif
  406. #ifdef MCELIO
  407. CASE ( IO_MCEL )
  408. IF ( wrf_dm_on_monitor() ) THEN
  409. CALL ext_mcel_open_for_write_commit ( Hndl , Status )
  410. ENDIF
  411. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  412. #endif
  413. #ifdef ESMFIO
  414. CASE ( IO_ESMF )
  415. CALL ext_esmf_open_for_write_commit ( Hndl , Status )
  416. #endif
  417. #ifdef PHDF5
  418. CASE ( IO_PHDF5 )
  419. CALL ext_phdf5_open_for_write_commit ( Hndl , Status )
  420. #endif
  421. #ifdef PNETCDF
  422. CASE ( IO_PNETCDF )
  423. CALL ext_pnc_open_for_write_commit ( Hndl , Status )
  424. #endif
  425. #ifdef XXX
  426. CASE ( IO_XXX )
  427. CALL ext_xxx_open_for_write_commit ( Hndl , Status )
  428. #endif
  429. #ifdef YYY
  430. CASE ( IO_YYY )
  431. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  432. CALL ext_yyy_open_for_write_commit ( Hndl , Status )
  433. ENDIF
  434. IF ( .NOT. multi_files(io_form) ) CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  435. #endif
  436. #ifdef ZZZ
  437. CASE ( IO_ZZZ )
  438. CALL ext_zzz_open_for_write_commit ( Hndl , Status )
  439. #endif
  440. #ifdef GRIB1
  441. CASE ( IO_GRIB1 )
  442. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  443. CALL ext_gr1_open_for_write_commit ( Hndl , Status )
  444. ENDIF
  445. IF ( .NOT. multi_files(io_form) ) CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  446. #endif
  447. #ifdef GRIB2
  448. CASE ( IO_GRIB2 )
  449. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  450. CALL ext_gr2_open_for_write_commit ( Hndl , Status )
  451. ENDIF
  452. IF ( .NOT. multi_files(io_form) ) CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  453. #endif
  454. #ifdef INTIO
  455. CASE ( IO_INTIO )
  456. CALL ext_int_open_for_write_commit ( Hndl , Status )
  457. #endif
  458. CASE DEFAULT
  459. Status = 0
  460. END SELECT
  461. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  462. CALL wrf_quilt_open_for_write_commit ( Hndl , Status )
  463. ELSE
  464. Status = 0
  465. ENDIF
  466. ELSE
  467. Status = 0
  468. ENDIF
  469. RETURN
  470. END SUBROUTINE wrf_open_for_write_commit
  471. !--- open_for_read_begin
  472. SUBROUTINE wrf_open_for_read_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
  473. DataHandle , Status )
  474. !<DESCRIPTION>
  475. !<PRE>
  476. ! Begin data definition ("training") phase for reading from WRF dataset
  477. ! FileName.
  478. !</PRE>
  479. !</DESCRIPTION>
  480. USE module_state_description
  481. IMPLICIT NONE
  482. #include "wrf_io_flags.h"
  483. CHARACTER*(*) :: FileName
  484. INTEGER , INTENT(IN) :: Comm_compute , Comm_io
  485. CHARACTER*(*) :: SysDepInfo
  486. INTEGER , INTENT(OUT) :: DataHandle
  487. INTEGER , INTENT(OUT) :: Status
  488. CHARACTER*128 :: DataSet
  489. INTEGER :: io_form
  490. INTEGER :: Hndl
  491. LOGICAL :: also_for_out
  492. INTEGER, EXTERNAL :: use_package
  493. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  494. CHARACTER*128 :: LocFilename ! for appending the process ID if necessary
  495. INTEGER myproc
  496. CHARACTER*128 :: mess, fhand
  497. CHARACTER*1028 :: tstr
  498. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_open_for_read_begin' )
  499. CALL get_value_from_pairs ( "DATASET" , SysDepInfo , DataSet )
  500. io_form = io_form_for_dataset( DataSet )
  501. Status = 0
  502. Hndl = -1
  503. also_for_out = .FALSE.
  504. ! IF ( .NOT. use_output_servers() ) THEN
  505. SELECT CASE ( use_package(io_form) )
  506. #ifdef NETCDF
  507. CASE ( IO_NETCDF )
  508. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  509. IF ( multi_files(io_form) ) THEN
  510. CALL wrf_get_myproc ( myproc )
  511. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  512. ELSE
  513. LocFilename = FileName
  514. ENDIF
  515. CALL ext_ncd_open_for_read_begin ( LocFilename , Comm_compute, Comm_io, SysDepInfo, &
  516. Hndl , Status )
  517. ENDIF
  518. IF ( .NOT. multi_files(io_form) ) THEN
  519. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  520. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  521. ENDIF
  522. #endif
  523. #ifdef PNETCDF
  524. CASE ( IO_PNETCDF )
  525. CALL ext_pnc_open_for_read_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  526. Hndl , Status )
  527. #endif
  528. #ifdef XXX
  529. CASE ( IO_XXX )
  530. CALL ext_xxx_open_for_read_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  531. Hndl , Status )
  532. #endif
  533. #ifdef YYY
  534. CASE ( IO_YYY )
  535. CALL ext_yyy_open_for_read_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  536. Hndl , Status )
  537. #endif
  538. #ifdef ZZZ
  539. CASE ( IO_ZZZ )
  540. CALL ext_zzz_open_for_read_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  541. Hndl , Status )
  542. #endif
  543. #ifdef MCELIO
  544. CASE ( IO_MCEL )
  545. also_for_out = .TRUE.
  546. IF ( wrf_dm_on_monitor() ) THEN
  547. WRITE(fhand,'(a,i0)')"filter_",filtno
  548. filtno = filtno + 1
  549. tstr = TRIM(SysDepInfo) // ',' // 'READ_MODE=UPDATE,LAT_R=XLAT,LON_R=XLONG,LANDMASK_I=LU_MASK,FILTER_HANDLE=' // TRIM(fhand)
  550. CALL ext_mcel_open_for_read_begin ( FileName , Comm_compute, Comm_io, tstr, &
  551. Hndl , Status )
  552. ENDIF
  553. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  554. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  555. #endif
  556. #ifdef ESMFIO
  557. CASE ( IO_ESMF )
  558. also_for_out = .TRUE.
  559. CALL ext_esmf_open_for_read_begin ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  560. Hndl , Status )
  561. #endif
  562. #ifdef GRIB1
  563. CASE ( IO_GRIB1 )
  564. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  565. IF ( multi_files(io_form) ) THEN
  566. CALL wrf_get_myproc ( myproc )
  567. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  568. ELSE
  569. LocFilename = FileName
  570. ENDIF
  571. CALL ext_gr1_open_for_read_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  572. Hndl , Status )
  573. ENDIF
  574. IF ( .NOT. multi_files(io_form) ) THEN
  575. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  576. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  577. ENDIF
  578. #endif
  579. #ifdef GRIB2
  580. CASE ( IO_GRIB2 )
  581. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  582. IF ( multi_files(io_form) ) THEN
  583. CALL wrf_get_myproc ( myproc )
  584. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  585. ELSE
  586. LocFilename = FileName
  587. ENDIF
  588. CALL ext_gr2_open_for_read_begin ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  589. Hndl , Status )
  590. ENDIF
  591. IF ( .NOT. multi_files(io_form) ) THEN
  592. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  593. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  594. ENDIF
  595. #endif
  596. #ifdef INTIO
  597. CASE ( IO_INTIO )
  598. #endif
  599. CASE DEFAULT
  600. IF ( io_form .NE. 0 ) THEN
  601. WRITE(mess,*)'Tried to open ',FileName,' reading: no valid io_form (',io_form,')'
  602. CALL wrf_message(mess)
  603. ENDIF
  604. Status = WRF_FILE_NOT_OPENED
  605. END SELECT
  606. ! ELSE
  607. ! Status = 0
  608. ! ENDIF
  609. CALL add_new_handle( Hndl, io_form, also_for_out, DataHandle )
  610. END SUBROUTINE wrf_open_for_read_begin
  611. !--- open_for_read_commit
  612. SUBROUTINE wrf_open_for_read_commit( DataHandle , Status )
  613. !<DESCRIPTION>
  614. !<PRE>
  615. ! End "training" phase for WRF dataset FileName. The call to
  616. ! wrf_open_for_read_commit() must be paired with a call to
  617. ! wrf_open_for_read_begin().
  618. !</PRE>
  619. !</DESCRIPTION>
  620. USE module_state_description
  621. IMPLICIT NONE
  622. INTEGER , INTENT(IN ) :: DataHandle
  623. INTEGER , INTENT(OUT) :: Status
  624. CHARACTER (128) :: DataSet
  625. INTEGER :: io_form
  626. INTEGER :: Hndl
  627. LOGICAL :: for_out
  628. INTEGER, EXTERNAL :: use_package
  629. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  630. #include "wrf_io_flags.h"
  631. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_open_for_read_commit' )
  632. Status = 0
  633. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  634. CALL set_first_operation( DataHandle )
  635. IF ( Hndl .GT. -1 ) THEN
  636. IF ( .NOT. (for_out .AND. use_output_servers()) ) THEN
  637. SELECT CASE ( use_package(io_form) )
  638. #ifdef NETCDF
  639. CASE ( IO_NETCDF )
  640. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  641. CALL ext_ncd_open_for_read_commit ( Hndl , Status )
  642. ENDIF
  643. IF ( .NOT. multi_files(io_form) ) CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  644. #endif
  645. #ifdef MCELIO
  646. CASE ( IO_MCEL )
  647. IF ( wrf_dm_on_monitor() ) THEN
  648. CALL ext_mcel_open_for_read_commit ( Hndl , Status )
  649. ENDIF
  650. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  651. #endif
  652. #ifdef ESMFIO
  653. CASE ( IO_ESMF )
  654. CALL ext_esmf_open_for_read_commit ( Hndl , Status )
  655. #endif
  656. #ifdef PNETCDF
  657. CASE ( IO_PNETCDF )
  658. CALL ext_pnc_open_for_read_commit ( Hndl , Status )
  659. #endif
  660. #ifdef XXX
  661. CASE ( IO_XXX )
  662. CALL ext_xxx_open_for_read_commit ( Hndl , Status )
  663. #endif
  664. #ifdef YYY
  665. CASE ( IO_YYY )
  666. CALL ext_yyy_open_for_read_commit ( Hndl , Status )
  667. #endif
  668. #ifdef ZZZ
  669. CASE ( IO_ZZZ )
  670. CALL ext_zzz_open_for_read_commit ( Hndl , Status )
  671. #endif
  672. #ifdef GRIB1
  673. CASE ( IO_GRIB1 )
  674. CALL ext_gr1_open_for_read_commit ( Hndl , Status )
  675. #endif
  676. #ifdef GRIB2
  677. CASE ( IO_GRIB2 )
  678. CALL ext_gr2_open_for_read_commit ( Hndl , Status )
  679. #endif
  680. #ifdef INTIO
  681. CASE ( IO_INTIO )
  682. #endif
  683. CASE DEFAULT
  684. Status = 0
  685. END SELECT
  686. ELSE
  687. Status = 0
  688. ENDIF
  689. ELSE
  690. Status = WRF_FILE_NOT_OPENED
  691. ENDIF
  692. RETURN
  693. END SUBROUTINE wrf_open_for_read_commit
  694. !--- open_for_read
  695. SUBROUTINE wrf_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  696. DataHandle , Status )
  697. !<DESCRIPTION>
  698. !<PRE>
  699. ! Opens a WRF dataset for reading.
  700. !</PRE>
  701. !</DESCRIPTION>
  702. USE module_state_description
  703. IMPLICIT NONE
  704. CHARACTER*(*) :: FileName
  705. INTEGER , INTENT(IN) :: Comm_compute , Comm_io
  706. CHARACTER*(*) :: SysDepInfo
  707. INTEGER , INTENT(OUT) :: DataHandle
  708. INTEGER , INTENT(OUT) :: Status
  709. CHARACTER (128) :: DataSet, LocFileName
  710. INTEGER :: io_form, myproc
  711. INTEGER :: Hndl
  712. INTEGER, EXTERNAL :: use_package
  713. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  714. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_open_for_read' )
  715. CALL get_value_from_pairs ( "DATASET" , SysDepInfo , DataSet )
  716. io_form = io_form_for_dataset( DataSet )
  717. Hndl = -1
  718. Status = 0
  719. SELECT CASE ( use_package(io_form) )
  720. #ifdef NETCDF
  721. CASE ( IO_NETCDF )
  722. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  723. IF ( multi_files(io_form) ) THEN
  724. CALL wrf_get_myproc ( myproc )
  725. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  726. ELSE
  727. LocFilename = FileName
  728. ENDIF
  729. CALL ext_ncd_open_for_read ( LocFilename , Comm_compute, Comm_io, SysDepInfo, &
  730. Hndl , Status )
  731. ENDIF
  732. IF ( .NOT. multi_files(io_form) ) THEN
  733. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  734. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  735. ENDIF
  736. #endif
  737. #ifdef PNETCDF
  738. CASE ( IO_PNETCDF )
  739. CALL ext_pnc_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  740. Hndl , Status )
  741. #endif
  742. #ifdef PHDF5
  743. CASE ( IO_PHDF5 )
  744. CALL ext_phdf5_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  745. Hndl , Status )
  746. #endif
  747. #ifdef XXX
  748. CASE ( IO_XXX )
  749. CALL ext_xxx_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  750. Hndl , Status )
  751. #endif
  752. #ifdef YYY
  753. CASE ( IO_YYY )
  754. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  755. IF ( multi_files(io_form) ) THEN
  756. CALL wrf_get_myproc ( myproc )
  757. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  758. ELSE
  759. LocFilename = FileName
  760. ENDIF
  761. CALL ext_yyy_open_for_read ( LocFilename , Comm_compute, Comm_io, SysDepInfo, &
  762. Hndl , Status )
  763. ENDIF
  764. IF ( .NOT. multi_files(io_form) ) THEN
  765. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  766. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  767. ENDIF
  768. #endif
  769. #ifdef ZZZ
  770. CASE ( IO_ZZZ )
  771. CALL ext_zzz_open_for_read ( FileName , Comm_compute, Comm_io, SysDepInfo, &
  772. Hndl , Status )
  773. #endif
  774. #ifdef GRIB1
  775. CASE ( IO_GRIB1 )
  776. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  777. IF ( multi_files(io_form) ) THEN
  778. CALL wrf_get_myproc ( myproc )
  779. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  780. ELSE
  781. LocFilename = FileName
  782. ENDIF
  783. CALL ext_gr1_open_for_read ( LocFilename , Comm_compute, Comm_io, SysDepInfo, &
  784. Hndl , Status )
  785. ENDIF
  786. IF ( .NOT. multi_files(io_form) ) THEN
  787. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  788. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  789. ENDIF
  790. #endif
  791. #ifdef GRIB2
  792. CASE ( IO_GRIB2 )
  793. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  794. IF ( multi_files(io_form) ) THEN
  795. CALL wrf_get_myproc ( myproc )
  796. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  797. ELSE
  798. LocFilename = FileName
  799. ENDIF
  800. CALL ext_gr2_open_for_read ( LocFilename , Comm_compute, Comm_io, SysDepInfo, &
  801. Hndl , Status )
  802. ENDIF
  803. IF ( .NOT. multi_files(io_form) ) THEN
  804. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  805. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  806. ENDIF
  807. #endif
  808. #ifdef INTIO
  809. CASE ( IO_INTIO )
  810. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) THEN
  811. IF ( multi_files(io_form) ) THEN
  812. CALL wrf_get_myproc ( myproc )
  813. CALL append_to_filename ( LocFilename , FileName , myproc, 4 )
  814. ELSE
  815. LocFilename = FileName
  816. ENDIF
  817. CALL ext_int_open_for_read ( LocFileName , Comm_compute, Comm_io, SysDepInfo, &
  818. Hndl , Status )
  819. ENDIF
  820. IF ( .NOT. multi_files(io_form) ) THEN
  821. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  822. CALL wrf_dm_bcast_bytes( Hndl, IWORDSIZE )
  823. ENDIF
  824. #endif
  825. CASE DEFAULT
  826. Status = 0
  827. END SELECT
  828. CALL add_new_handle( Hndl, io_form, .FALSE., DataHandle )
  829. RETURN
  830. END SUBROUTINE wrf_open_for_read
  831. !--- inquire_opened
  832. SUBROUTINE wrf_inquire_opened ( DataHandle, FileName , FileStatus, Status )
  833. !<DESCRIPTION>
  834. !<PRE>
  835. ! Inquire if the dataset referenced by DataHandle is open.
  836. !</PRE>
  837. !</DESCRIPTION>
  838. USE module_state_description
  839. IMPLICIT NONE
  840. INTEGER , INTENT(IN) :: DataHandle
  841. CHARACTER*(*) :: FileName
  842. INTEGER , INTENT(OUT) :: FileStatus
  843. INTEGER , INTENT(OUT) :: Status
  844. LOGICAL :: for_out
  845. INTEGER, EXTERNAL :: use_package
  846. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  847. #include "wrf_io_flags.h"
  848. #include "wrf_status_codes.h"
  849. INTEGER io_form , Hndl
  850. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_inquire_opened' )
  851. Status = 0
  852. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  853. IF ( Hndl .GT. -1 ) THEN
  854. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  855. SELECT CASE ( use_package(io_form) )
  856. #ifdef NETCDF
  857. CASE ( IO_NETCDF )
  858. IF (wrf_dm_on_monitor()) CALL ext_ncd_inquire_opened ( Hndl, FileName , FileStatus, Status )
  859. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  860. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  861. #endif
  862. #ifdef PHDF5
  863. CASE ( IO_PHDF5 )
  864. CALL ext_phdf5_inquire_opened ( Hndl, FileName , FileStatus, Status )
  865. #endif
  866. #ifdef PNETCDF
  867. CASE ( IO_PNETCDF )
  868. CALL ext_pnc_inquire_opened ( Hndl, FileName , FileStatus, Status )
  869. #endif
  870. #ifdef XXX
  871. CASE ( IO_XXX )
  872. CALL ext_xxx_inquire_opened ( Hndl, FileName , FileStatus, Status )
  873. #endif
  874. #ifdef YYY
  875. CASE ( IO_YYY )
  876. IF (wrf_dm_on_monitor()) CALL ext_yyy_inquire_opened ( Hndl, FileName , FileStatus, Status )
  877. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  878. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  879. #endif
  880. #ifdef ZZZ
  881. CASE ( IO_ZZZ )
  882. CALL ext_zzz_inquire_opened ( Hndl, FileName , FileStatus, Status )
  883. #endif
  884. #ifdef GRIB1
  885. CASE ( IO_GRIB1 )
  886. IF (wrf_dm_on_monitor()) CALL ext_gr1_inquire_opened ( Hndl, FileName , FileStatus, Status )
  887. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  888. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  889. #endif
  890. #ifdef GRIB2
  891. CASE ( IO_GRIB2 )
  892. IF (wrf_dm_on_monitor()) CALL ext_gr2_inquire_opened ( Hndl, FileName , FileStatus, Status )
  893. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  894. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  895. #endif
  896. #ifdef INTIO
  897. CASE ( IO_INTIO )
  898. IF (wrf_dm_on_monitor()) CALL ext_int_inquire_opened ( Hndl, FileName , FileStatus, Status )
  899. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  900. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  901. #endif
  902. CASE DEFAULT
  903. FileStatus = WRF_FILE_NOT_OPENED
  904. Status = 0
  905. END SELECT
  906. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  907. CALL wrf_quilt_inquire_opened ( Hndl, FileName , FileStatus, Status )
  908. ENDIF
  909. ELSE
  910. FileStatus = WRF_FILE_NOT_OPENED
  911. Status = 0
  912. ENDIF
  913. RETURN
  914. END SUBROUTINE wrf_inquire_opened
  915. !--- inquire_filename
  916. SUBROUTINE wrf_inquire_filename ( DataHandle, FileName , FileStatus, Status )
  917. !<DESCRIPTION>
  918. !<PRE>
  919. ! Returns the Filename and FileStatus associated with DataHandle.
  920. !</PRE>
  921. !</DESCRIPTION>
  922. USE module_state_description
  923. IMPLICIT NONE
  924. INTEGER , INTENT(IN) :: DataHandle
  925. CHARACTER*(*) :: FileName
  926. INTEGER , INTENT(OUT) :: FileStatus
  927. INTEGER , INTENT(OUT) :: Status
  928. #include "wrf_status_codes.h"
  929. INTEGER, EXTERNAL :: use_package
  930. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  931. LOGICAL :: for_out
  932. INTEGER io_form , Hndl
  933. INTEGER :: str_length , str_count
  934. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_inquire_filename' )
  935. Status = 0
  936. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  937. IF ( Hndl .GT. -1 ) THEN
  938. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  939. SELECT CASE ( use_package( io_form ) )
  940. #ifdef NETCDF
  941. CASE ( IO_NETCDF )
  942. str_length = LEN ( FileName )
  943. DO str_count = 1 , str_length
  944. FileName(str_count:str_count) = ' '
  945. END DO
  946. IF (wrf_dm_on_monitor()) CALL ext_ncd_inquire_filename ( Hndl, FileName , FileStatus, Status )
  947. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  948. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  949. #endif
  950. #ifdef PHDF5
  951. CASE ( IO_PHDF5 )
  952. CALL ext_phdf5_inquire_filename ( Hndl, FileName , FileStatus, Status )
  953. #endif
  954. #ifdef PNETCDF
  955. CASE ( IO_PNETCDF )
  956. CALL ext_pnc_inquire_filename ( Hndl, FileName , FileStatus, Status )
  957. #endif
  958. #ifdef XXX
  959. CASE ( IO_XXX )
  960. CALL ext_xxx_inquire_filename ( Hndl, FileName , FileStatus, Status )
  961. #endif
  962. #ifdef YYY
  963. CASE ( IO_YYY )
  964. IF (wrf_dm_on_monitor()) CALL ext_yyy_inquire_filename ( Hndl, FileName , FileStatus, Status )
  965. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  966. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  967. #endif
  968. #ifdef ZZZ
  969. CASE ( IO_ZZZ )
  970. CALL ext_zzz_inquire_filename ( Hndl, FileName , FileStatus, Status )
  971. #endif
  972. #ifdef GRIB1
  973. CASE ( IO_GRIB1 )
  974. IF (wrf_dm_on_monitor()) CALL ext_gr1_inquire_filename ( Hndl, FileName , FileStatus, Status )
  975. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  976. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  977. #endif
  978. #ifdef GRIB2
  979. CASE ( IO_GRIB2 )
  980. IF (wrf_dm_on_monitor()) CALL ext_gr2_inquire_filename ( Hndl, FileName , FileStatus, Status )
  981. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  982. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  983. #endif
  984. #ifdef INTIO
  985. CASE ( IO_INTIO )
  986. IF (wrf_dm_on_monitor()) CALL ext_int_inquire_filename ( Hndl, FileName , FileStatus, Status )
  987. CALL wrf_dm_bcast_bytes( FileStatus, IWORDSIZE )
  988. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  989. #endif
  990. CASE DEFAULT
  991. Status = 0
  992. END SELECT
  993. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  994. CALL wrf_quilt_inquire_filename ( Hndl, FileName , FileStatus, Status )
  995. ENDIF
  996. ELSE
  997. FileName = ""
  998. Status = 0
  999. ENDIF
  1000. RETURN
  1001. END SUBROUTINE wrf_inquire_filename
  1002. !--- sync
  1003. SUBROUTINE wrf_iosync ( DataHandle, Status )
  1004. !<DESCRIPTION>
  1005. !<PRE>
  1006. ! Synchronize the disk copy of a dataset with memory buffers.
  1007. !</PRE>
  1008. !</DESCRIPTION>
  1009. USE module_state_description
  1010. IMPLICIT NONE
  1011. INTEGER , INTENT(IN) :: DataHandle
  1012. INTEGER , INTENT(OUT) :: Status
  1013. #include "wrf_status_codes.h"
  1014. INTEGER, EXTERNAL :: use_package
  1015. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  1016. LOGICAL :: for_out
  1017. INTEGER io_form , Hndl
  1018. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_iosync' )
  1019. Status = 0
  1020. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  1021. IF ( Hndl .GT. -1 ) THEN
  1022. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  1023. SELECT CASE ( use_package(io_form) )
  1024. #ifdef NETCDF
  1025. CASE ( IO_NETCDF )
  1026. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_ncd_iosync( Hndl, Status )
  1027. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  1028. #endif
  1029. #ifdef XXX
  1030. CASE ( IO_XXX )
  1031. CALL ext_xxx_iosync( Hndl, Status )
  1032. #endif
  1033. #ifdef YYY
  1034. CASE ( IO_YYY )
  1035. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_yyy_iosync( Hndl, Status )
  1036. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  1037. #endif
  1038. #ifdef GRIB1
  1039. CASE ( IO_GRIB1 )
  1040. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr1_iosync( Hndl, Status )
  1041. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  1042. #endif
  1043. #ifdef GRIB2
  1044. CASE ( IO_GRIB2 )
  1045. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr2_iosync( Hndl, Status )
  1046. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  1047. #endif
  1048. #ifdef ZZZ
  1049. CASE ( IO_ZZZ )
  1050. CALL ext_zzz_iosync( Hndl, Status )
  1051. #endif
  1052. #ifdef INTIO
  1053. CASE ( IO_INTIO )
  1054. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_int_iosync( Hndl, Status )
  1055. CALL wrf_dm_bcast_bytes( Status , IWORDSIZE )
  1056. #endif
  1057. CASE DEFAULT
  1058. Status = 0
  1059. END SELECT
  1060. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  1061. CALL wrf_quilt_iosync( Hndl, Status )
  1062. ELSE
  1063. Status = 0
  1064. ENDIF
  1065. ELSE
  1066. Status = WRF_ERR_FATAL_BAD_FILE_STATUS
  1067. ENDIF
  1068. RETURN
  1069. END SUBROUTINE wrf_iosync
  1070. !--- close
  1071. SUBROUTINE wrf_ioclose ( DataHandle, Status )
  1072. !<DESCRIPTION>
  1073. !<PRE>
  1074. ! Close the dataset referenced by DataHandle.
  1075. !</PRE>
  1076. !</DESCRIPTION>
  1077. USE module_state_description
  1078. IMPLICIT NONE
  1079. INTEGER , INTENT(IN) :: DataHandle
  1080. INTEGER , INTENT(OUT) :: Status
  1081. #include "wrf_status_codes.h"
  1082. INTEGER, EXTERNAL :: use_package
  1083. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  1084. INTEGER io_form , Hndl
  1085. LOGICAL :: for_out
  1086. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_ioclose' )
  1087. Status = 0
  1088. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  1089. IF ( Hndl .GT. -1 ) THEN
  1090. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  1091. SELECT CASE ( use_package(io_form) )
  1092. #ifdef NETCDF
  1093. CASE ( IO_NETCDF )
  1094. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_ncd_ioclose( Hndl, Status )
  1095. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1096. #endif
  1097. #ifdef PHDF5
  1098. CASE ( IO_PHDF5 )
  1099. CALL ext_phdf5_ioclose( Hndl, Status )
  1100. #endif
  1101. #ifdef PNETCDF
  1102. CASE ( IO_PNETCDF )
  1103. CALL ext_pnc_ioclose( Hndl, Status )
  1104. #endif
  1105. #ifdef XXX
  1106. CASE ( IO_XXX )
  1107. CALL ext_xxx_ioclose( Hndl, Status )
  1108. #endif
  1109. #ifdef YYY
  1110. CASE ( IO_YYY )
  1111. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_yyy_ioclose( Hndl, Status )
  1112. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1113. #endif
  1114. #ifdef ZZZ
  1115. CASE ( IO_ZZZ )
  1116. CALL ext_zzz_ioclose( Hndl, Status )
  1117. #endif
  1118. #ifdef GRIB1
  1119. CASE ( IO_GRIB1 )
  1120. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr1_ioclose( Hndl, Status )
  1121. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1122. #endif
  1123. #ifdef GRIB2
  1124. CASE ( IO_GRIB2 )
  1125. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr2_ioclose( Hndl, Status )
  1126. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1127. #endif
  1128. #ifdef MCELIO
  1129. CASE ( IO_MCEL )
  1130. CALL ext_mcel_ioclose( Hndl, Status )
  1131. #endif
  1132. #ifdef ESMFIO
  1133. CASE ( IO_ESMF )
  1134. CALL ext_esmf_ioclose( Hndl, Status )
  1135. #endif
  1136. #ifdef INTIO
  1137. CASE ( IO_INTIO )
  1138. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_int_ioclose( Hndl, Status )
  1139. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1140. #endif
  1141. CASE DEFAULT
  1142. Status = 0
  1143. END SELECT
  1144. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  1145. CALL wrf_quilt_ioclose( Hndl, Status )
  1146. ELSE
  1147. Status = 0
  1148. ENDIF
  1149. CALL free_handle( DataHandle )
  1150. ELSE
  1151. Status = WRF_ERR_FATAL_BAD_FILE_STATUS
  1152. ENDIF
  1153. RETURN
  1154. END SUBROUTINE wrf_ioclose
  1155. !--- get_next_time (not defined for IntIO )
  1156. SUBROUTINE wrf_get_next_time ( DataHandle, DateStr, Status )
  1157. !<DESCRIPTION>
  1158. !<PRE>
  1159. ! Returns the next time stamp.
  1160. !</PRE>
  1161. !</DESCRIPTION>
  1162. USE module_state_description
  1163. IMPLICIT NONE
  1164. INTEGER , INTENT(IN) :: DataHandle
  1165. CHARACTER*(*) :: DateStr
  1166. INTEGER , INTENT(OUT) :: Status
  1167. #include "wrf_status_codes.h"
  1168. INTEGER, EXTERNAL :: use_package
  1169. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  1170. INTEGER io_form , Hndl, len_of_str
  1171. LOGICAL :: for_out
  1172. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_get_next_time' )
  1173. Status = 0
  1174. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  1175. IF ( Hndl .GT. -1 ) THEN
  1176. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  1177. SELECT CASE ( use_package(io_form) )
  1178. #ifdef NETCDF
  1179. CASE ( IO_NETCDF )
  1180. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_ncd_get_next_time( Hndl, DateStr, Status )
  1181. IF ( .NOT. multi_files(io_form) ) THEN
  1182. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1183. len_of_str = LEN(DateStr)
  1184. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1185. ENDIF
  1186. #endif
  1187. #ifdef PHDF5
  1188. CASE ( IO_PHDF5 )
  1189. CALL ext_phdf5_get_next_time( Hndl, DateStr, Status )
  1190. #endif
  1191. #ifdef PNETCDF
  1192. CASE ( IO_PNETCDF )
  1193. CALL ext_pnc_get_next_time( Hndl, DateStr, Status )
  1194. #endif
  1195. #ifdef XXX
  1196. CASE ( IO_XXX )
  1197. CALL ext_xxx_get_next_time( Hndl, DateStr, Status )
  1198. #endif
  1199. #ifdef YYY
  1200. CASE ( IO_YYY )
  1201. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_yyy_get_next_time( Hndl, DateStr, Status )
  1202. IF ( .NOT. multi_files(io_form) ) THEN
  1203. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1204. len_of_str = LEN(DateStr)
  1205. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1206. ENDIF
  1207. #endif
  1208. #ifdef ZZZ
  1209. CASE ( IO_ZZZ )
  1210. CALL ext_zzz_get_next_time( Hndl, DateStr, Status )
  1211. #endif
  1212. #ifdef GRIB1
  1213. CASE ( IO_GRIB1 )
  1214. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr1_get_next_time( Hndl, DateStr, Status )
  1215. IF ( .NOT. multi_files(io_form) ) THEN
  1216. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1217. len_of_str = LEN(DateStr)
  1218. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1219. ENDIF
  1220. #endif
  1221. #ifdef GRIB2
  1222. CASE ( IO_GRIB2 )
  1223. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr2_get_next_time( Hndl, DateStr, Status )
  1224. IF ( .NOT. multi_files(io_form) ) THEN
  1225. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1226. len_of_str = LEN(DateStr)
  1227. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1228. ENDIF
  1229. #endif
  1230. #ifdef INTIO
  1231. CASE ( IO_INTIO )
  1232. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_int_get_next_time( Hndl, DateStr, Status )
  1233. IF ( .NOT. multi_files(io_form) ) THEN
  1234. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1235. len_of_str = LEN(DateStr)
  1236. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1237. ENDIF
  1238. #endif
  1239. CASE DEFAULT
  1240. Status = 0
  1241. END SELECT
  1242. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  1243. CALL wrf_quilt_get_next_time( Hndl, DateStr, Status )
  1244. ELSE
  1245. Status = 0
  1246. ENDIF
  1247. ELSE
  1248. Status = WRF_ERR_FATAL_BAD_FILE_STATUS
  1249. ENDIF
  1250. RETURN
  1251. END SUBROUTINE wrf_get_next_time
  1252. !--- get_previous_time (not defined for IntIO )
  1253. SUBROUTINE wrf_get_previous_time ( DataHandle, DateStr, Status )
  1254. !<DESCRIPTION>
  1255. !<PRE>
  1256. ! Returns the previous time stamp.
  1257. !</PRE>
  1258. !</DESCRIPTION>
  1259. USE module_state_description
  1260. IMPLICIT NONE
  1261. INTEGER , INTENT(IN) :: DataHandle
  1262. CHARACTER*(*) :: DateStr
  1263. INTEGER , INTENT(OUT) :: Status
  1264. #include "wrf_status_codes.h"
  1265. INTEGER, EXTERNAL :: use_package
  1266. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  1267. INTEGER io_form , Hndl, len_of_str
  1268. LOGICAL :: for_out
  1269. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_get_previous_time' )
  1270. Status = 0
  1271. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  1272. IF ( Hndl .GT. -1 ) THEN
  1273. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  1274. SELECT CASE ( use_package(io_form) )
  1275. #ifdef NETCDF
  1276. CASE ( IO_NETCDF )
  1277. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_ncd_get_previous_time( Hndl, DateStr, Status )
  1278. IF ( .NOT. multi_files(io_form) ) THEN
  1279. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1280. len_of_str = LEN(DateStr)
  1281. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1282. ENDIF
  1283. #endif
  1284. #ifdef PHDF5
  1285. CASE ( IO_PHDF5 )
  1286. CALL ext_phdf5_get_previous_time( Hndl, DateStr, Status )
  1287. #endif
  1288. #ifdef PNETCDF
  1289. CASE ( IO_PNETCDF )
  1290. CALL ext_pnc_get_previous_time( Hndl, DateStr, Status )
  1291. #endif
  1292. #ifdef XXX
  1293. CASE ( IO_XXX )
  1294. CALL ext_xxx_get_previous_time( Hndl, DateStr, Status )
  1295. #endif
  1296. #ifdef YYY
  1297. CASE ( IO_YYY )
  1298. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_yyy_get_previous_time( Hndl, DateStr, Status )
  1299. IF ( .NOT. multi_files(io_form) ) THEN
  1300. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1301. len_of_str = LEN(DateStr)
  1302. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1303. ENDIF
  1304. #endif
  1305. #ifdef ZZZ
  1306. CASE ( IO_ZZZ )
  1307. CALL ext_zzz_get_previous_time( Hndl, DateStr, Status )
  1308. #endif
  1309. #ifdef GRIB1
  1310. CASE ( IO_GRIB1 )
  1311. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr1_get_previous_time( Hndl, DateStr, Status )
  1312. IF ( .NOT. multi_files(io_form) ) THEN
  1313. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1314. len_of_str = LEN(DateStr)
  1315. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1316. ENDIF
  1317. #endif
  1318. #ifdef GRIB2
  1319. CASE ( IO_GRIB2 )
  1320. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr2_get_previous_time( Hndl, DateStr, Status )
  1321. IF ( .NOT. multi_files(io_form) ) THEN
  1322. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1323. len_of_str = LEN(DateStr)
  1324. CALL wrf_dm_bcast_string ( DateStr , len_of_str )
  1325. ENDIF
  1326. #endif
  1327. #ifdef INTIO
  1328. #endif
  1329. CASE DEFAULT
  1330. Status = 0
  1331. END SELECT
  1332. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  1333. CALL wrf_quilt_get_previous_time( Hndl, DateStr, Status )
  1334. ELSE
  1335. Status = 0
  1336. ENDIF
  1337. ELSE
  1338. Status = WRF_ERR_FATAL_BAD_FILE_STATUS
  1339. ENDIF
  1340. RETURN
  1341. END SUBROUTINE wrf_get_previous_time
  1342. !--- set_time
  1343. SUBROUTINE wrf_set_time ( DataHandle, DateStr, Status )
  1344. !<DESCRIPTION>
  1345. !<PRE>
  1346. ! Sets the time stamp.
  1347. !</PRE>
  1348. !</DESCRIPTION>
  1349. USE module_state_description
  1350. IMPLICIT NONE
  1351. INTEGER , INTENT(IN) :: DataHandle
  1352. CHARACTER*(*) :: DateStr
  1353. INTEGER , INTENT(OUT) :: Status
  1354. #include "wrf_status_codes.h"
  1355. INTEGER, EXTERNAL :: use_package
  1356. LOGICAL, EXTERNAL :: wrf_dm_on_monitor, multi_files, use_output_servers
  1357. INTEGER io_form , Hndl
  1358. LOGICAL :: for_out
  1359. CALL wrf_debug( DEBUG_LVL, 'module_io.F: in wrf_set_time' )
  1360. Status = 0
  1361. CALL get_handle ( Hndl, io_form , for_out, DataHandle )
  1362. IF ( Hndl .GT. -1 ) THEN
  1363. IF ( multi_files( io_form ) .OR. .NOT. (for_out .AND. use_output_servers()) ) THEN
  1364. SELECT CASE ( use_package( io_form ) )
  1365. #ifdef NETCDF
  1366. CASE ( IO_NETCDF )
  1367. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_ncd_set_time( Hndl, DateStr, Status )
  1368. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1369. #endif
  1370. #ifdef PHDF5
  1371. CASE ( IO_PHDF5 )
  1372. CALL ext_phdf5_set_time( Hndl, DateStr, Status )
  1373. #endif
  1374. #ifdef PNETCDF
  1375. CASE ( IO_PNETCDF )
  1376. CALL ext_pnc_set_time( Hndl, DateStr, Status )
  1377. #endif
  1378. #ifdef XXX
  1379. CASE ( IO_XXX )
  1380. CALL ext_xxx_set_time( Hndl, DateStr, Status )
  1381. #endif
  1382. #ifdef YYY
  1383. CASE ( IO_YYY )
  1384. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_yyy_set_time( Hndl, DateStr, Status )
  1385. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1386. #endif
  1387. #ifdef ZZZ
  1388. CASE ( IO_ZZZ )
  1389. CALL ext_zzz_set_time( Hndl, DateStr, Status )
  1390. #endif
  1391. #ifdef GRIB1
  1392. CASE ( IO_GRIB1 )
  1393. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr1_set_time( Hndl, DateStr, Status )
  1394. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1395. #endif
  1396. #ifdef GRIB2
  1397. CASE ( IO_GRIB2 )
  1398. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_gr2_set_time( Hndl, DateStr, Status )
  1399. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1400. #endif
  1401. #ifdef INTIO
  1402. CASE ( IO_INTIO )
  1403. IF ( multi_files(io_form) .OR. wrf_dm_on_monitor() ) CALL ext_int_set_time( Hndl, DateStr, Status )
  1404. CALL wrf_dm_bcast_bytes( Status, IWORDSIZE )
  1405. #endif
  1406. CASE DEFAULT
  1407. Status = 0
  1408. END SELECT
  1409. ELSE IF ( io_form .GT. 0 .AND. for_out .AND. use_output_servers() ) THEN
  1410. CALL wrf_quilt_set_time( Hndl, DateStr, Status )
  1411. ELSE
  1412. Status = 0
  1413. ENDIF
  1414. ELSE
  1415. Status = WRF_ERR_FATAL_BAD_FILE_STATUS
  1416. ENDIF
  1417. RETURN
  1418. END SUBROUTINE wrf_set_time
  1419. !--- get_next_var (not defined for IntIO)
  1420. SUBROUTINE wrf_get_next_var ( DataHandle, VarName, Status )
  1421. !<DESCRIPTION>
  1422. !<PRE>
  1423. ! On reading, this rou

Large files files are truncated, but you can click here to view the full file