1 | MODULE ablrst |
---|
2 | !!====================================================================== |
---|
3 | !! *** MODULE ablrst *** |
---|
4 | !! abl : write/read the abl restart file |
---|
5 | !!====================================================================== |
---|
6 | !! History: 4.0 ! 2018 (some people) ABL |
---|
7 | !!---------------------------------------------------------------------- |
---|
8 | !! abl_rst_opn : open restart file |
---|
9 | !! abl_rst_write : write restart file |
---|
10 | !! abl_rst_read : read restart file |
---|
11 | !!---------------------------------------------------------------------- |
---|
12 | USE abl ! abl variables |
---|
13 | USE par_abl ! abl parameters |
---|
14 | USE dom_oce ! ocean domain |
---|
15 | USE sbc_oce , ONLY : nn_fsbc, jpka |
---|
16 | ! |
---|
17 | USE in_out_manager ! I/O manager |
---|
18 | USE iom ! I/O manager library |
---|
19 | USE lib_mpp ! MPP library |
---|
20 | USE lib_fortran ! fortran utilities (glob_sum + no signed zero) |
---|
21 | |
---|
22 | IMPLICIT NONE |
---|
23 | PRIVATE |
---|
24 | |
---|
25 | PUBLIC abl_rst_opn ! called by ablstp |
---|
26 | PUBLIC abl_rst_write ! called by ablstp |
---|
27 | PUBLIC abl_rst_read ! called by abl_init |
---|
28 | |
---|
29 | !!---------------------------------------------------------------------- |
---|
30 | !! NEMO/ABL 4.0 , NEMO Consortium (2018) |
---|
31 | !! $Id: ablrst.F90 11413 2019-08-06 15:59:22Z gsamson $ |
---|
32 | !! Software governed by the CeCILL license (see ./LICENSE) |
---|
33 | !!---------------------------------------------------------------------- |
---|
34 | CONTAINS |
---|
35 | |
---|
36 | SUBROUTINE abl_rst_opn( kt ) |
---|
37 | !!---------------------------------------------------------------------- |
---|
38 | !! *** abl_rst_opn *** |
---|
39 | !! |
---|
40 | !! ** purpose : open restart file |
---|
41 | !!---------------------------------------------------------------------- |
---|
42 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
43 | ! |
---|
44 | CHARACTER(len=20) :: clkt ! ocean time-step define as a character |
---|
45 | CHARACTER(len=50) :: clname ! abl output restart file name |
---|
46 | CHARACTER(len=256) :: clpath ! full path to abl output restart file |
---|
47 | !!---------------------------------------------------------------------- |
---|
48 | ! |
---|
49 | IF( kt == nit000 ) lrst_abl = .FALSE. ! default definition |
---|
50 | |
---|
51 | IF( ln_rst_list .OR. nn_stock /= -1 ) THEN |
---|
52 | ! in order to get better performances with NetCDF format, we open and define the abl restart file |
---|
53 | ! one abl time step before writing the data (-> at nitrst - 2*nn_fsbc + 1), except if we write abl |
---|
54 | ! restart files every abl time step or if an abl restart file was writen at nitend - 2*nn_fsbc + 1 |
---|
55 | IF( kt == nitrst - 2*nn_fsbc + 1 .OR. nn_stock == nn_fsbc & |
---|
56 | & .OR. ( kt == nitend - nn_fsbc + 1 .AND. .NOT. lrst_abl ) ) THEN |
---|
57 | IF( nitrst <= nitend .AND. nitrst > 0 ) THEN |
---|
58 | ! beware of the format used to write kt (default is i8.8, that should be large enough...) |
---|
59 | IF( nitrst > 99999999 ) THEN ; WRITE(clkt, * ) nitrst |
---|
60 | ELSE ; WRITE(clkt, '(i8.8)') nitrst |
---|
61 | ENDIF |
---|
62 | ! create the file |
---|
63 | clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ablrst_out) |
---|
64 | clpath = TRIM(cn_ablrst_outdir) |
---|
65 | IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath)//'/' |
---|
66 | IF(lwp) THEN |
---|
67 | WRITE(numout,*) |
---|
68 | WRITE(numout,*) ' open abl restart NetCDF file: ',TRIM(clpath)//clname |
---|
69 | IF( kt == nitrst - 2*nn_fsbc + 1 ) THEN |
---|
70 | WRITE(numout,*) ' kt = nitrst - 2*nn_fsbc + 1 = ', kt,' date= ', ndastp |
---|
71 | ELSE |
---|
72 | WRITE(numout,*) ' kt = ' , kt,' date= ', ndastp |
---|
73 | ENDIF |
---|
74 | ENDIF |
---|
75 | ! |
---|
76 | CALL iom_open( TRIM(clpath)//TRIM(clname), numraw, ldwrt = .TRUE., kdlev = jpka, cdcomp = 'ABL' ) |
---|
77 | lrst_abl = .TRUE. |
---|
78 | ENDIF |
---|
79 | ENDIF |
---|
80 | ENDIF |
---|
81 | ! |
---|
82 | END SUBROUTINE abl_rst_opn |
---|
83 | |
---|
84 | |
---|
85 | SUBROUTINE abl_rst_write( kt ) |
---|
86 | !!---------------------------------------------------------------------- |
---|
87 | !! *** abl_rst_write *** |
---|
88 | !! |
---|
89 | !! ** purpose : write restart file |
---|
90 | !!---------------------------------------------------------------------- |
---|
91 | INTEGER, INTENT(in) :: kt ! number of iteration |
---|
92 | !! |
---|
93 | INTEGER :: iter |
---|
94 | !!---------------------------------------------------------------------- |
---|
95 | |
---|
96 | iter = kt + nn_fsbc - 1 ! abl restarts are written at kt == nitrst - nn_fsbc + 1 |
---|
97 | |
---|
98 | IF( iter == nitrst ) THEN |
---|
99 | IF(lwp) WRITE(numout,*) |
---|
100 | IF(lwp) WRITE(numout,*) 'abl_rst_write : write abl restart file kt =', kt |
---|
101 | IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~' |
---|
102 | ENDIF |
---|
103 | |
---|
104 | ! Write in numraw (if iter == nitrst) |
---|
105 | ! ------------------ |
---|
106 | ! ! calendar control |
---|
107 | CALL iom_rstput( iter, nitrst, numraw, 'nn_fsbc', REAL( nn_fsbc, wp ) ) ! time-step |
---|
108 | CALL iom_rstput( iter, nitrst, numraw, 'kt_abl' , REAL( iter , wp ) ) ! date |
---|
109 | CALL iom_delay_rst( 'WRITE', 'ABL', numraw ) ! save only abl delayed global communication variables |
---|
110 | |
---|
111 | ! Prognostic (after timestep + swap time indices = now timestep) variables |
---|
112 | CALL iom_rstput( iter, nitrst, numraw, 'u_abl', u_abl(:,:,:,nt_n ) ) |
---|
113 | CALL iom_rstput( iter, nitrst, numraw, 'v_abl', v_abl(:,:,:,nt_n ) ) |
---|
114 | CALL iom_rstput( iter, nitrst, numraw, 't_abl', tq_abl(:,:,:,nt_n,jp_ta) ) |
---|
115 | CALL iom_rstput( iter, nitrst, numraw, 'q_abl', tq_abl(:,:,:,nt_n,jp_qa) ) |
---|
116 | CALL iom_rstput( iter, nitrst, numraw, 'tke_abl', tke_abl(:,:,:,nt_n ) ) |
---|
117 | CALL iom_rstput( iter, nitrst, numraw, 'avm_abl', avm_abl(:,:,: ) ) |
---|
118 | CALL iom_rstput( iter, nitrst, numraw, 'avt_abl', avt_abl(:,:,: ) ) |
---|
119 | CALL iom_rstput( iter, nitrst, numraw,'mxld_abl',mxld_abl(:,:,: ) ) |
---|
120 | CALL iom_rstput( iter, nitrst, numraw, 'pblh', pblh(:,: ) ) |
---|
121 | ! |
---|
122 | |
---|
123 | ! close restart file |
---|
124 | ! ------------------ |
---|
125 | IF( iter == nitrst ) THEN |
---|
126 | CALL iom_close( numraw ) |
---|
127 | lrst_abl = .FALSE. |
---|
128 | ENDIF |
---|
129 | ! |
---|
130 | END SUBROUTINE abl_rst_write |
---|
131 | |
---|
132 | |
---|
133 | SUBROUTINE abl_rst_read |
---|
134 | !!---------------------------------------------------------------------- |
---|
135 | !! *** abl_rst_read *** |
---|
136 | !! |
---|
137 | !! ** purpose : read restart file |
---|
138 | !!---------------------------------------------------------------------- |
---|
139 | REAL(wp) :: zfabl, ziter |
---|
140 | !!---------------------------------------------------------------------- |
---|
141 | |
---|
142 | IF(lwp) THEN |
---|
143 | WRITE(numout,*) |
---|
144 | WRITE(numout,*) 'abl_rst_read: read abl NetCDF restart file' |
---|
145 | WRITE(numout,*) '~~~~~~~~~~~~' |
---|
146 | ENDIF |
---|
147 | |
---|
148 | CALL iom_open ( TRIM(cn_ablrst_indir)//'/'//cn_ablrst_in, numrar ) |
---|
149 | |
---|
150 | ! Time info |
---|
151 | CALL iom_get( numrar, 'nn_fsbc', zfabl ) |
---|
152 | CALL iom_get( numrar, 'kt_abl' , ziter ) |
---|
153 | IF(lwp) WRITE(numout,*) ' read abl restart file at time step : ', ziter |
---|
154 | IF(lwp) WRITE(numout,*) ' in any case we force it to nit000 - 1 : ', nit000 - 1 |
---|
155 | |
---|
156 | ! Control of date |
---|
157 | IF( ( nit000 - NINT(ziter) ) /= 1 .AND. ABS( nrstdt ) == 1 ) & |
---|
158 | & CALL ctl_stop( 'abl_rst_read ===>>>> : problem with nit000 in abl restart', & |
---|
159 | & ' verify the file or rerun with the value 0 for the', & |
---|
160 | & ' control of time parameter nrstdt' ) |
---|
161 | IF( NINT(zfabl) /= nn_fsbc .AND. ABS( nrstdt ) == 1 ) & |
---|
162 | & CALL ctl_stop( 'abl_rst_read ===>>>> : problem with nn_fsbc in abl restart', & |
---|
163 | & ' verify the file or rerun with the value 0 for the', & |
---|
164 | & ' control of time parameter nrstdt' ) |
---|
165 | |
---|
166 | ! --- mandatory fields --- ! |
---|
167 | CALL iom_get( numrar, jpdom_auto, 'u_abl', u_abl(:,:,:,nt_n ), cd_type = 'U', psgn = -1._wp ) |
---|
168 | CALL iom_get( numrar, jpdom_auto, 'v_abl', v_abl(:,:,:,nt_n ), cd_type = 'V', psgn = -1._wp ) |
---|
169 | CALL iom_get( numrar, jpdom_auto, 't_abl', tq_abl(:,:,:,nt_n,jp_ta) ) |
---|
170 | CALL iom_get( numrar, jpdom_auto, 'q_abl', tq_abl(:,:,:,nt_n,jp_qa) ) |
---|
171 | CALL iom_get( numrar, jpdom_auto, 'tke_abl', tke_abl(:,:,:,nt_n ) ) |
---|
172 | CALL iom_get( numrar, jpdom_auto, 'avm_abl', avm_abl(:,:,: ) ) |
---|
173 | CALL iom_get( numrar, jpdom_auto, 'avt_abl', avt_abl(:,:,: ) ) |
---|
174 | CALL iom_get( numrar, jpdom_auto,'mxld_abl',mxld_abl(:,:,: ) ) |
---|
175 | CALL iom_get( numrar, jpdom_auto, 'pblh', pblh(:,: ) ) |
---|
176 | CALL iom_delay_rst( 'READ', 'ABL', numrar ) ! read only abl delayed global communication variables |
---|
177 | |
---|
178 | END SUBROUTINE abl_rst_read |
---|
179 | |
---|
180 | |
---|
181 | !!====================================================================== |
---|
182 | END MODULE ablrst |
---|