1 | MODULE sbcssm |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE sbcssm *** |
---|
4 | !! Off-line : interpolation of the physical fields |
---|
5 | !!====================================================================== |
---|
6 | !! History : |
---|
7 | !! NEMO 3.4 ! 2012-03 First version by S. Alderson |
---|
8 | !! ! Heavily derived from Christian's dtadyn routine |
---|
9 | !! ! in OFF_SRC |
---|
10 | !!---------------------------------------------------------------------- |
---|
11 | |
---|
12 | !!---------------------------------------------------------------------- |
---|
13 | !! sbc_ssm_init : initialization, namelist read, and SAVEs control |
---|
14 | !! sbc_ssm : Interpolation of the fields |
---|
15 | !!---------------------------------------------------------------------- |
---|
16 | USE oce ! ocean dynamics and tracers variables |
---|
17 | USE c1d ! 1D configuration: lk_c1d |
---|
18 | USE dom_oce ! ocean domain: variables |
---|
19 | USE zdf_oce ! ocean vertical physics: variables |
---|
20 | USE sbc_oce ! surface module: variables |
---|
21 | USE phycst ! physical constants |
---|
22 | USE eosbn2 ! equation of state - Brunt Vaisala frequency |
---|
23 | USE lbclnk ! ocean lateral boundary conditions (or mpp link) |
---|
24 | USE zpshde ! z-coord. with partial steps: horizontal derivatives |
---|
25 | USE in_out_manager ! I/O manager |
---|
26 | USE iom ! I/O library |
---|
27 | USE lib_mpp ! distributed memory computing library |
---|
28 | USE prtctl ! print control |
---|
29 | USE fldread ! read input fields |
---|
30 | USE timing ! Timing |
---|
31 | |
---|
32 | IMPLICIT NONE |
---|
33 | PRIVATE |
---|
34 | |
---|
35 | PUBLIC sbc_ssm_init ! called by sbc_init |
---|
36 | PUBLIC sbc_ssm ! called by sbc |
---|
37 | |
---|
38 | CHARACTER(len=100) :: cn_dir !: Root directory for location of ssm files |
---|
39 | LOGICAL :: ln_3d_uve !: specify whether input velocity data is 3D |
---|
40 | LOGICAL :: ln_read_frq !: specify whether we must read frq or not |
---|
41 | INTEGER :: nfld_3d |
---|
42 | INTEGER :: nfld_2d |
---|
43 | |
---|
44 | INTEGER :: jf_tem ! index of temperature |
---|
45 | INTEGER :: jf_sal ! index of salinity |
---|
46 | INTEGER :: jf_usp ! index of u velocity component |
---|
47 | INTEGER :: jf_vsp ! index of v velocity component |
---|
48 | INTEGER :: jf_ssh ! index of sea surface height |
---|
49 | INTEGER :: jf_e3t ! index of first T level thickness |
---|
50 | INTEGER :: jf_frq ! index of fraction of qsr absorbed in the 1st T level |
---|
51 | |
---|
52 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_3d ! structure of input fields (file information, fields read) |
---|
53 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_2d ! structure of input fields (file information, fields read) |
---|
54 | |
---|
55 | !!---------------------------------------------------------------------- |
---|
56 | !! NEMO/OFF 3.3 , NEMO Consortium (2010) |
---|
57 | !! $Id$ |
---|
58 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
59 | !!---------------------------------------------------------------------- |
---|
60 | CONTAINS |
---|
61 | |
---|
62 | SUBROUTINE sbc_ssm( kt ) |
---|
63 | !!---------------------------------------------------------------------- |
---|
64 | !! *** ROUTINE sbc_ssm *** |
---|
65 | !! |
---|
66 | !! ** Purpose : Prepares dynamics and physics fields from a NEMO run |
---|
67 | !! for an off-line simulation using surface processes only |
---|
68 | !! |
---|
69 | !! ** Method : calculates the position of data |
---|
70 | !! - interpolates data if needed |
---|
71 | !!---------------------------------------------------------------------- |
---|
72 | ! |
---|
73 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
74 | ! |
---|
75 | INTEGER :: ji, jj ! dummy loop indices |
---|
76 | REAL(wp) :: ztinta ! ratio applied to after records when doing time interpolation |
---|
77 | REAL(wp) :: ztintb ! ratio applied to before records when doing time interpolation |
---|
78 | !!---------------------------------------------------------------------- |
---|
79 | |
---|
80 | ! |
---|
81 | IF( nn_timing == 1 ) CALL timing_start( 'sbc_ssm') |
---|
82 | |
---|
83 | IF( nfld_3d > 0 ) CALL fld_read( kt, 1, sf_ssm_3d ) !== read data at kt time step ==! |
---|
84 | IF( nfld_2d > 0 ) CALL fld_read( kt, 1, sf_ssm_2d ) !== read data at kt time step ==! |
---|
85 | ! |
---|
86 | IF( ln_3d_uve ) THEN |
---|
87 | ssu_m(:,:) = sf_ssm_3d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity |
---|
88 | ssv_m(:,:) = sf_ssm_3d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity |
---|
89 | IF( lk_vvl ) e3t_m(:,:) = sf_ssm_3d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1) ! v-velocity |
---|
90 | ELSE |
---|
91 | ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity |
---|
92 | ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity |
---|
93 | IF( lk_vvl ) e3t_m(:,:) = sf_ssm_2d(jf_e3t)%fnow(:,:,1) * tmask(:,:,1) ! v-velocity |
---|
94 | ENDIF |
---|
95 | ! |
---|
96 | sst_m(:,:) = sf_ssm_2d(jf_tem)%fnow(:,:,1) * tmask(:,:,1) ! temperature |
---|
97 | sss_m(:,:) = sf_ssm_2d(jf_sal)%fnow(:,:,1) * tmask(:,:,1) ! salinity |
---|
98 | ssh_m(:,:) = sf_ssm_2d(jf_ssh)%fnow(:,:,1) * tmask(:,:,1) ! sea surface height |
---|
99 | IF( ln_read_frq ) frq_m(:,:) = sf_ssm_2d(jf_frq)%fnow(:,:,1) * tmask(:,:,1) ! sea surface height |
---|
100 | ! |
---|
101 | tsn(:,:,1,jp_tem) = sst_m(:,:) |
---|
102 | tsn(:,:,1,jp_sal) = sss_m(:,:) |
---|
103 | IF ( nn_ice == 1 ) THEN |
---|
104 | tsb(:,:,1,jp_tem) = sst_m(:,:) |
---|
105 | tsb(:,:,1,jp_sal) = sss_m(:,:) |
---|
106 | ENDIF |
---|
107 | ub (:,:,1) = ssu_m(:,:) |
---|
108 | vb (:,:,1) = ssv_m(:,:) |
---|
109 | |
---|
110 | IF(ln_ctl) THEN ! print control |
---|
111 | CALL prt_ctl(tab2d_1=sst_m, clinfo1=' sst_m - : ', mask1=tmask, ovlap=1 ) |
---|
112 | CALL prt_ctl(tab2d_1=sss_m, clinfo1=' sss_m - : ', mask1=tmask, ovlap=1 ) |
---|
113 | CALL prt_ctl(tab2d_1=ssu_m, clinfo1=' ssu_m - : ', mask1=umask, ovlap=1 ) |
---|
114 | CALL prt_ctl(tab2d_1=ssv_m, clinfo1=' ssv_m - : ', mask1=vmask, ovlap=1 ) |
---|
115 | CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' ssh_m - : ', mask1=tmask, ovlap=1 ) |
---|
116 | IF( lk_vvl ) CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' e3t_m - : ', mask1=tmask, ovlap=1 ) |
---|
117 | IF( ln_read_frq ) CALL prt_ctl(tab2d_1=frq_m, clinfo1=' frq_m - : ', mask1=tmask, ovlap=1 ) |
---|
118 | ENDIF |
---|
119 | ! |
---|
120 | IF( nn_timing == 1 ) CALL timing_stop( 'sbc_ssm') |
---|
121 | ! |
---|
122 | END SUBROUTINE sbc_ssm |
---|
123 | |
---|
124 | |
---|
125 | SUBROUTINE sbc_ssm_init |
---|
126 | !!---------------------------------------------------------------------- |
---|
127 | !! *** ROUTINE sbc_ssm_init *** |
---|
128 | !! |
---|
129 | !! ** Purpose : Initialisation of the dynamical data |
---|
130 | !! ** Method : - read the data namsbc_ssm namelist |
---|
131 | !! |
---|
132 | !! ** Action : - read parameters |
---|
133 | !!---------------------------------------------------------------------- |
---|
134 | INTEGER :: ierr, ierr0, ierr1, ierr2, ierr3 ! return error code |
---|
135 | INTEGER :: ifpr ! dummy loop indice |
---|
136 | INTEGER :: inum, idv, idimv, jpm ! local integer |
---|
137 | INTEGER :: ios ! Local integer output status for namelist read |
---|
138 | !! |
---|
139 | CHARACTER(len=100) :: cn_dir ! Root directory for location of core files |
---|
140 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_3d ! array of namelist information on the fields to read |
---|
141 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_2d ! array of namelist information on the fields to read |
---|
142 | TYPE(FLD_N) :: sn_tem, sn_sal ! information about the fields to be read |
---|
143 | TYPE(FLD_N) :: sn_usp, sn_vsp |
---|
144 | TYPE(FLD_N) :: sn_ssh, sn_e3t, sn_frq |
---|
145 | ! |
---|
146 | NAMELIST/namsbc_sas/cn_dir, ln_3d_uve, ln_read_frq, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh, sn_e3t, sn_frq |
---|
147 | !!---------------------------------------------------------------------- |
---|
148 | |
---|
149 | REWIND( numnam_ref ) ! Namelist namsbc_sas in reference namelist : Input fields |
---|
150 | READ ( numnam_ref, namsbc_sas, IOSTAT = ios, ERR = 901) |
---|
151 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in reference namelist', lwp ) |
---|
152 | |
---|
153 | REWIND( numnam_cfg ) ! Namelist namsbc_sas in configuration namelist : Input fields |
---|
154 | READ ( numnam_cfg, namsbc_sas, IOSTAT = ios, ERR = 902 ) |
---|
155 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in configuration namelist', lwp ) |
---|
156 | IF(lwm) WRITE ( numond, namsbc_sas ) |
---|
157 | |
---|
158 | ! ! store namelist information in an array |
---|
159 | ! ! Control print |
---|
160 | IF(lwp) THEN |
---|
161 | WRITE(numout,*) |
---|
162 | WRITE(numout,*) 'sbc_sas : standalone surface scheme ' |
---|
163 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
164 | WRITE(numout,*) ' Namelist namsbc_sas' |
---|
165 | WRITE(numout,*) ' Are we supplying a 3D u,v and e3 field ln_3d_uve = ', ln_3d_uve |
---|
166 | WRITE(numout,*) ' Are we reading frq (fraction of qsr absorbed in the 1st T level) ln_read_frq = ', ln_read_frq |
---|
167 | WRITE(numout,*) |
---|
168 | ENDIF |
---|
169 | |
---|
170 | ! |
---|
171 | !! switch off stuff that isn't sensible with a standalone module |
---|
172 | !! note that we need sbc_ssm called first in sbc |
---|
173 | ! |
---|
174 | IF( ln_apr_dyn ) THEN |
---|
175 | IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme' |
---|
176 | ln_apr_dyn = .FALSE. |
---|
177 | ENDIF |
---|
178 | IF( ln_dm2dc ) THEN |
---|
179 | IF( lwp ) WRITE(numout,*) 'No diurnal cycle needed with StandAlone Surface scheme' |
---|
180 | ln_dm2dc = .FALSE. |
---|
181 | ENDIF |
---|
182 | IF( ln_rnf ) THEN |
---|
183 | IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme' |
---|
184 | ln_rnf = .FALSE. |
---|
185 | ENDIF |
---|
186 | IF( ln_ssr ) THEN |
---|
187 | IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme' |
---|
188 | ln_ssr = .FALSE. |
---|
189 | ENDIF |
---|
190 | IF( nn_fwb > 0 ) THEN |
---|
191 | IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme' |
---|
192 | nn_fwb = 0 |
---|
193 | ENDIF |
---|
194 | IF( nn_closea > 0 ) THEN |
---|
195 | IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme' |
---|
196 | nn_closea = 0 |
---|
197 | ENDIF |
---|
198 | |
---|
199 | ! |
---|
200 | !! following code is a bit messy, but distinguishes between when u,v are 3d arrays and |
---|
201 | !! when we have other 3d arrays that we need to read in |
---|
202 | !! so if a new field is added i.e. jf_new, just give it the next integer in sequence |
---|
203 | !! for the corresponding dimension (currently if ln_3d_uve is true, 4 for 2d and 3 for 3d, |
---|
204 | !! alternatively if ln_3d_uve is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d, |
---|
205 | !! and the rest of the logic should still work |
---|
206 | ! |
---|
207 | jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3 ; jf_frq = 4 ! default 2D fields index |
---|
208 | ! |
---|
209 | IF( ln_3d_uve ) THEN |
---|
210 | jf_usp = 1 ; jf_vsp = 2 ; jf_e3t = 3 ! define 3D fields index |
---|
211 | nfld_3d = 2 + COUNT( (/lk_vvl/) ) ! number of 3D fields to read |
---|
212 | nfld_2d = 3 + COUNT( (/ln_read_frq/) ) ! number of 2D fields to read |
---|
213 | ELSE |
---|
214 | jf_usp = 4 ; jf_vsp = 5 ; jf_e3t = 6 ; jf_frq = 6 + COUNT( (/lk_vvl/) ) ! update 2D fields index |
---|
215 | nfld_3d = 0 ! no 3D fields to read |
---|
216 | nfld_2d = 5 + COUNT( (/lk_vvl/) ) + COUNT( (/ln_read_frq/) ) ! number of 2D fields to read |
---|
217 | ENDIF |
---|
218 | |
---|
219 | IF( nfld_3d > 0 ) THEN |
---|
220 | ALLOCATE( slf_3d(nfld_3d), STAT=ierr ) ! set slf structure |
---|
221 | IF( ierr > 0 ) THEN |
---|
222 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' ) ; RETURN |
---|
223 | ENDIF |
---|
224 | slf_3d(jf_usp) = sn_usp |
---|
225 | slf_3d(jf_vsp) = sn_vsp |
---|
226 | IF( lk_vvl ) slf_3d(jf_e3t) = sn_e3t |
---|
227 | ENDIF |
---|
228 | |
---|
229 | IF( nfld_2d > 0 ) THEN |
---|
230 | ALLOCATE( slf_2d(nfld_2d), STAT=ierr ) ! set slf structure |
---|
231 | IF( ierr > 0 ) THEN |
---|
232 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 2d structure' ) ; RETURN |
---|
233 | ENDIF |
---|
234 | slf_2d(jf_tem) = sn_tem ; slf_2d(jf_sal) = sn_sal ; slf_2d(jf_ssh) = sn_ssh |
---|
235 | IF( ln_read_frq ) slf_2d(jf_frq) = sn_frq |
---|
236 | IF( .NOT. ln_3d_uve ) THEN |
---|
237 | slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp |
---|
238 | IF( lk_vvl ) slf_2d(jf_e3t) = sn_e3t |
---|
239 | ENDIF |
---|
240 | ENDIF |
---|
241 | ! |
---|
242 | ierr1 = 0 ! default definition if slf_?d(ifpr)%ln_tint = .false. |
---|
243 | IF( nfld_3d > 0 ) THEN |
---|
244 | ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr ) ! set sf structure |
---|
245 | IF( ierr > 0 ) THEN |
---|
246 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf structure' ) ; RETURN |
---|
247 | ENDIF |
---|
248 | DO ifpr = 1, nfld_3d |
---|
249 | ALLOCATE( sf_ssm_3d(ifpr)%fnow(jpi,jpj,jpk) , STAT=ierr0 ) |
---|
250 | IF( slf_3d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_3d(ifpr)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 ) |
---|
251 | IF( ierr0 + ierr1 > 0 ) THEN |
---|
252 | CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_3d array structure' ) ; RETURN |
---|
253 | ENDIF |
---|
254 | END DO |
---|
255 | ! ! fill sf with slf_i and control print |
---|
256 | CALL fld_fill( sf_ssm_3d, slf_3d, cn_dir, 'sbc_ssm_init', '3D Data in file', 'namsbc_ssm' ) |
---|
257 | ENDIF |
---|
258 | |
---|
259 | IF( nfld_2d > 0 ) THEN |
---|
260 | ALLOCATE( sf_ssm_2d(nfld_2d), STAT=ierr ) ! set sf structure |
---|
261 | IF( ierr > 0 ) THEN |
---|
262 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf 2d structure' ) ; RETURN |
---|
263 | ENDIF |
---|
264 | DO ifpr = 1, nfld_2d |
---|
265 | ALLOCATE( sf_ssm_2d(ifpr)%fnow(jpi,jpj,1) , STAT=ierr0 ) |
---|
266 | IF( slf_2d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_2d(ifpr)%fdta(jpi,jpj,1,2) , STAT=ierr1 ) |
---|
267 | IF( ierr0 + ierr1 > 0 ) THEN |
---|
268 | CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_2d array structure' ) ; RETURN |
---|
269 | ENDIF |
---|
270 | END DO |
---|
271 | ! |
---|
272 | CALL fld_fill( sf_ssm_2d, slf_2d, cn_dir, 'sbc_ssm_init', '2D Data in file', 'namsbc_ssm' ) |
---|
273 | ENDIF |
---|
274 | ! |
---|
275 | ! finally tidy up |
---|
276 | |
---|
277 | IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr ) |
---|
278 | IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr ) |
---|
279 | |
---|
280 | CALL sbc_ssm( nit000 ) ! need to define ss?_m arrays used in limistate |
---|
281 | IF( .NOT. ln_read_frq ) frq_m(:,:) = 1. |
---|
282 | ! |
---|
283 | END SUBROUTINE sbc_ssm_init |
---|
284 | |
---|
285 | !!====================================================================== |
---|
286 | END MODULE sbcssm |
---|