source: LMDZ5/trunk/libf/phylmd/readchlorophyll.F90 @ 2354

Last change on this file since 2354 was 2346, checked in by Ehouarn Millour, 9 years ago

Physics/dynamics separation:

  • remove all references to dimensions.h from physics. nbp_lon (==iim) , nbp_lat (==jjm+1) and nbp_lev (==llm) from mod_grid_phy_lmdz should be used instead.
  • added module regular_lonlat_mod in phy_common to store information about the global (lon-lat) grid cell boundaries and centers.

EM

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