1 !--- open_for_read_begin
2 SUBROUTINE ext_esmf_open_for_read_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
6 CHARACTER*(*) :: FileName
7 INTEGER , INTENT(IN) :: Comm_compute , Comm_io
8 CHARACTER*(*) :: SysDepInfo
9 INTEGER , INTENT(OUT) :: DataHandle
10 INTEGER , INTENT(OUT) :: Status
13 TYPE(ESMF_State), POINTER :: importstate
14 TYPE(ESMF_StateIntent_Flag) :: stateIntent
15 INTEGER :: rc, itemCount
17 CALL int_get_fresh_handle(i)
18 okay_to_write(i) = .false.
19 okay_to_read(i) = .false.
20 opened_for_read(i) = .true.
21 opened_for_write(i) = .false.
24 ! Grab the current importState and ensure that it is empty
25 CALL ESMF_ImportStateGetCurrent(importstate, rc)
26 IF ( rc /= ESMF_SUCCESS ) THEN
27 CALL wrf_error_fatal("ext_esmf_open_for_read: ESMF_ImportStateGetCurrent failed" )
29 ! For now, If the import state is not empty, whine and die.
30 !TODO: Eventually, use nested states to allow more than one auxinput stream
31 !TODO: to be supported via ESMF.
32 !TODO: Eventually, get smart about interacting with "needed" and "optional"
33 !TODO: named state items
34 CALL ESMF_StateGet( importstate, itemCount=itemCount, &
35 stateintent=stateintent, rc=rc )
36 IF ( rc /= ESMF_SUCCESS ) THEN
37 CALL wrf_error_fatal("ext_esmf_open_for_read: ESMF_ImportStateGet failed" )
39 IF ( stateintent /= ESMF_STATEINTENT_IMPORT ) THEN
40 CALL wrf_error_fatal("ext_esmf_open_for_read: not an import state" )
42 IF ( itemCount /= 0 ) THEN
43 CALL wrf_error_fatal("ext_esmf_open_for_read: import state not empty, io_esmf is currently limited to only one auxinput stream" )
48 END SUBROUTINE ext_esmf_open_for_read_begin
51 !--- open_for_read_commit
52 SUBROUTINE ext_esmf_open_for_read_commit( DataHandle , Status )
55 INTEGER , INTENT(IN ) :: DataHandle
56 INTEGER , INTENT(OUT) :: Status
58 IF ( int_valid_handle( DataHandle ) ) THEN
59 IF ( int_handle_in_use( DataHandle ) ) THEN
60 okay_to_read( DataHandle ) = .true.
66 END SUBROUTINE ext_esmf_open_for_read_commit