[5118] | 1 | SUBROUTINE dynredem0_loc(fichnom, iday_end, phis) |
---|
[5099] | 2 | |
---|
[5118] | 3 | !------------------------------------------------------------------------------- |
---|
| 4 | ! Write the NetCDF restart file (initialization). |
---|
| 5 | !------------------------------------------------------------------------------- |
---|
[2299] | 6 | USE IOIPSL |
---|
| 7 | USE parallel_lmdz |
---|
| 8 | USE mod_hallo |
---|
[5117] | 9 | USE lmdz_strings, ONLY: maxlen |
---|
[4063] | 10 | USE infotrac, ONLY: nqtot, tracers |
---|
[5118] | 11 | USE netcdf, ONLY: nf90_create, nf90_def_dim, nf90_inq_varid, nf90_global, & |
---|
| 12 | nf90_close, nf90_put_att, nf90_unlimited, nf90_clobber, & |
---|
| 13 | nf90_64bit_offset |
---|
[2299] | 14 | USE dynredem_mod, ONLY: cre_var, put_var, err, modname, fil |
---|
[5118] | 15 | USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs, & |
---|
| 16 | aps, bps, pseudoalt |
---|
[2597] | 17 | USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad |
---|
[2603] | 18 | USE logic_mod, ONLY: fxyhypb, ysinus |
---|
[5118] | 19 | USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, & |
---|
| 20 | taux, tauy |
---|
[2601] | 21 | USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time |
---|
[5118] | 22 | USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0 |
---|
[5114] | 23 | USE lmdz_description, ONLY: descript |
---|
[5118] | 24 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
[5136] | 25 | USE lmdz_comgeom |
---|
[2598] | 26 | |
---|
[5159] | 27 | USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm |
---|
| 28 | USE lmdz_paramet |
---|
[2299] | 29 | IMPLICIT NONE |
---|
[5159] | 30 | |
---|
| 31 | |
---|
[5118] | 32 | !=============================================================================== |
---|
| 33 | ! Arguments: |
---|
| 34 | CHARACTER(LEN = *), INTENT(IN) :: fichnom !--- FILE NAME |
---|
| 35 | INTEGER, INTENT(IN) :: iday_end !--- |
---|
| 36 | REAL, INTENT(IN) :: phis(ijb_u:ije_u)!--- GROUND GEOPOTENTIAL |
---|
| 37 | !=============================================================================== |
---|
| 38 | ! Local variables: |
---|
[4172] | 39 | INTEGER :: iq |
---|
[5118] | 40 | INTEGER, PARAMETER :: length = 100 |
---|
| 41 | REAL :: tab_cntrl(length) !--- RUN PARAMETERS TABLE |
---|
| 42 | REAL :: phis_glo(ip1jmp1) |
---|
| 43 | ! For NetCDF: |
---|
| 44 | CHARACTER(LEN = maxlen) :: unites |
---|
[2299] | 45 | INTEGER :: indexID |
---|
| 46 | INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID |
---|
[4172] | 47 | INTEGER :: sID, sigID, nID, timID |
---|
[2299] | 48 | INTEGER :: yyears0, jjour0, mmois0 |
---|
[5118] | 49 | REAL :: zjulian, hours |
---|
| 50 | !=============================================================================== |
---|
| 51 | modname = 'dynredem0'; fil = fichnom |
---|
| 52 | CALL Gather_field_u(phis, phis_glo, 1) |
---|
[2299] | 53 | IF(mpi_rank/=0) RETURN |
---|
[1632] | 54 | |
---|
[2299] | 55 | CALL ymds2ju(annee_ref, 1, iday_end, 0.0, zjulian) |
---|
| 56 | CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) |
---|
[1632] | 57 | |
---|
[5118] | 58 | tab_cntrl(:) = 0. |
---|
| 59 | tab_cntrl(1) = REAL(iim) |
---|
| 60 | tab_cntrl(2) = REAL(jjm) |
---|
| 61 | tab_cntrl(3) = REAL(llm) |
---|
| 62 | tab_cntrl(4) = REAL(day_ref) |
---|
| 63 | tab_cntrl(5) = REAL(annee_ref) |
---|
| 64 | tab_cntrl(6) = rad |
---|
| 65 | tab_cntrl(7) = omeg |
---|
| 66 | tab_cntrl(8) = g |
---|
| 67 | tab_cntrl(9) = cpp |
---|
[2299] | 68 | tab_cntrl(10) = kappa |
---|
| 69 | tab_cntrl(11) = daysec |
---|
| 70 | tab_cntrl(12) = dtvr |
---|
| 71 | tab_cntrl(13) = etot0 |
---|
| 72 | tab_cntrl(14) = ptot0 |
---|
| 73 | tab_cntrl(15) = ztot0 |
---|
| 74 | tab_cntrl(16) = stot0 |
---|
| 75 | tab_cntrl(17) = ang0 |
---|
| 76 | tab_cntrl(18) = pa |
---|
| 77 | tab_cntrl(19) = preff |
---|
[1632] | 78 | |
---|
[5118] | 79 | ! ..... parameters for zoom ...... |
---|
[2299] | 80 | tab_cntrl(20) = clon |
---|
| 81 | tab_cntrl(21) = clat |
---|
| 82 | tab_cntrl(22) = grossismx |
---|
| 83 | tab_cntrl(23) = grossismy |
---|
[5099] | 84 | |
---|
[5118] | 85 | IF (fxyhypb) THEN |
---|
[2299] | 86 | tab_cntrl(24) = 1. |
---|
| 87 | tab_cntrl(25) = dzoomx |
---|
| 88 | tab_cntrl(26) = dzoomy |
---|
| 89 | tab_cntrl(27) = 0. |
---|
| 90 | tab_cntrl(28) = taux |
---|
| 91 | tab_cntrl(29) = tauy |
---|
| 92 | ELSE |
---|
| 93 | tab_cntrl(24) = 0. |
---|
| 94 | tab_cntrl(25) = dzoomx |
---|
| 95 | tab_cntrl(26) = dzoomy |
---|
| 96 | tab_cntrl(27) = 0. |
---|
| 97 | tab_cntrl(28) = 0. |
---|
| 98 | tab_cntrl(29) = 0. |
---|
[5118] | 99 | IF(ysinus) tab_cntrl(27) = 1. |
---|
[2299] | 100 | END IF |
---|
| 101 | tab_cntrl(30) = REAL(iday_end) |
---|
| 102 | tab_cntrl(31) = REAL(itau_dyn + itaufin) |
---|
[5118] | 103 | ! start_time: start_time of simulation (not necessarily 0.) |
---|
[2299] | 104 | tab_cntrl(32) = start_time |
---|
[1632] | 105 | |
---|
[5118] | 106 | !--- File creation |
---|
| 107 | CALL err(nf90_create(fichnom, IOR(nf90_clobber, nf90_64bit_offset), nid)) |
---|
[1632] | 108 | |
---|
[5118] | 109 | !--- Some global attributes |
---|
| 110 | CALL err(nf90_put_att(nid, nf90_global, "title", "Fichier demarrage dynamique")) |
---|
[1632] | 111 | |
---|
[5118] | 112 | !--- Dimensions |
---|
| 113 | CALL err(nf90_def_dim(nid, "index", length, indexID)) |
---|
| 114 | CALL err(nf90_def_dim(nid, "rlonu", iip1, rlonuID)) |
---|
| 115 | CALL err(nf90_def_dim(nid, "rlatu", jjp1, rlatuID)) |
---|
| 116 | CALL err(nf90_def_dim(nid, "rlonv", iip1, rlonvID)) |
---|
| 117 | CALL err(nf90_def_dim(nid, "rlatv", jjm, rlatvID)) |
---|
| 118 | CALL err(nf90_def_dim(nid, "sigs", llm, sID)) |
---|
| 119 | CALL err(nf90_def_dim(nid, "sig", llmp1, sigID)) |
---|
| 120 | CALL err(nf90_def_dim(nid, "temps", nf90_unlimited, timID)) |
---|
[1632] | 121 | |
---|
[5118] | 122 | !--- Define and save invariant fields |
---|
| 123 | CALL put_var(nid, "controle", "Parametres de controle", [indexID], tab_cntrl) |
---|
| 124 | CALL put_var(nid, "rlonu", "Longitudes des points U", [rlonuID], rlonu) |
---|
| 125 | CALL put_var(nid, "rlatu", "Latitudes des points U", [rlatuID], rlatu) |
---|
| 126 | CALL put_var(nid, "rlonv", "Longitudes des points V", [rlonvID], rlonv) |
---|
| 127 | CALL put_var(nid, "rlatv", "Latitudes des points V", [rlatvID], rlatv) |
---|
| 128 | CALL put_var(nid, "nivsigs", "Numero naturel des couches s", [sID], nivsigs) |
---|
| 129 | CALL put_var(nid, "nivsig", "Numero naturel des couches sigma", [sigID], nivsig) |
---|
| 130 | CALL put_var(nid, "ap", "Coefficient A pour hybride", [sigID], ap) |
---|
| 131 | CALL put_var(nid, "bp", "Coefficient B pour hybride", [sigID], bp) |
---|
| 132 | CALL put_var(nid, "presnivs", "", [sID], presnivs) |
---|
| 133 | ! covariant <-> contravariant <-> natural conversion coefficients |
---|
| 134 | CALL put_var(nid, "cu", "Coefficient de passage pour U", [rlonuID, rlatuID], cu) |
---|
| 135 | CALL put_var(nid, "cv", "Coefficient de passage pour V", [rlonvID, rlatvID], cv) |
---|
| 136 | CALL put_var(nid, "aire", "Aires de chaque maille", [rlonvID, rlatuID], aire) |
---|
| 137 | CALL put_var(nid, "phisinit", "Geopotentiel au sol", [rlonvID, rlatuID], phis_glo) |
---|
[1632] | 138 | |
---|
[5118] | 139 | !--- Define fields saved later |
---|
| 140 | WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") & |
---|
| 141 | yyears0, mmois0, jjour0 |
---|
| 142 | CALL cre_var(nid, "temps", "Temps de simulation", [timID], unites) |
---|
| 143 | CALL cre_var(nid, "ucov", "Vitesse U", [rlonuID, rlatuID, sID, timID]) |
---|
| 144 | CALL cre_var(nid, "vcov", "Vitesse V", [rlonvID, rlatvID, sID, timID]) |
---|
| 145 | CALL cre_var(nid, "teta", "Temperature", [rlonvID, rlatuID, sID, timID]) |
---|
| 146 | DO iq = 1, nqtot |
---|
| 147 | CALL cre_var(nid, tracers(iq)%name, tracers(iq)%longName, [rlonvID, rlatuID, sID, timID]) |
---|
[2299] | 148 | END DO |
---|
[5118] | 149 | CALL cre_var(nid, "masse", "Masse d air", [rlonvID, rlatuID, sID, timID]) |
---|
| 150 | CALL cre_var(nid, "ps", "Pression au sol", [rlonvID, rlatuID, timID]) |
---|
[5100] | 151 | CALL err(nf90_close (nid)) |
---|
[1632] | 152 | |
---|
[5118] | 153 | WRITE(lunout, *)TRIM(modname) // ': iim,jjm,llm,iday_end', iim, jjm, llm, iday_end |
---|
| 154 | WRITE(lunout, *)TRIM(modname) // ': rad,omeg,g,cpp,kappa', rad, omeg, g, cpp, kappa |
---|
[1632] | 155 | |
---|
[2299] | 156 | END SUBROUTINE dynredem0_loc |
---|
[5099] | 157 | |
---|
[2299] | 158 | !------------------------------------------------------------------------------- |
---|
[1632] | 159 | |
---|
| 160 | |
---|
[2299] | 161 | !------------------------------------------------------------------------------- |
---|
[5099] | 162 | |
---|
[5118] | 163 | SUBROUTINE dynredem1_loc(fichnom, time, vcov, ucov, teta, q, masse, ps) |
---|
[5099] | 164 | |
---|
[5118] | 165 | !------------------------------------------------------------------------------- |
---|
| 166 | ! Purpose: Write the NetCDF restart file (append). |
---|
| 167 | !------------------------------------------------------------------------------- |
---|
[2299] | 168 | USE parallel_lmdz |
---|
| 169 | USE mod_hallo |
---|
[5117] | 170 | USE lmdz_strings, ONLY: maxlen |
---|
[4389] | 171 | USE infotrac, ONLY: nqtot, tracers, type_trac |
---|
[2299] | 172 | USE control_mod |
---|
[5118] | 173 | USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid, & |
---|
| 174 | nf90_close, nf90_write, nf90_put_var, nf90_noerr |
---|
[2299] | 175 | USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, & |
---|
[5118] | 176 | err, modname, fil, msg |
---|
[2601] | 177 | USE temps_mod, ONLY: itau_dyn, itaufin |
---|
[5114] | 178 | USE lmdz_description, ONLY: descript |
---|
[5118] | 179 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
[5136] | 180 | USE lmdz_comgeom |
---|
[5118] | 181 | |
---|
[5159] | 182 | USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm |
---|
| 183 | USE lmdz_paramet |
---|
[2299] | 184 | IMPLICIT NONE |
---|
[5159] | 185 | |
---|
| 186 | |
---|
[5118] | 187 | !=============================================================================== |
---|
| 188 | ! Arguments: |
---|
| 189 | CHARACTER(LEN = *), INTENT(IN) :: fichnom !-- FILE NAME |
---|
| 190 | REAL, INTENT(IN) :: time !-- TIME |
---|
| 191 | REAL, INTENT(IN) :: vcov(ijb_v:ije_v, llm) !-- V COVARIANT WIND |
---|
| 192 | REAL, INTENT(IN) :: ucov(ijb_u:ije_u, llm) !-- U COVARIANT WIND |
---|
| 193 | REAL, INTENT(IN) :: teta(ijb_u:ije_u, llm) !-- POTENTIAL TEMPERATURE |
---|
| 194 | REAL, INTENT(INOUT) :: q(ijb_u:ije_u, llm, nqtot) !-- TRACERS |
---|
| 195 | REAL, INTENT(IN) :: masse(ijb_u:ije_u, llm) !-- MASS PER CELL |
---|
| 196 | REAL, INTENT(IN) :: ps(ijb_u:ije_u) !-- GROUND PRESSURE |
---|
| 197 | !=============================================================================== |
---|
| 198 | ! Local variables: |
---|
[4172] | 199 | INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac |
---|
[5118] | 200 | INTEGER, SAVE :: nb = 0 |
---|
| 201 | INTEGER, PARAMETER :: length = 100 |
---|
| 202 | REAL :: tab_cntrl(length) ! tableau des parametres du run |
---|
| 203 | CHARACTER(LEN = maxlen) :: var, dum |
---|
| 204 | LOGICAL :: lread_inca |
---|
| 205 | !=============================================================================== |
---|
[1632] | 206 | |
---|
[5118] | 207 | !$OMP MASTER |
---|
[2299] | 208 | IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
[5118] | 209 | modname = 'dynredem1_loc'; fil = fichnom |
---|
| 210 | CALL err(nf90_open(fil, nf90_write, nid), "open", fil) |
---|
[1632] | 211 | |
---|
[5118] | 212 | !--- Write/extend time coordinate |
---|
| 213 | nb = nb + 1 |
---|
| 214 | var = "temps" |
---|
| 215 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
| 216 | CALL err(nf90_put_var(nid, vID, [time]), "put", var) |
---|
| 217 | WRITE(lunout, *)TRIM(modname) // ": Saving for ", nb, time |
---|
[1632] | 218 | |
---|
[5118] | 219 | !--- Rewrite control table (itaufin undefined in dynredem0) |
---|
| 220 | var = "controle" |
---|
| 221 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
| 222 | CALL err(nf90_get_var(nid, vID, tab_cntrl), "get", var) |
---|
| 223 | tab_cntrl(31) = DBLE(itau_dyn + itaufin) |
---|
| 224 | CALL err(nf90_inq_varid(nid, var, vID), "inq", var) |
---|
| 225 | CALL err(nf90_put_var(nid, vID, tab_cntrl), "put", var) |
---|
[2299] | 226 | END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
[5118] | 227 | !$OMP END MASTER |
---|
[1632] | 228 | |
---|
[5118] | 229 | !--- Save fields |
---|
| 230 | CALL dynredem_write_u(nid, "ucov", ucov, llm) |
---|
| 231 | CALL dynredem_write_v(nid, "vcov", vcov, llm) |
---|
| 232 | CALL dynredem_write_u(nid, "teta", teta, llm) |
---|
| 233 | CALL dynredem_write_u(nid, "masse", masse, llm) |
---|
| 234 | CALL dynredem_write_u(nid, "ps", ps, 1) |
---|
[1632] | 235 | |
---|
[5118] | 236 | !--- Tracers in file "start_trac.nc" (added by Anne) |
---|
| 237 | lread_inca = .FALSE. |
---|
| 238 | !$OMP MASTER |
---|
| 239 | fil = "start_trac.nc" |
---|
| 240 | IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE = fil, EXIST = lread_inca) |
---|
| 241 | IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite, nid_trac), "open") |
---|
| 242 | !$OMP END MASTER |
---|
| 243 | !$OMP BARRIER |
---|
[1632] | 244 | |
---|
[5118] | 245 | !--- Save tracers |
---|
| 246 | DO iq = 1, nqtot; var = TRIM(tracers(iq)%name); ierr = -1 |
---|
| 247 | IF(lread_inca) THEN !--- Possibly read from "start_trac.nc" |
---|
| 248 | !$OMP MASTER |
---|
| 249 | fil = "start_trac.nc" |
---|
| 250 | ierr = nf90_inq_varid(nid_trac, var, vID_trac) |
---|
| 251 | dum = 'inq'; IF(ierr==nf90_noerr) dum = 'fnd' |
---|
| 252 | WRITE(lunout, *)msg(dum, var) |
---|
| 253 | !$OMP END MASTER |
---|
| 254 | !$OMP BARRIER |
---|
| 255 | IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac, var, q(:, :, iq), llm) |
---|
| 256 | END IF |
---|
| 257 | fil = fichnom |
---|
| 258 | CALL dynredem_write_u(nid, var, q(:, :, iq), llm) |
---|
[2299] | 259 | END DO |
---|
[1632] | 260 | |
---|
[5118] | 261 | !$OMP MASTER |
---|
[2299] | 262 | IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
[5118] | 263 | CALL err(nf90_close(nid), "close") |
---|
| 264 | fil = "start_trac.nc" |
---|
| 265 | IF(lread_inca) CALL err(nf90_close(nid_trac), "close") |
---|
[2299] | 266 | END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
---|
[5118] | 267 | !$OMP END MASTER |
---|
[1632] | 268 | |
---|
[2299] | 269 | END SUBROUTINE dynredem1_loc |
---|
| 270 | |
---|