Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GOTO statements from the Fortran code (bugzilla #310) #4

Open
DanIredell-NOAA opened this issue Mar 15, 2022 · 5 comments
Open

Comments

@DanIredell-NOAA
Copy link
Contributor

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.

                            V1 GOTOs        V2 GOTOs

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

  • These are new codes delivered to us by the Navy as part of NOAA-NCEP MoA.
    ** Community HYCOM codes with improvements.

[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

@DanIredell-NOAA
Copy link
Contributor Author

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

@DanIredell-NOAA
Copy link
Contributor Author

DanIredell-NOAA commented Nov 23, 2022

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

@DanIredell-NOAA
Copy link
Contributor Author

DanIredell-NOAA commented Nov 27, 2023

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

@DanIredell-NOAA
Copy link
Contributor Author

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

@DanIredell-NOAA
Copy link
Contributor Author

RTOFS v2.5.0 gotos reduced from 1181 to 1172

RTOFS V2.4.0
libs                 0
rtofs_code.fd       61
rtofs_hycom.fd     885
rtofs_ncoda.fd     226
TOTAL             1172

rtofs_code.fd
rtofs_archv2netCDF.fd      33
rtofs_raw2hycom.fd          1
rtofs_hycom_diff.fd         3
rtofs_hycom_extract.fd      2
rtofs_ncoda_archiv_inc.fd  18
rtofs_ssmis_tol2.cd        4

rtofs_hycom.fd
esmf_4_0_0rp2   789
hycom (hycom)    95
hycom (cice)      1

rtofs_ncoda.fd
ncoda_decode   22
ncoda_qc       133
ncoda_var      71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant