| 1 | ! $Id: initfluxsto.f90 5195 2024-09-16 13:18:00Z idelkadi $ |
|---|
| 2 | |
|---|
| 3 | SUBROUTINE initfluxsto & |
|---|
| 4 | (infile, tstep, t_ops, t_wrt, & |
|---|
| 5 | fileid, filevid, filedid) |
|---|
| 6 | |
|---|
| 7 | USE IOIPSL |
|---|
| 8 | USE comconst_mod, ONLY: pi |
|---|
| 9 | USE comvert_mod, ONLY: nivsigs |
|---|
| 10 | USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn |
|---|
| 11 | USE lmdz_iniprint, ONLY: lunout, prt_level |
|---|
| 12 | USE lmdz_comgeom |
|---|
| 13 | |
|---|
| 14 | USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm |
|---|
| 15 | USE lmdz_paramet |
|---|
| 16 | IMPLICIT NONE |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | ! Routine d'initialisation des ecritures des fichiers histoires LMDZ |
|---|
| 20 | ! au format IOIPSL |
|---|
| 21 | |
|---|
| 22 | ! Appels succesifs des routines: histbeg |
|---|
| 23 | ! histhori |
|---|
| 24 | ! histver |
|---|
| 25 | ! histdef |
|---|
| 26 | ! histend |
|---|
| 27 | |
|---|
| 28 | ! Entree: |
|---|
| 29 | |
|---|
| 30 | ! infile: nom du fichier histoire a creer |
|---|
| 31 | ! day0,anne0: date de reference |
|---|
| 32 | ! tstep: duree du pas de temps en seconde |
|---|
| 33 | ! t_ops: frequence de l'operation pour IOIPSL |
|---|
| 34 | ! t_wrt: frequence d'ecriture sur le fichier |
|---|
| 35 | |
|---|
| 36 | ! Sortie: |
|---|
| 37 | ! fileid: ID du fichier netcdf cree |
|---|
| 38 | ! filevid:ID du fichier netcdf pour la grille v |
|---|
| 39 | |
|---|
| 40 | ! L. Fairhead, LMD, 03/99 |
|---|
| 41 | |
|---|
| 42 | ! ===================================================================== |
|---|
| 43 | |
|---|
| 44 | ! Declarations |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | ! Arguments |
|---|
| 49 | |
|---|
| 50 | CHARACTER(LEN = *) :: infile |
|---|
| 51 | REAL :: tstep, t_ops, t_wrt |
|---|
| 52 | INTEGER :: fileid, filevid, filedid |
|---|
| 53 | |
|---|
| 54 | ! This routine needs IOIPSL to work |
|---|
| 55 | ! Variables locales |
|---|
| 56 | |
|---|
| 57 | REAL :: nivd(1) |
|---|
| 58 | INTEGER :: tau0 |
|---|
| 59 | REAL :: zjulian |
|---|
| 60 | CHARACTER(LEN = 3) :: str |
|---|
| 61 | CHARACTER(LEN = 10) :: ctrac |
|---|
| 62 | INTEGER :: iq |
|---|
| 63 | REAL :: rlong(iip1, jjp1), rlat(iip1, jjp1), rl(1, 1) |
|---|
| 64 | INTEGER :: uhoriid, vhoriid, thoriid, zvertiid, dhoriid, dvertiid |
|---|
| 65 | INTEGER :: ii, jj |
|---|
| 66 | INTEGER :: zan, idayref |
|---|
| 67 | LOGICAL :: ok_sync |
|---|
| 68 | |
|---|
| 69 | ! Initialisations |
|---|
| 70 | |
|---|
| 71 | pi = 4. * atan (1.) |
|---|
| 72 | str = 'q ' |
|---|
| 73 | ctrac = 'traceur ' |
|---|
| 74 | ok_sync = .TRUE. |
|---|
| 75 | |
|---|
| 76 | ! Appel a histbeg: creation du fichier netcdf et initialisations diverses |
|---|
| 77 | ! |
|---|
| 78 | |
|---|
| 79 | zan = annee_ref |
|---|
| 80 | idayref = day_ref |
|---|
| 81 | CALL ymds2ju(zan, 1, idayref, 0.0, zjulian) |
|---|
| 82 | tau0 = itau_dyn |
|---|
| 83 | |
|---|
| 84 | DO jj = 1, jjp1 |
|---|
| 85 | DO ii = 1, iip1 |
|---|
| 86 | rlong(ii, jj) = rlonu(ii) * 180. / pi |
|---|
| 87 | rlat(ii, jj) = rlatu(jj) * 180. / pi |
|---|
| 88 | enddo |
|---|
| 89 | enddo |
|---|
| 90 | |
|---|
| 91 | CALL histbeg(infile, iip1, rlong(:, 1), jjp1, rlat(1, :), & |
|---|
| 92 | 1, iip1, 1, jjp1, & |
|---|
| 93 | tau0, zjulian, tstep, uhoriid, fileid) |
|---|
| 94 | |
|---|
| 95 | ! Creation du fichier histoire pour la grille en V (oblige pour l'instant, |
|---|
| 96 | ! IOIPSL ne permet pas de grilles avec des nombres de point differents dans |
|---|
| 97 | ! un meme fichier) |
|---|
| 98 | |
|---|
| 99 | DO jj = 1, jjm |
|---|
| 100 | DO ii = 1, iip1 |
|---|
| 101 | rlong(ii, jj) = rlonv(ii) * 180. / pi |
|---|
| 102 | rlat(ii, jj) = rlatv(jj) * 180. / pi |
|---|
| 103 | enddo |
|---|
| 104 | enddo |
|---|
| 105 | |
|---|
| 106 | CALL histbeg('fluxstokev.nc', iip1, rlong(:, 1), jjm, rlat(1, :), & |
|---|
| 107 | 1, iip1, 1, jjm, & |
|---|
| 108 | tau0, zjulian, tstep, vhoriid, filevid) |
|---|
| 109 | |
|---|
| 110 | rl(1, 1) = 1. |
|---|
| 111 | CALL histbeg('defstoke.nc', 1, rl, 1, rl, & |
|---|
| 112 | 1, 1, 1, 1, & |
|---|
| 113 | tau0, zjulian, tstep, dhoriid, filedid) |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | ! Appel a histhori pour rajouter les autres grilles horizontales |
|---|
| 117 | |
|---|
| 118 | DO jj = 1, jjp1 |
|---|
| 119 | DO ii = 1, iip1 |
|---|
| 120 | rlong(ii, jj) = rlonv(ii) * 180. / pi |
|---|
| 121 | rlat(ii, jj) = rlatu(jj) * 180. / pi |
|---|
| 122 | enddo |
|---|
| 123 | enddo |
|---|
| 124 | |
|---|
| 125 | CALL histhori(fileid, iip1, rlong, jjp1, rlat, 'scalar', & |
|---|
| 126 | 'Grille points scalaires', thoriid) |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | ! Appel a histvert pour la grille verticale |
|---|
| 130 | |
|---|
| 131 | CALL histvert(fileid, 'sig_s', 'Niveaux sigma', & |
|---|
| 132 | 'sigma_level', & |
|---|
| 133 | llm, nivsigs, zvertiid) |
|---|
| 134 | ! Pour le fichier V |
|---|
| 135 | CALL histvert(filevid, 'sig_s', 'Niveaux sigma', & |
|---|
| 136 | 'sigma_level', & |
|---|
| 137 | llm, nivsigs, zvertiid) |
|---|
| 138 | ! pour le fichier def |
|---|
| 139 | nivd(1) = 1 |
|---|
| 140 | CALL histvert(filedid, 'sig_s', 'Niveaux sigma', & |
|---|
| 141 | 'sigma_level', & |
|---|
| 142 | 1, nivd, dvertiid) |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | ! Appels a histdef pour la definition des variables a sauvegarder |
|---|
| 146 | |
|---|
| 147 | CALL histdef(fileid, "phis", "Surface geop. height", "-", & |
|---|
| 148 | iip1, jjp1, thoriid, 1, 1, 1, -99, 32, & |
|---|
| 149 | "once", t_ops, t_wrt) |
|---|
| 150 | |
|---|
| 151 | CALL histdef(fileid, "aire", "Grid area", "-", & |
|---|
| 152 | iip1, jjp1, thoriid, 1, 1, 1, -99, 32, & |
|---|
| 153 | "once", t_ops, t_wrt) |
|---|
| 154 | |
|---|
| 155 | CALL histdef(filedid, "dtvr", "tps dyn", "s", & |
|---|
| 156 | 1, 1, dhoriid, 1, 1, 1, -99, 32, & |
|---|
| 157 | "once", t_ops, t_wrt) |
|---|
| 158 | |
|---|
| 159 | CALL histdef(filedid, "istdyn", "tps stock", "s", & |
|---|
| 160 | 1, 1, dhoriid, 1, 1, 1, -99, 32, & |
|---|
| 161 | "once", t_ops, t_wrt) |
|---|
| 162 | |
|---|
| 163 | CALL histdef(filedid, "istphy", "tps stock phy", "s", & |
|---|
| 164 | 1, 1, dhoriid, 1, 1, 1, -99, 32, & |
|---|
| 165 | "once", t_ops, t_wrt) |
|---|
| 166 | |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | ! Masse |
|---|
| 170 | |
|---|
| 171 | CALL histdef(fileid, 'masse', 'Masse', 'kg', & |
|---|
| 172 | iip1, jjp1, thoriid, llm, 1, llm, zvertiid, & |
|---|
| 173 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 174 | |
|---|
| 175 | ! Pbaru |
|---|
| 176 | |
|---|
| 177 | CALL histdef(fileid, 'pbaru', 'flx de masse zonal', 'kg m/s', & |
|---|
| 178 | iip1, jjp1, uhoriid, llm, 1, llm, zvertiid, & |
|---|
| 179 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | ! Pbarv |
|---|
| 183 | |
|---|
| 184 | CALL histdef(filevid, 'pbarv', 'flx de masse mer', 'kg m/s', & |
|---|
| 185 | iip1, jjm, vhoriid, llm, 1, llm, zvertiid, & |
|---|
| 186 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 187 | |
|---|
| 188 | ! w |
|---|
| 189 | |
|---|
| 190 | CALL histdef(fileid, 'w', 'flx de masse vert', 'kg m/s', & |
|---|
| 191 | iip1, jjp1, thoriid, llm, 1, llm, zvertiid, & |
|---|
| 192 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | ! Temperature potentielle |
|---|
| 196 | |
|---|
| 197 | CALL histdef(fileid, 'teta', 'temperature potentielle', '-', & |
|---|
| 198 | iip1, jjp1, thoriid, llm, 1, llm, zvertiid, & |
|---|
| 199 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 200 | ! |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | ! Geopotentiel |
|---|
| 204 | |
|---|
| 205 | CALL histdef(fileid, 'phi', 'geopotentiel instantane', '-', & |
|---|
| 206 | iip1, jjp1, thoriid, llm, 1, llm, zvertiid, & |
|---|
| 207 | 32, 'inst(X)', t_ops, t_wrt) |
|---|
| 208 | |
|---|
| 209 | ! Fin |
|---|
| 210 | |
|---|
| 211 | CALL histend(fileid) |
|---|
| 212 | CALL histend(filevid) |
|---|
| 213 | CALL histend(filedid) |
|---|
| 214 | IF (ok_sync) THEN |
|---|
| 215 | CALL histsync(fileid) |
|---|
| 216 | CALL histsync(filevid) |
|---|
| 217 | CALL histsync(filedid) |
|---|
| 218 | ENDIF |
|---|
| 219 | |
|---|
| 220 | RETURN |
|---|
| 221 | END SUBROUTINE initfluxsto |
|---|