Skip to content

Commit

Permalink
Fix PGI warnings about intent for restart_CS
Browse files Browse the repository at this point in the history
- The PGI compiler was complaining about some `intent(in) :: CS`
  in MOM_restart.F90. This was because of a line that changes the
  state of data pointed to from within `CS`, but not `CS` itself:
     CS%restart_field(n)%initialized = .true.
  The strict interpretation is that `CS` is not modified because
  `CS%restart_field` is a pointer to memory elsewhere. However, the
  `intent(in)` indicates to the user/programmer that nothing changes
  and since all arguments to the functions are `intent(in)` most entities,
  including the PGI compiler, should be surprised that something changed
  as a result of a passive "query" function. This strict interpretation
  allows a devious hidden-change-of-state to occur.
- Changing the intent to `intent(inout)` has the consequence that the
  new intent has to be propagated upwards through the code. And why should
  a type be `intent(out)` for query functions?
- This commit removes offending lines that change the state. Apparently
  we didn't need them!?
  • Loading branch information
adcroft authored and marshallward committed Jul 4, 2022
1 parent d2d3236 commit 1e9febe
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/framework/MOM_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,6 @@ function query_initialized_name(name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if ((n==CS%novars+1) .and. (is_root_pe())) &
call MOM_error(NOTE,"MOM_restart: Unknown restart variable "//name// &
" queried for initialization.")
Expand Down Expand Up @@ -625,8 +623,6 @@ function query_initialized_0d(f_ptr, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.

end function query_initialized_0d

Expand All @@ -651,8 +647,6 @@ function query_initialized_1d(f_ptr, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.

end function query_initialized_1d

Expand All @@ -678,8 +672,6 @@ function query_initialized_2d(f_ptr, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.

end function query_initialized_2d

Expand All @@ -705,8 +697,6 @@ function query_initialized_3d(f_ptr, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.

end function query_initialized_3d

Expand All @@ -732,8 +722,6 @@ function query_initialized_4d(f_ptr, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.

end function query_initialized_4d

Expand All @@ -760,8 +748,6 @@ function query_initialized_0d_name(f_ptr, name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if (n==CS%novars+1) then
if (is_root_pe()) &
call MOM_error(NOTE,"MOM_restart: Unable to find "//name//" queried by pointer, "//&
Expand Down Expand Up @@ -795,8 +781,6 @@ function query_initialized_1d_name(f_ptr, name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if (n==CS%novars+1) then
if (is_root_pe()) &
call MOM_error(NOTE,"MOM_restart: Unable to find "//name//" queried by pointer, "//&
Expand Down Expand Up @@ -830,8 +814,6 @@ function query_initialized_2d_name(f_ptr, name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if (n==CS%novars+1) then
if (is_root_pe()) &
call MOM_error(NOTE,"MOM_restart: Unable to find "//name//" queried by pointer, "//&
Expand Down Expand Up @@ -865,8 +847,6 @@ function query_initialized_3d_name(f_ptr, name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if (n==CS%novars+1) then
if (is_root_pe()) &
call MOM_error(NOTE, "MOM_restart: Unable to find "//name//" queried by pointer, "//&
Expand Down Expand Up @@ -900,8 +880,6 @@ function query_initialized_4d_name(f_ptr, name, CS) result(query_initialized)
n = m ; exit
endif
enddo
! Assume that you are going to initialize it now, so set flag to initialized if queried again.
if (n<=CS%novars) CS%restart_field(n)%initialized = .true.
if (n==CS%novars+1) then
if (is_root_pe()) &
call MOM_error(NOTE, "MOM_restart: Unable to find "//name//" queried by pointer, "//&
Expand Down

0 comments on commit 1e9febe

Please sign in to comment.