[3764] | 1 | MODULE asmbkg |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE asmtrj -> asmbkg *** |
---|
| 4 | !! Assimilation trajectory interface: Write to file the background state and the model state trajectory |
---|
| 5 | !!====================================================================== |
---|
| 6 | !! History : ! 2007-03 (M. Martin) Met. Office version |
---|
| 7 | !! ! 2007-04 (A. Weaver) asm_trj_wri, original code |
---|
| 8 | !! ! 2007-03 (K. Mogensen) Adapt to NEMOVAR and use IOM instead of IOIPSL |
---|
| 9 | !! ! 2007-04 (A. Weaver) Name change (formally asmbkg.F90). Distinguish |
---|
| 10 | !! background states in Jb term and at analysis time. |
---|
| 11 | !! Include state trajectory routine (currently empty) |
---|
| 12 | !! ! 2007-07 (A. Weaver) Add tke_rst and flt_rst for case nitbkg=0 |
---|
| 13 | !! ! 2009-03 (F. Vigilant) Add hmlp (zdfmxl) for no tracer nmldp=2 |
---|
| 14 | !! ! 2009-06 (F. Vigilant) asm_trj_wri: special case when kt=nit000-1 |
---|
| 15 | !! ! 2009-07 (F. Vigilant) asm_trj_wri: add computation of eiv at restart |
---|
| 16 | !! ! 2010-01 (A. Vidard) split asm_trj_wri into tam_trj_wri and asm_bkg_wri |
---|
| 17 | !!---------------------------------------------------------------------- |
---|
| 18 | |
---|
| 19 | !!---------------------------------------------------------------------- |
---|
| 20 | !! 'key_asminc' : Switch on the assimilation increment interface |
---|
| 21 | !!---------------------------------------------------------------------- |
---|
| 22 | !! asm_bkg_wri : Write out the background state |
---|
| 23 | !! asm_trj_wri : Write out the model state trajectory (used with 4D-Var) |
---|
| 24 | !!---------------------------------------------------------------------- |
---|
| 25 | USE oce ! Dynamics and active tracers defined in memory |
---|
| 26 | USE sbc_oce ! Ocean surface boundary conditions |
---|
| 27 | USE zdf_oce ! Vertical mixing variables |
---|
| 28 | USE zdfddm ! Double diffusion mixing parameterization |
---|
| 29 | USE ldftra_oce ! Lateral tracer mixing coefficient defined in memory |
---|
| 30 | USE ldfslp ! Slopes of neutral surfaces |
---|
| 31 | USE tradmp ! Tracer damping |
---|
| 32 | #if defined key_zdftke |
---|
| 33 | USE zdftke ! TKE vertical physics |
---|
| 34 | #endif |
---|
| 35 | USE eosbn2 ! Equation of state (eos_bn2 routine) |
---|
| 36 | USE zdfmxl ! Mixed layer depth |
---|
| 37 | USE dom_oce, ONLY : ndastp |
---|
| 38 | USE sol_oce, ONLY : gcx ! Solver variables defined in memory |
---|
| 39 | USE in_out_manager ! I/O manager |
---|
| 40 | USE iom ! I/O module |
---|
| 41 | USE asmpar ! Parameters for the assmilation interface |
---|
| 42 | USE zdfmxl ! mixed layer depth |
---|
| 43 | #if defined key_traldf_c2d |
---|
| 44 | USE ldfeiv ! eddy induced velocity coef. (ldf_eiv routine) |
---|
| 45 | #endif |
---|
| 46 | #if defined key_lim2 |
---|
| 47 | USE ice_2 |
---|
| 48 | #endif |
---|
| 49 | #if defined key_lim3 |
---|
| 50 | USE ice |
---|
| 51 | #endif |
---|
| 52 | IMPLICIT NONE |
---|
| 53 | PRIVATE |
---|
| 54 | |
---|
| 55 | PUBLIC asm_bkg_wri !: Write out the background state |
---|
| 56 | |
---|
| 57 | !!---------------------------------------------------------------------- |
---|
| 58 | !! NEMO/OPA 3.3 , NEMO Consortium (2010) |
---|
| 59 | !! $Id: $ |
---|
| 60 | !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) |
---|
| 61 | !!---------------------------------------------------------------------- |
---|
| 62 | CONTAINS |
---|
| 63 | |
---|
| 64 | SUBROUTINE asm_bkg_wri( kt ) |
---|
| 65 | !!----------------------------------------------------------------------- |
---|
| 66 | !! *** ROUTINE asm_bkg_wri *** |
---|
| 67 | !! |
---|
| 68 | !! ** Purpose : Write to file the background state for later use in the |
---|
| 69 | !! inner loop of data assimilation or for direct initialization |
---|
| 70 | !! in the outer loop. |
---|
| 71 | !! |
---|
| 72 | !! ** Method : Write out the background state for use in the Jb term |
---|
| 73 | !! in the cost function and for use with direct initialization |
---|
| 74 | !! at analysis time. |
---|
| 75 | !!----------------------------------------------------------------------- |
---|
| 76 | INTEGER, INTENT( IN ) :: kt ! Current time-step |
---|
| 77 | ! |
---|
| 78 | CHARACTER (LEN=50) :: cl_asmbkg |
---|
| 79 | CHARACTER (LEN=50) :: cl_asmdin |
---|
| 80 | LOGICAL :: llok ! Check if file exists |
---|
| 81 | INTEGER :: inum ! File unit number |
---|
| 82 | REAL(wp) :: zdate ! Date |
---|
| 83 | !!----------------------------------------------------------------------- |
---|
| 84 | |
---|
| 85 | ! !------------------------------------------- |
---|
| 86 | IF( kt == nitbkg_r ) THEN ! Write out background at time step nitbkg_r |
---|
| 87 | ! !-----------------------------------======== |
---|
| 88 | ! |
---|
| 89 | WRITE(cl_asmbkg, FMT='(A,".nc")' ) TRIM( c_asmbkg ) |
---|
| 90 | cl_asmbkg = TRIM( cl_asmbkg ) |
---|
| 91 | INQUIRE( FILE = cl_asmbkg, EXIST = llok ) |
---|
| 92 | ! |
---|
| 93 | IF( .NOT. llok ) THEN |
---|
| 94 | IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmbkg ) |
---|
| 95 | ! |
---|
| 96 | ! ! Define the output file |
---|
| 97 | CALL iom_open( c_asmbkg, inum, ldwrt = .TRUE., kiolib = jprstlib) |
---|
| 98 | ! |
---|
| 99 | IF( nitbkg_r == nit000 - 1 ) THEN ! Treat special case when nitbkg = 0 |
---|
| 100 | zdate = REAL( ndastp ) |
---|
| 101 | #if defined key_zdftke |
---|
| 102 | ! lk_zdftke=T : Read turbulent kinetic energy ( en ) |
---|
| 103 | IF(lwp) WRITE(numout,*) ' Reading TKE (en) from restart...' |
---|
| 104 | CALL tke_rst( nit000, 'READ' ) ! lk_zdftke=T : Read turbulent kinetic energy ( en ) |
---|
| 105 | |
---|
| 106 | #endif |
---|
| 107 | ELSE |
---|
| 108 | zdate = REAL( ndastp ) |
---|
| 109 | ENDIF |
---|
| 110 | ! |
---|
| 111 | ! ! Write the information |
---|
| 112 | CALL iom_rstput( kt, nitbkg_r, inum, 'rdastp' , zdate ) |
---|
| 113 | CALL iom_rstput( kt, nitbkg_r, inum, 'un' , un ) |
---|
| 114 | CALL iom_rstput( kt, nitbkg_r, inum, 'vn' , vn ) |
---|
| 115 | CALL iom_rstput( kt, nitbkg_r, inum, 'tn' , tsn(:,:,:,jp_tem) ) |
---|
| 116 | CALL iom_rstput( kt, nitbkg_r, inum, 'sn' , tsn(:,:,:,jp_sal) ) |
---|
| 117 | CALL iom_rstput( kt, nitbkg_r, inum, 'sshn' , sshn ) |
---|
| 118 | #if defined key_zdftke |
---|
| 119 | CALL iom_rstput( kt, nitbkg_r, inum, 'en' , en ) |
---|
| 120 | #endif |
---|
| 121 | CALL iom_rstput( kt, nitbkg_r, inum, 'gcx' , gcx ) |
---|
| 122 | ! |
---|
| 123 | CALL iom_close( inum ) |
---|
| 124 | ENDIF |
---|
| 125 | ! |
---|
| 126 | ENDIF |
---|
| 127 | |
---|
| 128 | ! !------------------------------------------- |
---|
| 129 | IF( kt == nitdin_r ) THEN ! Write out background at time step nitdin_r |
---|
| 130 | ! !-----------------------------------======== |
---|
| 131 | ! |
---|
| 132 | WRITE(cl_asmdin, FMT='(A,".nc")' ) TRIM( c_asmdin ) |
---|
| 133 | cl_asmdin = TRIM( cl_asmdin ) |
---|
| 134 | INQUIRE( FILE = cl_asmdin, EXIST = llok ) |
---|
| 135 | ! |
---|
| 136 | IF( .NOT. llok ) THEN |
---|
| 137 | IF(lwp) WRITE(numout,*) ' Setting up assimilation background file '// TRIM( c_asmdin ) |
---|
| 138 | ! |
---|
| 139 | ! ! Define the output file |
---|
| 140 | CALL iom_open( c_asmdin, inum, ldwrt = .TRUE., kiolib = jprstlib) |
---|
| 141 | ! |
---|
| 142 | IF( nitdin_r == nit000 - 1 ) THEN ! Treat special case when nitbkg = 0 |
---|
| 143 | |
---|
| 144 | zdate = REAL( ndastp ) |
---|
| 145 | ELSE |
---|
| 146 | zdate = REAL( ndastp ) |
---|
| 147 | ENDIF |
---|
| 148 | ! |
---|
| 149 | ! ! Write the information |
---|
| 150 | CALL iom_rstput( kt, nitdin_r, inum, 'rdastp' , zdate ) |
---|
| 151 | CALL iom_rstput( kt, nitdin_r, inum, 'un' , un ) |
---|
| 152 | CALL iom_rstput( kt, nitdin_r, inum, 'vn' , vn ) |
---|
| 153 | CALL iom_rstput( kt, nitdin_r, inum, 'tn' , tsn(:,:,:,jp_tem) ) |
---|
| 154 | CALL iom_rstput( kt, nitdin_r, inum, 'sn' , tsn(:,:,:,jp_sal) ) |
---|
| 155 | CALL iom_rstput( kt, nitdin_r, inum, 'sshn' , sshn ) |
---|
| 156 | #if defined key_lim2 || defined key_lim3 |
---|
| 157 | IF(( nn_ice == 2 ) .OR. ( nn_ice == 3 )) THEN |
---|
[5034] | 158 | IF(ALLOCATED(frld)) THEN |
---|
| 159 | CALL iom_rstput( kt, nitdin_r, inum, 'iceconc', 1.0 - frld(:,:) ) |
---|
| 160 | ELSE |
---|
| 161 | CALL ctl_warn('Ice concentration not written to background as ice variable frld not allocated on this timestep') |
---|
| 162 | ENDIF |
---|
[3764] | 163 | ENDIF |
---|
| 164 | #endif |
---|
| 165 | ! |
---|
| 166 | CALL iom_close( inum ) |
---|
| 167 | ENDIF |
---|
| 168 | ! |
---|
| 169 | ENDIF |
---|
| 170 | ! |
---|
| 171 | END SUBROUTINE asm_bkg_wri |
---|
| 172 | |
---|
| 173 | !!====================================================================== |
---|
| 174 | END MODULE asmbkg |
---|