1 |
cnh |
1.3 |
C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/nml_filter.F,v 1.2 2001/02/04 14:38:44 cnh Exp $ |
2 |
|
|
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
|
|
#include "CPP_OPTIONS.h" |
5 |
|
|
|
6 |
|
|
#define FTN_NML_F90 |
7 |
|
|
|
8 |
cnh |
1.3 |
CBOP |
9 |
|
|
|
10 |
|
|
C !ROUTINE: NML_FILTER |
11 |
|
|
|
12 |
|
|
C !INTERFACE: |
13 |
|
|
SUBROUTINE NML_FILTER( |
14 |
|
|
I fName |
15 |
|
|
O , outUnit |
16 |
heimbach |
1.1 |
I , myThid |
17 |
|
|
& ) |
18 |
cnh |
1.3 |
IMPLICIT NONE |
19 |
heimbach |
1.1 |
|
20 |
cnh |
1.3 |
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 |
heimbach |
1.1 |
|
37 |
cnh |
1.3 |
C !USES: |
38 |
|
|
C == Global variables == |
39 |
heimbach |
1.1 |
#include "EEPARAMS.h" |
40 |
cnh |
1.3 |
INTEGER ILNBLNK |
41 |
|
|
EXTERNAL ILNBLNK |
42 |
heimbach |
1.1 |
|
43 |
cnh |
1.3 |
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 |
heimbach |
1.1 |
|
58 |
cnh |
1.3 |
C-- Open the data file |
59 |
heimbach |
1.1 |
|
60 |
cnh |
1.3 |
CALL mdsFindUnit( inunit, mythid ) |
61 |
heimbach |
1.1 |
|
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 |
|
|
endif |
83 |
|
|
|
84 |
|
|
do while ( .true. ) |
85 |
|
|
read(inunit, fmt='(a)', iostat=errio) record |
86 |
|
|
if ( errio .ne. 0 ) then |
87 |
|
|
goto 1001 |
88 |
|
|
end if |
89 |
|
|
il = max(ilnblnk(record),1) |
90 |
|
|
if ( record(1:1) .eq. commentcharacter ) then |
91 |
|
|
else if ( record(1:1) .eq. '/' ) then |
92 |
|
|
#ifdef FTN_NML_F90 |
93 |
|
|
write(outunit, fmt='(a)') record(:il) |
94 |
|
|
#else |
95 |
|
|
write(outunit, fmt='(a)') ' &' |
96 |
|
|
#endif |
97 |
|
|
else if ( record(1:2) .eq. ' /' ) then |
98 |
|
|
#ifdef FTN_NML_F90 |
99 |
|
|
write(outunit, fmt='(a)') record(:il) |
100 |
|
|
#else |
101 |
|
|
write(outunit, fmt='(a)') ' &' |
102 |
|
|
#endif |
103 |
|
|
else |
104 |
|
|
write(outunit, fmt='(a)') record(:il) |
105 |
|
|
end if |
106 |
|
|
enddo |
107 |
|
|
1001 continue |
108 |
|
|
close( inunit ) |
109 |
|
|
|
110 |
|
|
rewind( outunit ) |
111 |
|
|
|
112 |
|
|
end |
113 |
|
|
|