Ignore:
Timestamp:
Oct 20, 2011, 12:39:09 PM (13 years ago)
Author:
emillour
Message:

Mars 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/libf/phymars/writediagfi.F

    r228 r320  
    2222
    2323! 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
    2426!
    2527!  parametres (input) :
     
    5355
    5456! Arguments on input:
    55       integer ngrid
    56       character (len=*) :: nom,titre,unite
    57       integer dim
    58       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)
    5961
    6062! Local variables:
     
    6567      real*4 dx0
    6668
    67       real*4 date
     69      real*4,save :: date
    6870
    6971      REAL phis(ip1jmp1)
    7072
    7173      integer irythme
    72       integer ierr
     74      integer ierr,ierr2
    7375      integer iq
    7476      integer i,j,l,zmax , ig0
    7577
    76       integer zitau
    77       character firstnom*20
    78       SAVE firstnom
    79       SAVE zitau
    80       SAVE date
    81       data firstnom /'1234567890'/
    82       data zitau /0/
     78      integer,save :: zitau=0
     79      character(len=20),save :: firstnom='1234567890'
    8380
    8481! Ajouts
     
    8683      integer :: idim,varid
    8784      integer :: nid
    88       character (len =50):: fichnom
     85      character(len=*),parameter :: fichnom="diagfi.nc"
    8986      integer, dimension(4) :: id
    9087      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.
    9197     
    9298#ifndef MESOSCALE
     
    102108!***************************************************************
    103109
     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
    104149
    105150! Initialisation of 'firstnom' and create/open the "diagfi.nc" NetCDF file
    106151! ------------------------------------------------------------------------
    107 ! (Au tout premier appel de la subroutine durant le run.)
    108 
    109       fichnom="diagfi.nc"
    110 
    111       if (firstnom.eq.'1234567890') then ! .true. for the very first call
    112       !  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'
    113156         firstnom = nom
    114157         ! just to be sure, check that firstnom is large enough to hold nom
Note: See TracChangeset for help on using the changeset viewer.