SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
init_io_surf_lfin.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 init_io_surf_lfi_n (DTCO, U, &
7  hmask,haction)
8 ! ######################
9 !
10 !!**** *INIT_IO_SURF_LFI* Keep in memory the output files
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 !!
16 !!** IMPLICIT ARGUMENTS
17 !! ------------------
18 !! None
19 !!
20 !! REFERENCE
21 !! ---------
22 !!
23 !! AUTHOR
24 !! ------
25 !! V. Masson *Meteo France*
26 !!
27 !! MODIFICATIONS
28 !! -------------
29 !!
30 !! P. Le Moigne 04/2004: distinguish in and out file name
31 !! P. Le Moigne 04/2006: special HACTION='GTMSK' to initialize
32 !! a mask different of 'FULL ' in order
33 !! to read dimensions only.
34 !
35 !* 0. DECLARATIONS
36 ! ------------
37 !
38 !
39 !
40 !
41 !
43 USE modd_surf_atm_n, ONLY : surf_atm_t
44 !
45 USE modd_surfex_mpi, ONLY : nrank, nindex, npio, nsize
46 !
47 USE modd_surf_par, ONLY: nundef
48 !
49 USE modd_io_surf_lfi,ONLY: cfile_lfi, cfilein_lfi,cfileout_lfi, &
50  nmask,cluout_lfi,nfull,cmask, nluout, &
51  nfull_surf, &
52  nib, nie, njb, nje, niu, nju, &
53  nib_surf, nie_surf, njb_surf, nje_surf,&
54  niu_surf, nju_surf
55 !
56 USE modi_get_luout
58 USE modi_get_dim_full_n
59 USE modi_get_size_full_n
60 USE modi_get_type_dim_n
61 USE modi_init_io_surf_mask_n
62 !
63 USE yomhook ,ONLY : lhook, dr_hook
64 USE parkind1 ,ONLY : jprb
65 !
66 IMPLICIT NONE
67 !
68 !
69 TYPE(data_cover_t), INTENT(INOUT) :: dtco
70 TYPE(surf_atm_t), INTENT(INOUT) :: u
71 !
72  CHARACTER(LEN=6), INTENT(IN) :: hmask
73  CHARACTER(LEN=5), INTENT(IN) :: haction
74 !
75 INTEGER :: ilu,iret, il
76 INTEGER :: inb ! number of articles in the file
77 REAL(KIND=JPRB) :: zhook_handle
78 !------------------------------------------------------------------------------
79 IF (lhook) CALL dr_hook('INIT_IO_SURF_LFI_N',0,zhook_handle)
80 !
81  CALL get_luout('LFI ',nluout)
82 !
83 !$OMP BARRIER
84 !
85 IF (haction=='GTMSK') THEN
86  IF (nrank==npio) THEN
87 !$OMP SINGLE
88  CALL fmopen(cfilein_lfi,'OLD',cluout_lfi,0,1,1,inb,iret)
89 !$OMP END SINGLE
90  cfile_lfi = cfilein_lfi
91  ENDIF
92  cmask = hmask
93  IF (lhook) CALL dr_hook('INIT_IO_SURF_LFI_N',1,zhook_handle)
94  RETURN
95 ENDIF
96 !
97 IF (haction == 'READ ') THEN
98  IF (nrank==npio) THEN
99 !$OMP SINGLE
100  CALL fmopen(cfilein_lfi,'OLD',cluout_lfi,0,1,1,inb,iret)
101 !$OMP END SINGLE
102  cfile_lfi = cfilein_lfi
103  ENDIF
104  CALL read_surf(&
105  'LFI ','DIM_FULL',nfull,iret,hdir='A')
106  IF (hmask == 'FULL ') THEN
107  nfull_surf = nfull
108  nib_surf = nib
109  nie_surf = nie
110  njb_surf = njb
111  nje_surf = nje
112  niu_surf = niu
113  nju_surf = nju
114  ENDIF
115 ELSE
116  CALL get_dim_full_n(u, &
117  nfull)
118 ENDIF
119 !
120 !
121 IF (haction=='WRITE' .AND. nrank==npio) THEN
122 !$OMP SINGLE
123  CALL fmopen(cfileout_lfi,'UNKNOWN',cluout_lfi,0,1,1,inb,iret)
124 !$OMP END SINGLE
125  cfile_lfi = cfileout_lfi
126 ENDIF
127 !
128 !* initialisation of 2D arrays
129 !
130 IF (nib_surf/=nundef) THEN
131  nib = nib_surf
132  nie = nie_surf
133  njb = njb_surf
134  nje = nje_surf
135  niu = niu_surf
136  nju = nju_surf
137 END IF
138 !
139 ! nindex is needed for call to get_size_full_n. In init_index_mpi,
140 ! it's not initialized for first readings.
141 IF (.NOT.ALLOCATED(nindex)) THEN
142  ALLOCATE(nindex(nfull))
143  nindex(:) = 0
144 ENDIF
145 !
146 !------------------------------------------------------------------------------
147 !
148 ! MASK is sized according to the mpi task running
149  CALL get_size_full_n(u, &
150  'LFI ',nfull,ilu)
151 IF (ilu>nsize) nsize = ilu
152 !
153 il = ilu
154  CALL get_type_dim_n(dtco, u, &
155  hmask,il)
156  CALL init_io_surf_mask_n(dtco, u, &
157  hmask, il, nluout, ilu, nmask)
158 !
159 !------------------------------------------------------------------------------
160  cmask = hmask
161 IF (lhook) CALL dr_hook('INIT_IO_SURF_LFI_N',1,zhook_handle)
162 !------------------------------------------------------------------------------
163 !
164 END SUBROUTINE init_io_surf_lfi_n
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
subroutine get_dim_full_n(U, KDIM_FULL)
subroutine init_io_surf_lfi_n(DTCO, U, HMASK, HACTION)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine get_size_full_n(U, HPROGRAM, KDIM_FULL, KSIZE_FULL)
subroutine init_io_surf_mask_n(DTCO, U, HMASK, KSIZE, KLUOUT, KFULL, KMASK)