Changeset 5118 for LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_loc.F90
- Timestamp:
- Jul 24, 2024, 4:39:59 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Amaury_dev/libf/dyn3dmem/dynredem_loc.F90
r5117 r5118 1 SUBROUTINE dynredem0_loc(fichnom, iday_end,phis)2 3 !-------------------------------------------------------------------------------4 ! Write the NetCDF restart file (initialization).5 !-------------------------------------------------------------------------------1 SUBROUTINE dynredem0_loc(fichnom, iday_end, phis) 2 3 !------------------------------------------------------------------------------- 4 ! Write the NetCDF restart file (initialization). 5 !------------------------------------------------------------------------------- 6 6 USE IOIPSL 7 7 USE parallel_lmdz … … 9 9 USE lmdz_strings, ONLY: maxlen 10 10 USE infotrac, ONLY: nqtot, tracers 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 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 14 14 USE dynredem_mod, ONLY: cre_var, put_var, err, modname, fil 15 USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs,&16 aps,bps,pseudoalt15 USE comvert_mod, ONLY: ap, bp, presnivs, pa, preff, nivsig, nivsigs, & 16 aps, bps, pseudoalt 17 17 USE comconst_mod, ONLY: cpp, daysec, dtvr, g, kappa, omeg, rad 18 18 USE logic_mod, ONLY: fxyhypb, ysinus 19 USE serre_mod, ONLY: clon, clat,grossismx,grossismy,dzoomx,dzoomy, &20 taux,tauy19 USE serre_mod, ONLY: clon, clat, grossismx, grossismy, dzoomx, dzoomy, & 20 taux, tauy 21 21 USE temps_mod, ONLY: annee_ref, day_ref, itau_dyn, itaufin, start_time 22 USE ener_mod, ONLY: etot0, ptot0,ztot0,stot0,ang022 USE ener_mod, ONLY: etot0, ptot0, ztot0, stot0, ang0 23 23 USE lmdz_description, ONLY: descript 24 USE lmdz_iniprint, ONLY: lunout, prt_level 24 25 25 26 IMPLICIT NONE … … 27 28 include "paramet.h" 28 29 include "comgeom.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: 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: 37 37 INTEGER :: iq 38 INTEGER, PARAMETER :: length =10039 REAL 40 REAL 41 ! For NetCDF:42 CHARACTER(LEN =maxlen) :: unites38 INTEGER, PARAMETER :: length = 100 39 REAL :: tab_cntrl(length) !--- RUN PARAMETERS TABLE 40 REAL :: phis_glo(ip1jmp1) 41 ! For NetCDF: 42 CHARACTER(LEN = maxlen) :: unites 43 43 INTEGER :: indexID 44 44 INTEGER :: rlonuID, rlonvID, rlatuID, rlatvID 45 45 INTEGER :: sID, sigID, nID, timID 46 46 INTEGER :: yyears0, jjour0, mmois0 47 REAL 48 !===============================================================================49 modname ='dynredem0'; fil=fichnom50 CALL Gather_field_u(phis, phis_glo,1)47 REAL :: zjulian, hours 48 !=============================================================================== 49 modname = 'dynredem0'; fil = fichnom 50 CALL Gather_field_u(phis, phis_glo, 1) 51 51 IF(mpi_rank/=0) RETURN 52 52 … … 54 54 CALL ju2ymds(zjulian, yyears0, mmois0, jjour0, hours) 55 55 56 tab_cntrl(:) 57 tab_cntrl(1) 58 tab_cntrl(2) 59 tab_cntrl(3) 60 tab_cntrl(4) 61 tab_cntrl(5) 62 tab_cntrl(6) 63 tab_cntrl(7) 64 tab_cntrl(8) 65 tab_cntrl(9) 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 66 tab_cntrl(10) = kappa 67 67 tab_cntrl(11) = daysec … … 75 75 tab_cntrl(19) = preff 76 76 77 ! ..... parameters for zoom ...... 77 ! ..... parameters for zoom ...... 78 78 tab_cntrl(20) = clon 79 79 tab_cntrl(21) = clat … … 81 81 tab_cntrl(23) = grossismy 82 82 83 IF ( fxyhypb) THEN83 IF (fxyhypb) THEN 84 84 tab_cntrl(24) = 1. 85 85 tab_cntrl(25) = dzoomx … … 95 95 tab_cntrl(28) = 0. 96 96 tab_cntrl(29) = 0. 97 IF( ysinus) tab_cntrl(27) = 1.97 IF(ysinus) tab_cntrl(27) = 1. 98 98 END IF 99 99 tab_cntrl(30) = REAL(iday_end) 100 100 tab_cntrl(31) = REAL(itau_dyn + itaufin) 101 ! start_time: start_time of simulation (not necessarily 0.)101 ! start_time: start_time of simulation (not necessarily 0.) 102 102 tab_cntrl(32) = start_time 103 103 104 !--- File creation105 CALL err(nf90_create(fichnom, IOR(nf90_clobber,nf90_64bit_offset),nid))106 107 !--- Some global attributes108 CALL err(nf90_put_att(nid, nf90_global,"title","Fichier demarrage dynamique"))109 110 !--- Dimensions111 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))119 120 !--- Define and save invariant fields121 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 coefficients132 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)136 137 !--- Define fields saved later138 WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") &139 yyears0,mmois0,jjour0140 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,nqtot145 CALL cre_var(nid, tracers(iq)%name,tracers(iq)%longName,[rlonvID,rlatuID,sID,timID])104 !--- File creation 105 CALL err(nf90_create(fichnom, IOR(nf90_clobber, nf90_64bit_offset), nid)) 106 107 !--- Some global attributes 108 CALL err(nf90_put_att(nid, nf90_global, "title", "Fichier demarrage dynamique")) 109 110 !--- Dimensions 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)) 119 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) 136 137 !--- Define fields saved later 138 WRITE(unites, "('days since ',i4,'-',i2.2,'-',i2.2,' 00:00:00')") & 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 145 CALL cre_var(nid, tracers(iq)%name, tracers(iq)%longName, [rlonvID, rlatuID, sID, timID]) 146 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])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]) 149 149 CALL err(nf90_close (nid)) 150 150 151 WRITE(lunout, *)TRIM(modname)//': iim,jjm,llm,iday_end',iim,jjm,llm,iday_end152 WRITE(lunout, *)TRIM(modname)//': rad,omeg,g,cpp,kappa',rad,omeg,g,cpp,kappa151 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 153 153 154 154 END SUBROUTINE dynredem0_loc … … 159 159 !------------------------------------------------------------------------------- 160 160 161 SUBROUTINE dynredem1_loc(fichnom, time,vcov,ucov,teta,q,masse,ps)162 163 !-------------------------------------------------------------------------------164 ! Purpose: Write the NetCDF restart file (append).165 !-------------------------------------------------------------------------------161 SUBROUTINE dynredem1_loc(fichnom, time, vcov, ucov, teta, q, masse, ps) 162 163 !------------------------------------------------------------------------------- 164 ! Purpose: Write the NetCDF restart file (append). 165 !------------------------------------------------------------------------------- 166 166 USE parallel_lmdz 167 167 USE mod_hallo … … 169 169 USE infotrac, ONLY: nqtot, tracers, type_trac 170 170 USE control_mod 171 USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid,&172 nf90_close, nf90_write,nf90_put_var, nf90_noerr171 USE netcdf, ONLY: nf90_open, nf90_nowrite, nf90_get_var, nf90_inq_varid, & 172 nf90_close, nf90_write, nf90_put_var, nf90_noerr 173 173 USE dynredem_mod, ONLY: dynredem_write_u, dynredem_write_v, dynredem_read_u, & 174 174 err, modname, fil, msg 175 175 USE temps_mod, ONLY: itau_dyn, itaufin 176 176 USE lmdz_description, ONLY: descript 177 177 USE lmdz_iniprint, ONLY: lunout, prt_level 178 178 179 IMPLICIT NONE 179 180 include "dimensions.h" 180 181 include "paramet.h" 181 182 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: 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: 195 195 INTEGER :: iq, nid, vID, ierr, nid_trac, vID_trac 196 INTEGER, SAVE :: nb =0197 INTEGER, PARAMETER :: length =100198 REAL 199 CHARACTER(LEN =maxlen) :: var, dum200 LOGICAL 201 !===============================================================================202 203 !$OMP MASTER196 INTEGER, SAVE :: nb = 0 197 INTEGER, PARAMETER :: length = 100 198 REAL :: tab_cntrl(length) ! tableau des parametres du run 199 CHARACTER(LEN = maxlen) :: var, dum 200 LOGICAL :: lread_inca 201 !=============================================================================== 202 203 !$OMP MASTER 204 204 IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 205 modname='dynredem1_loc'; fil=fichnom206 CALL err(nf90_open(fil,nf90_write,nid),"open",fil)207 208 !--- Write/extend time coordinate209 nb = nb + 1210 var="temps"211 CALL err(nf90_inq_varid(nid,var,vID),"inq",var)212 CALL err(nf90_put_var(nid,vID,[time]),"put",var)213 WRITE(lunout,*)TRIM(modname)//": Saving for ", nb, time214 215 !--- Rewrite control table (itaufin undefined in dynredem0)216 var="controle"217 CALL err(nf90_inq_varid(nid,var,vID),"inq",var)218 CALL err(nf90_get_var(nid,vID,tab_cntrl),"get",var)219 tab_cntrl(31)=DBLE(itau_dyn + itaufin)220 CALL err(nf90_inq_varid(nid,var,vID),"inq",var)221 CALL err(nf90_put_var(nid,vID,tab_cntrl),"put",var)205 modname = 'dynredem1_loc'; fil = fichnom 206 CALL err(nf90_open(fil, nf90_write, nid), "open", fil) 207 208 !--- Write/extend time coordinate 209 nb = nb + 1 210 var = "temps" 211 CALL err(nf90_inq_varid(nid, var, vID), "inq", var) 212 CALL err(nf90_put_var(nid, vID, [time]), "put", var) 213 WRITE(lunout, *)TRIM(modname) // ": Saving for ", nb, time 214 215 !--- Rewrite control table (itaufin undefined in dynredem0) 216 var = "controle" 217 CALL err(nf90_inq_varid(nid, var, vID), "inq", var) 218 CALL err(nf90_get_var(nid, vID, tab_cntrl), "get", var) 219 tab_cntrl(31) = DBLE(itau_dyn + itaufin) 220 CALL err(nf90_inq_varid(nid, var, vID), "inq", var) 221 CALL err(nf90_put_var(nid, vID, tab_cntrl), "put", var) 222 222 END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 223 !$OMP END MASTER224 225 !--- Save fields226 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)231 232 !--- Tracers in file "start_trac.nc" (added by Anne)233 lread_inca =.FALSE.234 !$OMP MASTER235 fil ="start_trac.nc"236 IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE=fil,EXIST=lread_inca)237 IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite,nid_trac),"open")238 !$OMP END MASTER239 !$OMP BARRIER240 241 !--- Save tracers242 DO iq =1,nqtot; var=TRIM(tracers(iq)%name); ierr=-1243 244 !$OMP MASTER 245 fil="start_trac.nc"246 ierr=nf90_inq_varid(nid_trac,var,vID_trac)247 dum='inq'; IF(ierr==nf90_noerr) dum='fnd'248 WRITE(lunout,*)msg(dum,var)249 !$OMP END MASTER250 !$OMP BARRIER251 IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac,var,q(:,:,iq),llm)252 253 fil=fichnom254 CALL dynredem_write_u(nid,var,q(:,:,iq),llm)223 !$OMP END MASTER 224 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) 231 232 !--- Tracers in file "start_trac.nc" (added by Anne) 233 lread_inca = .FALSE. 234 !$OMP MASTER 235 fil = "start_trac.nc" 236 IF(ANY(type_trac == ['inca', 'inco'])) INQUIRE(FILE = fil, EXIST = lread_inca) 237 IF(lread_inca) CALL err(nf90_open(fil, nf90_nowrite, nid_trac), "open") 238 !$OMP END MASTER 239 !$OMP BARRIER 240 241 !--- Save tracers 242 DO iq = 1, nqtot; var = TRIM(tracers(iq)%name); ierr = -1 243 IF(lread_inca) THEN !--- Possibly read from "start_trac.nc" 244 !$OMP MASTER 245 fil = "start_trac.nc" 246 ierr = nf90_inq_varid(nid_trac, var, vID_trac) 247 dum = 'inq'; IF(ierr==nf90_noerr) dum = 'fnd' 248 WRITE(lunout, *)msg(dum, var) 249 !$OMP END MASTER 250 !$OMP BARRIER 251 IF(ierr==nf90_noerr) CALL dynredem_read_u(nid_trac, var, q(:, :, iq), llm) 252 END IF 253 fil = fichnom 254 CALL dynredem_write_u(nid, var, q(:, :, iq), llm) 255 255 END DO 256 256 257 !$OMP MASTER257 !$OMP MASTER 258 258 IF(mpi_rank==0) THEN !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 259 CALL err(nf90_close(nid),"close")260 fil="start_trac.nc"261 IF(lread_inca) CALL err(nf90_close(nid_trac),"close")259 CALL err(nf90_close(nid), "close") 260 fil = "start_trac.nc" 261 IF(lread_inca) CALL err(nf90_close(nid_trac), "close") 262 262 END IF !++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 263 !$OMP END MASTER263 !$OMP END MASTER 264 264 265 265 END SUBROUTINE dynredem1_loc
Note: See TracChangeset
for help on using the changeset viewer.