SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
prep_hor_ocean_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_ocean_field (DTCO, UG, U, &
7  o, or, sg, &
8  hprogram, &
9  hfile,hfiletype,kluout,ounif, &
10  hsurf,hncvarname )
11 ! #######################################################
12 !
13 !!**** *PREP_HOR_OCEAN_FIELD* -reads, interpolates and prepares oceanic fields
14 !!
15 !! PURPOSE
16 !! -------
17 !!
18 !!** METHOD
19 !! ------
20 !!
21 !! REFERENCE
22 !! ---------
23 !!
24 !!
25 !! AUTHOR
26 !! ------
27 !! C. Lebeaupin Brossier
28 !!
29 !! MODIFICATIONS
30 !! -------------
31 !! Original 01/2008
32 !! Modified 07/2012, P. Le Moigne : CMO1D phasing
33 !!------------------------------------------------------------------
34 !
35 !
36 !
37 !
40 USE modd_surf_atm_n, ONLY : surf_atm_t
41 !
42 USE modd_ocean_n, ONLY : ocean_t
43 USE modd_ocean_rel_n, ONLY : ocean_rel_t
45 !
46 USE modd_csts, ONLY : xtt
47 USE modd_surf_par, ONLY : xundef
48 USE modd_ocean_grid, ONLY : nockmin,nockmax
49 USE modd_prep, ONLY : cingrid_type, cinterp_type, xlat_out, xlon_out,&
50  xx_out, xy_out
51 !
52 USE modi_prep_ocean_unif
53 USE modi_prep_ocean_netcdf
54 USE modi_prep_ocean_ascllv
55 !
56 USE modi_hor_interpol
57 !
58 USE yomhook ,ONLY : lhook, dr_hook
59 USE parkind1 ,ONLY : jprb
60 !
61 USE modi_abor1_sfx
62 IMPLICIT NONE
63 !
64 !* 0.1 declarations of arguments
65 !
66 !
67 !
68 TYPE(data_cover_t), INTENT(INOUT) :: dtco
69 TYPE(surf_atm_grid_t), INTENT(INOUT) :: ug
70 TYPE(surf_atm_t), INTENT(INOUT) :: u
71 !
72 TYPE(ocean_t), INTENT(INOUT) :: o
73 TYPE(ocean_rel_t), INTENT(INOUT) :: or
74 TYPE(seaflux_grid_t), INTENT(INOUT) :: sg
75 !
76  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling surf. schemes
77  CHARACTER(LEN=28), INTENT(IN) :: hfile ! file name
78  CHARACTER(LEN=6), INTENT(IN) :: hfiletype ! file type
79 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
80 LOGICAL, INTENT(IN) :: ounif ! flag for prescribed uniform field
81  CHARACTER(LEN=7) :: hsurf ! type of field
82  CHARACTER(LEN=28), INTENT(IN), OPTIONAL :: hncvarname!var to read
83 !
84 !
85 !* 0.2 declarations of local variables
86 !
87 REAL, POINTER, DIMENSION(:,:,:) ::zfieldin!field to interpolate horizontally
88 REAL, POINTER, DIMENSION(:,:) ::zfield !field to interpolate horizontally
89 REAL, ALLOCATABLE, DIMENSION(:,:,:)::zfieldout!field interpolated horizontally
90 !
91 INTEGER :: jlev ! loop on oceanic vertical level
92 INTEGER :: ik1
93 REAL(KIND=JPRB) :: zhook_handle
94 !----------------------------------------------------------------------------
95 !* 1. Does the field exist?
96 !
97 !* 2. Reading of input configuration (Grid and interpolation type)
98 !
99 IF (lhook) CALL dr_hook('PREP_HOR_OCEAN_FIELD',0,zhook_handle)
100 !
101 IF (ounif) THEN
102  WRITE(kluout,*) '*****warning*****: you ask for uniform oceanic variables'
103  CALL prep_ocean_unif(kluout,hsurf,zfieldin)
104 ELSE IF (hfiletype=='NETCDF') THEN
105  CALL prep_ocean_netcdf(hprogram,hsurf,hfile,hfiletype,kluout,&
106  hncvarname,zfieldin)
107 ELSE IF (hfiletype=='ASCII') THEN
108  WRITE(kluout,*) 'PERSONAL LIB TEST FOR READING ',hfiletype,'file type'
109  WRITE(kluout,*) 'ASCII FILE MUST CONTAIN LAT,LON,DEPTH,T,S,U,V'
110  CALL prep_ocean_ascllv(dtco, ug, u, &
111  hprogram,hsurf,hfile,kluout,zfieldin)
112 ELSE
113  CALL abor1_sfx('PREP_OCEAN_HOR_FIELD: data file type not supported : '//hfiletype)
114 END IF
115 !
116 !-------------------------------------------------------------------------------
117 !
118 !* 3. Horizontal interpolation
119 !
120 ALLOCATE(zfieldout(SIZE(sg%XLAT),SIZE(zfieldin,2),SIZE(zfieldin,3)) )
121 ALLOCATE(zfield(SIZE(zfieldin,1),SIZE(zfieldin,3)))
122 !
123 DO jlev=1,SIZE(zfieldin,2)
124  zfield(:,:)=zfieldin(:,jlev,:)
125  CALL hor_interpol(dtco, u, &
126  kluout,zfield,zfieldout(:,jlev,:))
127 ENDDO
128 !
129 !* 5. Return to historical variable
130 !
131 ik1=nockmin+1
132 SELECT CASE (hsurf)
133  CASE('TEMP_OC')
134  ALLOCATE(o%XSEAT(SIZE(zfieldout,1),nockmin:nockmax))
135  ALLOCATE(or%XSEAT_REL(SIZE(zfieldout,1),nockmin:nockmax))
136  DO jlev=ik1,nockmax
137  o%XSEAT(:,jlev) = zfieldout(:,jlev,1)
138  !prevoir interpolation sur la grille verticale si niveau diffĂ©rents
139  ENDDO
140  o%XSEAT(:,nockmin)=o%XSEAT(:,ik1)
141  !
142  ! Relaxation Profile = initial profile for the steady regime
143  ! Change it for seasonal cycle!!
144  or%XSEAT_REL(:,:) = o%XSEAT(:,:)
145  !
146  CASE('SALT_OC')
147  ALLOCATE(o%XSEAS(SIZE(zfieldout,1),nockmin:nockmax))
148  ALLOCATE(or%XSEAS_REL(SIZE(zfieldout,1),nockmin:nockmax))
149  DO jlev=ik1,nockmax
150  o%XSEAS(:,jlev) = zfieldout(:,jlev,1)
151  ENDDO
152  o%XSEAS(:,nockmin)=o%XSEAS(:,ik1)
153  !
154  ! Relaxation Profile = initial profile for the steady regime
155  ! Change it for seasonal cycle!!
156  or%XSEAS_REL(:,:) = o%XSEAS(:,:)
157  !
158  CASE('UCUR_OC')
159  ALLOCATE(o%XSEAU(SIZE(zfieldout,1),nockmin:nockmax))
160  ALLOCATE(or%XSEAU_REL(SIZE(zfieldout,1),nockmin:nockmax))
161  DO jlev=ik1,nockmax
162  o%XSEAU(:,jlev) = zfieldout(:,jlev,1)
163  ENDDO
164  o%XSEAU(:,nockmin)=o%XSEAU(:,ik1)
165  !
166  IF (.NOT.o%LCURRENT) o%XSEAU(:,:)=0.
167  !
168  or%XSEAU_REL(:,:) = o%XSEAU(:,:)
169  !
170  CASE('VCUR_OC')
171  ALLOCATE(o%XSEAV(SIZE(zfieldout,1),nockmin:nockmax))
172  ALLOCATE(or%XSEAV_REL(SIZE(zfieldout,1),nockmin:nockmax))
173  DO jlev=ik1,nockmax
174  o%XSEAV(:,jlev) = zfieldout(:,jlev,1)
175  ENDDO
176  o%XSEAV(:,nockmin)=o%XSEAV(:,ik1)
177  !
178  IF (.NOT.o%LCURRENT) o%XSEAV(:,:)=0.
179  !
180  or%XSEAV_REL(:,:) = o%XSEAV(:,:)
181  !
182 END SELECT
183 !
184 !------------------------------------------------------------------------------
185 !
186 !* 6. Deallocations
187 !
188 DEALLOCATE(zfield )
189 DEALLOCATE(zfieldout)
190 IF (lhook) CALL dr_hook('PREP_HOR_OCEAN_FIELD',1,zhook_handle)
191 !
192 END SUBROUTINE prep_hor_ocean_field
subroutine prep_ocean_netcdf(HPROGRAM, HSURF, HFILE, HFILETYPE, KLUOUT, HNCVARNAME, PFIELD)
subroutine prep_ocean_unif(KLUOUT, HSURF, PFIELD)
subroutine prep_ocean_ascllv(DTCO, UG, U, HPROGRAM, HSURF, HFILE, KLUOUT, PFIELD)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine hor_interpol(DTCO, U, KLUOUT, PFIELDIN, PFIELDOUT)
Definition: hor_interpol.F90:6
subroutine prep_hor_ocean_field(DTCO, UG, U, O, OR, SG, HPROGRAM, HFILE, HFILETYPE, KLUOUT, OUNIF, HSURF, HNCVARNAME)