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