SURFEX v8.1
General documentation of Surfex
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, HMASK,HACTION)
7 ! ######################
8 !
9 !!**** *INIT_IO_SURF_ASC* Keep in memory the output files
10 !!
11 !! PURPOSE
12 !! -------
13 !
14 !!
15 !!** IMPLICIT ARGUMENTS
16 !! ------------------
17 !! None
18 !!
19 !! REFERENCE
20 !! ---------
21 !!
22 !! AUTHOR
23 !! ------
24 !! V. Masson *Meteo France*
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !!
29 !! P. Le Moigne 04/2004: distinguish in and out file name
30 !! P. Le Moigne 04/2006: special HACTION='GTMSK' to initialize
31 !! a mask different of 'FULL ' in order
32 !! to read dimensions only.
33 !! S. Faroux 06/2012 : implementations for MPI
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, nsize, npio
46 !
49 !
50 USE modi_get_luout
52 USE modi_get_dim_full_n
53 USE modi_get_size_full_n
54 USE modi_get_type_dim_n
55 USE modi_init_io_surf_mask_n
56 !
57 USE yomhook ,ONLY : lhook, dr_hook
58 USE parkind1 ,ONLY : jprb
59 !
60 IMPLICIT NONE
61 !
62 !
63 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
64 TYPE(surf_atm_t), INTENT(INOUT) :: U
65 !
66  CHARACTER(LEN=6), INTENT(IN) :: HMASK
67  CHARACTER(LEN=5), INTENT(IN) :: HACTION
68 !
69 INTEGER :: ILU,IRET, IL
70 REAL(KIND=JPRB) :: ZHOOK_HANDLE
71 !------------------------------------------------------------------------------
72 IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',0,zhook_handle)
73 !
74  CALL get_luout('ASCII ',nluout)
75 !
76 nunit=20
77 !
78 IF (haction=='GTMSK') THEN
79  IF (nrank==npio) THEN
80  OPEN(unit=nunit,file=cfilein,form='FORMATTED')
81  ENDIF
82  cmask = hmask
83  cfile = cfilein
84  IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',1,zhook_handle)
85  RETURN
86 ENDIF
87 !
88 IF (haction == 'READ ') THEN
89  OPEN(unit=nunit,file=cfilein,form='FORMATTED')
90  ! NFULL must be known even if HMASK/=FULL because it's no longer
91  ! updated in init_io_surf_maskn.
92  cmask = 'FULL '
93  CALL read_surf(&
94  'ASCII ','DIM_FULL',nfull,iret,hdir='A')
95  cmask = hmask
96  cfile = cfilein
97 ELSE
98  IF (nrank==npio) THEN
99  IF (lcreated) THEN
100  OPEN(unit=nunit,file=cfileout,form='FORMATTED',position='APPEND')
101  ELSE
102  OPEN(unit=nunit,file=cfileout,form='FORMATTED')
103  lcreated=.true.
104  ENDIF
105  ENDIF
106  ! NFULL must be known in every case.
107  CALL get_dim_full_n(u%NDIM_FULL, nfull)
108  cmask = hmask
109  cfile = cfileout
110 ENDIF
111 !
112 ! nindex is needed for call to get_size_full_n. In init_index_mpi,
113 ! it's not initialized for first readings.
114 IF (.NOT.ALLOCATED(nindex) .AND. nrank==npio) THEN
115  ALLOCATE(nindex(nfull))
116  nindex(:) = 0
117 ELSE
118  CALL get_dim_full_n(u%NDIM_FULL,nfull)
119 ENDIF
120 !
121 !------------------------------------------------------------------------------
122 !
123 ! MASK is sized according to the mpi task running
124  CALL get_size_full_n('ASCII ',nfull,u%NSIZE_FULL,ilu)
125 IF (ilu>nsize) nsize = ilu
126 !
127 il = ilu
128  CALL get_type_dim_n(dtco, u,hmask,il)
129  CALL init_io_surf_mask_n(dtco, u, hmask, il, nluout, ilu, nmask)
130 !
131 !
132 !------------------------------------------------------------------------------
133 IF (lhook) CALL dr_hook('INIT_IO_SURF_ASC_N',1,zhook_handle)
134 !------------------------------------------------------------------------------
135 END SUBROUTINE init_io_surf_asc_n
subroutine get_type_dim_n(DTCO, U, HTYPE, KDIM)
character(len=6) cmask
subroutine get_dim_full_n(KDIM_FULL_IN, KDIM_FULL_OUT)
integer, dimension(:), pointer nmask
logical, save lcreated
subroutine get_size_full_n(HPROGRAM, KDIM_FULL, KSIZE_FULL_IN, KSIZE
subroutine init_io_surf_asc_n(DTCO, U, HMASK, HACTION)
integer, parameter jprb
Definition: parkind1.F90:32
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
integer, dimension(:), allocatable nindex
subroutine init_io_surf_mask_n(DTCO, U, HMASK, KSIZE, KLUOUT, KFULL, KMASK)
character(len=28), save cfileout
character(len=28), save cfilein
character(len=28), save cfile