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 + remove 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 phycst ! physical constants |
---|
19 | USE dom_oce ! ocean space and time domain |
---|
20 | USE fldread ! read input fields |
---|
21 | ! |
---|
22 | USE in_out_manager ! I/O manager |
---|
23 | USE lib_mpp ! MPP library |
---|
24 | |
---|
25 | IMPLICIT NONE |
---|
26 | PRIVATE |
---|
27 | |
---|
28 | PUBLIC dta_tsd_init ! called by opa.F90 |
---|
29 | PUBLIC dta_tsd ! called by istate.F90 and tradmp.90 |
---|
30 | |
---|
31 | ! !!* namtsd namelist : Temperature & Salinity Data * |
---|
32 | LOGICAL , PUBLIC :: ln_tsd_init !: T & S data flag |
---|
33 | LOGICAL , PUBLIC :: ln_tsd_dmp !: internal damping toward input data flag |
---|
34 | |
---|
35 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tsdini ! structure of input SST (file informations, fields read) |
---|
36 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_tsddmp ! structure of input SST (file informations, fields read) |
---|
37 | |
---|
38 | !! * Substitutions |
---|
39 | # include "do_loop_substitute.h90" |
---|
40 | !!---------------------------------------------------------------------- |
---|
41 | !! NEMO/OCE 4.0 , NEMO Consortium (2018) |
---|
42 | !! $Id: dtatsd.F90 10213 2018-10-23 14:40:09Z aumont $ |
---|
43 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
44 | !!---------------------------------------------------------------------- |
---|
45 | CONTAINS |
---|
46 | |
---|
47 | SUBROUTINE dta_tsd_init( ld_tradmp ) |
---|
48 | !!---------------------------------------------------------------------- |
---|
49 | !! *** ROUTINE dta_tsd_init *** |
---|
50 | !! |
---|
51 | !! ** Purpose : initialisation of T & S input data |
---|
52 | !! |
---|
53 | !! ** Method : - Read namtsd namelist |
---|
54 | !! - allocates T & S data structure |
---|
55 | !!---------------------------------------------------------------------- |
---|
56 | LOGICAL, INTENT(in), OPTIONAL :: ld_tradmp ! force the initialization when tradp is used |
---|
57 | ! |
---|
58 | INTEGER :: ios, ierr0, ierr1, ierr2, ierr3 ! local integers |
---|
59 | !! |
---|
60 | CHARACTER(len=100) :: cn_dir ! Root directory for location of ssr files |
---|
61 | TYPE(FLD_N), DIMENSION( jpts) :: slf_i ! array of namelist informations on the fields to read |
---|
62 | TYPE(FLD_N) :: sn_tem, sn_sal |
---|
63 | TYPE(FLD_N) :: sn_dmpt, sn_dmps |
---|
64 | !! |
---|
65 | NAMELIST/namtsd/ ln_tsd_init, ln_tsd_dmp, cn_dir, sn_tem, sn_sal, sn_dmpt, sn_dmps |
---|
66 | !!---------------------------------------------------------------------- |
---|
67 | ! |
---|
68 | ! Initialisation |
---|
69 | ierr0 = 0 ; ierr1 = 0 ; ierr2 = 0 ; ierr3 = 0 |
---|
70 | ! |
---|
71 | READ ( numnam_ref, namtsd, IOSTAT = ios, ERR = 901) |
---|
72 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in reference namelist' ) |
---|
73 | READ ( numnam_cfg, namtsd, IOSTAT = ios, ERR = 902 ) |
---|
74 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namtsd in configuration namelist' ) |
---|
75 | IF(lwm) WRITE ( numond, namtsd ) |
---|
76 | |
---|
77 | IF( PRESENT( ld_tradmp ) ) ln_tsd_dmp = .TRUE. ! forces the initialization when tradmp is used |
---|
78 | |
---|
79 | IF(lwp) THEN ! control print |
---|
80 | WRITE(numout,*) |
---|
81 | WRITE(numout,*) 'dta_tsd_init : Temperature & Salinity data ' |
---|
82 | WRITE(numout,*) '~~~~~~~~~~~~ ' |
---|
83 | WRITE(numout,*) ' Namelist namtsd' |
---|
84 | WRITE(numout,*) ' Initialisation of ocean T & S with T &S input data ln_tsd_init = ', ln_tsd_init |
---|
85 | WRITE(numout,*) ' damping of ocean T & S toward T &S input data ln_tsd_dmp = ', ln_tsd_dmp |
---|
86 | WRITE(numout,*) |
---|
87 | IF( .NOT.ln_tsd_init .AND. .NOT.ln_tsd_dmp ) THEN |
---|
88 | WRITE(numout,*) |
---|
89 | WRITE(numout,*) ' ===>> T & S data not used' |
---|
90 | ENDIF |
---|
91 | ENDIF |
---|
92 | ! |
---|
93 | IF( ln_rstart .AND. ln_tsd_init ) THEN |
---|
94 | CALL ctl_warn( 'dta_tsd_init: ocean restart and T & S data intialisation, ', & |
---|
95 | & 'we keep the restart T & S values and set ln_tsd_init to FALSE' ) |
---|
96 | ln_tsd_init = .FALSE. |
---|
97 | ENDIF |
---|
98 | ! |
---|
99 | ! ! allocate the arrays (if necessary) |
---|
100 | IF( ln_tsd_init ) THEN |
---|
101 | ! |
---|
102 | ALLOCATE( sf_tsdini(jpts), STAT=ierr0 ) |
---|
103 | IF( ierr0 > 0 ) THEN |
---|
104 | CALL ctl_stop( 'dta_tsd_init: unable to allocate sf_tsd structure' ) ; RETURN |
---|
105 | ENDIF |
---|
106 | ! |
---|
107 | ALLOCATE( sf_tsdini(jp_tem)%fnow(jpi,jpj,jpk) , STAT=ierr0 ) |
---|
108 | IF( sn_tem%ln_tint ) ALLOCATE( sf_tsdini(jp_tem)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 ) |
---|
109 | ALLOCATE( sf_tsdini(jp_sal)%fnow(jpi,jpj,jpk) , STAT=ierr2 ) |
---|
110 | IF( sn_sal%ln_tint ) ALLOCATE( sf_tsdini(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 ) |
---|
111 | ! |
---|
112 | IF( ierr0 + ierr1 + ierr2 + ierr3 > 0 ) THEN |
---|
113 | CALL ctl_stop( 'dta_tsd : unable to allocate T & S data arrays' ) ; RETURN |
---|
114 | ENDIF |
---|
115 | ! |
---|
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_tsdini, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity data', 'namtsd', no_print ) |
---|
119 | ! |
---|
120 | END IF |
---|
121 | |
---|
122 | IF( ln_tsd_dmp ) THEN |
---|
123 | ! |
---|
124 | ALLOCATE( sf_tsddmp(jpts), STAT=ierr0 ) |
---|
125 | IF( ierr0 > 0 ) THEN |
---|
126 | CALL ctl_stop( 'dta_tsd_init: unable to allocate sf_tsddmp structure' ) ; RETURN |
---|
127 | ENDIF |
---|
128 | ! |
---|
129 | ! dmp file |
---|
130 | ALLOCATE( sf_tsddmp(jp_tem)%fnow(jpi,jpj,jpk) , STAT=ierr0 ) |
---|
131 | IF( sn_dmpt%ln_tint ) ALLOCATE( sf_tsddmp(jp_tem)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 ) |
---|
132 | ALLOCATE( sf_tsddmp(jp_sal)%fnow(jpi,jpj,jpk) , STAT=ierr2 ) |
---|
133 | IF( sn_dmps%ln_tint ) ALLOCATE( sf_tsddmp(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 ) |
---|
134 | ! |
---|
135 | IF( ierr0 + ierr1 + ierr2 + ierr3 > 0 ) THEN |
---|
136 | CALL ctl_stop( 'dta_tsd : unable to allocate T & S dmp data arrays' ) ; RETURN |
---|
137 | ENDIF |
---|
138 | ! |
---|
139 | ! ! fill sf_tsd with sn_tem & sn_sal and control print |
---|
140 | slf_i(jp_tem) = sn_dmpt ; slf_i(jp_sal) = sn_dmps |
---|
141 | CALL fld_fill( sf_tsddmp, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity dmp data', 'namtsd', no_print ) |
---|
142 | ! |
---|
143 | ENDIF |
---|
144 | ! |
---|
145 | END SUBROUTINE dta_tsd_init |
---|
146 | |
---|
147 | |
---|
148 | SUBROUTINE dta_tsd( kt, cddta, ptsd ) |
---|
149 | !!---------------------------------------------------------------------- |
---|
150 | !! *** ROUTINE dta_tsd *** |
---|
151 | !! |
---|
152 | !! ** Purpose : provides T and S data at kt |
---|
153 | !! |
---|
154 | !! ** Method : - call fldread routine |
---|
155 | !! - ORCA_R2: add some hand made alteration to read data |
---|
156 | !! - 'key_orca_lev10' interpolates on 10 times more levels |
---|
157 | !! - s- or mixed z-s coordinate: vertical interpolation on model mesh |
---|
158 | !! - ln_tsd_dmp=F: deallocates the T-S data structure |
---|
159 | !! as T-S data are no are used |
---|
160 | !! |
---|
161 | !! ** Action : ptsd T-S data on medl mesh and interpolated at time-step kt |
---|
162 | !!---------------------------------------------------------------------- |
---|
163 | INTEGER , INTENT(in ) :: kt ! ocean time-step |
---|
164 | CHARACTER(LEN=3) , INTENT(in ) :: cddta ! dmp or ini |
---|
165 | REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT( out) :: ptsd ! T & S data |
---|
166 | ! |
---|
167 | INTEGER :: ji, jj, jk, jl, jkk ! dummy loop indicies |
---|
168 | INTEGER :: ik, il0, il1, ii0, ii1, ij0, ij1 ! local integers |
---|
169 | REAL(wp):: zl, zi ! local scalars |
---|
170 | REAL(wp), DIMENSION(jpk) :: ztp, zsp ! 1D workspace |
---|
171 | !!---------------------------------------------------------------------- |
---|
172 | ! |
---|
173 | SELECT CASE(cddta) |
---|
174 | CASE('ini') |
---|
175 | CALL fld_read( kt, 1, sf_tsdini ) !== read T & S data at kt time step ==! |
---|
176 | ptsd(:,:,:,jp_tem) = sf_tsdini(jp_tem)%fnow(:,:,:) ! NO mask |
---|
177 | ptsd(:,:,:,jp_sal) = sf_tsdini(jp_sal)%fnow(:,:,:) |
---|
178 | CASE('dmp') |
---|
179 | CALL fld_read( kt, 1, sf_tsddmp ) !== read T & S data at kt time step ==! |
---|
180 | ptsd(:,:,:,jp_tem) = sf_tsddmp(jp_tem)%fnow(:,:,:) ! NO mask |
---|
181 | ptsd(:,:,:,jp_sal) = sf_tsddmp(jp_sal)%fnow(:,:,:) |
---|
182 | CASE DEFAULT |
---|
183 | CALL ctl_stop('STOP', 'dta_tsd: cddta case unknown') |
---|
184 | END SELECT |
---|
185 | ! |
---|
186 | IF( ln_sco ) THEN !== s- or mixed s-zps-coordinate ==! |
---|
187 | ! |
---|
188 | IF( kt == nit000 .AND. lwp )THEN |
---|
189 | WRITE(numout,*) |
---|
190 | WRITE(numout,*) 'dta_tsd: interpolates T & S data onto the s- or mixed s-z-coordinate mesh' |
---|
191 | ENDIF |
---|
192 | ! |
---|
193 | DO_2D_11_11 |
---|
194 | DO jk = 1, jpk ! determines the intepolated T-S profiles at each (i,j) points |
---|
195 | zl = gdept_0(ji,jj,jk) |
---|
196 | IF( zl < gdept_1d(1 ) ) THEN ! above the first level of data |
---|
197 | ztp(jk) = ptsd(ji,jj,1 ,jp_tem) |
---|
198 | zsp(jk) = ptsd(ji,jj,1 ,jp_sal) |
---|
199 | ELSEIF( zl > gdept_1d(jpk) ) THEN ! below the last level of data |
---|
200 | ztp(jk) = ptsd(ji,jj,jpkm1,jp_tem) |
---|
201 | zsp(jk) = ptsd(ji,jj,jpkm1,jp_sal) |
---|
202 | ELSE ! inbetween : vertical interpolation between jkk & jkk+1 |
---|
203 | DO jkk = 1, jpkm1 ! when gdept(jkk) < zl < gdept(jkk+1) |
---|
204 | IF( (zl-gdept_1d(jkk)) * (zl-gdept_1d(jkk+1)) <= 0._wp ) THEN |
---|
205 | zi = ( zl - gdept_1d(jkk) ) / (gdept_1d(jkk+1)-gdept_1d(jkk)) |
---|
206 | ztp(jk) = ptsd(ji,jj,jkk,jp_tem) + ( ptsd(ji,jj,jkk+1,jp_tem) - ptsd(ji,jj,jkk,jp_tem) ) * zi |
---|
207 | zsp(jk) = ptsd(ji,jj,jkk,jp_sal) + ( ptsd(ji,jj,jkk+1,jp_sal) - ptsd(ji,jj,jkk,jp_sal) ) * zi |
---|
208 | ENDIF |
---|
209 | END DO |
---|
210 | ENDIF |
---|
211 | END DO |
---|
212 | DO jk = 1, jpkm1 |
---|
213 | ptsd(ji,jj,jk,jp_tem) = ztp(jk) * tmask(ji,jj,jk) ! mask required for mixed zps-s-coord |
---|
214 | ptsd(ji,jj,jk,jp_sal) = zsp(jk) * tmask(ji,jj,jk) |
---|
215 | END DO |
---|
216 | ptsd(ji,jj,jpk,jp_tem) = 0._wp |
---|
217 | ptsd(ji,jj,jpk,jp_sal) = 0._wp |
---|
218 | END_2D |
---|
219 | ! |
---|
220 | ELSE !== z- or zps- coordinate ==! |
---|
221 | ! |
---|
222 | ptsd(:,:,:,jp_tem) = ptsd(:,:,:,jp_tem) * tmask(:,:,:) ! Mask |
---|
223 | ptsd(:,:,:,jp_sal) = ptsd(:,:,:,jp_sal) * tmask(:,:,:) |
---|
224 | ! |
---|
225 | IF( ln_zps ) THEN ! zps-coordinate (partial steps) interpolation at the last ocean level |
---|
226 | DO_2D_11_11 |
---|
227 | ik = mbkt(ji,jj) |
---|
228 | IF( ik > 1 ) THEN |
---|
229 | zl = ( gdept_1d(ik) - gdept_0(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) ) |
---|
230 | ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik-1,jp_tem) |
---|
231 | ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik-1,jp_sal) |
---|
232 | ENDIF |
---|
233 | ik = mikt(ji,jj) |
---|
234 | IF( ik > 1 ) THEN |
---|
235 | zl = ( gdept_0(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) ) |
---|
236 | ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik+1,jp_tem) |
---|
237 | ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik+1,jp_sal) |
---|
238 | END IF |
---|
239 | END_2D |
---|
240 | ENDIF |
---|
241 | ! |
---|
242 | ENDIF |
---|
243 | ! |
---|
244 | SELECT CASE(cddta) |
---|
245 | CASE('ini') |
---|
246 | ! !== deallocate T & S structure ==! |
---|
247 | ! (data used only for initialisation) |
---|
248 | IF(lwp) WRITE(numout,*) 'dta_tsd: deallocte T & S arrays as they are only use to initialize the run' |
---|
249 | DEALLOCATE( sf_tsdini(jp_tem)%fnow ) ! T arrays in the structure |
---|
250 | IF( sf_tsdini(jp_tem)%ln_tint ) DEALLOCATE( sf_tsdini(jp_tem)%fdta ) |
---|
251 | DEALLOCATE( sf_tsdini(jp_sal)%fnow ) ! S arrays in the structure |
---|
252 | IF( sf_tsdini(jp_sal)%ln_tint ) DEALLOCATE( sf_tsdini(jp_sal)%fdta ) |
---|
253 | DEALLOCATE( sf_tsdini ) ! the structure itself |
---|
254 | ! |
---|
255 | END SELECT |
---|
256 | ! |
---|
257 | END SUBROUTINE dta_tsd |
---|
258 | |
---|
259 | !!====================================================================== |
---|
260 | END MODULE dtatsd |
---|