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