SURFEX v8.1
General documentation of Surfex
prep_hor_seaflux_field.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 prep_hor_seaflux_field (DTCO, UG, U, GCP, DTS, O, OR, KLAT, S, &
7  HPROGRAM,HSURF,HATMFILE,HATMFILETYPE,HPGDFILE,HPGDFILETYPE,YDCTL)
8 ! #################################################################################
9 !
10 !!**** *PREP_HOR_SEAFLUX_FIELD* - reads, interpolates and prepares a sea field
11 !!
12 !! PURPOSE
13 !! -------
14 !
15 !!** METHOD
16 !! ------
17 !!
18 !! REFERENCE
19 !! ---------
20 !!
21 !!
22 !! AUTHOR
23 !! ------
24 !! S. Malardel
25 !!
26 !! MODIFICATIONS
27 !! -------------
28 !! Original 01/2004
29 !! P. Le Moigne 10/2005, Phasage Arome
30 !! P. Le Moigne 09/2007, sst from clim
31 !! S. Senesi 09/2013, extends to fields of SSS and SIC
32 !! P. Marguinaud10/2014, Support for a 2-part PREP
33 !!------------------------------------------------------------------
34 !
37 USE modd_surf_atm_n, ONLY : surf_atm_t
39 !
41 USE modd_ocean_n, ONLY : ocean_t
42 USE modd_ocean_rel_n, ONLY : ocean_rel_t
43 USE modd_seaflux_n, ONLY : seaflux_t
44 !
46 USE modd_surfex_mpi, ONLY : nrank, npio, ncomm, nproc
48 !
49 USE modd_grid_grib, ONLY : cinmodel
50 !
52 !
53 USE modi_prep_grib_grid
54 USE modi_read_prep_seaflux_conf
55 USE modi_prep_seaflux_grib
56 USE modi_prep_seaflux_unif
57 USE modi_prep_seaflux_buffer
58 USE modi_prep_seaflux_netcdf
59 USE modi_hor_interpol
60 USE modi_get_luout
61 USE modi_prep_seaflux_extern
62 USE modi_prep_sst_init
63 !
64 USE modi_prep_hor_ocean_fields
65 !
66 USE yomhook ,ONLY : lhook, dr_hook
67 USE parkind1 ,ONLY : jprb
68 !
69 USE modi_abor1_sfx
70 !
71 IMPLICIT NONE
72 !
73 #ifdef SFX_MPI
74 include "mpif.h"
75 #endif
76 !
77 !* 0.1 declarations of arguments
78 !
79 TYPE(data_cover_t), INTENT(INOUT) :: DTCO
80 TYPE(surf_atm_grid_t), INTENT(INOUT) :: UG
81 TYPE(surf_atm_t), INTENT(INOUT) :: U
82 TYPE(grid_conf_proj_t),INTENT(INOUT) :: GCP
83 !
84 TYPE(data_seaflux_t), INTENT(INOUT) :: DTS
85 TYPE(ocean_t), INTENT(INOUT) :: O
86 TYPE(ocean_rel_t), INTENT(INOUT) :: OR
87 INTEGER, INTENT(IN) :: KLAT
88 TYPE(seaflux_t), INTENT(INOUT) :: S
89 type(prep_ctl), INTENT(INOUT) :: ydctl
90 !
91  CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM ! program calling surf. schemes
92  CHARACTER(LEN=7), INTENT(IN) :: HSURF ! type of field
93  CHARACTER(LEN=28), INTENT(IN) :: HATMFILE ! name of the Atmospheric file
94  CHARACTER(LEN=6), INTENT(IN) :: HATMFILETYPE! type of the Atmospheric file
95  CHARACTER(LEN=28), INTENT(IN) :: HPGDFILE ! name of the Atmospheric file
96  CHARACTER(LEN=6), INTENT(IN) :: HPGDFILETYPE! type of the Atmospheric file
97 !
98 !* 0.2 declarations of local variables
99 !
100  CHARACTER(LEN=6) :: YFILETYPE ! type of input file
101  CHARACTER(LEN=28) :: YFILE ! name of file
102  CHARACTER(LEN=6) :: YFILEPGDTYPE ! type of input file
103  CHARACTER(LEN=28) :: YFILEPGD ! name of file
104 REAL, POINTER, DIMENSION(:,:) :: ZFIELDIN ! field to interpolate horizontally
105 REAL, POINTER, DIMENSION(:,:) :: ZFIELDOUT ! field interpolated horizontally
106 type(date_time) :: tztime_grib ! current date and time
107 INTEGER :: ILUOUT ! output listing logical unit
108 INTEGER :: INFOMPI, INL
109 !
110 LOGICAL :: GUNIF ! flag for prescribed uniform field
111  CHARACTER (LEN=28) :: CLFILE
112 INTEGER :: IRESP
113  CHARACTER (LEN=100) :: CLCOMMENT
114  CHARACTER (LEN=6) :: CLSCHEME
115 REAL(KIND=JPRB) :: ZHOOK_HANDLE
116 !-------------------------------------------------------------------------------------
117 !
118 !
119 !* 1. Reading of input file name and type
120 !
121 IF (lhook) CALL dr_hook('PREP_HOR_SEAFLUX_FIELD',0,zhook_handle)
122  CALL get_luout(hprogram,iluout)
123 !
124  CALL read_prep_seaflux_conf(o%LMERCATOR, &
125  hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,&
126  hatmfile,hatmfiletype,hpgdfile,hpgdfiletype,iluout,gunif)
127 !
128  cmask = 'SEA'
129 !
130 NULLIFY (zfieldin, zfieldout)
131 !
132 IF (ydctl%LPART1) THEN
133 !
134 !--------------------------------------------------------------------- ----------------
135 !
136 !* 2. Reading of input configuration (Grid and interpolation type)
137 !
138  IF (gunif) THEN
139  CALL prep_seaflux_unif(iluout,hsurf,zfieldin)
140  ELSE IF (yfiletype=='GRIB ') THEN
141  CALL prep_grib_grid(yfile,iluout,cinmodel,cingrid_type,cinterp_type,tztime_grib)
142  IF (nrank==npio) CALL prep_seaflux_grib(hprogram,hsurf,yfile,iluout,zfieldin)
143  ELSE IF (yfiletype=='MESONH' .OR. yfiletype=='ASCII ' .OR. yfiletype=='LFI '&
144  .OR. yfiletype=='FA '.OR. yfiletype=='AROME '.OR.yfiletype=='NC ') THEN
145  CALL prep_seaflux_extern(gcp,hprogram,hsurf,yfile,yfiletype,yfilepgd,yfilepgdtype,iluout,zfieldin)
146  ELSE IF (yfiletype=='BUFFER') THEN
147  CALL prep_seaflux_buffer(hprogram,hsurf,iluout,zfieldin)
148  ELSE IF (yfiletype=='NETCDF') THEN
149  CALL prep_seaflux_netcdf(hprogram,hsurf,yfile,iluout,zfieldin)
150  ELSE
151  CALL abor1_sfx('PREP_HOR_SEAFLUX_FIELD: data file type not supported : '//yfiletype)
152  END IF
153 !
154 ENDIF
155 !
156 !
157 !* 4. Horizontal interpolation
158 !
159  CALL prep_ctl_int_part2 (ydctl, hsurf, 'SEA', cmask, zfieldin)
160 !
161 IF (ydctl%LPART3) THEN
162 !
163  IF (nrank==npio) THEN
164  inl = SIZE(zfieldin,2)
165  ELSEIF (.NOT.ASSOCIATED(zfieldin)) THEN
166  ALLOCATE(zfieldin(0,0))
167  ENDIF
168 !
169  IF (nproc>1) THEN
170 #ifdef SFX_MPI
171  CALL mpi_bcast(inl,kind(inl)/4,mpi_integer,npio,ncomm,infompi)
172 #endif
173  ENDIF
174  ALLOCATE(zfieldout(klat,inl))
175 !
176  CALL hor_interpol(dtco, u, gcp, iluout,zfieldin,zfieldout)
177 !
178 ENDIF
179 !
180  CALL prep_ctl_int_part4 (ydctl, hsurf, 'SEA', cmask, zfieldin, zfieldout)
181 !
182 IF (ydctl%LPART5) THEN
183 !
184 !* 5. Return to historical variable
185 !
186  SELECT CASE (hsurf)
187  CASE('ZS ')
188  ALLOCATE(xzs_ls(SIZE(zfieldout,1)))
189  xzs_ls(:) = zfieldout(:,1)
190  CASE('SST ')
191  ALLOCATE(s%XSST(SIZE(zfieldout,1)))
192  s%XSST(:) = zfieldout(:,1)
193  IF (dts%LSST_DATA) THEN
194  ! XSST is derived from array XDATA_SST from MODD_DATA_SEAFLUX, with time interpolation
195  CALL prep_sst_init(dts, s%TTIME, s%JSX, s%XSST)
196  END IF
197  IF (o%LMERCATOR) THEN
198  ! Preparing input for ocean 1D model
199  CALL prep_hor_ocean_fields(dtco, ug, u, gcp, o, or, klat, s%XSEABATHY, &
200  hprogram,hsurf,yfile,yfiletype,iluout,gunif)
201  ENDIF
202  CASE('SSS ')
203  ALLOCATE(s%XSSS(SIZE(zfieldout,1)))
204  s%XSSS(:) = zfieldout(:,1)
205  CASE('SIC ')
206  ALLOCATE(s%XSIC(SIZE(zfieldout,1)))
207  s%XSIC(:) = zfieldout(:,1)
208  END SELECT
209 !
210 ENDIF
211 !
212 !-------------------------------------------------------------------------------------
213 !
214 !* 6. Deallocations
215 !
216 IF (ASSOCIATED (zfieldin)) DEALLOCATE(zfieldin )
217 IF (ASSOCIATED (zfieldout)) DEALLOCATE(zfieldout)
218 IF (lhook) CALL dr_hook('PREP_HOR_SEAFLUX_FIELD',1,zhook_handle)
219 !
220 !-------------------------------------------------------------------------------------
221 !
222 END SUBROUTINE prep_hor_seaflux_field
subroutine prep_grib_grid(HGRIB, KLUOUT, HINMODEL, HGRIDTYPE, HINTERP_
character(len=10) cingrid_type
Definition: modd_prep.F90:39
subroutine prep_hor_seaflux_field(DTCO, UG, U, GCP, DTS, O, OR, KLAT, S, HPROGRAM, HSURF, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, YDCTL)
real, dimension(:), allocatable xzs_ls
Definition: modd_prep.F90:45
character(len=6) cmask
Definition: modd_prep.F90:41
character(len=6) cinterp_type
Definition: modd_prep.F90:40
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
character(len=6) cinmodel
subroutine hor_interpol(DTCO, U, GCP, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:7
integer, parameter jprb
Definition: parkind1.F90:32
subroutine prep_seaflux_buffer(HPROGRAM, HSURF, KLUOUT, PFIELD)
subroutine read_prep_seaflux_conf(OMERCATOR, HPROGRAM, HVAR, HFILE,
subroutine prep_seaflux_unif(KLUOUT, HSURF, PFIELD)
subroutine get_luout(HPROGRAM, KLUOUT)
Definition: get_luout.F90:7
logical lhook
Definition: yomhook.F90:15
subroutine prep_seaflux_extern(GCP, HPROGRAM, HSURF, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, KLUOUT, PFIELD)
subroutine prep_hor_ocean_fields(DTCO, UG, U, GCP, O, OR, KLAT, PSEABATHY, HPROGRAM, HSURF, HFILE, HFILETYPE, KLUOUT, OUNIF)
subroutine prep_seaflux_grib(HPROGRAM, HSURF, HFILE, KLUOUT, PFIELD)
subroutine prep_sst_init(DTS, TPTIME, KSX, PSST)
subroutine prep_seaflux_netcdf(HPROGRAM, HSURF, HFILE, KLUOUT, PFIELD)