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