1 |
C $Header: /u/gcmpack/MITgcm/eesupp/src/nml_filter.F,v 1.3 2001/09/21 03:54:35 cnh Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "CPP_OPTIONS.h" |
5 |
|
6 |
#define FTN_NML_F90 |
7 |
|
8 |
CBOP |
9 |
|
10 |
C !ROUTINE: NML_FILTER |
11 |
|
12 |
C !INTERFACE: |
13 |
SUBROUTINE NML_FILTER( |
14 |
I fName |
15 |
O , outUnit |
16 |
I , myThid |
17 |
& ) |
18 |
IMPLICIT NONE |
19 |
|
20 |
C !DESCRIPTION: |
21 |
C *=================================================================* |
22 |
C | SUBROUTINE NML_FILTER |
23 |
C | o Remove comments from namelist. |
24 |
C *=================================================================* |
25 |
C | |
26 |
C | Started: Ralf.Giering@FastOpt.de 15-Mai-2000 |
27 |
C | |
28 |
C | - remove comments from namelist file |
29 |
c | - usage |
30 |
C | |
31 |
C | CALL NML_FILTER( 'datafile', iUnit, myThid ) |
32 |
C | READ ( UNIT = iunit, NML = the_namelist ) |
33 |
C | CLOSE ( iUnit ) |
34 |
C | |
35 |
C *=================================================================* |
36 |
|
37 |
C !USES: |
38 |
C == Global variables == |
39 |
#include "EEPARAMS.h" |
40 |
INTEGER ILNBLNK |
41 |
EXTERNAL ILNBLNK |
42 |
|
43 |
C !INPUT/OUTPUT PARAMETERS: |
44 |
C == Routine arguments == |
45 |
CHARACTER*(*) fName |
46 |
INTEGER outUnit |
47 |
INTEGER myThid |
48 |
|
49 |
C !LOCAL VARIABLES: |
50 |
C == Local variables == |
51 |
INTEGER errIo |
52 |
INTEGER il |
53 |
INTEGER inUnit |
54 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
55 |
CHARACTER*(MAX_LEN_PREC) record |
56 |
CEOP |
57 |
|
58 |
C-- Open the data file |
59 |
|
60 |
CALL mdsFindUnit( inunit, mythid ) |
61 |
|
62 |
open( unit = inunit |
63 |
& , file = fname |
64 |
& , status = 'old' |
65 |
& , iostat = errio |
66 |
& ) |
67 |
|
68 |
c-- open the filtered data file |
69 |
call mdsfindunit( outunit, mythid ) |
70 |
open( unit=outunit, status='scratch' ) |
71 |
|
72 |
if ( errio .lt. 0 ) then |
73 |
write(msgBuf,'(A)') 'S/R nml_filter' |
74 |
call PRINT_ERROR( msgBuf , 1) |
75 |
write(msgBuf,'(A)') 'Unable to open execution environment' |
76 |
call PRINT_ERROR( msgBuf , 1) |
77 |
write(msgBuf,'(3a)') 'namelist file "', fname, '"' |
78 |
call PRINT_ERROR( msgBuf , 1) |
79 |
close(outunit) |
80 |
outunit = 0 |
81 |
stop ' stopped in nml_filter' |
82 |
else |
83 |
write(msgBuf,'(3a)') 'Processing namelist file ', fname, ' ...' |
84 |
call PRINT_MESSAGE(msgBuf,standardMessageUnit, |
85 |
& SQUEEZE_RIGHT,myThid) |
86 |
endif |
87 |
|
88 |
do while ( .true. ) |
89 |
read(inunit, fmt='(a)', iostat=errio) record |
90 |
if ( errio .ne. 0 ) then |
91 |
goto 1001 |
92 |
end if |
93 |
il = max(ilnblnk(record),1) |
94 |
if ( record(1:1) .eq. commentcharacter ) then |
95 |
else if ( record(1:1) .eq. '/' ) then |
96 |
#ifdef FTN_NML_F90 |
97 |
write(outunit, fmt='(a)') record(:il) |
98 |
#else |
99 |
write(outunit, fmt='(a)') ' &' |
100 |
#endif |
101 |
else if ( record(1:2) .eq. ' /' ) then |
102 |
#ifdef FTN_NML_F90 |
103 |
write(outunit, fmt='(a)') record(:il) |
104 |
#else |
105 |
write(outunit, fmt='(a)') ' &' |
106 |
#endif |
107 |
else |
108 |
write(outunit, fmt='(a)') record(:il) |
109 |
end if |
110 |
enddo |
111 |
1001 continue |
112 |
close( inunit ) |
113 |
|
114 |
rewind( outunit ) |
115 |
|
116 |
end |
117 |
|