1 |
cnh |
1.2 |
C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/nml_filter.F,v 1.1 2001/02/01 19:32:52 heimbach Exp $ |
2 |
|
|
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
|
|
#include "CPP_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
#define FTN_NML_F90 |
7 |
|
|
|
8 |
|
|
subroutine nml_filter( |
9 |
|
|
I fname |
10 |
|
|
O , outunit |
11 |
|
|
I , myThid |
12 |
|
|
& ) |
13 |
|
|
|
14 |
|
|
c ================================================================== |
15 |
|
|
c SUBROUTINE nml_filter |
16 |
|
|
c ================================================================== |
17 |
|
|
c |
18 |
|
|
c o |
19 |
|
|
c |
20 |
|
|
c started: Ralf.Giering@FastOpt.de 15-Mai-2000 |
21 |
|
|
c |
22 |
|
|
c - remove comments from namelist file |
23 |
|
|
c - usage |
24 |
|
|
c |
25 |
|
|
c call nml_filter( 'datafile', iunit, myThid ) |
26 |
|
|
c read ( unit = iunit, nml = the_namelist ) |
27 |
|
|
c close ( iunit ) |
28 |
|
|
c |
29 |
|
|
c ================================================================== |
30 |
|
|
c SUBROUTINE nml_filter |
31 |
|
|
c ================================================================== |
32 |
|
|
|
33 |
|
|
implicit none |
34 |
|
|
|
35 |
|
|
c == global variables == |
36 |
|
|
|
37 |
|
|
#include "EEPARAMS.h" |
38 |
|
|
|
39 |
|
|
c == routine arguments == |
40 |
|
|
character*(*) fname |
41 |
|
|
integer outunit |
42 |
|
|
integer myThid |
43 |
|
|
|
44 |
|
|
c == local variables == |
45 |
|
|
integer errio |
46 |
|
|
integer il |
47 |
|
|
integer inunit |
48 |
|
|
|
49 |
|
|
character*(MAX_LEN_MBUF) msgBuf |
50 |
|
|
character*(MAX_LEN_PREC) record |
51 |
|
|
|
52 |
|
|
c == external == |
53 |
|
|
|
54 |
|
|
integer ilnblnk |
55 |
|
|
external ilnblnk |
56 |
|
|
|
57 |
|
|
c == end of interface == |
58 |
|
|
|
59 |
|
|
c-- open the data file |
60 |
|
|
|
61 |
|
|
call mdsfindunit( inunit, mythid ) |
62 |
|
|
|
63 |
|
|
open( unit = inunit |
64 |
|
|
& , file = fname |
65 |
|
|
& , status = 'old' |
66 |
|
|
& , iostat = errio |
67 |
|
|
& ) |
68 |
|
|
|
69 |
|
|
c-- open the filtered data file |
70 |
|
|
call mdsfindunit( outunit, mythid ) |
71 |
|
|
open( unit=outunit, status='scratch' ) |
72 |
|
|
|
73 |
|
|
if ( errio .lt. 0 ) then |
74 |
|
|
write(msgBuf,'(A)') 'S/R nml_filter' |
75 |
|
|
call PRINT_ERROR( msgBuf , 1) |
76 |
|
|
write(msgBuf,'(A)') 'Unable to open execution environment' |
77 |
|
|
call PRINT_ERROR( msgBuf , 1) |
78 |
|
|
write(msgBuf,'(3a)') 'namelist file "', fname, '"' |
79 |
|
|
call PRINT_ERROR( msgBuf , 1) |
80 |
|
|
close(outunit) |
81 |
|
|
outunit = 0 |
82 |
|
|
stop ' stopped in nml_filter' |
83 |
|
|
endif |
84 |
|
|
|
85 |
|
|
do while ( .true. ) |
86 |
|
|
read(inunit, fmt='(a)', iostat=errio) record |
87 |
|
|
if ( errio .ne. 0 ) then |
88 |
|
|
goto 1001 |
89 |
|
|
end if |
90 |
|
|
il = max(ilnblnk(record),1) |
91 |
|
|
if ( record(1:1) .eq. commentcharacter ) then |
92 |
|
|
else if ( record(1:1) .eq. '/' ) then |
93 |
|
|
#ifdef FTN_NML_F90 |
94 |
|
|
write(outunit, fmt='(a)') record(:il) |
95 |
|
|
#else |
96 |
|
|
write(outunit, fmt='(a)') ' &' |
97 |
|
|
#endif |
98 |
|
|
else if ( record(1:2) .eq. ' /' ) then |
99 |
|
|
#ifdef FTN_NML_F90 |
100 |
|
|
write(outunit, fmt='(a)') record(:il) |
101 |
|
|
#else |
102 |
|
|
write(outunit, fmt='(a)') ' &' |
103 |
|
|
#endif |
104 |
|
|
else |
105 |
|
|
write(outunit, fmt='(a)') record(:il) |
106 |
|
|
end if |
107 |
|
|
enddo |
108 |
|
|
1001 continue |
109 |
|
|
close( inunit ) |
110 |
|
|
|
111 |
|
|
rewind( outunit ) |
112 |
|
|
|
113 |
|
|
end |
114 |
|
|
|