SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
pgd.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  PROGRAM pgd
7 ! ###########
8 !!
9 !! PURPOSE
10 !! -------
11 !! This program prepares the physiographic data fields.
12 !!
13 !! METHOD
14 !! ------
15 !!
16 !!
17 !! EXTERNAL
18 !! --------
19 !!
20 !!
21 !! IMPLICIT ARGUMENTS
22 !! ------------------
23 !!
24 !!
25 !! REFERENCE
26 !! ---------
27 !!
28 !! AUTHOR
29 !! ------
30 !!
31 !! F. Mereyde Meteo-France
32 !!
33 !! MODIFICATION
34 !! ------------
35 !!
36 !! Original 21/07/95
37 !! Modification 26/07/95 Treatment of orography and subgrid-scale
38 !! orography roughness length (V. Masson)
39 !! Modification 22/05/96 Variable CSTORAGE_TYPE (V. Masson)
40 !! Modification 25/05/96 Modification of splines, correction on z0rel
41 !! and set limits for some surface varaibles
42 !! Modification 12/06/96 Treatment of a rare case for ZPGDZ0EFF (Masson)
43 !! Modification 22/11/96 removes the filtering. It will have to be
44 !! performed in ADVANCED_PREP_PGD (Masson)
45 !! Modification 15/03/99 **** MAJOR MODIFICATION **** (Masson)
46 !! PGD fields are now defined from the cover
47 !! type fractions in the grid meshes
48 !! User can still include its own data, and
49 !! even additional (dummy) fields
50 !! Modificatio 06/00 patch approach, for vegetation related variable (Solmon/Masson)
51 ! averaging is performed on subclass(=patch) of nature
52 !! 08/03/01 add chemical emission treatment (D.Gazen)
53 !! Modification 15/10/01 allow namelists in different orders (I.Mallet)
54 !! Modification 07/11 new routine write_pgd_surf_atmn.F90 for writing PGD field (B.Decharme)
55 !! flag_update now in write_pgd_surf_atmn.F90 (B.Decharme)
56 !!
57 !!
58 !! ################################
59 !! 13/10/03 EXTERNALIZED VERSION (V. Masson)
60 !! ################################
61 !!
62 !----------------------------------------------------------------------------
63 !
64 !* 0. DECLARATION
65 ! -----------
66 !
67 USE modd_surfex_omp, ONLY : nwork, nwork2, xwork, xwork2, xwork3, &
68  nwork_full, nwork2_full, xwork_full, xwork2_full
69 !
75 USE modi_open_namelist
76 USE modi_close_namelist
77 !
78 USE modi_get_lonlat_n
79 !
80 USE modi_io_buff_clean
81 USE modi_pgd_orog_filter
82 USE modi_pgd_surf_atm
83 USE modi_pgd_grid_surf_atm
84 USE modi_split_grid
85 USE modi_write_header_fa
86 USE modi_write_header_mnh
87 USE modi_write_pgd_surf_atm_n
88 USE modi_init_output_nc_n
89 !
90 USE mode_pos_surf
91 !
94 !
95 USE modd_io_surf_fa, ONLY : lfanocompact
96 !
97 USE yomhook ,ONLY : lhook, dr_hook
98 USE parkind1 ,ONLY : jprb
99 !
100 USE modi_get_luout
101 !
103 !
104 IMPLICIT NONE
105 !
106 !* 0.2 Declaration of local variables
107 ! ------------------------------
108 !
109 INTEGER :: iluout
110 INTEGER :: ilunam
111 LOGICAL :: gfound
112 !
113  CHARACTER(LEN=28) :: yluout ='LISTING_PGD' ! name of the listing
114 !
115 INTEGER :: inw, jnw
116 INTEGER :: iret
117 REAL(KIND=JPRB) :: zhook_handle
118 !
119 !------------------------------------------------------------------------------
120 !
121 IF (lhook) CALL dr_hook('PGD',0,zhook_handle)
122 !
123  CALL surfex_alloc_list(1)
124  csoftware='PGD '
125  CALL goto_model(1)
126 !
127 !* 1. Set default names and parallelized I/O
128 ! --------------------------------------
129 !
130  CALL get_luout('ASCII ',iluout)
131  cluout_lfi = adjustl(adjustr(yluout)//'.txt')
132 OPEN(unit=iluout,file=adjustl(adjustr(yluout)//'.txt'),form='FORMATTED',action='WRITE')
133 !
134 ! 1.3 output file name read in namelist
135 ! ---------------------------------
136  CALL open_namelist('ASCII ',ilunam,cnamelist)
137  CALL posnam(ilunam,'NAM_IO_OFFLINE',gfound)
138 IF (gfound) READ (unit=ilunam,nml=nam_io_offline)
139  CALL posnam(ilunam,'NAM_WRITE_SURF_ATM',gfound)
140 IF (gfound) READ (unit=ilunam,nml=nam_write_surf_atm)
141  CALL close_namelist('ASCII ',ilunam)
142 !
143  cfileout = adjustl(adjustr(cpgdfile)//'.txt') ! output of PGD program
144  cfileout_fa = adjustl(adjustr(cpgdfile)//'.fa')
145  cfileout_lfi = cpgdfile
146  cfileout_nc = adjustl(adjustr(cpgdfile)//'.nc')
147 !
148 !* 2. Preparation of surface physiographic fields
149 ! -------------------------------------------
150 !
151  CALL pgd_grid_surf_atm(ysurf_cur%UG, ysurf_cur%U,&
152  csurf_filetype,' ',' ',.false.)
153 !
154  CALL split_grid(ysurf_cur%UG, ysurf_cur%U,&
155  'OFFLIN')
156 !
157  CALL pgd_surf_atm(ysurf_cur,&
158  csurf_filetype,' ',' ',.false.)
159 !
160  CALL pgd_orog_filter(ysurf_cur%U,&
161  csurf_filetype)
162 !
163 !* 3. writing of surface physiographic fields
164 ! ---------------------------------------
165 !
166 !* building of the header for the opening of the file in case of Arpege file
167 IF (csurf_filetype=='FA ') THEN
168  lfanocompact = .true.
169  CALL write_header_fa(ysurf_cur%UG, &
170  csurf_filetype,'PGD')
171 END IF
172 !
173 ldef = .true.
174 !
175 IF (csurf_filetype=="NC ") THEN
176  CALL init_output_nc_n(ysurf_cur%TM%BDD, ysurf_cur%CHE, ysurf_cur%CHN, ysurf_cur%CHU, &
177  ysurf_cur%SM%DTS, ysurf_cur%TM%DTT, ysurf_cur%DTZ, ysurf_cur%IM%I, &
178  ysurf_cur%UG, ysurf_cur%U, ysurf_cur%DGU)
179 ENDIF
180 !
181 inw = 1
182 IF (csurf_filetype=="NC ") inw = 2
183 !
184 DO jnw = 1,inw
185  !
186  IF (lwrite_coord) CALL get_lonlat_n(ysurf_cur, &
187  csurf_filetype)
188  !
189  !* writing of the fields
190  CALL io_buff_clean
191 
192  ! FLAG_UPDATE now in WRITE_PGD_SURF_ATM_n
193  CALL write_pgd_surf_atm_n(ysurf_cur, &
194  csurf_filetype)
195  !
196  ldef = .false.
197  CALL io_buff_clean
198  !
199 ENDDO
200 !
201 !* closes the file
202 IF (csurf_filetype=='FA ') THEN
203 #ifdef SFX_FA
204  CALL fairme(iret,nunit_fa,'UNKNOWN')
205 #endif
206 END IF
207 !
208 !* add informations in the file
209 IF (csurf_filetype=='LFI ' .AND. lmnh_compatible) CALL write_header_mnh
210 !
211 !* 3. Close parallelized I/O
212 ! ----------------------
213 !
214 WRITE(iluout,*) ' '
215 WRITE(iluout,*) ' ----------------------'
216 WRITE(iluout,*) ' | PGD ENDS CORRECTLY |'
217 WRITE(iluout,*) ' ----------------------'
218 !
219 WRITE(*,*) ' '
220 WRITE(*,*) ' ----------------------'
221 WRITE(*,*) ' | PGD ENDS CORRECTLY |'
222 WRITE(*,*) ' ----------------------'
223  !
224  CLOSE(iluout)
225  CALL surfex_deallo_list
226 !
227 IF (ASSOCIATED(nwork)) DEALLOCATE(nwork)
228 IF (ASSOCIATED(xwork)) DEALLOCATE(xwork)
229 IF (ASSOCIATED(nwork2)) DEALLOCATE(nwork2)
230 IF (ASSOCIATED(xwork2)) DEALLOCATE(xwork2)
231 IF (ASSOCIATED(xwork3)) DEALLOCATE(xwork3)
232 IF (ASSOCIATED(nwork_full)) DEALLOCATE(nwork_full)
233 IF (ASSOCIATED(xwork_full)) DEALLOCATE(xwork_full)
234 IF (ASSOCIATED(nwork2_full)) DEALLOCATE(nwork2_full)
235 IF (ASSOCIATED(xwork2_full)) DEALLOCATE(xwork2_full)
236 !
237 IF (lhook) CALL dr_hook('PGD',1,zhook_handle)
238 !
239 !-------------------------------------------------------------------------------
240 !
241 END PROGRAM pgd
subroutine init_output_nc_n(BDD, CHE, CHN, CHU, DTS, DTT, DTZ, I, UG, U, DGU)
subroutine write_header_mnh
subroutine pgd_grid_surf_atm(UG, U, HPROGRAM, HFILE, HFILETYPE, OGRID)
subroutine write_pgd_surf_atm_n(YSC, HPROGRAM)
subroutine get_lonlat_n(YSC, HPROGRAM)
Definition: get_lonlatn.F90:6
subroutine write_header_fa(UG, CFILETYPE, HWRITE)
subroutine io_buff_clean
program pgd
Definition: pgd.F90:6
subroutine pgd_surf_atm(YSC, HPROGRAM, HFILE, HFILETYPE, OZS)
Definition: pgd_surf_atm.F90:6
subroutine pgd_orog_filter(U, HPROGRAM)
subroutine surfex_deallo_list
subroutine close_namelist(HPROGRAM, KLUNAM)
subroutine goto_model(KMODEL)
subroutine split_grid(UG, U, HPROGRAM)
Definition: split_grid.F90:6
subroutine posnam(KULNAM, HDNAML, OFOUND, KLUOUT)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:6
subroutine surfex_alloc_list(KMODEL)
subroutine open_namelist(HPROGRAM, KLUNAM, HFILE)