[3977] | 1 | SUBROUTINE iotd_ini(fichnom,iim,jjm,llm,prlon,prlat,pcoordv,jour0,mois0,an0,t0,timestep,calendrier) |
---|
[5270] | 2 | USE netcdf, ONLY: nf90_enddef, nf90_put_att, nf90_float, nf90_def_var, nf90_redef, & |
---|
| 3 | nf90_global, nf90_def_dim, nf90_create, nf90_clobber, nf90_unlimited, nf90_put_var |
---|
[5291] | 4 | USE iotd_mod_h |
---|
[1980] | 5 | IMPLICIT NONE |
---|
| 6 | |
---|
| 7 | !======================================================================= |
---|
| 8 | ! |
---|
| 9 | ! Auteur: F. Hourdin |
---|
| 10 | ! ------- |
---|
| 11 | ! |
---|
| 12 | ! Objet: |
---|
| 13 | ! ------ |
---|
| 14 | ! Light interface for netcdf outputs. can be used outside LMDZ |
---|
| 15 | ! |
---|
| 16 | !======================================================================= |
---|
| 17 | !----------------------------------------------------------------------- |
---|
| 18 | |
---|
| 19 | ! Arguments: |
---|
| 20 | ! ---------- |
---|
| 21 | |
---|
| 22 | integer iim,jjm,llm |
---|
[3977] | 23 | real prlon(iim),prlat(jjm),pcoordv(llm),timestep,t0 |
---|
[1980] | 24 | INTEGER id_FOCE |
---|
[3977] | 25 | INTEGER jour0,mois0,an0 |
---|
| 26 | CHARACTER*(*) calendrier |
---|
[1980] | 27 | |
---|
| 28 | integer corner(4),edges(4),ndim |
---|
| 29 | real px(1000) |
---|
| 30 | character (len=10) :: nom |
---|
[5084] | 31 | real*4 rlon(iim),rlat(jjm),coordv(llm) |
---|
[1980] | 32 | |
---|
| 33 | ! Local: |
---|
| 34 | ! ------ |
---|
[3977] | 35 | CHARACTER*3,DIMENSION(12) :: cmois=(/'JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'/) |
---|
| 36 | CHARACTER*10 date0 |
---|
| 37 | CHARACTER*11 date0b |
---|
| 38 | |
---|
[3978] | 39 | INTEGER :: ierr |
---|
[1980] | 40 | |
---|
| 41 | integer :: nvarid |
---|
| 42 | integer, dimension(2) :: id |
---|
| 43 | |
---|
[3977] | 44 | character*(*) fichnom |
---|
[1980] | 45 | |
---|
| 46 | real pi |
---|
| 47 | |
---|
[3977] | 48 | iotd_ts=timestep |
---|
| 49 | iotd_t0=t0 |
---|
| 50 | print*,'iotd_ini, ',timestep,iotd_ts |
---|
[1980] | 51 | imax=iim |
---|
| 52 | jmax=jjm |
---|
| 53 | lmax=llm |
---|
[3977] | 54 | ! Utile pour passer en real*4 pour les ecritures |
---|
| 55 | rlon=prlon |
---|
| 56 | rlat=prlat |
---|
[1980] | 57 | coordv=pcoordv |
---|
| 58 | |
---|
[3977] | 59 | |
---|
[3978] | 60 | !----------------------------------------------------------------------- |
---|
| 61 | ! Possibilité de spécifier une liste de variables à sortir |
---|
| 62 | ! dans iotd.def |
---|
| 63 | ! Si iotd.def existe et est non vide, |
---|
| 64 | ! seules les variables faisant à la fois l'objet d'un call iotd_ecrit |
---|
| 65 | ! et étant spécifiées dans iotd.def sont sorties. |
---|
| 66 | ! Sinon, toutes les variables faisant l'objet d'un call iotd_ecrit |
---|
| 67 | ! sont sorties |
---|
| 68 | !----------------------------------------------------------------------- |
---|
| 69 | n_names_iotd_def=0 |
---|
| 70 | open(99,file='iotd.def',form='formatted',status='old',iostat=ierr) |
---|
[5084] | 71 | if ( ierr.eq.0 ) then |
---|
[3978] | 72 | ierr=0 |
---|
| 73 | do while (ierr==0) |
---|
| 74 | read(99,*,iostat=ierr) un_nom |
---|
| 75 | if (ierr==0) then |
---|
| 76 | n_names_iotd_def=n_names_iotd_def+1 |
---|
| 77 | names_iotd_def(n_names_iotd_def)=un_nom |
---|
| 78 | endif |
---|
| 79 | enddo |
---|
| 80 | endif |
---|
| 81 | print*,n_names_iotd_def,names_iotd_def(1:n_names_iotd_def) |
---|
| 82 | close(99) |
---|
[1980] | 83 | |
---|
| 84 | |
---|
| 85 | pi=2.*asin(1.) |
---|
| 86 | |
---|
| 87 | ! Define dimensions |
---|
| 88 | |
---|
[3977] | 89 | ! Create the NetCDF file |
---|
[5270] | 90 | ierr=nf90_create(fichnom, nf90_clobber, nid) |
---|
| 91 | ierr=nf90_def_dim(nid, "lon", iim, dim_coord(1)) |
---|
| 92 | ierr=nf90_def_dim(nid, "lat", jjm, dim_coord(2)) |
---|
| 93 | ierr=nf90_def_dim(nid, "lev", llm, dim_coord(3)) |
---|
| 94 | ierr=nf90_def_dim(nid,"time",nf90_unlimited,dim_coord(4)) |
---|
| 95 | ierr = nf90_put_att(nid,nf90_global,'Conventions',"CF-1.1") |
---|
| 96 | ierr=nf90_enddef(nid) |
---|
[1980] | 97 | |
---|
[3977] | 98 | ! Switch out of NetCDF Define mode |
---|
[1980] | 99 | |
---|
| 100 | |
---|
[5270] | 101 | ierr=nf90_enddef(nid) |
---|
[1980] | 102 | ! |
---|
| 103 | ! Contol parameters for this run |
---|
[3977] | 104 | ! ---- longitude ----------- |
---|
[1980] | 105 | |
---|
[5270] | 106 | ierr=nf90_redef(nid) |
---|
| 107 | ierr=nf90_def_var(nid,"lon", nf90_float, dim_coord(1),nvarid) |
---|
| 108 | ierr = nf90_put_att(nid,nvarid,'axis','X') |
---|
| 109 | ierr=nf90_put_att(nid,nvarid,'units',"degrees_east") |
---|
| 110 | ierr=nf90_enddef(nid) |
---|
| 111 | ierr=nf90_put_var(nid,nvarid,rlon) |
---|
[1980] | 112 | print*,ierr |
---|
| 113 | |
---|
[3977] | 114 | ! ---- latitude ------------ |
---|
[5270] | 115 | ierr=nf90_redef(nid) |
---|
| 116 | ierr=nf90_def_var(nid, "lat", nf90_float, dim_coord(2),nvarid) |
---|
| 117 | ierr = nf90_put_att(nid,nvarid,'axis','Y') |
---|
| 118 | ierr=nf90_put_att(nid,nvarid,'units',"degrees_north") |
---|
| 119 | ierr=nf90_enddef(nid) |
---|
| 120 | ierr=nf90_put_var(nid,nvarid,rlat) |
---|
[1980] | 121 | ! |
---|
[3977] | 122 | ! ---- vertical ------------ |
---|
[5270] | 123 | ierr=nf90_redef(nid) |
---|
| 124 | ierr=nf90_def_var(nid, "lev", nf90_float, dim_coord(3),nvarid) |
---|
| 125 | ierr=nf90_put_att(nid,nvarid,"long_name","vert level") |
---|
[3977] | 126 | if ( coordv(2)>coordv(1) ) then |
---|
[5270] | 127 | ierr=nf90_put_att(nid,nvarid,"long_name","pseudo-alt") |
---|
| 128 | ierr=nf90_put_att(nid,nvarid,'positive',"up") |
---|
[1980] | 129 | else |
---|
[5270] | 130 | ierr=nf90_put_att(nid,nvarid,"long_name","pressure") |
---|
| 131 | ierr = nf90_put_att (nid,nvarid,'positive',"down") |
---|
[1980] | 132 | endif |
---|
[5270] | 133 | ierr=nf90_enddef(nid) |
---|
| 134 | ierr=nf90_put_var(nid,nvarid,coordv) |
---|
[1980] | 135 | |
---|
| 136 | ! |
---|
[3977] | 137 | ! ---- time ---------------- |
---|
[5270] | 138 | ierr=nf90_redef(nid) |
---|
[3977] | 139 | ! Define the 'time' variable |
---|
[5270] | 140 | ierr=nf90_def_var(nid, "time", nf90_float, dim_coord(4),nvarid) |
---|
[3977] | 141 | ! ! Add attributes |
---|
[5270] | 142 | ierr = nf90_put_att(nid,nvarid,'axis','T') |
---|
| 143 | ierr = nf90_put_att(nid,nvarid,'standard_name','time') |
---|
[3977] | 144 | WRITE(date0,'(i4.4,"-",i2.2,"-",i2.2)') an0,mois0,jour0 |
---|
[5270] | 145 | ierr=nf90_put_att(nid, nvarid,'units', & |
---|
[3977] | 146 | & "seconds since "//date0//" 00:00:00") |
---|
[5270] | 147 | ierr = nf90_put_att(nid,nvarid,'calendar',calendrier) |
---|
| 148 | !ierr = nf90_put_att(nid,nvarid,'calendar','360d') |
---|
| 149 | ierr = nf90_put_att(nid,nvarid,'title','Time') |
---|
| 150 | ierr = nf90_put_att(nid,nvarid,'long_name','Time axis') |
---|
[3977] | 151 | WRITE(date0b,'(i4.4,"-",a3,"-",i2.2)') an0,cmois(mois0),jour0 |
---|
[5270] | 152 | ierr = nf90_put_att(nid,nvarid,'time_origin', & |
---|
[3977] | 153 | & date0b//' 00:00:00') |
---|
[5270] | 154 | ierr=nf90_enddef(nid) |
---|
[3977] | 155 | |
---|
| 156 | |
---|
[5390] | 157 | END SUBROUTINE iotd_ini |
---|