[3] | 1 | SUBROUTINE writeg1d(ngrid,nx,x,nom,titre) |
---|
| 2 | IMPLICIT NONE |
---|
| 3 | c....................................................................... |
---|
| 4 | c |
---|
| 5 | c ecriture de x pour GRADS-1D |
---|
| 6 | c |
---|
| 7 | c in : |
---|
| 8 | c * ngrid ---> pour controler que l'on est bien en 1D |
---|
| 9 | c * nx ---> taille du vecteur a stocker |
---|
| 10 | c "1" pour une variable de surface |
---|
| 11 | c "nlayer" pour une variable de centre de couche |
---|
| 12 | c "nlayer+1" pour une variable d'interface |
---|
| 13 | c * x ---> variable a stocker |
---|
| 14 | c * nom ---> nom "pour grads" |
---|
| 15 | c * titre ---> titre "pour grads" |
---|
| 16 | c |
---|
| 17 | c....................................................................... |
---|
| 18 | c |
---|
| 19 | #include "comg1d.h" |
---|
| 20 | |
---|
| 21 | c |
---|
| 22 | c....................................................................... |
---|
| 23 | c declaration des arguments |
---|
| 24 | c |
---|
| 25 | INTEGER ngrid,nx,i |
---|
| 26 | REAL*4 xr4(1000) |
---|
| 27 | REAL x(nx) |
---|
| 28 | CHARACTER*(*) nom,titre |
---|
| 29 | c |
---|
| 30 | c declaration des arguments |
---|
| 31 | c....................................................................... |
---|
| 32 | c declaration des variables locales |
---|
| 33 | c |
---|
| 34 | INTEGER ilayer,ivar |
---|
| 35 | LOGICAL test |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | integer isortie ! les sorties ne se font qu'une fois tous les |
---|
| 39 | logical oksortie ! nbphypers appels de la physique |
---|
| 40 | save isortie |
---|
| 41 | c |
---|
| 42 | c declaration des variables locales |
---|
| 43 | c....................................................................... |
---|
| 44 | c controle 1D |
---|
| 45 | c |
---|
| 46 | c print*,'ngrid=',ngrid |
---|
| 47 | IF (ngrid.NE.1) return |
---|
| 48 | c |
---|
| 49 | c controle 1D |
---|
| 50 | c....................................................................... |
---|
| 51 | c copy => force en reel 4 pour l'ecriture dans grads1d.dat |
---|
| 52 | |
---|
| 53 | do i=1,nx |
---|
| 54 | xr4(i) = x(i) |
---|
| 55 | enddo |
---|
| 56 | |
---|
| 57 | c copy => force en reel 4 pour l'ecriture dans grads1d.dat |
---|
| 58 | c....................................................................... |
---|
| 59 | c ouverture du fichier au premier appel |
---|
| 60 | c |
---|
| 61 | IF (g1d_premier) THEN |
---|
| 62 | OPEN (g1d_unitfich,FILE=g1d_nomfich |
---|
| 63 | & ,FORM='unformatted',ACCESS='direct',RECL=4) |
---|
| 64 | g1d_irec=0 |
---|
| 65 | g1d_nvar=0 |
---|
| 66 | |
---|
| 67 | oksortie= .true. |
---|
| 68 | isortie = nbphypers |
---|
| 69 | ENDIF |
---|
| 70 | c |
---|
| 71 | c ouverture du fichier au premier appel |
---|
| 72 | c....................................................................... |
---|
| 73 | c rythme des sorties |
---|
| 74 | if (.not.g1d_premier) then |
---|
| 75 | oksortie=.false. |
---|
| 76 | if (nom.eq.g1d_nomvar(1)) then |
---|
| 77 | if (isortie.eq.nbphypers) then |
---|
| 78 | isortie = 1 |
---|
| 79 | else |
---|
| 80 | if (isortie.eq.(nbphypers-1)) then |
---|
| 81 | oksortie=.true. |
---|
| 82 | isortie = nbphypers |
---|
| 83 | else |
---|
| 84 | isortie = isortie+1 |
---|
| 85 | endif |
---|
| 86 | endif |
---|
| 87 | else |
---|
| 88 | if (isortie.eq.nbphypers) then |
---|
| 89 | oksortie=.true. |
---|
| 90 | endif |
---|
| 91 | endif |
---|
| 92 | endif |
---|
| 93 | c rythme des sorties |
---|
| 94 | c....................................................................... |
---|
| 95 | c pour l'ecriture du fichier ctl |
---|
| 96 | c |
---|
| 97 | test=.true. |
---|
| 98 | DO ivar=1,g1d_nvar |
---|
| 99 | IF (nom.EQ.g1d_nomvar(ivar)) test=.false. |
---|
| 100 | IF (nx .GT. 1000) then |
---|
| 101 | print*,'ERROR: nx > 1000 dans writeg1d.F' |
---|
| 102 | print*,'Changer la dimension de xr4' |
---|
| 103 | call exit(1) |
---|
| 104 | ENDIF |
---|
| 105 | ENDDO |
---|
| 106 | IF (test) THEN |
---|
| 107 | g1d_nvar=g1d_nvar+1 |
---|
| 108 | g1d_nomvar(g1d_nvar)=nom |
---|
| 109 | g1d_titrevar(g1d_nvar)=titre |
---|
| 110 | IF (nx.EQ.1) THEN |
---|
| 111 | g1d_dimvar(g1d_nvar)=0 |
---|
| 112 | ELSEIF (nx.EQ.g1d_nlayer) THEN |
---|
| 113 | g1d_dimvar(g1d_nvar)=g1d_nlayer |
---|
| 114 | ELSEIF (nx.EQ.g1d_nlayer+1) THEN |
---|
| 115 | g1d_dimvar(g1d_nvar)=g1d_nlayer+1 |
---|
| 116 | ELSE |
---|
| 117 | PRINT *,'._. probleme de dimension dans GRADS-1D ._.' |
---|
| 118 | print*,'NX = ',nx |
---|
| 119 | print*,'g1d_nlayer = ',g1d_nlayer |
---|
| 120 | ENDIF |
---|
| 121 | ENDIF |
---|
| 122 | c |
---|
| 123 | c pour l'ecriture du fichier ctl |
---|
| 124 | c....................................................................... |
---|
| 125 | c test pour rythme des sorties |
---|
| 126 | if (oksortie) then |
---|
| 127 | c print*,nom,isortie,' ok' |
---|
| 128 | c....................................................................... |
---|
| 129 | c ecriture |
---|
| 130 | c |
---|
| 131 | IF (nx.EQ.1) THEN |
---|
| 132 | g1d_irec=g1d_irec+1 |
---|
| 133 | WRITE(g1d_unitfich,REC=g1d_irec) xr4(1) |
---|
| 134 | ELSE |
---|
| 135 | DO ilayer=1,g1d_nlayer |
---|
| 136 | g1d_irec=g1d_irec+1 |
---|
| 137 | WRITE(g1d_unitfich,REC=g1d_irec) xr4(ilayer) |
---|
| 138 | ENDDO |
---|
| 139 | ENDIF |
---|
| 140 | c |
---|
| 141 | c ecriture |
---|
| 142 | c....................................................................... |
---|
| 143 | c else |
---|
| 144 | c print*,nom,isortie |
---|
| 145 | endif |
---|
| 146 | c test pour rythme des sorties |
---|
| 147 | c....................................................................... |
---|
| 148 | c |
---|
| 149 | g1d_premier=.false. |
---|
| 150 | RETURN |
---|
| 151 | END |
---|
| 152 | |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | c ********************************************************************* |
---|
| 158 | c ********************************************************************* |
---|
| 159 | |
---|
| 160 | SUBROUTINE endg1d(ngrid,nlayer,zlayer,ndt) |
---|
| 161 | IMPLICIT NONE |
---|
| 162 | c....................................................................... |
---|
| 163 | c |
---|
| 164 | c ecriture du fichier de controle pour GRADS-1D |
---|
| 165 | c |
---|
| 166 | c in : |
---|
| 167 | c * ngrid ---> pour controler que l'on est bien en 1D |
---|
| 168 | c * nlayer ---> nombre de couches |
---|
| 169 | c * zlayer ---> altitude au centre de chaque couche (km) |
---|
| 170 | c * ndt ---> nombre de pas de temps |
---|
| 171 | c |
---|
| 172 | c....................................................................... |
---|
| 173 | c |
---|
| 174 | #include "comg1d.h" |
---|
| 175 | #include "comcstfi.h" |
---|
| 176 | c |
---|
| 177 | c....................................................................... |
---|
| 178 | c declaration des arguments |
---|
| 179 | c |
---|
| 180 | INTEGER ngrid,nlayer |
---|
| 181 | REAL zlayer(nlayer) |
---|
| 182 | INTEGER ndt |
---|
| 183 | c |
---|
| 184 | c declaration des arguments |
---|
| 185 | c....................................................................... |
---|
| 186 | c declaration des variables locales |
---|
| 187 | c |
---|
| 188 | INTEGER ivar,ilayer |
---|
| 189 | c |
---|
| 190 | c declaration des variables locales |
---|
| 191 | c....................................................................... |
---|
| 192 | c contole 1D |
---|
| 193 | c |
---|
| 194 | IF (ngrid.NE.1) GOTO 10001 |
---|
| 195 | c |
---|
| 196 | c contole 1D |
---|
| 197 | c....................................................................... |
---|
| 198 | c |
---|
| 199 | IF (nlayer.ne.g1d_nlayer) |
---|
| 200 | &PRINT *,'._. probleme de dimension dans GRADS-1D (endg1d.F) ' |
---|
| 201 | c |
---|
| 202 | c....................................................................... |
---|
| 203 | c |
---|
| 204 | CLOSE (g1d_unitfich) |
---|
| 205 | c |
---|
| 206 | c....................................................................... |
---|
| 207 | c |
---|
| 208 | OPEN (g1d_unitctl,FILE=g1d_nomctl,FORM='formatted',RECL=4*100) |
---|
| 209 | WRITE (g1d_unitctl,'(a4,2x,a1,a20)') 'DSET','^',g1d_nomfich |
---|
| 210 | WRITE (g1d_unitctl,'(a5,2x,a20)') 'UNDEF ','1.E+30' |
---|
| 211 | WRITE (g1d_unitctl,'(a11)') 'FORMAT YREV' |
---|
| 212 | WRITE (g1d_unitctl,'(a5,2x,a30)') 'TITLE ','champs 1D' |
---|
| 213 | WRITE (g1d_unitctl,'(a5,i4,a20)') 'XDEF ',1,' LINEAR 0 1' |
---|
| 214 | WRITE (g1d_unitctl,'(a5,i4,a20)') 'YDEF ',1,' LINEAR 0 1' |
---|
| 215 | WRITE (g1d_unitctl,'(a5,i4,a20)') 'ZDEF ',g1d_nlayer,' LEVELS' |
---|
| 216 | WRITE (g1d_unitctl,'(5(1x,f13.5))') |
---|
| 217 | & (zlayer(ilayer),ilayer=1,g1d_nlayer) |
---|
| 218 | |
---|
| 219 | c Writing true timestep in g1d.ctl (in planet "minutes"= sol/(60*24) |
---|
| 220 | ivar =min( max(int(1440.*dtphys*nbphypers/daysec +0.5),1) , 99) |
---|
| 221 | WRITE (g1d_unitctl,'(a4,2x,i10,a19,i2,a2)') |
---|
| 222 | & 'TDEF ',ndt/nbphypers,' LINEAR 01JAN2000 ', ivar,'MN ' |
---|
| 223 | |
---|
| 224 | WRITE (g1d_unitctl,'(a5,i5)') 'VARS ',g1d_nvar |
---|
| 225 | DO ivar=1,g1d_nvar |
---|
| 226 | WRITE (g1d_unitctl,'(a9,3x,i4,i3,1x,a39)') |
---|
| 227 | & g1d_nomvar(ivar),g1d_dimvar(ivar),99,g1d_titrevar(ivar) |
---|
| 228 | ENDDO |
---|
| 229 | WRITE (g1d_unitctl,'(a7)') 'ENDVARS' |
---|
| 230 | CLOSE (g1d_unitctl) |
---|
| 231 | c |
---|
| 232 | c....................................................................... |
---|
| 233 | c |
---|
| 234 | 10001 CONTINUE |
---|
| 235 | c |
---|
| 236 | c....................................................................... |
---|
| 237 | c |
---|
| 238 | RETURN |
---|
| 239 | END |
---|