Changeset 3995 for LMDZ6/trunk/libf/dyn3d
- Timestamp:
- Oct 29, 2021, 5:38:11 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/trunk/libf/dyn3d/guide_mod.F90
r3803 r3995 9 9 !======================================================================= 10 10 11 USE getparam 11 USE getparam, only: ini_getparam, fin_getparam, getpar 12 12 USE Write_Field 13 use netcdf, only: nf90_nowrite, nf90_open, nf90_inq_varid, nf90_close 14 use pres2lev_mod 13 use netcdf, only: nf90_nowrite, nf90_open, nf90_inq_varid, nf90_close, & 14 nf90_inq_dimid, nf90_inquire_dimension 15 use pres2lev_mod, only: pres2lev 15 16 16 17 IMPLICIT NONE … … 20 21 ! --------------------------------------------- 21 22 INTEGER, PRIVATE, SAVE :: iguide_read,iguide_int,iguide_sav 22 INTEGER, PRIVATE, SAVE :: nlevnc 23 INTEGER, PRIVATE, SAVE :: nlevnc, guide_plevs 23 24 LOGICAL, PRIVATE, SAVE :: guide_u,guide_v,guide_T,guide_Q,guide_P 24 25 LOGICAL, PRIVATE, SAVE :: guide_hr,guide_teta 25 26 LOGICAL, PRIVATE, SAVE :: guide_BL,guide_reg,guide_add,gamma4,guide_zon 26 LOGICAL, PRIVATE, SAVE :: guide_modele,invert_p,invert_y,ini_anal 27 LOGICAL, PRIVATE, SAVE :: guide_2D,guide_sav 27 LOGICAL, PRIVATE, SAVE :: invert_p,invert_y,ini_anal 28 LOGICAL, PRIVATE, SAVE :: guide_2D,guide_sav,guide_modele 29 !FC 30 LOGICAL, PRIVATE, SAVE :: convert_Pa 28 31 29 32 REAL, PRIVATE, SAVE :: tau_min_u,tau_max_u … … 49 52 REAL, ALLOCATABLE, DIMENSION(:,:,:), PRIVATE, SAVE :: tnat1,tnat2 50 53 REAL, ALLOCATABLE, DIMENSION(:,:,:), PRIVATE, SAVE :: qnat1,qnat2 54 REAL, ALLOCATABLE, DIMENSION(:,:,:), PRIVATE, SAVE :: pnat1,pnat2 51 55 REAL, ALLOCATABLE, DIMENSION(:,:), PRIVATE, SAVE :: psnat1,psnat2 52 56 REAL, ALLOCATABLE, DIMENSION(:), PRIVATE, SAVE :: apnc,bpnc … … 75 79 CHARACTER (len = 80) :: abort_message 76 80 CHARACTER (len = 20) :: modname = 'guide_init' 81 CHARACTER (len = 20) :: namedim 77 82 78 83 ! --------------------------------------------- … … 140 145 iguide_int=day_step*iguide_int 141 146 ENDIF 142 CALL getpar('guide_modele',.false.,guide_modele,'guidage niveaux modele') 147 CALL getpar('guide_plevs',0,guide_plevs,'niveaux pression fichiers guidage') 148 ! Pour compatibilite avec ancienne version avec guide_modele 149 CALL getpar('guide_modele',.false.,guide_modele,'niveaux pression ap+bp*psol') 150 IF (guide_modele) THEN 151 guide_plevs=1 152 ENDIF 153 !FC 154 CALL getpar('convert_Pa',.true.,convert_Pa,'Convert Pressure levels in Pa') 155 ! Fin raccord 143 156 CALL getpar('ini_anal',.false.,ini_anal,'Etat initial = analyse') 144 157 CALL getpar('guide_invertp',.true.,invert_p,'niveaux p inverses') … … 153 166 ! --------------------------------------------- 154 167 ncidpl=-99 155 if (guide_ modele) then168 if (guide_plevs.EQ.1) then 156 169 if (ncidpl.eq.-99) then 157 170 rcod=nf90_open('apbp.nc',Nf90_NOWRITe, ncidpl) 158 171 if (rcod.NE.NF_NOERR) THEN 159 CALL abort_gcm(modname, &160 'Guide: probleme -> pas de fichier apbp.nc',1)172 abort_message=' Nudging error -> no file apbp.nc' 173 CALL abort_gcm(modname,abort_message,1) 161 174 endif 162 175 endif 163 else 164 if (guide_u) then 176 elseif (guide_plevs.EQ.2) then 177 if (ncidpl.EQ.-99) then 178 rcod=nf90_open('P.nc',Nf90_NOWRITe,ncidpl) 179 if (rcod.NE.NF_NOERR) THEN 180 abort_message=' Nudging error -> no file P.nc' 181 CALL abort_gcm(modname,abort_message,1) 182 endif 183 endif 184 185 elseif (guide_u) then 165 186 if (ncidpl.eq.-99) then 166 187 rcod=nf90_open('u.nc',Nf90_NOWRITe,ncidpl) 167 188 if (rcod.NE.NF_NOERR) THEN 168 189 CALL abort_gcm(modname, & 169 ' Guide: probleme -> pas de fichieru.nc',1)190 ' Nudging error -> no file u.nc',1) 170 191 endif 171 192 endif 172 elseif (guide_v) then 193 194 elseif (guide_v) then 173 195 if (ncidpl.eq.-99) then 174 196 rcod=nf90_open('v.nc',nf90_nowrite,ncidpl) 175 197 if (rcod.NE.NF_NOERR) THEN 176 198 CALL abort_gcm(modname, & 177 ' Guide: probleme -> pas de fichierv.nc',1)199 ' Nudging error -> no file v.nc',1) 178 200 endif 179 201 endif 180 202 elseif (guide_T) then 181 203 if (ncidpl.eq.-99) then 182 204 rcod=nf90_open('T.nc',nf90_nowrite,ncidpl) 183 205 if (rcod.NE.NF_NOERR) THEN 184 206 CALL abort_gcm(modname, & 185 ' Guide: probleme -> pas de fichierT.nc',1)207 ' Nudging error -> no file T.nc',1) 186 208 endif 187 209 endif 188 210 elseif (guide_Q) then 189 211 if (ncidpl.eq.-99) then 190 212 rcod=nf90_open('hur.nc',nf90_nowrite, ncidpl) 191 213 if (rcod.NE.NF_NOERR) THEN 192 214 CALL abort_gcm(modname, & 193 ' Guide: probleme -> pas de fichierhur.nc',1)215 ' Nudging error -> no file hur.nc',1) 194 216 endif 195 217 endif 196 endif 218 219 197 220 endif 198 221 error=NF_INQ_DIMID(ncidpl,'LEVEL',rid) 199 222 IF (error.NE.NF_NOERR) error=NF_INQ_DIMID(ncidpl,'PRESSURE',rid) 200 223 IF (error.NE.NF_NOERR) THEN 201 CALL abort_gcm(modname,' Guide: probleme lecture niveaux pression',1)224 CALL abort_gcm(modname,'Nudging: error reading pressure levels',1) 202 225 ENDIF 203 226 error=NF_INQ_DIMLEN(ncidpl,rid,nlevnc) 204 print *,'Guide: nombre niveaux vert.nlevnc', nlevnc227 write(*,*)trim(modname)//' : number of vertical levels nlevnc', nlevnc 205 228 rcod = nf90_close(ncidpl) 206 229 … … 208 231 ! Allocation des variables 209 232 ! --------------------------------------------- 210 abort_message=' pb in allocation guide'233 abort_message='nudging allocation error' 211 234 212 235 ALLOCATE(apnc(nlevnc), stat = error) … … 278 301 ENDIF 279 302 280 IF (guide_P.OR.guide_modele) THEN 303 IF (guide_plevs.EQ.2) THEN 304 ALLOCATE(pnat1(iip1,jjp1,nlevnc), stat = error) 305 IF (error /= 0) CALL abort_gcm(modname,abort_message,1) 306 ALLOCATE(pnat2(iip1,jjp1,nlevnc), stat = error) 307 IF (error /= 0) CALL abort_gcm(modname,abort_message,1) 308 pnat1=0.;pnat2=0.; 309 ENDIF 310 311 IF (guide_P.OR.guide_plevs.EQ.1) THEN 281 312 ALLOCATE(psnat1(iip1,jjp1), stat = error) 282 313 IF (error /= 0) CALL abort_gcm(modname,abort_message,1) … … 305 336 IF (guide_T) tnat1=tnat2 306 337 IF (guide_Q) qnat1=qnat2 307 IF (guide_P.OR.guide_modele) psnat1=psnat2 338 IF (guide_plevs.EQ.2) pnat1=pnat2 339 IF (guide_P.OR.guide_plevs.EQ.1) psnat1=psnat2 308 340 309 341 END SUBROUTINE guide_init … … 312 344 SUBROUTINE guide_main(itau,ucov,vcov,teta,q,masse,ps) 313 345 346 USE exner_hyb_m, ONLY: exner_hyb 347 USE exner_milieu_m, ONLY: exner_milieu 314 348 USE control_mod, ONLY: day_step, iperiod 315 USE comconst_mod, ONLY: dtvr, daysec316 USE comvert_mod, ONLY: ap, bp, preff, presnivs 349 USE comconst_mod, ONLY: cpp, dtvr, daysec,kappa 350 USE comvert_mod, ONLY: ap, bp, preff, presnivs, pressure_exner 317 351 318 352 IMPLICIT NONE … … 331 365 LOGICAL :: f_out ! sortie guidage 332 366 REAL, DIMENSION (ip1jmp1,llm) :: f_add ! var aux: champ de guidage 333 REAL, DIMENSION (ip1jmp1,llm) :: p ! besoin si guide_P 367 REAL :: pk(ip1jmp1,llm) ! Exner at mid-layers 368 REAL :: pks(ip1jmp1) ! Exner at the surface 369 REAL :: unskap ! 1./kappa 370 REAL, DIMENSION (ip1jmp1,llmp1) :: p ! Pressure at inter-layers 334 371 ! Compteurs temps: 335 372 INTEGER, SAVE :: step_rea,count_no_rea,itau_test ! lecture guidage … … 339 376 340 377 INTEGER :: l 378 CHARACTER(LEN=20) :: modname="guide_main" 341 379 342 380 !----------------------------------------------------------------------- … … 379 417 ENDIF 380 418 ! Verification structure guidage 381 IF (guide_u) THEN382 CALL writefield('unat',unat1)383 CALL writefield('ucov',RESHAPE(ucov,(/iip1,jjp1,llm/)))384 ENDIF385 IF (guide_T) THEN386 CALL writefield('tnat',tnat1)387 CALL writefield('teta',RESHAPE(teta,(/iip1,jjp1,llm/)))388 ENDIF419 ! IF (guide_u) THEN 420 ! CALL writefield('unat',unat1) 421 ! CALL writefield('ucov',RESHAPE(ucov,(/iip1,jjp1,llm/))) 422 ! ENDIF 423 ! IF (guide_T) THEN 424 ! CALL writefield('tnat',tnat1) 425 ! CALL writefield('teta',RESHAPE(teta,(/iip1,jjp1,llm/))) 426 ! ENDIF 389 427 390 428 ENDIF !first … … 404 442 IF (reste.EQ.0.) THEN 405 443 IF (itau_test.EQ.itau) THEN 406 write(*,*)'deuxieme passage de advreel a itau=',itau 407 stop 444 write(*,*)trim(modname)//' second pass in advreel at itau=',& 445 itau 446 stop 408 447 ELSE 409 448 IF (guide_v) vnat1=vnat2 … … 411 450 IF (guide_T) tnat1=tnat2 412 451 IF (guide_Q) qnat1=qnat2 413 IF (guide_P.OR.guide_modele) psnat1=psnat2 452 IF (guide_plevs.EQ.2) pnat1=pnat2 453 IF (guide_P.OR.guide_plevs.EQ.1) psnat1=psnat2 414 454 step_rea=step_rea+1 415 455 itau_test=itau 416 print*,'Lecture fichiers guidage, pas ',step_rea,&417 'apres ',count_no_rea,' non lectures'456 write(*,*)trim(modname)//' Reading nudging files, step ',& 457 step_rea,'after ',count_no_rea,' skips' 418 458 IF (guide_2D) THEN 419 459 CALL guide_read2D(step_rea) … … 447 487 ! Sauvegarde du guidage? 448 488 f_out=((MOD(itau,iguide_sav).EQ.0).AND.guide_sav) 449 IF (f_out) CALL guide_out("SP",jjp1,1,ps) 489 IF (f_out) THEN 490 ! compute pressures at layer interfaces 491 CALL pression(ip1jmp1,ap,bp,ps,p) 492 if (pressure_exner) then 493 call exner_hyb(ip1jmp1,ps,p,pks,pk) 494 else 495 call exner_milieu(ip1jmp1,ps,p,pks,pk) 496 endif 497 unskap=1./kappa 498 ! Now compute pressures at mid-layer 499 do l=1,llm 500 p(:,l)=preff*(pk(:,l)/cpp)**unskap 501 enddo 502 CALL guide_out("SP",jjp1,llm,p(:,1:llm)) 503 ENDIF 450 504 451 505 if (guide_u) then … … 483 537 if (guide_zon) CALL guide_zonave(2,jjp1,1,f_add(1:ip1jmp1,1)) 484 538 CALL guide_addfield(ip1jmp1,1,f_add(1:ip1jmp1,1),alpha_P) 485 IF (f_out) CALL guide_out("ps",jjp1,1,f_add(1:ip1jmp1,1)/factt)539 ! IF (f_out) CALL guide_out("ps",jjp1,1,f_add(1:ip1jmp1,1)/factt) 486 540 ps=ps+f_add(1:ip1jmp1,1) 487 541 CALL pression(ip1jmp1,ap,bp,ps,p) … … 637 691 638 692 INTEGER :: i,j,l,ij 693 CHARACTER(LEN=20),PARAMETER :: modname="guide_interp" 639 694 640 print *,'Guide: conversion variables guidage'695 write(*,*)trim(modname)//': interpolate nudging variables' 641 696 ! ----------------------------------------------------------------- 642 697 ! Calcul des niveaux de pression champs guidage … … 664 719 if (first) then 665 720 first=.FALSE. 666 print*,'Guide: verification ordre niveaux verticaux'667 print*,'LMDZ :'721 write(*,*)trim(modname)//' : check vertical level order' 722 write(*,*)trim(modname)//' LMDZ :' 668 723 do l=1,llm 669 print*,'PL(',l,')=',(ap(l)+ap(l+1))/2. &724 write(*,*)trim(modname)//' PL(',l,')=',(ap(l)+ap(l+1))/2. & 670 725 +psi(1,jjp1)*(bp(l)+bp(l+1))/2. 671 726 enddo 672 print*,'Fichiers guidage'727 write(*,*)trim(modname)//' nudging file :' 673 728 do l=1,nlevnc 674 print*,'PL(',l,')=',plnc2(1,1,l)729 write(*,*)trim(modname)//' PL(',l,')=',plnc2(1,1,l) 675 730 enddo 676 print *,'inversion de l''ordre: invert_p=',invert_p731 write(*,*)trim(modname)//' invert ordering: invert_p=',invert_p 677 732 if (guide_u) then 678 733 do l=1,nlevnc 679 print*,'U(',l,')=',unat2(1,1,l)734 write(*,*)trim(modname)//' U(',l,')=',unat2(1,1,l) 680 735 enddo 681 736 endif 682 737 if (guide_T) then 683 738 do l=1,nlevnc 684 print*,'T(',l,')=',tnat2(1,1,l)739 write(*,*)trim(modname)//' T(',l,')=',tnat2(1,1,l) 685 740 enddo 686 741 endif … … 881 936 real alphamin,alphamax,xi 882 937 integer i,j,ilon,ilat 938 character(len=20),parameter :: modname="tau2alpha" 883 939 884 940 … … 969 1025 ! Calcul de gamma 970 1026 if (abs(grossismx-1.).lt.0.1.or.abs(grossismy-1.).lt.0.1) then 971 print*,'ATTENTION modele peu zoome'972 print*,'ATTENTION on prend une constante de guidage cste'973 1027 write(*,*)trim(modname)//' ATTENTION modele peu zoome' 1028 write(*,*)trim(modname)//' ATTENTION on prend une constante de guidage cste' 1029 gamma=0. 974 1030 else 975 976 print*,'gamma=',gamma977 978 print*,'gamma =',gamma,'<1e-5'979 980 981 982 983 984 985 print*,'gamma=',gamma1031 gamma=(dxdy_max-2.*dxdy_min)/(dxdy_max-dxdy_min) 1032 write(*,*)trim(modname)//' gamma=',gamma 1033 if (gamma.lt.1.e-5) then 1034 write(*,*)trim(modname)//' gamma =',gamma,'<1e-5' 1035 stop 1036 endif 1037 gamma=log(0.5)/log(gamma) 1038 if (gamma4) then 1039 gamma=min(gamma,4.) 1040 endif 1041 write(*,*)trim(modname)//' gamma=',gamma 986 1042 endif 987 1043 ENDIF !first … … 1024 1080 IMPLICIT NONE 1025 1081 1026 #include "netcdf.inc"1027 #include "dimensions.h"1028 #include "paramet.h"1082 include "netcdf.inc" 1083 include "dimensions.h" 1084 include "paramet.h" 1029 1085 1030 1086 INTEGER, INTENT(IN) :: timestep … … 1032 1088 LOGICAL, SAVE :: first=.TRUE. 1033 1089 ! Identification fichiers et variables NetCDF: 1034 INTEGER, SAVE :: ncidu,varidu,ncidv,varidv,ncid Q1035 INTEGER, SAVE :: varidQ,ncidt,varidt,ncidps,varidps1036 INTEGER :: ncidpl,varidpl,varidap,varidbp 1090 INTEGER, SAVE :: ncidu,varidu,ncidv,varidv,ncidp,varidp 1091 INTEGER, SAVE :: ncidQ,varidQ,ncidt,varidt,ncidps,varidps 1092 INTEGER :: ncidpl,varidpl,varidap,varidbp,dimid,lendim 1037 1093 ! Variables auxiliaires NetCDF: 1038 1094 INTEGER, DIMENSION(4) :: start,count 1039 1095 INTEGER :: status,rcode 1040 1041 1096 CHARACTER (len = 80) :: abort_message 1042 1097 CHARACTER (len = 20) :: modname = 'guide_read' 1098 CHARACTER (len = 20) :: namedim 1099 1043 1100 ! ----------------------------------------------------------------- 1044 1101 ! Premier appel: initialisation de la lecture des fichiers … … 1046 1103 if (first) then 1047 1104 ncidpl=-99 1048 print*,'Guide: ouverture des fichiers guidage'1105 write(*,*),trim(modname)//': opening nudging files ' 1049 1106 ! Niveaux de pression si non constants 1050 if (guide_ modele) then1051 print *,'Lecture du guidage sur niveaux modele'1107 if (guide_plevs.EQ.1) then 1108 write(*,*),trim(modname)//' Reading nudging on model levels' 1052 1109 rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl) 1053 1110 IF (rcode.NE.NF_NOERR) THEN 1054 print *,'Guide: probleme -> pas de fichierapbp.nc'1111 abort_message='Nudging: error -> no file apbp.nc' 1055 1112 CALL abort_gcm(modname,abort_message,1) 1056 1113 ENDIF 1057 1114 rcode = nf90_inq_varid(ncidpl, 'AP', varidap) 1058 1115 IF (rcode.NE.NF_NOERR) THEN 1059 print *,'Guide: probleme -> pas de variable AP, fichierapbp.nc'1116 abort_message='Nudging: error -> no AP variable in file apbp.nc' 1060 1117 CALL abort_gcm(modname,abort_message,1) 1061 1118 ENDIF 1062 1119 rcode = nf90_inq_varid(ncidpl, 'BP', varidbp) 1063 1120 IF (rcode.NE.NF_NOERR) THEN 1064 print *,'Guide: probleme -> pas de variable BP, fichierapbp.nc'1121 abort_message='Nudging: error -> no BP variable in file apbp.nc' 1065 1122 CALL abort_gcm(modname,abort_message,1) 1066 1123 ENDIF 1067 print*,'ncidpl,varidap',ncidpl,varidap1124 write(*,*),trim(modname)//' ncidpl,varidap',ncidpl,varidap 1068 1125 endif 1126 1127 ! Pression si guidage sur niveaux P variables 1128 if (guide_plevs.EQ.2) then 1129 rcode = nf90_open('P.nc', nf90_nowrite, ncidp) 1130 IF (rcode.NE.NF_NOERR) THEN 1131 abort_message='Nudging: error -> no file P.nc' 1132 CALL abort_gcm(modname,abort_message,1) 1133 ENDIF 1134 rcode = nf90_inq_varid(ncidp, 'PRES', varidp) 1135 IF (rcode.NE.NF_NOERR) THEN 1136 abort_message='Nudging: error -> no PRES variable in file P.nc' 1137 CALL abort_gcm(modname,abort_message,1) 1138 ENDIF 1139 write(*,*),trim(modname)//' ncidp,varidp',ncidp,varidp 1140 if (ncidpl.eq.-99) ncidpl=ncidp 1141 endif 1142 1069 1143 ! Vent zonal 1070 1144 if (guide_u) then 1071 1145 rcode = nf90_open('u.nc', nf90_nowrite, ncidu) 1072 1146 IF (rcode.NE.NF_NOERR) THEN 1073 print *,'Guide: probleme -> pas de fichieru.nc'1147 abort_message='Nudging: error -> no file u.nc' 1074 1148 CALL abort_gcm(modname,abort_message,1) 1075 1149 ENDIF 1076 1150 rcode = nf90_inq_varid(ncidu, 'UWND', varidu) 1077 1151 IF (rcode.NE.NF_NOERR) THEN 1078 print *,'Guide: probleme -> pas de variable UWND, fichieru.nc'1152 abort_message='Nudging: error -> no UWND variable in file u.nc' 1079 1153 CALL abort_gcm(modname,abort_message,1) 1080 1154 ENDIF 1081 print*,'ncidu,varidu',ncidu,varidu1155 write(*,*),trim(modname)//' ncidu,varidu',ncidu,varidu 1082 1156 if (ncidpl.eq.-99) ncidpl=ncidu 1157 1158 status=NF90_INQ_DIMID(ncidu, "LONU", dimid) 1159 status=NF90_INQUIRE_DIMENSION(ncidu,dimid,namedim,lendim) 1160 IF (lendim .NE. iip1) THEN 1161 abort_message='dimension LONU different from iip1 in u.nc' 1162 CALL abort_gcm(modname,abort_message,1) 1163 ENDIF 1164 1165 status=NF90_INQ_DIMID(ncidu, "LATU", dimid) 1166 status=NF90_INQUIRE_DIMENSION(ncidu,dimid,namedim,lendim) 1167 IF (lendim .NE. jjp1) THEN 1168 abort_message='dimension LATU different from jjp1 in u.nc' 1169 CALL abort_gcm(modname,abort_message,1) 1170 ENDIF 1171 1083 1172 endif 1173 1084 1174 ! Vent meridien 1085 1175 if (guide_v) then 1086 1176 rcode = nf90_open('v.nc', nf90_nowrite, ncidv) 1087 1177 IF (rcode.NE.NF_NOERR) THEN 1088 print *,'Guide: probleme -> pas de fichierv.nc'1178 abort_message='Nudging: error -> no file v.nc' 1089 1179 CALL abort_gcm(modname,abort_message,1) 1090 1180 ENDIF 1091 1181 rcode = nf90_inq_varid(ncidv, 'VWND', varidv) 1092 1182 IF (rcode.NE.NF_NOERR) THEN 1093 print *,'Guide: probleme -> pas de variable VWND, fichierv.nc'1183 abort_message='Nudging: error -> no VWND variable in file v.nc' 1094 1184 CALL abort_gcm(modname,abort_message,1) 1095 1185 ENDIF 1096 print*,'ncidv,varidv',ncidv,varidv1186 write(*,*),trim(modname)//' ncidv,varidv',ncidv,varidv 1097 1187 if (ncidpl.eq.-99) ncidpl=ncidv 1188 1189 status=NF90_INQ_DIMID(ncidv, "LONV", dimid) 1190 status=NF90_INQUIRE_DIMENSION(ncidv,dimid,namedim,lendim) 1191 1192 IF (lendim .NE. iip1) THEN 1193 abort_message='dimension LONV different from iip1 in v.nc' 1194 CALL abort_gcm(modname,abort_message,1) 1195 ENDIF 1196 1197 1198 status=NF90_INQ_DIMID(ncidv, "LATV", dimid) 1199 status=NF90_INQUIRE_DIMENSION(ncidv,dimid,namedim,lendim) 1200 IF (lendim .NE. jjm) THEN 1201 abort_message='dimension LATV different from jjm in v.nc' 1202 CALL abort_gcm(modname,abort_message,1) 1203 ENDIF 1204 1098 1205 endif 1206 1099 1207 ! Temperature 1100 1208 if (guide_T) then 1101 1209 rcode = nf90_open('T.nc', nf90_nowrite, ncidt) 1102 1210 IF (rcode.NE.NF_NOERR) THEN 1103 print *,'Guide: probleme -> pas de fichierT.nc'1211 abort_message='Nudging: error -> no file T.nc' 1104 1212 CALL abort_gcm(modname,abort_message,1) 1105 1213 ENDIF 1106 1214 rcode = nf90_inq_varid(ncidt, 'AIR', varidt) 1107 1215 IF (rcode.NE.NF_NOERR) THEN 1108 print *,'Guide: probleme -> pas de variable AIR, fichierT.nc'1216 abort_message='Nudging: error -> no AIR variable in file T.nc' 1109 1217 CALL abort_gcm(modname,abort_message,1) 1110 1218 ENDIF 1111 print*,'ncidT,varidT',ncidt,varidt1219 write(*,*),trim(modname)//' ncidT,varidT',ncidt,varidt 1112 1220 if (ncidpl.eq.-99) ncidpl=ncidt 1221 1222 status=NF90_INQ_DIMID(ncidt, "LONV", dimid) 1223 status=NF90_INQUIRE_DIMENSION(ncidt,dimid,namedim,lendim) 1224 IF (lendim .NE. iip1) THEN 1225 abort_message='dimension LONV different from iip1 in T.nc' 1226 CALL abort_gcm(modname,abort_message,1) 1227 ENDIF 1228 1229 status=NF90_INQ_DIMID(ncidt, "LATU", dimid) 1230 status=NF90_INQUIRE_DIMENSION(ncidt,dimid,namedim,lendim) 1231 IF (lendim .NE. jjp1) THEN 1232 abort_message='dimension LATU different from jjp1 in T.nc' 1233 CALL abort_gcm(modname,abort_message,1) 1234 ENDIF 1235 1113 1236 endif 1237 1114 1238 ! Humidite 1115 1239 if (guide_Q) then 1116 1240 rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ) 1117 1241 IF (rcode.NE.NF_NOERR) THEN 1118 print *,'Guide: probleme -> pas de fichierhur.nc'1242 abort_message='Nudging: error -> no file hur.nc' 1119 1243 CALL abort_gcm(modname,abort_message,1) 1120 1244 ENDIF 1121 1245 rcode = nf90_inq_varid(ncidQ, 'RH', varidQ) 1122 1246 IF (rcode.NE.NF_NOERR) THEN 1123 print *,'Guide: probleme -> pas de variable RH, fichierhur.nc'1247 abort_message='Nudging: error -> no RH variable in file hur.nc' 1124 1248 CALL abort_gcm(modname,abort_message,1) 1125 1249 ENDIF 1126 print*,'ncidQ,varidQ',ncidQ,varidQ1250 write(*,*),trim(modname)//' ncidQ,varidQ',ncidQ,varidQ 1127 1251 if (ncidpl.eq.-99) ncidpl=ncidQ 1252 1253 status=NF90_INQ_DIMID(ncidQ, "LONV", dimid) 1254 status=NF90_INQUIRE_DIMENSION(ncidQ,dimid,namedim,lendim) 1255 IF (lendim .NE. iip1) THEN 1256 abort_message='dimension LONV different from iip1 in hur.nc' 1257 CALL abort_gcm(modname,abort_message,1) 1258 ENDIF 1259 1260 status=NF90_INQ_DIMID(ncidQ, "LATU", dimid) 1261 status=NF90_INQUIRE_DIMENSION(ncidQ,dimid,namedim,lendim) 1262 IF (lendim .NE. jjp1) THEN 1263 abort_message='dimension LATU different from jjp1 in hur.nc' 1264 CALL abort_gcm(modname,abort_message,1) 1265 ENDIF 1266 1128 1267 endif 1268 1129 1269 ! Pression de surface 1130 1270 if ((guide_P).OR.(guide_modele)) then 1131 1271 rcode = nf90_open('ps.nc', nf90_nowrite, ncidps) 1132 1272 IF (rcode.NE.NF_NOERR) THEN 1133 print *,'Guide: probleme -> pas de fichierps.nc'1273 abort_message='Nudging: error -> no file ps.nc' 1134 1274 CALL abort_gcm(modname,abort_message,1) 1135 1275 ENDIF 1136 1276 rcode = nf90_inq_varid(ncidps, 'SP', varidps) 1137 1277 IF (rcode.NE.NF_NOERR) THEN 1138 print *,'Guide: probleme -> pas de variable SP, fichierps.nc'1278 abort_message='Nudging: error -> no SP variable in file ps.nc' 1139 1279 CALL abort_gcm(modname,abort_message,1) 1140 1280 ENDIF 1141 print*,'ncidps,varidps',ncidps,varidps1281 write(*,*),trim(modname)//' ncidps,varidps',ncidps,varidps 1142 1282 endif 1143 1283 ! Coordonnee verticale 1144 if ( .not.guide_modele) then1284 if (guide_plevs.EQ.0) then 1145 1285 rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl) 1146 1286 IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl) 1147 print*,'ncidpl,varidpl',ncidpl,varidpl1287 write(*,*),trim(modname)//' ncidpl,varidpl',ncidpl,varidpl 1148 1288 endif 1149 1289 ! Coefs ap, bp pour calcul de la pression aux differents niveaux 1150 if (guide_ modele) then1290 if (guide_plevs.EQ.1) then 1151 1291 #ifdef NC_DOUBLE 1152 1292 status=NF_GET_VARA_DOUBLE(ncidpl,varidap,1,nlevnc,apnc) … … 1156 1296 status=NF_GET_VARA_REAL(ncidpl,varidbp,1,nlevnc,bpnc) 1157 1297 #endif 1158 else1298 ELSEIF (guide_plevs.EQ.0) THEN 1159 1299 #ifdef NC_DOUBLE 1160 1300 status=NF_GET_VARA_DOUBLE(ncidpl,varidpl,1,nlevnc,apnc) … … 1162 1302 status=NF_GET_VARA_REAL(ncidpl,varidpl,1,nlevnc,apnc) 1163 1303 #endif 1164 apnc=apnc*100.! conversion en Pascals 1304 !FC Pour les corrections la pression est deja en Pascals on commente la ligne ci-dessous 1305 IF(convert_Pa) apnc=apnc*100.! conversion en Pascals 1165 1306 bpnc(:)=0. 1166 1307 endif … … 1182 1323 count(3)=nlevnc 1183 1324 count(4)=1 1325 1326 ! Pression 1327 if (guide_plevs.EQ.2) then 1328 #ifdef NC_DOUBLE 1329 status=NF_GET_VARA_DOUBLE(ncidp,varidp,start,count,pnat2) 1330 #else 1331 status=NF_GET_VARA_REAL(ncidp,varidp,start,count,pnat2) 1332 #endif 1333 IF (invert_y) THEN 1334 ! PRINT*,"Invertion impossible actuellement" 1335 ! CALL abort_gcm(modname,abort_message,1) 1336 CALL invert_lat(iip1,jjp1,nlevnc,pnat2) 1337 ENDIF 1338 endif 1184 1339 1185 1340 ! Vent zonal … … 1257 1412 IMPLICIT NONE 1258 1413 1259 #include "netcdf.inc"1260 #include "dimensions.h"1261 #include "paramet.h"1414 include "netcdf.inc" 1415 include "dimensions.h" 1416 include "paramet.h" 1262 1417 1263 1418 INTEGER, INTENT(IN) :: timestep … … 1265 1420 LOGICAL, SAVE :: first=.TRUE. 1266 1421 ! Identification fichiers et variables NetCDF: 1267 INTEGER, SAVE :: ncidu,varidu,ncidv,varidv,ncid Q1268 INTEGER, SAVE :: varidQ,ncidt,varidt,ncidps,varidps1422 INTEGER, SAVE :: ncidu,varidu,ncidv,varidv,ncidp,varidp 1423 INTEGER, SAVE :: ncidQ,varidQ,ncidt,varidt,ncidps,varidps 1269 1424 INTEGER :: ncidpl,varidpl,varidap,varidbp 1270 1425 ! Variables auxiliaires NetCDF: … … 1283 1438 if (first) then 1284 1439 ncidpl=-99 1285 print*,'Guide: ouverture des fichiers guidage ' 1286 ! Niveaux de pression si non constants 1287 if (guide_modele) then 1288 print *,'Lecture du guidage sur niveaux modele' 1289 rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl) 1290 IF (rcode.NE.NF_NOERR) THEN 1291 print *,'Guide: probleme -> pas de fichier apbp.nc' 1292 CALL abort_gcm(modname,abort_message,1) 1293 ENDIF 1294 rcode = nf90_inq_varid(ncidpl, 'AP', varidap) 1295 IF (rcode.NE.NF_NOERR) THEN 1296 print *,'Guide: probleme -> pas de variable AP, fichier apbp.nc' 1297 CALL abort_gcm(modname,abort_message,1) 1298 ENDIF 1299 rcode = nf90_inq_varid(ncidpl, 'BP', varidbp) 1300 IF (rcode.NE.NF_NOERR) THEN 1301 print *,'Guide: probleme -> pas de variable BP, fichier apbp.nc' 1302 CALL abort_gcm(modname,abort_message,1) 1303 ENDIF 1304 print*,'ncidpl,varidap',ncidpl,varidap 1440 write(*,*)trim(modname)//' : opening nudging files ' 1441 ! Ap et Bp si niveaux de pression hybrides 1442 if (guide_plevs.EQ.1) then 1443 write(*,*)trim(modname)//' Reading nudging on model levels' 1444 rcode = nf90_open('apbp.nc', nf90_nowrite, ncidpl) 1445 IF (rcode.NE.NF_NOERR) THEN 1446 abort_message='Nudging: error -> no file apbp.nc' 1447 CALL abort_gcm(modname,abort_message,1) 1448 ENDIF 1449 rcode = nf90_inq_varid(ncidpl, 'AP', varidap) 1450 IF (rcode.NE.NF_NOERR) THEN 1451 abort_message='Nudging: error -> no AP variable in file apbp.nc' 1452 CALL abort_gcm(modname,abort_message,1) 1453 ENDIF 1454 rcode = nf90_inq_varid(ncidpl, 'BP', varidbp) 1455 IF (rcode.NE.NF_NOERR) THEN 1456 abort_message='Nudging: error -> no BP variable in file apbp.nc' 1457 CALL abort_gcm(modname,abort_message,1) 1458 ENDIF 1459 write(*,*)trim(modname)//'ncidpl,varidap',ncidpl,varidap 1460 endif 1461 ! Pression 1462 if (guide_plevs.EQ.2) then 1463 rcode = nf90_open('P.nc', nf90_nowrite, ncidp) 1464 IF (rcode.NE.NF_NOERR) THEN 1465 abort_message='Nudging: error -> no file P.nc' 1466 CALL abort_gcm(modname,abort_message,1) 1467 ENDIF 1468 rcode = nf90_inq_varid(ncidp, 'PRES', varidp) 1469 IF (rcode.NE.NF_NOERR) THEN 1470 abort_message='Nudging: error -> no PRES variable in file P.nc' 1471 CALL abort_gcm(modname,abort_message,1) 1472 ENDIF 1473 write(*,*)trim(modname)//' ncidp,varidp',ncidp,varidp 1474 if (ncidpl.eq.-99) ncidpl=ncidp 1305 1475 endif 1306 1476 ! Vent zonal 1307 1477 if (guide_u) then 1308 1309 1310 print *,'Guide: probleme -> pas de fichieru.nc'1311 1312 1313 1314 1315 print *,'Guide: probleme -> pas de variable UWND, fichieru.nc'1316 1317 1318 print*,'ncidu,varidu',ncidu,varidu1319 1478 rcode = nf90_open('u.nc', nf90_nowrite, ncidu) 1479 IF (rcode.NE.NF_NOERR) THEN 1480 abort_message='Nudging: error -> no file u.nc' 1481 CALL abort_gcm(modname,abort_message,1) 1482 ENDIF 1483 rcode = nf90_inq_varid(ncidu, 'UWND', varidu) 1484 IF (rcode.NE.NF_NOERR) THEN 1485 abort_message='Nudging: error -> no UWND variable in file u.nc' 1486 CALL abort_gcm(modname,abort_message,1) 1487 ENDIF 1488 write(*,*)trim(modname)//' ncidu,varidu',ncidu,varidu 1489 if (ncidpl.eq.-99) ncidpl=ncidu 1320 1490 endif 1321 1491 ! Vent meridien 1322 1492 if (guide_v) then 1323 1324 1325 print *,'Guide: probleme -> pas de fichierv.nc'1326 1327 1328 1329 1330 print *,'Guide: probleme -> pas de variable VWND, fichierv.nc'1331 1332 1333 print*,'ncidv,varidv',ncidv,varidv1334 1493 rcode = nf90_open('v.nc', nf90_nowrite, ncidv) 1494 IF (rcode.NE.NF_NOERR) THEN 1495 abort_message='Nudging: error -> no file v.nc' 1496 CALL abort_gcm(modname,abort_message,1) 1497 ENDIF 1498 rcode = nf90_inq_varid(ncidv, 'VWND', varidv) 1499 IF (rcode.NE.NF_NOERR) THEN 1500 abort_message='Nudging: error -> no VWND variable in file v.nc' 1501 CALL abort_gcm(modname,abort_message,1) 1502 ENDIF 1503 write(*,*)trim(modname)//' ncidv,varidv',ncidv,varidv 1504 if (ncidpl.eq.-99) ncidpl=ncidv 1335 1505 endif 1336 1506 ! Temperature 1337 1507 if (guide_T) then 1338 1339 1340 print *,'Guide: probleme -> pas de fichierT.nc'1341 1342 1343 1344 1345 print *,'Guide: probleme -> pas de variable AIR, fichierT.nc'1346 1347 1348 print*,'ncidT,varidT',ncidt,varidt1349 1508 rcode = nf90_open('T.nc', nf90_nowrite, ncidt) 1509 IF (rcode.NE.NF_NOERR) THEN 1510 abort_message='Nudging: error -> no file T.nc' 1511 CALL abort_gcm(modname,abort_message,1) 1512 ENDIF 1513 rcode = nf90_inq_varid(ncidt, 'AIR', varidt) 1514 IF (rcode.NE.NF_NOERR) THEN 1515 abort_message='Nudging: error -> no AIR variable in file T.nc' 1516 CALL abort_gcm(modname,abort_message,1) 1517 ENDIF 1518 write(*,*)trim(modname)//' ncidT,varidT',ncidt,varidt 1519 if (ncidpl.eq.-99) ncidpl=ncidt 1350 1520 endif 1351 1521 ! Humidite 1352 1522 if (guide_Q) then 1353 1354 1355 print *,'Guide: probleme -> pas de fichierhur.nc'1356 1357 1358 1359 1360 print *,'Guide: probleme -> pas de variable RH, fichierhur.nc'1361 1362 1363 print*,'ncidQ,varidQ',ncidQ,varidQ1364 1523 rcode = nf90_open('hur.nc', nf90_nowrite, ncidQ) 1524 IF (rcode.NE.NF_NOERR) THEN 1525 abort_message='Nudging: error -> no file hur.nc' 1526 CALL abort_gcm(modname,abort_message,1) 1527 ENDIF 1528 rcode = nf90_inq_varid(ncidQ, 'RH', varidQ) 1529 IF (rcode.NE.NF_NOERR) THEN 1530 abort_message='Nudging: error -> no RH,variable in file hur.nc' 1531 CALL abort_gcm(modname,abort_message,1) 1532 ENDIF 1533 write(*,*)trim(modname)//' ncidQ,varidQ',ncidQ,varidQ 1534 if (ncidpl.eq.-99) ncidpl=ncidQ 1365 1535 endif 1366 1536 ! Pression de surface 1367 1537 if ((guide_P).OR.(guide_modele)) then 1368 1369 1370 print *,'Guide: probleme -> pas de fichierps.nc'1371 1372 1373 1374 1375 print *,'Guide: probleme -> pas de variable SP, fichierps.nc'1376 1377 1378 print*,'ncidps,varidps',ncidps,varidps1538 rcode = nf90_open('ps.nc', nf90_nowrite, ncidps) 1539 IF (rcode.NE.NF_NOERR) THEN 1540 abort_message='Nudging: error -> no file ps.nc' 1541 CALL abort_gcm(modname,abort_message,1) 1542 ENDIF 1543 rcode = nf90_inq_varid(ncidps, 'SP', varidps) 1544 IF (rcode.NE.NF_NOERR) THEN 1545 abort_message='Nudging: error -> no SP variable in file ps.nc' 1546 CALL abort_gcm(modname,abort_message,1) 1547 ENDIF 1548 write(*,*)trim(modname)//' ncidps,varidps',ncidps,varidps 1379 1549 endif 1380 1550 ! Coordonnee verticale 1381 if ( .not.guide_modele) then1382 1383 1384 print*,'ncidpl,varidpl',ncidpl,varidpl1551 if (guide_plevs.EQ.0) then 1552 rcode = nf90_inq_varid(ncidpl, 'LEVEL', varidpl) 1553 IF (rcode.NE.0) rcode = nf90_inq_varid(ncidpl, 'PRESSURE', varidpl) 1554 write(*,*)trim(modname)//' ncidpl,varidpl',ncidpl,varidpl 1385 1555 endif 1386 1556 ! Coefs ap, bp pour calcul de la pression aux differents niveaux 1387 if (guide_ modele) then1557 if (guide_plevs.EQ.1) then 1388 1558 #ifdef NC_DOUBLE 1389 1559 status=NF_GET_VARA_DOUBLE(ncidpl,varidap,1,nlevnc,apnc) … … 1393 1563 status=NF_GET_VARA_REAL(ncidpl,varidbp,1,nlevnc,bpnc) 1394 1564 #endif 1395 else 1565 elseif (guide_plevs.EQ.0) THEN 1396 1566 #ifdef NC_DOUBLE 1397 1567 status=NF_GET_VARA_DOUBLE(ncidpl,varidpl,1,nlevnc,apnc) … … 1420 1590 count(4)=1 1421 1591 1592 ! Pression 1593 if (guide_plevs.EQ.2) then 1594 #ifdef NC_DOUBLE 1595 status=NF_GET_VARA_DOUBLE(ncidp,varidp,start,count,zu) 1596 #else 1597 status=NF_GET_VARA_REAL(ncidp,varidp,start,count,zu) 1598 #endif 1599 DO i=1,iip1 1600 pnat2(i,:,:)=zu(:,:) 1601 ENDDO 1602 1603 IF (invert_y) THEN 1604 ! PRINT*,"Invertion impossible actuellement" 1605 ! CALL abort_gcm(modname,abort_message,1) 1606 CALL invert_lat(iip1,jjp1,nlevnc,pnat2) 1607 ENDIF 1608 endif 1422 1609 ! Vent zonal 1423 1610 if (guide_u) then … … 1490 1677 1491 1678 ! Pression de surface 1492 if ((guide_P).OR.(guide_ modele)) then1679 if ((guide_P).OR.(guide_plevs.EQ.1)) then 1493 1680 start(3)=timestep 1494 1681 start(4)=0 … … 1543 1730 INTEGER :: ierr, varid,l 1544 1731 REAL, DIMENSION (iip1,hsize,vsize) :: field2 1545 1546 print *,'Guide: output timestep',timestep,'var ',varname 1732 CHARACTER(LEN=20),PARAMETER :: modname="guide_out" 1733 1734 write(*,*)trim(modname)//': output timestep',timestep,'var ',varname 1547 1735 IF (timestep.EQ.0) THEN 1548 1736 ! ---------------------------------------------- … … 1566 1754 ierr=NF_DEF_VAR(nid,"LEVEL",NF_FLOAT,1,id_lev,vid_lev) 1567 1755 ierr=NF_DEF_VAR(nid,"cu",NF_FLOAT,2,(/id_lonu,id_latu/),vid_cu) 1756 ierr=NF_DEF_VAR(nid,"cv",NF_FLOAT,2,(/id_lonv,id_latv/),vid_cv) 1568 1757 ierr=NF_DEF_VAR(nid,"au",NF_FLOAT,2,(/id_lonu,id_latu/),vid_au) 1569 ierr=NF_DEF_VAR(nid,"cv",NF_FLOAT,2,(/id_lonv,id_latv/),vid_cv)1570 1758 ierr=NF_DEF_VAR(nid,"av",NF_FLOAT,2,(/id_lonv,id_latv/),vid_av) 1571 1759 call nf95_def_var(nid, "alpha_T", nf90_float, (/id_lonv, id_latu/), & … … 1604 1792 ! -------------------------------------------------------------------- 1605 1793 ierr = NF_REDEF(nid) 1606 ! Surface pressure (GCM)1607 dim 3=(/id_lonv,id_latu,id_tim/)1608 ierr = NF_DEF_VAR(nid,"SP",NF_FLOAT, 3,dim3,varid)1794 ! Pressure (GCM) 1795 dim4=(/id_lonv,id_latu,id_lev,id_tim/) 1796 ierr = NF_DEF_VAR(nid,"SP",NF_FLOAT,4,dim4,varid) 1609 1797 ! Surface pressure (guidage) 1610 1798 IF (guide_P) THEN … … 1651 1839 SELECT CASE (varname) 1652 1840 CASE ("SP","ps") 1653 start=(/1,1, timestep,0/)1654 count=(/iip1,jjp1, 1,0/)1841 start=(/1,1,1,timestep/) 1842 count=(/iip1,jjp1,llm,1/) 1655 1843 CASE ("v","va","vcov") 1656 1844 start=(/1,1,1,timestep/)
Note: See TracChangeset
for help on using the changeset viewer.