SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
init_io_surf_ascn.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_asc_n (DTCO, U, &
7  hmask,haction)
8 ! ######################
9 !
10 !!**** *INIT_IO_SURF_ASC* 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 !! S. Faroux 06/2012 : implementations for MPI
35 !
36 !* 0. DECLARATIONS
37 ! ------------
38 !
39 !
40 !
41 !
42 !
44 USE modd_surf_atm_n, ONLY : surf_atm_t
45 !
46 USE modd_surfex_mpi, ONLY : nrank, nindex, nsize, npio
47 !
48 USE modd_io_surf_asc,ONLY: nunit,cfilein,cfileout,nmask,nluout,nfull,cmask, &
49  lopen, lcreated
50 !
51 USE modi_get_luout
53 USE modi_get_dim_full_n
54 USE modi_get_size_full_n
55 USE modi_get_type_dim_n
56 USE modi_init_io_surf_mask_n
57 !
58 USE yomhook ,ONLY : lhook, dr_hook
59 USE parkind1 ,ONLY : jprb
60 !
61 IMPLICIT NONE
62 !
63 !
64 TYPE(data_cover_t), INTENT(INOUT) :: dtco
65 TYPE(surf_atm_t), INTENT(INOUT) :: u
66 !
67  CHARACTER(LEN=6), INTENT(IN) :: hmask
68  CHARACTER(LEN=5), INTENT(IN) :: haction
69 !
70 INTEGER :: ilu,iret, il
71 REAL(KIND=JPRB) :: zhook_handle
72 !------------------------------------------------------------------------------
73 IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',0,zhook_handle)
74 !
75  CALL get_luout('ASCII ',nluout)
76 !
77 !$OMP BARRIER
78 !
79 IF (nrank==npio) lopen=.false.
80 !
81 nunit=20
82 !
83 IF (haction=='GTMSK') THEN
84  IF (nrank==npio) THEN
85 !$OMP SINGLE
86  OPEN(unit=nunit,file=cfilein,form='FORMATTED')
87 !$OMP END SINGLE
88  ENDIF
89  cmask = hmask
90  IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',1,zhook_handle)
91  RETURN
92 ENDIF
93 !
94 IF (haction == 'READ ') THEN
95  IF (nrank==npio) THEN
96 !$OMP SINGLE
97  OPEN(unit=nunit,file=cfilein,form='FORMATTED')
98 !$OMP END SINGLE
99  lopen=.true.
100  ENDIF
101  ! NFULL must be known even if HMASK/=FULL because it's no longer
102  ! updated in init_io_surf_maskn.
103  cmask = 'FULL '
104  CALL read_surf(&
105  'ASCII ','DIM_FULL',nfull,iret,hdir='A')
106  cmask = hmask
107 ELSE
108  IF (nrank==npio) THEN
109 !$OMP SINGLE
110  IF (lcreated) THEN
111  OPEN(unit=nunit,file=cfileout,form='FORMATTED',position='APPEND')
112  ELSE
113  OPEN(unit=nunit,file=cfileout,form='FORMATTED')
114  lcreated=.true.
115  ENDIF
116  lopen=.true.
117 !$OMP END SINGLE
118  ENDIF
119  ! NFULL must be known in every case.
120  CALL get_dim_full_n(u, &
121  nfull)
122  cmask = hmask
123 ENDIF
124 !
125 ! nindex is needed for call to get_size_full_n. In init_index_mpi,
126 ! it's not initialized for first readings.
127 IF (.NOT.ALLOCATED(nindex)) THEN
128  ALLOCATE(nindex(nfull))
129  nindex(:) = 0
130 ENDIF
131 !
132 !------------------------------------------------------------------------------
133 !
134 ! MASK is sized according to the mpi task running
135  CALL get_size_full_n(u, &
136  'ASCII ',nfull,ilu)
137 IF (ilu>nsize) nsize = ilu
138 !
139 il = ilu
140  CALL get_type_dim_n(dtco, u, &
141  hmask,il)
142  CALL init_io_surf_mask_n(dtco, u, &
143  hmask, il, nluout, ilu, nmask)
144 !
145 !$OMP BARRIER
146 !
147 !------------------------------------------------------------------------------
148 IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',1,zhook_handle)
149 !------------------------------------------------------------------------------
150 END SUBROUTINE init_io_surf_asc_n
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
subroutine get_dim_full_n(U, KDIM_FULL)
subroutine init_io_surf_asc_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)