SURFEX v8.1
General documentation of Surfex
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 !
51  nfull_surf, &
52  nib, nie, njb, nje, niu, nju, &
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 IF (haction=='GTMSK') THEN
84  IF (nrank==npio) THEN
85  CALL fmopen(cfilein_lfi,'OLD',cluout_lfi,0,1,1,inb,iret)
87  ENDIF
88  cmask = hmask
89  IF (lhook) CALL dr_hook('INIT_IO_SURF_LFI_N',1,zhook_handle)
90  RETURN
91 ENDIF
92 !
93 IF (haction == 'READ ') THEN
94  CALL fmopen(cfilein_lfi,'OLD',cluout_lfi,0,1,1,inb,iret)
96  CALL read_surf(&
97  'LFI ','DIM_FULL',nfull,iret,hdir='A')
98  IF (hmask == 'FULL ') THEN
100  nib_surf = nib
101  nie_surf = nie
102  njb_surf = njb
103  nje_surf = nje
104  niu_surf = niu
105  nju_surf = nju
106  ENDIF
107 ELSE
108  CALL get_dim_full_n(u%NDIM_FULL, nfull)
109 ENDIF
110 !
111 !
112 IF (haction=='WRITE' .AND. nrank==npio) THEN
113  IF (nrank==npio) THEN
114  CALL fmopen(cfileout_lfi,'UNKNOWN',cluout_lfi,0,1,1,inb,iret)
115  ENDIF
117 ENDIF
118 !
119 !* initialisation of 2D arrays
120 !
121 IF (nib_surf/=nundef) THEN
122  nib = nib_surf
123  nie = nie_surf
124  njb = njb_surf
125  nje = nje_surf
126  niu = niu_surf
127  nju = nju_surf
128 END IF
129 !
130 ! nindex is needed for call to get_size_full_n. In init_index_mpi,
131 ! it's not initialized for first readings.
132 IF (.NOT.ALLOCATED(nindex).AND.nrank==npio) THEN
133  ALLOCATE(nindex(nfull))
134  nindex(:) = 0
135 ELSE
136  CALL get_dim_full_n(u%NDIM_FULL,nfull)
137 ENDIF
138 !
139 !------------------------------------------------------------------------------
140 !
141 ! MASK is sized according to the mpi task running
142  CALL get_size_full_n('LFI ',nfull,u%NSIZE_FULL,ilu)
143 IF (ilu>nsize) nsize = ilu
144 !
145 il = ilu
146  CALL get_type_dim_n(dtco, u, &
147  hmask,il)
148  CALL init_io_surf_mask_n(dtco, u, &
149  hmask, il, nluout, ilu, nmask)
150 !
151 !------------------------------------------------------------------------------
152 CMASK = HMASK
153 IF (lhook) CALL dr_hook('INIT_IO_SURF_LFI_N',1,zhook_handle)
154 !------------------------------------------------------------------------------
155 !
156 END SUBROUTINE init_io_surf_lfi_n
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
subroutine fmopen(HFILEM, HSTATU, HFIPRI, KNPRAR, KFTYPE, KVERB, KNINAR, KRESP)
Definition: fmopen.F90:4
subroutine init_io_surf_lfi_n(DTCO, U, HMASK, HACTION)
subroutine get_dim_full_n(KDIM_FULL_IN, KDIM_FULL_OUT)
subroutine get_size_full_n(HPROGRAM, KDIM_FULL, KSIZE_FULL_IN, KSIZE
character(len=28), save cluout_lfi
integer, parameter jprb
Definition: parkind1.F90:32
character(len=28), save cfile_lfi
integer, parameter nundef
integer, dimension(:), pointer nmask
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
character(len=28), save cfileout_lfi
integer, dimension(:), allocatable nindex
subroutine init_io_surf_mask_n(DTCO, U, HMASK, KSIZE, KLUOUT, KFULL, KMASK)
character(len=6) cmask
character(len=28), save cfilein_lfi