| 119 | |
| 120 | '''Full development branch''' |
| 121 | |
| 122 | This approach has been implemented and tested on a 2019 development branch: |
| 123 | |
| 124 | https://forge.ipsl.jussieu.fr/nemo/browser/NEMO/branches/2019/dev_r11613_ENHANCE-04_namelists_as_internalfiles |
| 125 | |
| 126 | This branch contains only the substantive changes; to compile and run tests all REWIND and CLOSE operations on the (no longer) units have to be removed. These changes affect many more files but can be scripted so are not included the branch in order to make a later merge easier. The scripts used to prepare code for testing are included below. With these additional changes this code passes most SETTE tests but the AGRIF preprocessor does not currently accept the new allocatable character strings. The conversion routine first bails on: |
| 127 | |
| 128 | {{{ |
| 129 | fcm_internal compile:F nemo /home/acc/NEMO/IMMERSE/dev_r11613_ENHANCE-04_namelists_as_internalfiles/tests/VORTEX_ST/NEMOFILES/ppsrc/nemo/in_out_manager.f90 in_out_manager.f90 |
| 130 | /home/acc/NEMO/IMMERSE/dev_r11613_ENHANCE-04_namelists_as_internalfiles/mk/agrifpp.sh in_out_manager.f90 /home/acc/NEMO/IMMERSE/dev_r11613_ENHANCE-04_namelists_as_internalfiles/tests/VORTEX_ST/NEMOFILES/inc /home/acc/NEMO/IMMERSE/dev_r11613_ENHANCE-04_namelists_as_internalfiles/tests/VORTEX_ST/NEMOFILES/ppsrc/nemo/in_out_manager.f90 |
| 131 | syntax error line 135, file in_out_manager.f90 motclef = |:| |
| 132 | fcm_internal compile failed (256) |
| 133 | |
| 134 | which is the line: |
| 135 | |
| 136 | CHARACTER(LEN=:), ALLOCATABLE :: numnam_ref !: character buffer for reference namelist |
| 137 | |
| 138 | }}} |
| 139 | |
| 140 | AGRIF will need to be made to understand the (LEN=: ) syntax before this solution can be progressed. |
| 141 | |
| 142 | All non-AGRIF SETTE tests are passing but note none of the current tests use multiple BDY namelists; a solution for that issue has yet to be coded. |
| 143 | |
| 144 | |
| 145 | '''Lists and scripts''' |
| 146 | To minimise changes that need to be merged later, only the substantive changes have been checked into the development branch. These changes include the new routine in lib_mpp.F90, buffer declarations and replacement of any ctl_opn calls for namelist input. The list of files in this category is held in src/substantive.list and is: |
| 147 | |
| 148 | {{{ |
| 149 | ICE/icestp.F90 |
| 150 | OCE/IOM/in_out_manager.F90 |
| 151 | OCE/LBC/lib_mpp.F90 |
| 152 | OCE/nemogcm.F90 |
| 153 | OFF/nemogcm.F90 |
| 154 | SAO/nemogcm.F90 |
| 155 | SAS/nemogcm.F90 |
| 156 | TOP/PISCES/SED/sedini.F90 |
| 157 | TOP/PISCES/sms_pisces.F90 |
| 158 | TOP/PISCES/trcnam_pisces.F90 |
| 159 | TOP/trc.F90 |
| 160 | TOP/trcnam.F90 |
| 161 | }}} |
| 162 | |
| 163 | A list of files potentially containing REWIND and CLOSE statements (but excluding files in the substantive list) can be built by running the following script in the src directory: |
| 164 | |
| 165 | {{{ |
| 166 | #!/bin/bash |
| 167 | # |
| 168 | INUNITS=( numnam_ref numnam_cfg numnat_ref numnat_cfg numtrc_ref numtrc_cfg numnam_ice_ref numnam_ice_cfg numnamsed_ref numnamsed_cfg numnatp_cfg numnatp_ref ) |
| 169 | RM_CMDS=( REWIND CLOSE ) |
| 170 | # |
| 171 | # First build a list of files likely to need alteration |
| 172 | # |
| 173 | if [ -f all_rewfiles.list ] ; then rm all_rewfiles.list; fi |
| 174 | for n in `seq 0 1 $(( ${#INUNITS[*]} - 1 ))` |
| 175 | do |
| 176 | grep -l -i ${INUNITS[$n]} `find ./ -name '*.[Ffh]90'` >> all_rewfiles.list |
| 177 | grep -l -i ${INUNITS[$n]} `find ../tests -name '*.[Ffh]90'` | grep -v WORK | grep -v BLD | grep -v NEMOFILES >> all_rewfiles.list |
| 178 | grep -l -i ${INUNITS[$n]} `find ../cfgs -name '*.[Ffh]90'` | grep -v WORK | grep -v BLD | grep -v NEMOFILES >> all_rewfiles.list |
| 179 | done |
| 180 | sort -u all_rewfiles.list > alluniq_rewfiles.list |
| 181 | for f in `cat substantive.list` |
| 182 | do |
| 183 | ff=`echo $f | sed -e 's:/:\\\/:g'` |
| 184 | echo $ff |
| 185 | ed - alluniq_rewfiles.list << EOF |
| 186 | /$ff/d |
| 187 | w |
| 188 | q |
| 189 | EOF |
| 190 | done |
| 191 | }}} |
| 192 | |
| 193 | and this list can be used to target an editing script which removes any REWIND or CLOSE statements on converted units (also to be run in src): |
| 194 | |
| 195 | {{{ |
| 196 | #!/bin/bash |
| 197 | # |
| 198 | INUNITS=( numnam_ref numnam_cfg numnat_ref numnat_cfg numtrc_ref numtrc_cfg numnam_ice_ref numnam_ice_cfg numnamsed_ref numnamsed_cfg numnatp_cfg numnatp_ref ) |
| 199 | RM_CMDS=( REWIND CLOSE ) |
| 200 | # |
| 201 | for f in `cat alluniq_rewfiles.list` |
| 202 | do |
| 203 | n=0 |
| 204 | for n in `seq 0 1 $(( ${#INUNITS[*]} - 1 ))` |
| 205 | do |
| 206 | for m in `seq 0 1 $(( ${#RM_CMDS[*]} - 1 ))` |
| 207 | do |
| 208 | perl -ni.bak -e 'print unless m@.*\s*'${RM_CMDS[$m]}'\s*\(\s*'${INUNITS[$n]}'\s*\).*@i' $f |
| 209 | done |
| 210 | done |
| 211 | done |
| 212 | cd ../ |
| 213 | rm `find ./ -name '*.bak'` |
| 214 | }}} |
| 215 | |
| 216 | . |