| 1 | module phyredem |
|---|
| 2 | |
|---|
| 3 | implicit none |
|---|
| 4 | |
|---|
| 5 | INTEGER,SAVE :: nid_restart ! NetCDF file identifier for restartfi.nc file |
|---|
| 6 | |
|---|
| 7 | contains |
|---|
| 8 | |
|---|
| 9 | subroutine physdem0(filename,lonfi,latfi,nsoil,ngrid,nlay,nq, & |
|---|
| 10 | phystep,day_ini,time,airefi, & |
|---|
| 11 | alb,pzmea,pzstd,pzsig,pzgam,pzthe) |
|---|
| 12 | ! create physics restart file and write time-independent variables |
|---|
| 13 | use comsoil_h, only: volcapa, mlayer |
|---|
| 14 | use geometry_mod, only: cell_area |
|---|
| 15 | use surfdat_h, only: zmea, zstd, zsig, zgam, zthe, & |
|---|
| 16 | emisice, emissiv, & |
|---|
| 17 | iceradius, dtemisice, phisfi |
|---|
| 18 | use iostart, only : create_restartphy, open_restartphy, close_restartphy, & |
|---|
| 19 | put_var, put_field, length, ldscrpt, ndscrpt |
|---|
| 20 | use mod_grid_phy_lmdz, only : klon_glo |
|---|
| 21 | use planete_mod, only: year_day, periastr, apoastr, peri_day, & |
|---|
| 22 | obliquit, z0, lmixmin, emin_turb |
|---|
| 23 | use comcstfi_mod, only: rad, omeg, g, mugaz, rcp |
|---|
| 24 | use time_phylmdz_mod, only: daysec |
|---|
| 25 | |
|---|
| 26 | implicit none |
|---|
| 27 | |
|---|
| 28 | character(len=*), intent(in) :: filename |
|---|
| 29 | real,intent(in) :: lonfi(ngrid) |
|---|
| 30 | real,intent(in) :: latfi(ngrid) |
|---|
| 31 | integer,intent(in) :: nsoil |
|---|
| 32 | integer,intent(in) :: ngrid |
|---|
| 33 | integer,intent(in) :: nlay |
|---|
| 34 | integer,intent(in) :: nq |
|---|
| 35 | real,intent(in) :: phystep |
|---|
| 36 | real,intent(in) :: day_ini |
|---|
| 37 | real,intent(in) :: time |
|---|
| 38 | real,intent(in) :: airefi(ngrid) |
|---|
| 39 | real,intent(in) :: alb(ngrid) |
|---|
| 40 | real,intent(in) :: pzmea(ngrid) |
|---|
| 41 | real,intent(in) :: pzstd(ngrid) |
|---|
| 42 | real,intent(in) :: pzsig(ngrid) |
|---|
| 43 | real,intent(in) :: pzgam(ngrid) |
|---|
| 44 | real,intent(in) :: pzthe(ngrid) |
|---|
| 45 | |
|---|
| 46 | character(ndscrpt), dimension(ldscrpt), parameter :: dscrpt_tab_cntrl = (/ & |
|---|
| 47 | "(1) Number of atmospheric columns in physics ", & |
|---|
| 48 | "(2) Number of atmospheric layers ", & |
|---|
| 49 | "(3) Final day ", & |
|---|
| 50 | "(4) Final time of day ", & |
|---|
| 51 | "(5) Planet radius (m) ", & |
|---|
| 52 | "(6) Rotation rate (rad.s-1) ", & |
|---|
| 53 | "(7) Gravity (m.s-2) ", & |
|---|
| 54 | "(8) Molar mass of the atmosphere (g.mol-1) ", & |
|---|
| 55 | "(9) = r/Cp (=kappa in the dynamics) ", & |
|---|
| 56 | "(10) Length of a solar day (s) ", & |
|---|
| 57 | "(11) Physics time step (s) ", & |
|---|
| 58 | "(12) - ", & |
|---|
| 59 | "(13) - ", & |
|---|
| 60 | "(14) Length of year (in solar days) ", & |
|---|
| 61 | "(15) Minimum star-planet distance (AU) ", & |
|---|
| 62 | "(16) Maximum star-planet distance (AU) ", & |
|---|
| 63 | "(17) Date of periastro (sols since N. spring) ", & |
|---|
| 64 | "(18) Obliquity of the planet (deg) ", & |
|---|
| 65 | "(19) Default surface roughness (m) ", & |
|---|
| 66 | "(20) - ", & |
|---|
| 67 | "(21) - ", & |
|---|
| 68 | "(22) - ", & |
|---|
| 69 | "(23) - ", & |
|---|
| 70 | "(24) Emissivity of northern cap ~0.95 ", & |
|---|
| 71 | "(25) Emissivity of southern cap ~0.95 ", & |
|---|
| 72 | "(26) Emissivity of martian soil ~.95 ", & |
|---|
| 73 | "(27) - ", & |
|---|
| 74 | "(28) - ", & |
|---|
| 75 | "(29) - ", & |
|---|
| 76 | "(30) - ", & |
|---|
| 77 | "(31) Mean scat radius of CO2 snow (north) ", & |
|---|
| 78 | "(32) Mean scat radius of CO2 snow (south) ", & |
|---|
| 79 | "(33) Time scale for snow metamorphism (north) ", & |
|---|
| 80 | "(34) Time scale for snow metamorphism (south) ", & |
|---|
| 81 | "(35) Soil volumetric heat capacity "/) |
|---|
| 82 | real :: tab_cntrl(length) ! nb "length=100" defined in iostart module |
|---|
| 83 | |
|---|
| 84 | ! Create physics start file |
|---|
| 85 | call create_restartphy(filename,nid_restart) |
|---|
| 86 | |
|---|
| 87 | ! tab_cntrl() contains run parameters |
|---|
| 88 | tab_cntrl(:)=0 ! initialization |
|---|
| 89 | !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
|---|
| 90 | ! Fill control array tab_cntrl(:) with paramleters for this run |
|---|
| 91 | !cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc |
|---|
| 92 | ! Informations on the physics grid |
|---|
| 93 | tab_cntrl(1) = float(klon_glo) ! number of nodes on physics grid |
|---|
| 94 | tab_cntrl(2) = float(nlay) ! number of atmospheric layers |
|---|
| 95 | tab_cntrl(3) = day_ini + int(time) ! final day |
|---|
| 96 | tab_cntrl(4) = time -int(time) ! final time of day |
|---|
| 97 | |
|---|
| 98 | ! Informations about Mars, used by dynamics and physics |
|---|
| 99 | tab_cntrl(5) = rad ! radius of Mars (m) ~3397200 |
|---|
| 100 | tab_cntrl(6) = omeg ! rotation rate (rad.s-1) |
|---|
| 101 | tab_cntrl(7) = g ! gravity (m.s-2) ~3.72 |
|---|
| 102 | tab_cntrl(8) = mugaz ! Molar mass of the atmosphere (g.mol-1) ~43.49 |
|---|
| 103 | tab_cntrl(9) = rcp ! = r/cp ~0.256793 (=kappa dans dynamique) |
|---|
| 104 | tab_cntrl(10) = daysec ! length of a sol (s) ~88775 |
|---|
| 105 | |
|---|
| 106 | tab_cntrl(11) = phystep ! time step in the physics |
|---|
| 107 | tab_cntrl(12) = 0. |
|---|
| 108 | tab_cntrl(13) = 0. |
|---|
| 109 | |
|---|
| 110 | ! Informations about Mars, only for physics |
|---|
| 111 | tab_cntrl(14) = year_day ! length of year (sols) ~668.6 |
|---|
| 112 | tab_cntrl(15) = periastr ! min. star-planet distance (AU) |
|---|
| 113 | tab_cntrl(16) = apoastr ! max. star-planet distance (AU) |
|---|
| 114 | tab_cntrl(17) = peri_day ! date of periastron (sols since N. spring) |
|---|
| 115 | tab_cntrl(18) = obliquit ! Obliquity of the planet (deg) ~23.98 |
|---|
| 116 | |
|---|
| 117 | ! Boundary layer and turbulence |
|---|
| 118 | tab_cntrl(19) = z0 ! surface roughness (m) ~0.01 |
|---|
| 119 | tab_cntrl(20) = lmixmin ! mixing length ~100 |
|---|
| 120 | tab_cntrl(21) = emin_turb ! minimal energy ~1.e-8 |
|---|
| 121 | |
|---|
| 122 | ! Optical properties of polar caps and ground emissivity |
|---|
| 123 | tab_cntrl(24) = emisice(1) ! Emissivity of northern cap ~0.95 |
|---|
| 124 | tab_cntrl(25) = emisice(2) ! Emissivity of southern cap ~0.95 |
|---|
| 125 | tab_cntrl(26) = emissiv ! Emissivity of martian soil ~.95 |
|---|
| 126 | tab_cntrl(31) = iceradius(1) ! mean scat radius of N2 snow (north) |
|---|
| 127 | tab_cntrl(32) = iceradius(2) ! mean scat radius of N2 snow (south) |
|---|
| 128 | tab_cntrl(33) = dtemisice(1) ! time scale for snow metamorphism (north) |
|---|
| 129 | tab_cntrl(34) = dtemisice(2) ! time scale for snow metamorphism (south) |
|---|
| 130 | |
|---|
| 131 | tab_cntrl(28) = 0. |
|---|
| 132 | tab_cntrl(29) = 0. |
|---|
| 133 | tab_cntrl(30) = 0. |
|---|
| 134 | ! Soil properties: |
|---|
| 135 | tab_cntrl(35) = volcapa ! soil volumetric heat capacity |
|---|
| 136 | |
|---|
| 137 | call put_var(nid_restart,"controle","Control parameters",tab_cntrl) |
|---|
| 138 | |
|---|
| 139 | ! Write the controle array descriptor |
|---|
| 140 | call put_var(nid_restart,"controle_descriptor",& |
|---|
| 141 | "Description of control parameters",dscrpt_tab_cntrl) |
|---|
| 142 | |
|---|
| 143 | ! Write the mid-layer depths |
|---|
| 144 | call put_var(nid_restart,"soildepth","Soil mid-layer depth",mlayer) |
|---|
| 145 | |
|---|
| 146 | ! Write longitudes |
|---|
| 147 | call put_field(nid_restart,"longitude","Longitudes of physics grid",lonfi) |
|---|
| 148 | |
|---|
| 149 | ! Write latitudes |
|---|
| 150 | call put_field(nid_restart,"latitude","Latitudes of physics grid",latfi) |
|---|
| 151 | |
|---|
| 152 | ! Write mesh areas |
|---|
| 153 | call put_field(nid_restart,"area","Mesh area",cell_area) |
|---|
| 154 | |
|---|
| 155 | ! Write surface geopotential |
|---|
| 156 | call put_field(nid_restart,"phisfi","Geopotential at the surface",phisfi) |
|---|
| 157 | |
|---|
| 158 | ! Write surface albedo |
|---|
| 159 | !call put_field(nid_restart,"albedodat","Albedo of bare ground",alb) |
|---|
| 160 | |
|---|
| 161 | ! Subgrid topogaphy variables |
|---|
| 162 | call put_field(nid_restart,"ZMEA","Relief: mean relief",zmea) |
|---|
| 163 | call put_field(nid_restart,"ZSTD","Relief: standard deviation",zstd) |
|---|
| 164 | call put_field(nid_restart,"ZSIG","Relief: sigma parameter",zsig) |
|---|
| 165 | call put_field(nid_restart,"ZGAM","Relief: gamma parameter",zgam) |
|---|
| 166 | call put_field(nid_restart,"ZTHE","Relief: theta parameter",zthe) |
|---|
| 167 | |
|---|
| 168 | ! Close file |
|---|
| 169 | call close_restartphy(nid_restart) |
|---|
| 170 | |
|---|
| 171 | end subroutine physdem0 |
|---|
| 172 | |
|---|
| 173 | subroutine physdem1(filename,nsoil,ngrid,nlay,nq, & |
|---|
| 174 | phystep,time,tsurf,tsoil,inertiesoil, & |
|---|
| 175 | emis,alb,q2,qsurf) |
|---|
| 176 | ! write time-dependent variable to restart file |
|---|
| 177 | use iostart, only : open_restartphy, close_restartphy, & |
|---|
| 178 | put_var, put_field |
|---|
| 179 | use tracer_h, only: noms |
|---|
| 180 | |
|---|
| 181 | implicit none |
|---|
| 182 | |
|---|
| 183 | character(len=*),intent(in) :: filename |
|---|
| 184 | integer,intent(in) :: nsoil |
|---|
| 185 | integer,intent(in) :: ngrid |
|---|
| 186 | integer,intent(in) :: nlay |
|---|
| 187 | integer,intent(in) :: nq |
|---|
| 188 | real,intent(in) :: phystep |
|---|
| 189 | real,intent(in) :: time |
|---|
| 190 | real,intent(in) :: tsurf(ngrid) |
|---|
| 191 | real,intent(in) :: tsoil(ngrid,nsoil) |
|---|
| 192 | real,intent(in) :: emis(ngrid) |
|---|
| 193 | real,intent(in) :: alb(ngrid) |
|---|
| 194 | real,intent(in) :: inertiesoil(ngrid,nsoil) |
|---|
| 195 | real,intent(in) :: q2(ngrid,nlay+1) |
|---|
| 196 | real,intent(in) :: qsurf(ngrid,nq) |
|---|
| 197 | |
|---|
| 198 | integer :: iq |
|---|
| 199 | |
|---|
| 200 | ! Open file |
|---|
| 201 | call open_restartphy(filename, nid_restart) |
|---|
| 202 | |
|---|
| 203 | ! First variable to write must be "Time", in order to correctly |
|---|
| 204 | ! set time counter in file |
|---|
| 205 | !call put_var("Time","Temps de simulation",time) |
|---|
| 206 | |
|---|
| 207 | ! Surface temperature |
|---|
| 208 | call put_field(nid_restart,"tsurf","Surface temperature",tsurf) |
|---|
| 209 | |
|---|
| 210 | ! Soil inertia |
|---|
| 211 | call put_field(nid_restart,"inertiedat","Soil thermal inertia",inertiesoil) |
|---|
| 212 | |
|---|
| 213 | ! Soil temperature |
|---|
| 214 | call put_field(nid_restart,"tsoil","Soil temperature",tsoil) |
|---|
| 215 | |
|---|
| 216 | ! Emissivity of the surface |
|---|
| 217 | call put_field(nid_restart,"emis","Surface emissivity",emis) |
|---|
| 218 | |
|---|
| 219 | ! Albedo of the surface |
|---|
| 220 | call put_field(nid_restart,"albedodat","Albedo of bare ground",alb) |
|---|
| 221 | |
|---|
| 222 | ! Planetary Boundary Layer |
|---|
| 223 | call put_field(nid_restart,"q2","pbl wind variance",q2) |
|---|
| 224 | |
|---|
| 225 | ! cloud fraction and sea ice !AF24: removed |
|---|
| 226 | |
|---|
| 227 | ! !Slab ocean !AF24: removed |
|---|
| 228 | |
|---|
| 229 | ! tracers |
|---|
| 230 | if (nq>0) then |
|---|
| 231 | do iq=1,nq |
|---|
| 232 | call put_field(nid_restart,noms(iq),"tracer on surface",qsurf(:,iq)) |
|---|
| 233 | enddo |
|---|
| 234 | endif ! of if (nq>0) |
|---|
| 235 | |
|---|
| 236 | ! Non-orographic gavity waves !AF24: removed |
|---|
| 237 | |
|---|
| 238 | ! close file |
|---|
| 239 | CALL close_restartphy(nid_restart) |
|---|
| 240 | !$OMP BARRIER |
|---|
| 241 | |
|---|
| 242 | end subroutine physdem1 |
|---|
| 243 | |
|---|
| 244 | end module phyredem |
|---|