source: lmdz_wrf/trunk/WRFV3/share/mediation_wrfmain.F @ 2661

Last change on this file since 2661 was 1, checked in by lfita, 10 years ago
  • -- --- Opening of the WRF+LMDZ coupling repository --- -- -

WRF: version v3.3
LMDZ: version v1818

More details in:

File size: 5.3 KB
Line 
1!WRF:MEDIATION_LAYER:
2!
3
4SUBROUTINE med_initialdata_input_ptr ( grid , config_flags )
5   USE module_domain
6   USE module_configure
7   IMPLICIT NONE
8   TYPE (domain) , POINTER :: grid
9   TYPE (grid_config_rec_type) , INTENT(IN)   :: config_flags
10   INTERFACE
11      SUBROUTINE med_initialdata_input ( grid , config_flags )
12         USE module_domain
13         USE module_configure
14         TYPE (domain) :: grid
15         TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
16      END SUBROUTINE med_initialdata_input
17   END INTERFACE
18   CALL  med_initialdata_input ( grid , config_flags )
19END SUBROUTINE med_initialdata_input_ptr
20
21SUBROUTINE med_initialdata_input ( grid , config_flags )
22  ! Driver layer
23   USE module_domain
24   USE module_io_domain
25   USE module_timing
26use module_io
27  ! Model layer
28   USE module_configure
29   USE module_bc_time_utilities
30   USE module_utility
31
32   IMPLICIT NONE
33
34  ! Interface
35   INTERFACE
36     SUBROUTINE start_domain ( grid , allowed_to_read )  ! comes from module_start in appropriate dyn_ directory
37       USE module_domain
38       TYPE (domain) grid
39       LOGICAL, INTENT(IN) :: allowed_to_read
40     END SUBROUTINE start_domain
41   END INTERFACE
42
43  ! Arguments
44   TYPE(domain)                               :: grid
45   TYPE (grid_config_rec_type) , INTENT(IN)   :: config_flags
46  ! Local
47   INTEGER                :: fid , ierr , myproc
48   CHARACTER (LEN=80)     :: inpname , rstname, timestr
49   CHARACTER (LEN=80)     :: message
50   LOGICAL                :: restart
51   LOGICAL, EXTERNAL      :: wrf_dm_on_monitor
52
53   CALL nl_get_restart( 1, restart )
54   IF ( .NOT. restart ) THEN
55     !  Initialize the mother domain.
56     grid%input_from_file = .true.
57     IF ( grid%input_from_file ) THEN
58
59        CALL       wrf_debug ( 1 , 'wrf main: calling open_r_dataset for wrfinput' )
60
61        IF ( wrf_dm_on_monitor() ) CALL start_timing
62
63! typically <date> will not be part of input_inname but allow for it
64        CALL domain_clock_get( grid, current_timestr=timestr )
65        CALL construct_filename2a ( inpname , config_flags%input_inname , grid%id , 2 , timestr )
66
67        CALL open_r_dataset ( fid, TRIM(inpname) , grid , config_flags , "DATASET=INPUT", ierr )
68        IF ( ierr .NE. 0 ) THEN
69          WRITE( wrf_err_message , * ) 'program wrf: error opening ',TRIM(inpname),' for reading ierr=',ierr
70          CALL WRF_ERROR_FATAL ( wrf_err_message )
71        ENDIF
72! registry-generated code that reads the variable set defined on a given stream
73#include "fine_stream_input.inc"
74
75        CALL close_dataset ( fid , config_flags , "DATASET=INPUT" )
76        IF ( wrf_dm_on_monitor() ) THEN
77          WRITE ( message , FMT = '("processing wrfinput file (stream 0) for domain ",I8)' ) grid%id
78          CALL end_timing ( TRIM(message) )
79        ENDIF
80#ifdef MOVE_NESTS
81#if ( EM_CORE == 1 )
82        grid%nest_pos = grid%ht
83        where ( grid%nest_pos .gt. 0 ) grid%nest_pos = grid%nest_pos + 500.  ! make a cliff
84#endif
85#endif
86     ENDIF
87     grid%imask_nostag = 1
88     grid%imask_xstag = 1
89     grid%imask_ystag = 1
90     grid%imask_xystag = 1
91#if (EM_CORE == 1)
92     grid%press_adj = .FALSE.
93#endif
94     CALL start_domain ( grid , .TRUE. )
95   ELSE
96
97     IF ( wrf_dm_on_monitor() ) CALL start_timing
98
99     CALL domain_clock_get( grid, current_timestr=timestr )
100     CALL construct_filename2a ( rstname , config_flags%rst_inname , grid%id , 2 , timestr )
101
102     WRITE(message,*)'RESTART run: opening ',TRIM(rstname),' for reading'
103     CALL wrf_message (  message )
104     CALL open_r_dataset ( fid , TRIM(rstname) , grid , config_flags , "DATASET=RESTART", ierr )
105     IF ( ierr .NE. 0 ) THEN
106       WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
107       CALL WRF_ERROR_FATAL ( message )
108     ENDIF
109     CALL input_restart ( fid,   grid , config_flags , ierr )
110     CALL close_dataset ( fid , config_flags , "DATASET=RESTART" )
111
112     IF ( wrf_dm_on_monitor() ) THEN
113       WRITE ( message , FMT = '("processing restart file for domain ",I8)' ) grid%id
114       CALL end_timing ( TRIM(message) )
115     ENDIF
116
117     grid%imask_nostag = 1
118     grid%imask_xstag = 1
119     grid%imask_ystag = 1
120     grid%imask_xystag = 1
121#if (EM_CORE == 1)
122     grid%press_adj = .FALSE.
123#endif
124     CALL start_domain ( grid , .TRUE. )
125   ENDIF
126
127   RETURN
128END SUBROUTINE med_initialdata_input
129
130SUBROUTINE med_shutdown_io ( grid , config_flags )
131  ! Driver layer
132   USE module_domain
133   USE module_io_domain
134  ! Model layer
135   USE module_configure
136
137   IMPLICIT NONE
138
139  ! Arguments
140   TYPE(domain)                               :: grid
141   TYPE (grid_config_rec_type) , INTENT(IN)   :: config_flags
142  ! Local
143   CHARACTER (LEN=80)      :: message
144   INTEGER                 :: ierr
145
146   IF ( grid%oid > 0 ) CALL close_dataset ( grid%oid , config_flags , "DATASET=HISTORY" )
147   IF ( grid%lbc_fid > 0 ) CALL close_dataset ( grid%lbc_fid , config_flags , "DATASET=BOUNDARY" )
148
149! registry generated closes for auxhist streams
150#include "shutdown_closes.inc"
151
152   CALL wrf_ioexit( ierr )    ! shut down the quilt I/O
153
154   RETURN
155
156END SUBROUTINE med_shutdown_io
157
158SUBROUTINE med_add_config_info_to_grid ( grid )
159
160   USE module_domain
161   USE module_configure
162 
163   IMPLICIT NONE
164
165   !  Input data.
166
167   TYPE(domain) , TARGET          :: grid
168
169#define SOURCE_RECORD model_config_rec %
170#define SOURCE_REC_DEX (grid%id)
171#define DEST_RECORD   grid %
172#include <config_assigns.inc>
173
174   RETURN
175
176END SUBROUTINE med_add_config_info_to_grid
177
Note: See TracBrowser for help on using the repository browser.