New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
trcdta.F90 in trunk/NEMO/TOP_SRC – NEMO

source: trunk/NEMO/TOP_SRC/trcdta.F90 @ 1796

Last change on this file since 1796 was 1796, checked in by cetlod, 14 years ago

correction of trcdta.F90 routine, see ticket:639

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.8 KB
Line 
1MODULE trcdta
2   !!======================================================================
3   !!                     ***  MODULE  trcdta  ***
4   !! TOP :  reads passive tracer data
5   !!=====================================================================
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
9   !!----------------------------------------------------------------------
10#if  defined key_top  &&  defined key_dtatrc
11   !!----------------------------------------------------------------------
12   !!   'key_top'  and  'key_dtatrc'        TOP model + passive tracer data
13   !!----------------------------------------------------------------------
14   !!   trc_dta      : read ocean passive tracer data
15   !!----------------------------------------------------------------------
16   USE oce_trc
17   USE par_trc
18   USE trc
19   USE lib_print
20   USE iom
21
22   IMPLICIT NONE
23   PRIVATE
24
25   PUBLIC trc_dta   ! called in trcini.F90 and trcdmp.F90
26
27   REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk,jptra) ::   trdta   !: tracer data at given time-step
28
29   REAL(wp), DIMENSION(jpi,jpj,jpk,jptra,2) ::   tracdta            ! tracer data at two consecutive times
30   INTEGER , DIMENSION(jptra) ::   nlectr      !: switch for reading once
31   INTEGER , DIMENSION(jptra) ::   ntrc1       !: number of first month when reading 12 monthly value
32   INTEGER , DIMENSION(jptra) ::   ntrc2       !: number of second month when reading 12 monthly value
33
34   !! * Substitutions
35#  include "top_substitute.h90"
36   !!----------------------------------------------------------------------
37   !! NEMO/TOP 1.0 , LOCEAN-IPSL (2005)
38   !! $Id$
39   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
40   !!----------------------------------------------------------------------
41
42CONTAINS
43
44   !!----------------------------------------------------------------------
45   !!   Default case                                            NetCDF file
46   !!----------------------------------------------------------------------
47   
48   SUBROUTINE trc_dta( kt )
49      !!----------------------------------------------------------------------
50      !!                   ***  ROUTINE trc_dta  ***
51      !!
52      !! ** Purpose :   Reads passive tracer data (Levitus monthly data)
53      !!
54      !! ** Method  :   Read on unit numtr the interpolated tracer concentra-
55      !!      tion onto the global grid. Data begin at january.
56      !!      The value is centered at the middle of month.
57      !!      In the opa model, kt=1 agree with january 1.
58      !!      At each time step, a linear interpolation is applied between
59      !!      two monthly values.
60      !!----------------------------------------------------------------------
61      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
62      !!
63      CHARACTER (len=39) ::   clname(jptra)
64      INTEGER, PARAMETER ::   &
65         jpmonth = 12    ! number of months
66      INTEGER ::   ji, jj, jn, jl 
67      INTEGER ::   imois, iman, i15, ik  ! temporary integers
68      REAL(wp) ::   zxy, zl
69      !!----------------------------------------------------------------------
70
71      DO jn = 1, jptra
72
73         IF( lutini(jn) ) THEN
74
75            IF ( kt == nittrc000 ) THEN
76               !! 3D tracer data
77               IF(lwp)WRITE(numout,*)
78               IF(lwp)WRITE(numout,*) ' dta_trc: reading tracer' 
79               IF(lwp)WRITE(numout,*) ' data file ', jn, ctrcnm(jn)
80               IF(lwp)WRITE(numout,*)
81               nlectr(jn) = 0
82            ENDIF
83            ! Initialization
84            iman = jpmois
85            i15  = nday / 16
86            imois = nmonth + i15 -1
87            IF( imois == 0 ) imois = iman
88
89
90            ! First call kt=nit000
91            ! --------------------
92
93            IF ( kt == nittrc000 .AND. nlectr(jn) == 0 ) THEN
94               ntrc1(jn) = 0
95               IF(lwp) WRITE(numout,*) ' trc_dta : Levitus tracer data monthly fields'
96               ! open file
97# if defined key_pisces
98               clname(jn) = 'data_1m_'//TRIM(ctrcnm(jn))//'_nomask'
99# else
100               clname(jn) = TRIM(ctrcnm(jn))
101# endif
102               CALL iom_open ( clname(jn), numtr(jn) )             
103
104            ENDIF
105
106# if defined key_pisces
107            ! Read montly file
108            IF( ( kt == nittrc000 .AND. nlectr(jn) == 0)  .OR. imois /= ntrc1(jn) ) THEN
109               nlectr(jn) = 1
110
111               ! Calendar computation
112
113               ! ntrc1 number of the first file record used in the simulation
114               ! ntrc2 number of the last  file record
115
116               ntrc1(jn) = imois
117               ntrc2(jn) = ntrc1(jn) + 1
118               ntrc1(jn) = MOD( ntrc1(jn), iman )
119               IF ( ntrc1(jn) == 0 ) ntrc1(jn) = iman
120               ntrc2(jn) = MOD( ntrc2(jn), iman )
121               IF ( ntrc2(jn) == 0 ) ntrc2(jn) = iman
122               IF(lwp) WRITE(numout,*) 'first record file used ntrc1 ', ntrc1(jn) 
123               IF(lwp) WRITE(numout,*) 'last  record file used ntrc2 ', ntrc2(jn)
124
125               ! Read montly passive tracer data Levitus
126
127               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), tracdta(:,:,:,jn,1), ntrc1(jn) )
128               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), tracdta(:,:,:,jn,2), ntrc2(jn) )
129
130               IF(lwp) THEN
131                  WRITE(numout,*)
132                  WRITE(numout,*) ' read tracer data ', ctrcnm(jn),' ok'
133                  WRITE(numout,*)
134               ENDIF
135
136               ! Apply Mask
137               DO jl = 1, 2
138                  tracdta(:,:,:  ,jn,jl) = tracdta(:,:,:,jn,jl) * tmask(:,:,:) 
139                  tracdta(:,:,jpk,jn,jl) = 0.
140                  IF( ln_zps ) THEN                ! z-coord. with partial steps
141                     DO jj = 1, jpj                ! interpolation of temperature at the last level
142                        DO ji = 1, jpi
143                           ik = mbathy(ji,jj) - 1
144                           IF( ik > 2 ) THEN
145                              zl = ( gdept_0(ik) - fsdept_0(ji,jj,ik) ) / ( gdept_0(ik) - gdept_0(ik-1) )
146                              tracdta(ji,jj,ik,jn,jl) = (1.-zl) * tracdta(ji,jj,ik  ,jn,jl)    &
147                                 &                    +     zl  * tracdta(ji,jj,ik-1,jn,jl)
148                           ENDIF
149                        END DO
150                     END DO
151                  ENDIF
152
153               END DO
154
155            ENDIF
156
157            IF(lwp) THEN
158               WRITE(numout,*) ctrcnm(jn), 'Levitus month ', ntrc1(jn), ntrc2(jn)
159               WRITE(numout,*)
160               WRITE(numout,*) ' Levitus month = ', ntrc1(jn), '  level = 1'
161               CALL prihre( tracdta(1,1,1,jn,1), jpi, jpj, 1, jpi, 20, 1   &
162                  &        ,jpj, 20, 1., numout )
163               WRITE(numout,*) ' Levitus month = ', ntrc1(jn), '  level = ',jpk/2
164               CALL prihre( tracdta(1,1,jpk/2,jn,1), jpi, jpj, 1, jpi,    &
165                  &         20, 1, jpj, 20, 1., numout )
166               WRITE(numout,*) ' Levitus month = ',ntrc1(jn),'  level = ',jpkm1
167               CALL prihre( tracdta(1,1,jpkm1,jn,1), jpi, jpj, 1, jpi,     &
168                  &         20, 1, jpj, 20, 1., numout )
169            ENDIF
170
171            ! At every time step compute temperature data
172            zxy = FLOAT( nday + 15 - 30 * i15 ) / 30.
173            trdta(:,:,:,jn) =  ( 1. - zxy ) * tracdta(:,:,:,jn,1)    &
174               &              +       zxy   * tracdta(:,:,:,jn,2) 
175
176            IF( jn == jpno3 )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   7.6e-6
177            IF( jn == jpdic )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
178            IF( jn == jptal )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
179            IF( jn == jpoxy )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *  44.6e-6
180            IF( jn == jpsil )   trdta(:,:,:,jn) = trdta(:,:,:,jn) *   1.0e-6
181            IF( jn == jppo4 )   trdta(:,:,:,jn) = trdta(:,:,:,jn) * 122.0e-6
182
183            ! Close the file
184            ! --------------
185           
186            IF( kt == nitend )   CALL iom_close( numtr(jn) )
187
188# else
189            ! Read init file only
190            IF( kt == nittrc000  ) THEN
191               ntrc1(jn) = 1
192               CALL iom_get ( numtr(jn), jpdom_data, ctrcnm(jn), trdta(:,:,:,jn), ntrc1(jn) )
193               trdta(:,:,:,jn) = trdta(:,:,:,jn) * tmask(:,:,:)
194               CALL iom_close ( numtr(jn) )
195            ENDIF 
196# endif
197
198         ENDIF
199
200      END DO
201      !
202   END SUBROUTINE trc_dta
203
204#else
205   !!----------------------------------------------------------------------
206   !!   Dummy module                              NO 3D passive tracer data
207   !!----------------------------------------------------------------------
208CONTAINS
209   SUBROUTINE trc_dta( kt )        ! Empty routine
210      WRITE(*,*) 'trc_dta: You should not have seen this print! error?', kt
211   END SUBROUTINE trc_dta
212#endif
213
214   !!======================================================================
215END MODULE trcdta
Note: See TracBrowser for help on using the repository browser.