added checking for ir,jr in case of bad namelists
[wrffire.git] / standalone / wrf_fakes.F
blob512b0d672eb77667b9158d153bc77a1b6003ca08
1 ! wrf_fakes.F
2 ! things that would be normally done in WRF
4 module module_model_constants
5 ! The model may not define any physical constants, all must be done here.
6 ! copied what needed from WRFV3/share/module_model_constants.F
7    REAL   , PARAMETER :: r_d          = 287.
8    REAL   , PARAMETER :: cp           = 7.*r_d/2.   ! specific heat of the atmosphere
9    REAL   , PARAMETER :: xlv          = 2.5E6       ! latent heat
10    REAL   , PARAMETER ::  pi2=2.*3.1415926          ! 2*pi
11    REAL   , PARAMETER :: reradius     = 1./6370.0e03 ! 1/earth radius
12    REAL   , PARAMETER :: g            = 9.81        ! gravity acceleration
13 end module module_model_constants
16 !***
19 module module_wrf_error
20 implicit none
21 contains
23 ! mock-up of various wrf utility functions
25 subroutine wrf_error_fatal(s)
26 !*** purpose: abort with a message
27 implicit none
28 character(len=*), intent(in)::s
29 call latch ! food for debugger so you can say "stop at latch" and not worry about module name
30 write(6,*)s
31 call abort()
32 end subroutine wrf_error_fatal
35 !***
38 subroutine wrf_debug(level,s)
39 !*** purpose: print a message
41 implicit none
42 character(len=*), intent(in)::s
43 integer, intent(in):: level
44 write(6,*)s
45 end subroutine wrf_debug
48 !***
51 subroutine wrf_message(s)
52 character(len=*), intent(in)::s
53 integer i
54 do i=len(s),2,-1
55     select case(s(i:i))
56     case(' ')
57     case default
58         goto 1
59     end select
60 enddo
61 1 write(6,'(a)')s(1:i)
62 end subroutine wrf_message
64 end module module_wrf_error
67 !***
70 ! just for testing
71 subroutine latch
72 end
75 !*** various stubs, mostly doing nothing
78 module module_dm
79 use module_wrf_error
80 implicit none
81 contains
82 subroutine wrf_get_nproc (nprocs)
83 integer nprocs
84 nprocs=1
85 end subroutine wrf_get_nproc
88 !***
91 subroutine wrf_get_myproc( myproc )
92 integer myproc
93 myproc=1
94 end subroutine wrf_get_myproc
97 !***
100 subroutine wrf_dm_maxval_integer( val, idex, jdex )
101 integer::val
102 integer::idex,jdex
103 call wrf_error_fatal('wrf_dm_maxval_integer:not implemented')
104 end subroutine wrf_dm_maxval_integer
106 end module module_dm
109 !*** external stubs
113 SUBROUTINE wrf_dm_bcast_real( BUF, N1 )
114    IMPLICIT NONE
115    INTEGER n1
116    REAL  buf(*)
117    RETURN
118 END SUBROUTINE wrf_dm_bcast_real
121 !***
124 LOGICAL FUNCTION wrf_dm_on_monitor()
125   wrf_dm_on_monitor = .true.
126 END FUNCTION wrf_dm_on_monitor
129 !***
132 SUBROUTINE wrf_dm_bcast_integer( BUF, N1 )
133    IMPLICIT NONE
134    INTEGER n1
135    INTEGER  buf(*)
136    RETURN
137 END SUBROUTINE wrf_dm_bcast_integer
140 !WRF:DRIVER_LAYER:UTIL
143 MODULE module_timing
144    use module_wrf_error 
146    INTEGER, PARAMETER, PRIVATE :: cnmax = 30
147    INTEGER, PRIVATE, DIMENSION(cnmax) :: count_int1 , count_rate_int1 , count_max_int1
148    INTEGER, PRIVATE, DIMENSION(cnmax) :: count_int2 , count_rate_int2 , count_max_int2
149    INTEGER, PRIVATE :: cn = 0 
150    REAL, PRIVATE    :: elapsed_seconds , elapsed_seconds_total = 0
151    REAL, PRIVATE    :: cpu_1 , cpu_2 , cpu_seconds , cpu_seconds_total = 0
152    data cn /0/
154 CONTAINS
156    SUBROUTINE init_module_timing
157       cn = 0
158    END SUBROUTINE init_module_timing
161    SUBROUTINE start_timing
163       IMPLICIT NONE
165       cn = cn + 1
166       IF ( cn .gt. cnmax ) THEN
167         CALL  wrf_error_fatal( 'module_timing: clock nesting error (too many nests)' )
168         RETURN
169       ENDIF
170       CALL SYSTEM_CLOCK ( count_int1(cn) , count_rate_int1(cn) , count_max_int1(cn) )
171 !     CALL CPU_TIME ( cpu_1 )
173    END SUBROUTINE start_timing
176    SUBROUTINE end_timing ( string )
177    
178       IMPLICIT NONE
180       CHARACTER *(*) :: string
182       IF ( cn .lt. 1 ) THEN
183         CALL  wrf_error_fatal( 'module_timing: clock nesting error, cn<1' ) 
184       ELSE IF ( cn .gt. cnmax ) THEN
185         CALL  wrf_error_fatal( 'module_timing: clock nesting error, cn>cnmax' ) 
186       ENDIF
188       CALL SYSTEM_CLOCK ( count_int2(cn) , count_rate_int2(cn) , count_max_int2(cn) )
189 !     CALL CPU_TIME ( cpu_2 )
191       IF ( count_int2(cn) < count_int1(cn) ) THEN
192          count_int2(cn) = count_int2(cn) + count_max_int2(cn)
193       ENDIF
195       count_int2(cn) = count_int2(cn) - count_int1(cn)
196       elapsed_seconds = REAL(count_int2(cn)) / REAL(count_rate_int2(cn))
197       elapsed_seconds_total = elapsed_seconds_total + elapsed_seconds
199       WRITE(6,'(A,A,A,F10.5,A)') 'Timing for ',TRIM(string),': ',elapsed_seconds,' elapsed seconds.'
200 #if defined(DM_PARALLEL) && ! defined(STUBMPI)
201       WRITE(0,'(A,A,A,F10.5,A)') 'Timing for ',TRIM(string),': ',elapsed_seconds,' elapsed seconds.'
202 #endif
204 !     cpu_seconds = cpu_2 - cpu_1
205 !     cpu_seconds_total = cpu_seconds_total + cpu_seconds
206 !     PRINT '(A,A,A,F10.5,A)' ,'Timing for ',TRIM(string),': ',cpu_seconds,' cpu seconds.'
208       cn = cn - 1
210    END SUBROUTINE end_timing
212 END MODULE module_timing