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.
tamtrj.F90 in branches/TAM_V3_0/NEMO/OPA_SRC/TAM – NEMO

source: branches/TAM_V3_0/NEMO/OPA_SRC/TAM/tamtrj.F90 @ 1946

Last change on this file since 1946 was 1946, checked in by rblod, 14 years ago

adjustement for TAM branch

File size: 6.9 KB
Line 
1MODULE tamtrj
2   !!======================================================================
3   !!                       ***  MODULE tamtrj  ***
4   !! Tangent and adjoint  trajectory interface: Write to file
5   !!                                    the model state trajectory
6   !!======================================================================
7   !!----------------------------------------------------------------------
8   !!   tam_trj_ini  : init: read the namelist
9   !!   tam_trj_wri  : Write out the model state trajectory
10   !!----------------------------------------------------------------------
11   !! * Modules used   
12   USE oce                ! Dynamics and active tracers defined in memory
13   USE sbc_oce            ! Ocean surface boundary conditions
14   USE zdf_oce            ! Vertical mixing variables
15#if defined key_zdfddm 
16   USE zdfddm, ONLY : &   ! Double diffusion mixing parameterization
17      & avs               ! Salinity vertical diffusivity coeff. at w-point
18#endif
19   USE ldftra_oce         ! Lateral tracer mixing coefficient defined in memory
20   USE ldfslp, ONLY : &   ! Slopes of neutral surfaces
21      & uslp, wslpi,  &   ! i_slope at U- and W-points
22      & vslp, wslpj       ! j-slope at V- and W-points
23   USE tradmp             ! Tracer damping
24   USE sol_oce, ONLY : &  ! Solver variables defined in memory
25      & gcx
26   USE in_out_manager, ONLY : &  ! I/O manager
27      & lwp,     &
28      & numout
29   USE daymod, ONLY : &
30      & ndastp
31   USE iom                 ! I/O module
32   USE zdfmxl, ONLY : &   ! mixed layer depth
33      & hmlp
34
35   IMPLICIT NONE
36
37   !! * Routine accessibility
38   PRIVATE
39   PUBLIC tam_trj_ini, &  !: Write out the background state
40      &   tam_trj_wri     !: Write out the background state
41
42   LOGICAL, PUBLIC :: & 
43      & ln_trjwri = .FALSE.   !: No output of the state trajectory fields
44
45   CHARACTER (LEN=40), PUBLIC, PARAMETER :: &
46      & c_asmtrj = 'tam_trajectory'                !: Filename for storing the
47                                                   !: reference trajectory
48   INTEGER, PUBLIC :: &         
49      & nittrjfrq         !: Frequency of trajectory output for 4D-VAR
50
51CONTAINS
52   SUBROUTINE tam_trj_ini
53      !!-----------------------------------------------------------------------
54      !!
55      !!                  ***  ROUTINE tam_trj_ini ***
56      !!
57      !! ** Purpose : initialize the model state trajectory
58      !!
59      !! ** Method  :
60      !!
61      !! ** Action  :
62      !!                   
63      !! References :
64      !!
65      !! History :
66      !!        ! 10-01 (A. Vidard)
67      !!-----------------------------------------------------------------------
68
69      IMPLICIT NONE
70
71      !! * Modules used
72      NAMELIST/namtam/ nittrjfrq, ln_trjwri
73
74      ln_trjwri = .FALSE.
75      nittrjfrq = 1
76
77      REWIND ( numnam )
78      READ   ( numnam, namtam )
79
80      ! Control print
81      IF(lwp) THEN
82         WRITE(numout,*)
83         WRITE(numout,*) 'tam_trj_ini : Trajectory handling:'
84         WRITE(numout,*) '~~~~~~~~~~~~'
85         WRITE(numout,*) '          Namelist namtam : set trajectory parameters'
86         WRITE(numout,*) '             Logical switch for writing out state trajectory         ', &
87            &            ' ln_trjwri = ', ln_trjwri
88         WRITE(numout,*) '             Frequency of trajectory output                          ', &
89            &            ' nittrjfrq = ', nittrjfrq
90      END IF
91   END SUBROUTINE tam_trj_ini
92   SUBROUTINE tam_trj_wri( kt )
93      !!-----------------------------------------------------------------------
94      !!
95      !!                  ***  ROUTINE tam_trj_wri ***
96      !!
97      !! ** Purpose : Write to file the model state trajectory
98      !!
99      !! ** Method  :
100      !!
101      !! ** Action  :
102      !!                   
103      !! References :
104      !!
105      !! History :
106      !!        ! 07-04 (A. Weaver)
107      !!        ! 09-03 (F. Vigilant) Add hmlp (zdfmxl) for no tracer nmldp=2
108      !!        ! 09-06 (F. Vigilant) special case when kt=nit000-1
109      !!        ! 09-07 (F. Vigilant) add computation of eiv at restart
110      !!        ! 10-01 (A. Vidard) asm_trj_wri->tam_trj_wri
111      !!-----------------------------------------------------------------------
112
113      !! * Arguments
114      INTEGER, INTENT( IN ) :: &
115         & kt                    ! Current time-step
116
117      !! * Local declarations
118      INTEGER :: &
119         & inum                  ! File unit number
120      INTEGER :: &
121         & it
122      CHARACTER (LEN=50) :: &
123         & cl_asmtrj
124      REAL(wp) :: &
125         & zdate            ! Date
126
127      !------------------------------------------------------------------------
128      ! Write a single file for each trajectory time step
129      !------------------------------------------------------------------------
130      IF ( ( MOD( kt - nit000 + 1, nittrjfrq ) == 0 ) .OR. &
131         & ( kt == nitend ) ) THEN
132         
133         it = kt - nit000 + 1
134
135         ! Define the output file       
136         WRITE(cl_asmtrj, FMT='(A,A,I5.5)' ) TRIM( c_asmtrj ), '_', it
137         cl_asmtrj = TRIM( cl_asmtrj )
138         CALL iom_open( cl_asmtrj, inum, ldwrt = .TRUE., kiolib = jprstlib)
139
140         ! Output trajectory fields
141         CALL iom_rstput( it, it, inum, 'emp'   , emp    )
142         CALL iom_rstput( it, it, inum, 'emps'  , emps   )
143         CALL iom_rstput( it, it, inum, 'un'    , un     )
144         CALL iom_rstput( it, it, inum, 'vn'    , vn     )
145         CALL iom_rstput( it, it, inum, 'tn'    , tn     )
146         CALL iom_rstput( it, it, inum, 'sn'    , sn     )
147         CALL iom_rstput( it, it, inum, 'avmu'  , avmu   )
148         CALL iom_rstput( it, it, inum, 'avmv'  , avmv   )
149         CALL iom_rstput( it, it, inum, 'avt'   , avt    )
150#if defined key_ldfslp
151         CALL iom_rstput( it, it, inum, 'uslp'  , uslp   )
152         CALL iom_rstput( it, it, inum, 'vslp'  , vslp   )
153         CALL iom_rstput( it, it, inum, 'wslpi' , wslpi  )
154         CALL iom_rstput( it, it, inum, 'wslpj' , wslpj  )
155#endif
156#if defined key_zdfddm
157         CALL iom_rstput( it, it, inum, 'avs'   , avs    )
158#endif
159    IF ( kt == nit000 -1 ) THEN
160            ! ta, sa not available at restart
161            ! but need to ensure non-zero values due to subsequent interpolation
162            ! issue should be solved with next version of IOM (current 3.0)
163            CALL iom_rstput( it, it, inum, 'ta'    , tn     )
164            CALL iom_rstput( it, it, inum, 'sa'    , sn     )
165         ELSE
166            CALL iom_rstput( it, it, inum, 'ta'    , ta     )
167            CALL iom_rstput( it, it, inum, 'sa'    , sa     )
168         ENDIF
169         CALL iom_rstput( it, it, inum, 'tb'    , tb     )
170         CALL iom_rstput( it, it, inum, 'sb'    , sb     )
171#if defined key_tradmp
172         CALL iom_rstput( it, it, inum, 'hmlp'  , hmlp   )
173#endif
174         CALL iom_rstput( it, it, inum, 'aeiu'  , aeiu   )
175         CALL iom_rstput( it, it, inum, 'aeiv'  , aeiv   )
176         CALL iom_rstput( it, it, inum, 'aeiw'  , aeiw   )
177
178         CALL iom_close( inum )
179         
180      ENDIF
181
182   END SUBROUTINE tam_trj_wri
183END MODULE tamtrj
Note: See TracBrowser for help on using the repository browser.