-
Notifications
You must be signed in to change notification settings - Fork 11
Some small bugs in feature/eCAI are fixed #16
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
Open
guoqiang-tang
wants to merge
8
commits into
NCAR:feature/eCAI
Choose a base branch
from
guoqiang-fork:feature/eCAI
base: feature/eCAI
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c6ab502
updat gitignore and add files in from_NR and downscale
guoqiang-tang f72d60f
makefile
guoqiang-tang 266da63
update
guoqiang-tang 38293a2
update downscale makefile
guoqiang-tang 07ca4e7
update ensemble makefile
guoqiang-tang ce95277
update
guoqiang-tang db4c354
fix small bugs
guoqiang-tang 0c1315a
correct the abs() for trange in daily_anom
guoqiang-tang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # ============= Makefile for downscaling program ====================== | ||
|
|
||
| # NOTE: first link one numrec.f file needed into this directory if not present | ||
| # eg, ln -s ../from_NR/numrec.f90 | ||
|
|
||
| # name of executable | ||
| EXE = downscale.exe | ||
|
|
||
| # core directory | ||
| KOREDIR = /Users/localuser/Github/GMET/downscale | ||
|
|
||
| # fortran compiler | ||
| FC = gfortran | ||
|
|
||
| # NetCDF libraries | ||
| PATHNETCDF = /usr/local/Cellar/netcdf/4.6.3_1 | ||
| LIBNETCDF = -L$(PATHNETCDF)/lib -lnetcdff | ||
| INCNETCDF = -I$(PATHNETCDF)/include | ||
|
|
||
| # define compiler flags | ||
| FLAGS = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds | ||
|
|
||
| # define subroutines | ||
| GMET_SUB = \ | ||
| $(KOREDIR)/type.f90 \ | ||
| $(KOREDIR)/precmod.f90 \ | ||
| $(KOREDIR)/string_mod.f90 \ | ||
| $(KOREDIR)/numrec.f90 \ | ||
| $(KOREDIR)/utim.f90 \ | ||
| $(KOREDIR)/read_config.f90 \ | ||
| $(KOREDIR)/read_control.f90 \ | ||
| $(KOREDIR)/read_nc.f90 \ | ||
| $(KOREDIR)/read_domain_grid.f90 \ | ||
| $(KOREDIR)/write_nc.f90 \ | ||
| $(KOREDIR)/stats_routines.f90 \ | ||
| $(KOREDIR)/regression_routines.f90 \ | ||
| $(KOREDIR)/station_weights.f90 \ | ||
| $(KOREDIR)/estimate_coefficients.f90 \ | ||
| $(KOREDIR)/estimate_forcing_regression.f90 \ | ||
| $(KOREDIR)/estimate_climo_regression.f90 \ | ||
| $(KOREDIR)/estimate_climo_anom_regression.f90 | ||
|
|
||
| # Define the driver routine | ||
| DRIVER = $(KOREDIR)/main.f90 | ||
|
|
||
| # Compile | ||
|
|
||
| # tasks | ||
| all: compile install clean | ||
|
|
||
| # compile | ||
| compile: | ||
| $(FC) $(FLAGS) $(GMET_SUB) $(DRIVER) \ | ||
| $(LIBNETCDF) $(INCNETCDF) -o $(EXE) | ||
|
|
||
| install: | ||
|
|
||
| # Remove object files | ||
| clean: | ||
| @rm -f *.o | ||
| @rm -f *.mod | ||
| @rm -f *__genmod.f90 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # ============= Makefile for downscaling program ====================== | ||
|
|
||
| # NOTE: first link one numrec.f file needed into this directory if not present | ||
| # eg, ln -s ../from_NR/numrec.f90 | ||
|
|
||
| # name of executable | ||
| EXE = downscale.exe | ||
|
|
||
| # core directory | ||
| KOREDIR = /home/gut428/GMET/GMET_scripts/downscale | ||
|
|
||
| # fortran compiler | ||
| FC = gfortran | ||
|
|
||
| # NetCDF libraries | ||
| # PATHNETCDF = /usr/local | ||
| PATHNETCDF = /cvmfs/soft.computecanada.ca/easybuild/software/2017/avx/Compiler/gcc5.4/netcdf-fortran/4.4.4 | ||
| LIBNETCDF = -L$(PATHNETCDF)/lib -lnetcdff | ||
| INCNETCDF = -I$(PATHNETCDF)/include | ||
|
|
||
| # define compiler flags | ||
| FLAGS = -p -g -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds | ||
|
|
||
| # define subroutines | ||
| GMET_SUB = \ | ||
| $(KOREDIR)/type.f90 \ | ||
| $(KOREDIR)/precmod.f90 \ | ||
| $(KOREDIR)/string_mod.f90 \ | ||
| $(KOREDIR)/numrec.f90 \ | ||
| $(KOREDIR)/utim.f90 \ | ||
| $(KOREDIR)/read_config.f90 \ | ||
| $(KOREDIR)/read_control.f90 \ | ||
| $(KOREDIR)/read_nc.f90 \ | ||
| $(KOREDIR)/read_domain_grid.f90 \ | ||
| $(KOREDIR)/write_nc.f90 \ | ||
| $(KOREDIR)/stats_routines.f90 \ | ||
| $(KOREDIR)/regression_routines.f90 \ | ||
| $(KOREDIR)/station_weights.f90 \ | ||
| $(KOREDIR)/estimate_coefficients.f90 \ | ||
| $(KOREDIR)/estimate_forcing_regression.f90 \ | ||
| $(KOREDIR)/estimate_climo_regression.f90 \ | ||
| $(KOREDIR)/estimate_climo_anom_regression.f90 | ||
|
|
||
| # Define the driver routine | ||
| DRIVER = $(KOREDIR)/main.f90 | ||
|
|
||
| # Compile | ||
|
|
||
| # tasks | ||
| all: compile install clean | ||
|
|
||
| # compile | ||
| compile: | ||
| $(FC) $(FLAGS) $(GMET_SUB) $(DRIVER) \ | ||
| $(LIBNETCDF) $(INCNETCDF) -o $(EXE) | ||
|
|
||
| install: | ||
|
|
||
| # Remove object files | ||
| clean: | ||
| @rm -f *.o | ||
| @rm -f *.mod | ||
| @rm -f *__genmod.f90 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>CFBundleDevelopmentRegion</key> | ||
| <string>English</string> | ||
| <key>CFBundleIdentifier</key> | ||
| <string>com.apple.xcode.dsym.downscale.exe</string> | ||
| <key>CFBundleInfoDictionaryVersion</key> | ||
| <string>6.0</string> | ||
| <key>CFBundlePackageType</key> | ||
| <string>dSYM</string> | ||
| <key>CFBundleSignature</key> | ||
| <string>????</string> | ||
| <key>CFBundleShortVersionString</key> | ||
| <string>1.0</string> | ||
| <key>CFBundleVersion</key> | ||
| <string>1</string> | ||
| </dict> | ||
| </plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| ! This collection of routines from num_rec was put together as part of the | ||
| ! downscaling code effort. NCAR 2013 | ||
|
|
||
|
|
||
| subroutine nrerror (string) | ||
| character (len=*), intent (in) :: string | ||
| write (*,*) 'nrerror: ', string | ||
| stop 'program terminated by nrerror' | ||
| end subroutine nrerror | ||
|
|
||
| function assert_eq (n1, n2, n3, string) | ||
| character (len=*), intent (in) :: string | ||
| integer, intent (in) :: n1, n2, n3 | ||
| integer :: assert_eq | ||
| if (n1 == n2 .and. n2 == n3) then | ||
| assert_eq = n1 | ||
| else | ||
| write (*,*) 'nrerror: an assert_eq failed with this tag:', string | ||
| stop 'program terminated by assert_eq3' | ||
| end if | ||
| end function assert_eq | ||
|
|
||
| subroutine swap_d (a, b) | ||
| use type | ||
| real (dp), dimension (:), intent (inout) :: a, b | ||
| real (dp), dimension (size(a)) :: dum | ||
| dum = a | ||
| a = b | ||
| b = dum | ||
| end subroutine swap_d | ||
|
|
||
| function imaxloc (arr) | ||
| use type | ||
| real (dp), dimension (:), intent (in) :: arr | ||
| integer (i4b) :: imaxloc | ||
| integer (i4b), dimension (1) :: imax | ||
| imax = maxloc (arr(:)) | ||
| imaxloc = imax (1) | ||
| end function imaxloc | ||
|
|
||
| function outerprod (a, b) | ||
| use type | ||
| real (dp), dimension (:), intent (in) :: a, b | ||
| real (dp), dimension (size(a), size(b)) :: outerprod | ||
| outerprod = spread (a, dim=2, ncopies=size(b)) * spread (b, dim=1, ncopies=size(a)) | ||
| end function outerprod | ||
|
|
||
| subroutine ludcmp (a, indx, d) | ||
| use type | ||
| implicit none | ||
| interface | ||
| subroutine nrerror (string) | ||
| character (len=*), intent (in) :: string | ||
| end subroutine nrerror | ||
|
|
||
| function assert_eq (n1, n2, n3, string) | ||
| character (len=*), intent (in) :: string | ||
| integer, intent (in) :: n1, n2, n3 | ||
| integer :: assert_eq | ||
| end function assert_eq | ||
|
|
||
| function imaxloc (arr) | ||
| use type | ||
| real (dp), dimension (:), intent (in) :: arr | ||
| integer (i4b) :: imaxloc | ||
| end function imaxloc | ||
|
|
||
| function outerprod (a, b) | ||
| use type | ||
| real (dp), dimension (:), intent (in) :: a, b | ||
| real (dp), dimension (size(a), size(b)) :: outerprod | ||
| end function outerprod | ||
|
|
||
| subroutine swap_d (a, b) | ||
| use type | ||
| real (dp), dimension (:), intent (inout) :: a, b | ||
| end subroutine swap_d | ||
| end interface | ||
|
|
||
| real (dp), dimension (:, :), intent (inout) :: a | ||
| integer (i4b), dimension (:), intent (out) :: indx | ||
| real (dp), intent (out) :: d | ||
| real (dp), dimension (size(a, 1)) :: vv | ||
| ! REAL(DP), PARAMETER :: TINY=1.0e-20 | ||
| integer (i4b) :: j, n, imax | ||
| n = assert_eq (size(a, 1), size(a, 2), size(indx), 'ludcmp') | ||
| d = 1.0d0 | ||
| vv = maxval (abs(a), dim=2) | ||
| if (any(vv == 0.0)) call nrerror ('singular matrix in ludcmp') | ||
| vv = 1.0d0 / vv | ||
| do j = 1, n | ||
| imax = (j-1) + imaxloc (vv(j:n)*abs(a(j:n, j))) | ||
| if (j /= imax) then | ||
| call swap_d (a(imax, :), a(j, :)) | ||
| d = - d | ||
| vv (imax) = vv (j) | ||
| end if | ||
| indx (j) = imax | ||
| if (a(j, j) == 0.0) a (j, j) = tiny | ||
| a (j+1:n, j) = a (j+1:n, j) / a (j, j) | ||
| a (j+1:n, j+1:n) = a (j+1:n, j+1:n) - outerprod (a(j+1:n, j), a(j, j+1:n)) | ||
| end do | ||
| end subroutine ludcmp | ||
|
|
||
| subroutine lubksb (a, indx, b) | ||
| use type | ||
| implicit none | ||
| interface | ||
| function assert_eq (n1, n2, n3, string) | ||
| character (len=*), intent (in) :: string | ||
| integer, intent (in) :: n1, n2, n3 | ||
| integer :: assert_eq | ||
| end function assert_eq | ||
| end interface | ||
|
|
||
| real (dp), dimension (:, :), intent (in) :: a | ||
| integer (i4b), dimension (:), intent (in) :: indx | ||
| real (dp), dimension (:), intent (inout) :: b | ||
| integer (i4b) :: i, n, ii, ll | ||
| real (dp) :: summ | ||
| n = assert_eq (size(a, 1), size(a, 2), size(indx), 'lubksb') | ||
| ii = 0 | ||
| do i = 1, n | ||
| ll = indx (i) | ||
| summ = b (ll) | ||
| b (ll) = b (i) | ||
| if (ii /= 0) then | ||
| summ = summ - dot_product (a(i, ii:i-1), b(ii:i-1)) | ||
| else if (summ /= 0.0) then | ||
| ii = i | ||
| end if | ||
| b (i) = summ | ||
| end do | ||
| do i = n, 1, - 1 | ||
| b (i) = (b(i)-dot_product(a(i, i+1:n), b(i+1:n))) / a (i, i) | ||
| end do | ||
| end subroutine lubksb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| FUNCTION erf_s(x) | ||
| USE nrtype | ||
| USE nr, ONLY : gammp | ||
| IMPLICIT NONE | ||
| REAL(SP), INTENT(IN) :: x | ||
| REAL(SP) :: erf_s | ||
| erf_s=gammp(0.5_sp,x**2) | ||
| if (x < 0.0) erf_s=-erf_s | ||
| END FUNCTION erf_s | ||
|
|
||
|
|
||
| FUNCTION erf_v(x) | ||
| USE nrtype | ||
| USE nr, ONLY : gammp | ||
| IMPLICIT NONE | ||
| REAL(SP), DIMENSION(:), INTENT(IN) :: x | ||
| REAL(SP), DIMENSION(size(x)) :: erf_v | ||
| erf_v=gammp(spread(0.5_sp,1,size(x)),x**2) | ||
| where (x < 0.0) erf_v=-erf_v | ||
| END FUNCTION erf_v |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The abs() was included in the case that Tmax is larger than Tmin in the input files. We can remove it but that may allow for negative DTR...
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 should really add a warning to the user and then stop the program if Tmax > Tmin.
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 tend to want to avoid putting in an if statement at the most granular data levels ... I think I would leave the abs in but if there is a way to also check for temperature flips at a field/vector level, perhaps once per timestep, and report if any are found, that might be preferable.