4 |
|
|
5 |
contains |
contains |
6 |
|
|
7 |
SUBROUTINE read_sst(dtime, jour, knindex, debut, lmt_sst) |
SUBROUTINE read_sst(julien, knindex, lmt_sst) |
8 |
|
|
9 |
! From interfoce_lim |
! From interfoce_lim |
10 |
|
|
11 |
|
use conf_gcm_m, only: lmt_pas |
12 |
USE dimphy, ONLY: klon |
USE dimphy, ONLY: klon |
13 |
USE netcdf, ONLY: nf90_nowrite |
USE netcdf, ONLY: nf90_nowrite |
14 |
use netcdf95, only: NF95_CLOSE, nf95_get_var, NF95_INQ_VARID, nf95_open |
use netcdf95, only: NF95_CLOSE, nf95_get_var, NF95_INQ_VARID, nf95_open |
15 |
use nr_util, only: assert |
use nr_util, only: assert |
16 |
use time_phylmdz, only: itap |
use time_phylmdz, only: itap |
17 |
|
|
18 |
real, intent(IN):: dtime ! pas de temps de la physique (en s) |
integer, intent(IN):: julien ! jour a lire dans l'annee |
|
integer, intent(IN):: jour ! jour a lire dans l'annee |
|
19 |
|
|
20 |
integer, intent(in):: knindex(:) ! (knon) |
integer, intent(in):: knindex(:) ! (knon) |
21 |
! index des points de la surface a traiter |
! index des points de la surface a traiter |
22 |
|
|
|
logical, intent(IN):: debut ! 1er appel a la physique (initialisation) |
|
|
|
|
23 |
real, intent(out):: lmt_sst(:) ! (knon) |
real, intent(out):: lmt_sst(:) ! (knon) |
24 |
! SST lues dans le fichier de conditions aux limites |
! SST lues dans le fichier de conditions aux limites |
25 |
|
|
26 |
! Local: |
! Local: |
27 |
|
|
|
INTEGER, save:: lmt_pas ! frequence de lecture des conditions limites |
|
|
! (en pas de physique) |
|
|
|
|
|
logical, save:: deja_lu |
|
|
! pour indiquer que le jour à lire a déjà été lu pour une surface |
|
|
! précédente |
|
|
|
|
|
integer, save:: jour_lu |
|
|
|
|
28 |
! Champ lu dans le fichier de conditions aux limites : |
! Champ lu dans le fichier de conditions aux limites : |
29 |
real, allocatable, save:: sst_lu(:) |
real, save:: sst_lu(klon) |
30 |
|
|
31 |
integer ncid, varid ! pour NetCDF |
integer ncid, varid ! pour NetCDF |
32 |
|
|
34 |
|
|
35 |
call assert(size(knindex) == size(lmt_sst), "read_sst knon") |
call assert(size(knindex) == size(lmt_sst), "read_sst knon") |
36 |
|
|
|
if (debut .and. .not. allocated(sst_lu)) then |
|
|
lmt_pas = nint(86400. / dtime) ! pour une lecture une fois par jour |
|
|
jour_lu = jour - 1 |
|
|
allocate(sst_lu(klon)) |
|
|
endif |
|
|
|
|
|
if ((jour - jour_lu) /= 0) deja_lu = .false. |
|
|
|
|
37 |
! Tester d'abord si c'est le moment de lire le fichier |
! Tester d'abord si c'est le moment de lire le fichier |
38 |
if (mod(itap - 1, lmt_pas) == 0 .and. .not. deja_lu) then |
if (mod(itap - 1, lmt_pas) == 0) then |
39 |
call NF95_OPEN ('limit.nc', NF90_NOWRITE, ncid) |
call NF95_OPEN ('limit.nc', NF90_NOWRITE, ncid) |
40 |
|
|
41 |
call NF95_INQ_VARID(ncid, 'SST', varid) |
call NF95_INQ_VARID(ncid, 'SST', varid) |
42 |
call NF95_GET_VAR(ncid, varid, sst_lu, start = (/1, jour/)) |
call NF95_GET_VAR(ncid, varid, sst_lu, start = (/1, julien/)) |
43 |
|
|
44 |
call NF95_CLOSE(ncid) |
call NF95_CLOSE(ncid) |
|
deja_lu = .true. |
|
|
jour_lu = jour |
|
45 |
endif |
endif |
46 |
|
|
|
! Recopie dans le champ de sortie |
|
47 |
lmt_sst = sst_lu(knindex) |
lmt_sst = sst_lu(knindex) |
48 |
|
|
49 |
END SUBROUTINE read_sst |
END SUBROUTINE read_sst |