Changeset 4434 for palm/trunk/SOURCE


Ignore:
Timestamp:
Mar 3, 2020 10:02:18 AM (4 years ago)
Author:
oliver.maas
Message:

added optional netcdf data input for wtm array input parameters

Location:
palm/trunk/SOURCE
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/Makefile

    r4420 r4434  
    13031303        cpulog_mod.o \
    13041304        data_output_module.o \
     1305        netcdf_data_input_mod.o \
    13051306        mod_kinds.o \
    13061307        modules.o
  • palm/trunk/SOURCE/netcdf_data_input_mod.f90

    r4404 r4434  
    2525! -----------------
    2626! $Id$
     27! added optional netcdf data input for wtm array input parameters
     28!
     29! 4404 2020-02-12 17:01:53Z suehring
    2730! Fix misplaced preprocessor directives.
    2831!
     
    646649    CHARACTER(LEN=100) ::  input_file_uvem    = 'PIDS_UVEM'    !< Name of file which comprises static uv_exposure model input data
    647650    CHARACTER(LEN=100) ::  input_file_vm      = 'PIDS_VM'      !< Name of file which comprises virtual measurement data
    648    
     651    CHARACTER(LEN=100) ::  input_file_wtm     = 'PIDS_WTM'     !< Name of file which comprises wind turbine model input data
     652       
    649653    CHARACTER(LEN=25), ALLOCATABLE, DIMENSION(:) ::  string_values  !< output of string variables read from netcdf input files
    650654    CHARACTER(LEN=50), DIMENSION(:), ALLOCATABLE ::  vars_pids      !< variable in input file
     
    661665    LOGICAL ::  input_pids_uvem    = .FALSE.   !< Flag indicating whether uv-expoure-model input file containing static information exists
    662666    LOGICAL ::  input_pids_vm      = .FALSE.   !< Flag indicating whether input file for virtual measurements exist
     667    LOGICAL ::  input_pids_wtm     = .FALSE.   !< Flag indicating whether input file for wind turbine model exists
    663668
    664669    LOGICAL ::  collective_read = .FALSE.      !< Enable NetCDF collective read
     
    764769           input_pids_static,                                                  &
    765770           input_pids_dynamic, input_pids_vm, input_file_vm,                   &
     771           input_pids_wtm, input_file_wtm,                                     &
    766772           num_var_pids,                                                       &
    767773           pavement_pars_f, pavement_subsurface_pars_f, pavement_type_f,       &
     
    827833       INQUIRE( FILE = TRIM( input_file_vm )      // TRIM( coupling_char ),    &
    828834                EXIST = input_pids_vm )
     835       INQUIRE( FILE = TRIM( input_file_wtm )     // TRIM( coupling_char ),    &
     836                EXIST = input_pids_wtm )
    829837#endif
    830838
  • palm/trunk/SOURCE/wind_turbine_model_mod.f90

    r4426 r4434  
    2626! -----------------
    2727! $Id$
     28! added optional netcdf data input for wtm array input parameters
     29!
     30! 4426 2020-02-27 10:02:19Z oliver.maas
    2831! define time as unlimited dimension so that no maximum number
    2932! of time steps has to be given for wtm_data_output
     
    145148    USE kinds
    146149
     150    USE netcdf_data_input_mod,                                                 &
     151        ONLY:  check_existence,                                                &
     152               close_input_file,                                               &
     153               get_variable,                                                   &
     154               input_pids_wtm,                                                 &
     155               inquire_num_variables,                                          &
     156               inquire_variable_names,                                         &
     157               input_file_wtm,                                                 &
     158               num_var_pids,                                                   &
     159               open_read_file,                                                 &
     160               pids_id,                                                        &
     161               vars_pids
     162   
    147163    USE pegrid
    148164
     
    479495    SUBROUTINE wtm_parin
    480496
    481 
    482497       IMPLICIT NONE
    483        
     498
    484499       CHARACTER (LEN=80) ::  line  !< dummy string that contains the current line of the parameter file
    485500
    486                                  
    487501       NAMELIST /wind_turbine_parameters/                                      &
    488502                                  air_dens, dtow, dt_data_output_wtm, gear_eff,&
     
    520534       CALL parin_fail_message( 'wind_turbine_parameters', line )
    521535
    522 
    523536 12    CONTINUE   ! TBD Change from continue, mit ierrn machen
    524 
    525537
    526538    END SUBROUTINE wtm_parin
     
    635647       IMPLICIT NONE
    636648   
    637        IF ( ( .NOT.speed_control ) .AND. pitch_control )  THEN
    638           message_string = 'pitch_control = .TRUE. requires '//                &
    639                            'speed_control = .TRUE.'
    640           CALL message( 'wtm_check_parameters', 'PA0461', 1, 2, 0, 6, 0 )
     649       IF ( .NOT. input_pids_wtm )  THEN
     650          IF ( ( .NOT.speed_control ) .AND. pitch_control )  THEN
     651             message_string = 'pitch_control = .TRUE. requires '//                &
     652                               'speed_control = .TRUE.'
     653             CALL message( 'wtm_check_parameters', 'PA0461', 1, 2, 0, 6, 0 )
     654          ENDIF
     655         
     656          IF ( ANY( omega_rot(1:nturbines) < 0.0 ) )  THEN
     657             message_string = 'omega_rot < 0.0, Please set omega_rot to '     // &
     658                               'a value equal or larger than zero'
     659             CALL message( 'wtm_check_parameters', 'PA0462', 1, 2, 0, 6, 0 )
     660          ENDIF
     661         
     662         
     663          IF ( ANY( rcx(1:nturbines) == 9999999.9_wp ) .OR.                       &
     664                ANY( rcy(1:nturbines) == 9999999.9_wp ) .OR.                       &
     665                ANY( rcz(1:nturbines) == 9999999.9_wp ) )  THEN
     666             
     667             message_string = 'rcx, rcy, rcz '                                 // &
     668                               'have to be given for each turbine.'         
     669             CALL message( 'wtm_check_parameters', 'PA0463', 1, 2, 0, 6, 0 )         
     670          ENDIF
    641671       ENDIF
    642672       
    643        IF ( ANY( omega_rot(1:nturbines) < 0.0 ) )  THEN
    644           message_string = 'omega_rot < 0.0, Please set omega_rot to '     // &
    645                            'a value equal or larger than zero'
    646           CALL message( 'wtm_check_parameters', 'PA0462', 1, 2, 0, 6, 0 )
    647        ENDIF
    648        
    649        
    650        IF ( ANY( rcx(1:nturbines) == 9999999.9_wp ) .OR.                       &
    651             ANY( rcy(1:nturbines) == 9999999.9_wp ) .OR.                       &
    652             ANY( rcz(1:nturbines) == 9999999.9_wp ) )  THEN
    653          
    654           message_string = 'rcx, rcy, rcz '                                 // &
    655                            'have to be given for each turbine.'         
    656           CALL message( 'wtm_check_parameters', 'PA0463', 1, 2, 0, 6, 0 )         
    657          
    658        ENDIF
    659 
    660673    END SUBROUTINE wtm_check_parameters
    661674!     
     
    668681    SUBROUTINE wtm_init_arrays
    669682
    670 
    671683       IMPLICIT NONE
    672684
    673685       REAL(wp) ::  delta_r_factor   !<
    674686       REAL(wp) ::  delta_r_init     !<
     687
     688!
     689! Read wtm input file (netcdf) if it exists
     690       IF ( input_pids_wtm )  THEN
     691
     692!
     693!--       Open the wtm  input file
     694#if defined( __netcdf )
     695          CALL open_read_file( TRIM( input_file_wtm ) //                       &
     696                               TRIM( coupling_char ), pids_id )
     697
     698          CALL inquire_num_variables( pids_id, num_var_pids )
     699
     700!
     701!--       Allocate memory to store variable names and read them
     702          ALLOCATE( vars_pids(1:num_var_pids) )
     703          CALL inquire_variable_names( pids_id, vars_pids )
     704
     705!
     706!--       Input of all wtm parameters
     707          IF ( check_existence( vars_pids, 'dtow' ) )  THEN
     708             CALL get_variable( pids_id, 'dtow', dtow(1:nturbines))
     709          ENDIF
     710
     711          IF ( check_existence( vars_pids, 'omega_rot' ) )  THEN
     712             CALL get_variable( pids_id, 'omega_rot', omega_rot(1:nturbines))
     713          ENDIF
     714
     715          IF ( check_existence( vars_pids, 'pitch_add' ) )  THEN
     716             CALL get_variable( pids_id, 'pitch_add', pitch_add(1:nturbines))
     717          ENDIF
     718
     719          IF ( check_existence( vars_pids, 'phi_yaw' ) )  THEN
     720             CALL get_variable( pids_id, 'phi_yaw', phi_yaw(1:nturbines))
     721          ENDIF
     722
     723          IF ( check_existence( vars_pids, 'rcx' ) )  THEN
     724             CALL get_variable( pids_id, 'rcx', rcx(1:nturbines))
     725          ENDIF
     726
     727          IF ( check_existence( vars_pids, 'rcy' ) )  THEN
     728             CALL get_variable( pids_id, 'rcy', rcy(1:nturbines))
     729          ENDIF
     730
     731          IF ( check_existence( vars_pids, 'rcz' ) )  THEN
     732             CALL get_variable( pids_id, 'rcz', rcz(1:nturbines))
     733          ENDIF
     734
     735          IF ( check_existence( vars_pids, 'rnac' ) )  THEN
     736             CALL get_variable( pids_id, 'rnac', rnac(1:nturbines))
     737          ENDIF
     738
     739          IF ( check_existence( vars_pids, 'rr' ) )  THEN
     740             CALL get_variable( pids_id, 'rr', rr(1:nturbines))
     741          ENDIF
     742!
     743!           IF ( check_existence( vars_pids, 'turb_cd_nacelle' ) )  THEN
     744!              CALL get_variable( pids_id, 'turb_cd_nacelle', turb_cd_nacelle(1:nturbines))
     745!           ENDIF
     746
     747          IF ( check_existence( vars_pids, 'turb_cd_tower' ) )  THEN
     748             CALL get_variable( pids_id, 'turb_cd_tower', turb_cd_tower(1:nturbines))
     749          ENDIF
     750!
     751!--       Close wtm input file
     752          CALL close_input_file( pids_id )
     753
     754       ENDIF
     755#endif
    675756
    676757!
     
    12731354       CALL wtm_read_blade_tables
    12741355
    1275        
    1276    
    1277        
    1278      
    12791356       IF ( debug_output )  CALL debug_message( 'wtm_init', 'end' )
    12801357 
     
    22162293!--                and the direction of the flow relative to the rotor:
    22172294
    2218                    phi_rel(rseg) = ATAN( u_rot /                               &
     2295                   phi_rel(rseg) = ATAN2( u_rot ,                               &
    22192296                                         ( omega_rot(inot) * cur_r -           &
    22202297                                           vtheta(rseg) ) )
     
    25742651!--          Can't be allocated before dt_3d is set
    25752652             IF ( start_up )  THEN
    2576                 WDLON = NINT( 30.0_wp / dt_3d )  ! 30s running mean array
     2653                WDLON = MAX( 1 , NINT( 30.0_wp / dt_3d ) )  ! 30s running mean array
    25772654                ALLOCATE( wd30(1:nturbines,1:WDLON) )
    25782655                wd30 = 999.0_wp                  ! Set to dummy value
    25792656                ALLOCATE( wd30_l(1:WDLON) )
    25802657               
    2581                 WDSHO = NINT( 2.0_wp / dt_3d )   ! 2s running mean array
     2658                WDSHO = MAX( 1 , NINT( 2.0_wp / dt_3d ) )   ! 2s running mean array
    25822659                ALLOCATE( wd2(1:nturbines,1:WDSHO) )
    25832660                wd2 = 999.0_wp                   ! Set to dummy value
Note: See TracChangeset for help on using the changeset viewer.