1 !--- open_for_write_begin
2 SUBROUTINE ext_esmf_open_for_write_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 :: exportstate
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) = .false.
21 opened_for_write(i) = .true.
24 ! Grab the current exportState and ensure that it is empty
25 CALL ESMF_ExportStateGetCurrent(exportstate, rc)
26 IF ( rc /= ESMF_SUCCESS ) THEN
27 CALL wrf_error_fatal("ext_esmf_open_for_write: ESMF_ExportStateGetCurrent failed" )
29 ! For now, If the export state is not empty, whine and die.
30 !TODO: Eventually, use nested states to allow more than one auxhist 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( exportstate, itemCount=itemCount, &
35 stateintent=stateintent, rc=rc )
36 IF ( rc /= ESMF_SUCCESS ) THEN
37 CALL wrf_error_fatal("ext_esmf_open_for_write: ESMF_ExportStateGet failed" )
39 IF ( stateintent /= ESMF_STATEINTENT_EXPORT ) THEN
40 CALL wrf_error_fatal("ext_esmf_open_for_write: not an export state" )
42 IF ( itemCount /= 0 ) THEN
43 CALL wrf_error_fatal("ext_esmf_open_for_write: export state not empty, io_esmf is currently limited to only one auxhist stream" )
48 END SUBROUTINE ext_esmf_open_for_write_begin
51 !--- open_for_write_commit
52 SUBROUTINE ext_esmf_open_for_write_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_write( DataHandle ) = .true.
66 END SUBROUTINE ext_esmf_open_for_write_commit