Skip to content

Commit

Permalink
Update external_ic.F90 and fv_nudge.F90 to use allocatable arrays (NO…
Browse files Browse the repository at this point in the history
…AA-GFDL#65)


* revise external_ic.F90 and fv_nudge.F90 to use allocatable arrays
  • Loading branch information
binli2337 authored and laurenchilutti committed Jan 14, 2022
1 parent 81b9be0 commit 44211c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions tools/external_ic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3914,16 +3914,17 @@ subroutine pmaxmin( qname, a, im, jm, fac )
integer i, j
class(*) a(im,jm)

real(r4_kind) qmin(jm), qmax(jm)
real(r4_kind) pmax, pmin
real(r4_kind), dimension(:), allocatable :: qmin, qmax
real(r4_kind) pmax, pmin
class(*) fac ! multiplication factor
real(r8_kind) qmin8(jm), qmax8(jm)
real(r8_kind) pmax8, pmin8
real(r8_kind), dimension(:), allocatable :: qmin8, qmax8
real(r8_kind) pmax8, pmin8

select type (fac)
type is (real(kind=r4_kind))
select type (a)
type is (real(kind=r4_kind))
allocate(qmax(jm), qmin(jm))
do j=1,jm
pmax = a(1,j)
pmin = a(1,j)
Expand All @@ -3943,6 +3944,7 @@ subroutine pmaxmin( qname, a, im, jm, fac )
pmax = max(pmax, qmax(j))
pmin = min(pmin, qmin(j))
enddo
deallocate(qmax, qmin)

write(*,*) qname, ' max = ', pmax*fac, ' min = ', pmin*fac
class default
Expand All @@ -3952,6 +3954,7 @@ subroutine pmaxmin( qname, a, im, jm, fac )
type is (real(kind=r8_kind))
select type (a)
type is (real(kind=r8_kind))
allocate(qmax8(jm), qmin8(jm))
do j=1,jm
pmax8 = a(1,j)
pmin8 = a(1,j)
Expand All @@ -3971,6 +3974,7 @@ subroutine pmaxmin( qname, a, im, jm, fac )
pmax8 = max(pmax8, qmax8(j))
pmin8 = min(pmin8, qmin8(j))
enddo
deallocate(qmax8, qmin8)

write(*,*) qname, ' max = ', pmax8*fac, ' min = ', pmin8*fac
class default
Expand Down
8 changes: 6 additions & 2 deletions tools/fv_nudge.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3403,16 +3403,17 @@ subroutine pmaxmin( qname, a, imax, jmax, fac )
class(*) a(imax,jmax)
class(*) fac ! multiplication factor

real(r4_kind) qmin(jmax), qmax(jmax)
real(r4_kind), dimension(:), allocatable :: qmin, qmax
real(r4_kind) pmax, pmin

real(r8_kind) qmin8(jmax), qmax8(jmax)
real(r8_kind), dimension(:), allocatable :: qmin8, qmax8
real(r8_kind) pmax8, pmin8

select type (fac)
type is (real(kind=r4_kind))
select type (a)
type is (real(kind=r4_kind))
allocate(qmax(jmax), qmin(jmax))
do j=1,jmax
pmax = a(1,j)
pmin = a(1,j)
Expand All @@ -3432,6 +3433,7 @@ subroutine pmaxmin( qname, a, imax, jmax, fac )
pmax = max(pmax, qmax(j))
pmin = min(pmin, qmin(j))
enddo
deallocate(qmax, qmin)

write(*,*) qname, ' max = ', pmax*fac, ' min = ', pmin*fac
class default
Expand All @@ -3441,6 +3443,7 @@ subroutine pmaxmin( qname, a, imax, jmax, fac )
type is (real(kind=r8_kind))
select type (a)
type is (real(kind=r8_kind))
allocate(qmax8(jmax), qmin8(jmax))
do j=1,jmax
pmax8 = a(1,j)
pmin8 = a(1,j)
Expand All @@ -3460,6 +3463,7 @@ subroutine pmaxmin( qname, a, imax, jmax, fac )
pmax8 = max(pmax8, qmax8(j))
pmin8 = min(pmin8, qmin8(j))
enddo
deallocate(qmax8, qmin8)

write(*,*) qname, ' max = ', pmax8*fac, ' min = ', pmin8*fac
class default
Expand Down

0 comments on commit 44211c0

Please sign in to comment.