[3362] | 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 | |
---|
[3364] | 35 | PUBLIC sbc_ssm_init ! called by sbc_init |
---|
| 36 | PUBLIC sbc_ssm ! called by sbc |
---|
[3362] | 37 | |
---|
[3363] | 38 | CHARACTER(len=100) :: cn_dir = './' !: Root directory for location of ssm files |
---|
| 39 | LOGICAL :: ln_3d_uv = .true. !: specify whether input velocity data is 3D |
---|
| 40 | INTEGER , SAVE :: nfld_3d |
---|
| 41 | INTEGER , SAVE :: nfld_2d |
---|
[3362] | 42 | |
---|
| 43 | INTEGER , PARAMETER :: jpfld_3d = 4 ! maximum number of files to read |
---|
| 44 | INTEGER , PARAMETER :: jpfld_2d = 1 ! maximum number of files to read |
---|
| 45 | INTEGER , SAVE :: jf_tem ! index of temperature |
---|
| 46 | INTEGER , SAVE :: jf_sal ! index of salinity |
---|
| 47 | INTEGER , SAVE :: jf_usp ! index of u velocity component |
---|
| 48 | INTEGER , SAVE :: jf_vsp ! index of v velocity component |
---|
| 49 | INTEGER , SAVE :: jf_ssh ! index of sea surface height |
---|
| 50 | |
---|
| 51 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_3d ! structure of input fields (file information, fields read) |
---|
| 52 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_ssm_2d ! structure of input fields (file information, fields read) |
---|
| 53 | |
---|
| 54 | !! * Substitutions |
---|
| 55 | # include "domzgr_substitute.h90" |
---|
| 56 | # include "vectopt_loop_substitute.h90" |
---|
| 57 | !!---------------------------------------------------------------------- |
---|
| 58 | !! NEMO/OFF 3.3 , NEMO Consortium (2010) |
---|
| 59 | !! $Id: sbcssm.F90 3294 2012-01-28 16:44:18Z rblod $ |
---|
| 60 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 61 | !!---------------------------------------------------------------------- |
---|
| 62 | CONTAINS |
---|
| 63 | |
---|
| 64 | SUBROUTINE sbc_ssm( kt ) |
---|
| 65 | !!---------------------------------------------------------------------- |
---|
| 66 | !! *** ROUTINE sbc_ssm *** |
---|
| 67 | !! |
---|
| 68 | !! ** Purpose : Prepares dynamics and physics fields from a NEMO run |
---|
| 69 | !! for an off-line simulation using surface processes only |
---|
| 70 | !! |
---|
| 71 | !! ** Method : calculates the position of data |
---|
| 72 | !! - interpolates data if needed |
---|
| 73 | !!---------------------------------------------------------------------- |
---|
| 74 | ! |
---|
| 75 | INTEGER, INTENT(in) :: kt ! ocean time-step index |
---|
| 76 | ! |
---|
| 77 | INTEGER :: ji, jj ! dummy loop indices |
---|
| 78 | REAL(wp) :: ztinta ! ratio applied to after records when doing time interpolation |
---|
| 79 | REAL(wp) :: ztintb ! ratio applied to before records when doing time interpolation |
---|
| 80 | !!---------------------------------------------------------------------- |
---|
| 81 | |
---|
| 82 | ! |
---|
[4147] | 83 | IF (kt == nn_it000 ) CALL sbc_ssm_init() |
---|
| 84 | |
---|
[3362] | 85 | IF( nn_timing == 1 ) CALL timing_start( 'sbc_ssm') |
---|
| 86 | |
---|
[3363] | 87 | IF( nfld_3d > 0 ) CALL fld_read( kt, 1, sf_ssm_3d ) !== read data at kt time step ==! |
---|
| 88 | IF( nfld_2d > 0 ) CALL fld_read( kt, 1, sf_ssm_2d ) !== read data at kt time step ==! |
---|
[3362] | 89 | ! |
---|
| 90 | IF( ln_3d_uv ) THEN |
---|
| 91 | ssu_m(:,:) = sf_ssm_3d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity |
---|
| 92 | ssv_m(:,:) = sf_ssm_3d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity |
---|
| 93 | ELSE |
---|
| 94 | ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1) ! u-velocity |
---|
| 95 | ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1) ! v-velocity |
---|
| 96 | ENDIF |
---|
| 97 | ! |
---|
| 98 | sst_m(:,:) = sf_ssm_2d(jf_tem)%fnow(:,:,1) * tmask(:,:,1) ! temperature |
---|
| 99 | sss_m(:,:) = sf_ssm_2d(jf_sal)%fnow(:,:,1) * tmask(:,:,1) ! salinity |
---|
| 100 | ssh_m(:,:) = sf_ssm_2d(jf_ssh)%fnow(:,:,1) * tmask(:,:,1) ! sea surface height |
---|
| 101 | ! |
---|
| 102 | tsn(:,:,1,jp_tem) = sst_m(:,:) |
---|
| 103 | tsn(:,:,1,jp_sal) = sss_m(:,:) |
---|
[4147] | 104 | IF ( nn_ice == 1 ) THEN |
---|
| 105 | tsb(:,:,1,jp_tem) = sst_m(:,:) |
---|
| 106 | tsb(:,:,1,jp_sal) = sss_m(:,:) |
---|
| 107 | ENDIF |
---|
[3362] | 108 | ub (:,:,1 ) = ssu_m(:,:) |
---|
| 109 | vb (:,:,1 ) = ssv_m(:,:) |
---|
| 110 | |
---|
| 111 | IF(ln_ctl) THEN ! print control |
---|
| 112 | CALL prt_ctl(tab2d_1=sst_m, clinfo1=' sst_m - : ', mask1=tmask, ovlap=1 ) |
---|
| 113 | CALL prt_ctl(tab2d_1=sss_m, clinfo1=' sss_m - : ', mask1=tmask, ovlap=1 ) |
---|
| 114 | CALL prt_ctl(tab2d_1=ssu_m, clinfo1=' ssu_m - : ', mask1=umask, ovlap=1 ) |
---|
| 115 | CALL prt_ctl(tab2d_1=ssv_m, clinfo1=' ssv_m - : ', mask1=vmask, ovlap=1 ) |
---|
| 116 | CALL prt_ctl(tab2d_1=ssh_m, clinfo1=' ssh_m - : ', mask1=tmask, ovlap=1 ) |
---|
| 117 | ENDIF |
---|
| 118 | ! |
---|
| 119 | IF( nn_timing == 1 ) CALL timing_stop( 'sbc_ssm') |
---|
| 120 | ! |
---|
| 121 | END SUBROUTINE sbc_ssm |
---|
| 122 | |
---|
| 123 | |
---|
[3364] | 124 | SUBROUTINE sbc_ssm_init |
---|
[3362] | 125 | !!---------------------------------------------------------------------- |
---|
| 126 | !! *** ROUTINE sbc_ssm_init *** |
---|
| 127 | !! |
---|
| 128 | !! ** Purpose : Initialisation of the dynamical data |
---|
| 129 | !! ** Method : - read the data namsbc_ssm namelist |
---|
| 130 | !! |
---|
| 131 | !! ** Action : - read parameters |
---|
| 132 | !!---------------------------------------------------------------------- |
---|
| 133 | INTEGER :: ierr, ierr0, ierr1, ierr2, ierr3 ! return error code |
---|
| 134 | INTEGER :: ifpr ! dummy loop indice |
---|
| 135 | INTEGER :: inum, idv, idimv, jpm ! local integer |
---|
[4147] | 136 | INTEGER :: ios ! Local integer output status for namelist read |
---|
[3362] | 137 | !! |
---|
[3364] | 138 | CHARACTER(len=100) :: cn_dir ! Root directory for location of core files |
---|
| 139 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_3d ! array of namelist information on the fields to read |
---|
| 140 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_2d ! array of namelist information on the fields to read |
---|
[3362] | 141 | TYPE(FLD_N) :: sn_tem, sn_sal ! information about the fields to be read |
---|
| 142 | TYPE(FLD_N) :: sn_usp, sn_vsp, sn_ssh |
---|
| 143 | ! |
---|
[4147] | 144 | NAMELIST/namsbc_sas/cn_dir, ln_3d_uv, sn_tem, sn_sal, sn_usp, sn_vsp, sn_ssh |
---|
| 145 | |
---|
| 146 | REWIND( numnam_ref ) ! Namelist namsbc_sas in reference namelist : Input fields |
---|
| 147 | READ ( numnam_ref, namsbc_sas, IOSTAT = ios, ERR = 901) |
---|
| 148 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in reference namelist', lwp ) |
---|
[3362] | 149 | |
---|
[4147] | 150 | REWIND( numnam_cfg ) ! Namelist namsbc_sas in configuration namelist : Input fields |
---|
| 151 | READ ( numnam_cfg, namsbc_sas, IOSTAT = ios, ERR = 902 ) |
---|
| 152 | 902 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_sas in configuration namelist', lwp ) |
---|
| 153 | WRITE ( numond, namsbc_sas ) |
---|
| 154 | |
---|
[3362] | 155 | ! ! store namelist information in an array |
---|
| 156 | ! ! Control print |
---|
| 157 | IF(lwp) THEN |
---|
| 158 | WRITE(numout,*) |
---|
[4147] | 159 | WRITE(numout,*) 'sbc_sas : standalone surface scheme ' |
---|
[3362] | 160 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
[4147] | 161 | WRITE(numout,*) ' Namelist namsbc_sas' |
---|
[3362] | 162 | WRITE(numout,*) |
---|
| 163 | ENDIF |
---|
[3364] | 164 | |
---|
| 165 | ! |
---|
| 166 | !! switch off stuff that isn't sensible with a standalone module |
---|
| 167 | !! note that we need sbc_ssm called first in sbc |
---|
| 168 | ! |
---|
| 169 | IF( ln_cpl ) THEN |
---|
| 170 | IF( lwp ) WRITE(numout,*) 'Coupled mode not sensible with StandAlone Surface scheme' |
---|
| 171 | ln_cpl = .FALSE. |
---|
| 172 | ENDIF |
---|
| 173 | IF( ln_apr_dyn ) THEN |
---|
| 174 | IF( lwp ) WRITE(numout,*) 'No atmospheric gradient needed with StandAlone Surface scheme' |
---|
| 175 | ln_apr_dyn = .FALSE. |
---|
| 176 | ENDIF |
---|
| 177 | IF( ln_dm2dc ) THEN |
---|
| 178 | IF( lwp ) WRITE(numout,*) 'No diurnal cycle needed with StandAlone Surface scheme' |
---|
| 179 | ln_dm2dc = .FALSE. |
---|
| 180 | ENDIF |
---|
| 181 | IF( ln_rnf ) THEN |
---|
| 182 | IF( lwp ) WRITE(numout,*) 'No runoff needed with StandAlone Surface scheme' |
---|
| 183 | ln_rnf = .FALSE. |
---|
| 184 | ENDIF |
---|
| 185 | IF( ln_ssr ) THEN |
---|
| 186 | IF( lwp ) WRITE(numout,*) 'No surface relaxation needed with StandAlone Surface scheme' |
---|
| 187 | ln_ssr = .FALSE. |
---|
| 188 | ENDIF |
---|
| 189 | IF( nn_fwb > 0 ) THEN |
---|
| 190 | IF( lwp ) WRITE(numout,*) 'No freshwater budget adjustment needed with StandAlone Surface scheme' |
---|
| 191 | nn_fwb = 0 |
---|
| 192 | ENDIF |
---|
| 193 | IF( nn_closea > 0 ) THEN |
---|
| 194 | IF( lwp ) WRITE(numout,*) 'No closed seas adjustment needed with StandAlone Surface scheme' |
---|
| 195 | nn_closea = 0 |
---|
| 196 | ENDIF |
---|
| 197 | |
---|
[3362] | 198 | ! |
---|
[3364] | 199 | !! following code is a bit messy, but distinguishes between when u,v are 3d arrays and |
---|
| 200 | !! when we have other 3d arrays that we need to read in |
---|
| 201 | !! so if a new field is added i.e. jf_new, just give it the next integer in sequence |
---|
| 202 | !! for the corresponding dimension (currently if ln_3d_uv is true, 4 for 2d and 3 for 3d, |
---|
| 203 | !! alternatively if ln_3d_uv is false, 6 for 2d and 1 for 3d), reset nfld_3d, nfld_2d, |
---|
| 204 | !! and the rest of the logic should still work |
---|
| 205 | ! |
---|
[3362] | 206 | jf_tem = 1 ; jf_sal = 2 ; jf_ssh = 3 |
---|
| 207 | ! |
---|
| 208 | IF( ln_3d_uv ) THEN |
---|
| 209 | jf_usp = 1 ; jf_vsp = 2 |
---|
[3363] | 210 | nfld_3d = 2 |
---|
| 211 | nfld_2d = 3 |
---|
[3362] | 212 | ELSE |
---|
| 213 | jf_usp = 4 ; jf_vsp = 5 |
---|
[3363] | 214 | nfld_3d = 0 |
---|
| 215 | nfld_2d = 5 |
---|
[3362] | 216 | ENDIF |
---|
| 217 | |
---|
[3364] | 218 | IF( nfld_3d > 0 ) THEN |
---|
| 219 | ALLOCATE( slf_3d(nfld_3d), STAT=ierr ) ! set slf structure |
---|
| 220 | IF( ierr > 0 ) THEN |
---|
| 221 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate slf 3d structure' ) ; RETURN |
---|
| 222 | ENDIF |
---|
| 223 | IF( ln_3d_uv ) THEN |
---|
| 224 | slf_3d(jf_usp) = sn_usp |
---|
| 225 | slf_3d(jf_vsp) = sn_vsp |
---|
| 226 | ENDIF |
---|
| 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( .NOT. ln_3d_uv ) THEN |
---|
| 236 | slf_2d(jf_usp) = sn_usp ; slf_2d(jf_vsp) = sn_vsp |
---|
| 237 | ENDIF |
---|
| 238 | ENDIF |
---|
[3362] | 239 | ! |
---|
[3363] | 240 | IF( nfld_3d > 0 ) THEN |
---|
| 241 | ALLOCATE( sf_ssm_3d(nfld_3d), STAT=ierr ) ! set sf structure |
---|
[3362] | 242 | IF( ierr > 0 ) THEN |
---|
[3364] | 243 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf structure' ) ; RETURN |
---|
[3362] | 244 | ENDIF |
---|
[3363] | 245 | DO ifpr = 1, nfld_3d |
---|
[3362] | 246 | ALLOCATE( sf_ssm_3d(ifpr)%fnow(jpi,jpj,jpk) , STAT=ierr0 ) |
---|
| 247 | IF( slf_3d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_3d(ifpr)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 ) |
---|
| 248 | IF( ierr0 + ierr1 > 0 ) THEN |
---|
| 249 | CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_3d array structure' ) ; RETURN |
---|
| 250 | ENDIF |
---|
| 251 | END DO |
---|
| 252 | ! ! fill sf with slf_i and control print |
---|
| 253 | CALL fld_fill( sf_ssm_3d, slf_3d, cn_dir, 'sbc_ssm_init', '3D Data in file', 'namsbc_ssm' ) |
---|
| 254 | ENDIF |
---|
| 255 | |
---|
[3363] | 256 | IF( nfld_2d > 0 ) THEN |
---|
| 257 | ALLOCATE( sf_ssm_2d(nfld_2d), STAT=ierr ) ! set sf structure |
---|
[3362] | 258 | IF( ierr > 0 ) THEN |
---|
[3364] | 259 | CALL ctl_stop( 'sbc_ssm_init: unable to allocate sf 2d structure' ) ; RETURN |
---|
[3362] | 260 | ENDIF |
---|
[3363] | 261 | DO ifpr = 1, nfld_2d |
---|
[3362] | 262 | ALLOCATE( sf_ssm_2d(ifpr)%fnow(jpi,jpj,1) , STAT=ierr0 ) |
---|
| 263 | IF( slf_2d(ifpr)%ln_tint ) ALLOCATE( sf_ssm_2d(ifpr)%fdta(jpi,jpj,1,2) , STAT=ierr1 ) |
---|
| 264 | IF( ierr0 + ierr1 > 0 ) THEN |
---|
| 265 | CALL ctl_stop( 'sbc_ssm_init : unable to allocate sf_ssm_2d array structure' ) ; RETURN |
---|
| 266 | ENDIF |
---|
| 267 | END DO |
---|
| 268 | ! |
---|
| 269 | CALL fld_fill( sf_ssm_2d, slf_2d, cn_dir, 'sbc_ssm_init', '2D Data in file', 'namsbc_ssm' ) |
---|
| 270 | ENDIF |
---|
| 271 | ! |
---|
| 272 | ! lim code currently uses surface temperature and salinity in tsn array for initialisation |
---|
| 273 | ! and ub, vb arrays in ice dynamics |
---|
| 274 | ! so allocate enough of arrays to use |
---|
| 275 | ! |
---|
[4147] | 276 | ierr3 = 0 |
---|
[3362] | 277 | jpm = MAX(jp_tem, jp_sal) |
---|
| 278 | ALLOCATE( tsn(jpi,jpj,1,jpm), STAT=ierr0 ) |
---|
| 279 | ALLOCATE( ub(jpi,jpj,1) , STAT=ierr1 ) |
---|
| 280 | ALLOCATE( vb(jpi,jpj,1) , STAT=ierr2 ) |
---|
[4147] | 281 | IF ( nn_ice == 1 ) ALLOCATE( tsb(jpi,jpj,1,jpm), STAT=ierr3 ) |
---|
| 282 | ierr = ierr0 + ierr1 + ierr2 + ierr3 |
---|
[3362] | 283 | IF( ierr > 0 ) THEN |
---|
| 284 | CALL ctl_stop('sbc_ssm_init: unable to allocate surface arrays') |
---|
| 285 | ENDIF |
---|
| 286 | ! |
---|
[3364] | 287 | ! finally tidy up |
---|
[3362] | 288 | |
---|
[3364] | 289 | IF( nfld_3d > 0 ) DEALLOCATE( slf_3d, STAT=ierr ) |
---|
| 290 | IF( nfld_2d > 0 ) DEALLOCATE( slf_2d, STAT=ierr ) |
---|
| 291 | ! |
---|
| 292 | END SUBROUTINE sbc_ssm_init |
---|
| 293 | |
---|
[3362] | 294 | !!====================================================================== |
---|
| 295 | END MODULE sbcssm |
---|