Ignore:
Timestamp:
Feb 24, 2026, 9:59:11 AM (9 days ago)
Author:
emillour
Message:

Generic PCM:
OpenMP bug fix in "rad_correlatedk_stellar_spectrum", all intermediate computations
should be done by all OpenMp? threads.
While at it did some cleanup:

  • added some OMP threadprivate statements in radcommon_h.F90 (not alwyas necessary, but best practice is that all saved variables be threadprivate)
  • turned rad_blackbody.F into a module and modernized routines.
  • use clearer stategy (wrt OpenMP) in "rad_correlatedk_init_thermal.F90" and "rad_correlatedk_init_stellar.F90": have the master read in file and data and then broadcast to all cores.

EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.GENERIC/libf/phygeneric/rad_correlatedk_init_stellar.F90

    r4077 r4081  
    3434      use callkeys_mod, only: Fat1AU
    3535      use rad_correlatedk_stellar_spectrum_mod, only: rad_correlatedk_stellar_spectrum
     36      use mod_phys_lmdz_para, only : is_master, bcast
    3637
    3738      implicit none
     
    7475      endif
    7576       
    76 !$OMP MASTER       
    77       nb=0
    78       ierr=0
    79       ! check that the file contains the right number of bands
    80       open(131,file=file_path,form='formatted')
    81       read(131,*,iostat=ierr) file_entries
    82       do while (ierr==0)
     77      if (is_master) then ! only the master needs to read in BWNV(:) from file
     78       nb=0
     79       ierr=0
     80       ! check that the file contains the right number of bands
     81       open(131,file=file_path,form='formatted')
     82       read(131,*,iostat=ierr) file_entries
     83       do while (ierr==0)
    8384        read(131,*,iostat=ierr) dummy
    8485        if (ierr==0) nb=nb+1
    85       enddo
    86       close(131)
     86       enddo
     87       close(131)
    8788
    88       write(*,*) 'rad_correlatedk_init_stellar: L_NSPECTV = ',L_NSPECTV, 'in the model '
    89       write(*,*) '        there are   ',nb, 'entries in ',TRIM(file_path)
    90       if(nb.ne.L_NSPECTV) then
     89       write(*,*) 'rad_correlatedk_init_stellar: L_NSPECTV = ',L_NSPECTV, 'in the model '
     90       write(*,*) '        there are   ',nb, 'entries in ',TRIM(file_path)
     91       if(nb.ne.L_NSPECTV) then
    9192         write(*,*) 'MISMATCH !! I stop here'
    9293         call abort_physic("rad_correlatedk_init_stellar","The number of entries in narrowbands_VI.in does not match with L_NSPECTV",1)
    93       endif
     94       endif
    9495
    95       ! load and display the data
    96       open(111,file=file_path,form='formatted')
    97       read(111,*)
    98        do M=1,L_NSPECTV-1
     96       ! load and display the data
     97       open(111,file=file_path,form='formatted')
     98       read(111,*)
     99        do M=1,L_NSPECTV-1
    99100         read(111,*) BWNV(M)
    100       end do
    101       read(111,*) lastband
    102       close(111)
    103       BWNV(L_NSPECTV)  =lastband(1)
    104       BWNV(L_NSPECTV+1)=lastband(2)
    105 !$OMP END MASTER
    106 !$OMP BARRIER
     101       end do
     102       read(111,*) lastband
     103       close(111)
     104       BWNV(L_NSPECTV)  =lastband(1)
     105       BWNV(L_NSPECTV+1)=lastband(2)
    107106
    108       print*,'rad_correlatedk_init_stellar: VI band limits:'
    109       do M=1,L_NSPECTV+1
     107       print*,'rad_correlatedk_init_stellar: VI band limits:'
     108       do M=1,L_NSPECTV+1
    110109         print*,m,'-->',BWNV(M),' cm^-1'
    111       end do
    112       print*,' '
     110       end do
     111       print*,' '
     112      endif ! of if (is_master)
     113
     114      ! Broadcast BWNV to all cores
     115      call bcast(BWNV)
    113116
    114117!     Set up mean wavenumbers and wavenumber deltas.  Units of
Note: See TracChangeset for help on using the changeset viewer.