1 | MODULE dtatsd |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE dtatsd *** |
---|
4 | !! Ocean data : read ocean Temperature & Salinity Data from gridded data |
---|
5 | !!====================================================================== |
---|
6 | !! History : OPA ! 1991-03 () Original code |
---|
7 | !! - ! 1992-07 (M. Imbard) |
---|
8 | !! 8.0 ! 1999-10 (M.A. Foujols, M. Imbard) NetCDF FORMAT |
---|
9 | !! NEMO 1.0 ! 2002-06 (G. Madec) F90: Free form and module |
---|
10 | !! 3.3 ! 2010-10 (C. Bricaud, S. Masson) use of fldread |
---|
11 | !! 3.4 ! 2010-11 (G. Madec, C. Ethe) Merge of dtatem and dtasal + suppression of CPP keys |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | |
---|
14 | !!---------------------------------------------------------------------- |
---|
15 | !! dta_tsd : read and time interpolated ocean Temperature & Salinity Data |
---|
16 | !!---------------------------------------------------------------------- |
---|
17 | USE oce ! ocean dynamics and tracers |
---|
18 | USE dom_oce ! ocean space and time domain |
---|
19 | USE fldread ! read input fields |
---|
20 | USE in_out_manager ! I/O manager |
---|
21 | USE phycst ! physical constants |
---|
22 | USE lib_mpp ! MPP library |
---|
23 | USE wrk_nemo ! Memory allocation |
---|
24 | USE timing ! Timing |
---|
25 | |
---|
26 | IMPLICIT NONE |
---|
27 | PRIVATE |
---|
28 | |
---|
29 | PUBLIC dta_tsd_init ! called by opa.F90 |
---|
30 | PUBLIC dta_tsd ! called by istate.F90 and tradmp.90 |
---|
31 | |
---|
32 | LOGICAL , PUBLIC :: ln_tsd_init !: T & S data flag |
---|
33 | LOGICAL , PUBLIC :: ln_tsd_tradmp !: internal damping toward input data flag |
---|
34 | |
---|
35 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tsd ! structure of input SST (file informations, fields read) |
---|
36 | |
---|
37 | !!---------------------------------------------------------------------- |
---|
38 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
39 | !! $Id$ |
---|
40 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
41 | !!---------------------------------------------------------------------- |
---|
42 | CONTAINS |
---|
43 | |
---|
44 | SUBROUTINE dta_tsd_init( ld_tradmp ) |
---|
45 | !!---------------------------------------------------------------------- |
---|
46 | !! *** ROUTINE dta_tsd_init *** |
---|
47 | !! |
---|
48 | !! ** Purpose : initialisation of T & S input data |
---|
49 | !! |
---|
50 | !! ** Method : - Read namtsd namelist |
---|
51 | !! - allocates T & S data structure |
---|
52 | !!---------------------------------------------------------------------- |
---|
53 | LOGICAL, INTENT(in), OPTIONAL :: ld_tradmp ! force the initialization when tradp is used |
---|
54 | ! |
---|
55 | INTEGER :: ios, ierr0, ierr1, ierr2, ierr3 ! local integers |
---|
56 | !! |
---|
57 | CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files |
---|
58 | TYPE(FLD_N), DIMENSION( jpts) :: slf_i ! array of namelist informations on the fields to read |
---|
59 | TYPE(FLD_N) :: sn_tem, sn_sal |
---|
60 | !! |
---|
61 | NAMELIST/namtsd/ ln_tsd_init, ln_tsd_tradmp, cn_dir, sn_tem, sn_sal |
---|
62 | !!---------------------------------------------------------------------- |
---|
63 | ! |
---|
64 | IF( nn_timing == 1 ) CALL timing_start('dta_tsd_init') |
---|
65 | ! |
---|
66 | ! Initialisation |
---|
67 | ierr0 = 0 ; ierr1 = 0 ; ierr2 = 0 ; ierr3 = 0 |
---|
68 | ! |
---|
69 | REWIND( numnam_ref ) ! Namelist namtsd in reference namelist : |
---|
70 | READ ( numnam_ref, namtsd, IOSTAT = ios, ERR = 901) |
---|
71 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in reference namelist', lwp ) |
---|
72 | |
---|
73 | REWIND( numnam_cfg ) ! Namelist namtsd in configuration namelist : Parameters of the run |
---|
74 | READ ( numnam_cfg, namtsd, IOSTAT = ios, ERR = 902 ) |
---|
75 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in configuration namelist', lwp ) |
---|
76 | IF(lwm) WRITE ( numond, namtsd ) |
---|
77 | |
---|
78 | IF( PRESENT( ld_tradmp ) ) ln_tsd_tradmp = .TRUE. ! forces the initialization when tradmp is used |
---|
79 | |
---|
80 | IF(lwp) THEN ! control print |
---|
81 | WRITE(numout,*) |
---|
82 | WRITE(numout,*) 'dta_tsd_init : Temperature & Salinity data ' |
---|
83 | WRITE(numout,*) '~~~~~~~~~~~~ ' |
---|
84 | WRITE(numout,*) ' Namelist namtsd' |
---|
85 | WRITE(numout,*) ' Initialisation of ocean T & S with T &S input data ln_tsd_init = ', ln_tsd_init |
---|
86 | WRITE(numout,*) ' damping of ocean T & S toward T &S input data ln_tsd_tradmp = ', ln_tsd_tradmp |
---|
87 | WRITE(numout,*) |
---|
88 | IF( .NOT.ln_tsd_init .AND. .NOT.ln_tsd_tradmp ) THEN |
---|
89 | WRITE(numout,*) |
---|
90 | WRITE(numout,*) ' T & S data not used' |
---|
91 | ENDIF |
---|
92 | ENDIF |
---|
93 | ! |
---|
94 | IF( ln_rstart .AND. ln_tsd_init ) THEN |
---|
95 | CALL ctl_warn( 'dta_tsd_init: ocean restart and T & S data intialisation, ', & |
---|
96 | & 'we keep the restart T & S values and set ln_tsd_init to FALSE' ) |
---|
97 | ln_tsd_init = .FALSE. |
---|
98 | ENDIF |
---|
99 | ! |
---|
100 | ! ! allocate the arrays (if necessary) |
---|
101 | IF( ln_tsd_init .OR. ln_tsd_tradmp ) THEN |
---|
102 | ! |
---|
103 | ALLOCATE( sf_tsd(jpts), STAT=ierr0 ) |
---|
104 | IF( ierr0 > 0 ) THEN |
---|
105 | CALL ctl_stop( 'dta_tsd_init: unable to allocate sf_tsd structure' ) ; RETURN |
---|
106 | ENDIF |
---|
107 | ! |
---|
108 | ALLOCATE( sf_tsd(jp_tem)%fnow(jpi,jpj,jpk) , STAT=ierr0 ) |
---|
109 | IF( sn_tem%ln_tint ) ALLOCATE( sf_tsd(jp_tem)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 ) |
---|
110 | ALLOCATE( sf_tsd(jp_sal)%fnow(jpi,jpj,jpk) , STAT=ierr2 ) |
---|
111 | IF( sn_sal%ln_tint ) ALLOCATE( sf_tsd(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 ) |
---|
112 | ! |
---|
113 | IF( ierr0 + ierr1 + ierr2 + ierr3 > 0 ) THEN |
---|
114 | CALL ctl_stop( 'dta_tsd : unable to allocate T & S data arrays' ) ; RETURN |
---|
115 | ENDIF |
---|
116 | ! ! fill sf_tsd with sn_tem & sn_sal and control print |
---|
117 | slf_i(jp_tem) = sn_tem ; slf_i(jp_sal) = sn_sal |
---|
118 | CALL fld_fill( sf_tsd, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity data', 'namtsd', no_print ) |
---|
119 | ! |
---|
120 | ENDIF |
---|
121 | ! |
---|
122 | IF( nn_timing == 1 ) CALL timing_stop('dta_tsd_init') |
---|
123 | ! |
---|
124 | END SUBROUTINE dta_tsd_init |
---|
125 | |
---|
126 | |
---|
127 | SUBROUTINE dta_tsd( kt, ptsd ) |
---|
128 | !!---------------------------------------------------------------------- |
---|
129 | !! *** ROUTINE dta_tsd *** |
---|
130 | !! |
---|
131 | !! ** Purpose : provides T and S data at kt |
---|
132 | !! |
---|
133 | !! ** Method : - call fldread routine |
---|
134 | !! - ORCA_R2: add some hand made alteration to read data |
---|
135 | !! - 'key_orca_lev10' interpolates on 10 times more levels |
---|
136 | !! - s- or mixed z-s coordinate: vertical interpolation on model mesh |
---|
137 | !! - ln_tsd_tradmp=F: deallocates the T-S data structure |
---|
138 | !! as T-S data are no are used |
---|
139 | !! |
---|
140 | !! ** Action : ptsd T-S data on medl mesh and interpolated at time-step kt |
---|
141 | !!---------------------------------------------------------------------- |
---|
142 | INTEGER , INTENT(in ) :: kt ! ocean time-step |
---|
143 | REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT( out) :: ptsd ! T & S data |
---|
144 | ! |
---|
145 | INTEGER :: ji, jj, jk, jl, jkk ! dummy loop indicies |
---|
146 | INTEGER :: ik, il0, il1, ii0, ii1, ij0, ij1 ! local integers |
---|
147 | REAL(wp):: zl, zi |
---|
148 | REAL(wp), POINTER, DIMENSION(:) :: ztp, zsp ! 1D workspace |
---|
149 | !!---------------------------------------------------------------------- |
---|
150 | ! |
---|
151 | IF( nn_timing == 1 ) CALL timing_start('dta_tsd') |
---|
152 | ! |
---|
153 | CALL fld_read( kt, 1, sf_tsd ) !== read T & S data at kt time step ==! |
---|
154 | ! |
---|
155 | ! |
---|
156 | !!gm This should be removed from the code ===>>>> T & S files has to be changed |
---|
157 | ! |
---|
158 | ! !== ORCA_R2 configuration and T & S damping ==! |
---|
159 | IF( cn_cfg == "orca" .AND. nn_cfg == 2 .AND. ln_tsd_tradmp ) THEN ! some hand made alterations |
---|
160 | ! |
---|
161 | ij0 = 101 ; ij1 = 109 ! Reduced T & S in the Alboran Sea |
---|
162 | ii0 = 141 ; ii1 = 155 |
---|
163 | DO jj = mj0(ij0), mj1(ij1) |
---|
164 | DO ji = mi0(ii0), mi1(ii1) |
---|
165 | sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp |
---|
166 | sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp |
---|
167 | sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp |
---|
168 | ! |
---|
169 | sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp |
---|
170 | sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp |
---|
171 | sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp |
---|
172 | sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp |
---|
173 | END DO |
---|
174 | END DO |
---|
175 | ij0 = 87 ; ij1 = 96 ! Reduced temperature in Red Sea |
---|
176 | ii0 = 148 ; ii1 = 160 |
---|
177 | sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 4:10 ) = 7.0_wp |
---|
178 | sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp |
---|
179 | sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp |
---|
180 | ENDIF |
---|
181 | !!gm end |
---|
182 | ! |
---|
183 | ptsd(:,:,:,jp_tem) = sf_tsd(jp_tem)%fnow(:,:,:) ! NO mask |
---|
184 | ptsd(:,:,:,jp_sal) = sf_tsd(jp_sal)%fnow(:,:,:) |
---|
185 | ! |
---|
186 | IF( ln_sco ) THEN !== s- or mixed s-zps-coordinate ==! |
---|
187 | ! |
---|
188 | CALL wrk_alloc( jpk, ztp, zsp ) |
---|
189 | ! |
---|
190 | IF( kt == nit000 .AND. lwp )THEN |
---|
191 | WRITE(numout,*) |
---|
192 | WRITE(numout,*) 'dta_tsd: interpolates T & S data onto the s- or mixed s-z-coordinate mesh' |
---|
193 | ENDIF |
---|
194 | ! |
---|
195 | DO jj = 1, jpj ! vertical interpolation of T & S |
---|
196 | DO ji = 1, jpi |
---|
197 | DO jk = 1, jpk ! determines the intepolated T-S profiles at each (i,j) points |
---|
198 | zl = gdept_0(ji,jj,jk) |
---|
199 | IF( zl < gdept_1d(1 ) ) THEN ! above the first level of data |
---|
200 | ztp(jk) = ptsd(ji,jj,1 ,jp_tem) |
---|
201 | zsp(jk) = ptsd(ji,jj,1 ,jp_sal) |
---|
202 | ELSEIF( zl > gdept_1d(jpk) ) THEN ! below the last level of data |
---|
203 | ztp(jk) = ptsd(ji,jj,jpkm1,jp_tem) |
---|
204 | zsp(jk) = ptsd(ji,jj,jpkm1,jp_sal) |
---|
205 | ELSE ! inbetween : vertical interpolation between jkk & jkk+1 |
---|
206 | DO jkk = 1, jpkm1 ! when gdept(jkk) < zl < gdept(jkk+1) |
---|
207 | IF( (zl-gdept_1d(jkk)) * (zl-gdept_1d(jkk+1)) <= 0._wp ) THEN |
---|
208 | zi = ( zl - gdept_1d(jkk) ) / (gdept_1d(jkk+1)-gdept_1d(jkk)) |
---|
209 | ztp(jk) = ptsd(ji,jj,jkk,jp_tem) + ( ptsd(ji,jj,jkk+1,jp_tem) - ptsd(ji,jj,jkk,jp_tem) ) * zi |
---|
210 | zsp(jk) = ptsd(ji,jj,jkk,jp_sal) + ( ptsd(ji,jj,jkk+1,jp_sal) - ptsd(ji,jj,jkk,jp_sal) ) * zi |
---|
211 | ENDIF |
---|
212 | END DO |
---|
213 | ENDIF |
---|
214 | END DO |
---|
215 | DO jk = 1, jpkm1 |
---|
216 | ptsd(ji,jj,jk,jp_tem) = ztp(jk) * tmask(ji,jj,jk) ! mask required for mixed zps-s-coord |
---|
217 | ptsd(ji,jj,jk,jp_sal) = zsp(jk) * tmask(ji,jj,jk) |
---|
218 | END DO |
---|
219 | ptsd(ji,jj,jpk,jp_tem) = 0._wp |
---|
220 | ptsd(ji,jj,jpk,jp_sal) = 0._wp |
---|
221 | END DO |
---|
222 | END DO |
---|
223 | ! |
---|
224 | CALL wrk_dealloc( jpk, ztp, zsp ) |
---|
225 | ! |
---|
226 | ELSE !== z- or zps- coordinate ==! |
---|
227 | ! |
---|
228 | ptsd(:,:,:,jp_tem) = ptsd(:,:,:,jp_tem) * tmask(:,:,:) ! Mask |
---|
229 | ptsd(:,:,:,jp_sal) = ptsd(:,:,:,jp_sal) * tmask(:,:,:) |
---|
230 | ! |
---|
231 | IF( ln_zps ) THEN ! zps-coordinate (partial steps) interpolation at the last ocean level |
---|
232 | DO jj = 1, jpj |
---|
233 | DO ji = 1, jpi |
---|
234 | ik = mbkt(ji,jj) |
---|
235 | IF( ik > 1 ) THEN |
---|
236 | zl = ( gdept_1d(ik) - gdept_0(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) ) |
---|
237 | ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik-1,jp_tem) |
---|
238 | ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik-1,jp_sal) |
---|
239 | ENDIF |
---|
240 | ik = mikt(ji,jj) |
---|
241 | IF( ik > 1 ) THEN |
---|
242 | zl = ( gdept_0(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) ) |
---|
243 | ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik+1,jp_tem) |
---|
244 | ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik+1,jp_sal) |
---|
245 | END IF |
---|
246 | END DO |
---|
247 | END DO |
---|
248 | ENDIF |
---|
249 | ! |
---|
250 | ENDIF |
---|
251 | ! |
---|
252 | IF( .NOT.ln_tsd_tradmp ) THEN !== deallocate T & S structure ==! |
---|
253 | ! (data used only for initialisation) |
---|
254 | IF(lwp) WRITE(numout,*) 'dta_tsd: deallocte T & S arrays as they are only use to initialize the run' |
---|
255 | DEALLOCATE( sf_tsd(jp_tem)%fnow ) ! T arrays in the structure |
---|
256 | IF( sf_tsd(jp_tem)%ln_tint ) DEALLOCATE( sf_tsd(jp_tem)%fdta ) |
---|
257 | DEALLOCATE( sf_tsd(jp_sal)%fnow ) ! S arrays in the structure |
---|
258 | IF( sf_tsd(jp_sal)%ln_tint ) DEALLOCATE( sf_tsd(jp_sal)%fdta ) |
---|
259 | DEALLOCATE( sf_tsd ) ! the structure itself |
---|
260 | ENDIF |
---|
261 | ! |
---|
262 | IF( nn_timing == 1 ) CALL timing_stop('dta_tsd') |
---|
263 | ! |
---|
264 | END SUBROUTINE dta_tsd |
---|
265 | |
---|
266 | !!====================================================================== |
---|
267 | END MODULE dtatsd |
---|