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