From a4869c7e3658dd219e71be71b34c9def39b57d8c Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Thu, 23 Mar 2017 18:43:37 -0600 Subject: [PATCH 1/7] Warn users when projection is inappropriate for GWD_OPT=1 TYPE: new feature KEYWORDS: gwd_opt, projection SOURCE: internal DESCRIPTION OF CHANGES: In the WRF model for domain 1, if the projection has a large sinalpha (where it is larger than a default value), notify the user and stop. LIST OF MODIFIED FILES: list of changed files (use `git diff --name-status master` to get formatted list) M dyn_em/start_em.F TESTS CONDUCTED: - [ ] Reggie 3.07, checked means that is has been run --- dyn_em/start_em.F | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index f63e7d2429..c91a9c687b 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -161,6 +161,30 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ALLOCATE(z_at_q(IMS:IME,KMS:KME,JMS:JME),STAT=I) ; z_at_q = 0. CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags ) + ! If the rotation angle is too large, the GWD option does not do well with the assumed U and V + ! being close to earth relative. + + IF ( ( grid%id .EQ. 1 ) .AND. ( .NOT. config_flags%polar ) .AND. ( config_flags%gwd_opt .EQ. 1 ) ) THEN + max_sa = ABS(grid%sinalpha(its,jts)) + DO j=jts,MIN(jde-1,jte) + DO i=its,MIN(ide-1,ite) + max_sa = MAX ( max_sa , ABS(grid%sinalpha(i,j)) ) + END DO + END DO +#if ( defined(DM_PARALLEL) && ! defined(STUBMPI) ) + max_sa = wrf_dm_max_real ( max_sa ) +#endif + IF ( max_sa .GT. ABS(config_flags%max_sa_gwd) ) THEN + WRITE ( a_message , FMT='(A,F5.2)' ) 'Max ABS(sinalpha) for domain 1 = ',max_sa + CALL wrf_message ( a_message ) + WRITE ( a_message , FMT='(A)' ) 'This projection may not be appropriate for using the gravity wave drag option.' + CALL wrf_message ( a_message ) + WRITE ( a_message , FMT='(A,F5.2)' ) 'In namelist.input set either: 1) gwd_opt=0 or 2) max_sa_gwd>',max_sa + CALL wrf_error_fatal ( a_message ) + END IF + END IF + + IF ( ( MOD (ide-ids,config_flags%parent_grid_ratio) .NE. 0 ) .OR. & ( MOD (jde-jds,config_flags%parent_grid_ratio) .NE. 0 ) ) THEN WRITE(message, FMT='(A,I2,": Both MOD(",I4,"-",I1,",",I2,") and MOD(",I4,"-",I1,",",I2,") must = 0" )') & From b0a408517e9565c6706a17faeb15bfff5d24ec62 Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Thu, 23 Mar 2017 18:51:23 -0600 Subject: [PATCH 2/7] Need the registry also --- Registry/Registry.EM_COMMON | 1 + 1 file changed, 1 insertion(+) diff --git a/Registry/Registry.EM_COMMON b/Registry/Registry.EM_COMMON index 805636e152..82bec04185 100644 --- a/Registry/Registry.EM_COMMON +++ b/Registry/Registry.EM_COMMON @@ -2465,6 +2465,7 @@ rconfig integer km_opt_dfi namelist,dynamics max_domains 1 rconfig integer damp_opt namelist,dynamics 1 0 irh "damp_opt" "" "" rconfig integer rad_nudge namelist,dynamics 1 0 irh "rad_nudge" "" "" rconfig integer gwd_opt namelist,dynamics 1 0 irh "gwd_opt" "" "" +rconfig real max_sa_gwd namelist,dynamics 0.5 0 irh "gwd_opt" "max sinalpha allowed for gwd_opt=1" "" rconfig real zdamp namelist,dynamics max_domains 5000. h "zdamp" "" "" rconfig real dampcoef namelist,dynamics max_domains 0. h "dampcoef" "" "" rconfig real khdif namelist,dynamics max_domains 0 h "khdif" "" "" From 7c5b1fb3a7ee641343e8c2991a5a4099c00fcdc3 Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Thu, 23 Mar 2017 18:54:45 -0600 Subject: [PATCH 3/7] Addd in the declaration for max_sa --- dyn_em/start_em.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index c91a9c687b..8c722954cf 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -142,7 +142,7 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ! CCN for MP=18 initializatio REAL :: ccn_max_val - REAL :: max_mf + REAL :: max_mf, max_sa CALL get_ijk_from_grid ( grid , & ids, ide, jds, jde, kds, kde, & ims, ime, jms, jme, kms, kme, & From da5d7d6d5e5e694a5e961d186414f72042c7442e Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Thu, 23 Mar 2017 20:28:40 -0600 Subject: [PATCH 4/7] max_sa_gsd default is 0.5, oops on the num_dom entry --- Registry/Registry.EM_COMMON | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Registry/Registry.EM_COMMON b/Registry/Registry.EM_COMMON index 82bec04185..86e2ee0dc2 100644 --- a/Registry/Registry.EM_COMMON +++ b/Registry/Registry.EM_COMMON @@ -2465,7 +2465,7 @@ rconfig integer km_opt_dfi namelist,dynamics max_domains 1 rconfig integer damp_opt namelist,dynamics 1 0 irh "damp_opt" "" "" rconfig integer rad_nudge namelist,dynamics 1 0 irh "rad_nudge" "" "" rconfig integer gwd_opt namelist,dynamics 1 0 irh "gwd_opt" "" "" -rconfig real max_sa_gwd namelist,dynamics 0.5 0 irh "gwd_opt" "max sinalpha allowed for gwd_opt=1" "" +rconfig real max_sa_gwd namelist,dynamics 1 0.5 irh "gwd_opt" "max sinalpha allowed for gwd_opt=1" "" rconfig real zdamp namelist,dynamics max_domains 5000. h "zdamp" "" "" rconfig real dampcoef namelist,dynamics max_domains 0. h "dampcoef" "" "" rconfig real khdif namelist,dynamics max_domains 0 h "khdif" "" "" From 4c35bfb35d4bd237f21f3e1fcc9d5fe086b8cbb4 Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Thu, 23 Mar 2017 20:45:03 -0600 Subject: [PATCH 5/7] sinalpha -> sina --- dyn_em/start_em.F | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index 8c722954cf..b4c0572d44 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -165,17 +165,17 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ! being close to earth relative. IF ( ( grid%id .EQ. 1 ) .AND. ( .NOT. config_flags%polar ) .AND. ( config_flags%gwd_opt .EQ. 1 ) ) THEN - max_sa = ABS(grid%sinalpha(its,jts)) + max_sa = ABS(grid%sina(its,jts)) DO j=jts,MIN(jde-1,jte) DO i=its,MIN(ide-1,ite) - max_sa = MAX ( max_sa , ABS(grid%sinalpha(i,j)) ) + max_sa = MAX ( max_sa , ABS(grid%sina(i,j)) ) END DO END DO #if ( defined(DM_PARALLEL) && ! defined(STUBMPI) ) max_sa = wrf_dm_max_real ( max_sa ) #endif IF ( max_sa .GT. ABS(config_flags%max_sa_gwd) ) THEN - WRITE ( a_message , FMT='(A,F5.2)' ) 'Max ABS(sinalpha) for domain 1 = ',max_sa + WRITE ( a_message , FMT='(A,F5.2)' ) 'Max ABS(sina) for domain 1 = ',max_sa CALL wrf_message ( a_message ) WRITE ( a_message , FMT='(A)' ) 'This projection may not be appropriate for using the gravity wave drag option.' CALL wrf_message ( a_message ) From 6f6b6af0e104706a41b36b90bf5cb0e5accda57a Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Fri, 24 Mar 2017 15:57:40 -0600 Subject: [PATCH 6/7] Switch from sin(rotation angle) to rotation angle Set value to 22.5 degrees as max (half of 45 degrees), original data at 45 degree directions --- Registry/Registry.EM_COMMON | 2 +- dyn_em/start_em.F | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Registry/Registry.EM_COMMON b/Registry/Registry.EM_COMMON index 86e2ee0dc2..f8d630bfa9 100644 --- a/Registry/Registry.EM_COMMON +++ b/Registry/Registry.EM_COMMON @@ -2465,7 +2465,7 @@ rconfig integer km_opt_dfi namelist,dynamics max_domains 1 rconfig integer damp_opt namelist,dynamics 1 0 irh "damp_opt" "" "" rconfig integer rad_nudge namelist,dynamics 1 0 irh "rad_nudge" "" "" rconfig integer gwd_opt namelist,dynamics 1 0 irh "gwd_opt" "" "" -rconfig real max_sa_gwd namelist,dynamics 1 0.5 irh "gwd_opt" "max sinalpha allowed for gwd_opt=1" "" +rconfig real max_rot_angle_gwd namelist,dynamics 1 22.5 irh "max_rot_angle_gwd" "max projection rotation angle permitted for gwd_opt=1" "" rconfig real zdamp namelist,dynamics max_domains 5000. h "zdamp" "" "" rconfig real dampcoef namelist,dynamics max_domains 0. h "dampcoef" "" "" rconfig real khdif namelist,dynamics max_domains 0 h "khdif" "" "" diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index b4c0572d44..f09cf246c6 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -142,7 +142,7 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ! CCN for MP=18 initializatio REAL :: ccn_max_val - REAL :: max_mf, max_sa + REAL :: max_mf, max_rot_angle CALL get_ijk_from_grid ( grid , & ids, ide, jds, jde, kds, kde, & ims, ime, jms, jme, kms, kme, & @@ -164,22 +164,28 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & ! If the rotation angle is too large, the GWD option does not do well with the assumed U and V ! being close to earth relative. - IF ( ( grid%id .EQ. 1 ) .AND. ( .NOT. config_flags%polar ) .AND. ( config_flags%gwd_opt .EQ. 1 ) ) THEN - max_sa = ABS(grid%sina(its,jts)) + IF ( ( grid%id .EQ. 1 ) .AND. ( config_flags%gwd_opt .EQ. 1 ) ) THEN + max_rot_angle = ASIN(ABS(grid%sina(its,jts)))/DEGRAD DO j=jts,MIN(jde-1,jte) DO i=its,MIN(ide-1,ite) - max_sa = MAX ( max_sa , ABS(grid%sina(i,j)) ) + max_rot_angle = MAX ( max_rot_angle , ASIN(ABS(grid%sina(i,j)))/DEGRAD ) END DO END DO #if ( defined(DM_PARALLEL) && ! defined(STUBMPI) ) max_sa = wrf_dm_max_real ( max_sa ) #endif - IF ( max_sa .GT. ABS(config_flags%max_sa_gwd) ) THEN - WRITE ( a_message , FMT='(A,F5.2)' ) 'Max ABS(sina) for domain 1 = ',max_sa + IF ( max_rot_angle .GT. ABS(config_flags%max_rot_angle_gwd) ) THEN + WRITE ( a_message , FMT='(A,F5.2)' ) 'Max projection rotation angle for domain 1 = ',max_rot_angle CALL wrf_message ( a_message ) WRITE ( a_message , FMT='(A)' ) 'This projection may not be appropriate for using the gravity wave drag option.' CALL wrf_message ( a_message ) - WRITE ( a_message , FMT='(A,F5.2)' ) 'In namelist.input set either: 1) gwd_opt=0 or 2) max_sa_gwd>',max_sa + WRITE ( a_message , FMT='(A)' ) 'In namelist.input make one of the two following changes:' + CALL wrf_message ( a_message ) + WRITE ( a_message , FMT='(A)' ) ' 1) gwd_opt = 0 ' + CALL wrf_message ( a_message ) + WRITE ( a_message , FMT='(A,F5.2)' ) ' 2) max_rot_angle_gwd > ',max_rot_angle + CALL wrf_message ( a_message ) + WRITE ( a_message , FMT='(A)' ) '--- ERROR: gwd_opt does not work with this domain' CALL wrf_error_fatal ( a_message ) END IF END IF From f6981094314df697035078efc55fcc89f6672dab Mon Sep 17 00:00:00 2001 From: Dave Gill Date: Fri, 24 Mar 2017 16:15:41 -0600 Subject: [PATCH 7/7] left-over "max_sa" inside of ifdef, not hit during serial test, thanks Jamie --- dyn_em/start_em.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dyn_em/start_em.F b/dyn_em/start_em.F index f09cf246c6..4e71bb11fb 100644 --- a/dyn_em/start_em.F +++ b/dyn_em/start_em.F @@ -172,7 +172,7 @@ SUBROUTINE start_domain_em ( grid, allowed_to_read & END DO END DO #if ( defined(DM_PARALLEL) && ! defined(STUBMPI) ) - max_sa = wrf_dm_max_real ( max_sa ) + max_rot_angle = wrf_dm_max_real ( max_rot_angle ) #endif IF ( max_rot_angle .GT. ABS(config_flags%max_rot_angle_gwd) ) THEN WRITE ( a_message , FMT='(A,F5.2)' ) 'Max projection rotation angle for domain 1 = ',max_rot_angle