*=*=*=*= inifis.html =*=*=*=*
SUBROUTINE inifis

SUBROUTINE inifis


      SUBROUTINE inifis(ngrid,nlayer,
     $           pdaysec,
     $           day_ini,ptimestep,
     $           plat,plon,parea,
     $           prad,pg,pr,pcpp)
      IMPLICIT NONE
c
c=======================================================================
c
c   subject:
c   --------
c
c   Initialisation for the physical parametrisations of the LMD
c   martian atmospheric general circulation modele.
c
c   author: Frederic Hourdin 15 / 10 /93
c   -------
c
c   arguments:
c   ----------
c
c   input:
c   ------
c
c    ngrid                 Size of the horizontal grid.
c                          All internal loops are performed on that grid.
c    nlayer                Number of vertical layers.
c    pdayref               Day of reference for the simulation
c    firstcall             True at the first call
c    lastcall              True at the last call
c    pday                  Number of days counted from the North. Spring
c                          equinoxe.
c
c=======================================================================
c
c-----------------------------------------------------------------------
c   declarations:
c   -------------

#include "dimensions.h"
#include "dimphys.h"
#include "planete.h"
#include "comcstfi.h"
#include "comsaison.h"
#include "comdiurn.h"
#include "comgeomfi.h"
#include "callkeys.h"
#include "surfdat.h"
#include "lmdstd.h"

      REAL prad,pg,pr,pcpp,pdaysec

      INTEGER ngrid,nlayer
      REAL plat(ngrid),plon(ngrid),parea(ngridmx)
      integer day_ini
      REAL ptimestep
      INTEGER ig,ierr

      EXTERNAL iniorbit,orbite
      EXTERNAL SSUM
      REAL SSUM

      CHARACTER ch1*12

      IF (nlayer.NE.nlayermx) THEN
         PRINT*,'STOP in inifis'
         PRINT*,'Probleme de dimenesions :'
         PRINT*,'nlayer     = ',nlayer
         PRINT*,'nlayermx   = ',nlayermx
         STOP
      ENDIF

      IF (ngrid.NE.ngridmx) THEN
         PRINT*,'STOP in inifis'
         PRINT*,'Probleme de dimenesions :'
         PRINT*,'ngrid     = ',ngrid
         PRINT*,'ngridmx   = ',ngridmx
         STOP
      ENDIF

      callrad=.true.
      calldifv=.true.
      calladj=.true.
      callcond=.true.
      callsoil=.true.
      season=.true.
      diurnal=.false.
      lwrite=.false.
      calllott=.true.
      laervar=.true.
      laervarlat=.true.
      esadust=.true.
      mellor=.true.
      topdustref=55.
      OPEN(99,file='callphys.def',status='old',form='formatted'
     .     ,iostat=ierr)
      IF(ierr.EQ.0) THEN
      PRINT*
      PRINT*
      PRINT*,'--------------------------------------------'
      PRINT*,' Parametres pour la physique (callphys.def)'
      PRINT*,'--------------------------------------------'

         READ(99,*),ch1
         READ(99,'(l1)') callrad
         WRITE(*,8000) ch1,callrad

         READ(99,*),ch1
         READ(99,'(l1)') calldifv
         WRITE(*,8000) ch1,calldifv

         READ(99,*),ch1
         READ(99,'(l1)') mellor
         WRITE(*,8000) ch1,mellor

         READ(99,*),ch1
         READ(99,'(l1)') calladj
         WRITE(*,8000) ch1,calladj

         READ(99,*),ch1
         READ(99,'(l1)') callcond
         WRITE(*,8000) ch1,callcond

         READ(99,*),ch1
         READ(99,'(l1)') callsoil
         WRITE(*,8000) ch1,callsoil

         READ(99,*),ch1
         READ(99,'(l1)') calllott
         WRITE(*,8000) ch1,calllott

         READ(99,*),ch1
         READ(99,'(l1)') season
         WRITE(*,8000) ch1,season

         READ(99,*),ch1
         READ(99,'(l1)') diurnal
         WRITE(*,8000) ch1,diurnal

         READ(99,*),ch1
         READ(99,'(l1)') lwrite
         WRITE(*,8000) ch1,lwrite

         READ(99,*),ch1
         READ(99,'(l1)') laervar
         WRITE(*,8000) ch1,laervar

         READ(99,*),ch1
         READ(99,'(l1)') laervarlat
         WRITE(*,8000) ch1,laervarlat

         READ(99,*),ch1
         READ(99,*) topdustref
         WRITE(*,8002) ch1,topdustref

         READ(99,*),ch1
         READ(99,'(l1)') esadust
         WRITE(*,8000) ch1,esadust

         READ(99,*),ch1
         READ(99,*) callemis
         WRITE(*,8000) ch1,callemis

         READ(99,*),ch1
         READ(99,*) iradia
         WRITE(*,8001) ch1,iradia

         READ(99,*),ch1
         READ(99,*) ilwd
         WRITE(*,8001) ch1,ilwd

         READ(99,*),ch1
         READ(99,*) ilwn
         WRITE(*,8001) ch1,ilwn

         READ(99,*),ch1
         READ(99,*) linear
         WRITE(*,8000) ch1,linear

         READ(99,*),ch1
         READ(99,*) ncouche
         WRITE(*,8001) ch1,ncouche

         READ(99,*),ch1
         READ(99,*) alphan
         WRITE(*,*) ch1,alphan

         READ(99,*),ch1
         READ(99,*) ilwb
         WRITE(*,8001) ch1,ilwb

         READ(99,*),ch1
         READ(99,'(l1)') callstats
         WRITE(*,8000) ch1,callstats

         READ(99,*),ch1
         READ(99,'(l1)') callco2v
         WRITE(*,8000) ch1,callco2v

         READ(99,*),ch1
         READ(99,'(l1)') callnlte
         WRITE(*,8000) ch1,callnlte

         READ(99,*),ch1
         READ(99,'(l1)') callg2d
         WRITE(*,8000) ch1,callg2d

         READ(99,*),ch1
         READ(99,*) semi
         WRITE(*,*) ch1,semi

      PRINT*,'--------------------------------------------'
      PRINT*
      PRINT*
      ENDIF
      CLOSE(99)

8000  FORMAT(t5,a12,l8)
8001  FORMAT(t5,a12,i8)
8002  FORMAT(t5,a12,f8)

c   choice of the frequency of the computation of radiations
c     IF(diurnal) THEN
c        iradia=NINT(pdaysec/(20.*ptimestep))
c     ELSE
c        iradia=NINT(pdaysec/(4.*ptimestep))
c     ENDIF

      PRINT*
      PRINT*,'daysec',pdaysec
      PRINT*
      PRINT*,'The radiative transfer is computed:'
      PRINT*,'           each ',iradia,' physical time-step'
      PRINT*,'        or each ',iradia*ptimestep,' seconds'
      PRINT*
c-----------------------------------------------------------------------

      CALL SCOPY(ngrid,plon,1,long,1)
      CALL SCOPY(ngrid,plat,1,lati,1)
      CALL SCOPY(ngrid,parea,1,area,1)
      totarea=SSUM(ngridmx,area,1)

      DO ig=1,ngrid
         sinlat(ig)=sin(plat(ig))
         coslat(ig)=cos(plat(ig))
         sinlon(ig)=sin(plon(ig))
         coslon(ig)=cos(plon(ig))
      ENDDO

      pi=2.*asin(1.)
      rad=prad
      g=pg
      r=pr
      cpp=pcpp
      rcp=r/cpp
      dtphys=ptimestep
      daysec=pdaysec

      RETURN
9999  STOP'Cette version demande les fichier rnatur.dat et surf.def'
      END