[268] | 1 | MODULE trcdta |
---|
| 2 | !!====================================================================== |
---|
[433] | 3 | !! *** MODULE trcdta *** |
---|
[945] | 4 | !! TOP : reads passive tracer data |
---|
[268] | 5 | !!===================================================================== |
---|
[945] | 6 | !! History : 1.0 ! 2002-04 (O. Aumont) original code |
---|
| 7 | !! - ! 2004-03 (C. Ethe) module |
---|
| 8 | !! - ! 2005-03 (O. Aumont, A. El Moussaoui) F90 |
---|
[3294] | 9 | !! 3.4 ! 2010-11 (C. Ethe, G. Madec) use of fldread + dynamical allocation |
---|
[4230] | 10 | !! 3.5 ! 2013-08 (M. Vichi) generalization for other BGC models |
---|
[7646] | 11 | !! 3.6 ! 2015-03 (T. Lovato) revisit code I/O |
---|
[274] | 12 | !!---------------------------------------------------------------------- |
---|
[6140] | 13 | #if defined key_top |
---|
[268] | 14 | !!---------------------------------------------------------------------- |
---|
[3294] | 15 | !! 'key_top' TOP model |
---|
[268] | 16 | !!---------------------------------------------------------------------- |
---|
[3294] | 17 | !! trc_dta : read and time interpolated passive tracer data |
---|
[268] | 18 | !!---------------------------------------------------------------------- |
---|
[3294] | 19 | USE par_trc ! passive tracers parameters |
---|
| 20 | USE oce_trc ! shared variables between ocean and passive tracers |
---|
| 21 | USE trc ! passive tracers common variables |
---|
[9124] | 22 | ! |
---|
[3294] | 23 | USE iom ! I/O manager |
---|
| 24 | USE lib_mpp ! MPP library |
---|
| 25 | USE fldread ! read input fields |
---|
[268] | 26 | |
---|
| 27 | IMPLICIT NONE |
---|
| 28 | PRIVATE |
---|
| 29 | |
---|
[2715] | 30 | PUBLIC trc_dta ! called in trcini.F90 and trcdmp.F90 |
---|
[7646] | 31 | PUBLIC trc_dta_ini ! called in trcini.F90 |
---|
[268] | 32 | |
---|
[14086] | 33 | INTEGER , PUBLIC :: nb_trcdta ! number of tracers to be initialised with data |
---|
| 34 | INTEGER , PUBLIC, ALLOCATABLE, DIMENSION(:) :: n_trc_index ! indice of tracer which is initialised with data |
---|
| 35 | INTEGER , PUBLIC :: ntra ! MAX( 1, nb_trcdta ) to avoid compilation error with bounds checking |
---|
| 36 | REAL(wp) , ALLOCATABLE, DIMENSION(:) :: rf_trfac ! multiplicative factor for tracer values |
---|
| 37 | TYPE(FLD), ALLOCATABLE, DIMENSION(:) :: sf_trcdta ! structure of input SST (file informations, fields read) |
---|
[6140] | 38 | |
---|
[12377] | 39 | !! Substitutions |
---|
| 40 | #include "do_loop_substitute.h90" |
---|
[13237] | 41 | #include "domzgr_substitute.h90" |
---|
[268] | 42 | !!---------------------------------------------------------------------- |
---|
[10068] | 43 | !! NEMO/TOP 4.0 , NEMO Consortium (2018) |
---|
[1152] | 44 | !! $Id$ |
---|
[10068] | 45 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
[268] | 46 | !!---------------------------------------------------------------------- |
---|
| 47 | CONTAINS |
---|
| 48 | |
---|
[7646] | 49 | SUBROUTINE trc_dta_ini(ntrc) |
---|
[335] | 50 | !!---------------------------------------------------------------------- |
---|
[7646] | 51 | !! *** ROUTINE trc_dta_ini *** |
---|
[3294] | 52 | !! |
---|
| 53 | !! ** Purpose : initialisation of passive tracer input data |
---|
| 54 | !! |
---|
| 55 | !! ** Method : - Read namtsd namelist |
---|
| 56 | !! - allocates passive tracer data structure |
---|
[335] | 57 | !!---------------------------------------------------------------------- |
---|
[9169] | 58 | INTEGER,INTENT(in) :: ntrc ! number of tracers |
---|
[3294] | 59 | ! |
---|
[9169] | 60 | INTEGER :: jl, jn ! dummy loop indices |
---|
| 61 | INTEGER :: ios, ierr0, ierr1, ierr2, ierr3 ! local integers |
---|
| 62 | REAL(wp) :: zfact |
---|
| 63 | CHARACTER(len=100) :: clndta, clntrc |
---|
[3294] | 64 | ! |
---|
[9169] | 65 | CHARACTER(len=100) :: cn_dir |
---|
[4230] | 66 | TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) :: slf_i ! array of namelist informations on the fields to read |
---|
| 67 | TYPE(FLD_N), DIMENSION(jpmaxtrc) :: sn_trcdta |
---|
| 68 | REAL(wp) , DIMENSION(jpmaxtrc) :: rn_trfac ! multiplicative factor for tracer values |
---|
[945] | 69 | !! |
---|
[3294] | 70 | NAMELIST/namtrc_dta/ sn_trcdta, cn_dir, rn_trfac |
---|
[335] | 71 | !!---------------------------------------------------------------------- |
---|
[3294] | 72 | ! |
---|
[6140] | 73 | IF( lwp ) THEN |
---|
[9169] | 74 | WRITE(numout,*) |
---|
| 75 | WRITE(numout,*) 'trc_dta_ini : Tracers Initial Conditions (IC)' |
---|
| 76 | WRITE(numout,*) '~~~~~~~~~~~ ' |
---|
[6140] | 77 | ENDIF |
---|
| 78 | ! |
---|
[3294] | 79 | ! Initialisation |
---|
| 80 | ierr0 = 0 ; ierr1 = 0 ; ierr2 = 0 ; ierr3 = 0 |
---|
| 81 | ! Compute the number of tracers to be initialised with data |
---|
[4230] | 82 | ALLOCATE( n_trc_index(ntrc), slf_i(ntrc), STAT=ierr0 ) |
---|
[3294] | 83 | IF( ierr0 > 0 ) THEN |
---|
[7646] | 84 | CALL ctl_stop( 'trc_dta_ini: unable to allocate n_trc_index' ) ; RETURN |
---|
[3294] | 85 | ENDIF |
---|
| 86 | nb_trcdta = 0 |
---|
| 87 | n_trc_index(:) = 0 |
---|
[4230] | 88 | DO jn = 1, ntrc |
---|
[3294] | 89 | IF( ln_trc_ini(jn) ) THEN |
---|
| 90 | nb_trcdta = nb_trcdta + 1 |
---|
| 91 | n_trc_index(jn) = nb_trcdta |
---|
| 92 | ENDIF |
---|
[9169] | 93 | END DO |
---|
[3294] | 94 | ! |
---|
| 95 | ntra = MAX( 1, nb_trcdta ) ! To avoid compilation error with bounds checking |
---|
[3827] | 96 | IF(lwp) THEN |
---|
[9169] | 97 | WRITE(numout,*) |
---|
| 98 | WRITE(numout,*) ' number of passive tracers to be initialize by data :', ntra |
---|
[3827] | 99 | ENDIF |
---|
[3294] | 100 | ! |
---|
[4147] | 101 | READ ( numnat_ref, namtrc_dta, IOSTAT = ios, ERR = 901) |
---|
[11536] | 102 | 901 IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dta_ini in reference namelist' ) |
---|
[4147] | 103 | READ ( numnat_cfg, namtrc_dta, IOSTAT = ios, ERR = 902 ) |
---|
[11536] | 104 | 902 IF( ios > 0 ) CALL ctl_nam ( ios , 'namtrc_dta_ini in configuration namelist' ) |
---|
[4624] | 105 | IF(lwm) WRITE ( numont, namtrc_dta ) |
---|
[4147] | 106 | |
---|
[3294] | 107 | IF( lwp ) THEN |
---|
[4230] | 108 | DO jn = 1, ntrc |
---|
[3294] | 109 | IF( ln_trc_ini(jn) ) THEN ! open input file only if ln_trc_ini(jn) is true |
---|
| 110 | clndta = TRIM( sn_trcdta(jn)%clvar ) |
---|
| 111 | clntrc = TRIM( ctrcnm (jn) ) |
---|
[6140] | 112 | if (jn > jptra) clntrc='Dummy' ! By pass weird formats in ocean.output if ntrc > jptra |
---|
[3294] | 113 | zfact = rn_trfac(jn) |
---|
| 114 | IF( clndta /= clntrc ) THEN |
---|
[7646] | 115 | CALL ctl_warn( 'trc_dta_ini: passive tracer data initialisation ', & |
---|
[6140] | 116 | & 'Input name of data file : '//TRIM(clndta)// & |
---|
| 117 | & ' differs from that of tracer : '//TRIM(clntrc)//' ') |
---|
[3294] | 118 | ENDIF |
---|
[9169] | 119 | WRITE(numout,*) |
---|
| 120 | WRITE(numout,'(a, i4,3a,e11.3)') ' Read IC file for tracer number :', & |
---|
[6140] | 121 | & jn, ', name : ', TRIM(clndta), ', Multiplicative Scaling factor : ', zfact |
---|
[335] | 122 | ENDIF |
---|
[3294] | 123 | END DO |
---|
| 124 | ENDIF |
---|
| 125 | ! |
---|
| 126 | IF( nb_trcdta > 0 ) THEN ! allocate only if the number of tracer to initialise is greater than zero |
---|
| 127 | ALLOCATE( sf_trcdta(nb_trcdta), rf_trfac(nb_trcdta), STAT=ierr1 ) |
---|
| 128 | IF( ierr1 > 0 ) THEN |
---|
[7646] | 129 | CALL ctl_stop( 'trc_dta_ini: unable to allocate sf_trcdta structure' ) ; RETURN |
---|
[3294] | 130 | ENDIF |
---|
| 131 | ! |
---|
[4230] | 132 | DO jn = 1, ntrc |
---|
[3294] | 133 | IF( ln_trc_ini(jn) ) THEN ! update passive tracers arrays with input data read from file |
---|
| 134 | jl = n_trc_index(jn) |
---|
| 135 | slf_i(jl) = sn_trcdta(jn) |
---|
| 136 | rf_trfac(jl) = rn_trfac(jn) |
---|
| 137 | ALLOCATE( sf_trcdta(jl)%fnow(jpi,jpj,jpk) , STAT=ierr2 ) |
---|
| 138 | IF( sn_trcdta(jn)%ln_tint ) ALLOCATE( sf_trcdta(jl)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 ) |
---|
| 139 | IF( ierr2 + ierr3 > 0 ) THEN |
---|
[7646] | 140 | CALL ctl_stop( 'trc_dta_ini : unable to allocate passive tracer data arrays' ) ; RETURN |
---|
[3294] | 141 | ENDIF |
---|
| 142 | ENDIF |
---|
| 143 | ! |
---|
| 144 | ENDDO |
---|
| 145 | ! ! fill sf_trcdta with slf_i and control print |
---|
[7646] | 146 | CALL fld_fill( sf_trcdta, slf_i, cn_dir, 'trc_dta_ini', 'Passive tracer data', 'namtrc' ) |
---|
[3294] | 147 | ! |
---|
| 148 | ENDIF |
---|
| 149 | ! |
---|
[4230] | 150 | DEALLOCATE( slf_i ) ! deallocate local field structure |
---|
[3294] | 151 | ! |
---|
[7646] | 152 | END SUBROUTINE trc_dta_ini |
---|
[268] | 153 | |
---|
[493] | 154 | |
---|
[14086] | 155 | SUBROUTINE trc_dta( kt, kjl, ptrcdta) |
---|
[3294] | 156 | !!---------------------------------------------------------------------- |
---|
| 157 | !! *** ROUTINE trc_dta *** |
---|
| 158 | !! |
---|
| 159 | !! ** Purpose : provides passive tracer data at kt |
---|
| 160 | !! |
---|
| 161 | !! ** Method : - call fldread routine |
---|
| 162 | !! - s- or mixed z-s coordinate: vertical interpolation on model mesh |
---|
| 163 | !! - ln_trcdmp=F: deallocates the data structure as they are not used |
---|
| 164 | !! |
---|
[7646] | 165 | !! ** Action : sf_trcdta passive tracer data on meld mesh and interpolated at time-step kt |
---|
[3294] | 166 | !!---------------------------------------------------------------------- |
---|
[7646] | 167 | INTEGER , INTENT(in ) :: kt ! ocean time-step |
---|
[14086] | 168 | INTEGER , INTENT(in ) :: kjl ! tracer index |
---|
[7646] | 169 | REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout ) :: ptrcdta ! 3D data array |
---|
[3294] | 170 | ! |
---|
[4230] | 171 | INTEGER :: ji, jj, jk, jl, jkk, ik ! dummy loop indices |
---|
[3294] | 172 | REAL(wp):: zl, zi |
---|
| 173 | REAL(wp), DIMENSION(jpk) :: ztp ! 1D workspace |
---|
[6701] | 174 | CHARACTER(len=100) :: clndta |
---|
[3294] | 175 | !!---------------------------------------------------------------------- |
---|
| 176 | ! |
---|
[9124] | 177 | IF( ln_timing ) CALL timing_start('trc_dta') |
---|
[3294] | 178 | ! |
---|
[12377] | 179 | IF( kt == nit000 .AND. lwp) THEN |
---|
| 180 | WRITE(numout,*) |
---|
| 181 | WRITE(numout,*) 'trc_dta : passive tracers data for IC' |
---|
| 182 | WRITE(numout,*) '~~~~~~~ ' |
---|
| 183 | ENDIF |
---|
| 184 | ! |
---|
[3294] | 185 | IF( nb_trcdta > 0 ) THEN |
---|
| 186 | ! |
---|
[7646] | 187 | ! read data at kt time step |
---|
| 188 | CALL fld_read( kt, 1, sf_trcdta ) |
---|
[14086] | 189 | ptrcdta(:,:,:) = sf_trcdta(kjl)%fnow(:,:,:) * tmask(:,:,:) |
---|
[7646] | 190 | ! |
---|
[15446] | 191 | #if ! defined key_sed_off |
---|
[7646] | 192 | IF( ln_sco ) THEN !== s- or mixed s-zps-coordinate ==! |
---|
[3294] | 193 | ! |
---|
| 194 | IF( kt == nit000 .AND. lwp )THEN |
---|
| 195 | WRITE(numout,*) |
---|
| 196 | WRITE(numout,*) 'trc_dta: interpolates passive tracer data onto the s- or mixed s-z-coordinate mesh' |
---|
[268] | 197 | ENDIF |
---|
[14834] | 198 | DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) ! vertical interpolation of T & S |
---|
[12377] | 199 | DO jk = 1, jpk ! determines the intepolated T-S profiles at each (i,j) points |
---|
[14086] | 200 | zl = gdept_0(ji,jj,jk) |
---|
[12377] | 201 | IF( zl < gdept_1d(1 ) ) THEN ! above the first level of data |
---|
| 202 | ztp(jk) = ptrcdta(ji,jj,1) |
---|
| 203 | ELSEIF( zl > gdept_1d(jpk) ) THEN ! below the last level of data |
---|
| 204 | ztp(jk) = ptrcdta(ji,jj,jpkm1) |
---|
| 205 | ELSE ! inbetween : vertical interpolation between jkk & jkk+1 |
---|
[13237] | 206 | DO jkk = 1, jpkm1 ! when gdept_1d(jkk) < zl < gdept_1d(jkk+1) |
---|
[12377] | 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) = ptrcdta(ji,jj,jkk) + ( ptrcdta(ji,jj,jkk+1) - ptrcdta(ji,jj,jkk) ) * zi |
---|
| 210 | ENDIF |
---|
| 211 | END DO |
---|
| 212 | ENDIF |
---|
| 213 | END DO |
---|
| 214 | DO jk = 1, jpkm1 |
---|
| 215 | ptrcdta(ji,jj,jk) = ztp(jk) * tmask(ji,jj,jk) ! mask required for mixed zps-s-coord |
---|
| 216 | END DO |
---|
| 217 | ptrcdta(ji,jj,jpk) = 0._wp |
---|
| 218 | END_2D |
---|
[3294] | 219 | ! |
---|
| 220 | ELSE !== z- or zps- coordinate ==! |
---|
[7646] | 221 | ! zps-coordinate (partial steps) interpolation at the last ocean level |
---|
[14086] | 222 | IF( ln_zps ) THEN |
---|
[15446] | 223 | DO_2D( nn_hls, nn_hls, nn_hls, nn_hls ) |
---|
[14086] | 224 | ik = mbkt(ji,jj) |
---|
[15446] | 225 | IF( ik > 1 .AND. gdept_0(ji,jj,ik) < gdept_1d(ik) ) THEN |
---|
[14086] | 226 | zl = ( gdept_1d(ik) - gdept_0(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) ) |
---|
| 227 | ptrcdta(ji,jj,ik) = (1.-zl) * ptrcdta(ji,jj,ik) + zl * ptrcdta(ji,jj,ik-1) |
---|
| 228 | ENDIF |
---|
| 229 | ik = mikt(ji,jj) |
---|
| 230 | IF( ik > 1 ) THEN |
---|
| 231 | zl = ( gdept_0(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) ) |
---|
| 232 | ptrcdta(ji,jj,ik) = (1.-zl) * ptrcdta(ji,jj,ik) + zl * ptrcdta(ji,jj,ik+1) |
---|
| 233 | ENDIF |
---|
| 234 | END_2D |
---|
| 235 | ENDIF |
---|
[3294] | 236 | ! |
---|
| 237 | ENDIF |
---|
[15446] | 238 | #endif |
---|
[7646] | 239 | ! Scale by multiplicative factor |
---|
[14086] | 240 | ptrcdta(:,:,:) = ptrcdta(:,:,:) * rf_trfac(kjl) |
---|
[6701] | 241 | ! |
---|
[3294] | 242 | ENDIF |
---|
[4230] | 243 | ! |
---|
[9124] | 244 | IF( ln_timing ) CALL timing_stop('trc_dta') |
---|
[945] | 245 | ! |
---|
[1011] | 246 | END SUBROUTINE trc_dta |
---|
[6607] | 247 | |
---|
[268] | 248 | #else |
---|
| 249 | !!---------------------------------------------------------------------- |
---|
[945] | 250 | !! Dummy module NO 3D passive tracer data |
---|
[268] | 251 | !!---------------------------------------------------------------------- |
---|
| 252 | CONTAINS |
---|
[14086] | 253 | SUBROUTINE trc_dta( kt, kjl, ptrcdta) ! Empty routine |
---|
[1011] | 254 | WRITE(*,*) 'trc_dta: You should not have seen this print! error?', kt |
---|
| 255 | END SUBROUTINE trc_dta |
---|
[268] | 256 | #endif |
---|
[6140] | 257 | |
---|
[945] | 258 | !!====================================================================== |
---|
[268] | 259 | END MODULE trcdta |
---|