[15] | 1 | !Interpolation NL/lineaire rayon 200/400 km + orbital forcing + CO2 decrease interpo lin ou |
---|
| 2 | !log |
---|
| 3 | ! Ajout de l'interpolation verticale sous maille LMDZ -> GRISLI C. DUMAS Fev 2015 |
---|
| 4 | ! Lecture d'un fichier de topo associé au fichier climat |
---|
| 5 | |
---|
[18] | 6 | module climat_forcage_insolation_mod_oneway |
---|
[15] | 7 | |
---|
| 8 | ! forcage avec champs mensuels |
---|
| 9 | ! lecture fichier topo correspondant a chaque snapshot climatique |
---|
| 10 | ! fonctionne avec un index en co2 et des snapshots a differents tx de co2 |
---|
| 11 | ! nouvelle version avec liste des variables utilisées par le module |
---|
| 12 | ! C. Dumas 06/2015 |
---|
| 13 | |
---|
| 14 | USE module3D_phy,only:nx,ny,S,slv,Tann,Tjuly,Tmois,acc,coefbmshelf,ro,num_param,num_rep_42,dirnameinp,time |
---|
[16] | 15 | !use interface_input |
---|
| 16 | use netcdf |
---|
| 17 | use io_netcdf_grisli |
---|
[15] | 18 | !USE printtable |
---|
| 19 | |
---|
| 20 | implicit none |
---|
| 21 | |
---|
| 22 | ! 1=decalaration variables |
---|
| 23 | !------------------------- |
---|
| 24 | |
---|
| 25 | integer :: nft ! NFT est le nombre de lignes a lire dans le fichier contenant le forcage climatique |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | integer,parameter :: mois=12 |
---|
| 29 | integer,parameter :: ntr=1 ! nb de snapshots selon les paramètres orbitaux |
---|
| 30 | integer,parameter :: gtr=1 ! nb de snapshots selon l'état de la calotte |
---|
| 31 | integer,parameter :: ctr=1 ! nb de snapshots selon le CO2 |
---|
| 32 | real :: CO2_value=1120. |
---|
| 33 | |
---|
| 34 | real,dimension(nx,ny,mois,ntr) :: Tm ! temperature mensuelle de chaque tranche |
---|
| 35 | real,dimension(nx,ny,mois,ntr) :: Pm ! precipitation mensuelle |
---|
| 36 | |
---|
| 37 | real,dimension(nx,ny,ctr,gtr) :: Ssnap ! altitude surface dans le snapshot |
---|
| 38 | real,dimension(nx,ny,mois,ctr,gtr,ntr) :: Tm_fin ! tableau d'interpolation stylé |
---|
| 39 | real,dimension(nx,ny,mois,ctr,gtr,ntr) :: Pm_fin ! tableau d'interpolation stylé |
---|
| 40 | |
---|
| 41 | !interpolation sur param orbitaux |
---|
| 42 | real,dimension(nx,ny,mois,ctr,gtr) :: Tm_time_fin_1 ! temperature mensuelle au temps time (non corrige altitude) |
---|
| 43 | real,dimension(nx,ny,mois,ctr,gtr) :: Pm_time_fin_1 ! precipitation mensuelle au temps time |
---|
| 44 | |
---|
| 45 | !interpolation sur surface glace |
---|
| 46 | real,dimension(nx,ny,mois,ctr) :: Tm_time_fin_2 ! temperature mensuelle au temps time (corrige altitude) |
---|
| 47 | real,dimension(nx,ny,mois,ctr) :: Pm_time_fin_2 ! precipitation mensuelle au temps time |
---|
| 48 | |
---|
| 49 | !interpolation sur le CO2 |
---|
| 50 | real,dimension(nx,ny,mois) :: Tm_time_fin_3 ! temperature mensuelle au temps time (corrige altitude) |
---|
| 51 | real,dimension(nx,ny,mois) :: Pm_time_fin_3 ! precipitation mensuelle au temps time |
---|
| 52 | |
---|
| 53 | real,dimension(nx,ny,mois,ctr,gtr) :: Tm_surf_mod ! correction altitude |
---|
| 54 | real,dimension(nx,ny,mois,ctr,gtr) :: Pm_surf_mod ! correction altitude |
---|
| 55 | |
---|
| 56 | real,dimension(nx,ny,mois) :: Tm_surf ! surface temperature (after topo. correction) |
---|
[18] | 57 | |
---|
[15] | 58 | real,dimension(nx,ny,mois) :: Pm_surf ! surface precipitation (after topo. correction) |
---|
| 59 | |
---|
| 60 | real,dimension(nx,ny) :: ZS !< surface topography above sea level |
---|
| 61 | |
---|
| 62 | real,dimension(nx,ny,mois) :: lapserate ! lapse rate |
---|
| 63 | real :: psolid=2. ! temp limit between liquid and solid precip |
---|
| 64 | |
---|
| 65 | character(len=150) :: filin ! nom temporaire |
---|
| 66 | character(len=100) :: file_temporel ! forcage temporel |
---|
| 67 | character(len=100),dimension(ctr,gtr,ntr) :: filtr_t ! fichier snapshot temp file name |
---|
| 68 | character(len=100),dimension(ctr,gtr,ntr) :: filtr_p ! fichierprecip file |
---|
| 69 | CHARACTER(len=100),dimension(ctr,gtr) :: file_topo ! fichier altitude surface dans le snapshot : topo GCM sur grille GRISLI |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | real :: mincoefbmelt ! butoirs pour coefbmshelf |
---|
| 73 | real :: maxcoefbmelt |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | contains |
---|
| 78 | |
---|
| 79 | ! 2=lecture des inputs |
---|
| 80 | !-------------------- |
---|
| 81 | |
---|
| 82 | subroutine input_clim ! routine qui permet d'initialiser les variables climatiques |
---|
| 83 | ! variables locales |
---|
| 84 | !------------------- |
---|
| 85 | |
---|
| 86 | implicit none |
---|
[65] | 87 | |
---|
[15] | 88 | integer :: intr |
---|
| 89 | integer :: igtr |
---|
| 90 | integer :: ictr |
---|
[65] | 91 | ! character(len=100) :: file_ncdf !< fichier netcdf issue des fichiers .dat |
---|
[16] | 92 | real*8, dimension(:,:,:), pointer :: data_3D => null() ! donnees lues dans le netcdf |
---|
| 93 | real*8, dimension(:,:),pointer :: data_2D => null() ! donnees lues dans le netcdf |
---|
[15] | 94 | |
---|
| 95 | ! lecture des fichiers snapshots pour tout geoplace |
---|
| 96 | ! ------------------------------------------------- |
---|
| 97 | write(6,*) 'fichiers snapshots' |
---|
| 98 | DO ictr=1,ctr |
---|
| 99 | DO igtr=1,gtr |
---|
| 100 | DO intr=1,ntr |
---|
| 101 | |
---|
| 102 | !temperature |
---|
[108] | 103 | filin=TRIM(dirnameinp)//'forcing/'//TRIM(filtr_t(ictr,igtr,intr)) |
---|
[16] | 104 | call Read_ncdf_var('t2m',trim(filin),data_3D) ! Temperature |
---|
[108] | 105 | Tm_fin(:,:,:,ictr,igtr,intr)=data_3D(:,:,:) |
---|
[16] | 106 | ! WRITE(6,*) TRIM(filin) |
---|
| 107 | ! OPEN(20,file=TRIM(filin)) |
---|
| 108 | ! DO j=1,ny |
---|
| 109 | ! DO i=1,nx |
---|
[15] | 110 | ! do J=ny,1,-1 |
---|
| 111 | ! do I=1,nx |
---|
[16] | 112 | ! READ(20,*) ti, tj, (Tm_fin(i,j,mo,ictr,igtr,intr),mo=1,12) |
---|
| 113 | ! END DO |
---|
| 114 | ! END DO |
---|
| 115 | ! CLOSE(20) |
---|
[15] | 116 | |
---|
| 117 | !precipitation |
---|
[108] | 118 | filin=TRIM(dirnameinp)//'forcing/'//TRIM(filtr_p(ictr,igtr,intr)) |
---|
[16] | 119 | call Read_ncdf_var('precip',trim(filin),data_3D) ! precipitation |
---|
| 120 | Pm_fin(:,:,:,ictr,igtr,intr)=data_3D(:,:,:) |
---|
| 121 | ! WRITE(6,*) TRIM(filin) |
---|
| 122 | ! OPEN(20,file=TRIM(filin)) |
---|
| 123 | ! DO j=1,ny |
---|
| 124 | ! DO i=1,nx |
---|
[15] | 125 | ! do J=ny,1,-1 |
---|
| 126 | ! do I=1,nx |
---|
[16] | 127 | ! READ(20,*) ti, tj, (Pm_fin(i,j,mo,ictr,igtr,intr),mo=1,12) |
---|
| 128 | ! END DO |
---|
| 129 | ! END DO |
---|
| 130 | ! CLOSE(20) |
---|
[15] | 131 | END DO |
---|
| 132 | |
---|
| 133 | ! topo |
---|
[108] | 134 | filin=TRIM(dirnameinp)//'forcing/'//TRIM(file_topo(ictr,igtr)) |
---|
[16] | 135 | call Read_ncdf_var('TOPO',trim(filin),data_2D) ! topo |
---|
| 136 | Ssnap(:,:,ictr,igtr)=data_2D(:,:) |
---|
[18] | 137 | where(Ssnap(:,:,ictr,igtr).eq.0.0) ! Pour PLIOMIP niv marin=25m |
---|
[16] | 138 | Ssnap(:,:,ictr,igtr)=25.0 |
---|
| 139 | endwhere |
---|
| 140 | ! WRITE(6,*) TRIM(filin) |
---|
| 141 | ! OPEN(20,file=TRIM(filin)) |
---|
| 142 | ! DO j=1,ny |
---|
| 143 | ! DO i=1,nx |
---|
| 144 | ! READ(20,*) Ssnap(i,j,ictr,igtr) |
---|
| 145 | ! if (Ssnap(i,j,ictr,igtr).eq.0.0) Ssnap(i,j,ictr,igtr)=25.0 |
---|
| 146 | ! END DO |
---|
| 147 | ! END DO |
---|
| 148 | ! CLOSE(20) |
---|
[15] | 149 | ENDDO |
---|
| 150 | ENDDO |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | end subroutine input_clim |
---|
| 154 | !-------------------------------------------------------------------------------- |
---|
| 155 | !subroutine input_climat_ref |
---|
| 156 | ! quand on traite en absolu, pas besoin du climat de reference |
---|
| 157 | |
---|
| 158 | !end subroutine input_climat_ref |
---|
| 159 | |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | SUBROUTINE init_forclim |
---|
| 163 | |
---|
| 164 | ! fichiers snapshots |
---|
| 165 | NAMELIST/snap_forcage_mois_insol/filtr_t,filtr_p,file_topo ! ce bloc est a dupliquer pour chaque snapshot en changeant ! la numerotation. ntr snapshots |
---|
| 166 | !namelist/snap_forcage_mois/filtr_t,filtr_p,Seuil_haut,Seuil_bas,summorb,palier_ice,surf_ice,palier_CO2 ! ce bloc est a dupliquer pour chaque snapshot en changeant ! la numerotation. ntr snapshots |
---|
| 167 | ! forcage temporel |
---|
| 168 | !------------------ |
---|
| 169 | namelist/forc_temporel/file_temporel,mincoefbmelt,maxcoefbmelt |
---|
| 170 | |
---|
| 171 | ! lecture par namelist |
---|
| 172 | !--------------------- |
---|
| 173 | ! formats pour les ecritures dans 42 |
---|
| 174 | 428 format(A) |
---|
| 175 | rewind(num_param) ! pour revenir au debut du fichier param_list.dat |
---|
| 176 | read(num_param,snap_forcage_mois_insol) |
---|
| 177 | write(num_rep_42,428)'!___________________________________________________________' |
---|
| 178 | write(num_rep_42,428) '&snap_forcage_mois_insol ! module climat-forcage-insolation_mod' |
---|
| 179 | write(num_rep_42,'(A,A)') 'filtr_t = ', filtr_t |
---|
| 180 | write(num_rep_42,'(A,A)') 'filtr_p = ', filtr_p |
---|
| 181 | write(num_rep_42,'(A,A)') 'file_topo = ', file_topo |
---|
| 182 | ! write(num_rep_42,'(A,2(f7.1,","))') 'Seuil_haut = ', Seuil_haut(:) |
---|
| 183 | ! write(num_rep_42,'(A,2(f7.1,","))') 'Seuil_bas = ', Seuil_bas(:) |
---|
| 184 | ! write(num_rep_42,'(A,2(f5.1,","))') 'summorb = ', summorb(:) |
---|
| 185 | ! write(num_rep_42,'(A,2(f7.1,","))') 'palier_ice = ', palier_ice(:,:) |
---|
| 186 | ! write(num_rep_42,'(A,A)') 'surf_ice = ', surf_ice |
---|
| 187 | ! write(num_rep_42,'(A,2(f3.1,","))') 'palier_CO2 = ', palier_CO2(:) |
---|
| 188 | write(num_rep_42,*)'/' |
---|
| 189 | write(num_rep_42,428) '! fichiers temperature et precip : 12 mois et topo' |
---|
| 190 | write(num_rep_42,428) '! faire un bloc namelist par snapshot' |
---|
| 191 | write(num_rep_42,*) |
---|
| 192 | |
---|
| 193 | ! do i=1,ntr |
---|
| 194 | ! glaciaire |
---|
| 195 | ! write(filtr_t(i),'(A,i3,A)') filtr_t1(1:32),int(ttr(i)),filtr_t1(36:50) |
---|
| 196 | ! write(filtr_p(i),'(A,i3,A)') filtr_p1(1:34),int(ttr(i)),filtr_p1(38:52) |
---|
| 197 | ! write(filtr_t(i),'(A)') filtr_t |
---|
| 198 | ! write(filtr_p(i),'(A)') filtr_p |
---|
| 199 | ! enddo |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | call lect_lapserate_months ! lit les lasperate mensuels |
---|
| 203 | ! pour une version spatialisee ecrire une autre routine |
---|
| 204 | ! fichiers donnant l'evolution temporelle |
---|
| 205 | ! ---------------------------- ------------ |
---|
| 206 | |
---|
| 207 | rewind(num_param) ! pour revenir au debut du fichier param_list.dat |
---|
| 208 | read(num_param,forc_temporel) |
---|
| 209 | |
---|
| 210 | write(num_rep_42,428)'!___________________________________________________________' |
---|
| 211 | write(num_rep_42,428) '&forc_temporel ! module climat_forcage_mois_mod' |
---|
| 212 | write(num_rep_42,'(A,A)') 'file_temporel =', file_temporel |
---|
| 213 | write(num_rep_42,*) 'mincoefbmelt =', mincoefbmelt |
---|
| 214 | write(num_rep_42,*) 'maxcoefbmelt =', maxcoefbmelt |
---|
| 215 | write(num_rep_42,*)'/' |
---|
| 216 | write(num_rep_42,428) '!fichier forcage temporel pour snapshot' |
---|
| 217 | write(num_rep_42,*) |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | end subroutine init_forclim |
---|
| 221 | !--------------------------------------------------------------------- |
---|
| 222 | |
---|
| 223 | !forcage climatique au cours du temps |
---|
| 224 | |
---|
| 225 | subroutine forclim |
---|
| 226 | |
---|
| 227 | implicit none |
---|
| 228 | |
---|
| 229 | !integer l ! dumm index for loops on snapshots files l=ITR,NTR-1 |
---|
| 230 | !cdc integer itr ! index of the current snapshot file (change with time) |
---|
| 231 | |
---|
| 232 | integer mo |
---|
| 233 | integer :: i,j |
---|
| 234 | |
---|
| 235 | !***************** |
---|
| 236 | !***** ORBIT ***** |
---|
| 237 | !***************** |
---|
| 238 | Tm_time_fin_1(:,:,:,:,:)=Tm_fin(:,:,:,:,:,1) |
---|
| 239 | Pm_time_fin_1(:,:,:,:,:)=Pm_fin(:,:,:,:,:,1) |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | !Correction d'altitude pour les états |
---|
| 243 | !il faut que Ssnap soit un tableau avec les différentes hauteurs de glace selon la |
---|
| 244 | !simulation (no ice, med ice, full ice et 2x, 2.5x, 3x) |
---|
| 245 | do j=1,ny |
---|
| 246 | do i=1,nx |
---|
| 247 | Zs(i,j)=max(slv(i,j),S(i,j)) |
---|
| 248 | !Il faut mettre S0(i,j) si pas d'interpolation sinon Ssnap(i,j,ictr,igtr) |
---|
| 249 | !if (Zs(i,j).ge.Ssnap(i,j,ictr,igtr)) then |
---|
| 250 | do mo=1,mois |
---|
| 251 | ! correction d'altitude |
---|
| 252 | ! Tm_surf_mod(i,j,mo,1,1)=-lapserate(i,j,mo)*(Zs(i,j)-S0(i,j)) & |
---|
| 253 | ! +Tm_time_fin_1(i,j,mo,1,1) |
---|
| 254 | Tm_surf_mod(i,j,mo,1,1)=-lapserate(i,j,mo)*(Zs(i,j)-Ssnap(i,j,1,1)) & |
---|
| 255 | + Tm_time_fin_1(i,j,mo,1,1) |
---|
| 256 | |
---|
| 257 | ! if (Ssnap(i,j,1,1).le.25.11479) Tm_surf_mod(i,j,mo,1,1)=Tm_time_fin_1(i,j,mo,1,1) |
---|
| 258 | |
---|
| 259 | ! if (Ssnap(i,j,1,1).eq.0.) Tm_surf_mod(i,j,mo,1,1)=0.0 |
---|
| 260 | |
---|
| 261 | Pm_surf_mod(i,j,mo,1,1)=Pm_time_fin_1(i,j,mo,1,1)*exp(0.05*(Tm_surf_mod(i,j,mo,1,1) & |
---|
| 262 | -Tm_time_fin_1(i,j,mo,1,1))) |
---|
| 263 | |
---|
| 264 | ! if ((Ssnap(i,j,1,1).eq.0.0).and.(Zs(i,j).eq.slv(i,j))) Pm_surf_mod(i,j,mo,1,1)=0.0 |
---|
| 265 | |
---|
| 266 | end do |
---|
| 267 | !else if (Zs(i,j).lt.Ssnap(i,j,ictr,igtr)) then |
---|
| 268 | ! do mo=1,mois |
---|
| 269 | ! ! correction d'altitude avec condition pour que T ne soit |
---|
| 270 | ! ! pas supérieure à la T de l'état sans glace corrigé |
---|
| 271 | ! Tm_surf_mod(i,j,mo,ictr,igtr)=min(-lapserate(i,j,mo)*(Zs(i,j)-Ssnap(i,j,ictr,igtr))+Tm_time_fin_1(i,j,mo,ictr,igtr), & |
---|
| 272 | ! -lapserate(i,j,mo)*(Zs(i,j)-Ssnap(i,j,ictr,gtr))+Tm_time_fin_1(i,j,mo,ictr,gtr)) |
---|
| 273 | |
---|
| 274 | ! Pm_surf_mod(i,j,mo,ictr,igtr)=Pm_time_fin_1(i,j,mo,ictr,igtr)*exp(0.05*(Tm_surf_mod(i,j,mo,ictr,igtr) & |
---|
| 275 | ! -Tm_time_fin_1(i,j,mo,ictr,igtr))) |
---|
| 276 | ! end do |
---|
| 277 | !endif |
---|
| 278 | end do |
---|
| 279 | end do |
---|
| 280 | |
---|
| 281 | |
---|
| 282 | !*************** |
---|
| 283 | !***** ICE ***** |
---|
| 284 | !*************** |
---|
| 285 | Tm_time_fin_2(:,:,:,:)=Tm_surf_mod(:,:,:,:,1) |
---|
| 286 | Pm_time_fin_2(:,:,:,:)=Pm_surf_mod(:,:,:,:,1) |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | !*************** |
---|
| 290 | !***** CO2 ***** |
---|
| 291 | !*************** |
---|
| 292 | Tm_time_fin_3(:,:,:)=Tm_time_fin_2(:,:,:,1) |
---|
| 293 | Pm_time_fin_3(:,:,:)=Pm_time_fin_2(:,:,:,1) |
---|
| 294 | |
---|
| 295 | |
---|
| 296 | !*************** |
---|
| 297 | !**** MONTH **** |
---|
| 298 | !*************** |
---|
| 299 | do i=1,nx |
---|
| 300 | do j=1,ny |
---|
| 301 | do mo=1,mois |
---|
| 302 | Tm_surf(i,j,mo)=Tm_time_fin_3(i,j,mo) |
---|
| 303 | Pm_surf(i,j,mo)=Pm_time_fin_3(i,j,mo) |
---|
| 304 | end do |
---|
| 305 | end do |
---|
| 306 | end do |
---|
| 307 | |
---|
| 308 | |
---|
| 309 | !coefbmshelf coefficient pour la fusion basale sous les ice shelves |
---|
| 310 | |
---|
| 311 | coefbmshelf=1.0 |
---|
| 312 | coefbmshelf=max(coefbmshelf,mincoefbmelt) |
---|
| 313 | coefbmshelf=min(coefbmshelf,maxcoefbmelt) |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | !********************************* |
---|
| 317 | !Correction d'altitude à vérifier |
---|
| 318 | !********************************* |
---|
| 319 | |
---|
| 320 | |
---|
| 321 | ! Correction d'altitude pour la temperature y compris sur les lacs |
---|
| 322 | ! Zs est l'altitude de la surface qu'elle soit mer, glace ou lac |
---|
| 323 | |
---|
| 324 | !do j=1,ny |
---|
| 325 | ! do i=1,nx |
---|
| 326 | ! ZS(I,J)=max(slv(i,j),S(I,J)) |
---|
| 327 | ! do mo=1,mois |
---|
| 328 | ! Tm_surf(i,j,mo)= - lapserate(i,j,mo) * (Zs(i,j)-Ssnap(i,j)) & ! correction d'altitude T |
---|
| 329 | ! + Tm_time(i,j,mo) |
---|
| 330 | ! |
---|
| 331 | ! Pm_surf(i,j,mo)= Pm_time(i,j,mo)*exp(0.05*(Tm_surf(i,j,mo)-Tm_time(i,j,mo))) |
---|
| 332 | ! |
---|
| 333 | ! end do |
---|
| 334 | ! end do |
---|
| 335 | !end do |
---|
| 336 | |
---|
| 337 | |
---|
| 338 | do mo=1,mois |
---|
| 339 | Tmois(:,:,mo)=Tm_surf(:,:,mo) |
---|
| 340 | enddo |
---|
| 341 | |
---|
| 342 | ! calcul de Tann et Tjuly pour les sorties : |
---|
| 343 | Tann(:,:)=sum(Tmois,dim=3)/12. ! moy annuelle |
---|
| 344 | Tjuly(:,:)=Tmois(:,:,7) ! temp juillet |
---|
| 345 | |
---|
| 346 | acc(:,:)=sum(Pm_surf,dim=3,mask=Tmois < psolid) ! /12. |
---|
| 347 | acc(:,:)=acc(:,:)*1000./ro |
---|
| 348 | |
---|
| 349 | |
---|
| 350 | END subroutine forclim |
---|
| 351 | |
---|
| 352 | |
---|
| 353 | |
---|
| 354 | !************************************************************************ |
---|
| 355 | ! Numerical Recipes |
---|
| 356 | ! interpolation spline cubique |
---|
| 357 | |
---|
| 358 | !Récupéré grace à Christophe. Modifié 17.04.13 par JB |
---|
| 359 | SUBROUTINE splint(xa,ya,y2a,n,y) |
---|
| 360 | INTEGER,intent(in) :: n |
---|
| 361 | double precision,dimension(n),intent(in) :: xa,y2a,ya |
---|
| 362 | double precision,intent(out) :: y |
---|
| 363 | ! Calculates the cubic spline interpolation. |
---|
| 364 | ! Given 2 arrays of dimension n, xa and ya, and y2a, the second derivative |
---|
| 365 | ! of the function ya at any of the n points, it computes the interpolation for |
---|
| 366 | ! the array y of dimension nmax. |
---|
| 367 | ! for example, if n is 10001 (e.g. 1e6 years computed with Laskar algorithm and |
---|
| 368 | ! a sampling step of 100 years), then nmax would be 1e6 because GRISLI has a |
---|
| 369 | ! sampling step of 1 year. |
---|
| 370 | INTEGER l |
---|
| 371 | REAL a,b,h |
---|
| 372 | ! We will find the right place in the table by means of bisection. |
---|
| 373 | |
---|
| 374 | ! do i=1,nmax |
---|
| 375 | ! print *,x(i) |
---|
| 376 | ! write (*,*) 'Press Enter to Continue' |
---|
| 377 | ! read (*,*) |
---|
| 378 | ! enddo |
---|
| 379 | |
---|
| 380 | !l=1 |
---|
| 381 | !do j=1,nmax |
---|
| 382 | !if (j==1) then |
---|
| 383 | ! l=2 |
---|
| 384 | !else if (j==nmax) then |
---|
| 385 | ! l=n |
---|
| 386 | !else if (x(j).gt.xa(l)) then |
---|
| 387 | ! l=l+1 |
---|
| 388 | !endif |
---|
| 389 | |
---|
| 390 | |
---|
| 391 | if (time==0) then |
---|
| 392 | l=2 |
---|
| 393 | else if (time==xa(n)) then |
---|
| 394 | l=n |
---|
| 395 | else |
---|
| 396 | l=1 |
---|
| 397 | do while (time.gt.xa(l)) |
---|
| 398 | l=l+1 |
---|
| 399 | enddo |
---|
| 400 | endif |
---|
| 401 | |
---|
| 402 | |
---|
| 403 | h=xa(l)-xa(l-1) |
---|
| 404 | a=(xa(l)-time)/h |
---|
| 405 | b=(time-xa(l-1))/h |
---|
| 406 | y=a*ya(l-1)+b*ya(l)+((a**3-a)*y2a(l-1)+(b**3-b)*y2a(l))*(h**2)/6. |
---|
| 407 | |
---|
| 408 | ! print *,time,l,xa(l-1),xa(l),ya(l-1),ya(l),h,a,b,y |
---|
| 409 | ! write (*,*) 'Press Enter to Continue' |
---|
| 410 | ! read (*,*) |
---|
| 411 | |
---|
| 412 | return |
---|
| 413 | |
---|
| 414 | END SUBROUTINE splint |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | |
---|
| 418 | ! Calculates the 2nd derivative of the y function for any points |
---|
| 419 | ! Recupere grace à Christophe. Modifié par JB 18.04.13 |
---|
| 420 | SUBROUTINE spline(x,y,n,yp1,ypn,y2) |
---|
| 421 | INTEGER,intent(in) :: n |
---|
| 422 | double precision,dimension(n), intent(in) :: x,y |
---|
| 423 | double precision,dimension(n), intent(out) :: y2 |
---|
| 424 | double precision,intent(in) :: yp1,ypn |
---|
| 425 | |
---|
| 426 | INTEGER i,k |
---|
| 427 | double precision :: p,qn,sig,un |
---|
| 428 | double precision,dimension(n) :: u |
---|
| 429 | |
---|
| 430 | if (yp1.gt..99e30) then ! The lower boundary condition is set either to 0 |
---|
| 431 | y2(1)=0. |
---|
| 432 | u(1)=0. |
---|
| 433 | else ! or else to have a specified first derivative. |
---|
| 434 | y2(1)=-0.5 |
---|
| 435 | u(1)=(3./(x(2)-x(1)))*((y(2)-y(1))/(x(2)-x(1))-yp1) |
---|
| 436 | endif |
---|
| 437 | do i=2,n-1 |
---|
| 438 | ! This is the decomposition loop of the tridiagonal algorithm. y2 and u are used |
---|
| 439 | ! for temporary storage of the decomposed factors. |
---|
| 440 | |
---|
| 441 | sig=(x(i)-x(i-1))/(x(i+1)-x(i-1)) |
---|
| 442 | p=sig*y2(i-1)+2. |
---|
| 443 | y2(i)=(sig-1.)/p |
---|
| 444 | u(i)=(6.*((y(i+1)-y(i))/(x(i+1)-x(i))-(y(i)-y(i-1)) & |
---|
| 445 | /(x(i)-x(i-1)))/(x(i+1)-x(i-1))-sig*u(i-1))/p |
---|
| 446 | enddo |
---|
| 447 | |
---|
| 448 | if (ypn.gt..99e30) then ! The upper boundary condition is set eith |
---|
| 449 | qn=0. |
---|
| 450 | un=0. |
---|
| 451 | else ! or else to have a specified first derivative. |
---|
| 452 | qn=0.5 |
---|
| 453 | un=(3./(x(n)-x(n-1)))*(ypn-(y(n)-y(n-1))/(x(n)-x(n-1))) |
---|
| 454 | endif |
---|
| 455 | y2(n)=(un-qn*u(n-1))/(qn*y2(n-1)+1.) |
---|
| 456 | do k=n-1,1,-1 ! This is the backsubstitution loop of the tridiagonal algorithm |
---|
| 457 | y2(k)=y2(k)*y2(k+1)+u(k) |
---|
| 458 | enddo |
---|
| 459 | return |
---|
| 460 | |
---|
| 461 | END SUBROUTINE spline |
---|
| 462 | |
---|
| 463 | |
---|
| 464 | |
---|
| 465 | |
---|
| 466 | |
---|
| 467 | |
---|
| 468 | |
---|
| 469 | !------------------------------------------------------------------------------------------------------------ |
---|
| 470 | subroutine lect_lapserate_months ! lapserates mensuels mais uniformes spatialement |
---|
| 471 | |
---|
| 472 | implicit none |
---|
| 473 | real,dimension(12) :: lect_lapse ! pour la lecture |
---|
| 474 | integer :: i,j |
---|
| 475 | |
---|
| 476 | namelist/lapse_month/lect_lapse |
---|
| 477 | |
---|
| 478 | ! lecture de la namelist |
---|
| 479 | |
---|
| 480 | ! formats pour les ecritures dans 42 |
---|
| 481 | 428 format(A) |
---|
| 482 | |
---|
| 483 | rewind(num_param) ! pour revenir au debut du fichier param_list.dat |
---|
| 484 | read(num_param,lapse_month) |
---|
| 485 | |
---|
| 486 | write(num_rep_42,428)'!___________________________________________________________' |
---|
| 487 | write(num_rep_42,428) '&lapse_month ! module climat_forcage_mois_mod' |
---|
| 488 | write(num_rep_42,'(A,12(f0.2,","))') 'lapse_month = ', lect_lapse |
---|
| 489 | write(num_rep_42,*)'/' |
---|
| 490 | write(num_rep_42,428) '! laspe rates janvier -> decembre en deg/km' |
---|
| 491 | |
---|
| 492 | |
---|
| 493 | ! pour repasser en deg/m et copier dans lapserate |
---|
| 494 | |
---|
| 495 | do j=1,ny |
---|
| 496 | do i=1,nx |
---|
| 497 | lapserate(i,j,:)=lect_lapse(:)/1000. |
---|
| 498 | end do |
---|
| 499 | end do |
---|
| 500 | end subroutine lect_lapserate_months |
---|
| 501 | !-------------------------------------------------------------------------------------------------------- |
---|
| 502 | |
---|
[18] | 503 | end module climat_forcage_insolation_mod_oneway |
---|