source: trunk/src/SIMULS_IRCAAM/progfiltrage_simulation.F90 @ 91

Last change on this file since 91 was 85, checked in by pinsard, 14 years ago

better representation of variable parts in filenames

File size: 6.2 KB
Line 
1      PROGRAM progfiltrage_simulation
2C+
3C 
4C .. _progfiltrage_simulation.F90:
5C
6C ===========================
7C progfiltrage_simulation.F90
8C ===========================
9C
10C SYNOPSIS
11C ========
12C
13C ``progfiltrage_simulation.x``
14C
15C DESCRIPTION
16C ===========
17C
18C filtrage sur olr JAN-DEC de 1968
19C +todo+
20C
21C From :file:`olr_nofiltre_arpege_{simulation}.dat`, ``progfiltrage_simulation.x`` compute +todo+.
22C
23C ``progfiltrage_simulation.x`` write
24C :file:`olr_filtre_{period1}-{period2}d_arpege_{simulation}.dat`.
25C
26C
27C CAUTIONS
28C ========
29C
30C On MAC ppc, this program must be compile with ``-fendian=little``
31C for g95
32C according to machineformat used in :ref:`prepare_olr_filtre_simulation.m`.
33C
34C EXAMPLES
35C ========
36C
37C Following line read :file:`olr_nofiltre_arpege_AfNQIVIV.dat`,
38C compute ++,
39C write :file:`olr_filtre_10-30d_arpege_AfNQIVIV.dat`::
40C
41C $ echo "arpege AfNQIVIV 10 30" | progfiltrage_simulation.x -
42C
43C SEE ALSO
44C ========
45C
46C :ref:`prepare_olr_filtre_simulation.m`
47C
48C :ref:`forfilter.f`
49C
50C TODO
51C ====
52C
53C underflow tracking (see ifort failure)
54C
55C REAL ou DOUBLE PRECISION dans les fichiers matlab
56C
57C improve description
58C
59C improve file pb (err in open/read/write)
60C
61C F90 modules
62C
63C portability check because of getenv : now (20090203) written for
64C working on zeus using g95 (GCC 4.0.3 (g95!) Jun 18 2006)
65C
66C use PT fortran tool box ?! when public ...
67C
68C direct access file ? seems to work but see also
69C http://objectmix.com/fortran/305264-read-binaries-matlab.html
70C
71C EVOLUTIONS
72C ==========
73C
74C $Id$
75C
76C - fplod 2009-02-11T11:28:01Z aedon.locean-ipsl.upmc.fr (Darwin)
77C
78C   * bug fix for getenv using Nag compiler
79C
80C - fplod 2009-02-10T13:57:29Z aedon.locean-ipsl.upmc.fr (Darwin)
81C
82C   * bug fix on output file name to be compatible to convention
83C     (not fixed period number of digits)
84C
85C - fplod 2009-02-02T13:45:57Z aedon.locean-ipsl.upmc.fr (Darwin)
86C
87C   * created from progfiltrage_10_30.f  to replace it as well as
88C     progfiltrage_30_100.f
89C
90C   * Subroutines externalized in forfilter.f
91C
92C   * add parameters ircaam_dataset and simulation according to
93C     prepare_olr_filtre_simulation.m
94C
95C   * consolidation : implicit none, inquire iolength, force
96C     LITTLE ENDIAN
97C
98C-
99C
100#ifdef NAGf90Fortran
101      USE F90_UNIX_ENV
102#endif
103
104      IMPLICIT NONE
105
106      EXTERNAL FILTRE
107
108      INTEGER, PARAMETER :: nb = 3660
109      INTEGER :: period1
110      INTEGER :: period2
111C
112      INTEGER :: i
113      INTEGER :: j
114      INTEGER :: k
115      INTEGER :: l
116      INTEGER :: lon0
117      INTEGER :: lat0
118C
119      REAL :: olr(24,15,nb),vb(nb)
120      REAL :: vvb(nb),vvvb(nb),olrf(24,15,nb)
121C
122      CHARACTER (LEN=255) :: ircaam_id
123      CHARACTER (LEN=255) :: ircaam_od
124C
125      CHARACTER (LEN=255) :: fullfilename
126      CHARACTER (LEN=255) :: fullfilename_format
127      INTEGER :: record_length = 0
128C
129      CHARACTER (LEN=6) :: ircaam_dataset
130      CHARACTER (LEN=8) :: simulation
131      LOGICAL           :: vsel = .TRUE.
132
133      write (*,*) 'enter ircaam_dataset simulation period1 period2'
134      read (*,*) ircaam_dataset,simulation,period1,period2
135
136      write (*,*) 'ircaam_dataset : ', ircaam_dataset
137      write (*,*) 'simulation : ', simulation
138      write (*,*) 'period1 : ', period1
139      write (*,*) 'period2 : ', period2
140
141C validation of ircaam_dataset
142      IF (ircaam_dataset /= 'arpege') THEN
143       vsel = .FALSE.
144       WRITE(*,*)' eee : pb validation ircaam_dataset'
145      ENDIF
146
147C validation of simulation
148      IF ((simulation /= 'AfNQIVIV') .AND.
149     +    (simulation /= 'TrNQIVIV') .AND.
150     +    (simulation /= 'AsNQIVIV') .AND.
151     +    (simulation /= 'CtIV') .AND.
152     +    (simulation /= 'CtCl ')) THEN
153       vsel = .FALSE.
154       WRITE(*,*)' eee : pb validation simulation'
155      ENDIF
156
157C validation of period1 and period2
158
159      IF (period1 >= period2) THEN
160       vsel = .FALSE.
161       WRITE(*,*)' eee : pb validation period1 vs period2'
162      ENDIF
163C
164      IF (.NOT. vsel) THEN
165       GOTO 994
166      ENDIF
167
168      CALL GETENV('IRCAAM_ID',ircaam_id)
169      CALL GETENV('IRCAAM_OD',ircaam_od)
170
171      WRITE(fullfilename,'(A,A,A,A,A,A)')
172     +TRIM(ircaam_id),
173     +'olr_nofiltre_',
174     +TRIM(ircaam_dataset),
175     +'_',
176     +TRIM(simulation),
177     +'.dat'
178
179C ask for record length
180      INQUIRE (IOLENGTH=record_length)
181     +(((olr(i,j,k),i=1,24),j=1,15),k=1,nb)
182
183      open(1,file=fullfilename
184     +,status='old'
185     +,form='unformatted',access='direct',recl=record_length)
186
187      read(1,rec=1)
188     +(((olr(i,j,k),i=1,24),j=1,15),k=1,nb)
189
190      CLOSE(1)
191
192c  l'ordre maximal du filtrage est tel que 2*MOR+1 < nb
193c  veuillez changer dans la subroutine FILTRE le parameter MOR
194
195      do lon0=1,24
196       do lat0=1,15
197        do i=1,nb
198         vb(i)=olr(lon0,lat0,i)
199        enddo
200        call filtre(vb,vvb,REAL(period1),nb)
201        call filtre(vb,vvvb,REAL(period2),nb)
202        do i=1,nb
203         olrf(lon0,lat0,i)=vvb(i)-vvvb(i)
204        enddo
205       enddo
206      enddo
207C      print*,(olrf(1,1,j),j=1,nb)
208
209C adjust format of output filename according to period1 and period2 values
210      fullfilename_format = '(A,A,'
211      IF (period1 < 10 ) THEN
212       fullfilename_format = TRIM(fullfilename_format)//'I1,'
213      ENDIF
214      IF ((period1 >= 10) .AND. (period1 < 100)) THEN
215       fullfilename_format = TRIM(fullfilename_format)//'I2,'
216      ENDIF
217      IF (period1 >= 100 ) THEN
218       fullfilename_format = TRIM(fullfilename_format)//'I3,'
219      ENDIF
220      fullfilename_format = TRIM(fullfilename_format) //'A,'
221      IF (period2 < 10 ) THEN
222       fullfilename_format = TRIM(fullfilename_format)//'I1,'
223      ENDIF
224      IF ((period2 >= 10) .AND. (period2 < 100)) THEN
225       fullfilename_format = TRIM(fullfilename_format)//'I2,'
226      ENDIF
227      IF (period2 >= 100 ) THEN
228       fullfilename_format = TRIM(fullfilename_format)//'I3,'
229      ENDIF
230
231      fullfilename_format = TRIM(fullfilename_format)//'A,A,A,A,A)'
232
233      WRITE(fullfilename,fullfilename_format)
234     +TRIM(ircaam_od),
235     +'olr_filtre_',
236     +period1,
237     +'-',
238     +period2,
239     +'d_',
240     +TRIM(ircaam_dataset),
241     +'_',
242     +TRIM(simulation),
243     +'.dat'
244
245      open(2,file=fullfilename
246     +,status='replace'
247     +,form='unformatted',access='direct',recl=24*15*nb*4)
248
249      write(2,rec=1)(((olrf(lon0,lat0,l),lon0=1,24),
250     +                lat0=1,15),l=1,nb)
251      close(2)
252
253994   CONTINUE
254      STOP
255      END
Note: See TracBrowser for help on using the repository browser.