Changeset 323 for trunk/LMDZ.GENERIC


Ignore:
Timestamp:
Oct 21, 2011, 11:29:30 AM (13 years ago)
Author:
emillour
Message:

Generic GCM:

  • added FF's upgrade of writediagfi. Now, if at runtime there is a diagfi.def file, it should contain the list of variables (1 per line) than will be put in the diagfi.nc file. If there is no diagfi.def file, then all variables are put in the diagfi.nc file (as was the case before).

EM

Location:
trunk/LMDZ.GENERIC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/README

    r253 r323  
    528528   A bug involving the definition of the Planck function boundaries was corrected in sfluxi.F90
    529529   and gfluxi.F.
     530
     531== 21/10/2011 == EM
     532- added FF's upgrade of writediagfi. Now, if at runtime there is a diagfi.def
     533  file, it should contain the list of variables (1 per line) than will be put
     534  in the diagfi.nc file. If there is no diagfi.def file, then all variables
     535  are put in the diagfi.nc file (as was the case before).
  • trunk/LMDZ.GENERIC/libf/phystd/writediagfi.F

    r253 r323  
    66!  0d (pour un scalaire qui ne depend que du temps : ex : la longitude
    77!  solaire)
    8 !  (ou encore 1d, dans le cas de rcm1d, pour sortir une colonne)
     8!  (ou encore 1d, dans le cas de testphys1d, pour sortir une colonne)
    99!  La periode d'ecriture est donnee par
    1010!  "ecritphy " regle dans le fichier de controle de run :  run.def
     
    2121! avant l'ecriture dans diagfi (cf. physiq.F)
    2222
     23! Modifs: Aug.2010 Ehouarn: enforce outputs to be real*4
     24!         Oct 2011 Francois: enable having a 'diagfi.def' file to select
     25!                            at runtime, which variables to put in file
    2326!
    2427!  parametres (input) :
     
    5255
    5356! Arguments on input:
    54       integer ngrid
    55       character (len=*) :: nom,titre,unite
    56       integer dim
    57       real px(ngrid,llm)
     57      integer,intent(in) :: ngrid
     58      character (len=*),intent(in) :: nom,titre,unite
     59      integer,intent(in) :: dim
     60      real,intent(in) :: px(ngrid,llm)
    5861
    5962! Local variables:
    6063
    61       real dx3(iip1,jjp1,llm) ! to store a 3D data set
    62       real dx2(iip1,jjp1)     ! to store a 2D (surface) data set
    63       real dx1(llm)           ! to store a 1D (column) data set
    64       real dx0
    65 
    66       real date
     64      real*4 dx3(iip1,jjp1,llm) ! to store a 3D data set
     65      real*4 dx2(iip1,jjp1)     ! to store a 2D (surface) data set
     66      real*4 dx1(llm)           ! to store a 1D (column) data set
     67      real*4 dx0
     68
     69      real*4,save :: date
    6770
    6871      REAL phis(ip1jmp1)
    6972
    7073      integer irythme
    71       integer ierr
     74      integer ierr,ierr2
    7275      integer iq
    7376      integer i,j,l,zmax , ig0
    7477
    75       integer zitau
    76       character firstnom*20
    77       SAVE firstnom
    78       SAVE zitau
    79       SAVE date
    80       data firstnom /'1234567890'/
    81       data zitau /0/
     78      integer,save :: zitau=0
     79      character(len=20),save :: firstnom='1234567890'
    8280
    8381! Ajouts
     
    8583      integer :: idim,varid
    8684      integer :: nid
    87       character (len =50):: fichnom
     85      character(len=*),parameter :: fichnom="diagfi.nc"
    8886      integer, dimension(4) :: id
    8987      integer, dimension(4) :: edges,corner
     88
     89! Added to use diagfi.def to select output variable
     90      logical,save :: diagfi_def
     91      logical :: getout
     92      integer,save :: n_nom_def
     93      integer :: n
     94      integer,parameter :: n_nom_def_max=99
     95      character(len=20),save :: nom_def(n_nom_def_max)
     96      logical,save :: firstcall=.true.
    9097     
    91 
     98#ifndef MESOSCALE
    9299!***************************************************************
    93100!Sortie des variables au rythme voulu
     
    101108!***************************************************************
    102109
     110! At very first call, check if there is a "diagfi.def" to use and read it
     111! -----------------------------------------------------------------------
     112      IF (firstcall) THEN
     113         firstcall=.false.
     114
     115  !      Open diagfi.def definition file if there is one:
     116         open(99,file="diagfi.def",status='old',form='formatted',
     117     s   iostat=ierr2)
     118
     119         if(ierr2.eq.0) then
     120            diagfi_def=.true.
     121            write(*,*) "******************"
     122            write(*,*) "Reading diagfi.def"
     123            write(*,*) "******************"
     124            do n=1,n_nom_def_max
     125              read(99,fmt='(a)',end=88) nom_def(n)
     126              write(*,*) 'Output in diagfi: ', trim(nom_def(n))
     127            end do
     128 88         continue
     129            if (n.ge.n_nom_def_max) then
     130               write(*,*)"n_nom_def_max too small in writediagfi.F:",n
     131               stop
     132            end if
     133            n_nom_def=n-1
     134            close(99)
     135         else
     136            diagfi_def=.false.
     137         endif
     138      END IF ! of IF (firstcall)
     139
     140! Get out of write_diagfi if there is diagfi.def AND variable not listed
     141!  ---------------------------------------------------------------------
     142      if (diagfi_def) then
     143          getout=.true.
     144          do n=1,n_nom_def
     145             if(trim(nom_def(n)).eq.nom) getout=.false.
     146          end do
     147          if (getout) return
     148      end if
    103149
    104150! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file
    105151! ------------------------------------------------------------------------
    106 ! (Au tout premier appel de la subroutine durant le run.)
    107 
    108       fichnom="diagfi.nc"
    109 
    110       if (firstnom.eq.'1234567890') then ! .true. for the very first call
    111       !  to this subroutine; now set 'firstnom'
     152! (at very first call to the subroutine, in accordance with diagfi.def)
     153
     154      if (firstnom.eq.'1234567890') then ! .true. for the very first valid
     155      !   call to this subroutine; now set 'firstnom'
    112156         firstnom = nom
    113157         ! just to be sure, check that firstnom is large enough to hold nom
     
    124168         ierr = nf_def_dim(nid,"Time",NF_UNLIMITED,idim)
    125169         ! Define the 'Time' variable
    126 #ifdef NC_DOUBLE
    127          ierr = NF_DEF_VAR (nid, "Time", NF_DOUBLE, 1, idim,varid)
    128 #else
     170!#ifdef NC_DOUBLE
     171!         ierr = NF_DEF_VAR (nid, "Time", NF_DOUBLE, 1, idim,varid)
     172!#else
    129173         ierr = NF_DEF_VAR (nid, "Time", NF_FLOAT, 1, idim,varid)
    130 #endif
     174!#endif
    131175         ! Add a long_name attribute
    132176         ierr = NF_PUT_ATT_TEXT (nid, varid, "long_name",
     
    149193
    150194      if (ngridmx.eq.1) then
    151         ! in rcm1d, for the 1d version of the GCM, iphysiq and irythme
     195        ! in testphys1d, for the 1d version of the GCM, iphysiq and irythme
    152196        ! are undefined; so set them to 1
    153197        iphysiq=1
     
    182226           ierr= NF_INQ_VARID(nid,"Time",varid)
    183227           ! Write (append) the new date to the 'Time' array
    184 #ifdef NC_DOUBLE
    185            ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
    186 #else
     228!#ifdef NC_DOUBLE
     229!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date)
     230!#else
    187231           ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date)
    188 #endif
     232!#endif
    189233           if (ierr.ne.NF_NOERR) then
    190234              write(*,*) "***** PUT_VAR matter in writediagfi_nc"
     
    247291           edges(3)=llm
    248292           edges(4)=1
    249 #ifdef NC_DOUBLE
    250            ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3)
    251 #else
     293!#ifdef NC_DOUBLE
     294!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx3)
     295!#else
    252296           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx3)
    253 #endif
     297!#endif
    254298
    255299           if (ierr.ne.NF_NOERR) then
     
    306350
    307351
    308 #ifdef NC_DOUBLE
    309            ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx2)
    310 #else         
     352!#ifdef NC_DOUBLE
     353!           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx2)
     354!#else         
    311355           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx2)
    312 #endif     
     356!#endif     
    313357
    314358           if (ierr.ne.NF_NOERR) then
     
    349393           edges(1)=llm
    350394           edges(2)=1
    351 #ifdef NC_DOUBLE
    352            ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx1)
    353 #else
     395!#ifdef NC_DOUBLE
     396!           ierr= NF_PUT_VARA_DOUBLE(nid,varid,corner,edges,dx1)
     397!#else
    354398           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx1)
    355 #endif
     399!#endif
    356400
    357401           if (ierr.ne.NF_NOERR) then
     
    385429           edges(1)=1
    386430
    387 #ifdef NC_DOUBLE
    388            ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx0) 
    389 #else
     431!#ifdef NC_DOUBLE
     432!           ierr = NF_PUT_VARA_DOUBLE (nid,varid,corner,edges,dx0) 
     433!#else
    390434           ierr= NF_PUT_VARA_REAL(nid,varid,corner,edges,dx0)
    391 #endif
     435!#endif
    392436           if (ierr.ne.NF_NOERR) then
    393437              write(*,*) "***** PUT_VAR matter in writediagfi"
     
    403447      ierr= NF_CLOSE(nid)
    404448
     449#endif
    405450      end
Note: See TracChangeset for help on using the changeset viewer.