source: trunk/WRF.COMMON/WRFV3/external/io_esmf/ext_esmf_open_for_write.F90

Last change on this file was 2759, checked in by aslmd, 3 years ago

adding unmodified code from WRFV3.0.1.1, expurged from useless data +1M size

File size: 2.3 KB
Line 
1!--- open_for_write_begin
2SUBROUTINE ext_esmf_open_for_write_begin( FileName , Comm_compute, Comm_io, SysDepInfo, &
3                                          DataHandle , Status )
4  USE module_ext_esmf
5  IMPLICIT NONE
6  CHARACTER*(*)               :: FileName
7  INTEGER ,       INTENT(IN)  :: Comm_compute , Comm_io
8  CHARACTER*(*)               :: SysDepInfo
9  INTEGER ,       INTENT(OUT) :: DataHandle
10  INTEGER ,       INTENT(OUT) :: Status
11  ! Local declarations
12  INTEGER :: i
13  TYPE(ESMF_State), POINTER :: exportstate
14  TYPE(ESMF_StateType) :: statetype
15  INTEGER :: rc, itemCount
16
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.
22  DataHandle = i
23
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" )
28  ENDIF
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                      statetype=statetype, rc=rc )
36  IF ( rc /= ESMF_SUCCESS ) THEN
37    CALL wrf_error_fatal("ext_esmf_open_for_write:  ESMF_ExportStateGet failed" )
38  ENDIF
39  IF ( statetype /= ESMF_STATE_EXPORT ) THEN
40    CALL wrf_error_fatal("ext_esmf_open_for_write:  not an export state" )
41  ENDIF
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" )
44  ENDIF
45
46  Status = 0
47  RETURN 
48END SUBROUTINE ext_esmf_open_for_write_begin
49
50
51!--- open_for_write_commit
52SUBROUTINE ext_esmf_open_for_write_commit( DataHandle , Status )
53  USE module_ext_esmf
54  IMPLICIT NONE
55  INTEGER , INTENT(IN ) :: DataHandle
56  INTEGER , INTENT(OUT) :: Status
57
58  IF ( int_valid_handle( DataHandle ) ) THEN
59    IF ( int_handle_in_use( DataHandle ) ) THEN
60      okay_to_write( DataHandle ) = .true.
61    ENDIF
62  ENDIF
63
64  Status = 0
65  RETURN 
66END SUBROUTINE ext_esmf_open_for_write_commit
67
Note: See TracBrowser for help on using the repository browser.