[3809] | 1 | ! |
---|
| 2 | ! $Id$ |
---|
| 3 | ! |
---|
| 4 | |
---|
| 5 | subroutine readchlorophyll(debut) |
---|
| 6 | |
---|
| 7 | use netcdf95, only: nf95_close, nf95_gw_var, nf95_inq_dimid, & |
---|
| 8 | nf95_inq_varid, nf95_open |
---|
| 9 | use netcdf, only: nf90_get_var, nf90_noerr, nf90_nowrite |
---|
| 10 | |
---|
| 11 | USE phys_cal_mod, ONLY : mth_cur |
---|
| 12 | USE mod_grid_phy_lmdz |
---|
| 13 | USE mod_phys_lmdz_mpi_data, ONLY : is_mpi_root |
---|
| 14 | USE mod_phys_lmdz_para |
---|
| 15 | USE phys_state_var_mod |
---|
| 16 | USE phys_local_var_mod |
---|
| 17 | USE dimphy |
---|
| 18 | |
---|
| 19 | implicit none |
---|
| 20 | |
---|
| 21 | include "YOMCST.h" |
---|
| 22 | |
---|
| 23 | ! Variable input |
---|
| 24 | logical debut |
---|
| 25 | |
---|
| 26 | ! Variables locales |
---|
| 27 | integer n_lat ! number of latitudes in the input data |
---|
| 28 | integer n_lon ! number of longitudes in the input data |
---|
| 29 | integer n_lev ! number of levels in the input data |
---|
| 30 | integer n_month ! number of months in the input data |
---|
| 31 | real, pointer:: latitude(:) |
---|
| 32 | real, pointer:: longitude(:) |
---|
| 33 | real, pointer:: time(:) |
---|
| 34 | integer i, k |
---|
| 35 | integer, save :: mth_pre |
---|
| 36 | !$OMP THREADPRIVATE(mth_pre) |
---|
| 37 | |
---|
| 38 | ! Champs reconstitues |
---|
| 39 | real, allocatable:: chlorocon(:, :, :) |
---|
| 40 | real, allocatable:: chlorocon_mois(:, :) |
---|
| 41 | real, allocatable:: chlorocon_mois_glo(:) |
---|
| 42 | |
---|
| 43 | ! For NetCDF: |
---|
| 44 | integer ncid_in ! IDs for input files |
---|
| 45 | integer varid, ncerr |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | !-------------------------------------------------------- |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | !--only read file if beginning of run or start of new month |
---|
| 52 | IF (debut.OR.mth_cur.NE.mth_pre) THEN |
---|
| 53 | |
---|
| 54 | IF (is_mpi_root) THEN |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | CALL nf95_open("chlorophyll.nc", nf90_nowrite, ncid_in) |
---|
| 58 | |
---|
| 59 | CALL nf95_inq_varid(ncid_in, "lon", varid) |
---|
| 60 | CALL nf95_gw_var(ncid_in, varid, longitude) |
---|
| 61 | n_lon = size(longitude) |
---|
| 62 | ! print *, 'LON chlorophyll=', n_lon, longitude |
---|
[3819] | 63 | IF (n_lon.NE.nbp_lon) THEN |
---|
| 64 | print *,'Le nombre de lon n est pas egal a nbp_lon' |
---|
[3809] | 65 | STOP |
---|
| 66 | ENDIF |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | CALL nf95_inq_varid(ncid_in, "lat", varid) |
---|
| 70 | CALL nf95_gw_var(ncid_in, varid, latitude) |
---|
| 71 | n_lat = size(latitude) |
---|
| 72 | ! print *, 'LAT chlorophyll=', n_lat, latitude |
---|
[3819] | 73 | IF (n_lat.NE.nbp_lat) THEN |
---|
| 74 | print *,'Le nombre de lat n est pas egal a nbp_lat' |
---|
[3809] | 75 | STOP |
---|
| 76 | ENDIF |
---|
| 77 | |
---|
| 78 | CALL nf95_inq_varid(ncid_in, "time", varid) |
---|
| 79 | CALL nf95_gw_var(ncid_in, varid, time) |
---|
| 80 | n_month = size(time) |
---|
| 81 | ! print *, 'TIME aerosol strato=', n_month, time |
---|
| 82 | IF (n_month.NE.12) THEN |
---|
| 83 | print *,'Le nombre de month n est pas egal a 12' |
---|
| 84 | STOP |
---|
| 85 | ENDIF |
---|
| 86 | |
---|
| 87 | IF (.not.ALLOCATED(chlorocon)) ALLOCATE(chlorocon(n_lon, n_lat, n_month)) |
---|
| 88 | IF (.not.ALLOCATED(chlorocon_mois)) ALLOCATE(chlorocon_mois(n_lon, n_lat)) |
---|
| 89 | IF (.not.ALLOCATED(chlorocon_mois_glo)) ALLOCATE(chlorocon_mois_glo(klon_glo)) |
---|
| 90 | |
---|
| 91 | !--reading stratospheric AOD at 550 nm |
---|
| 92 | CALL nf95_inq_varid(ncid_in, "CHL", varid) |
---|
| 93 | ncerr = nf90_get_var(ncid_in, varid, chlorocon) |
---|
| 94 | print *,'code erreur readaerosolstrato=', ncerr, varid |
---|
| 95 | |
---|
| 96 | CALL nf95_close(ncid_in) |
---|
| 97 | |
---|
| 98 | !---select the correct month |
---|
| 99 | IF (mth_cur.LT.1.OR.mth_cur.GT.12) THEN |
---|
| 100 | print *,'probleme avec le mois dans readaerosolstrat =', mth_cur |
---|
| 101 | ENDIF |
---|
| 102 | chlorocon_mois(:,:) = chlorocon(:,:,mth_cur) |
---|
| 103 | |
---|
| 104 | !---reduce to a klon_glo grid |
---|
| 105 | CALL grid2dTo1d_glo(chlorocon_mois,chlorocon_mois_glo) |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | print*,"chrolophyll current month",mth_cur |
---|
| 109 | do i=1,klon_glo |
---|
| 110 | if(isnan(chlorocon_mois_glo(i)))then |
---|
| 111 | chlorocon_mois_glo(i)=0. |
---|
| 112 | endif |
---|
| 113 | !print*,"high chl con",i,chlorocon_mois_glo(i) |
---|
| 114 | enddo |
---|
| 115 | |
---|
| 116 | ! DEALLOCATE(chlorocon) |
---|
| 117 | ! DEALLOCATE(chlorocon_mois) |
---|
| 118 | ! DEALLOCATE(chlorocon_mois_glo) |
---|
| 119 | |
---|
| 120 | ENDIF !--is_mpi_root |
---|
| 121 | |
---|
| 122 | !--scatter on all proc |
---|
| 123 | CALL scatter(chlorocon_mois_glo,chl_con) |
---|
| 124 | |
---|
| 125 | !--keep memory of previous month |
---|
| 126 | mth_pre=mth_cur |
---|
| 127 | |
---|
| 128 | ENDIF !--debut ou nouveau mois |
---|
| 129 | |
---|
| 130 | end subroutine readchlorophyll |
---|