SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
ol_read_atm_conf_ascii.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6 SUBROUTINE ol_read_atm_conf_ascii (YSC, &
7  hsurf_filetype, hforcing_filetype, &
8  pduration, ptstep_forc, kni, &
9  kyear, kmonth, kday, ptime, &
10  plat, plon, pzs, &
11  pzref, puref )
12 !
13 !==================================================================
14 !!**** *OL_READ_ATM_CONF* - Initialization routine
15 !!
16 !! PURPOSE
17 !! -------
18 !!
19 !!** METHOD
20 !! ------
21 !!
22 !! EXTERNAL
23 !! --------
24 !!
25 !!
26 !! IMPLICIT ARGUMENTS
27 !! ------------------
28 !!
29 !! REFERENCE
30 !! ---------
31 !!
32 !!
33 !! AUTHOR
34 !! ------
35 !! F. Habets *Meteo France*
36 !!
37 !! MODIFICATIONS
38 !! -------------
39 !! Original 01/2004
40 !! Modified by P. Le Moigne (04/2005): cleaning and checking
41 !! Modified by P. Le Moigne (04/2006): init_io_surf for nature
42 !! with GTMSK to read dimensions.
43 !==================================================================
44 !
45 !
46 !
47 USE modd_surfex_n, ONLY : surfex_t
48 !
49 !
51 !
52 USE modd_surfex_mpi, ONLY : nrank, npio, ncomm, nproc, xtime_comm_read, xtime_npio_read
53 !
54 USE modd_arch, ONLY : little_endian_arch
55 USE modd_io_surf_asc, ONLY : nni_forc
56 !
57 USE modi_get_luout
58 USE modi_init_io_surf_n
60 USE modi_end_io_surf_n
61 USE modi_get_size_full_n
63 USE modi_abor1_sfx
64 !
65 USE modi_set_surfex_filein
66 !
67 USE yomhook ,ONLY : lhook, dr_hook
68 USE parkind1 ,ONLY : jprb
69 !
70 IMPLICIT NONE
71 !
72 #ifdef SFX_MPI
73 include 'mpif.h'
74 #endif
75 !
76 !
77 TYPE(surfex_t), INTENT(INOUT) :: ysc
78 !
79  CHARACTER(LEN=6), INTENT(IN) :: hsurf_filetype
80  CHARACTER(LEN=6), INTENT(IN) :: hforcing_filetype
81 INTEGER, INTENT(OUT) :: kni
82 INTEGER, INTENT(OUT) :: kyear, kmonth, kday
83 REAL, INTENT(OUT) :: pduration,ptstep_forc
84 REAL, INTENT(OUT) :: ptime
85 REAL, DIMENSION(:), POINTER :: plat, plon
86 REAL, DIMENSION(:), POINTER :: pzs
87 REAL, DIMENSION(:), POINTER :: pzref, puref
88 !
89 REAL, DIMENSION(:), ALLOCATABLE :: zwork
90 REAL :: zwork0
91 REAL :: ztime
92  CHARACTER(LEN=1) :: yswap
93 TYPE (date_time) :: ttime
94 INTEGER :: ini, idim_full
95 INTEGER :: iyear, imonth, iday
96 INTEGER :: iluout
97 INTEGER :: iret, inb_forc
98 INTEGER :: infompi
99 DOUBLE PRECISION :: xtime0
100 REAL(KIND=JPRB) :: zhook_handle
101 !
102 !==================================================================
103 !
104 IF (lhook) CALL dr_hook('OL_READ_ATM_CONF_ASCII',0,zhook_handle)
105 !
106 IF (nrank==npio) THEN
107  !
108  CALL get_luout(hsurf_filetype,iluout)
109  !
110 #ifdef SFX_MPI
111  xtime0 = mpi_wtime()
112 #endif
113  !
114  !* 1. Define configuration parameters
115  !
116  yswap='N'
117  IF (hforcing_filetype == 'BINARY') READ(21,*) yswap
118  IF (yswap.EQ.'Y') THEN
119  little_endian_arch=.NOT.little_endian_arch
120  WRITE(iluout,*) '*******************************************************************'
121  WRITE(iluout,*) 'Architecture of the machine needs to swap LITTLE_ENDIAN_ARCH to ', &
122  little_endian_arch
123  WRITE(iluout,*) '*******************************************************************'
124  ENDIF
125  !
126  READ(21,*) ini
127  nni_forc = ini
128  !
129  READ(21,*) inb_forc
130  READ(21,*) ptstep_forc
131  pduration = ( inb_forc - 1 ) * ptstep_forc
132  !
133  READ(21,*) iyear
134  READ(21,*) imonth
135  READ(21,*) iday
136  READ(21,*) ztime
137  !
138 #ifdef SFX_MPI
139  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
140 #endif
141  !
142 ENDIF
143 !
144 IF (nproc>1) THEN
145 #ifdef SFX_MPI
146  xtime0 = mpi_wtime()
147  CALL mpi_bcast(ptstep_forc,kind(ptstep_forc)/4,mpi_real,npio,ncomm,infompi)
148  CALL mpi_bcast(pduration,kind(pduration)/4,mpi_real,npio,ncomm,infompi)
149  xtime_comm_read = xtime_comm_read + (mpi_wtime() - xtime0)
150 #endif
151 ENDIF
152 !
153 !* 2. Read full grid dimension and date
154 !
155  CALL set_surfex_filein(hsurf_filetype,'PREP')
156  CALL init_io_surf_n(ysc%DTCO, ysc%DGU, ysc%U, &
157  hsurf_filetype,'FULL ','SURF ','READ ')
158 !
159  CALL read_surf(&
160  hsurf_filetype,'DIM_FULL',idim_full,iret)
161  CALL read_surf(&
162  hsurf_filetype,'DTCUR',ttime,iret)
163 !
164  CALL end_io_surf_n(hsurf_filetype)
165 !
166 kyear = ttime%TDATE%YEAR
167 kmonth = ttime%TDATE%MONTH
168 kday = ttime%TDATE%DAY
169 ptime = ttime%TIME
170 !
171 !* 4. Geographical initialization
172 !
173  CALL get_size_full_n(ysc%U, &
174  'OFFLIN ',idim_full,kni)
175 !
176 ALLOCATE(plon(kni))
177 ALLOCATE(plat(kni))
178 ALLOCATE(pzs(kni))
179 ALLOCATE(pzref(kni))
180 ALLOCATE(puref(kni))
181 !
182 IF (nrank==npio) THEN
183  ALLOCATE(zwork(idim_full))
184 ELSE
185  ALLOCATE(zwork(0))
186 ENDIF
187 !
188 IF (nrank==npio) THEN
189  !
190 #ifdef SFX_MPI
191  xtime0 = mpi_wtime()
192 #endif
193  !
194  IF (ini==1) THEN
195  READ(unit=21,fmt='(F15.8)') zwork0
196  zwork(:) = zwork0
197  ELSE
198  READ(unit=21,fmt='(50(F15.8))') zwork
199  END IF
200  !
201 #ifdef SFX_MPI
202  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
203 #endif
204 ENDIF
205  CALL read_and_send_mpi(zwork,plon)
206 !
207 IF (nrank==npio) THEN
208  !
209 #ifdef SFX_MPI
210  xtime0 = mpi_wtime()
211 #endif
212  !
213  IF (ini==1) THEN
214  READ(unit=21,fmt='(F15.8)') zwork0
215  zwork(:) = zwork0
216  ELSE
217  READ(unit=21,fmt='(50(F15.8))') zwork
218  END IF
219  !
220 #ifdef SFX_MPI
221  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
222 #endif
223 ENDIF
224  CALL read_and_send_mpi(zwork,plat)
225 !
226 IF (nrank==npio) THEN
227  !
228 #ifdef SFX_MPI
229  xtime0 = mpi_wtime()
230 #endif
231  !
232  IF (ini==1) THEN
233  READ(unit=21,fmt='(F15.8)') zwork0
234  zwork(:) = zwork0
235  ELSE
236  READ(unit=21,fmt='(50(F15.8))') zwork
237  END IF
238  !
239 #ifdef SFX_MPI
240  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
241 #endif
242 ENDIF
243  CALL read_and_send_mpi(zwork,pzs)
244 !
245 IF (nrank==npio) THEN
246  !
247 #ifdef SFX_MPI
248  xtime0 = mpi_wtime()
249 #endif
250  !
251  IF (ini==1) THEN
252  READ(unit=21,fmt='(F15.8)') zwork0
253  zwork(:) = zwork0
254  ELSE
255  READ(unit=21,fmt='(50(F15.8))') zwork
256  END IF
257  !
258 #ifdef SFX_MPI
259  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
260 #endif
261 ENDIF
262  CALL read_and_send_mpi(zwork,pzref)
263 !
264 IF (nrank==npio) THEN
265  !
266 #ifdef SFX_MPI
267  xtime0 = mpi_wtime()
268 #endif
269  !
270  IF (ini==1) THEN
271  READ(unit=21,fmt='(F15.8)') zwork0
272  zwork(:) = zwork0
273  ELSE
274  READ(unit=21,fmt='(50(F15.8))') zwork
275  END IF
276  !
277 #ifdef SFX_MPI
278  xtime_npio_read = xtime_npio_read + (mpi_wtime() - xtime0)
279 #endif
280 ENDIF
281  CALL read_and_send_mpi(zwork,puref)
282 !
283 DEALLOCATE(zwork)
284 !
285 !* 3. Check the consistency
286 !
287 IF (nrank==npio) THEN
288  !
289  IF (idim_full /= ini .AND. ini/=1) THEN
290  WRITE(iluout,*)' NUMBER OF GRID POINTS INCONSISTENCY: ',kni,'/',ini
291  CALL abor1_sfx('OL_READ_ATM_CONF_ASCII: NUMBER OF GRID POINTS INCONSISTENCY')
292  ENDIF
293  !
294  ! check date and time
295  !
296  IF ( (kyear /= iyear) .OR. (kmonth /= imonth) .OR. (kday /= iday) ) THEN
297  WRITE(iluout,*)' DATE INCONSISTANCY: ',kyear,kmonth,kday,'/',iyear,imonth,iday
298  CALL abor1_sfx('OL_READ_ATM_CONF_ASCII: DATE INCONSISTENCY')
299  ENDIF
300  !
301  IF ( ptime /= ztime ) THEN
302  WRITE(iluout,*)' TIME INCONSISTANCY: ',ptime,'/',ztime
303  CALL abor1_sfx('OL_READ_ATM_CONF_ASCII: TIME INCONSISTENCY')
304  ENDIF
305  !
306 ENDIF
307 !
308 IF (lhook) CALL dr_hook('OL_READ_ATM_CONF_ASCII',1,zhook_handle)
309 !
310 END SUBROUTINE ol_read_atm_conf_ascii
subroutine init_io_surf_n(DTCO, DGU, U, HPROGRAM, HMASK, HSCHEME, HACTION)
subroutine set_surfex_filein(HPROGRAM, HMASK)
subroutine ol_read_atm_conf_ascii(YSC, HSURF_FILETYPE, HFORCING_FILETYPE, PDURATION, PTSTEP_FORC, KNI, KYEAR, KMONTH, KDAY, PTIME, PLAT, PLON, PZS, PZREF, PUREF)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine end_io_surf_n(HPROGRAM)
Definition: end_io_surfn.F90:6
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine get_size_full_n(U, HPROGRAM, KDIM_FULL, KSIZE_FULL)