source: trunk/WRF.COMMON/WRFV2/external/io_esmf/ext_esmf_open_for_read.F90

Last change on this file was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

File size: 2.2 KB
Line 
1!--- open_for_read_begin
2SUBROUTINE ext_esmf_open_for_read_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 :: importstate
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) = .true.
21  opened_for_write(i) = .false.
22  DataHandle = i
23
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" )
28  ENDIF
29  ! For now, If the import state is not empty, whine and die.
30!$$$ Eventually, use nested states to allow than one auxinput stream
31!$$$ to be supported via ESMF. 
32!$$$ Eventually, get smart about interacting with "needed" and "optional"
33!$$$ named state items
34  CALL ESMF_StateGet( importstate, itemCount=itemCount, &
35                      statetype=statetype, rc=rc )
36  IF ( rc /= ESMF_SUCCESS ) THEN
37    CALL wrf_error_fatal("ext_esmf_open_for_read:  ESMF_ImportStateGet failed" )
38  ENDIF
39  IF ( statetype /= ESMF_STATE_IMPORT ) THEN
40    CALL wrf_error_fatal("ext_esmf_open_for_read:  not an import state" )
41  ENDIF
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" )
44  ENDIF
45
46  Status = 0
47  RETURN 
48END SUBROUTINE ext_esmf_open_for_read_begin
49
50
51!--- open_for_read_commit
52SUBROUTINE ext_esmf_open_for_read_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_read( DataHandle ) = .true.
61    ENDIF
62  ENDIF
63
64  Status = 0
65  RETURN 
66END SUBROUTINE ext_esmf_open_for_read_commit
67
Note: See TracBrowser for help on using the repository browser.