-
Notifications
You must be signed in to change notification settings - Fork 25
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
Some cosmetic changes #299
Some cosmetic changes #299
Conversation
hamocc/ncout_hamocc.F90
Outdated
if (use_cisonew) then | ||
call ncdefvar3d(SRF_ATMC13(iogrp),cmpflg,'p', & | ||
& 'atmc13','Atmospheric 13CO2',' ','ppm',0) | ||
call ncdefvar3d(SRF_ATMC14(iogrp),cmpflg,'p', & | ||
& 'atmc14','Atmospheric 14CO2',' ','ppm',0) | ||
end if | ||
endif | ||
|
||
! --- define 3d layer fields | ||
call ncdefvar3d(LYR_DP(iogrp),cmpflg,'p', & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed this &
sign
hamocc/ncout_hamocc.F90
Outdated
if (use_BROMO) then | ||
call ncdefvar3d(LYR_BROMO(iogrp),cmpflg,'p', & | ||
& 'bromo','Bromoform',' ','mol CHBr3 m-3',1) | ||
end if | ||
endif | ||
|
||
! --- define 3d level fields | ||
call ncdefvar3d(LVL_DIC(iogrp),cmpflg,'p', & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and these ones
! - solid volume fraction at cell center | ||
! - vertical molecular diffusion coefficients scaled with porosity | ||
! | ||
! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly, I am not really happy with loosing the indentation here for the comments, since they belong to what comes after, which is also indented. But that might be just my personal matter and if you prefer it like this, I'll adapt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmaerz - is your preference to have all comments not indented? Is that the general consensus for hamocc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, just the opposite. I would want to have the comments aligned to the code - I was just about to suggest this as a general comment - but it is something to generally agree on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We totally agree. Best free-format practices recommend - 'Indent blocks by 2 characters. Where possible, comments should be indented with the code within a block'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also generally agree - in this specific case, however, I was interpreting the comment as a header of the subroutine and therefore aligned it with the SUBROUTINE statement above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if it would have been written above the subroutine (which I wouldn't want) I would agree. Admittedly, here and also in other places, I would prefer indentation (there are a few more places, where this holds). But again, I am also fine, if you prefer it differently.
Hi @JorgSchwinger , ok, seems as if now, I am becoming a bit picky, sorry for that, but: could we think about aligning comments in general with the respective code? - e.g. in |
Another thing would be the small or capital writing of fortran command, but maybe this goes beyond what we should care about right now. For those, I would prefer to keep |
+ wts2*powtra(i,j,k,:) | ||
burial2(i,j,m,:) = wts1*burial2(i,j,m,:) & | ||
+ wts2*burial2(i,j,n,:) & | ||
+ wts2*burial(i,j,:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mvertens
this is a good example of what I mean with the vertical alignment. I guess these changes would be reverted by an auto-indent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JorgSchwinger - yes it is. Thanks for the clarification. I agree that these changes would be reverted.
Not sure if we could automate that. Maybe a meeting to discuss all of these issues would be good.
Looks like we opened a can of worms :-) |
Mmh, since this PR provokes some comments, I would suggest to collect them afterward in a small document (or updating older documents on best practices for iHAMOCC coding style). |
ncstat = NF90_OPEN(rstfnm,NF90_NOWRITE, ncid) | ||
IF ( ncstat .NE. NF90_NOERR ) THEN | ||
CALL xchalt('(AUFR: Problem with netCDF1)') | ||
stop '(AUFR: Problem with netCDF1)' | ||
CALL xchalt('(AUFR: Problem with netCDF1)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly, the indentation of the stop is unclear to me (if it is about aligning the message, you could just shift the message). Go as you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, will fix this.
I agree, this seems to be a can of worms... It looks like we will have to discuss things a bit first. I would suggest that we sit together and update the HAMOCC coding guidelines that we already made some time ago (should be also put into the repository). For now, I would suggest to leave it here (I have one more pending request though) such that we can proceed making the release v1.4.0 and start working towards v1.5.0. |
hamocc/ocprod.F90
Outdated
@@ -100,7 +101,6 @@ subroutine ocprod(kpie,kpje,kpke,kbnd,pdlxp,pdlyp,pddpo,omask,ptho,pi_ph) | |||
use_BROMO,use_AGG,use_PBGC_OCNP_TIMESTEP,use_FB_BGC_OCE,use_AGG,use_cisonew,use_natDIC, & | |||
use_WLIN,use_sedbypass | |||
use mo_vgrid, only: dp_min,dp_min_sink,k0100,k0500,k1000,k2000,k4000,kwrbioz,ptiestu | |||
use mod_xc, only: mnproc | |||
use mo_biomod, only: eps3d,bifr13_perm,growth_co2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mo_biomod
could go up (to the first mo_biomod
)
+ ocetra(i,j,kdonor,icalc13)*wcald)/ & | ||
(pddpo(i,j,k)+wcal) | ||
ocetra(i,j,k,icalc14) = (ocetra(i,j,k ,icalc14)*pddpo(i,j,k) & | ||
+ ocetra(i,j,kdonor,icalc14)*wcald)/ & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& sign indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JorgSchwinger , many thanks for the effort to bring the code to a better shape! - I am fine to approve (and do so), but I would suggest that we note down some (further) suggestions that we have, when browsing your changes. We had this already on the bucket list since a while and now the PR gives rise to further thoughts on it. From my side, I came up with a few general thoughts when browsing the changes:
- How much indent per code block (I would also opt for 2-3)
- Some routines/modules still have the +7 F77 indent, which could be changed to a smaller indent
- I agree with your 'indent by meaning approach' when aligning following up lines, which likely would mean no automated indention via emacs.
- Wrt spatial loops: any way is fine, I would say.
- I would be in favor of aligning comments to code blocks (to not break the visual code flow) - similarly, one could think about OMP directives
- small versus capital writing of Fortran commands (as written before, I would prefer capital for module, contains, implicit none, potentially subroutines, the rest I would be fine either way - like integer, float, if else endif constructs)
- Indention of comments on subroutines?
Ok, I guess, this is the collection of mine for now, but others might have more - I would compile this list also in the discussion #298, where we can follow up on it.
@jmaerz - thanks so much for compiling this list. That's super helpful and I agree should be moved to a discussion. I think we need to consider if we want a tool to go through the code and format it as a first pass and then fix things we don't like. It does not have to be emacs. Another point to consider is that most auto-formatters will not handle f77 code - but deal with free format code. At any rate this is a good discussion to have and come to a consensus on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JorgSchwinger - Thanks! This look fine to me 👍
hamocc/aufw_bgc.F90
Outdated
@@ -178,7 +177,7 @@ SUBROUTINE AUFW_BGC(kpie,kpje,kpke,ntr,ntrbgc,itrbgc,trc, & | |||
ncstat = NF90_CREATE(rstfnm,NF90_64BIT_OFFSET,ncid) | |||
IF ( ncstat .NE. NF90_NOERR ) THEN | |||
call xchalt('(AUFW: Problem with netCDF1)') | |||
stop '(AUFW: Problem with netCDF1)' | |||
stop '(AUFW: Problem with netCDF1)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same indentation as for aufr_bgc
. Just a reminder to fix it in both files.
@JorgSchwinger @jmaerz |
@TomasTorsvik , I think, #300 should also come in, right? - I'll update #289 |
I went through the code and prettied a few things up a bit (as I believe). If there is something controversial I'm happy to revert it.