Open DanIredell-NOAA opened 2 years ago
Better command for counting (?)
for file in find sorc -name "*.[fF]*" -type f
; do egrep -iH "go[ ]*to" $file | grep -iv :c | grep -iv :! ; done | wc -l
Clarification on the commands --
grep -ri 'go *to' . | grep -v -e '^c' -e '^!' | wc -l
for file in $(find . -name "*.[fF]*" -type f) ; do egrep -iH "go[ ]*to" $file | grep -iv :c | grep -iv :! ; done | wc -l
The second command does a better job of searching only fortran codes and not finding 'go to' in comments
RTOFS V2.3.4
libs 0
rtofs_code.fd 77
rtofs_hycom.fd 890
rtofs_ncoda.fd 373
TOTAL 1340
rtofs_code.fd
rtofs_archv2netCDF.fd 35
rtofs_raw2hycom.fd 1
rtofs_hycom_diff.fd 3
rtofs_hycom_extract.fd 2
rtofs_ncoda_archiv_inc.fd 19
rtofs_ssmis_tol2.cd 17
rtofs_hycom.fd
esmf_4_0_0rp2 789
hycom (hycom) 96
hycom (cice) 5
rtofs_ncoda.fd
ncoda_decode 22
ncoda_qc 133
ncoda_graph 147
ncoda_var 71
Removing dead code reduces the number by 159:
RTOFS V2.4.0
libs 0
rtofs_code.fd 65
rtofs_hycom.fd 890
rtofs_ncoda.fd 226
TOTAL 1181
rtofs_code.fd
rtofs_archv2netCDF.fd 35
rtofs_raw2hycom.fd 1
rtofs_hycom_diff.fd 3
rtofs_hycom_extract.fd 2
rtofs_ncoda_archiv_inc.fd 19
rtofs_ssmis_tol2.cd 5
rtofs_hycom.fd
esmf_4_0_0rp2 789
hycom (hycom) 96
hycom (cice) 5
rtofs_ncoda.fd
ncoda_decode 22
ncoda_qc 133
ncoda_var 71
From http://www2.spa.ncep.noaa.gov/bugzilla/show_bug.cgi?id=310
[NCO] 20150827 Please replace GOTO statements with more structured constants (if blocks, do loops, case blocks).
Current number of GOTO statements:
grep -ri 'go *to' /nwpara2/rtofs_glo.v1.1.0/sorc | grep -v -e '^c' -e '^!' | wc -l 62
[EMC] 20200804 Note that not any of the below GOTOs are either assigned or computed. GOTOs have been reduced in EMC codes.
In both V1 and V2 rtofs_archv2netCDF.fd 35 35 rtofs_atmforcing_correct.fd 0 0 rtofs_atmforcing.fd 1 0 rtofs_getkpds.fd 0 0 rtofs_hycom2raw8.fd 1 1 rtofs_hycom_expr.fd 2 0 rtofs_nc2grb2.fd 0 0 rtofs_hycomiot (library) 0 0 rtofs_mpi_mods (library) 0 0 39 36
REMOVED in V2 rtofs_cice_stat.fd 0 n/a rtofs_hycom_extract.fd 2 n/a rtofs_hycom_range.fd 1 n/a rtofs_restart2archv.fd 20 n/a 23 0 NEW to V2 rtofs_hycom_diff.fd n/a 3 *rtofs_ncoda_archv_inc.fd n/a 19 rtofs_raw2hycom.fd n/a 1 0 23
TOTAL for EMC codes 62 59
3rd party codes *HYCOM 162 98
NCODA n/a 330
OVERALL TOTAL 224 487
[NCO] 20201123 Please continue to improve "go to" usage at next upgrade.
There are 571 GO TOs in this para version, while there are 260 GO TOs in current production rtofs_glo.v1.3.0. Bugzilla ticket is updated.
Prod rtofs_glo.v1.3.0 260 - rtofs_archv2netCDF.fd 35, rtofs_atmforcing_correct.fd 0,
rtofs_atmforcing.fd 1, rtofs_cice_stat.fd 0, rtofs_getkpds.fd 0, rtofs_hycom2raw8.fd 1, rtofs_hycom_expr.fd 2, rtofs_hycom_extract.fd 2, rtofs_hycom_range.fd 1, rtofs_nc2grb2.fd 0, rtofs_restart2archv.fd 20, rtofs_code.v2.2.86F2p0i/sorc 198
Para rtofs_glo.v2.0.6 571 - rtofs_code.fd 64, rtofs_hycom.fd 108, rtofs_ncoda.fd 399